diff options
Diffstat (limited to 'tests')
23 files changed, 357 insertions, 78 deletions
diff --git a/tests/codegen/mir-aggregate-no-alloca.rs b/tests/codegen/mir-aggregate-no-alloca.rs index a7752d714fe..c0e7e1a05e3 100644 --- a/tests/codegen/mir-aggregate-no-alloca.rs +++ b/tests/codegen/mir-aggregate-no-alloca.rs @@ -55,7 +55,7 @@ pub fn make_cell_of_bool(b: bool) -> std::cell::Cell<bool> { std::cell::Cell::new(b) } -// CHECK-LABLE: { i8, i16 } @make_cell_of_bool_and_short(i1 noundef zeroext %b, i16 noundef %s) +// CHECK-LABEL: { i8, i16 } @make_cell_of_bool_and_short(i1 noundef zeroext %b, i16 noundef %s) #[no_mangle] pub fn make_cell_of_bool_and_short(b: bool, s: u16) -> std::cell::Cell<(bool, u16)> { // CHECK-NOT: alloca diff --git a/tests/crashes/123901.rs b/tests/crashes/123901.rs deleted file mode 100644 index 06722f0bf29..00000000000 --- a/tests/crashes/123901.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ known-bug: #123901 -//@ edition:2021 - -pub fn test(test: &u64, temp: &u64) { - async |check, a, b| { - temp.abs_diff(12); - }; -} diff --git a/tests/run-make/alloc-no-oom-handling/Makefile b/tests/run-make/alloc-no-oom-handling/Makefile deleted file mode 100644 index 7c3ae90b58d..00000000000 --- a/tests/run-make/alloc-no-oom-handling/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# This test checks that alloc can still compile correctly when the unstable no_global_oom_handling feature is turned on. -# See https://github.com/rust-lang/rust/pull/84266 - -include ../tools.mk - -all: - $(RUSTC) --edition=2021 -Dwarnings --crate-type=rlib ../../../library/alloc/src/lib.rs --cfg no_global_oom_handling diff --git a/tests/run-make/alloc-no-oom-handling/rmake.rs b/tests/run-make/alloc-no-oom-handling/rmake.rs new file mode 100644 index 00000000000..fec3c653294 --- /dev/null +++ b/tests/run-make/alloc-no-oom-handling/rmake.rs @@ -0,0 +1,15 @@ +// This test checks that alloc can still compile correctly +// when the unstable no_global_oom_handling feature is turned on. +// See https://github.com/rust-lang/rust/pull/84266 + +use run_make_support::rustc; + +fn main() { + rustc() + .edition("2021") + .arg("-Dwarnings") + .crate_type("rlib") + .input("../../../library/alloc/src/lib.rs") + .cfg("no_global_oom_handling") + .run(); +} diff --git a/tests/run-make/alloc-no-rc/Makefile b/tests/run-make/alloc-no-rc/Makefile deleted file mode 100644 index fcfe1603b6c..00000000000 --- a/tests/run-make/alloc-no-rc/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# This test checks that alloc can still compile correctly when the unstable no_rc feature is turned on. -# See https://github.com/rust-lang/rust/pull/89891 - -include ../tools.mk - -all: - $(RUSTC) --edition=2021 -Dwarnings --crate-type=rlib ../../../library/alloc/src/lib.rs --cfg no_rc diff --git a/tests/run-make/alloc-no-rc/rmake.rs b/tests/run-make/alloc-no-rc/rmake.rs new file mode 100644 index 00000000000..c5744a3f5ee --- /dev/null +++ b/tests/run-make/alloc-no-rc/rmake.rs @@ -0,0 +1,15 @@ +// This test checks that alloc can still compile correctly +// when the unstable no_rc feature is turned on. +// See https://github.com/rust-lang/rust/pull/84266 + +use run_make_support::rustc; + +fn main() { + rustc() + .edition("2021") + .arg("-Dwarnings") + .crate_type("rlib") + .input("../../../library/alloc/src/lib.rs") + .cfg("no_rc") + .run(); +} diff --git a/tests/run-make/alloc-no-sync/Makefile b/tests/run-make/alloc-no-sync/Makefile deleted file mode 100644 index 997dbcf6603..00000000000 --- a/tests/run-make/alloc-no-sync/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# This test checks that alloc can still compile correctly when the unstable no_sync feature is turned on. -# See https://github.com/rust-lang/rust/pull/89891 - -include ../tools.mk - -all: - $(RUSTC) --edition=2021 -Dwarnings --crate-type=rlib ../../../library/alloc/src/lib.rs --cfg no_sync diff --git a/tests/run-make/alloc-no-sync/rmake.rs b/tests/run-make/alloc-no-sync/rmake.rs new file mode 100644 index 00000000000..6410eca80ab --- /dev/null +++ b/tests/run-make/alloc-no-sync/rmake.rs @@ -0,0 +1,15 @@ +// This test checks that alloc can still compile correctly +// when the unstable no_sync feature is turned on. +// See https://github.com/rust-lang/rust/pull/84266 + +use run_make_support::rustc; + +fn main() { + rustc() + .edition("2021") + .arg("-Dwarnings") + .crate_type("rlib") + .input("../../../library/alloc/src/lib.rs") + .cfg("no_sync") + .run(); +} diff --git a/tests/run-make/core-no-fp-fmt-parse/rmake.rs b/tests/run-make/core-no-fp-fmt-parse/rmake.rs index e3484888ca5..aef28fd2528 100644 --- a/tests/run-make/core-no-fp-fmt-parse/rmake.rs +++ b/tests/run-make/core-no-fp-fmt-parse/rmake.rs @@ -2,7 +2,6 @@ // support for formatting and parsing floating-point numbers. use run_make_support::rustc; -use std::path::PathBuf; fn main() { rustc() diff --git a/tests/ui/async-await/async-closures/ambiguous-arg.rs b/tests/ui/async-await/async-closures/ambiguous-arg.rs new file mode 100644 index 00000000000..d76a1cf953e --- /dev/null +++ b/tests/ui/async-await/async-closures/ambiguous-arg.rs @@ -0,0 +1,15 @@ +//@ edition:2021 + +// Regression test for #123901. We previously ICE'd as we silently +// swallowed an in the `ExprUseVisitor`. + +#![feature(async_closure)] + +pub fn test(test: &u64, temp: &u64) { + async |check, a, b| { + //~^ ERROR type annotations needed + temp.abs_diff(12); + }; +} + +fn main() {} diff --git a/tests/ui/async-await/async-closures/ambiguous-arg.stderr b/tests/ui/async-await/async-closures/ambiguous-arg.stderr new file mode 100644 index 00000000000..01f72e94ecc --- /dev/null +++ b/tests/ui/async-await/async-closures/ambiguous-arg.stderr @@ -0,0 +1,13 @@ +error[E0282]: type annotations needed + --> $DIR/ambiguous-arg.rs:9:25 + | +LL | async |check, a, b| { + | _________________________^ +LL | | +LL | | temp.abs_diff(12); +LL | | }; + | |_____^ cannot infer type + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/macros/stringify.rs b/tests/ui/macros/stringify.rs index 472cb4d417b..6b215ba525d 100644 --- a/tests/ui/macros/stringify.rs +++ b/tests/ui/macros/stringify.rs @@ -675,6 +675,11 @@ fn test_stmt() { "let (a, b): (u32, u32) = (1, 2);", "let (a, b): (u32, u32) = (1, 2)" ); + c2!(stmt, + [ let _ = f() else { return; } ], + "let _ = f() else { return; };", + "let _ = f() else { return; }", + ); macro_rules! c2_let_expr_minus_one { ([ $expr:expr ], $stmt_expected:expr, $tokens_expected:expr $(,)?) => { c2!(stmt, [ let _ = $expr - 1 ], $stmt_expected, $tokens_expected); @@ -685,6 +690,16 @@ fn test_stmt() { "let _ = match void {} - 1;", "let _ = match void {} - 1", ); + macro_rules! c2_let_expr_else_return { + ([ $expr:expr ], $stmt_expected:expr, $tokens_expected:expr $(,)?) => { + c2!(stmt, [ let _ = $expr else { return; } ], $stmt_expected, $tokens_expected); + }; + } + c2_let_expr_else_return!( + [ f() ], + "let _ = f() else { return; };", + "let _ = f() else { return; }", + ); // StmtKind::Item c1!(stmt, [ struct S; ], "struct S;"); diff --git a/tests/ui/pattern/auxiliary/match_ergonomics_2024_macros.rs b/tests/ui/pattern/auxiliary/match_ergonomics_2024_macros.rs new file mode 100644 index 00000000000..0b70e4404ab --- /dev/null +++ b/tests/ui/pattern/auxiliary/match_ergonomics_2024_macros.rs @@ -0,0 +1,12 @@ +//@ edition: 2024 +//@ compile-flags: -Z unstable-options + +// This contains a binding in edition 2024, so if matched with a reference binding mode it will end +// up with a `mut ref mut` binding mode. We use this to test the migration lint on patterns with +// mixed editions. +#[macro_export] +macro_rules! mixed_edition_pat { + ($foo:ident) => { + Some(mut $foo) + }; +} diff --git a/tests/ui/pattern/match_ergonomics_2024.fixed b/tests/ui/pattern/match_ergonomics_2024.fixed new file mode 100644 index 00000000000..d8dbcb217c0 --- /dev/null +++ b/tests/ui/pattern/match_ergonomics_2024.fixed @@ -0,0 +1,57 @@ +//@ edition: 2021 +//@ run-rustfix +//@ rustfix-only-machine-applicable +//@ aux-build:match_ergonomics_2024_macros.rs +#![feature(mut_preserve_binding_mode_2024, ref_pat_eat_one_layer_2024)] +#![allow(incomplete_features, unused)] +#![deny(rust_2024_incompatible_pat)] + +extern crate match_ergonomics_2024_macros; + +struct Foo(u8); + +fn main() { + let &Foo(mut a) = &Foo(0); + //~^ ERROR: the semantics of this pattern will change in edition 2024 + a = 42; + + let &mut Foo(mut a) = &mut Foo(0); + //~^ ERROR: the semantics of this pattern will change in edition 2024 + a = 42; + + if let &&&&&Some(&_) = &&&&&Some(&0u8) {} + //~^ ERROR: the semantics of this pattern will change in edition 2024 + + if let &&&&&Some(&mut _) = &&&&&Some(&mut 0u8) {} + //~^ ERROR: the semantics of this pattern will change in edition 2024 + + if let &&&&&mut Some(&_) = &&&&&mut Some(&0u8) {} + //~^ ERROR: the semantics of this pattern will change in edition 2024 + + if let &mut Some(&mut Some(&mut Some(_))) = &mut Some(&mut Some(&mut Some(0u8))) {} + //~^ ERROR: the semantics of this pattern will change in edition 2024 + + if let &mut Some(&mut Some(&mut Some(ref mut _a))) = &mut Some(&mut Some(&mut Some(0u8))) {} + //~^ ERROR: the semantics of this pattern will change in edition 2024 + + struct Struct { + a: u32, + b: u32, + c: u32, + } + let s = Struct { a: 0, b: 0, c: 0 }; + let &Struct { ref a, mut b, ref c } = &s; + //~^ ERROR: the semantics of this pattern will change in edition 2024 + + #[warn(rust_2024_incompatible_pat)] + match &(Some(0), Some(0)) { + // The two patterns are the same syntactically, but because they're defined in different + // editions they don't mean the same thing. + (Some(mut _x), match_ergonomics_2024_macros::mixed_edition_pat!(_y)) => { + //~^ WARN: the semantics of this pattern will change in edition 2024 + _x = 4; + _y = &7; + } + _ => {} + } +} diff --git a/tests/ui/pattern/match_ergonomics_2024.rs b/tests/ui/pattern/match_ergonomics_2024.rs new file mode 100644 index 00000000000..38dc0c8bebb --- /dev/null +++ b/tests/ui/pattern/match_ergonomics_2024.rs @@ -0,0 +1,57 @@ +//@ edition: 2021 +//@ run-rustfix +//@ rustfix-only-machine-applicable +//@ aux-build:match_ergonomics_2024_macros.rs +#![feature(mut_preserve_binding_mode_2024, ref_pat_eat_one_layer_2024)] +#![allow(incomplete_features, unused)] +#![deny(rust_2024_incompatible_pat)] + +extern crate match_ergonomics_2024_macros; + +struct Foo(u8); + +fn main() { + let Foo(mut a) = &Foo(0); + //~^ ERROR: the semantics of this pattern will change in edition 2024 + a = 42; + + let Foo(mut a) = &mut Foo(0); + //~^ ERROR: the semantics of this pattern will change in edition 2024 + a = 42; + + if let Some(&_) = &&&&&Some(&0u8) {} + //~^ ERROR: the semantics of this pattern will change in edition 2024 + + if let Some(&mut _) = &&&&&Some(&mut 0u8) {} + //~^ ERROR: the semantics of this pattern will change in edition 2024 + + if let Some(&_) = &&&&&mut Some(&0u8) {} + //~^ ERROR: the semantics of this pattern will change in edition 2024 + + if let Some(&mut Some(Some(_))) = &mut Some(&mut Some(&mut Some(0u8))) {} + //~^ ERROR: the semantics of this pattern will change in edition 2024 + + if let Some(&mut Some(Some(_a))) = &mut Some(&mut Some(&mut Some(0u8))) {} + //~^ ERROR: the semantics of this pattern will change in edition 2024 + + struct Struct { + a: u32, + b: u32, + c: u32, + } + let s = Struct { a: 0, b: 0, c: 0 }; + let Struct { a, mut b, c } = &s; + //~^ ERROR: the semantics of this pattern will change in edition 2024 + + #[warn(rust_2024_incompatible_pat)] + match &(Some(0), Some(0)) { + // The two patterns are the same syntactically, but because they're defined in different + // editions they don't mean the same thing. + (Some(mut _x), match_ergonomics_2024_macros::mixed_edition_pat!(_y)) => { + //~^ WARN: the semantics of this pattern will change in edition 2024 + _x = 4; + _y = &7; + } + _ => {} + } +} diff --git a/tests/ui/pattern/match_ergonomics_2024.stderr b/tests/ui/pattern/match_ergonomics_2024.stderr new file mode 100644 index 00000000000..11844434ad2 --- /dev/null +++ b/tests/ui/pattern/match_ergonomics_2024.stderr @@ -0,0 +1,97 @@ +error: the semantics of this pattern will change in edition 2024 + --> $DIR/match_ergonomics_2024.rs:14:9 + | +LL | let Foo(mut a) = &Foo(0); + | -^^^^^^^^^ + | | + | help: desugar the match ergonomics: `&` + | +note: the lint level is defined here + --> $DIR/match_ergonomics_2024.rs:7:9 + | +LL | #![deny(rust_2024_incompatible_pat)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: the semantics of this pattern will change in edition 2024 + --> $DIR/match_ergonomics_2024.rs:18:9 + | +LL | let Foo(mut a) = &mut Foo(0); + | -^^^^^^^^^ + | | + | help: desugar the match ergonomics: `&mut` + +error: the semantics of this pattern will change in edition 2024 + --> $DIR/match_ergonomics_2024.rs:22:12 + | +LL | if let Some(&_) = &&&&&Some(&0u8) {} + | -^^^^^^^ + | | + | help: desugar the match ergonomics: `&&&&&` + +error: the semantics of this pattern will change in edition 2024 + --> $DIR/match_ergonomics_2024.rs:25:12 + | +LL | if let Some(&mut _) = &&&&&Some(&mut 0u8) {} + | -^^^^^^^^^^^ + | | + | help: desugar the match ergonomics: `&&&&&` + +error: the semantics of this pattern will change in edition 2024 + --> $DIR/match_ergonomics_2024.rs:28:12 + | +LL | if let Some(&_) = &&&&&mut Some(&0u8) {} + | -^^^^^^^ + | | + | help: desugar the match ergonomics: `&&&&&mut` + +error: the semantics of this pattern will change in edition 2024 + --> $DIR/match_ergonomics_2024.rs:31:12 + | +LL | if let Some(&mut Some(Some(_))) = &mut Some(&mut Some(&mut Some(0u8))) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: desugar the match ergonomics + | +LL | if let &mut Some(&mut Some(&mut Some(_))) = &mut Some(&mut Some(&mut Some(0u8))) {} + | ++++ ++++ + +error: the semantics of this pattern will change in edition 2024 + --> $DIR/match_ergonomics_2024.rs:34:12 + | +LL | if let Some(&mut Some(Some(_a))) = &mut Some(&mut Some(&mut Some(0u8))) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: desugar the match ergonomics + | +LL | if let &mut Some(&mut Some(&mut Some(ref mut _a))) = &mut Some(&mut Some(&mut Some(0u8))) {} + | ++++ ++++ +++++++ + +error: the semantics of this pattern will change in edition 2024 + --> $DIR/match_ergonomics_2024.rs:43:9 + | +LL | let Struct { a, mut b, c } = &s; + | ^^^^^^^^^^^^^^^^^^^^^^ + | +help: desugar the match ergonomics + | +LL | let &Struct { ref a, mut b, ref c } = &s; + | + +++ +++ + +warning: the semantics of this pattern will change in edition 2024 + --> $DIR/match_ergonomics_2024.rs:50:9 + | +LL | (Some(mut _x), match_ergonomics_2024_macros::mixed_edition_pat!(_y)) => { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/match_ergonomics_2024.rs:46:12 + | +LL | #[warn(rust_2024_incompatible_pat)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: desugar the match ergonomics + | +LL | &(Some(mut _x), match_ergonomics_2024_macros::mixed_edition_pat!(ref _y)) => { + | + +++ + +error: aborting due to 8 previous errors; 1 warning emitted + diff --git a/tests/ui/pattern/mut_preserve_binding_mode_2024_lint.rs b/tests/ui/pattern/mut_preserve_binding_mode_2024_lint.rs deleted file mode 100644 index 249f251d2cd..00000000000 --- a/tests/ui/pattern/mut_preserve_binding_mode_2024_lint.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ edition: 2021 -#![feature(mut_preserve_binding_mode_2024)] -#![allow(incomplete_features, unused)] -#![forbid(dereferencing_mut_binding)] - -struct Foo(u8); - -fn main() { - let Foo(mut a) = &Foo(0); - //~^ ERROR: dereferencing `mut` binding - a = 42; - - let Foo(mut a) = &mut Foo(0); - //~^ ERROR: dereferencing `mut` binding - a = 42; -} diff --git a/tests/ui/pattern/mut_preserve_binding_mode_2024_lint.stderr b/tests/ui/pattern/mut_preserve_binding_mode_2024_lint.stderr deleted file mode 100644 index e8d11acd83e..00000000000 --- a/tests/ui/pattern/mut_preserve_binding_mode_2024_lint.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error: dereferencing `mut` binding - --> $DIR/mut_preserve_binding_mode_2024_lint.rs:9:13 - | -LL | let Foo(mut a) = &Foo(0); - | ^^^^^ `mut` dereferences the type of this binding - | -help: this will change in edition 2024 - --> $DIR/mut_preserve_binding_mode_2024_lint.rs:9:13 - | -LL | let Foo(mut a) = &Foo(0); - | ^^^^^ -note: the lint level is defined here - --> $DIR/mut_preserve_binding_mode_2024_lint.rs:4:11 - | -LL | #![forbid(dereferencing_mut_binding)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: dereferencing `mut` binding - --> $DIR/mut_preserve_binding_mode_2024_lint.rs:13:13 - | -LL | let Foo(mut a) = &mut Foo(0); - | ^^^^^ `mut` dereferences the type of this binding - | -help: this will change in edition 2024 - --> $DIR/mut_preserve_binding_mode_2024_lint.rs:13:13 - | -LL | let Foo(mut a) = &mut Foo(0); - | ^^^^^ - -error: aborting due to 2 previous errors - diff --git a/tests/ui/traits/next-solver/typeck/normalize-in-upvar-collection.rs b/tests/ui/traits/next-solver/typeck/normalize-in-upvar-collection.rs new file mode 100644 index 00000000000..6567f275240 --- /dev/null +++ b/tests/ui/traits/next-solver/typeck/normalize-in-upvar-collection.rs @@ -0,0 +1,19 @@ +//@ compile-flags: -Znext-solver +//@ check-pass + +// Fixes a regression in icu_provider_adaptors where we weren't normalizing the +// return type of a function type before performing a `Ty::builtin_deref` call, +// leading to an ICE. + +struct Struct { + field: i32, +} + +fn hello(f: impl Fn() -> &'static Box<[i32]>, f2: impl Fn() -> &'static Struct) { + let cl = || { + let x = &f()[0]; + let y = &f2().field; + }; +} + +fn main() {} diff --git a/tests/ui/unpretty/pretty-let-else.rs b/tests/ui/unpretty/let-else-hir.rs index 9c231189659..9c231189659 100644 --- a/tests/ui/unpretty/pretty-let-else.rs +++ b/tests/ui/unpretty/let-else-hir.rs diff --git a/tests/ui/unpretty/pretty-let-else.stdout b/tests/ui/unpretty/let-else-hir.stdout index ed55f293876..ed55f293876 100644 --- a/tests/ui/unpretty/pretty-let-else.stdout +++ b/tests/ui/unpretty/let-else-hir.stdout diff --git a/tests/ui/unpretty/let-else.rs b/tests/ui/unpretty/let-else.rs new file mode 100644 index 00000000000..4db6eca99b1 --- /dev/null +++ b/tests/ui/unpretty/let-else.rs @@ -0,0 +1,11 @@ +//@ 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 new file mode 100644 index 00000000000..4bc4d9e085f --- /dev/null +++ b/tests/ui/unpretty/let-else.stdout @@ -0,0 +1,15 @@ +#![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; }; +} |
