File tree Expand file tree Collapse file tree 2 files changed +2
-6
lines changed
compiler/rustc_parse/src/parser Expand file tree Collapse file tree 2 files changed +2
-6
lines changed Original file line number Diff line number Diff line change @@ -1231,7 +1231,7 @@ impl<'a> Parser<'a> {
12311231 }
12321232 let enum_field_start_span = this. token . span ;
12331233 let ident = this. parse_field_ident ( "enum" , vlo) ?;
1234- if this. token . kind == token:: Colon {
1234+ if this. token . kind == token:: Colon && !start_span . in_derive_expansion ( ) {
12351235 let snapshot = this. clone ( ) ;
12361236 this. bump ( ) ;
12371237 match this. parse_ty ( ) {
@@ -1612,7 +1612,7 @@ impl<'a> Parser<'a> {
16121612 {
16131613 let snapshot = self . clone ( ) ;
16141614 if let Err ( err) = self . parse_ty ( ) {
1615- if let Some ( span) = start_span {
1615+ if let Some ( span) = start_span && !span . in_derive_expansion ( ) {
16161616 error. span_suggestion_verbose (
16171617 span,
16181618 "consider using `enum` instead of `struct`" ,
Original file line number Diff line number Diff line change @@ -5,10 +5,6 @@ LL | #[derive(A)]
55 | ^ expected `:`
66 |
77 = note: this error originates in the derive macro `A` (in Nightly builds, run with -Z macro-backtrace for more info)
8- help: consider using `enum` instead of `struct`
9- |
10- LL | #[derive(enum)]
11- | ~~~~
128
139error: proc-macro derive produced unparseable tokens
1410 --> $DIR/derive-bad.rs:6:10
You can’t perform that action at this time.
0 commit comments