From 669be1a0a6ffe8e57ac9a0182e085ff9d9910743 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 5 Mar 2019 19:05:03 -0800 Subject: [PATCH] On incorrect cfg literal/identifier, point at the right span --- src/libsyntax/parse/attr.rs | 2 +- .../conditional-compilation/cfg-attr-syntax-validation.stderr | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index e7937f57002..6c02a7407e0 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -286,7 +286,7 @@ fn parse_meta_item_inner(&mut self) -> PResult<'a, ast::NestedMetaItem> { 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)) + Err(self.diagnostic().struct_span_err(self.span, &msg)) } /// matches meta_seq = ( COMMASEP(meta_item_inner) ) diff --git a/src/test/ui/conditional-compilation/cfg-attr-syntax-validation.stderr b/src/test/ui/conditional-compilation/cfg-attr-syntax-validation.stderr index bcf13ead2f4..0770d1038e1 100644 --- a/src/test/ui/conditional-compilation/cfg-attr-syntax-validation.stderr +++ b/src/test/ui/conditional-compilation/cfg-attr-syntax-validation.stderr @@ -53,10 +53,10 @@ LL | #[cfg(a = b"hi")] //~ ERROR literal in `cfg` predicate value must be a str | ^^^^^ help: consider removing the prefix: `"hi"` error: expected unsuffixed literal or identifier, found concat!("nonexistent") - --> $DIR/cfg-attr-syntax-validation.rs:30:15 + --> $DIR/cfg-attr-syntax-validation.rs:30:25 | LL | #[cfg(feature = $expr)] - | ^^^^^^^ + | ^^^^^ ... LL | generate_s10!(concat!("nonexistent")); | -------------------------------------- in this macro invocation