Rollup merge of #58961 - estebank:issue-58462, r=varkor

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

CC #58462
This commit is contained in:
Pietro Albini 2019-03-08 09:42:09 +01:00 committed by GitHub
commit 54a5073af9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View file

@ -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) )

View file

@ -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;
}
}

View file

@ -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