diff options
Diffstat (limited to 'tests/ui')
67 files changed, 2214 insertions, 344 deletions
diff --git a/tests/ui/associated-inherent-types/bugs/wf-check-skipped.next.stderr b/tests/ui/associated-inherent-types/bugs/wf-check-skipped.next.stderr index 77fbaf52934..bf53089675d 100644 --- a/tests/ui/associated-inherent-types/bugs/wf-check-skipped.next.stderr +++ b/tests/ui/associated-inherent-types/bugs/wf-check-skipped.next.stderr @@ -1,8 +1,11 @@ -error: the type `Foo::Bar<Vec<[u32]>>` is not well-formed - --> $DIR/wf-check-skipped.rs:17:14 +error[E0277]: the size for values of type `[u32]` cannot be known at compilation time + --> $DIR/wf-check-skipped.rs:17:25 | LL | fn main() -> Foo::Bar::<Vec<[u32]>> {} - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[u32]` error: aborting due to 1 previous error +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/associated-inherent-types/bugs/wf-check-skipped.rs b/tests/ui/associated-inherent-types/bugs/wf-check-skipped.rs index 5b812a2295e..52df4efd13e 100644 --- a/tests/ui/associated-inherent-types/bugs/wf-check-skipped.rs +++ b/tests/ui/associated-inherent-types/bugs/wf-check-skipped.rs @@ -15,4 +15,4 @@ impl Foo { } fn main() -> Foo::Bar::<Vec<[u32]>> {} -//[next]~^ ERROR the type `Foo::Bar<Vec<[u32]>>` is not well-formed +//[next]~^ ERROR the size for values of type `[u32]` cannot be known at compilation time diff --git a/tests/ui/feature-gates/feature-gate-stmt_expr_attributes.rs b/tests/ui/feature-gates/feature-gate-stmt_expr_attributes.rs index f213e8933bf..85c08ec035e 100644 --- a/tests/ui/feature-gates/feature-gate-stmt_expr_attributes.rs +++ b/tests/ui/feature-gates/feature-gate-stmt_expr_attributes.rs @@ -1,4 +1,15 @@ const X: i32 = #[allow(dead_code)] 8; //~^ ERROR attributes on expressions are experimental +const Y: i32 = + /// foo +//~^ ERROR attributes on expressions are experimental + 8; + +const Z: i32 = { + //! foo +//~^ ERROR attributes on expressions are experimental + 8 +}; + fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-stmt_expr_attributes.stderr b/tests/ui/feature-gates/feature-gate-stmt_expr_attributes.stderr index 67fdae030c0..14f7d58e47a 100644 --- a/tests/ui/feature-gates/feature-gate-stmt_expr_attributes.stderr +++ b/tests/ui/feature-gates/feature-gate-stmt_expr_attributes.stderr @@ -8,6 +8,28 @@ LL | const X: i32 = #[allow(dead_code)] 8; = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: aborting due to 1 previous error +error[E0658]: attributes on expressions are experimental + --> $DIR/feature-gate-stmt_expr_attributes.rs:5:5 + | +LL | /// foo + | ^^^^^^^ + | + = note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information + = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = help: `///` is used for outer documentation comments; for a plain comment, use `//` + +error[E0658]: attributes on expressions are experimental + --> $DIR/feature-gate-stmt_expr_attributes.rs:10:5 + | +LL | //! foo + | ^^^^^^^ + | + = note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information + = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = help: `//!` is used for inner documentation comments; for a plain comment, use `//` by removing the `!` or inserting a space in between them: `// !` + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/for/issue-20605.next.stderr b/tests/ui/for/issue-20605.next.stderr index 6855e17df9a..98609211865 100644 --- a/tests/ui/for/issue-20605.next.stderr +++ b/tests/ui/for/issue-20605.next.stderr @@ -11,31 +11,13 @@ help: consider mutably borrowing here LL | for item in &mut *things { *item = 0 } | ++++ -error: the type `<dyn Iterator<Item = &'a mut u8> as IntoIterator>::IntoIter` is not well-formed - --> $DIR/issue-20605.rs:6:17 - | -LL | for item in *things { *item = 0 } - | ^^^^^^^ - -error: the type `&mut <dyn Iterator<Item = &'a mut u8> as IntoIterator>::IntoIter` is not well-formed - --> $DIR/issue-20605.rs:6:17 - | -LL | for item in *things { *item = 0 } - | ^^^^^^^ - -error: the type `Option<<<dyn Iterator<Item = &'a mut u8> as IntoIterator>::IntoIter as Iterator>::Item>` is not well-formed - --> $DIR/issue-20605.rs:6:17 - | -LL | for item in *things { *item = 0 } - | ^^^^^^^ - error[E0614]: type `<dyn Iterator<Item = &'a mut u8> as IntoIterator>::Item` cannot be dereferenced --> $DIR/issue-20605.rs:6:27 | LL | for item in *things { *item = 0 } | ^^^^^ -error: aborting due to 5 previous errors +error: aborting due to 2 previous errors Some errors have detailed explanations: E0277, E0614. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/for/issue-20605.rs b/tests/ui/for/issue-20605.rs index b923a7088fe..647dc84028c 100644 --- a/tests/ui/for/issue-20605.rs +++ b/tests/ui/for/issue-20605.rs @@ -6,9 +6,6 @@ fn changer<'a>(mut things: Box<dyn Iterator<Item=&'a mut u8>>) { for item in *things { *item = 0 } //[current]~^ ERROR `dyn Iterator<Item = &'a mut u8>` is not an iterator //[next]~^^ ERROR `dyn Iterator<Item = &'a mut u8>` is not an iterator - //[next]~| ERROR the type `<dyn Iterator<Item = &'a mut u8> as IntoIterator>::IntoIter` is not well-formed - //[next]~| ERROR the type `&mut <dyn Iterator<Item = &'a mut u8> as IntoIterator>::IntoIter` is not well-formed - //[next]~| ERROR the type `Option<<<dyn Iterator<Item = &'a mut u8> as IntoIterator>::IntoIter as Iterator>::Item>` is not well-formed //[next]~| ERROR type `<dyn Iterator<Item = &'a mut u8> as IntoIterator>::Item` cannot be dereferenced // FIXME(-Znext-solver): these error messages are horrible and have to be diff --git a/tests/ui/generic-associated-types/guide-inference-in-gat-arg-deeper.rs b/tests/ui/generic-associated-types/guide-inference-in-gat-arg-deeper.rs new file mode 100644 index 00000000000..96a0f2f40bf --- /dev/null +++ b/tests/ui/generic-associated-types/guide-inference-in-gat-arg-deeper.rs @@ -0,0 +1,19 @@ +// Fix for <https://github.com/rust-lang/rust/issues/125196>. +//@ check-pass + +trait Tr { + type Gat<T>; +} + +struct W<T>(T); + +fn foo<T: Tr>() where for<'a> &'a T: Tr<Gat<W<i32>> = i32> { + let x: <&T as Tr>::Gat<W<_>> = 1i32; + // Previously, `match_projection_projections` only checked that + // `shallow_resolve(W<?0>) = W<?0>`. This won't prevent *all* inference guidance + // from projection predicates in the environment, just ones that guide the + // outermost type of each GAT constructor. This is definitely wrong, but there is + // code that relies on it in the wild :/ +} + +fn main() {} diff --git a/tests/ui/impl-trait/in-trait/alias-bounds-when-not-wf.rs b/tests/ui/impl-trait/in-trait/alias-bounds-when-not-wf.rs index 365955166e6..5a6bf9bfaef 100644 --- a/tests/ui/impl-trait/in-trait/alias-bounds-when-not-wf.rs +++ b/tests/ui/impl-trait/in-trait/alias-bounds-when-not-wf.rs @@ -14,6 +14,6 @@ struct W<T>(T); // `usize: Foo` doesn't hold. Therefore we ICE, because we don't expect to still // encounter weak types in `assemble_alias_bound_candidates_recur`. fn hello(_: W<A<usize>>) {} -//~^ ERROR the type `W<A<usize>>` is not well-formed +//~^ ERROR the size for values of type `A<usize>` cannot be known at compilation time fn main() {} diff --git a/tests/ui/impl-trait/in-trait/alias-bounds-when-not-wf.stderr b/tests/ui/impl-trait/in-trait/alias-bounds-when-not-wf.stderr index 5df27ac3bc6..9663fab3d8c 100644 --- a/tests/ui/impl-trait/in-trait/alias-bounds-when-not-wf.stderr +++ b/tests/ui/impl-trait/in-trait/alias-bounds-when-not-wf.stderr @@ -7,11 +7,14 @@ LL | #![feature(lazy_type_alias)] = note: see issue #112792 <https://github.com/rust-lang/rust/issues/112792> for more information = note: `#[warn(incomplete_features)]` on by default -error: the type `W<A<usize>>` is not well-formed +error[E0277]: the size for values of type `A<usize>` cannot be known at compilation time --> $DIR/alias-bounds-when-not-wf.rs:16:13 | LL | fn hello(_: W<A<usize>>) {} - | ^^^^^^^^^^^ + | ^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `A<usize>` error: aborting due to 1 previous error; 1 warning emitted +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/intrinsics/safe-intrinsic-mismatch.stderr b/tests/ui/intrinsics/safe-intrinsic-mismatch.stderr index 2e0812d6472..d73d5bab8d7 100644 --- a/tests/ui/intrinsics/safe-intrinsic-mismatch.stderr +++ b/tests/ui/intrinsics/safe-intrinsic-mismatch.stderr @@ -22,7 +22,7 @@ error[E0308]: intrinsic has wrong type --> $DIR/safe-intrinsic-mismatch.rs:11:16 | LL | const fn assume(_b: bool) {} - | ^ expected unsafe fn, found normal fn + | ^ expected unsafe fn, found safe fn | = note: expected signature `unsafe fn(_)` found signature `fn(_)` @@ -37,7 +37,7 @@ error[E0308]: intrinsic has wrong type --> $DIR/safe-intrinsic-mismatch.rs:15:26 | LL | const fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) {} - | ^ expected unsafe fn, found normal fn + | ^ expected unsafe fn, found safe fn | = note: expected signature `unsafe fn(_, _, _)` found signature `fn(_, _, _)` diff --git a/tests/ui/lint/unused/unused-doc-comments-edge-cases.stderr b/tests/ui/lint/unused/unused-doc-comments-edge-cases.stderr index add85b2f5e0..1ff5c8d8825 100644 --- a/tests/ui/lint/unused/unused-doc-comments-edge-cases.stderr +++ b/tests/ui/lint/unused/unused-doc-comments-edge-cases.stderr @@ -13,7 +13,7 @@ LL | (/// useless doc comment = note: see issue #15701 <https://github.com/rust-lang/rust/issues/15701> for more information = help: add `#![feature(stmt_expr_attributes)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - = help: `///` is for documentation comments. For a plain comment, use `//`. + = help: `///` is used for outer documentation comments; for a plain comment, use `//` error: unused doc comment --> $DIR/unused-doc-comments-edge-cases.rs:6:9 diff --git a/tests/ui/lint/unused/unused-macro-rules-compile-error.rs b/tests/ui/lint/unused/unused-macro-rules-compile-error.rs index 4d51db89bc0..0c8fe65bd5c 100644 --- a/tests/ui/lint/unused/unused-macro-rules-compile-error.rs +++ b/tests/ui/lint/unused/unused-macro-rules-compile-error.rs @@ -9,7 +9,7 @@ macro_rules! num { // Some nested use (two_) => { foo(compile_error!("foo")); }; (three) => { 3 }; - (four) => { 4 }; //~ ERROR: rule of macro + (four) => { 4 }; //~ ERROR: rule #5 of macro } const _NUM: u8 = num!(one) + num!(three); @@ -17,9 +17,9 @@ const _NUM: u8 = num!(one) + num!(three); macro_rules! num2 { (one) => { 1 }; // Only identifier present - (two) => { fn compile_error() {} }; //~ ERROR: rule of macro + (two) => { fn compile_error() {} }; //~ ERROR: rule #2 of macro // Only identifier and bang present - (two_) => { compile_error! }; //~ ERROR: rule of macro + (two_) => { compile_error! }; //~ ERROR: rule #3 of macro (three) => { 3 }; } const _NUM2: u8 = num2!(one) + num2!(three); diff --git a/tests/ui/lint/unused/unused-macro-rules-compile-error.stderr b/tests/ui/lint/unused/unused-macro-rules-compile-error.stderr index 76af8c967db..936428f6a1c 100644 --- a/tests/ui/lint/unused/unused-macro-rules-compile-error.stderr +++ b/tests/ui/lint/unused/unused-macro-rules-compile-error.stderr @@ -1,4 +1,4 @@ -error: 5th rule of macro `num` is never used +error: rule #5 of macro `num` is never used --> $DIR/unused-macro-rules-compile-error.rs:12:5 | LL | (four) => { 4 }; @@ -10,13 +10,13 @@ note: the lint level is defined here LL | #![deny(unused_macro_rules)] | ^^^^^^^^^^^^^^^^^^ -error: 3rd rule of macro `num2` is never used +error: rule #3 of macro `num2` is never used --> $DIR/unused-macro-rules-compile-error.rs:22:5 | LL | (two_) => { compile_error! }; | ^^^^^^ -error: 2nd rule of macro `num2` is never used +error: rule #2 of macro `num2` is never used --> $DIR/unused-macro-rules-compile-error.rs:20:5 | LL | (two) => { fn compile_error() {} }; diff --git a/tests/ui/lint/unused/unused-macro-rules-decl.rs b/tests/ui/lint/unused/unused-macro-rules-decl.rs index 537c84940fd..ca14d58e524 100644 --- a/tests/ui/lint/unused/unused-macro-rules-decl.rs +++ b/tests/ui/lint/unused/unused-macro-rules-decl.rs @@ -6,9 +6,9 @@ // Most simple case macro num { (one) => { 1 }, - (two) => { 2 }, //~ ERROR: 2nd rule of macro + (two) => { 2 }, //~ ERROR: rule #2 of macro (three) => { 3 }, - (four) => { 4 }, //~ ERROR: 4th rule of macro + (four) => { 4 }, //~ ERROR: rule #4 of macro } const _NUM: u8 = num!(one) + num!(three); @@ -28,7 +28,7 @@ macro num_rec { (two) => { num_rec!(one) + num_rec!(one) }, - (three) => { //~ ERROR: 3rd rule of macro + (three) => { //~ ERROR: rule #3 of macro num_rec!(one) + num_rec!(two) }, (four) => { diff --git a/tests/ui/lint/unused/unused-macro-rules-decl.stderr b/tests/ui/lint/unused/unused-macro-rules-decl.stderr index 4d9b22feda2..10ceb3921f3 100644 --- a/tests/ui/lint/unused/unused-macro-rules-decl.stderr +++ b/tests/ui/lint/unused/unused-macro-rules-decl.stderr @@ -1,4 +1,4 @@ -error: 4th rule of macro `num` is never used +error: rule #4 of macro `num` is never used --> $DIR/unused-macro-rules-decl.rs:11:5 | LL | (four) => { 4 }, @@ -10,13 +10,13 @@ note: the lint level is defined here LL | #![deny(unused_macro_rules)] | ^^^^^^^^^^^^^^^^^^ -error: 2nd rule of macro `num` is never used +error: rule #2 of macro `num` is never used --> $DIR/unused-macro-rules-decl.rs:9:5 | LL | (two) => { 2 }, | ^^^^^ -error: 3rd rule of macro `num_rec` is never used +error: rule #3 of macro `num_rec` is never used --> $DIR/unused-macro-rules-decl.rs:31:5 | LL | (three) => { diff --git a/tests/ui/lint/unused/unused-macro-rules.rs b/tests/ui/lint/unused/unused-macro-rules.rs index eeaf4d1b0a9..39a882e8e4d 100644 --- a/tests/ui/lint/unused/unused-macro-rules.rs +++ b/tests/ui/lint/unused/unused-macro-rules.rs @@ -5,9 +5,9 @@ // Most simple case macro_rules! num { (one) => { 1 }; - (two) => { 2 }; //~ ERROR: 2nd rule of macro + (two) => { 2 }; //~ ERROR: rule #2 of macro (three) => { 3 }; - (four) => { 4 }; //~ ERROR: 4th rule of macro + (four) => { 4 }; //~ ERROR: rule #4 of macro } const _NUM: u8 = num!(one) + num!(three); @@ -27,7 +27,7 @@ macro_rules! num_rec { (two) => { num_rec!(one) + num_rec!(one) }; - (three) => { //~ ERROR: 3rd rule of macro + (three) => { //~ ERROR: rule #3 of macro num_rec!(one) + num_rec!(two) }; (four) => { num_rec!(two) + num_rec!(two) }; diff --git a/tests/ui/lint/unused/unused-macro-rules.stderr b/tests/ui/lint/unused/unused-macro-rules.stderr index 2b3098a5128..b9258e77805 100644 --- a/tests/ui/lint/unused/unused-macro-rules.stderr +++ b/tests/ui/lint/unused/unused-macro-rules.stderr @@ -1,4 +1,4 @@ -error: 4th rule of macro `num` is never used +error: rule #4 of macro `num` is never used --> $DIR/unused-macro-rules.rs:10:5 | LL | (four) => { 4 }; @@ -10,13 +10,13 @@ note: the lint level is defined here LL | #![deny(unused_macro_rules)] | ^^^^^^^^^^^^^^^^^^ -error: 2nd rule of macro `num` is never used +error: rule #2 of macro `num` is never used --> $DIR/unused-macro-rules.rs:8:5 | LL | (two) => { 2 }; | ^^^^^ -error: 3rd rule of macro `num_rec` is never used +error: rule #3 of macro `num_rec` is never used --> $DIR/unused-macro-rules.rs:30:5 | LL | (three) => { diff --git a/tests/ui/macros/expr_2021_inline_const.edi2021.stderr b/tests/ui/macros/expr_2021_inline_const.edi2021.stderr new file mode 100644 index 00000000000..5e880964454 --- /dev/null +++ b/tests/ui/macros/expr_2021_inline_const.edi2021.stderr @@ -0,0 +1,32 @@ +error: no rules expected the token `const` + --> $DIR/expr_2021_inline_const.rs:21:12 + | +LL | macro_rules! m2021 { + | ------------------ when calling this macro +... +LL | m2021!(const { 1 }); + | ^^^^^ no rules expected this token in macro call + | +note: while trying to match meta-variable `$e:expr_2021` + --> $DIR/expr_2021_inline_const.rs:10:6 + | +LL | ($e:expr_2021) => { + | ^^^^^^^^^^^^ + +error: no rules expected the token `const` + --> $DIR/expr_2021_inline_const.rs:22:12 + | +LL | macro_rules! m2024 { + | ------------------ when calling this macro +... +LL | m2024!(const { 1 }); + | ^^^^^ no rules expected this token in macro call + | +note: while trying to match meta-variable `$e:expr` + --> $DIR/expr_2021_inline_const.rs:16:6 + | +LL | ($e:expr) => { + | ^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/macros/expr_2021_inline_const.edi2024.stderr b/tests/ui/macros/expr_2021_inline_const.edi2024.stderr new file mode 100644 index 00000000000..237ecb2cc19 --- /dev/null +++ b/tests/ui/macros/expr_2021_inline_const.edi2024.stderr @@ -0,0 +1,17 @@ +error: no rules expected the token `const` + --> $DIR/expr_2021_inline_const.rs:21:12 + | +LL | macro_rules! m2021 { + | ------------------ when calling this macro +... +LL | m2021!(const { 1 }); + | ^^^^^ no rules expected this token in macro call + | +note: while trying to match meta-variable `$e:expr_2021` + --> $DIR/expr_2021_inline_const.rs:10:6 + | +LL | ($e:expr_2021) => { + | ^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/macros/expr_2021_inline_const.rs b/tests/ui/macros/expr_2021_inline_const.rs new file mode 100644 index 00000000000..ebc5ea36421 --- /dev/null +++ b/tests/ui/macros/expr_2021_inline_const.rs @@ -0,0 +1,23 @@ +//@ revisions: edi2021 edi2024 +//@[edi2024]compile-flags: --edition=2024 -Z unstable-options +//@[edi2021]compile-flags: --edition=2021 + +// This test ensures that the inline const match only on edition 2024 +#![feature(expr_fragment_specifier_2024)] +#![allow(incomplete_features)] + +macro_rules! m2021 { + ($e:expr_2021) => { + $e + }; +} + +macro_rules! m2024 { + ($e:expr) => { + $e + }; +} +fn main() { + m2021!(const { 1 }); //~ ERROR: no rules expected the token `const` + m2024!(const { 1 }); //[edi2021]~ ERROR: no rules expected the token `const` +} diff --git a/tests/ui/macros/expr_2021_old_edition.rs b/tests/ui/macros/expr_2021_old_edition.rs new file mode 100644 index 00000000000..a7711266106 --- /dev/null +++ b/tests/ui/macros/expr_2021_old_edition.rs @@ -0,0 +1,13 @@ +//@ compile-flags: --edition=2018 + +// This test ensures that expr_2021 is not allowed on pre-2021 editions + +macro_rules! m { + ($e:expr_2021) => { //~ ERROR: invalid fragment specifier `expr_2021` + $e + }; +} + +fn main() { + m!(()); //~ ERROR: no rules expected the token `(` +} diff --git a/tests/ui/macros/expr_2021_old_edition.stderr b/tests/ui/macros/expr_2021_old_edition.stderr new file mode 100644 index 00000000000..bffa8a1ca17 --- /dev/null +++ b/tests/ui/macros/expr_2021_old_edition.stderr @@ -0,0 +1,26 @@ +error: invalid fragment specifier `expr_2021` + --> $DIR/expr_2021_old_edition.rs:6:6 + | +LL | ($e:expr_2021) => { + | ^^^^^^^^^^^^ + | + = help: fragment specifier `expr_2021` requires Rust 2021 or later + valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis` + +error: no rules expected the token `(` + --> $DIR/expr_2021_old_edition.rs:12:8 + | +LL | macro_rules! m { + | -------------- when calling this macro +... +LL | m!(()); + | ^ no rules expected this token in macro call + | +note: while trying to match meta-variable `$e:ident` + --> $DIR/expr_2021_old_edition.rs:6:6 + | +LL | ($e:expr_2021) => { + | ^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/macros/feature-gate-expr_fragment_specifier_2024.rs b/tests/ui/macros/feature-gate-expr_fragment_specifier_2024.rs new file mode 100644 index 00000000000..5a737b29821 --- /dev/null +++ b/tests/ui/macros/feature-gate-expr_fragment_specifier_2024.rs @@ -0,0 +1,11 @@ +//@ compile-flags: --edition=2024 -Z unstable-options + +macro_rules! m { + ($e:expr_2021) => { //~ ERROR: fragment specifier `expr_2021` is unstable + $e + }; +} + +fn main() { + m!(()); +} diff --git a/tests/ui/macros/feature-gate-expr_fragment_specifier_2024.stderr b/tests/ui/macros/feature-gate-expr_fragment_specifier_2024.stderr new file mode 100644 index 00000000000..273a93877ce --- /dev/null +++ b/tests/ui/macros/feature-gate-expr_fragment_specifier_2024.stderr @@ -0,0 +1,13 @@ +error[E0658]: fragment specifier `expr_2021` is unstable + --> $DIR/feature-gate-expr_fragment_specifier_2024.rs:4:6 + | +LL | ($e:expr_2021) => { + | ^^^^^^^^^^^^ + | + = note: see issue #123742 <https://github.com/rust-lang/rust/issues/123742> for more information + = help: add `#![feature(expr_fragment_specifier_2024)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/macros/issue-98790.rs b/tests/ui/macros/issue-98790.rs deleted file mode 100644 index b489efe9ce9..00000000000 --- a/tests/ui/macros/issue-98790.rs +++ /dev/null @@ -1,24 +0,0 @@ -//@ run-pass - -macro_rules! stringify_item { - ($item:item) => { - stringify!($item) - }; -} - -macro_rules! repro { - ($expr:expr) => { - stringify_item! { - pub fn repro() -> bool { - $expr - } - } - }; -} - -fn main() { - assert_eq!( - repro!(match () { () => true } | true), - "pub fn repro() -> bool { (match () { () => true, }) | true }" - ); -} diff --git a/tests/ui/macros/missing-semi.rs b/tests/ui/macros/missing-semi.rs new file mode 100644 index 00000000000..b7e90e9e442 --- /dev/null +++ b/tests/ui/macros/missing-semi.rs @@ -0,0 +1,11 @@ +#[allow(unused_macros)] +macro_rules! foo { + () => { + + } + () => { + //~^ ERROR expected `;`, found `(` + } +} + +fn main() {} diff --git a/tests/ui/macros/missing-semi.stderr b/tests/ui/macros/missing-semi.stderr new file mode 100644 index 00000000000..0a7afe50059 --- /dev/null +++ b/tests/ui/macros/missing-semi.stderr @@ -0,0 +1,8 @@ +error: expected `;`, found `(` + --> $DIR/missing-semi.rs:6:5 + | +LL | () => { + | ^ no rules expected this token in macro call + +error: aborting due to 1 previous error + diff --git a/tests/ui/macros/println-percent-prefix-num-issue-125002.rs b/tests/ui/macros/println-percent-prefix-num-issue-125002.rs new file mode 100644 index 00000000000..9f30d48a5cd --- /dev/null +++ b/tests/ui/macros/println-percent-prefix-num-issue-125002.rs @@ -0,0 +1,6 @@ +fn main() { + println!("%100000", 1); + //~^ ERROR argument never used + println!("% 65536", 1); + //~^ ERROR argument never used +} diff --git a/tests/ui/macros/println-percent-prefix-num-issue-125002.stderr b/tests/ui/macros/println-percent-prefix-num-issue-125002.stderr new file mode 100644 index 00000000000..7575137be6d --- /dev/null +++ b/tests/ui/macros/println-percent-prefix-num-issue-125002.stderr @@ -0,0 +1,28 @@ +error: argument never used + --> $DIR/println-percent-prefix-num-issue-125002.rs:2:25 + | +LL | println!("%100000", 1); + | ^ argument never used + | +note: format specifiers use curly braces, and the conversion specifier `1` is unknown or unsupported + --> $DIR/println-percent-prefix-num-issue-125002.rs:2:15 + | +LL | println!("%100000", 1); + | ^^ + = note: printf formatting is not supported; see the documentation for `std::fmt` + +error: argument never used + --> $DIR/println-percent-prefix-num-issue-125002.rs:4:29 + | +LL | println!("% 65536", 1); + | ^ argument never used + | +note: format specifiers use curly braces, and the conversion specifier ` ` is unknown or unsupported + --> $DIR/println-percent-prefix-num-issue-125002.rs:4:15 + | +LL | println!("% 65536", 1); + | ^^ + = note: printf formatting is not supported; see the documentation for `std::fmt` + +error: aborting due to 2 previous errors + diff --git a/tests/ui/proc-macro/signature.stderr b/tests/ui/proc-macro/signature.stderr index 2a53145a643..fd679442b6a 100644 --- a/tests/ui/proc-macro/signature.stderr +++ b/tests/ui/proc-macro/signature.stderr @@ -2,7 +2,7 @@ error: derive proc macro has incorrect signature --> $DIR/signature.rs:10:1 | LL | pub unsafe extern "C" fn foo(a: i32, b: u32) -> u32 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected normal fn, found unsafe fn + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected safe fn, found unsafe fn | = note: expected signature `fn(proc_macro::TokenStream) -> proc_macro::TokenStream` found signature `unsafe extern "C" fn(i32, u32) -> u32` diff --git a/tests/ui/traits/impl-method-mismatch.stderr b/tests/ui/traits/impl-method-mismatch.stderr index 2061fc78575..77d542c729a 100644 --- a/tests/ui/traits/impl-method-mismatch.stderr +++ b/tests/ui/traits/impl-method-mismatch.stderr @@ -2,7 +2,7 @@ error[E0053]: method `jumbo` has an incompatible type for trait --> $DIR/impl-method-mismatch.rs:7:5 | LL | unsafe fn jumbo(&self, x: &usize) { *self + *x; } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected normal fn, found unsafe fn + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected safe fn, found unsafe fn | note: type in trait --> $DIR/impl-method-mismatch.rs:2:5 diff --git a/tests/ui/traits/next-solver/canonical/const-region-infer-to-static-in-binder.stderr b/tests/ui/traits/next-solver/canonical/const-region-infer-to-static-in-binder.stderr index 044c24fd2b2..170f2c7d34c 100644 --- a/tests/ui/traits/next-solver/canonical/const-region-infer-to-static-in-binder.stderr +++ b/tests/ui/traits/next-solver/canonical/const-region-infer-to-static-in-binder.stderr @@ -1,8 +1,8 @@ -error[E0282]: type annotations needed +error[E0284]: type annotations needed: cannot satisfy `the constant `{ || {} }` can be evaluated` --> $DIR/const-region-infer-to-static-in-binder.rs:4:10 | LL | struct X<const FN: fn() = { || {} }>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer the value of the constant `{ || {} }` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot satisfy `the constant `{ || {} }` can be evaluated` error: using function pointers as const generic parameters is forbidden --> $DIR/const-region-infer-to-static-in-binder.rs:4:20 @@ -23,4 +23,4 @@ LL | struct X<const FN: fn() = { || {} }>; error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0282`. +For more information about this error, try `rustc --explain E0284`. diff --git a/tests/ui/traits/next-solver/coherence/coherence-fulfill-overflow.stderr b/tests/ui/traits/next-solver/coherence/coherence-fulfill-overflow.stderr index 6e68646fbe4..57cba790b55 100644 --- a/tests/ui/traits/next-solver/coherence/coherence-fulfill-overflow.stderr +++ b/tests/ui/traits/next-solver/coherence/coherence-fulfill-overflow.stderr @@ -1,12 +1,12 @@ -error[E0119]: conflicting implementations of trait `Trait` for type `W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<_>>>>>>>>>>>>>>>>>>>>>>` +error[E0119]: conflicting implementations of trait `Trait` for type `W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<_>>>>>>>>>>>>>>>>>>>>>` --> $DIR/coherence-fulfill-overflow.rs:12:1 | LL | impl<T: ?Sized + TwoW> Trait for W<T> {} | ------------------------------------- first implementation here LL | impl<T: ?Sized + TwoW> Trait for T {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<_>>>>>>>>>>>>>>>>>>>>>>` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<_>>>>>>>>>>>>>>>>>>>>>` | - = note: overflow evaluating the requirement `W<W<W<W<_>>>>: TwoW` + = note: overflow evaluating the requirement `W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<_>>>>>>>>>>>>>>>>>>>>>: TwoW` = help: consider increasing the recursion limit by adding a `#![recursion_limit = "20"]` attribute to your crate (`coherence_fulfill_overflow`) error: aborting due to 1 previous error diff --git a/tests/ui/traits/next-solver/cycles/coinduction/fixpoint-exponential-growth.stderr b/tests/ui/traits/next-solver/cycles/coinduction/fixpoint-exponential-growth.stderr index df25150c21f..8d7d8cee08a 100644 --- a/tests/ui/traits/next-solver/cycles/coinduction/fixpoint-exponential-growth.stderr +++ b/tests/ui/traits/next-solver/cycles/coinduction/fixpoint-exponential-growth.stderr @@ -1,16 +1,9 @@ -error[E0275]: overflow evaluating the requirement `_: Sized` +error[E0275]: overflow evaluating the requirement `W<_>: Trait` --> $DIR/fixpoint-exponential-growth.rs:33:13 | LL | impls::<W<_>>(); | ^^^^ | -note: required for `W<(W<_>, W<_>)>` to implement `Trait` - --> $DIR/fixpoint-exponential-growth.rs:23:12 - | -LL | impl<T, U> Trait for W<(W<T>, W<U>)> - | - ^^^^^ ^^^^^^^^^^^^^^^ - | | - | unsatisfied trait bound introduced here note: required by a bound in `impls` --> $DIR/fixpoint-exponential-growth.rs:30:13 | diff --git a/tests/ui/traits/next-solver/cycles/double-cycle-inductive-coinductive.stderr b/tests/ui/traits/next-solver/cycles/double-cycle-inductive-coinductive.stderr index 86c71ad92ff..7cedb4d36c9 100644 --- a/tests/ui/traits/next-solver/cycles/double-cycle-inductive-coinductive.stderr +++ b/tests/ui/traits/next-solver/cycles/double-cycle-inductive-coinductive.stderr @@ -1,53 +1,21 @@ -error[E0275]: overflow evaluating the requirement `(): Inductive` +error[E0275]: overflow evaluating the requirement `(): Trait` --> $DIR/double-cycle-inductive-coinductive.rs:32:19 | LL | impls_trait::<()>(); | ^^ | -note: required for `()` to implement `Trait` - --> $DIR/double-cycle-inductive-coinductive.rs:9:34 - | -LL | impl<T: Inductive + Coinductive> Trait for T {} - | --------- ^^^^^ ^ - | | - | unsatisfied trait bound introduced here -note: required for `()` to implement `Inductive` - --> $DIR/double-cycle-inductive-coinductive.rs:12:16 - | -LL | impl<T: Trait> Inductive for T {} - | ----- ^^^^^^^^^ ^ - | | - | unsatisfied trait bound introduced here - = note: 7 redundant requirements hidden - = note: required for `()` to implement `Trait` note: required by a bound in `impls_trait` --> $DIR/double-cycle-inductive-coinductive.rs:17:19 | LL | fn impls_trait<T: Trait>() {} | ^^^^^ required by this bound in `impls_trait` -error[E0275]: overflow evaluating the requirement `(): CoinductiveRev` +error[E0275]: overflow evaluating the requirement `(): TraitRev` --> $DIR/double-cycle-inductive-coinductive.rs:35:23 | LL | impls_trait_rev::<()>(); | ^^ | -note: required for `()` to implement `TraitRev` - --> $DIR/double-cycle-inductive-coinductive.rs:21:40 - | -LL | impl<T: CoinductiveRev + InductiveRev> TraitRev for T {} - | -------------- ^^^^^^^^ ^ - | | - | unsatisfied trait bound introduced here -note: required for `()` to implement `CoinductiveRev` - --> $DIR/double-cycle-inductive-coinductive.rs:27:19 - | -LL | impl<T: TraitRev> CoinductiveRev for T {} - | -------- ^^^^^^^^^^^^^^ ^ - | | - | unsatisfied trait bound introduced here - = note: 7 redundant requirements hidden - = note: required for `()` to implement `TraitRev` note: required by a bound in `impls_trait_rev` --> $DIR/double-cycle-inductive-coinductive.rs:29:23 | diff --git a/tests/ui/traits/next-solver/cycles/inductive-fixpoint-hang.stderr b/tests/ui/traits/next-solver/cycles/inductive-fixpoint-hang.stderr index ea46c0fea97..a2a5c028cf8 100644 --- a/tests/ui/traits/next-solver/cycles/inductive-fixpoint-hang.stderr +++ b/tests/ui/traits/next-solver/cycles/inductive-fixpoint-hang.stderr @@ -1,19 +1,9 @@ -error[E0275]: overflow evaluating the requirement `W<W<_>>: Trait` +error[E0275]: overflow evaluating the requirement `W<_>: Trait` --> $DIR/inductive-fixpoint-hang.rs:31:19 | LL | impls_trait::<W<_>>(); | ^^^^ | -note: required for `W<W<W<_>>>` to implement `Trait` - --> $DIR/inductive-fixpoint-hang.rs:22:17 - | -LL | impl<T: ?Sized> Trait for W<W<T>> - | ^^^^^ ^^^^^^^ -LL | where -LL | W<T>: Trait, - | ----- unsatisfied trait bound introduced here - = note: 8 redundant requirements hidden - = note: required for `W<W<W<W<W<W<W<W<W<W<W<_>>>>>>>>>>>` to implement `Trait` note: required by a bound in `impls_trait` --> $DIR/inductive-fixpoint-hang.rs:28:19 | diff --git a/tests/ui/traits/next-solver/cycles/inductive-not-on-stack.rs b/tests/ui/traits/next-solver/cycles/inductive-not-on-stack.rs index 9d0ea51b1b2..78683372580 100644 --- a/tests/ui/traits/next-solver/cycles/inductive-not-on-stack.rs +++ b/tests/ui/traits/next-solver/cycles/inductive-not-on-stack.rs @@ -39,7 +39,7 @@ fn impls_ar<T: AR>() {} fn main() { impls_a::<()>(); - //~^ ERROR overflow evaluating the requirement `(): B` + //~^ ERROR overflow evaluating the requirement `(): A` impls_ar::<()>(); //~^ ERROR overflow evaluating the requirement `(): AR` diff --git a/tests/ui/traits/next-solver/cycles/inductive-not-on-stack.stderr b/tests/ui/traits/next-solver/cycles/inductive-not-on-stack.stderr index fe02d3c407c..e9cc6bc6c81 100644 --- a/tests/ui/traits/next-solver/cycles/inductive-not-on-stack.stderr +++ b/tests/ui/traits/next-solver/cycles/inductive-not-on-stack.stderr @@ -1,25 +1,9 @@ -error[E0275]: overflow evaluating the requirement `(): B` +error[E0275]: overflow evaluating the requirement `(): A` --> $DIR/inductive-not-on-stack.rs:41:15 | LL | impls_a::<()>(); | ^^ | -note: required for `()` to implement `A` - --> $DIR/inductive-not-on-stack.rs:21:16 - | -LL | impl<T: B + C> A for T {} - | - ^ ^ - | | - | unsatisfied trait bound introduced here -note: required for `()` to implement `B` - --> $DIR/inductive-not-on-stack.rs:22:12 - | -LL | impl<T: A> B for T {} - | - ^ ^ - | | - | unsatisfied trait bound introduced here - = note: 7 redundant requirements hidden - = note: required for `()` to implement `A` note: required by a bound in `impls_a` --> $DIR/inductive-not-on-stack.rs:25:15 | @@ -32,29 +16,6 @@ error[E0275]: overflow evaluating the requirement `(): AR` LL | impls_ar::<()>(); | ^^ | -note: required for `()` to implement `BR` - --> $DIR/inductive-not-on-stack.rs:35:13 - | -LL | impl<T: AR> BR for T {} - | -- ^^ ^ - | | - | unsatisfied trait bound introduced here -note: required for `()` to implement `CR` - --> $DIR/inductive-not-on-stack.rs:36:13 - | -LL | impl<T: BR> CR for T {} - | -- ^^ ^ - | | - | unsatisfied trait bound introduced here -note: required for `()` to implement `AR` - --> $DIR/inductive-not-on-stack.rs:34:18 - | -LL | impl<T: CR + BR> AR for T {} - | -- ^^ ^ - | | - | unsatisfied trait bound introduced here - = note: 6 redundant requirements hidden - = note: required for `()` to implement `AR` note: required by a bound in `impls_ar` --> $DIR/inductive-not-on-stack.rs:38:16 | diff --git a/tests/ui/traits/next-solver/cycles/mixed-cycles-1.rs b/tests/ui/traits/next-solver/cycles/mixed-cycles-1.rs index b90a354be1b..6d75d241864 100644 --- a/tests/ui/traits/next-solver/cycles/mixed-cycles-1.rs +++ b/tests/ui/traits/next-solver/cycles/mixed-cycles-1.rs @@ -35,5 +35,5 @@ fn impls_a<T: A>() {} fn main() { impls_a::<()>(); - //~^ ERROR overflow evaluating the requirement `(): CInd` + //~^ ERROR overflow evaluating the requirement `(): A` } diff --git a/tests/ui/traits/next-solver/cycles/mixed-cycles-1.stderr b/tests/ui/traits/next-solver/cycles/mixed-cycles-1.stderr index 03e61dbf99c..17544eb1da5 100644 --- a/tests/ui/traits/next-solver/cycles/mixed-cycles-1.stderr +++ b/tests/ui/traits/next-solver/cycles/mixed-cycles-1.stderr @@ -1,46 +1,9 @@ -error[E0275]: overflow evaluating the requirement `(): CInd` +error[E0275]: overflow evaluating the requirement `(): A` --> $DIR/mixed-cycles-1.rs:37:15 | LL | impls_a::<()>(); | ^^ | -note: required for `()` to implement `B` - --> $DIR/mixed-cycles-1.rs:31:28 - | -LL | impl<T: ?Sized + CInd + C> B for T {} - | ---- ^ ^ - | | - | unsatisfied trait bound introduced here -note: required for `()` to implement `C` - --> $DIR/mixed-cycles-1.rs:32:25 - | -LL | impl<T: ?Sized + B + A> C for T {} - | - ^ ^ - | | - | unsatisfied trait bound introduced here -note: required for `()` to implement `CInd` - --> $DIR/mixed-cycles-1.rs:28:21 - | -LL | impl<T: ?Sized + C> CInd for T {} - | - ^^^^ ^ - | | - | unsatisfied trait bound introduced here - = note: 4 redundant requirements hidden - = note: required for `()` to implement `B` -note: required for `()` to implement `BInd` - --> $DIR/mixed-cycles-1.rs:23:21 - | -LL | impl<T: ?Sized + B> BInd for T {} - | - ^^^^ ^ - | | - | unsatisfied trait bound introduced here -note: required for `()` to implement `A` - --> $DIR/mixed-cycles-1.rs:30:28 - | -LL | impl<T: ?Sized + BInd + C> A for T {} - | ---- ^ ^ - | | - | unsatisfied trait bound introduced here note: required by a bound in `impls_a` --> $DIR/mixed-cycles-1.rs:34:15 | diff --git a/tests/ui/traits/next-solver/cycles/mixed-cycles-2.rs b/tests/ui/traits/next-solver/cycles/mixed-cycles-2.rs index a3ffcaafb37..c939a6e5ef2 100644 --- a/tests/ui/traits/next-solver/cycles/mixed-cycles-2.rs +++ b/tests/ui/traits/next-solver/cycles/mixed-cycles-2.rs @@ -28,5 +28,5 @@ fn impls_a<T: A>() {} fn main() { impls_a::<()>(); - //~^ ERROR overflow evaluating the requirement `(): BInd` + //~^ ERROR overflow evaluating the requirement `(): A` } diff --git a/tests/ui/traits/next-solver/cycles/mixed-cycles-2.stderr b/tests/ui/traits/next-solver/cycles/mixed-cycles-2.stderr index 892426abe82..a9be1016c74 100644 --- a/tests/ui/traits/next-solver/cycles/mixed-cycles-2.stderr +++ b/tests/ui/traits/next-solver/cycles/mixed-cycles-2.stderr @@ -1,32 +1,9 @@ -error[E0275]: overflow evaluating the requirement `(): BInd` +error[E0275]: overflow evaluating the requirement `(): A` --> $DIR/mixed-cycles-2.rs:30:15 | LL | impls_a::<()>(); | ^^ | -note: required for `()` to implement `B` - --> $DIR/mixed-cycles-2.rs:25:24 - | -LL | impl<T: ?Sized + BInd> B for T {} - | ---- ^ ^ - | | - | unsatisfied trait bound introduced here -note: required for `()` to implement `BInd` - --> $DIR/mixed-cycles-2.rs:22:21 - | -LL | impl<T: ?Sized + B> BInd for T {} - | - ^^^^ ^ - | | - | unsatisfied trait bound introduced here - = note: 6 redundant requirements hidden - = note: required for `()` to implement `BInd` -note: required for `()` to implement `A` - --> $DIR/mixed-cycles-2.rs:24:28 - | -LL | impl<T: ?Sized + BInd + B> A for T {} - | ---- ^ ^ - | | - | unsatisfied trait bound introduced here note: required by a bound in `impls_a` --> $DIR/mixed-cycles-2.rs:27:15 | diff --git a/tests/ui/traits/next-solver/diagnostics/ambiguous-fail.rs b/tests/ui/traits/next-solver/diagnostics/ambiguous-fail.rs new file mode 100644 index 00000000000..4094ab84166 --- /dev/null +++ b/tests/ui/traits/next-solver/diagnostics/ambiguous-fail.rs @@ -0,0 +1,21 @@ +//@ compile-flags: -Znext-solver + +trait Trait { + type Assoc; +} + +struct W<T>(*mut T); +impl<T> Trait for W<W<T>> +where + W<T>: Trait, +{ + type Assoc = (); +} + +trait NoOverlap {} +impl<T: Trait> NoOverlap for T {} + +impl<T: Trait<Assoc = u32>> NoOverlap for W<T> {} +//~^ ERROR conflicting implementations of trait `NoOverlap` for type `W<_>` + +fn main() {} diff --git a/tests/ui/traits/next-solver/diagnostics/ambiguous-fail.stderr b/tests/ui/traits/next-solver/diagnostics/ambiguous-fail.stderr new file mode 100644 index 00000000000..42be1960563 --- /dev/null +++ b/tests/ui/traits/next-solver/diagnostics/ambiguous-fail.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `NoOverlap` for type `W<_>` + --> $DIR/ambiguous-fail.rs:18:1 + | +LL | impl<T: Trait> NoOverlap for T {} + | ------------------------------ first implementation here +LL | +LL | impl<T: Trait<Assoc = u32>> NoOverlap for W<T> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `W<_>` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/tests/ui/traits/next-solver/diagnostics/ambiguous-pass.rs b/tests/ui/traits/next-solver/diagnostics/ambiguous-pass.rs new file mode 100644 index 00000000000..2d40ba37a89 --- /dev/null +++ b/tests/ui/traits/next-solver/diagnostics/ambiguous-pass.rs @@ -0,0 +1,21 @@ +//@ compile-flags: -Znext-solver + +trait Trait { + type Assoc; +} + +struct W<T>(*mut T); +impl<T> Trait for W<W<T>> +where + W<T>: Trait, +{ + type Assoc = (); +} + +trait NoOverlap {} +impl<T: Trait> NoOverlap for T {} + +impl<T: Trait<Assoc = ()>> NoOverlap for W<T> {} +//~^ ERROR conflicting implementations of trait `NoOverlap` for type `W<_>` + +fn main() {} diff --git a/tests/ui/traits/next-solver/diagnostics/ambiguous-pass.stderr b/tests/ui/traits/next-solver/diagnostics/ambiguous-pass.stderr new file mode 100644 index 00000000000..5c77fc71e55 --- /dev/null +++ b/tests/ui/traits/next-solver/diagnostics/ambiguous-pass.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `NoOverlap` for type `W<_>` + --> $DIR/ambiguous-pass.rs:18:1 + | +LL | impl<T: Trait> NoOverlap for T {} + | ------------------------------ first implementation here +LL | +LL | impl<T: Trait<Assoc = ()>> NoOverlap for W<T> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `W<_>` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/tests/ui/traits/next-solver/issue-118950-root-region.rs b/tests/ui/traits/next-solver/issue-118950-root-region.rs index 8667b3fe466..9f6dea5d5bf 100644 --- a/tests/ui/traits/next-solver/issue-118950-root-region.rs +++ b/tests/ui/traits/next-solver/issue-118950-root-region.rs @@ -12,7 +12,7 @@ trait ToUnit<'a> { trait Overlap<T> {} type Assoc<'a, T> = <*const T as ToUnit<'a>>::Unit; -//~^ ERROR: not well-formed +//~^ ERROR the trait bound `*const T: ToUnit<'a>` is not satisfied impl<T> Overlap<T> for T {} diff --git a/tests/ui/traits/next-solver/issue-118950-root-region.stderr b/tests/ui/traits/next-solver/issue-118950-root-region.stderr index 5cb24fa19aa..2e0566cad08 100644 --- a/tests/ui/traits/next-solver/issue-118950-root-region.stderr +++ b/tests/ui/traits/next-solver/issue-118950-root-region.stderr @@ -13,11 +13,17 @@ LL | #![feature(lazy_type_alias)] = note: see issue #112792 <https://github.com/rust-lang/rust/issues/112792> for more information = note: `#[warn(incomplete_features)]` on by default -error: the type `<*const T as ToUnit<'a>>::Unit` is not well-formed +error[E0277]: the trait bound `*const T: ToUnit<'a>` is not satisfied --> $DIR/issue-118950-root-region.rs:14:21 | LL | type Assoc<'a, T> = <*const T as ToUnit<'a>>::Unit; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `ToUnit<'a>` is not implemented for `*const T` + | +help: this trait has no implementations, consider adding one + --> $DIR/issue-118950-root-region.rs:8:1 + | +LL | trait ToUnit<'a> { + | ^^^^^^^^^^^^^^^^ WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: ['^0.Named(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), "'a"), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) } WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: ['^0.Named(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), "'a"), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc) } @@ -34,5 +40,5 @@ LL | impl<T> Overlap<for<'a> fn(Assoc<'a, T>)> for T where Missing: Overlap<T> { error: aborting due to 3 previous errors; 1 warning emitted -Some errors have detailed explanations: E0119, E0412. +Some errors have detailed explanations: E0119, E0277, E0412. For more information about an error, try `rustc --explain E0119`. diff --git a/tests/ui/traits/next-solver/member-constraints-in-root-universe.rs b/tests/ui/traits/next-solver/member-constraints-in-root-universe.rs deleted file mode 100644 index a5696fc7796..00000000000 --- a/tests/ui/traits/next-solver/member-constraints-in-root-universe.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ compile-flags: -Znext-solver - -trait Trait { - type Ty; -} - -impl Trait for for<'a> fn(&'a u8, &'a u8) { - type Ty = (); -} - -// argument is necessary to create universes before registering the hidden type. -fn test<'a>(_: <fn(&u8, &u8) as Trait>::Ty) -> impl Sized { - //~^ ERROR the type `<for<'a, 'b> fn(&'a u8, &'b u8) as Trait>::Ty` is not well-formed - "hidden type is `&'?0 str` with '?0 member of ['static,]" -} - -fn main() {} diff --git a/tests/ui/traits/next-solver/member-constraints-in-root-universe.stderr b/tests/ui/traits/next-solver/member-constraints-in-root-universe.stderr deleted file mode 100644 index 7a9982f07f6..00000000000 --- a/tests/ui/traits/next-solver/member-constraints-in-root-universe.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: the type `<for<'a, 'b> fn(&'a u8, &'b u8) as Trait>::Ty` is not well-formed - --> $DIR/member-constraints-in-root-universe.rs:12:16 - | -LL | fn test<'a>(_: <fn(&u8, &u8) as Trait>::Ty) -> impl Sized { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/traits/next-solver/object-unsafety.rs b/tests/ui/traits/next-solver/object-unsafety.rs index 3aa1af4956e..a347984daf6 100644 --- a/tests/ui/traits/next-solver/object-unsafety.rs +++ b/tests/ui/traits/next-solver/object-unsafety.rs @@ -10,9 +10,8 @@ fn copy<U: Setup + ?Sized>(from: &U::From) -> U::From { pub fn copy_any<T>(t: &T) -> T { copy::<dyn Setup<From=T>>(t) - //~^ ERROR the type `&<dyn Setup<From = T> as Setup>::From` is not well-formed + //~^ ERROR the trait bound `T: Copy` is not satisfied in `dyn Setup<From = T>` //~| ERROR mismatched types - //~| ERROR the type `<dyn Setup<From = T> as Setup>::From` is not well-formed //~| ERROR the trait bound `T: Copy` is not satisfied // FIXME(-Znext-solver): These error messages are horrible and some of them diff --git a/tests/ui/traits/next-solver/object-unsafety.stderr b/tests/ui/traits/next-solver/object-unsafety.stderr index 7c9a6077fe7..75d0ce24413 100644 --- a/tests/ui/traits/next-solver/object-unsafety.stderr +++ b/tests/ui/traits/next-solver/object-unsafety.stderr @@ -15,12 +15,6 @@ help: consider restricting type parameter `T` LL | pub fn copy_any<T: std::marker::Copy>(t: &T) -> T { | +++++++++++++++++++ -error: the type `&<dyn Setup<From = T> as Setup>::From` is not well-formed - --> $DIR/object-unsafety.rs:12:31 - | -LL | copy::<dyn Setup<From=T>>(t) - | ^ - error[E0308]: mismatched types --> $DIR/object-unsafety.rs:12:31 | @@ -37,13 +31,19 @@ note: function defined here LL | fn copy<U: Setup + ?Sized>(from: &U::From) -> U::From { | ^^^^ -------------- -error: the type `<dyn Setup<From = T> as Setup>::From` is not well-formed +error[E0277]: the trait bound `T: Copy` is not satisfied in `dyn Setup<From = T>` --> $DIR/object-unsafety.rs:12:5 | LL | copy::<dyn Setup<From=T>>(t) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `dyn Setup<From = T>`, the trait `Copy` is not implemented for `T`, which is required by `dyn Setup<From = T>: Setup` + | + = note: required because it appears within the type `dyn Setup<From = T>` +help: consider restricting type parameter `T` + | +LL | pub fn copy_any<T: std::marker::Copy>(t: &T) -> T { + | +++++++++++++++++++ -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors Some errors have detailed explanations: E0277, E0308. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/next-solver/overflow/exponential-trait-goals.rs b/tests/ui/traits/next-solver/overflow/exponential-trait-goals.rs index 052d803765d..186d0e8be56 100644 --- a/tests/ui/traits/next-solver/overflow/exponential-trait-goals.rs +++ b/tests/ui/traits/next-solver/overflow/exponential-trait-goals.rs @@ -15,5 +15,5 @@ fn impls<T: Trait>() {} fn main() { impls::<W<_>>(); - //~^ ERROR overflow evaluating the requirement `_: Sized` + //~^ ERROR overflow evaluating the requirement `W<_>: Trait` } diff --git a/tests/ui/traits/next-solver/overflow/exponential-trait-goals.stderr b/tests/ui/traits/next-solver/overflow/exponential-trait-goals.stderr index 6583cae8bb9..b032ae3e740 100644 --- a/tests/ui/traits/next-solver/overflow/exponential-trait-goals.stderr +++ b/tests/ui/traits/next-solver/overflow/exponential-trait-goals.stderr @@ -1,16 +1,9 @@ -error[E0275]: overflow evaluating the requirement `_: Sized` +error[E0275]: overflow evaluating the requirement `W<_>: Trait` --> $DIR/exponential-trait-goals.rs:17:13 | LL | impls::<W<_>>(); | ^^^^ | -note: required for `W<(W<_>, W<_>)>` to implement `Trait` - --> $DIR/exponential-trait-goals.rs:7:12 - | -LL | impl<T, U> Trait for W<(W<T>, W<U>)> - | - ^^^^^ ^^^^^^^^^^^^^^^ - | | - | unsatisfied trait bound introduced here note: required by a bound in `impls` --> $DIR/exponential-trait-goals.rs:14:13 | diff --git a/tests/ui/traits/next-solver/overflow/global-cache.stderr b/tests/ui/traits/next-solver/overflow/global-cache.stderr index 9e467721e83..67616619384 100644 --- a/tests/ui/traits/next-solver/overflow/global-cache.stderr +++ b/tests/ui/traits/next-solver/overflow/global-cache.stderr @@ -5,15 +5,6 @@ LL | impls_trait::<Four<Four<Four<Four<()>>>>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "18"]` attribute to your crate (`global_cache`) -note: required for `Inc<Inc<Inc<Inc<Inc<Inc<Inc<Inc<Inc<Inc<Inc<()>>>>>>>>>>>` to implement `Trait` - --> $DIR/global-cache.rs:12:16 - | -LL | impl<T: Trait> Trait for Inc<T> {} - | ----- ^^^^^ ^^^^^^ - | | - | unsatisfied trait bound introduced here - = note: 5 redundant requirements hidden - = note: required for `Inc<Inc<Inc<Inc<Inc<Inc<Inc<Inc<Inc<Inc<Inc<Inc<Inc<Inc<Inc<Inc<()>>>>>>>>>>>>>>>>` to implement `Trait` note: required by a bound in `impls_trait` --> $DIR/global-cache.rs:15:19 | diff --git a/tests/ui/unpretty/auxiliary/data.txt b/tests/ui/unpretty/auxiliary/data.txt new file mode 100644 index 00000000000..2f62e4609f4 --- /dev/null +++ b/tests/ui/unpretty/auxiliary/data.txt @@ -0,0 +1 @@ +data for include_bytes in ../expanded-exhaustive.rs diff --git a/tests/ui/unpretty/expanded-exhaustive.rs b/tests/ui/unpretty/expanded-exhaustive.rs new file mode 100644 index 00000000000..6aa032d7ed8 --- /dev/null +++ b/tests/ui/unpretty/expanded-exhaustive.rs @@ -0,0 +1,888 @@ +//@ compile-flags: -Zunpretty=expanded -Zunstable-options +//@ edition:2024 +//@ check-pass + +#![feature(async_closure)] +#![feature(auto_traits)] +#![feature(box_patterns)] +#![feature(builtin_syntax)] +#![feature(concat_idents)] +#![feature(const_trait_impl)] +#![feature(core_pattern_type)] +#![feature(decl_macro)] +#![feature(deref_patterns)] +#![feature(explicit_tail_calls)] +#![feature(gen_blocks)] +#![feature(let_chains)] +#![feature(more_qualified_paths)] +#![feature(never_patterns)] +#![feature(never_type)] +#![feature(pattern_types)] +#![feature(prelude_import)] +#![feature(raw_ref_op)] +#![feature(specialization)] +#![feature(trace_macros)] +#![feature(trait_alias)] +#![feature(try_blocks)] +#![feature(unnamed_fields)] +#![feature(yeet_expr)] +#![allow(incomplete_features)] + +#[prelude_import] +use self::prelude::*; + +mod prelude { + pub use std::prelude::rust_2024::*; + + pub type T = _; + + pub trait Trait { + const CONST: (); + } +} + +mod attributes { + //! inner single-line doc comment + /*! + * inner multi-line doc comment + */ + #![doc = "inner doc attribute"] + #![allow(dead_code, unused_variables)] + #![no_std] + + /// outer single-line doc comment + /** + * outer multi-line doc comment + */ + #[doc = "outer doc attribute"] + #[doc = concat!("mac", "ro")] + #[allow()] + #[repr(C)] + struct Struct; +} + +mod expressions { + /// ExprKind::Array + fn expr_array() { + []; + [true]; + [true,]; + [true, true]; + ["long........................................................................"]; + ["long............................................................", true]; + } + + /// ExprKind::ConstBlock + fn expr_const_block() { + const {}; + const { 1 }; + const { struct S; }; + } + + /// ExprKind::Call + fn expr_call() { + let f; + f(); + f::<u8>(); + f::<1>(); + f::<'static, u8, 1>(); + f(true); + f(true,); + ()(); + } + + /// ExprKind::MethodCall + fn expr_method_call() { + let x; + x.f(); + x.f::<u8>(); + x.collect::<Vec<_>>(); + } + + /// ExprKind::Tup + fn expr_tup() { + (); + (true,); + (true, false); + (true, false,); + } + + /// ExprKind::Binary + fn expr_binary() { + let (a, b, c, d, x, y); + true || false; + true || false && false; + a < 1 && 2 < b && c > 3 && 4 > d; + a & b & !c; + a + b * c - d + -1 * -2 - -3; + x = !y; + } + + /// ExprKind::Unary + fn expr_unary() { + let expr; + *expr; + !expr; + -expr; + } + + /// ExprKind::Lit + fn expr_lit() { + 'x'; + 1_000_i8; + 1.00000000000000000000001; + } + + /// ExprKind::Cast + fn expr_cast() { + let expr; + expr as T; + expr as T<u8>; + } + + /// ExprKind::Type + fn expr_type() { + let expr; + builtin # type_ascribe(expr, T); + } + + /// ExprKind::Let + fn expr_let() { + let b; + if let Some(a) = b {} + if let _ = true && false {} + if let _ = (true && false) {} + } + + /// ExprKind::If + fn expr_if() { + if true {} + if !true {} + if let true = true {} else {} + if true {} else if false {} + if true {} else if false {} else {} + if true { return; } else if false { 0 } else { 0 } + } + + /// ExprKind::While + fn expr_while() { + while false {} + 'a: while false {} + while let true = true {} + } + + /// ExprKind::ForLoop + fn expr_for_loop() { + let x; + for _ in x {} + 'a: for _ in x {} + } + + /// ExprKind::Loop + fn expr_loop() { + loop {} + 'a: loop {} + } + + /// ExprKind::Match + fn expr_match() { + let value; + match value {} + match value { ok => 1 } + match value { + ok => 1, + err => 0, + } + } + + /// ExprKind::Closure + fn expr_closure() { + let value; + || {}; + |x| {}; + |x: u8| {}; + || (); + move || value; + async || value; + async move || value; + static || value; + static move || value; + (static async || value); + (static async move || value); + || -> u8 { value }; + 1 + || {}; + } + + /// ExprKind::Block + fn expr_block() { + {} + unsafe {} + 'a: {} + #[allow()] {} + { #![allow()] } + } + + /// ExprKind::Gen + fn expr_gen() { + async {}; + async move {}; + gen {}; + gen move {}; + async gen {}; + async gen move {}; + } + + /// ExprKind::Await + fn expr_await() { + let fut; + fut.await; + } + + /// ExprKind::TryBlock + fn expr_try_block() { + try {} + try { return; } + } + + /// ExprKind::Assign + fn expr_assign() { + let expr; + expr = true; + } + + /// ExprKind::AssignOp + fn expr_assign_op() { + let expr; + expr += true; + } + + /// ExprKind::Field + fn expr_field() { + let expr; + expr.field; + expr.0; + } + + /// ExprKind::Index + fn expr_index() { + let expr; + expr[true]; + } + + /// ExprKind::Range + fn expr_range() { + let (lo, hi); + ..; + ..hi; + lo..; + lo..hi; + lo .. hi; + ..=hi; + lo..=hi; + -2..=-1; + } + + /// ExprKind::Underscore + fn expr_underscore() { + _; + } + + /// ExprKind::Path + fn expr_path() { + let x; + crate::expressions::expr_path; + crate::expressions::expr_path::<'static>; + <T as Default>::default; + <T as ::core::default::Default>::default::<>; + x::(); + x::(T, T) -> T; + crate::() -> ()::expressions::() -> ()::expr_path; + core::()::marker::()::PhantomData; + } + + /// ExprKind::AddrOf + fn expr_addr_of() { + let expr; + &expr; + &mut expr; + &raw const expr; + &raw mut expr; + } + + /// ExprKind::Break + fn expr_break() { + 'a: { + break; + break 'a; + break true; + break 'a true; + } + } + + /// ExprKind::Continue + fn expr_continue() { + 'a: { + continue; + continue 'a; + } + } + + /// ExprKind::Ret + fn expr_ret() { + return; + return true; + } + + /// ExprKind::InlineAsm + fn expr_inline_asm() { + let x; + core::arch::asm!( + "mov {tmp}, {x}", + "shl {tmp}, 1", + "shl {x}, 2", + "add {x}, {tmp}", + x = inout(reg) x, + tmp = out(reg) _, + ); + } + + /// ExprKind::OffsetOf + fn expr_offset_of() { + core::mem::offset_of!(T, field); + } + + /// ExprKind::MacCall + fn expr_mac_call() { + stringify!(...); + stringify![...]; + stringify! { ... }; + } + + /// ExprKind::Struct + fn expr_struct() { + struct Struct {} + let (x, base); + Struct {}; + <Struct as ToOwned>::Owned {}; + Struct { .. }; + Struct { .. base }; + Struct { x }; + Struct { x, ..base }; + Struct { x: true }; + Struct { x: true, .. }; + Struct { x: true, ..base }; + Struct { 0: true, ..base }; + } + + /// ExprKind::Repeat + fn expr_repeat() { + [(); 0]; + } + + /// ExprKind::Paren + fn expr_paren() { + let expr; + (expr); + } + + /// ExprKind::Try + fn expr_try() { + let expr; + expr?; + } + + /// ExprKind::Yield + fn expr_yield() { + yield; + yield true; + } + + /// ExprKind::Yeet + fn expr_yeet() { + do yeet; + do yeet 0; + } + + /// ExprKind::Become + fn expr_become() { + become true; + } + + /// ExprKind::IncludedBytes + fn expr_include_bytes() { + include_bytes!("auxiliary/data.txt"); + } + + /// ExprKind::FormatArgs + fn expr_format_args() { + let expr; + format_args!(""); + format_args!("{}", expr); + } +} + +mod items { + /// ItemKind::ExternCrate + mod item_extern_crate { + extern crate core; + extern crate self as unpretty; + pub extern crate core as _; + } + + /// ItemKind::Use + mod item_use { + use crate::{expressions, items::item_use}; + pub use core::*; + } + + /// ItemKind::Static + mod item_static { + pub static A: () = {}; + static mut B: () = {}; + } + + /// ItemKind::Const + mod item_const { + pub const A: () = {}; + + trait TraitItems { + const B: (); + const C: () = {}; + } + } + + /// ItemKind::Fn + mod item_fn { + pub const unsafe extern "C" fn f() {} + pub async unsafe extern fn g() {} + fn h<'a, T>() where T: 'a {} + + trait TraitItems { + unsafe extern fn f(); + } + + impl TraitItems for _ { + default unsafe extern fn f() {} + } + } + + /// ItemKind::Mod + mod item_mod { + // ... + } + + /// ItemKind::ForeignMod + mod item_foreign_mod { + extern "C++" {} + extern {} + } + + /// ItemKind::GlobalAsm + mod item_global_asm { + core::arch::global_asm!(".globl my_asm_func"); + } + + /// ItemKind::TyAlias + mod item_ty_alias { + pub type Type<'a> where T: 'a, = T; + } + + /// ItemKind::Enum + mod item_enum { + pub enum Void {} + enum Empty { + Unit, + Tuple(), + Struct {}, + } + enum Generic<'a, T> + where + T: 'a, + { + Tuple(T), + Struct { t: T }, + } + } + + /// ItemKind::Struct + mod item_struct { + pub struct Unit; + struct Tuple(); + struct Newtype(Unit); + struct Struct {} + struct Generic<'a, T> + where + T: 'a, + { + t: T, + } + } + + /// ItemKind::Union + mod item_union { + union Generic<'a, T> + where + T: 'a, + { + t: T, + } + } + + /// ItemKind::Trait + mod item_trait { + pub unsafe auto trait Send {} + trait Trait<'a>: Sized + where + Self: 'a, + { + } + } + + /// ItemKind::TraitAlias + mod item_trait_alias { + pub trait Trait<T> = Sized where for<'a> T: 'a; + } + + /// ItemKind::Impl + mod item_impl { + impl () {} + impl<T> () {} + impl Default for () {} + impl<T> const Default for () {} + } + + /// ItemKind::MacCall + mod item_mac_call { + trace_macros!(false); + trace_macros![false]; + trace_macros! { false } + } + + /// ItemKind::MacroDef + mod item_macro_def { + macro_rules! mac { () => {...}; } + pub macro stringify() {} + } + + /// ItemKind::Delegation + mod item_delegation { + /*! FIXME: todo */ + } + + /// ItemKind::DelegationMac + mod item_delegation_mac { + /*! FIXME: todo */ + } +} + +mod patterns { + /// PatKind::Wild + fn pat_wild() { + let _; + } + + /// PatKind::Ident + fn pat_ident() { + let x; + let ref x; + let mut x; + let ref mut x; + let ref mut x @ _; + } + + /// PatKind::Struct + fn pat_struct() { + let T {}; + let T::<T> {}; + let T::<'static> {}; + let T { x }; + let T { x: _x }; + let T { .. }; + let T { x, .. }; + let T { x: _x, .. }; + let T { 0: _x, .. }; + let <T as ToOwned>::Owned {}; + } + + /// PatKind::TupleStruct + fn pat_tuple_struct() { + struct Tuple(); + let Tuple(); + let Tuple::<T>(); + let Tuple::<'static>(); + let Tuple(x); + let Tuple(..); + let Tuple(x, ..); + } + + /// PatKind::Or + fn pat_or() { + let (true | false); + let (| true); + let (|true| false); + } + + /// PatKind::Path + fn pat_path() { + let core::marker::PhantomData; + let core::marker::PhantomData::<T>; + let core::marker::PhantomData::<'static>; + let <T as Trait>::CONST; + } + + /// PatKind::Tuple + fn pat_tuple() { + let (); + let (true,); + let (true, false); + } + + /// PatKind::Box + fn pat_box() { + let box pat; + } + + /// PatKind::Deref + fn pat_deref() { + let deref!(pat); + } + + /// PatKind::Ref + fn pat_ref() { + let &pat; + let &mut pat; + } + + /// PatKind::Lit + fn pat_lit() { + let 1_000_i8; + let -""; + } + + /// PatKind::Range + fn pat_range() { + let ..1; + let 0..; + let 0..1; + let 0..=1; + let -2..=-1; + } + + /// PatKind::Slice + fn pat_slice() { + let []; + let [true]; + let [true,]; + let [true, false]; + } + + /// PatKind::Rest + fn pat_rest() { + let ..; + } + + /// PatKind::Never + fn pat_never() { + let !; + let Some(!); + } + + /// PatKind::Paren + fn pat_paren() { + let (pat); + } + + /// PatKind::MacCall + fn pat_mac_call() { + let stringify!(); + let stringify![]; + let stringify! {}; + } +} + +mod statements { + /// StmtKind::Let + fn stmt_let() { + let _; + let _ = true; + let _: T = true; + let _ = true else { return; }; + } + + /// StmtKind::Item + fn stmt_item() { + struct Struct {} + struct Unit; + } + + /// StmtKind::Expr + fn stmt_expr() { + () + } + + /// StmtKind::Semi + fn stmt_semi() { + 1 + 1; + } + + /// StmtKind::Empty + fn stmt_empty() { + ; + } + + /// StmtKind::MacCall + fn stmt_mac_call() { + stringify!(...); + stringify![...]; + stringify! { ... }; + } +} + +mod types { + /// TyKind::Slice + fn ty_slice() { + let _: [T]; + } + + /// TyKind::Array + fn ty_array() { + let _: [T; 0]; + } + + /// TyKind::Ptr + fn ty_ptr() { + let _: *const T; + let _: *mut T; + } + + /// TyKind::Ref + fn ty_ref() { + let _: &T; + let _: &mut T; + let _: &'static T; + let _: &'static mut [T]; + let _: &T<T<T<T<T>>>>; + let _: &T<T<T<T<T> > > >; + } + + /// TyKind::BareFn + fn ty_bare_fn() { + let _: fn(); + let _: fn() -> (); + let _: fn(T); + let _: fn(t: T); + let _: for<> fn(); + let _: for<'a> fn(); + } + + /// TyKind::Never + fn ty_never() { + let _: !; + } + + /// TyKind::Tup + fn ty_tup() { + let _: (); + let _: (T,); + let _: (T, T); + } + + /// TyKind::AnonStruct + fn ty_anon_struct() { + struct Struct { + _: struct { t: T }, + } + } + + /// TyKind::AnonUnion + fn ty_anon_union() { + struct Struct { + _: union { t: T }, + } + } + + /// TyKind::Path + fn ty_path() { + let _: T; + let _: T<'static>; + let _: T<T>; + let _: T::<T>; + let _: T() -> !; + let _: <T as ToOwned>::Owned; + } + + /// TyKind::TraitObject + fn ty_trait_object() { + let _: dyn Send; + let _: dyn Send + 'static; + let _: dyn 'static + Send; + let _: dyn for<'a> Send; + } + + /// TyKind::ImplTrait + const fn ty_impl_trait() { + let _: impl Send; + let _: impl Send + 'static; + let _: impl 'static + Send; + let _: impl ?Sized; + let _: impl ~const Clone; + let _: impl for<'a> Send; + } + + /// TyKind::Paren + fn ty_paren() { + let _: (T); + } + + /// TyKind::Typeof + fn ty_typeof() { + /*! unused for now */ + } + + /// TyKind::Infer + fn ty_infer() { + let _: _; + } + + /// TyKind::ImplicitSelf + fn ty_implicit_self() { + /*! there is no syntax for this */ + } + + /// TyKind::MacCall + fn ty_mac_call() { + let _: concat_idents!(T); + let _: concat_idents![T]; + let _: concat_idents! { T }; + } + + /// TyKind::CVarArgs + fn ty_c_var_args() { + /*! FIXME: todo */ + } + + /// TyKind::Pat + fn ty_pat() { + let _: core::pattern_type!(u32 is 1..); + } +} + +mod visibilities { + /// VisibilityKind::Public + mod visibility_public { + pub struct Pub; + } + + /// VisibilityKind::Restricted + mod visibility_restricted { + pub(crate) struct PubCrate; + pub(self) struct PubSelf; + pub(super) struct PubSuper; + pub(in crate) struct PubInCrate; + pub(in self) struct PubInSelf; + pub(in super) struct PubInSuper; + pub(in crate::visibilities) struct PubInCrateVisibilities; + pub(in self::super) struct PubInSelfSuper; + pub(in super::visibility_restricted) struct PubInSuperMod; + } +} diff --git a/tests/ui/unpretty/expanded-exhaustive.stdout b/tests/ui/unpretty/expanded-exhaustive.stdout new file mode 100644 index 00000000000..325bace7b56 --- /dev/null +++ b/tests/ui/unpretty/expanded-exhaustive.stdout @@ -0,0 +1,719 @@ +#![feature(prelude_import)] +//@ compile-flags: -Zunpretty=expanded -Zunstable-options +//@ edition:2024 +//@ check-pass + +#![feature(async_closure)] +#![feature(auto_traits)] +#![feature(box_patterns)] +#![feature(builtin_syntax)] +#![feature(concat_idents)] +#![feature(const_trait_impl)] +#![feature(core_pattern_type)] +#![feature(decl_macro)] +#![feature(deref_patterns)] +#![feature(explicit_tail_calls)] +#![feature(gen_blocks)] +#![feature(let_chains)] +#![feature(more_qualified_paths)] +#![feature(never_patterns)] +#![feature(never_type)] +#![feature(pattern_types)] +#![feature(prelude_import)] +#![feature(raw_ref_op)] +#![feature(specialization)] +#![feature(trace_macros)] +#![feature(trait_alias)] +#![feature(try_blocks)] +#![feature(unnamed_fields)] +#![feature(yeet_expr)] +#![allow(incomplete_features)] +#[prelude_import] +use std::prelude::rust_2024::*; +#[macro_use] +extern crate std; + +#[prelude_import] +use self::prelude::*; + +mod prelude { + pub use std::prelude::rust_2024::*; + + pub type T = _; + + pub trait Trait { + const CONST: (); + } +} + +mod attributes { + //! inner single-line doc comment + /*! + * inner multi-line doc comment + */ + #![doc = "inner doc attribute"] + #![allow(dead_code, unused_variables)] + #![no_std] + + /// outer single-line doc comment + /** + * outer multi-line doc comment + */ + #[doc = "outer doc attribute"] + #[doc = "macro"] + #[allow()] + #[repr(C)] + struct Struct; +} + +mod expressions { + /// ExprKind::Array + fn expr_array() { + []; + [true]; + [true]; + [true, true]; + ["long........................................................................"]; + ["long............................................................", + true]; + } + + /// ExprKind::ConstBlock + fn expr_const_block() { + const {}; + const { 1 }; + const { + struct S; + }; + } + + /// ExprKind::Call + fn expr_call() { + let f; + f(); + f::<u8>(); + f::<1>(); + f::<'static, u8, 1>(); + f(true); + f(true); + ()(); + } + + /// ExprKind::MethodCall + fn expr_method_call() { + let x; + x.f(); + x.f::<u8>(); + x.collect::<Vec<_>>(); + } + + /// ExprKind::Tup + fn expr_tup() { (); (true,); (true, false); (true, false); } + + /// ExprKind::Binary + fn expr_binary() { + let (a, b, c, d, x, y); + true || false; + true || false && false; + a < 1 && 2 < b && c > 3 && 4 > d; + a & b & !c; + a + b * c - d + -1 * -2 - -3; + x = !y; + } + + /// ExprKind::Unary + fn expr_unary() { let expr; *expr; !expr; -expr; } + + /// ExprKind::Lit + fn expr_lit() { 'x'; 1_000_i8; 1.00000000000000000000001; } + + /// ExprKind::Cast + fn expr_cast() { let expr; expr as T; expr as T<u8>; } + + /// ExprKind::Type + fn expr_type() { let expr; builtin # type_ascribe(expr, T); } + + /// ExprKind::Let + fn expr_let() { + let b; + if let Some(a) = b {} + if let _ = true && false {} + if let _ = (true && false) {} + } + + /// ExprKind::If + fn expr_if() { + if true {} + if !true {} + if let true = true {} else {} + if true {} else if false {} + if true {} else if false {} else {} + if true { return; } else if false { 0 } else { 0 } + } + + /// ExprKind::While + fn expr_while() { + while false {} + 'a: while false {} + while let true = true {} + } + + /// ExprKind::ForLoop + fn expr_for_loop() { let x; for _ in x {} 'a: for _ in x {} } + + /// ExprKind::Loop + fn expr_loop() { loop {} 'a: loop {} } + + /// ExprKind::Match + fn expr_match() { + let value; + match value {} + match value { ok => 1, } + match value { ok => 1, err => 0, } + } + + /// ExprKind::Closure + fn expr_closure() { + let value; + || {}; + |x| {}; + |x: u8| {}; + || (); + move || value; + async || value; + async move || value; + static || value; + static move || value; + (static async || value); + (static async move || value); + || -> u8 { value }; + 1 + (|| {}); + } + + /// ExprKind::Block + fn expr_block() { + {} + unsafe {} + 'a: {} + + #[allow()] + {} + { + #![allow()] + } + } + + /// ExprKind::Gen + fn expr_gen() { + async {}; + async move {}; + gen {}; + gen move {}; + async gen {}; + async gen move {}; + } + + /// ExprKind::Await + fn expr_await() { let fut; fut.await; } + + /// ExprKind::TryBlock + fn expr_try_block() { try {} try { return; } } + + /// ExprKind::Assign + fn expr_assign() { let expr; expr = true; } + + /// ExprKind::AssignOp + fn expr_assign_op() { let expr; expr += true; } + + /// ExprKind::Field + fn expr_field() { let expr; expr.field; expr.0; } + + /// ExprKind::Index + fn expr_index() { let expr; expr[true]; } + + /// ExprKind::Range + fn expr_range() { + let (lo, hi); + ..; + ..hi; + lo..; + lo..hi; + lo..hi; + ..=hi; + lo..=hi; + -2..=-1; + } + + /// ExprKind::Underscore + fn expr_underscore() { _; } + + /// ExprKind::Path + fn expr_path() { + let x; + crate::expressions::expr_path; + crate::expressions::expr_path::<'static>; + <T as Default>::default; + <T as ::core::default::Default>::default::<>; + x::(); + x::(T, T) -> T; + crate::() -> ()::expressions::() -> ()::expr_path; + core::()::marker::()::PhantomData; + } + + /// ExprKind::AddrOf + fn expr_addr_of() { + let expr; + &expr; + &mut expr; + &raw const expr; + &raw mut expr; + } + + /// ExprKind::Break + fn expr_break() { 'a: { break; break 'a; break true; break 'a true; } } + + /// ExprKind::Continue + fn expr_continue() { 'a: { continue; continue 'a; } } + + /// ExprKind::Ret + fn expr_ret() { return; return true; } + + /// ExprKind::InlineAsm + fn expr_inline_asm() { + let x; + asm!("mov {1}, {0}\nshl {1}, 1\nshl {0}, 2\nadd {0}, {1}", + inout(reg) + x, + out(reg) + _); + } + + /// ExprKind::OffsetOf + fn expr_offset_of() { + + + + + + + + + + + + + + + + + + + + // ... + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + { builtin # offset_of(T, field) }; + } + /// ExprKind::MacCall + fn expr_mac_call() { "..."; "..."; "..."; } + /// ExprKind::Struct + fn expr_struct() { + struct Struct {} + let (x, base); + Struct {}; + <Struct as ToOwned>::Owned {}; + Struct { .. }; + Struct { ..base }; + Struct { x }; + Struct { x, ..base }; + Struct { x: true }; + Struct { x: true, .. }; + Struct { x: true, ..base }; + Struct { 0: true, ..base }; + } + /// ExprKind::Repeat + fn expr_repeat() { [(); 0]; } + /// ExprKind::Paren + fn expr_paren() { let expr; (expr); } + /// ExprKind::Try + fn expr_try() { let expr; expr?; } + /// ExprKind::Yield + fn expr_yield() { yield; yield true; } + /// ExprKind::Yeet + fn expr_yeet() { do yeet; do yeet 0; } + /// ExprKind::Become + fn expr_become() { become true; } + /// ExprKind::IncludedBytes + fn expr_include_bytes() { + b"data for include_bytes in ../expanded-exhaustive.rs\n"; + } + /// ExprKind::FormatArgs + fn expr_format_args() { + let expr; + format_args!(""); + format_args!("{0}", expr); + } +} +mod items { + /// ItemKind::ExternCrate + mod item_extern_crate { + extern crate core; + extern crate self as unpretty; + pub extern crate core as _; + } + /// ItemKind::Use + mod item_use { + use crate::{expressions, items::item_use}; + pub use core::*; + } + /// ItemKind::Static + mod item_static { + pub static A: () = {}; + static mut B: () = {}; + } + /// ItemKind::Const + mod item_const { + pub const A: () = {}; + trait TraitItems { + const B: (); + const C: () = {}; + } + } + /// ItemKind::Fn + mod item_fn { + pub const unsafe extern "C" fn f() {} + pub async unsafe extern fn g() {} + fn h<'a, T>() where T: 'a {} + trait TraitItems { + unsafe extern fn f(); + } + impl TraitItems for _ { + default unsafe extern fn f() {} + } + } + /// ItemKind::Mod + mod item_mod { } + /// ItemKind::ForeignMod + mod item_foreign_mod { + extern "C++" {} + extern {} + } + /// ItemKind::GlobalAsm + mod item_global_asm { + global_asm! (".globl my_asm_func"); + } + /// ItemKind::TyAlias + mod item_ty_alias { + pub type Type<'a> where T: 'a = T; + } + /// ItemKind::Enum + mod item_enum { + pub enum Void {} + enum Empty { Unit, Tuple(), Struct {}, } + enum Generic<'a, T> where T: 'a { + Tuple(T), + Struct { + t: T, + }, + } + } + /// ItemKind::Struct + mod item_struct { + pub struct Unit; + struct Tuple(); + struct Newtype(Unit); + struct Struct {} + struct Generic<'a, T> where T: 'a { + t: T, + } + } + /// ItemKind::Union + mod item_union { + union Generic<'a, T> where T: 'a { + t: T, + } + } + /// ItemKind::Trait + mod item_trait { + pub unsafe auto trait Send {} + trait Trait<'a>: Sized where Self: 'a {} + } + /// ItemKind::TraitAlias + mod item_trait_alias { + pub trait Trait<T> = Sized where for<'a> T: 'a; + } + /// ItemKind::Impl + mod item_impl { + impl () {} + impl<T> () {} + impl Default for () {} + impl<T> const Default for () {} + } + /// ItemKind::MacCall + mod item_mac_call { } + /// ItemKind::MacroDef + mod item_macro_def { + macro_rules! mac { () => { ... }; } + pub macro stringify { () => {} } + } + /// ItemKind::Delegation + mod item_delegation { + /*! FIXME: todo */ + } + /// ItemKind::DelegationMac + mod item_delegation_mac { + /*! FIXME: todo */ + } +} +mod patterns { + /// PatKind::Wild + fn pat_wild() { let _; } + /// PatKind::Ident + fn pat_ident() { + let x; + let ref x; + let mut x; + let ref mut x; + let ref mut x @ _; + } + /// PatKind::Struct + fn pat_struct() { + let T {}; + let T::<T> {}; + let T::<'static> {}; + let T { x }; + let T { x: _x }; + let T { .. }; + let T { x, .. }; + let T { x: _x, .. }; + let T { 0: _x, .. }; + let <T as ToOwned>::Owned {}; + } + /// PatKind::TupleStruct + fn pat_tuple_struct() { + struct Tuple(); + let Tuple(); + let Tuple::<T>(); + let Tuple::<'static>(); + let Tuple(x); + let Tuple(..); + let Tuple(x, ..); + } + /// PatKind::Or + fn pat_or() { let (true | false); let (true); let (true | false); } + /// PatKind::Path + fn pat_path() { + let core::marker::PhantomData; + let core::marker::PhantomData::<T>; + let core::marker::PhantomData::<'static>; + let <T as Trait>::CONST; + } + /// PatKind::Tuple + fn pat_tuple() { let (); let (true,); let (true, false); } + /// PatKind::Box + fn pat_box() { let box pat; } + /// PatKind::Deref + fn pat_deref() { let deref!(pat); } + /// PatKind::Ref + fn pat_ref() { let &pat; let &mut pat; } + /// PatKind::Lit + fn pat_lit() { let 1_000_i8; let -""; } + /// PatKind::Range + fn pat_range() { let ..1; let 0..; let 0..1; let 0..=1; let -2..=-1; } + /// PatKind::Slice + fn pat_slice() { let []; let [true]; let [true]; let [true, false]; } + /// PatKind::Rest + fn pat_rest() { let ..; } + /// PatKind::Never + fn pat_never() { let !; let Some(!); } + /// PatKind::Paren + fn pat_paren() { let (pat); } + /// PatKind::MacCall + fn pat_mac_call() { let ""; let ""; let ""; } +} +mod statements { + /// StmtKind::Let + fn stmt_let() { + let _; + let _ = true; + let _: T = true; + let _ = true else { return; }; + } + /// StmtKind::Item + fn stmt_item() { + struct Struct {} + struct Unit; + } + /// StmtKind::Expr + fn stmt_expr() { () } + /// StmtKind::Semi + fn stmt_semi() { 1 + 1; } + /// StmtKind::Empty + fn stmt_empty() { ; } + /// StmtKind::MacCall + fn stmt_mac_call() { "..."; "..."; "..."; } +} +mod types { + /// TyKind::Slice + fn ty_slice() { let _: [T]; } + /// TyKind::Array + fn ty_array() { let _: [T; 0]; } + /// TyKind::Ptr + fn ty_ptr() { let _: *const T; let _: *mut T; } + /// TyKind::Ref + fn ty_ref() { + let _: &T; + let _: &mut T; + let _: &'static T; + let _: &'static mut [T]; + let _: &T<T<T<T<T>>>>; + let _: &T<T<T<T<T>>>>; + } + /// TyKind::BareFn + fn ty_bare_fn() { + let _: fn(); + let _: fn() -> (); + let _: fn(T); + let _: fn(t: T); + let _: fn(); + let _: for<'a> fn(); + } + /// TyKind::Never + fn ty_never() { let _: !; } + /// TyKind::Tup + fn ty_tup() { let _: (); let _: (T,); let _: (T, T); } + /// TyKind::AnonStruct + fn ty_anon_struct() { + struct Struct { + _: struct { + t: T, + }, + } + } + /// TyKind::AnonUnion + fn ty_anon_union() { + struct Struct { + _: union { + t: T, + }, + } + } + /// TyKind::Path + fn ty_path() { + let _: T; + let _: T<'static>; + let _: T<T>; + let _: T<T>; + let _: T() -> !; + let _: <T as ToOwned>::Owned; + } + /// TyKind::TraitObject + fn ty_trait_object() { + let _: dyn Send; + let _: dyn Send + 'static; + let _: dyn 'static + Send; + let _: dyn for<'a> Send; + } + /// TyKind::ImplTrait + const fn ty_impl_trait() { + let _: impl Send; + let _: impl Send + 'static; + let _: impl 'static + Send; + let _: impl ?Sized; + let _: impl ~const Clone; + let _: impl for<'a> Send; + } + /// TyKind::Paren + fn ty_paren() { let _: (T); } + /// TyKind::Typeof + fn ty_typeof() { + /*! unused for now */ + } + /// TyKind::Infer + fn ty_infer() { let _: _; } + /// TyKind::ImplicitSelf + fn ty_implicit_self() { + /*! there is no syntax for this */ + } + /// TyKind::MacCall + fn ty_mac_call() { let _: T; let _: T; let _: T; } + /// TyKind::CVarArgs + fn ty_c_var_args() { + /*! FIXME: todo */ + } + /// TyKind::Pat + fn ty_pat() { let _: u32 is 1..; } +} +mod visibilities { + /// VisibilityKind::Public + mod visibility_public { + pub struct Pub; + } + /// VisibilityKind::Restricted + mod visibility_restricted { + pub(crate) struct PubCrate; + pub(self) struct PubSelf; + pub(super) struct PubSuper; + pub(in crate) struct PubInCrate; + pub(in self) struct PubInSelf; + pub(in super) struct PubInSuper; + pub(in crate::visibilities) struct PubInCrateVisibilities; + pub(in self::super) struct PubInSelfSuper; + pub(in super::visibility_restricted) struct PubInSuperMod; + } +} diff --git a/tests/ui/unpretty/expanded-interpolation.rs b/tests/ui/unpretty/expanded-interpolation.rs new file mode 100644 index 00000000000..8f0e21ce870 --- /dev/null +++ b/tests/ui/unpretty/expanded-interpolation.rs @@ -0,0 +1,106 @@ +//@ compile-flags: -Zunpretty=expanded +//@ check-pass + +// This test covers the AST pretty-printer's insertion of parentheses in some +// macro metavariable edge cases. Synthetic parentheses (i.e. not appearing in +// the syntax tree) need to be printed in order for the printed code to be valid +// Rust syntax. We also test negative cases: the pretty-printer should not be +// synthesizing parentheses indiscriminately; only where necessary. + +#![feature(let_chains)] +#![feature(if_let_guard)] + +macro_rules! expr { + ($expr:expr) => { $expr }; +} + +macro_rules! stmt { + ($stmt:stmt) => { $stmt }; +} + +fn if_let() { + macro_rules! if_let { + ($pat:pat, $expr:expr) => { + if let $pat = $expr {} + }; + } + + if let no_paren = true && false {} + if_let!(paren_around_binary, true && false); + if_let!(no_paren, true); + + struct Struct {} + match () { + _ if let no_paren = Struct {} => {} + } +} + +fn let_else() { + let no_paren = expr!(1 + 1) else { return; }; + let paren_around_loop = expr!(loop {}) else { return; }; +} + +fn local() { + macro_rules! let_expr_minus_one { + ($pat:pat, $expr:expr) => { + let $pat = $expr - 1; + }; + } + + let void; + let_expr_minus_one!(no_paren, match void {}); + + macro_rules! let_expr_else_return { + ($pat:pat, $expr:expr) => { + let $pat = $expr else { return; }; + }; + } + + let_expr_else_return!(no_paren, void()); +} + +fn match_arm() { + macro_rules! match_arm { + ($pat:pat, $expr:expr) => { + match () { $pat => $expr } + }; + } + + match_arm!(no_paren, 1 - 1); + match_arm!(paren_around_brace, { 1 } - 1); +} + +/// https://github.com/rust-lang/rust/issues/98790 +fn stmt_boundary() { + macro_rules! expr_as_stmt { + ($expr:expr) => { + stmt!($expr) + }; + } + + let paren_around_match; + expr_as_stmt!(match paren_around_match {} | true); + + macro_rules! minus_one { + ($expr:expr) => { + expr_as_stmt!($expr - 1) + }; + } + + let (no_paren, paren_around_loop); + minus_one!(no_paren); + minus_one!(match paren_around_match {}); + minus_one!(match paren_around_match {}()); + minus_one!(match paren_around_match {}[0]); + minus_one!(loop { break paren_around_loop; }); +} + +fn vis_inherited() { + macro_rules! vis_inherited { + ($vis:vis struct) => { + $vis struct Struct; + }; + } + + vis_inherited!(struct); +} diff --git a/tests/ui/unpretty/expanded-interpolation.stdout b/tests/ui/unpretty/expanded-interpolation.stdout new file mode 100644 index 00000000000..73322b50f2d --- /dev/null +++ b/tests/ui/unpretty/expanded-interpolation.stdout @@ -0,0 +1,92 @@ +#![feature(prelude_import)] +#![no_std] +//@ compile-flags: -Zunpretty=expanded +//@ check-pass + +// This test covers the AST pretty-printer's insertion of parentheses in some +// macro metavariable edge cases. Synthetic parentheses (i.e. not appearing in +// the syntax tree) need to be printed in order for the printed code to be valid +// Rust syntax. We also test negative cases: the pretty-printer should not be +// synthesizing parentheses indiscriminately; only where necessary. + +#![feature(let_chains)] +#![feature(if_let_guard)] +#[prelude_import] +use ::std::prelude::rust_2015::*; +#[macro_use] +extern crate std; + +macro_rules! expr { ($expr:expr) => { $expr }; } + +macro_rules! stmt { ($stmt:stmt) => { $stmt }; } + +fn if_let() { + macro_rules! if_let { + ($pat:pat, $expr:expr) => { if let $pat = $expr {} }; + } + + if let no_paren = true && false {} + if let paren_around_binary = (true && false) {}; + if let no_paren = true {}; + + struct Struct {} + match () { _ if let no_paren = Struct {} => {} } +} + +fn let_else() { + let no_paren = 1 + 1 else { return; }; + let paren_around_loop = (loop {}) else { return; }; +} + +fn local() { + macro_rules! let_expr_minus_one { + ($pat:pat, $expr:expr) => { let $pat = $expr - 1; }; + } + + let void; + let no_paren = match void {} - 1; + + macro_rules! let_expr_else_return { + ($pat:pat, $expr:expr) => { let $pat = $expr else { return; }; }; + } + let + + no_paren = void() else { return; }; +} + +fn match_arm() { + macro_rules! match_arm { + ($pat:pat, $expr:expr) => { match () { $pat => $expr } }; + } + match () { + + + no_paren => 1 - 1, + }; + match () { paren_around_brace => ({ 1 }) - 1, }; +} + +/// https://github.com/rust-lang/rust/issues/98790 +fn stmt_boundary() { + macro_rules! expr_as_stmt { ($expr:expr) => { stmt!($expr) }; } + + let paren_around_match; + (match paren_around_match {}) | true; + + macro_rules! minus_one { ($expr:expr) => { expr_as_stmt!($expr - 1) }; } + + let (no_paren, paren_around_loop); + no_paren - 1; + (match paren_around_match {}) - 1; + (match paren_around_match {})() - 1; + (match paren_around_match {})[0] - 1; + (loop { break paren_around_loop; }) - 1; +} + +fn vis_inherited() { + macro_rules! vis_inherited { + ($vis:vis struct) => { $vis struct Struct; }; + } + struct Struct; + +} diff --git a/tests/ui/unpretty/let-else.rs b/tests/ui/unpretty/let-else.rs deleted file mode 100644 index 4db6eca99b1..00000000000 --- a/tests/ui/unpretty/let-else.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ compile-flags: -Zunpretty=expanded -//@ check-pass - -macro_rules! expr { - ($e:expr) => { $e }; -} - -fn main() { - let _ = expr!(1 + 1) else { return; }; - let _ = expr!(loop {}) else { return; }; -} diff --git a/tests/ui/unpretty/let-else.stdout b/tests/ui/unpretty/let-else.stdout deleted file mode 100644 index 4bc4d9e085f..00000000000 --- a/tests/ui/unpretty/let-else.stdout +++ /dev/null @@ -1,15 +0,0 @@ -#![feature(prelude_import)] -#![no_std] -#[prelude_import] -use ::std::prelude::rust_2015::*; -#[macro_use] -extern crate std; -//@ compile-flags: -Zunpretty=expanded -//@ check-pass - -macro_rules! expr { ($e:expr) => { $e }; } - -fn main() { - let _ = 1 + 1 else { return; }; - let _ = (loop {}) else { return; }; -} diff --git a/tests/ui/unsafe/ranged-ctor-as-fn-ptr.stderr b/tests/ui/unsafe/ranged-ctor-as-fn-ptr.stderr index 23bfe3c9c2e..abd59bdbc75 100644 --- a/tests/ui/unsafe/ranged-ctor-as-fn-ptr.stderr +++ b/tests/ui/unsafe/ranged-ctor-as-fn-ptr.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/ranged-ctor-as-fn-ptr.rs:8:40 | LL | let x: fn(u8) -> NonZeroAndOneU8 = NonZeroAndOneU8; - | ------------------------- ^^^^^^^^^^^^^^^ expected normal fn, found unsafe fn + | ------------------------- ^^^^^^^^^^^^^^^ expected safe fn, found unsafe fn | | | expected due to this | diff --git a/tests/ui/unsafe/unsafe-subtyping.stderr b/tests/ui/unsafe/unsafe-subtyping.stderr index 1cc949cf757..ddeeaa51202 100644 --- a/tests/ui/unsafe/unsafe-subtyping.stderr +++ b/tests/ui/unsafe/unsafe-subtyping.stderr @@ -4,7 +4,7 @@ error[E0308]: mismatched types LL | fn foo(x: Option<fn(i32)>) -> Option<unsafe fn(i32)> { | ---------------------- expected `Option<unsafe fn(i32)>` because of return type LL | x - | ^ expected unsafe fn, found normal fn + | ^ expected unsafe fn, found safe fn | = note: expected enum `Option<unsafe fn(_)>` found enum `Option<fn(_)>` diff --git a/tests/ui/unsafe/unsafe-trait-impl.stderr b/tests/ui/unsafe/unsafe-trait-impl.stderr index 5888b674d4f..b9f2e1cc869 100644 --- a/tests/ui/unsafe/unsafe-trait-impl.stderr +++ b/tests/ui/unsafe/unsafe-trait-impl.stderr @@ -2,7 +2,7 @@ error[E0053]: method `len` has an incompatible type for trait --> $DIR/unsafe-trait-impl.rs:8:5 | LL | fn len(&self) -> u32 { *self } - | ^^^^^^^^^^^^^^^^^^^^ expected unsafe fn, found normal fn + | ^^^^^^^^^^^^^^^^^^^^ expected unsafe fn, found safe fn | note: type in trait --> $DIR/unsafe-trait-impl.rs:4:5 diff --git a/tests/ui/wf/wf-normalization-sized.next.stderr b/tests/ui/wf/wf-normalization-sized.next.stderr index 599b1f3d45e..1e898fb7b78 100644 --- a/tests/ui/wf/wf-normalization-sized.next.stderr +++ b/tests/ui/wf/wf-normalization-sized.next.stderr @@ -1,30 +1,37 @@ -error: the type `<[[[[[[u8]]]]]] as WellUnformed>::RequestNormalize` is not well-formed - --> $DIR/wf-normalization-sized.rs:19:10 +error[E0277]: the size for values of type `[[[[[u8]]]]]` cannot be known at compilation time + --> $DIR/wf-normalization-sized.rs:19:11 | LL | const _: <[[[[[[u8]]]]]] as WellUnformed>::RequestNormalize = (); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[[[[[u8]]]]]` -error: the type `<[[[[[[u8]]]]]] as WellUnformed>::RequestNormalize` is not well-formed - --> $DIR/wf-normalization-sized.rs:19:10 +error[E0277]: the size for values of type `[[[[[u8]]]]]` cannot be known at compilation time + --> $DIR/wf-normalization-sized.rs:19:11 | LL | const _: <[[[[[[u8]]]]]] as WellUnformed>::RequestNormalize = (); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^ doesn't have a size known at compile-time | + = help: the trait `Sized` is not implemented for `[[[[[u8]]]]]` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: the type `<Vec<str> as WellUnformed>::RequestNormalize` is not well-formed - --> $DIR/wf-normalization-sized.rs:22:10 +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/wf-normalization-sized.rs:22:11 | LL | const _: <Vec<str> as WellUnformed>::RequestNormalize = (); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `str` -error: the type `<Vec<str> as WellUnformed>::RequestNormalize` is not well-formed - --> $DIR/wf-normalization-sized.rs:22:10 +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/wf-normalization-sized.rs:22:11 | LL | const _: <Vec<str> as WellUnformed>::RequestNormalize = (); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^ doesn't have a size known at compile-time | + = help: the trait `Sized` is not implemented for `str` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: aborting due to 4 previous errors +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/wf/wf-normalization-sized.rs b/tests/ui/wf/wf-normalization-sized.rs index e6e24ff9e85..80b2c8803ff 100644 --- a/tests/ui/wf/wf-normalization-sized.rs +++ b/tests/ui/wf/wf-normalization-sized.rs @@ -17,10 +17,10 @@ impl<T: ?Sized> WellUnformed for T { } const _: <[[[[[[u8]]]]]] as WellUnformed>::RequestNormalize = (); -//[next]~^ the type -//[next]~| the type +//[next]~^ the size for values of type `[[[[[u8]]]]]` cannot be known at compilation time +//[next]~| the size for values of type `[[[[[u8]]]]]` cannot be known at compilation time const _: <Vec<str> as WellUnformed>::RequestNormalize = (); -//[next]~^ the type -//[next]~| the type +//[next]~^ the size for values of type `str` cannot be known at compilation time +//[next]~| the size for values of type `str` cannot be known at compilation time fn main() {} |
