about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2016-05-20 15:49:52 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2016-05-20 15:49:52 +0200
commit5dc8dfa86ff0862c8fa93f794f12c03007023b2e (patch)
tree859c5a861794252bc9ba80d6227851fbcd6976b5 /src/test
parentf22c5aab1e740cf38e0bc04895e2a08597e3b025 (diff)
parentedf1773fb7b56b39e68411d87c86f870697b997b (diff)
downloadrust-5dc8dfa86ff0862c8fa93f794f12c03007023b2e.tar.gz
rust-5dc8dfa86ff0862c8fa93f794f12c03007023b2e.zip
Rollup merge of #33683 - sanxiyn:paren-span, r=nikomatsakis
Preserve span when lowering ExprKind::Paren

Fix #33681.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/issue-2392.rs6
-rw-r--r--src/test/compile-fail/paren-span.rs31
2 files changed, 34 insertions, 3 deletions
diff --git a/src/test/compile-fail/issue-2392.rs b/src/test/compile-fail/issue-2392.rs
index 47d50eb9d53..790b774bd21 100644
--- a/src/test/compile-fail/issue-2392.rs
+++ b/src/test/compile-fail/issue-2392.rs
@@ -81,11 +81,11 @@ impl FuncContainerOuter {
     fn run(&self) {
         unsafe {
             (*self.container).f1(1); //~ ERROR no method named `f1` found
-            //~^ NOTE use `(*self.container.f1)(...)`
+            //~^ NOTE use `((*self.container).f1)(...)`
             (*self.container).f2(1); //~ ERROR no method named `f2` found
-            //~^ NOTE use `(*self.container.f2)(...)`
+            //~^ NOTE use `((*self.container).f2)(...)`
             (*self.container).f3(1); //~ ERROR no method named `f3` found
-            //~^ NOTE use `(*self.container.f3)(...)`
+            //~^ NOTE use `((*self.container).f3)(...)`
         }
     }
 }
diff --git a/src/test/compile-fail/paren-span.rs b/src/test/compile-fail/paren-span.rs
new file mode 100644
index 00000000000..8ed5050f3de
--- /dev/null
+++ b/src/test/compile-fail/paren-span.rs
@@ -0,0 +1,31 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// 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 `m::S` is private
+    //     ^^^ highlight here
+}