Skip to content

Commit

Permalink
not suggest if span originates in a derive-macro's expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
TaKO8Ki committed Apr 10, 2022
1 parent f50da2e commit f49601d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_parse/src/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,7 @@ impl<'a> Parser<'a> {
}
let enum_field_start_span = this.token.span;
let ident = this.parse_field_ident("enum", vlo)?;
if this.token.kind == token::Colon {
if this.token.kind == token::Colon && !start_span.in_derive_expansion() {
let snapshot = this.clone();
this.bump();
match this.parse_ty() {
Expand Down Expand Up @@ -1612,7 +1612,7 @@ impl<'a> Parser<'a> {
{
let snapshot = self.clone();
if let Err(err) = self.parse_ty() {
if let Some(span) = start_span {
if let Some(span) = start_span && !span.in_derive_expansion() {
error.span_suggestion_verbose(
span,
"consider using `enum` instead of `struct`",
Expand Down
4 changes: 0 additions & 4 deletions src/test/ui/proc-macro/derive-bad.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ LL | #[derive(A)]
| ^ expected `:`
|
= note: this error originates in the derive macro `A` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider using `enum` instead of `struct`
|
LL | #[derive(enum)]
| ~~~~

error: proc-macro derive produced unparseable tokens
--> $DIR/derive-bad.rs:6:10
Expand Down

0 comments on commit f49601d

Please sign in to comment.