Comments (8)
from rust.
wtf. why does that wrong comma cause the struct to be different from a struct with no fields
from rust.
minimized
struct X {,}
fn main() {
|| {
if let X { x: 1,} = (X {}) {}
};
}
from rust.
wtf. why does that wrong comma cause the struct to be different from a struct with no fields
An extra ,
is a recovered struct variant, and it is skipped here:
rust/compiler/rustc_hir_typeck/src/pat.rs
Line 1533 in 382148d
so we didn't emit the error like an empty struct:
rust/compiler/rustc_hir_typeck/src/pat.rs
Line 1610 in 382148d
error[E0026]: struct `X` does not have a field named `x`
--> src/main.rs:5:20
|
5 | if let X { x: 1,} = (X {}) {}
| ^ struct `X` does not have this field
So the compiler continues until the ICE point.
I think a trivial fix will be ok here?
from rust.
Hmm... I'd look into reporting that error even for recovered structs and figuring out how to avoid it just for the cases that this skip was intended to avoid
from rust.
seems there is nothing else we are trying to avoid:
I'd prefer not to report the no-field error, since the first error in parsing will point out the root cause, and there is a case like #126344, which may introduce noise when there are too many type errors, it's also applied to this issue.
from rust.
Oh... we can probably just replace the is_recovered
method with a new tainted_by_errors
method and return an Result<(), ErrorGuaranteed>
. This way we act as if we reported an error, and thus not continue to the ICE
from rust.
Since we cannot encode an ErrorGuaranteed
in the flags list, either take a TyCtxt
argument on the tainted_by_errors
method, or check if replacing the field
field with Result<IndexVec<FieldIdx, FieldDef>, ErrorGuaranteed>
works out nicely
from rust.
Related Issues (20)
- Different codegen between literal and constant on `bitwise-copy` struct HOT 4
- `allow_internal_unstable` can be used to bypass `incomplete_features` warning
- ICE: `unexpected const arg parent in type_of()` HOT 1
- Dollar sign is handled incorrectly for section names in inline-assembly on Windows platform HOT 6
- Overflow in RPITIT HOT 1
- Bootstrap should skip preparing a linker for targets when checking std HOT 4
- Regression in type inferencing in 1.80.0 HOT 2
- Proposal: stabilize `const_refs_to_static` HOT 4
- Release notes for 1.80.0 are missing on GitHub HOT 1
- ICE: `expected item, found (root_crate)`
- ICE: missing type for `static` item crashes due to LazyCell/LazyLock HOT 1
- Detect unsized expressions that are deref expressions like `*""`
- Tracking Issue for `rwlock_downgrade` HOT 4
- Surprising behavior of `'label: for`
- `slice.iter().take_while(f).count()` produces suboptimal assembly code HOT 1
- Incorrect code generated from inline assembly with `inout` register on riscv32im-unknown-none-elf HOT 6
- Performance regression with `get_many_mut()` HOT 1
- The compiler does not report errors for recursive calls that can not be ended HOT 2
- x86_64-win7-windows-msvc target cannot run HOT 11
- Permit library-only and binary-only dependencies HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust.