diff options
| author | Jonathan Turner <jturner@mozilla.com> | 2016-08-17 07:20:04 -0700 |
|---|---|---|
| committer | Jonathan Turner <jturner@mozilla.com> | 2016-08-17 14:26:14 -0700 |
| commit | 61865384b8fa6d79d2b36cbd7c899eaf15f4aeea (patch) | |
| tree | 136502c033d49ba3e6e28f9460129586a381e92a /src/test | |
| parent | d0a272b797fd538c4b4230bdefea534af8c1ffde (diff) | |
| download | rust-61865384b8fa6d79d2b36cbd7c899eaf15f4aeea.tar.gz rust-61865384b8fa6d79d2b36cbd7c899eaf15f4aeea.zip | |
Replace local backtrace with def-use, repair std macro spans
Diffstat (limited to 'src/test')
18 files changed, 240 insertions, 34 deletions
diff --git a/src/test/run-fail-fulldeps/qquote.rs b/src/test/run-fail-fulldeps/qquote.rs index e1461c7847e..47e97abbbaa 100644 --- a/src/test/run-fail-fulldeps/qquote.rs +++ b/src/test/run-fail-fulldeps/qquote.rs @@ -40,8 +40,10 @@ fn main() { }); let cx = &mut cx; + println!("{}", pprust::expr_to_string(&*quote_expr!(&cx, 23))); assert_eq!(pprust::expr_to_string(&*quote_expr!(&cx, 23)), "23"); let expr = quote_expr!(&cx, let x isize = 20;); + println!("{}", pprust::expr_to_string(&*expr)); assert_eq!(pprust::expr_to_string(&*expr), "let x isize = 20;"); } diff --git a/src/test/compile-fail/bad-format-args.rs b/src/test/ui/codemap_tests/bad-format-args.rs index 8c58c8c6062..de7bc88f9ba 100644 --- a/src/test/compile-fail/bad-format-args.rs +++ b/src/test/ui/codemap_tests/bad-format-args.rs @@ -8,13 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern: requires at least a format string argument -// error-pattern: in this expansion - -// error-pattern: expected token: `,` -// error-pattern: in this expansion -// error-pattern: in this expansion - fn main() { format!(); format!("" 1); diff --git a/src/test/ui/codemap_tests/bad-format-args.stderr b/src/test/ui/codemap_tests/bad-format-args.stderr new file mode 100644 index 00000000000..fab8e2c8ce1 --- /dev/null +++ b/src/test/ui/codemap_tests/bad-format-args.stderr @@ -0,0 +1,26 @@ +error: requires at least a format string argument + --> $DIR/bad-format-args.rs:12:5 + | +12 | format!(); + | ^^^^^^^^^^ + | + = note: this error originates in a macro from the standard library + +error: expected token: `,` + --> $DIR/bad-format-args.rs:13:5 + | +13 | format!("" 1); + | ^^^^^^^^^^^^^^ + | + = note: this error originates in a macro from the standard library + +error: expected token: `,` + --> $DIR/bad-format-args.rs:14:5 + | +14 | format!("", 1 1); + | ^^^^^^^^^^^^^^^^^ + | + = note: this error originates in a macro from the standard library + +error: aborting due to 3 previous errors + diff --git a/src/test/compile-fail/issue-28308.rs b/src/test/ui/codemap_tests/issue-28308.rs index b0c44b5f33a..e3a4920d951 100644 --- a/src/test/compile-fail/issue-28308.rs +++ b/src/test/ui/codemap_tests/issue-28308.rs @@ -8,10 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// this error is dispayed in `<std macros>` -// error-pattern:cannot apply unary operator `!` to type `&'static str` -// error-pattern:in this expansion of assert! - fn main() { assert!("foo"); } diff --git a/src/test/ui/codemap_tests/issue-28308.stderr b/src/test/ui/codemap_tests/issue-28308.stderr new file mode 100644 index 00000000000..0d51a3f36e9 --- /dev/null +++ b/src/test/ui/codemap_tests/issue-28308.stderr @@ -0,0 +1,10 @@ +error: cannot apply unary operator `!` to type `&'static str` + --> $DIR/issue-28308.rs:12:5 + | +12 | assert!("foo"); + | ^^^^^^^^^^^^^^^ + | + = note: this error originates in a macro from the standard library + +error: aborting due to previous error + diff --git a/src/test/ui/codemap_tests/repair_span_std_macros.rs b/src/test/ui/codemap_tests/repair_span_std_macros.rs new file mode 100644 index 00000000000..3abc91d4f5f --- /dev/null +++ b/src/test/ui/codemap_tests/repair_span_std_macros.rs @@ -0,0 +1,13 @@ +// 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. + +fn main() { + let x = vec![]; +} diff --git a/src/test/ui/codemap_tests/repair_span_std_macros.stderr b/src/test/ui/codemap_tests/repair_span_std_macros.stderr new file mode 100644 index 00000000000..1c9cbd63c33 --- /dev/null +++ b/src/test/ui/codemap_tests/repair_span_std_macros.stderr @@ -0,0 +1,11 @@ +error[E0282]: unable to infer enough type information about `_` + --> $DIR/repair_span_std_macros.rs:12:13 + | +12 | let x = vec![]; + | ^^^^^^ cannot infer type for `_` + | + = note: type annotations or generic parameter binding required + = note: this error originates in a macro from the standard library + +error: aborting due to previous error + diff --git a/src/test/ui/cross-crate-macro-backtrace/auxiliary/extern_macro_crate.rs b/src/test/ui/cross-crate-macro-backtrace/auxiliary/extern_macro_crate.rs new file mode 100644 index 00000000000..598e9f0f53a --- /dev/null +++ b/src/test/ui/cross-crate-macro-backtrace/auxiliary/extern_macro_crate.rs @@ -0,0 +1,23 @@ +// Copyright 2015 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. + +#![crate_type = "dylib"] + +pub fn print(_args: std::fmt::Arguments) {} + +#[macro_export] +macro_rules! myprint { + ($($arg:tt)*) => (print(format_args!($($arg)*))); +} + +#[macro_export] +macro_rules! myprintln { + ($fmt:expr) => (myprint!(concat!($fmt, "\n"))); +} diff --git a/src/test/ui/cross-crate-macro-backtrace/main.rs b/src/test/ui/cross-crate-macro-backtrace/main.rs new file mode 100644 index 00000000000..f8bb84abcd4 --- /dev/null +++ b/src/test/ui/cross-crate-macro-backtrace/main.rs @@ -0,0 +1,17 @@ +// Copyright 2012 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. + +// aux-build:extern_macro_crate.rs +#[macro_use(myprintln, myprint)] +extern crate extern_macro_crate; + +fn main() { + myprintln!("{}"); //~ ERROR in this macro +} diff --git a/src/test/ui/cross-crate-macro-backtrace/main.stderr b/src/test/ui/cross-crate-macro-backtrace/main.stderr new file mode 100644 index 00000000000..fceaa70288c --- /dev/null +++ b/src/test/ui/cross-crate-macro-backtrace/main.stderr @@ -0,0 +1,10 @@ +error: invalid reference to argument `0` (no arguments given) + --> $DIR/main.rs:16:5 + | +16 | myprintln!("{}"); //~ ERROR in this macro + | ^^^^^^^^^^^^^^^^^ + | + = note: this error originates in a macro from the standard library + +error: aborting due to previous error + diff --git a/src/test/ui/macros/bad_hello.rs b/src/test/ui/macros/bad_hello.rs new file mode 100644 index 00000000000..a18771deace --- /dev/null +++ b/src/test/ui/macros/bad_hello.rs @@ -0,0 +1,13 @@ +// 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. + +fn main() { + println!(3 + 4); +} diff --git a/src/test/ui/macros/bad_hello.stderr b/src/test/ui/macros/bad_hello.stderr new file mode 100644 index 00000000000..bffb33f468f --- /dev/null +++ b/src/test/ui/macros/bad_hello.stderr @@ -0,0 +1,8 @@ +error: expected a literal + --> $DIR/bad_hello.rs:12:14 + | +12 | println!(3 + 4); + | ^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/macro-backtrace-invalid-internals.rs b/src/test/ui/macros/macro-backtrace-invalid-internals.rs index ebec204184d..546e06b6c79 100644 --- a/src/test/compile-fail/macro-backtrace-invalid-internals.rs +++ b/src/test/ui/macros/macro-backtrace-invalid-internals.rs @@ -12,46 +12,46 @@ macro_rules! fake_method_stmt { () => { - 1.fake() //~ ERROR no method named `fake` found + 1.fake() } } macro_rules! fake_field_stmt { () => { - 1.fake //~ ERROR no field with that name + 1.fake } } macro_rules! fake_anon_field_stmt { () => { - (1).0 //~ ERROR type was not a tuple + (1).0 } } macro_rules! fake_method_expr { () => { - 1.fake() //~ ERROR no method named `fake` found + 1.fake() } } macro_rules! fake_field_expr { () => { - 1.fake //~ ERROR no field with that name + 1.fake } } macro_rules! fake_anon_field_expr { () => { - (1).0 //~ ERROR type was not a tuple + (1).0 } } fn main() { - fake_method_stmt!(); //~ NOTE in this expansion of - fake_field_stmt!(); //~ NOTE in this expansion of - fake_anon_field_stmt!(); //~ NOTE in this expansion of + fake_method_stmt!(); + fake_field_stmt!(); + fake_anon_field_stmt!(); - let _ = fake_method_expr!(); //~ NOTE in this expansion of - let _ = fake_field_expr!(); //~ NOTE in this expansion of - let _ = fake_anon_field_expr!(); //~ NOTE in this expansion of + let _ = fake_method_expr!(); + let _ = fake_field_expr!(); + let _ = fake_anon_field_expr!(); } diff --git a/src/test/ui/macros/macro-backtrace-invalid-internals.stderr b/src/test/ui/macros/macro-backtrace-invalid-internals.stderr new file mode 100644 index 00000000000..82000a59bfb --- /dev/null +++ b/src/test/ui/macros/macro-backtrace-invalid-internals.stderr @@ -0,0 +1,56 @@ +error: no method named `fake` found for type `{integer}` in the current scope + --> $DIR/macro-backtrace-invalid-internals.rs:15:13 + | +15 | 1.fake() + | ^^^^ +... +50 | fake_method_stmt!(); + | -------------------- in this macro invocation + +error: attempted access of field `fake` on type `{integer}`, but no field with that name was found + --> $DIR/macro-backtrace-invalid-internals.rs:21:11 + | +21 | 1.fake + | ^^^^^^ +... +51 | fake_field_stmt!(); + | ------------------- in this macro invocation + +error: attempted tuple index `0` on type `{integer}`, but the type was not a tuple or tuple struct + --> $DIR/macro-backtrace-invalid-internals.rs:27:11 + | +27 | (1).0 + | ^^^^^ +... +52 | fake_anon_field_stmt!(); + | ------------------------ in this macro invocation + +error: no method named `fake` found for type `{integer}` in the current scope + --> $DIR/macro-backtrace-invalid-internals.rs:33:13 + | +33 | 1.fake() + | ^^^^ +... +54 | let _ = fake_method_expr!(); + | ------------------- in this macro invocation + +error: attempted access of field `fake` on type `{integer}`, but no field with that name was found + --> $DIR/macro-backtrace-invalid-internals.rs:39:11 + | +39 | 1.fake + | ^^^^^^ +... +55 | let _ = fake_field_expr!(); + | ------------------ in this macro invocation + +error: attempted tuple index `0` on type `{integer}`, but the type was not a tuple or tuple struct + --> $DIR/macro-backtrace-invalid-internals.rs:45:11 + | +45 | (1).0 + | ^^^^^ +... +56 | let _ = fake_anon_field_expr!(); + | ----------------------- in this macro invocation + +error: aborting due to 6 previous errors + diff --git a/src/test/compile-fail/macro-backtrace-nested.rs b/src/test/ui/macros/macro-backtrace-nested.rs index c2a270ea9f5..d8bf6222c1c 100644 --- a/src/test/compile-fail/macro-backtrace-nested.rs +++ b/src/test/ui/macros/macro-backtrace-nested.rs @@ -12,19 +12,18 @@ // we replace the span of the expanded expression with that of the call site. macro_rules! nested_expr { - () => (fake) //~ ERROR unresolved name - //~^ ERROR unresolved name + () => (fake) } macro_rules! call_nested_expr { - () => (nested_expr!()) //~ NOTE in this expansion of nested_expr! + () => (nested_expr!()) } macro_rules! call_nested_expr_sum { - () => { 1 + nested_expr!(); } //~ NOTE in this expansion of nested_expr! + () => { 1 + nested_expr!(); } } fn main() { - 1 + call_nested_expr!(); //~ NOTE in this expansion of call_nested_expr! - call_nested_expr_sum!(); //~ NOTE in this expansion of + 1 + call_nested_expr!(); + call_nested_expr_sum!(); } diff --git a/src/test/ui/macros/macro-backtrace-nested.stderr b/src/test/ui/macros/macro-backtrace-nested.stderr new file mode 100644 index 00000000000..e452e8d69bd --- /dev/null +++ b/src/test/ui/macros/macro-backtrace-nested.stderr @@ -0,0 +1,20 @@ +error[E0425]: unresolved name `fake` + --> $DIR/macro-backtrace-nested.rs:15:12 + | +15 | () => (fake) + | ^^^^ +... +27 | 1 + call_nested_expr!(); + | ------------------- in this macro invocation + +error[E0425]: unresolved name `fake` + --> $DIR/macro-backtrace-nested.rs:15:12 + | +15 | () => (fake) + | ^^^^ +... +28 | call_nested_expr_sum!(); + | ------------------------ in this macro invocation + +error: aborting due to 2 previous errors + diff --git a/src/test/compile-fail/macro-backtrace-println.rs b/src/test/ui/macros/macro-backtrace-println.rs index 9d6da2a53a2..baf276919a5 100644 --- a/src/test/compile-fail/macro-backtrace-println.rs +++ b/src/test/ui/macros/macro-backtrace-println.rs @@ -17,15 +17,13 @@ fn print(_args: std::fmt::Arguments) {} macro_rules! myprint { - ($($arg:tt)*) => (print(format_args!($($arg)*))); //~ NOTE in this expansion of + ($($arg:tt)*) => (print(format_args!($($arg)*))); } macro_rules! myprintln { - ($fmt:expr) => (myprint!(concat!($fmt, "\n"))); //~ ERROR invalid reference to argument `0` - //~| NOTE in this expansion of concat! - //~| NOTE in this expansion of myprint! + ($fmt:expr) => (myprint!(concat!($fmt, "\n"))); } fn main() { - myprintln!("{}"); //~ NOTE in this expansion of + myprintln!("{}"); } diff --git a/src/test/ui/macros/macro-backtrace-println.stderr b/src/test/ui/macros/macro-backtrace-println.stderr new file mode 100644 index 00000000000..f21253bb67f --- /dev/null +++ b/src/test/ui/macros/macro-backtrace-println.stderr @@ -0,0 +1,11 @@ +error: invalid reference to argument `0` (no arguments given) + --> $DIR/macro-backtrace-println.rs:24:30 + | +24 | ($fmt:expr) => (myprint!(concat!($fmt, "/n"))); + | ^^^^^^^^^^^^^^^^^^^ +... +28 | myprintln!("{}"); + | ----------------- in this macro invocation + +error: aborting due to previous error + |
