about summary refs log tree commit diff
path: root/tests/ui/macros/macro-paren-span-diagnostic.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/macros/macro-paren-span-diagnostic.rs')
-rw-r--r--tests/ui/macros/macro-paren-span-diagnostic.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/ui/macros/macro-paren-span-diagnostic.rs b/tests/ui/macros/macro-paren-span-diagnostic.rs
new file mode 100644
index 00000000000..c8cb63d5190
--- /dev/null
+++ b/tests/ui/macros/macro-paren-span-diagnostic.rs
@@ -0,0 +1,21 @@
+// Be smart about span of parenthesized expression in macro.
+
+macro_rules! paren {
+    ($e:expr) => (($e))
+    //            ^^^^ do not highlight here
+}
+
+mod m {
+    pub struct S {
+        x: i32
+    }
+    pub fn make() -> S {
+        S { x: 0 }
+    }
+}
+
+fn main() {
+    let s = m::make();
+    paren!(s.x); //~ ERROR field `x` of struct `S` is private
+    //     ^^^ highlight here
+}