From a0b8f38ab54ac451646aa00cd5e91b6c76f22a84 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 30 May 2024 05:57:19 +0200 Subject: Merging upstream version 1.72.1+dfsg1. Signed-off-by: Daniel Baumann --- tests/ui/macros/auxiliary/proc_macro_sequence.rs | 5 -- .../ui/macros/builtin-prelude-no-accidents.stderr | 32 ++++++++--- tests/ui/macros/builtin-std-paths-fail.stderr | 3 + tests/ui/macros/format-args-temporaries.rs | 10 ++-- tests/ui/macros/issue-112342-1.rs | 49 +++++++++++++++++ tests/ui/macros/issue-112342-1.stderr | 64 ++++++++++++++++++++++ tests/ui/macros/issue-112342-2.rs | 39 +++++++++++++ tests/ui/macros/issue-112342-2.stderr | 24 ++++++++ tests/ui/macros/issue-88228.rs | 5 +- tests/ui/macros/issue-88228.stderr | 14 +++-- tests/ui/macros/macro-comma-support-rpass.rs | 4 +- tests/ui/macros/macro-outer-attributes.stderr | 5 ++ tests/ui/macros/macro-use-wrong-name.stderr | 12 +++- tests/ui/macros/same-sequence-span.stderr | 7 +-- 14 files changed, 238 insertions(+), 35 deletions(-) create mode 100644 tests/ui/macros/issue-112342-1.rs create mode 100644 tests/ui/macros/issue-112342-1.stderr create mode 100644 tests/ui/macros/issue-112342-2.rs create mode 100644 tests/ui/macros/issue-112342-2.stderr (limited to 'tests/ui/macros') diff --git a/tests/ui/macros/auxiliary/proc_macro_sequence.rs b/tests/ui/macros/auxiliary/proc_macro_sequence.rs index 1331480d8..2f69cbc94 100644 --- a/tests/ui/macros/auxiliary/proc_macro_sequence.rs +++ b/tests/ui/macros/auxiliary/proc_macro_sequence.rs @@ -8,11 +8,6 @@ extern crate proc_macro; use proc_macro::{quote, Span, TokenStream, TokenTree}; -fn assert_same_span(a: Span, b: Span) { - assert_eq!(a.start(), b.start()); - assert_eq!(a.end(), b.end()); -} - // This macro generates a macro with the same macro definition as `manual_foo` in // `same-sequence-span.rs` but with the same span for all sequences. #[proc_macro] diff --git a/tests/ui/macros/builtin-prelude-no-accidents.stderr b/tests/ui/macros/builtin-prelude-no-accidents.stderr index 8cd9a63b8..b726e1862 100644 --- a/tests/ui/macros/builtin-prelude-no-accidents.stderr +++ b/tests/ui/macros/builtin-prelude-no-accidents.stderr @@ -3,21 +3,37 @@ error[E0433]: failed to resolve: use of undeclared crate or module `env` | LL | env::current_dir; | ^^^ use of undeclared crate or module `env` - -error[E0433]: failed to resolve: use of undeclared crate or module `vec` - --> $DIR/builtin-prelude-no-accidents.rs:7:14 | -LL | type B = vec::Vec; - | ^^^ - | | - | use of undeclared crate or module `vec` - | help: a struct with a similar name exists (notice the capitalization): `Vec` +help: consider importing this module + | +LL + use std::env; + | error[E0433]: failed to resolve: use of undeclared crate or module `panic` --> $DIR/builtin-prelude-no-accidents.rs:6:14 | LL | type A = panic::PanicInfo; | ^^^^^ use of undeclared crate or module `panic` + | +help: consider importing this module + | +LL + use std::panic; + | + +error[E0433]: failed to resolve: use of undeclared crate or module `vec` + --> $DIR/builtin-prelude-no-accidents.rs:7:14 + | +LL | type B = vec::Vec; + | ^^^ use of undeclared crate or module `vec` + | +help: a struct with a similar name exists + | +LL | type B = Vec::Vec; + | ~~~ +help: consider importing this module + | +LL + use std::vec; + | error: aborting due to 3 previous errors diff --git a/tests/ui/macros/builtin-std-paths-fail.stderr b/tests/ui/macros/builtin-std-paths-fail.stderr index ba6261011..004a39043 100644 --- a/tests/ui/macros/builtin-std-paths-fail.stderr +++ b/tests/ui/macros/builtin-std-paths-fail.stderr @@ -93,6 +93,9 @@ error[E0433]: failed to resolve: could not find `test` in `std` | LL | #[std::test] | ^^^^ could not find `test` in `std` + | +note: found an item that was configured out + --> $SRC_DIR/std/src/lib.rs:LL:COL error: aborting due to 16 previous errors diff --git a/tests/ui/macros/format-args-temporaries.rs b/tests/ui/macros/format-args-temporaries.rs index 59323828b..1ff6e3f80 100644 --- a/tests/ui/macros/format-args-temporaries.rs +++ b/tests/ui/macros/format-args-temporaries.rs @@ -27,27 +27,27 @@ impl<'a> Display for MutexGuard<'a> { } fn main() { - let _print = { + let _print: () = { let mutex = Mutex; print!("{}", mutex.lock()) /* no semicolon */ }; - let _println = { + let _println: () = { let mutex = Mutex; println!("{}", mutex.lock()) /* no semicolon */ }; - let _eprint = { + let _eprint: () = { let mutex = Mutex; eprint!("{}", mutex.lock()) /* no semicolon */ }; - let _eprintln = { + let _eprintln: () = { let mutex = Mutex; eprintln!("{}", mutex.lock()) /* no semicolon */ }; - let _panic = { + let _panic: () = { let mutex = Mutex; panic!("{}", mutex.lock()) /* no semicolon */ }; diff --git a/tests/ui/macros/issue-112342-1.rs b/tests/ui/macros/issue-112342-1.rs new file mode 100644 index 000000000..bd2abe7f6 --- /dev/null +++ b/tests/ui/macros/issue-112342-1.rs @@ -0,0 +1,49 @@ +// same as #95267, ignore doc comment although it's a bug. + +macro_rules! m1 { + ( + $( + /// + )* + //~^^^ERROR repetition matches empty token tree + ) => {}; +} + +m1! {} + +macro_rules! m2 { + ( + $( + /// + )+ + //~^^^ERROR repetition matches empty token tree + ) => {}; +} + +m2! {} + +macro_rules! m3 { + ( + $( + /// + )? + //~^^^ERROR repetition matches empty token tree + ) => {}; +} + +m3! {} + + +macro_rules! m4 { + ( + $( + /// + /// + )* + //~^^^^ERROR repetition matches empty token tree + ) => {}; +} + +m4! {} + +fn main() {} diff --git a/tests/ui/macros/issue-112342-1.stderr b/tests/ui/macros/issue-112342-1.stderr new file mode 100644 index 000000000..f2d82bf59 --- /dev/null +++ b/tests/ui/macros/issue-112342-1.stderr @@ -0,0 +1,64 @@ +note: doc comments are ignored in matcher position + --> $DIR/issue-112342-1.rs:6:13 + | +LL | /// + | ^^^ + +error: repetition matches empty token tree + --> $DIR/issue-112342-1.rs:5:10 + | +LL | $( + | __________^ +LL | | /// +LL | | )* + | |_________^ + +note: doc comments are ignored in matcher position + --> $DIR/issue-112342-1.rs:17:13 + | +LL | /// + | ^^^ + +error: repetition matches empty token tree + --> $DIR/issue-112342-1.rs:16:10 + | +LL | $( + | __________^ +LL | | /// +LL | | )+ + | |_________^ + +note: doc comments are ignored in matcher position + --> $DIR/issue-112342-1.rs:28:13 + | +LL | /// + | ^^^ + +error: repetition matches empty token tree + --> $DIR/issue-112342-1.rs:27:10 + | +LL | $( + | __________^ +LL | | /// +LL | | )? + | |_________^ + +note: doc comments are ignored in matcher position + --> $DIR/issue-112342-1.rs:40:13 + | +LL | / /// +LL | | /// + | |_______________^ + +error: repetition matches empty token tree + --> $DIR/issue-112342-1.rs:39:10 + | +LL | $( + | __________^ +LL | | /// +LL | | /// +LL | | )* + | |_________^ + +error: aborting due to 4 previous errors + diff --git a/tests/ui/macros/issue-112342-2.rs b/tests/ui/macros/issue-112342-2.rs new file mode 100644 index 000000000..e797aff94 --- /dev/null +++ b/tests/ui/macros/issue-112342-2.rs @@ -0,0 +1,39 @@ +// check-pass + +// same as #95267, ignore doc comment although it's a bug. + +macro_rules! m1 { + ( + $( + /// + $expr: expr, + )* + ) => {}; +} + +m1! {} + +macro_rules! m2 { + ( + $( + /// + $expr: expr, + /// + )* + ) => {}; +} + +m2! {} + +macro_rules! m3 { + ( + $( + /// + $tt: tt, + )* + ) => {}; +} + +m3! {} + +fn main() {} diff --git a/tests/ui/macros/issue-112342-2.stderr b/tests/ui/macros/issue-112342-2.stderr new file mode 100644 index 000000000..8c1b6f947 --- /dev/null +++ b/tests/ui/macros/issue-112342-2.stderr @@ -0,0 +1,24 @@ +note: doc comments are ignored in matcher position + --> $DIR/issue-112342-2.rs:8:13 + | +LL | /// + | ^^^ + +note: doc comments are ignored in matcher position + --> $DIR/issue-112342-2.rs:19:13 + | +LL | /// + | ^^^ + +note: doc comments are ignored in matcher position + --> $DIR/issue-112342-2.rs:21:13 + | +LL | /// + | ^^^ + +note: doc comments are ignored in matcher position + --> $DIR/issue-112342-2.rs:31:13 + | +LL | /// + | ^^^ + diff --git a/tests/ui/macros/issue-88228.rs b/tests/ui/macros/issue-88228.rs index 60ba2eab7..ec55a2625 100644 --- a/tests/ui/macros/issue-88228.rs +++ b/tests/ui/macros/issue-88228.rs @@ -1,14 +1,14 @@ // compile-flags: -Z deduplicate-diagnostics=yes // edition:2018 -mod hey { +mod hey { //~ HELP consider importing this derive macro + //~^ HELP consider importing this macro pub use Copy as Bla; pub use std::println as bla; } #[derive(Bla)] //~^ ERROR cannot find derive macro `Bla` -//~| HELP consider importing this derive macro struct A; #[derive(println)] @@ -19,5 +19,4 @@ struct B; fn main() { bla!(); //~^ ERROR cannot find macro `bla` - //~| HELP consider importing this macro } diff --git a/tests/ui/macros/issue-88228.stderr b/tests/ui/macros/issue-88228.stderr index fe8a1deae..f9d0ac95d 100644 --- a/tests/ui/macros/issue-88228.stderr +++ b/tests/ui/macros/issue-88228.stderr @@ -4,8 +4,10 @@ error: cannot find macro `bla` in this scope LL | bla!(); | ^^^ | - = help: consider importing this macro: - crate::hey::bla +help: consider importing this macro through its public re-export + | +LL + use crate::hey::bla; + | error: cannot find derive macro `println` in this scope --> $DIR/issue-88228.rs:14:10 @@ -16,13 +18,15 @@ LL | #[derive(println)] = note: `println` is in scope, but it is a function-like macro error: cannot find derive macro `Bla` in this scope - --> $DIR/issue-88228.rs:9:10 + --> $DIR/issue-88228.rs:10:10 | LL | #[derive(Bla)] | ^^^ | - = help: consider importing this derive macro: - crate::hey::Bla +help: consider importing this derive macro through its public re-export + | +LL + use crate::hey::Bla; + | error: aborting due to 3 previous errors diff --git a/tests/ui/macros/macro-comma-support-rpass.rs b/tests/ui/macros/macro-comma-support-rpass.rs index cb019792e..2f08ad3c3 100644 --- a/tests/ui/macros/macro-comma-support-rpass.rs +++ b/tests/ui/macros/macro-comma-support-rpass.rs @@ -170,8 +170,8 @@ fn format_args() { #[test] fn include() { - let _ = include!("auxiliary/macro-comma-support.rs"); - let _ = include!("auxiliary/macro-comma-support.rs",); + include!("auxiliary/macro-comma-support.rs"); + include!("auxiliary/macro-comma-support.rs",); } #[test] diff --git a/tests/ui/macros/macro-outer-attributes.stderr b/tests/ui/macros/macro-outer-attributes.stderr index 0bdc3416f..0418e6116 100644 --- a/tests/ui/macros/macro-outer-attributes.stderr +++ b/tests/ui/macros/macro-outer-attributes.stderr @@ -4,6 +4,11 @@ error[E0425]: cannot find function `bar` in module `a` LL | a::bar(); | ^^^ not found in `a` | +note: found an item that was configured out + --> $DIR/macro-outer-attributes.rs:9:14 + | +LL | pub fn bar() { }); + | ^^^ help: consider importing this function | LL + use b::bar; diff --git a/tests/ui/macros/macro-use-wrong-name.stderr b/tests/ui/macros/macro-use-wrong-name.stderr index ca5f0f190..36339542a 100644 --- a/tests/ui/macros/macro-use-wrong-name.stderr +++ b/tests/ui/macros/macro-use-wrong-name.stderr @@ -2,15 +2,21 @@ error: cannot find macro `macro_two` in this scope --> $DIR/macro-use-wrong-name.rs:7:5 | LL | macro_two!(); - | ^^^^^^^^^ help: a macro with a similar name exists: `macro_one` + | ^^^^^^^^^ | ::: $DIR/auxiliary/two_macros.rs:2:1 | LL | macro_rules! macro_one { () => ("one") } | ---------------------- similarly named macro `macro_one` defined here | - = help: consider importing this macro: - two_macros::macro_two +help: a macro with a similar name exists + | +LL | macro_one!(); + | ~~~~~~~~~ +help: consider importing this macro + | +LL + use two_macros::macro_two; + | error: aborting due to previous error diff --git a/tests/ui/macros/same-sequence-span.stderr b/tests/ui/macros/same-sequence-span.stderr index bdd191e8e..3242a32e2 100644 --- a/tests/ui/macros/same-sequence-span.stderr +++ b/tests/ui/macros/same-sequence-span.stderr @@ -17,15 +17,14 @@ LL | $(= $z:tt)* error: `$x:expr` may be followed by `$y:tt`, which is not allowed for `expr` fragments --> $DIR/same-sequence-span.rs:19:1 | +LL | | } + | |_________________________________^ not allowed after `expr` fragments +LL | LL | proc_macro_sequence::make_foo!(); | ^------------------------------- | | | _in this macro invocation | | -LL | | -LL | | -LL | | fn main() {} - | |_________________________________^ not allowed after `expr` fragments | = note: allowed there are: `=>`, `,` or `;` = note: this error originates in the macro `proc_macro_sequence::make_foo` (in Nightly builds, run with -Z macro-backtrace for more info) -- cgit v1.2.3