-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compiler panics unexpectedly in 1.31 when constructing struct with wrong syntax #56611
Comments
|
I'm presently looking into this. Let me know if you have thoughts please, @estebank. |
@alexreg the ICE happens because of the unconditional attempt to get the span for the given defid: rust/src/librustc_typeck/check/callee.rs Line 283 in 3a75e80
You will need to add a check for I don't think this existing code already handles the "used parens instead of braces" case, but there's code to account for it which might have to also be adjusted. |
Marking as regression because it affects stable (even though the feature that caused this can't be used, it still can be triggered). |
@estebank Yep, after looking into this more myself, this was my conclusion too. That said, I found out that adding tcx.sess.span_err(span, "the `Self` constructor can only be used with \
tuple structs"); above the line |
Okay, I think I've figured this out. Added a |
Implement RFC 2338, "Type alias enum variants" This PR implements [RFC 2338](rust-lang/rfcs#2338), allowing one to write code like the following. ```rust #![feature(type_alias_enum_variants)] enum Foo { Bar(i32), Baz { i: i32 }, } type Alias = Foo; fn main() { let t = Alias::Bar(0); let t = Alias::Baz { i: 0 }; match t { Alias::Bar(_i) => {} Alias::Baz { i: _i } => {} } } ``` Since `Self` can be considered a type alias in this context, it also enables using `Self::Variant` as both a constructor and pattern. Fixes issues #56199 and #56611. N.B., after discussing the syntax for type arguments on enum variants with @petrochenkov and @eddyb (there are also a few comments on the [tracking issue](#49683)), the consensus seems to be treat the syntax as follows, which ought to be backwards-compatible. ```rust Option::<u8>::None; // OK Option::None::<u8>; // OK, but lint in near future (hard error next edition?) Alias::<u8>::None; // OK Alias::None::<u8>; // Error ``` I do not know if this will need an FCP, but let's start one if so. r? @petrochenkov
visiting for triage. No change necessary to meta-data (still P-high, still fixed by PR #55994, which has not yet landed). |
Implement RFC 2338, "Type alias enum variants" This PR implements [RFC 2338](rust-lang/rfcs#2338), allowing one to write code like the following. ```rust #![feature(type_alias_enum_variants)] enum Foo { Bar(i32), Baz { i: i32 }, } type Alias = Foo; fn main() { let t = Alias::Bar(0); let t = Alias::Baz { i: 0 }; match t { Alias::Bar(_i) => {} Alias::Baz { i: _i } => {} } } ``` Since `Self` can be considered a type alias in this context, it also enables using `Self::Variant` as both a constructor and pattern. Fixes issues #56199 and #56611. N.B., after discussing the syntax for type arguments on enum variants with @petrochenkov and @eddyb (there are also a few comments on the [tracking issue](#49683)), the consensus seems to be treat the syntax as follows, which ought to be backwards-compatible. ```rust Option::<u8>::None; // OK Option::None::<u8>; // OK, but lint in near future (hard error next edition?) Alias::<u8>::None; // OK Alias::None::<u8>; // Error ``` I do not know if this will need an FCP, but let's start one if so.
@alexreg could a backport against beta be prepared? |
Seems to have been backported via #57236. |
The compiler crashes when constructing a struct syntactically wrong.
Simply paste the code below into the playground.
I tried this code:
This is the compiler output:
The text was updated successfully, but these errors were encountered: