Skip to content
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

On incorrect cfg literal/identifier, point at the right span #58961

Merged
merged 2 commits into from
Mar 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/libsyntax/parse/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ impl<'a> Parser<'a> {
}

let found = self.this_token_to_string();
let msg = format!("expected unsuffixed literal or identifier, found {}", found);
Err(self.diagnostic().struct_span_err(lo, &msg))
let msg = format!("expected unsuffixed literal or identifier, found `{}`", found);
Err(self.diagnostic().struct_span_err(self.span, &msg))
}

/// matches meta_seq = ( COMMASEP(meta_item_inner) )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct S9;
macro_rules! generate_s10 {
($expr: expr) => {
#[cfg(feature = $expr)]
//~^ ERROR expected unsuffixed literal or identifier, found concat!("nonexistent")
//~^ ERROR expected unsuffixed literal or identifier, found `concat!("nonexistent")`
struct S10;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ error[E0565]: literal in `cfg` predicate value must be a string
LL | #[cfg(a = b"hi")] //~ ERROR literal in `cfg` predicate value must be a string
| ^^^^^ help: consider removing the prefix: `"hi"`

error: expected unsuffixed literal or identifier, found concat!("nonexistent")
--> $DIR/cfg-attr-syntax-validation.rs:30:15
error: expected unsuffixed literal or identifier, found `concat!("nonexistent")`
--> $DIR/cfg-attr-syntax-validation.rs:30:25
|
LL | #[cfg(feature = $expr)]
| ^^^^^^^
| ^^^^^
...
LL | generate_s10!(concat!("nonexistent"));
| -------------------------------------- in this macro invocation
Expand Down