Skip to content

Commit 54a5073

Browse files
authored
Rollup merge of rust-lang#58961 - estebank:issue-58462, r=varkor
On incorrect cfg literal/identifier, point at the right span CC rust-lang#58462
2 parents 1d33fc9 + 02eb523 commit 54a5073

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/libsyntax/parse/attr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ impl<'a> Parser<'a> {
285285
}
286286

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

292292
/// matches meta_seq = ( COMMASEP(meta_item_inner) )

src/test/ui/conditional-compilation/cfg-attr-syntax-validation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ struct S9;
2828
macro_rules! generate_s10 {
2929
($expr: expr) => {
3030
#[cfg(feature = $expr)]
31-
//~^ ERROR expected unsuffixed literal or identifier, found concat!("nonexistent")
31+
//~^ ERROR expected unsuffixed literal or identifier, found `concat!("nonexistent")`
3232
struct S10;
3333
}
3434
}

src/test/ui/conditional-compilation/cfg-attr-syntax-validation.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ error[E0565]: literal in `cfg` predicate value must be a string
5252
LL | #[cfg(a = b"hi")] //~ ERROR literal in `cfg` predicate value must be a string
5353
| ^^^^^ help: consider removing the prefix: `"hi"`
5454

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

0 commit comments

Comments
 (0)