]> git.lizzy.rs Git - rust.git/commitdiff
Fix bug in macro expression spans
authorJeffrey Seyfried <jeffrey.seyfried@gmail.com>
Wed, 18 May 2016 11:26:54 +0000 (11:26 +0000)
committerJeffrey Seyfried <jeffrey.seyfried@gmail.com>
Wed, 18 May 2016 11:46:08 +0000 (11:46 +0000)
src/libsyntax/ext/expand.rs
src/test/compile-fail/borrowck/borrowck-borrowed-uniq-rvalue-2.rs
src/test/compile-fail/issue-15167.rs
src/test/compile-fail/macro-backtrace-invalid-internals.rs
src/test/compile-fail/macro-backtrace-nested.rs
src/test/compile-fail/macro-backtrace-println.rs

index 65df379781ecd4047eb4e7e29a38b0d6fc16b8a8..f243706eecb8036334960f80ea07e6a46aa0c6bd 100644 (file)
@@ -70,15 +70,9 @@ pub fn expand_expr(e: P<ast::Expr>, fld: &mut MacroExpander) -> P<ast::Expr> {
 
             // Keep going, outside-in.
             let fully_expanded = fld.fold_expr(expanded_expr);
-            let span = fld.new_span(span);
             fld.cx.bt_pop();
 
-            fully_expanded.map(|e| ast::Expr {
-                id: ast::DUMMY_NODE_ID,
-                node: e.node,
-                span: span,
-                attrs: e.attrs,
-            })
+            fully_expanded
         }
 
         ast::ExprKind::InPlace(placer, value_expr) => {
index 309e286f48e509487cb004e3888a5ed87aee6f1a..7b811f581c1a707826c5ac042422c0a532c0b48e 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+// error-pattern: borrowed value does not live long enough
+
 struct defer<'a> {
     x: &'a [&'a str],
 }
@@ -28,6 +30,5 @@ fn defer<'r>(x: &'r [&'r str]) -> defer<'r> {
 
 fn main() {
     let x = defer(&vec!("Goodbye", "world!"));
-    //~^ ERROR borrowed value does not live long enough
     x.x[0];
 }
index 898e6be6fc85c0ce863a590dcc9a0ec8cc635041..2bd7da91d2c5832012544e85d3bb70824f07bf1f 100644 (file)
 // macro f should not be able to inject a reference to 'n'.
 
 macro_rules! f { () => (n) }
+//~^ ERROR unresolved name `n`
+//~| ERROR unresolved name `n`
+//~| ERROR unresolved name `n`
+//~| ERROR unresolved name `n`
 
 fn main() -> (){
     for n in 0..1 {
-        println!("{}", f!()); //~ ERROR unresolved name `n`
+        println!("{}", f!());
     }
 
     if let Some(n) = None {
-        println!("{}", f!()); //~ ERROR unresolved name `n`
+        println!("{}", f!());
     }
 
     if false {
     } else if let Some(n) = None {
-        println!("{}", f!()); //~ ERROR unresolved name `n`
+        println!("{}", f!());
     }
 
     while let Some(n) = None {
-        println!("{}", f!()); //~ ERROR unresolved name `n`
+        println!("{}", f!());
     }
 }
index 5069ec7d2846ae80216e3db001d53209abff909b..ebec204184d738527306fba1343b334560db18d1 100644 (file)
@@ -36,13 +36,13 @@ macro_rules! fake_method_expr {
 
 macro_rules! fake_field_expr {
      () => {
-          1.fake
+          1.fake //~ ERROR no field with that name
      }
 }
 
 macro_rules! fake_anon_field_expr {
      () => {
-          (1).0
+          (1).0 //~ ERROR type was not a tuple
      }
 }
 
@@ -52,8 +52,6 @@ fn main() {
     fake_anon_field_stmt!(); //~ NOTE in this expansion of
 
     let _ = fake_method_expr!(); //~ NOTE in this expansion of
-    let _ = fake_field_expr!(); //~ ERROR no field with that name
-                                //~^ NOTE in this expansion of
-    let _ = fake_anon_field_expr!(); //~ ERROR type was not a tuple
-                                     //~^ NOTE in this expansion of
+    let _ = fake_field_expr!(); //~ NOTE in this expansion of
+    let _ = fake_anon_field_expr!(); //~ NOTE in this expansion of
 }
index c935ccef055aeb0ae96f6591a0b95e674b50f5af..c2a270ea9f5c0d8f31aaab482ee8f1d976ce21d1 100644 (file)
 // we replace the span of the expanded expression with that of the call site.
 
 macro_rules! nested_expr {
-    () => (fake)
+    () => (fake) //~ ERROR unresolved name
+                 //~^ ERROR unresolved name
 }
 
 macro_rules! call_nested_expr {
-    () => (nested_expr!())
+    () => (nested_expr!()) //~ NOTE in this expansion of nested_expr!
 }
 
 macro_rules! call_nested_expr_sum {
-    () => { 1 + nested_expr!(); } //~ ERROR unresolved name
-                                  //~^ NOTE in this expansion of nested_expr!
+    () => { 1 + nested_expr!(); } //~ NOTE in this expansion of nested_expr!
 }
 
 fn main() {
-    1 + call_nested_expr!(); //~ ERROR unresolved name
-                             //~^ NOTE in this expansion of call_nested_expr!
+    1 + call_nested_expr!(); //~ NOTE in this expansion of call_nested_expr!
     call_nested_expr_sum!(); //~ NOTE in this expansion of
 }
index a485b9056de26980d10ffd2ca0193caf2305a5fc..c2277c3e6d8cdaba024839c618c0d1a59d2cf4ac 100644 (file)
@@ -21,11 +21,11 @@ macro_rules! myprint {
 }
 
 macro_rules! myprintln {
-    ($fmt:expr) => (myprint!(concat!($fmt, "\n"))); //~ ERROR invalid reference to argument `0`
-                                                    //~^ NOTE in this expansion of myprint!
-                                                    //~^^ NOTE in this expansion of concat!
+    ($fmt:expr) => (myprint!(concat!($fmt, "\n"))); //~ NOTE in this expansion of myprint!
+                                                    //~^ NOTE in this expansion of concat!
 }
 
 fn main() {
-    myprintln!("{}"); //~ NOTE in this expansion of
+    myprintln!("{}"); //~ ERROR invalid reference to argument `0`
+                      //~^ NOTE in this expansion of
 }