diff options
Diffstat (limited to 'tests')
137 files changed, 1309 insertions, 861 deletions
diff --git a/tests/assembly/asm/aarch64-outline-atomics.rs b/tests/assembly/asm/aarch64-outline-atomics.rs index bcf0964b722..46586f0f31c 100644 --- a/tests/assembly/asm/aarch64-outline-atomics.rs +++ b/tests/assembly/asm/aarch64-outline-atomics.rs @@ -7,7 +7,8 @@ #![crate_type = "rlib"] -use std::sync::atomic::{AtomicI32, Ordering::*}; +use std::sync::atomic::AtomicI32; +use std::sync::atomic::Ordering::*; pub fn compare_exchange(a: &AtomicI32) { // On AArch64 LLVM should outline atomic operations. diff --git a/tests/codegen/atomic-operations.rs b/tests/codegen/atomic-operations.rs index b1350273542..8a70c94e480 100644 --- a/tests/codegen/atomic-operations.rs +++ b/tests/codegen/atomic-operations.rs @@ -2,7 +2,8 @@ //@ compile-flags: -O #![crate_type = "lib"] -use std::sync::atomic::{AtomicI32, Ordering::*}; +use std::sync::atomic::AtomicI32; +use std::sync::atomic::Ordering::*; // CHECK-LABEL: @compare_exchange #[no_mangle] diff --git a/tests/codegen/cast-optimized.rs b/tests/codegen/cast-optimized.rs new file mode 100644 index 00000000000..313b2b4f0d6 --- /dev/null +++ b/tests/codegen/cast-optimized.rs @@ -0,0 +1,35 @@ +//@ compile-flags: -O -Z merge-functions=disabled +#![crate_type = "lib"] + +// This tests that LLVM can optimize based on the niches in the source or +// destination types for casts. + +// CHECK-LABEL: @u32_index +#[no_mangle] +pub fn u32_index(c: u32) -> [bool; 22] { + let mut array = [false; 22]; + + let index = 32 - c.leading_zeros(); + + // CHECK: call core::panicking::panic + array[index as usize] = true; + + array +} + +// CHECK-LABEL: @char_as_u32_index +#[no_mangle] +pub fn char_as_u32_index(c: char) -> [bool; 22] { + // CHECK: %[[B:.+]] = icmp ult i32 %c, 1114112 + // CHECK: call void @llvm.assume(i1 %[[B]]) + let c = c as u32; + + let mut array = [false; 22]; + + let index = 32 - c.leading_zeros(); + + // CHECK-NOT: call core::panicking::panic + array[index as usize] = true; + + array +} diff --git a/tests/codegen/intrinsics/transmute.rs b/tests/codegen/intrinsics/transmute.rs index 04a91bb87f7..8c8e975d327 100644 --- a/tests/codegen/intrinsics/transmute.rs +++ b/tests/codegen/intrinsics/transmute.rs @@ -6,11 +6,10 @@ #![feature(custom_mir)] #![allow(unreachable_code)] -use std::intrinsics::{transmute, transmute_unchecked}; -use std::mem::MaybeUninit; - // Some of these need custom MIR to not get removed by MIR optimizations. use std::intrinsics::mir::*; +use std::intrinsics::{transmute, transmute_unchecked}; +use std::mem::MaybeUninit; pub enum ZstNever {} diff --git a/tests/codegen/try_identity.rs b/tests/codegen/try_identity.rs deleted file mode 100644 index 6a3a8a06e82..00000000000 --- a/tests/codegen/try_identity.rs +++ /dev/null @@ -1,34 +0,0 @@ -//@ compile-flags: -C no-prepopulate-passes -O -Z mir-opt-level=3 -Zunsound-mir-opts - -// Ensure that `x?` has no overhead on `Result<T, E>` due to identity `match`es in lowering. -// This requires inlining to trigger the MIR optimizations in `SimplifyArmIdentity`. - -#![crate_type = "lib"] - -type R = Result<u64, i32>; - -// This was written to the `?` from `try_trait`, but `try_trait_v2` uses a different structure, -// so the relevant desugar is copied inline in order to keep the test testing the same thing. -// FIXME(#85133): while this might be useful for `r#try!`, it would be nice to have a MIR -// optimization that picks up the `?` desugaring, as `SimplifyArmIdentity` does not. -#[no_mangle] -pub fn try_identity(x: R) -> R { - // CHECK: start: - // FIXME(JakobDegen): Broken by deaggregation change CHECK-NOT\: br {{.*}} - // CHECK ret void - let y = match into_result(x) { - Err(e) => return from_error(From::from(e)), - Ok(v) => v, - }; - Ok(y) -} - -#[inline] -fn into_result<T, E>(r: Result<T, E>) -> Result<T, E> { - r -} - -#[inline] -fn from_error<T, E>(e: E) -> Result<T, E> { - Err(e) -} diff --git a/tests/mir-opt/dont_inline_type_id.rs b/tests/mir-opt/dont_inline_type_id.rs index ab748940ac4..d389733457b 100644 --- a/tests/mir-opt/dont_inline_type_id.rs +++ b/tests/mir-opt/dont_inline_type_id.rs @@ -2,8 +2,7 @@ //@ test-mir-pass: Inline //@ compile-flags: --crate-type=lib -C panic=abort -use std::any::Any; -use std::any::TypeId; +use std::any::{Any, TypeId}; struct A<T: ?Sized + 'static> { a: i32, diff --git a/tests/mir-opt/jump_threading.floats.JumpThreading.panic-abort.diff b/tests/mir-opt/jump_threading.floats.JumpThreading.panic-abort.diff new file mode 100644 index 00000000000..6ca37e96d29 --- /dev/null +++ b/tests/mir-opt/jump_threading.floats.JumpThreading.panic-abort.diff @@ -0,0 +1,59 @@ +- // MIR for `floats` before JumpThreading ++ // MIR for `floats` after JumpThreading + + fn floats() -> u32 { + let mut _0: u32; + let _1: f64; + let mut _2: bool; + let mut _3: bool; + let mut _4: f64; + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + _2 = const true; +- switchInt(move _2) -> [0: bb2, otherwise: bb1]; ++ goto -> bb1; + } + + bb1: { + _1 = const -0f64; + goto -> bb3; + } + + bb2: { + _1 = const 1f64; + goto -> bb3; + } + + bb3: { + StorageDead(_2); + StorageLive(_3); + StorageLive(_4); + _4 = _1; + _3 = Eq(move _4, const 0f64); + switchInt(move _3) -> [0: bb5, otherwise: bb4]; + } + + bb4: { + StorageDead(_4); + _0 = const 0_u32; + goto -> bb6; + } + + bb5: { + StorageDead(_4); + _0 = const 1_u32; + goto -> bb6; + } + + bb6: { + StorageDead(_3); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/jump_threading.floats.JumpThreading.panic-unwind.diff b/tests/mir-opt/jump_threading.floats.JumpThreading.panic-unwind.diff new file mode 100644 index 00000000000..6ca37e96d29 --- /dev/null +++ b/tests/mir-opt/jump_threading.floats.JumpThreading.panic-unwind.diff @@ -0,0 +1,59 @@ +- // MIR for `floats` before JumpThreading ++ // MIR for `floats` after JumpThreading + + fn floats() -> u32 { + let mut _0: u32; + let _1: f64; + let mut _2: bool; + let mut _3: bool; + let mut _4: f64; + scope 1 { + debug x => _1; + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + _2 = const true; +- switchInt(move _2) -> [0: bb2, otherwise: bb1]; ++ goto -> bb1; + } + + bb1: { + _1 = const -0f64; + goto -> bb3; + } + + bb2: { + _1 = const 1f64; + goto -> bb3; + } + + bb3: { + StorageDead(_2); + StorageLive(_3); + StorageLive(_4); + _4 = _1; + _3 = Eq(move _4, const 0f64); + switchInt(move _3) -> [0: bb5, otherwise: bb4]; + } + + bb4: { + StorageDead(_4); + _0 = const 0_u32; + goto -> bb6; + } + + bb5: { + StorageDead(_4); + _0 = const 1_u32; + goto -> bb6; + } + + bb6: { + StorageDead(_3); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/jump_threading.rs b/tests/mir-opt/jump_threading.rs index de290c1ef44..e5d8525dcac 100644 --- a/tests/mir-opt/jump_threading.rs +++ b/tests/mir-opt/jump_threading.rs @@ -521,6 +521,16 @@ fn aggregate_copy() -> u32 { if c == 2 { b.0 } else { 13 } } +fn floats() -> u32 { + // CHECK-LABEL: fn floats( + // CHECK: switchInt( + + // Test for issue #128243, where float equality was assumed to be bitwise. + // When adding float support, it must be ensured that this continues working properly. + let x = if true { -0.0 } else { 1.0 }; + if x == 0.0 { 0 } else { 1 } +} + fn main() { // CHECK-LABEL: fn main( too_complex(Ok(0)); @@ -535,6 +545,7 @@ fn main() { disappearing_bb(7); aggregate(7); assume(7, false); + floats(); } // EMIT_MIR jump_threading.too_complex.JumpThreading.diff @@ -550,3 +561,4 @@ fn main() { // EMIT_MIR jump_threading.aggregate.JumpThreading.diff // EMIT_MIR jump_threading.assume.JumpThreading.diff // EMIT_MIR jump_threading.aggregate_copy.JumpThreading.diff +// EMIT_MIR jump_threading.floats.JumpThreading.diff diff --git a/tests/mir-opt/simplify_arm.id_try.SimplifyArmIdentity.diff b/tests/mir-opt/simplify_arm.id_try.SimplifyArmIdentity.diff deleted file mode 100644 index cff9afc38f0..00000000000 --- a/tests/mir-opt/simplify_arm.id_try.SimplifyArmIdentity.diff +++ /dev/null @@ -1,89 +0,0 @@ -- // MIR for `id_try` before SimplifyArmIdentity -+ // MIR for `id_try` after SimplifyArmIdentity - - fn id_try(_1: Result<u8, i32>) -> Result<u8, i32> { - debug r => _1; // in scope 0 at $DIR/simplify-arm.rs:+0:11: +0:12 - let mut _0: std::result::Result<u8, i32>; // return place in scope 0 at $DIR/simplify-arm.rs:+0:34: +0:49 - let _2: u8; // in scope 0 at $DIR/simplify-arm.rs:+1:9: +1:10 - let mut _3: std::result::Result<u8, i32>; // in scope 0 at $DIR/simplify-arm.rs:+1:19: +1:33 - let mut _4: std::result::Result<u8, i32>; // in scope 0 at $DIR/simplify-arm.rs:+1:31: +1:32 - let mut _5: isize; // in scope 0 at $DIR/simplify-arm.rs:+2:9: +2:15 - let _6: i32; // in scope 0 at $DIR/simplify-arm.rs:+2:13: +2:14 - let mut _7: !; // in scope 0 at $DIR/simplify-arm.rs:+2:19: +2:51 - let mut _8: i32; // in scope 0 at $DIR/simplify-arm.rs:+2:37: +2:50 - let mut _9: i32; // in scope 0 at $DIR/simplify-arm.rs:+2:48: +2:49 - let _10: u8; // in scope 0 at $DIR/simplify-arm.rs:+3:12: +3:13 - let mut _11: u8; // in scope 0 at $DIR/simplify-arm.rs:+5:8: +5:9 - scope 1 { - debug x => _2; // in scope 1 at $DIR/simplify-arm.rs:+1:9: +1:10 - } - scope 2 { - debug e => _6; // in scope 2 at $DIR/simplify-arm.rs:+2:13: +2:14 - scope 5 (inlined <i32 as From<i32>>::from) { // at $DIR/simplify-arm.rs:37:37: 37:50 - debug t => _9; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL - } - scope 6 (inlined from_error::<u8, i32>) { // at $DIR/simplify-arm.rs:37:26: 37:51 - debug e => _8; // in scope 6 at $DIR/simplify-arm.rs:27:21: 27:22 - } - } - scope 3 { - debug v => _10; // in scope 3 at $DIR/simplify-arm.rs:+3:12: +3:13 - } - scope 4 (inlined into_result::<u8, i32>) { // at $DIR/simplify-arm.rs:36:19: 36:33 - debug r => _4; // in scope 4 at $DIR/simplify-arm.rs:23:22: 23:23 - } - - bb0: { - StorageLive(_2); // scope 0 at $DIR/simplify-arm.rs:+1:9: +1:10 - StorageLive(_3); // scope 0 at $DIR/simplify-arm.rs:+1:19: +1:33 - StorageLive(_4); // scope 0 at $DIR/simplify-arm.rs:+1:31: +1:32 - _4 = _1; // scope 0 at $DIR/simplify-arm.rs:+1:31: +1:32 - _3 = move _4; // scope 4 at $DIR/simplify-arm.rs:24:5: 24:6 - StorageDead(_4); // scope 0 at $DIR/simplify-arm.rs:+1:32: +1:33 - _5 = discriminant(_3); // scope 0 at $DIR/simplify-arm.rs:+1:19: +1:33 - switchInt(move _5) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify-arm.rs:+1:13: +1:33 - } - - bb1: { - StorageLive(_10); // scope 0 at $DIR/simplify-arm.rs:+3:12: +3:13 - _10 = ((_3 as Ok).0: u8); // scope 0 at $DIR/simplify-arm.rs:+3:12: +3:13 - _2 = _10; // scope 3 at $DIR/simplify-arm.rs:+3:18: +3:19 - StorageDead(_10); // scope 0 at $DIR/simplify-arm.rs:+3:18: +3:19 - StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:+4:6: +4:7 - StorageLive(_11); // scope 1 at $DIR/simplify-arm.rs:+5:8: +5:9 - _11 = _2; // scope 1 at $DIR/simplify-arm.rs:+5:8: +5:9 - Deinit(_0); // scope 1 at $DIR/simplify-arm.rs:+5:5: +5:10 - ((_0 as Ok).0: u8) = move _11; // scope 1 at $DIR/simplify-arm.rs:+5:5: +5:10 - discriminant(_0) = 0; // scope 1 at $DIR/simplify-arm.rs:+5:5: +5:10 - StorageDead(_11); // scope 1 at $DIR/simplify-arm.rs:+5:9: +5:10 - StorageDead(_2); // scope 0 at $DIR/simplify-arm.rs:+6:1: +6:2 - goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:+6:2: +6:2 - } - - bb2: { - unreachable; // scope 0 at $DIR/simplify-arm.rs:+1:19: +1:33 - } - - bb3: { - StorageLive(_6); // scope 0 at $DIR/simplify-arm.rs:+2:13: +2:14 - _6 = ((_3 as Err).0: i32); // scope 0 at $DIR/simplify-arm.rs:+2:13: +2:14 - StorageLive(_8); // scope 2 at $DIR/simplify-arm.rs:+2:37: +2:50 - StorageLive(_9); // scope 2 at $DIR/simplify-arm.rs:+2:48: +2:49 - _9 = _6; // scope 2 at $DIR/simplify-arm.rs:+2:48: +2:49 - _8 = move _9; // scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL - StorageDead(_9); // scope 2 at $DIR/simplify-arm.rs:+2:49: +2:50 - ((_0 as Err).0: i32) = move _8; // scope 6 at $DIR/simplify-arm.rs:28:9: 28:10 - Deinit(_0); // scope 6 at $DIR/simplify-arm.rs:28:5: 28:11 - discriminant(_0) = 1; // scope 6 at $DIR/simplify-arm.rs:28:5: 28:11 - StorageDead(_8); // scope 2 at $DIR/simplify-arm.rs:+2:50: +2:51 - StorageDead(_6); // scope 0 at $DIR/simplify-arm.rs:+2:50: +2:51 - StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:+4:6: +4:7 - StorageDead(_2); // scope 0 at $DIR/simplify-arm.rs:+6:1: +6:2 - goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:+6:2: +6:2 - } - - bb4: { - return; // scope 0 at $DIR/simplify-arm.rs:+6:2: +6:2 - } - } - diff --git a/tests/mir-opt/simplify_arm.id_try.SimplifyBranchSame.diff b/tests/mir-opt/simplify_arm.id_try.SimplifyBranchSame.diff deleted file mode 100644 index 9d38b93508c..00000000000 --- a/tests/mir-opt/simplify_arm.id_try.SimplifyBranchSame.diff +++ /dev/null @@ -1,89 +0,0 @@ -- // MIR for `id_try` before SimplifyBranchSame -+ // MIR for `id_try` after SimplifyBranchSame - - fn id_try(_1: Result<u8, i32>) -> Result<u8, i32> { - debug r => _1; // in scope 0 at $DIR/simplify-arm.rs:+0:11: +0:12 - let mut _0: std::result::Result<u8, i32>; // return place in scope 0 at $DIR/simplify-arm.rs:+0:34: +0:49 - let _2: u8; // in scope 0 at $DIR/simplify-arm.rs:+1:9: +1:10 - let mut _3: std::result::Result<u8, i32>; // in scope 0 at $DIR/simplify-arm.rs:+1:19: +1:33 - let mut _4: std::result::Result<u8, i32>; // in scope 0 at $DIR/simplify-arm.rs:+1:31: +1:32 - let mut _5: isize; // in scope 0 at $DIR/simplify-arm.rs:+2:9: +2:15 - let _6: i32; // in scope 0 at $DIR/simplify-arm.rs:+2:13: +2:14 - let mut _7: !; // in scope 0 at $DIR/simplify-arm.rs:+2:19: +2:51 - let mut _8: i32; // in scope 0 at $DIR/simplify-arm.rs:+2:37: +2:50 - let mut _9: i32; // in scope 0 at $DIR/simplify-arm.rs:+2:48: +2:49 - let _10: u8; // in scope 0 at $DIR/simplify-arm.rs:+3:12: +3:13 - let mut _11: u8; // in scope 0 at $DIR/simplify-arm.rs:+5:8: +5:9 - scope 1 { - debug x => _2; // in scope 1 at $DIR/simplify-arm.rs:+1:9: +1:10 - } - scope 2 { - debug e => _6; // in scope 2 at $DIR/simplify-arm.rs:+2:13: +2:14 - scope 5 (inlined <i32 as From<i32>>::from) { // at $DIR/simplify-arm.rs:37:37: 37:50 - debug t => _9; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL - } - scope 6 (inlined from_error::<u8, i32>) { // at $DIR/simplify-arm.rs:37:26: 37:51 - debug e => _8; // in scope 6 at $DIR/simplify-arm.rs:27:21: 27:22 - } - } - scope 3 { - debug v => _10; // in scope 3 at $DIR/simplify-arm.rs:+3:12: +3:13 - } - scope 4 (inlined into_result::<u8, i32>) { // at $DIR/simplify-arm.rs:36:19: 36:33 - debug r => _4; // in scope 4 at $DIR/simplify-arm.rs:23:22: 23:23 - } - - bb0: { - StorageLive(_2); // scope 0 at $DIR/simplify-arm.rs:+1:9: +1:10 - StorageLive(_3); // scope 0 at $DIR/simplify-arm.rs:+1:19: +1:33 - StorageLive(_4); // scope 0 at $DIR/simplify-arm.rs:+1:31: +1:32 - _4 = _1; // scope 0 at $DIR/simplify-arm.rs:+1:31: +1:32 - _3 = move _4; // scope 4 at $DIR/simplify-arm.rs:24:5: 24:6 - StorageDead(_4); // scope 0 at $DIR/simplify-arm.rs:+1:32: +1:33 - _5 = discriminant(_3); // scope 0 at $DIR/simplify-arm.rs:+1:19: +1:33 - switchInt(move _5) -> [0_isize: bb1, 1_isize: bb3, otherwise: bb2]; // scope 0 at $DIR/simplify-arm.rs:+1:13: +1:33 - } - - bb1: { - StorageLive(_10); // scope 0 at $DIR/simplify-arm.rs:+3:12: +3:13 - _10 = ((_3 as Ok).0: u8); // scope 0 at $DIR/simplify-arm.rs:+3:12: +3:13 - _2 = _10; // scope 3 at $DIR/simplify-arm.rs:+3:18: +3:19 - StorageDead(_10); // scope 0 at $DIR/simplify-arm.rs:+3:18: +3:19 - StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:+4:6: +4:7 - StorageLive(_11); // scope 1 at $DIR/simplify-arm.rs:+5:8: +5:9 - _11 = _2; // scope 1 at $DIR/simplify-arm.rs:+5:8: +5:9 - Deinit(_0); // scope 1 at $DIR/simplify-arm.rs:+5:5: +5:10 - ((_0 as Ok).0: u8) = move _11; // scope 1 at $DIR/simplify-arm.rs:+5:5: +5:10 - discriminant(_0) = 0; // scope 1 at $DIR/simplify-arm.rs:+5:5: +5:10 - StorageDead(_11); // scope 1 at $DIR/simplify-arm.rs:+5:9: +5:10 - StorageDead(_2); // scope 0 at $DIR/simplify-arm.rs:+6:1: +6:2 - goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:+6:2: +6:2 - } - - bb2: { - unreachable; // scope 0 at $DIR/simplify-arm.rs:+1:19: +1:33 - } - - bb3: { - StorageLive(_6); // scope 0 at $DIR/simplify-arm.rs:+2:13: +2:14 - _6 = ((_3 as Err).0: i32); // scope 0 at $DIR/simplify-arm.rs:+2:13: +2:14 - StorageLive(_8); // scope 2 at $DIR/simplify-arm.rs:+2:37: +2:50 - StorageLive(_9); // scope 2 at $DIR/simplify-arm.rs:+2:48: +2:49 - _9 = _6; // scope 2 at $DIR/simplify-arm.rs:+2:48: +2:49 - _8 = move _9; // scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL - StorageDead(_9); // scope 2 at $DIR/simplify-arm.rs:+2:49: +2:50 - ((_0 as Err).0: i32) = move _8; // scope 6 at $DIR/simplify-arm.rs:28:9: 28:10 - Deinit(_0); // scope 6 at $DIR/simplify-arm.rs:28:5: 28:11 - discriminant(_0) = 1; // scope 6 at $DIR/simplify-arm.rs:28:5: 28:11 - StorageDead(_8); // scope 2 at $DIR/simplify-arm.rs:+2:50: +2:51 - StorageDead(_6); // scope 0 at $DIR/simplify-arm.rs:+2:50: +2:51 - StorageDead(_3); // scope 0 at $DIR/simplify-arm.rs:+4:6: +4:7 - StorageDead(_2); // scope 0 at $DIR/simplify-arm.rs:+6:1: +6:2 - goto -> bb4; // scope 0 at $DIR/simplify-arm.rs:+6:2: +6:2 - } - - bb4: { - return; // scope 0 at $DIR/simplify-arm.rs:+6:2: +6:2 - } - } - diff --git a/tests/mir-opt/simplify_arm.rs b/tests/mir-opt/simplify_arm.rs deleted file mode 100644 index 5d9c31121dd..00000000000 --- a/tests/mir-opt/simplify_arm.rs +++ /dev/null @@ -1,50 +0,0 @@ -// skip-filecheck -//@ compile-flags: -Z mir-opt-level=3 -Zunsound-mir-opts -// EMIT_MIR simplify_arm.id.SimplifyArmIdentity.diff -// EMIT_MIR simplify_arm.id.SimplifyBranchSame.diff -// EMIT_MIR simplify_arm.id_result.SimplifyArmIdentity.diff -// EMIT_MIR simplify_arm.id_result.SimplifyBranchSame.diff -// EMIT_MIR simplify_arm.id_try.SimplifyArmIdentity.diff -// EMIT_MIR simplify_arm.id_try.SimplifyBranchSame.diff - -//@ ignore-test This pass is broken since deaggregation changed - -fn id(o: Option<u8>) -> Option<u8> { - match o { - Some(v) => Some(v), - None => None, - } -} - -fn id_result(r: Result<u8, i32>) -> Result<u8, i32> { - match r { - Ok(x) => Ok(x), - Err(y) => Err(y), - } -} - -fn into_result<T, E>(r: Result<T, E>) -> Result<T, E> { - r -} - -fn from_error<T, E>(e: E) -> Result<T, E> { - Err(e) -} - -// This was written to the `?` from `try_trait`, but `try_trait_v2` uses a different structure, -// so the relevant desugar is copied inline in order to keep the test testing the same thing. -// FIXME(#85133): while this might be useful for `r#try!`, it would be nice to have a MIR -// optimization that picks up the `?` desugaring, as `SimplifyArmIdentity` does not. -fn id_try(r: Result<u8, i32>) -> Result<u8, i32> { - let x = match into_result(r) { - Err(e) => return from_error(From::from(e)), - Ok(v) => v, - }; - Ok(x) -} - -fn main() { - id(None); - id_result(Ok(4)); - id_try(Ok(4)); -} diff --git a/tests/mir-opt/simplify_arm_identity.rs b/tests/mir-opt/simplify_arm_identity.rs deleted file mode 100644 index 79395b312ac..00000000000 --- a/tests/mir-opt/simplify_arm_identity.rs +++ /dev/null @@ -1,26 +0,0 @@ -// skip-filecheck -// Checks that `SimplifyArmIdentity` is not applied if enums have incompatible layouts. -// Regression test for issue #66856. -// -//@ compile-flags: -Zmir-opt-level=3 -// EMIT_MIR_FOR_EACH_BIT_WIDTH - -//@ ignore-test This pass is broken since deaggregation changed - -enum Src { - Foo(u8), - Bar, -} - -enum Dst { - Foo(u8), -} - -// EMIT_MIR simplify_arm_identity.main.SimplifyArmIdentity.diff -fn main() { - let e: Src = Src::Foo(0); - let _: Dst = match e { - Src::Foo(x) => Dst::Foo(x), - Src::Bar => Dst::Foo(0), - }; -} diff --git a/tests/mir-opt/simplify_try_if_let.rs b/tests/mir-opt/simplify_try_if_let.rs deleted file mode 100644 index 98df9a54abb..00000000000 --- a/tests/mir-opt/simplify_try_if_let.rs +++ /dev/null @@ -1,44 +0,0 @@ -// skip-filecheck -//@ compile-flags: -Zmir-opt-level=1 -Zunsound-mir-opts -//@ ignore-test -// FIXME: the pass is unsound and causes ICEs in the MIR validator - -// EMIT_MIR simplify_try_if_let.{impl#0}-append.SimplifyArmIdentity.diff - -use std::ptr::NonNull; - -pub struct LinkedList { - head: Option<NonNull<Node>>, - tail: Option<NonNull<Node>>, -} - -pub struct Node { - next: Option<NonNull<Node>>, -} - -impl LinkedList { - pub fn new() -> Self { - Self { head: None, tail: None } - } - - pub fn append(&mut self, other: &mut Self) { - match self.tail { - None => {} - Some(mut tail) => { - // `as_mut` is okay here because we have exclusive access to the entirety - // of both lists. - if let Some(other_head) = other.head.take() { - unsafe { - tail.as_mut().next = Some(other_head); - } - } - } - } - } -} - -fn main() { - let mut one = LinkedList::new(); - let mut two = LinkedList::new(); - one.append(&mut two); -} diff --git a/tests/mir-opt/simplify_try_if_let.{impl#0}-append.SimplifyArmIdentity.diff b/tests/mir-opt/simplify_try_if_let.{impl#0}-append.SimplifyArmIdentity.diff deleted file mode 100644 index 11f6b533741..00000000000 --- a/tests/mir-opt/simplify_try_if_let.{impl#0}-append.SimplifyArmIdentity.diff +++ /dev/null @@ -1,104 +0,0 @@ -- // MIR for `<impl at $DIR/simplify_try_if_let.rs:15:1: 34:2>::append` before SimplifyArmIdentity -+ // MIR for `<impl at $DIR/simplify_try_if_let.rs:15:1: 34:2>::append` after SimplifyArmIdentity - - fn <impl at $DIR/simplify_try_if_let.rs:15:1: 34:2>::append(_1: &mut LinkedList, _2: &mut LinkedList) -> () { - debug self => _1; // in scope 0 at $DIR/simplify_try_if_let.rs:20:19: 20:28 - debug other => _2; // in scope 0 at $DIR/simplify_try_if_let.rs:20:30: 20:35 - let mut _0: (); // return place in scope 0 at $DIR/simplify_try_if_let.rs:20:48: 20:48 - let mut _3: isize; // in scope 0 at $DIR/simplify_try_if_let.rs:22:13: 22:17 - let mut _4: std::ptr::NonNull<Node>; // in scope 0 at $DIR/simplify_try_if_let.rs:23:18: 23:26 - let mut _5: std::option::Option<std::ptr::NonNull<Node>>; // in scope 0 at $DIR/simplify_try_if_let.rs:26:43: 26:60 - let mut _6: &mut std::option::Option<std::ptr::NonNull<Node>>; // in scope 0 at $DIR/simplify_try_if_let.rs:26:43: 26:53 - let mut _7: isize; // in scope 0 at $DIR/simplify_try_if_let.rs:26:24: 26:40 - let mut _9: std::option::Option<std::ptr::NonNull<Node>>; // in scope 0 at $DIR/simplify_try_if_let.rs:28:46: 28:62 - let mut _10: std::ptr::NonNull<Node>; // in scope 0 at $DIR/simplify_try_if_let.rs:28:51: 28:61 - let mut _11: &mut Node; // in scope 0 at $DIR/simplify_try_if_let.rs:28:25: 28:38 - let mut _12: &mut std::ptr::NonNull<Node>; // in scope 0 at $DIR/simplify_try_if_let.rs:28:25: 28:29 - scope 1 { - debug tail => _4; // in scope 1 at $DIR/simplify_try_if_let.rs:23:18: 23:26 - let _8: std::ptr::NonNull<Node>; // in scope 1 at $DIR/simplify_try_if_let.rs:26:29: 26:39 - scope 2 { -- debug other_head => _8; // in scope 2 at $DIR/simplify_try_if_let.rs:26:29: 26:39 -+ debug other_head => ((_9 as Some).0: std::ptr::NonNull<Node>); // in scope 2 at $DIR/simplify_try_if_let.rs:26:29: 26:39 - scope 3 { - } - } - } - - bb0: { - _3 = discriminant(((*_1).1: std::option::Option<std::ptr::NonNull<Node>>)); // scope 0 at $DIR/simplify_try_if_let.rs:22:13: 22:17 - switchInt(move _3) -> [0_isize: bb3, 1_isize: bb1, otherwise: bb2]; // scope 0 at $DIR/simplify_try_if_let.rs:22:13: 22:17 - } - - bb1: { - StorageLive(_4); // scope 0 at $DIR/simplify_try_if_let.rs:23:18: 23:26 - _4 = ((((*_1).1: std::option::Option<std::ptr::NonNull<Node>>) as Some).0: std::ptr::NonNull<Node>); // scope 0 at $DIR/simplify_try_if_let.rs:23:18: 23:26 - StorageLive(_5); // scope 1 at $DIR/simplify_try_if_let.rs:26:43: 26:60 - StorageLive(_6); // scope 1 at $DIR/simplify_try_if_let.rs:26:43: 26:53 - _6 = &mut ((*_2).0: std::option::Option<std::ptr::NonNull<Node>>); // scope 1 at $DIR/simplify_try_if_let.rs:26:43: 26:53 - _5 = Option::<NonNull<Node>>::take(move _6) -> bb4; // scope 1 at $DIR/simplify_try_if_let.rs:26:43: 26:60 - // mir::Constant - // + span: $DIR/simplify_try_if_let.rs:26:54: 26:58 - // + literal: Const { ty: for<'r> fn(&'r mut std::option::Option<std::ptr::NonNull<Node>>) -> std::option::Option<std::ptr::NonNull<Node>> {std::option::Option::<std::ptr::NonNull<Node>>::take}, val: Value(Scalar(<ZST>)) } - } - - bb2: { - unreachable; // scope 0 at $DIR/simplify_try_if_let.rs:21:15: 21:24 - } - - bb3: { - _0 = const (); // scope 0 at $DIR/simplify_try_if_let.rs:22:21: 22:24 - goto -> bb9; // scope 0 at $DIR/simplify_try_if_let.rs:21:9: 32:10 - } - - bb4: { - StorageDead(_6); // scope 1 at $DIR/simplify_try_if_let.rs:26:59: 26:60 - _7 = discriminant(_5); // scope 1 at $DIR/simplify_try_if_let.rs:26:24: 26:40 - switchInt(move _7) -> [1_isize: bb6, otherwise: bb5]; // scope 1 at $DIR/simplify_try_if_let.rs:26:24: 26:40 - } - - bb5: { - _0 = const (); // scope 1 at $DIR/simplify_try_if_let.rs:26:17: 30:18 - goto -> bb8; // scope 1 at $DIR/simplify_try_if_let.rs:26:17: 30:18 - } - - bb6: { - StorageLive(_8); // scope 1 at $DIR/simplify_try_if_let.rs:26:29: 26:39 - _8 = ((_5 as Some).0: std::ptr::NonNull<Node>); // scope 1 at $DIR/simplify_try_if_let.rs:26:29: 26:39 - StorageLive(_9); // scope 3 at $DIR/simplify_try_if_let.rs:28:46: 28:62 -- StorageLive(_10); // scope 3 at $DIR/simplify_try_if_let.rs:28:51: 28:61 -- _10 = _8; // scope 3 at $DIR/simplify_try_if_let.rs:28:51: 28:61 -- ((_9 as Some).0: std::ptr::NonNull<Node>) = move _10; // scope 3 at $DIR/simplify_try_if_let.rs:28:46: 28:62 -- discriminant(_9) = 1; // scope 3 at $DIR/simplify_try_if_let.rs:28:46: 28:62 -- StorageDead(_10); // scope 3 at $DIR/simplify_try_if_let.rs:28:61: 28:62 -+ _9 = move _5; // scope 3 at $DIR/simplify_try_if_let.rs:28:46: 28:62 - StorageLive(_11); // scope 3 at $DIR/simplify_try_if_let.rs:28:25: 28:38 - StorageLive(_12); // scope 3 at $DIR/simplify_try_if_let.rs:28:25: 28:29 - _12 = &mut _4; // scope 3 at $DIR/simplify_try_if_let.rs:28:25: 28:29 - _11 = NonNull::<Node>::as_mut(move _12) -> bb7; // scope 3 at $DIR/simplify_try_if_let.rs:28:25: 28:38 - // mir::Constant - // + span: $DIR/simplify_try_if_let.rs:28:30: 28:36 - // + literal: Const { ty: for<'r> unsafe fn(&'r mut std::ptr::NonNull<Node>) -> &'r mut Node {std::ptr::NonNull::<Node>::as_mut}, val: Value(Scalar(<ZST>)) } - } - - bb7: { - StorageDead(_12); // scope 3 at $DIR/simplify_try_if_let.rs:28:37: 28:38 - ((*_11).0: std::option::Option<std::ptr::NonNull<Node>>) = move _9; // scope 3 at $DIR/simplify_try_if_let.rs:28:25: 28:62 - StorageDead(_9); // scope 3 at $DIR/simplify_try_if_let.rs:28:61: 28:62 - StorageDead(_11); // scope 3 at $DIR/simplify_try_if_let.rs:28:62: 28:63 - _0 = const (); // scope 3 at $DIR/simplify_try_if_let.rs:27:21: 29:22 - StorageDead(_8); // scope 1 at $DIR/simplify_try_if_let.rs:30:17: 30:18 - goto -> bb8; // scope 1 at $DIR/simplify_try_if_let.rs:26:17: 30:18 - } - - bb8: { - StorageDead(_5); // scope 1 at $DIR/simplify_try_if_let.rs:31:13: 31:14 - StorageDead(_4); // scope 0 at $DIR/simplify_try_if_let.rs:31:13: 31:14 - goto -> bb9; // scope 0 at $DIR/simplify_try_if_let.rs:21:9: 32:10 - } - - bb9: { - return; // scope 0 at $DIR/simplify_try_if_let.rs:33:6: 33:6 - } - } - diff --git a/tests/run-make/branch-protection-check-IBT/_rmake.rs b/tests/run-make/branch-protection-check-IBT/_rmake.rs index d66ecf9c005..91151408785 100644 --- a/tests/run-make/branch-protection-check-IBT/_rmake.rs +++ b/tests/run-make/branch-protection-check-IBT/_rmake.rs @@ -8,9 +8,7 @@ //@ ignore-test // FIXME(jieyouxu): see the FIXME in the Makefile -use run_make_support::llvm_readobj; -use run_make_support::rustc; -use run_make_support::{cwd, env_var}; +use run_make_support::{cwd, env_var, llvm_readobj, rustc}; fn main() { let llvm_components = env_var("LLVM_COMPONENTS"); diff --git a/tests/run-make/c-link-to-rust-staticlib/rmake.rs b/tests/run-make/c-link-to-rust-staticlib/rmake.rs index ee35350da66..e21b976035b 100644 --- a/tests/run-make/c-link-to-rust-staticlib/rmake.rs +++ b/tests/run-make/c-link-to-rust-staticlib/rmake.rs @@ -3,9 +3,10 @@ //@ ignore-cross-compile +use std::fs; + use run_make_support::rfs::remove_file; use run_make_support::{cc, extra_c_flags, run, rustc, static_lib_name}; -use std::fs; fn main() { rustc().input("foo.rs").run(); diff --git a/tests/run-make/c-link-to-rust-va-list-fn/checkrust.rs b/tests/run-make/c-link-to-rust-va-list-fn/checkrust.rs index 196c6440747..0a959c3bd88 100644 --- a/tests/run-make/c-link-to-rust-va-list-fn/checkrust.rs +++ b/tests/run-make/c-link-to-rust-va-list-fn/checkrust.rs @@ -1,9 +1,7 @@ #![crate_type = "staticlib"] #![feature(c_variadic)] -use std::ffi::VaList; -use std::ffi::{c_char, c_double, c_int, c_long, c_longlong}; -use std::ffi::{CStr, CString}; +use std::ffi::{c_char, c_double, c_int, c_long, c_longlong, CStr, CString, VaList}; macro_rules! continue_if { ($cond:expr) => { diff --git a/tests/run-make/comment-section/rmake.rs b/tests/run-make/comment-section/rmake.rs index a16adea7162..ecee441b35f 100644 --- a/tests/run-make/comment-section/rmake.rs +++ b/tests/run-make/comment-section/rmake.rs @@ -9,10 +9,7 @@ use std::path::PathBuf; -use run_make_support::llvm_readobj; -use run_make_support::rfs; -use run_make_support::rustc; -use run_make_support::{cwd, env_var, run_in_tmpdir}; +use run_make_support::{cwd, env_var, llvm_readobj, rfs, run_in_tmpdir, rustc}; fn main() { let target = env_var("TARGET"); diff --git a/tests/run-make/compiler-builtins/rmake.rs b/tests/run-make/compiler-builtins/rmake.rs index 43d1d69b245..42ed07d9daf 100644 --- a/tests/run-make/compiler-builtins/rmake.rs +++ b/tests/run-make/compiler-builtins/rmake.rs @@ -14,15 +14,14 @@ #![deny(warnings)] +use std::collections::HashSet; +use std::path::PathBuf; + use run_make_support::object::read::archive::ArchiveFile; use run_make_support::object::read::Object; -use run_make_support::object::ObjectSection; -use run_make_support::object::ObjectSymbol; -use run_make_support::object::RelocationTarget; +use run_make_support::object::{ObjectSection, ObjectSymbol, RelocationTarget}; use run_make_support::rfs::{read, read_dir}; use run_make_support::{cmd, env_var, object}; -use std::collections::HashSet; -use std::path::PathBuf; fn main() { let target_dir = PathBuf::from("target"); diff --git a/tests/run-make/crate-hash-rustc-version/rmake.rs b/tests/run-make/crate-hash-rustc-version/rmake.rs index 97b3dd3931e..c7c36cfdf11 100644 --- a/tests/run-make/crate-hash-rustc-version/rmake.rs +++ b/tests/run-make/crate-hash-rustc-version/rmake.rs @@ -4,8 +4,7 @@ //@ ignore-cross-compile //@ only-unix -use run_make_support::llvm; -use run_make_support::{diff, dynamic_lib_name, is_darwin, run, run_fail, rustc}; +use run_make_support::{diff, dynamic_lib_name, is_darwin, llvm, run, run_fail, rustc}; fn llvm_readobj() -> llvm::LlvmReadobj { let mut cmd = llvm::llvm_readobj(); diff --git a/tests/run-make/cross-lang-lto-riscv-abi/rmake.rs b/tests/run-make/cross-lang-lto-riscv-abi/rmake.rs index f40da662128..391759ec5f6 100644 --- a/tests/run-make/cross-lang-lto-riscv-abi/rmake.rs +++ b/tests/run-make/cross-lang-lto-riscv-abi/rmake.rs @@ -6,13 +6,11 @@ // FIXME(#126180): This test doesn't actually run anywhere, because the only // CI job that sets RUSTBUILD_FORCE_CLANG_BASED_TESTS runs very few tests. +use std::path::PathBuf; +use std::process::{Command, Output}; +use std::{env, str}; + use run_make_support::{bin_name, clang, llvm_readobj, rustc}; -use std::{ - env, - path::PathBuf, - process::{Command, Output}, - str, -}; fn check_target(target: &str, clang_target: &str, carch: &str, is_double_float: bool) { eprintln!("Checking target {target}"); diff --git a/tests/run-make/doctests-keep-binaries/rmake.rs b/tests/run-make/doctests-keep-binaries/rmake.rs index 6bff5c0c8d0..246539bcf82 100644 --- a/tests/run-make/doctests-keep-binaries/rmake.rs +++ b/tests/run-make/doctests-keep-binaries/rmake.rs @@ -1,9 +1,10 @@ // Check that valid binaries are persisted by running them, regardless of whether the // --run or --no-run option is used. +use std::path::Path; + use run_make_support::rfs::{create_dir, remove_dir_all}; use run_make_support::{run, rustc, rustdoc}; -use std::path::Path; fn setup_test_env<F: FnOnce(&Path, &Path)>(callback: F) { let out_dir = Path::new("doctests"); diff --git a/tests/run-make/doctests-runtool/rmake.rs b/tests/run-make/doctests-runtool/rmake.rs index 5d829b9e88b..c7be829c215 100644 --- a/tests/run-make/doctests-runtool/rmake.rs +++ b/tests/run-make/doctests-runtool/rmake.rs @@ -1,8 +1,9 @@ // Tests behavior of rustdoc `--runtool`. +use std::path::PathBuf; + use run_make_support::rfs::{create_dir, remove_dir_all}; use run_make_support::{rustc, rustdoc}; -use std::path::PathBuf; fn mkdir(name: &str) -> PathBuf { let dir = PathBuf::from(name); diff --git a/tests/run-make/emit-shared-files/rmake.rs b/tests/run-make/emit-shared-files/rmake.rs index 33c12310246..8ac9073e993 100644 --- a/tests/run-make/emit-shared-files/rmake.rs +++ b/tests/run-make/emit-shared-files/rmake.rs @@ -5,9 +5,10 @@ // `all-shared` should only emit files that can be shared between crates. // See https://github.com/rust-lang/rust/pull/83478 -use run_make_support::{has_extension, has_prefix, rustdoc, shallow_find_files}; use std::path::Path; +use run_make_support::{has_extension, has_prefix, rustdoc, shallow_find_files}; + fn main() { rustdoc() .arg("-Zunstable-options") diff --git a/tests/run-make/incr-prev-body-beyond-eof/rmake.rs b/tests/run-make/incr-prev-body-beyond-eof/rmake.rs index 14e75671df8..47dce85248a 100644 --- a/tests/run-make/incr-prev-body-beyond-eof/rmake.rs +++ b/tests/run-make/incr-prev-body-beyond-eof/rmake.rs @@ -13,8 +13,7 @@ //@ ignore-nvptx64-nvidia-cuda // FIXME: can't find crate for `std` -use run_make_support::rfs; -use run_make_support::rustc; +use run_make_support::{rfs, rustc}; fn main() { rfs::create_dir("src"); diff --git a/tests/run-make/incremental-debugger-visualizer/rmake.rs b/tests/run-make/incremental-debugger-visualizer/rmake.rs index 985816ff5d7..58a7e415bc5 100644 --- a/tests/run-make/incremental-debugger-visualizer/rmake.rs +++ b/tests/run-make/incremental-debugger-visualizer/rmake.rs @@ -2,9 +2,10 @@ // (in this case, foo.py and foo.natvis) are picked up when compiling incrementally. // See https://github.com/rust-lang/rust/pull/111641 -use run_make_support::{invalid_utf8_contains, invalid_utf8_not_contains, rfs, rustc}; use std::io::Read; +use run_make_support::{invalid_utf8_contains, invalid_utf8_not_contains, rfs, rustc}; + fn main() { rfs::create_file("foo.py"); rfs::write("foo.py", "GDB script v1"); diff --git a/tests/run-make/inline-always-many-cgu/rmake.rs b/tests/run-make/inline-always-many-cgu/rmake.rs index 5a6929c855b..678b949bc70 100644 --- a/tests/run-make/inline-always-many-cgu/rmake.rs +++ b/tests/run-make/inline-always-many-cgu/rmake.rs @@ -1,9 +1,8 @@ -use run_make_support::regex::Regex; -use run_make_support::rfs; -use run_make_support::rustc; - use std::ffi::OsStr; +use run_make_support::regex::Regex; +use run_make_support::{rfs, rustc}; + fn main() { rustc().input("foo.rs").emit("llvm-ir").codegen_units(2).run(); let re = Regex::new(r"\bcall\b").unwrap(); diff --git a/tests/run-make/intrinsic-unreachable/exit-unreachable.rs b/tests/run-make/intrinsic-unreachable/exit-unreachable.rs index d0f193d49ee..4309767e05c 100644 --- a/tests/run-make/intrinsic-unreachable/exit-unreachable.rs +++ b/tests/run-make/intrinsic-unreachable/exit-unreachable.rs @@ -1,7 +1,6 @@ #![feature(core_intrinsics)] #![crate_type = "lib"] use std::arch::asm; - use std::intrinsics; #[allow(unreachable_code)] diff --git a/tests/run-make/invalid-library/rmake.rs b/tests/run-make/invalid-library/rmake.rs index 42afb74a59e..6b3ae1d485a 100644 --- a/tests/run-make/invalid-library/rmake.rs +++ b/tests/run-make/invalid-library/rmake.rs @@ -4,8 +4,7 @@ // one appearing in stderr in this scenario. // See https://github.com/rust-lang/rust/pull/12645 -use run_make_support::rfs; -use run_make_support::{llvm_ar, rustc}; +use run_make_support::{llvm_ar, rfs, rustc}; fn main() { rfs::create_file("lib.rmeta"); diff --git a/tests/run-make/issue-107495-archive-permissions/rmake.rs b/tests/run-make/issue-107495-archive-permissions/rmake.rs index f47b8d7190f..f210b7c737b 100644 --- a/tests/run-make/issue-107495-archive-permissions/rmake.rs +++ b/tests/run-make/issue-107495-archive-permissions/rmake.rs @@ -3,12 +3,12 @@ #[cfg(unix)] extern crate libc; -use run_make_support::{aux_build, rfs}; - #[cfg(unix)] use std::os::unix::fs::PermissionsExt; use std::path::Path; +use run_make_support::{aux_build, rfs}; + fn main() { #[cfg(unix)] unsafe { diff --git a/tests/run-make/lib-trait-for-trait-no-ice/rmake.rs b/tests/run-make/lib-trait-for-trait-no-ice/rmake.rs index 766acfc00da..0c5e12055e8 100644 --- a/tests/run-make/lib-trait-for-trait-no-ice/rmake.rs +++ b/tests/run-make/lib-trait-for-trait-no-ice/rmake.rs @@ -5,9 +5,10 @@ // the lib crate-type flag was actually followed. // See https://github.com/rust-lang/rust/issues/18943 -use run_make_support::{rust_lib_name, rustc}; use std::path::Path; +use run_make_support::{rust_lib_name, rustc}; + fn main() { rustc().input("foo.rs").crate_type("lib").run(); assert!(Path::new(&rust_lib_name("foo")).exists()); diff --git a/tests/run-make/libtest-thread-limit/test.rs b/tests/run-make/libtest-thread-limit/test.rs index 88e8a498ae9..87e1d519171 100644 --- a/tests/run-make/libtest-thread-limit/test.rs +++ b/tests/run-make/libtest-thread-limit/test.rs @@ -1,8 +1,6 @@ -use std::{ - io::ErrorKind, - sync::OnceLock, - thread::{self, Builder, ThreadId}, -}; +use std::io::ErrorKind; +use std::sync::OnceLock; +use std::thread::{self, Builder, ThreadId}; static THREAD_ID: OnceLock<ThreadId> = OnceLock::new(); diff --git a/tests/run-make/llvm-outputs/rmake.rs b/tests/run-make/llvm-outputs/rmake.rs index 2dc3030ca91..b8ac21c98a0 100644 --- a/tests/run-make/llvm-outputs/rmake.rs +++ b/tests/run-make/llvm-outputs/rmake.rs @@ -1,8 +1,9 @@ // test that directories get created when emitting llvm bitcode and IR -use run_make_support::{cwd, run_in_tmpdir, rustc}; use std::path::PathBuf; +use run_make_support::{cwd, run_in_tmpdir, rustc}; + fn main() { let mut path_bc = PathBuf::new(); let mut path_ir = PathBuf::new(); diff --git a/tests/run-make/ls-metadata/rmake.rs b/tests/run-make/ls-metadata/rmake.rs index 45299a48c11..42db97a292b 100644 --- a/tests/run-make/ls-metadata/rmake.rs +++ b/tests/run-make/ls-metadata/rmake.rs @@ -6,8 +6,7 @@ //@ ignore-cross-compile -use run_make_support::rfs; -use run_make_support::rustc; +use run_make_support::{rfs, rustc}; fn main() { rustc().input("foo.rs").run(); diff --git a/tests/run-make/lto-readonly-lib/rmake.rs b/tests/run-make/lto-readonly-lib/rmake.rs index d0ba3fb37a2..b9f0dc21daf 100644 --- a/tests/run-make/lto-readonly-lib/rmake.rs +++ b/tests/run-make/lto-readonly-lib/rmake.rs @@ -7,8 +7,7 @@ //@ ignore-cross-compile -use run_make_support::rfs; -use run_make_support::{run, rust_lib_name, rustc, test_while_readonly}; +use run_make_support::{rfs, run, rust_lib_name, rustc, test_while_readonly}; fn main() { rustc().input("lib.rs").run(); diff --git a/tests/run-make/manual-crate-name/rmake.rs b/tests/run-make/manual-crate-name/rmake.rs index f171f78087c..9085b6c7bc2 100644 --- a/tests/run-make/manual-crate-name/rmake.rs +++ b/tests/run-make/manual-crate-name/rmake.rs @@ -1,6 +1,7 @@ -use run_make_support::rustc; use std::path::Path; +use run_make_support::rustc; + fn main() { rustc().input("bar.rs").crate_name("foo").run(); assert!(Path::new("libfoo.rlib").is_file()); diff --git a/tests/run-make/no-intermediate-extras/rmake.rs b/tests/run-make/no-intermediate-extras/rmake.rs index 0641417504e..0b12da6a01d 100644 --- a/tests/run-make/no-intermediate-extras/rmake.rs +++ b/tests/run-make/no-intermediate-extras/rmake.rs @@ -5,9 +5,10 @@ //@ ignore-cross-compile -use run_make_support::rustc; use std::fs; +use run_make_support::rustc; + fn main() { rustc().crate_type("rlib").arg("--test").input("foo.rs").run(); assert!( diff --git a/tests/run-make/non-unicode-env/rmake.rs b/tests/run-make/non-unicode-env/rmake.rs index 0042e4d1e17..d708192908c 100644 --- a/tests/run-make/non-unicode-env/rmake.rs +++ b/tests/run-make/non-unicode-env/rmake.rs @@ -1,5 +1,4 @@ -use run_make_support::rfs; -use run_make_support::rustc; +use run_make_support::{rfs, rustc}; fn main() { #[cfg(unix)] diff --git a/tests/run-make/obey-crate-type-flag/rmake.rs b/tests/run-make/obey-crate-type-flag/rmake.rs index 8d6eb237982..3fef4b7e65b 100644 --- a/tests/run-make/obey-crate-type-flag/rmake.rs +++ b/tests/run-make/obey-crate-type-flag/rmake.rs @@ -5,10 +5,11 @@ //@ ignore-cross-compile +use std::path::Path; + use run_make_support::{ cwd, dynamic_lib_name, has_extension, rfs, rust_lib_name, rustc, shallow_find_files, }; -use std::path::Path; fn main() { rustc().input("test.rs").run(); diff --git a/tests/run-make/output-type-permutations/rmake.rs b/tests/run-make/output-type-permutations/rmake.rs index c51b2153945..76fd8c1c260 100644 --- a/tests/run-make/output-type-permutations/rmake.rs +++ b/tests/run-make/output-type-permutations/rmake.rs @@ -4,11 +4,12 @@ // files are exactly what is expected, no more, no less. // See https://github.com/rust-lang/rust/pull/12020 +use std::path::PathBuf; + use run_make_support::{ bin_name, dynamic_lib_name, filename_not_in_denylist, rfs, rust_lib_name, rustc, shallow_find_files, static_lib_name, }; -use std::path::PathBuf; // Each test takes 4 arguments: // `must_exist`: output files which must be found - if any are absent, the test fails diff --git a/tests/run-make/parallel-rustc-no-overwrite/rmake.rs b/tests/run-make/parallel-rustc-no-overwrite/rmake.rs index 3f412bfefc8..aa38eb664cf 100644 --- a/tests/run-make/parallel-rustc-no-overwrite/rmake.rs +++ b/tests/run-make/parallel-rustc-no-overwrite/rmake.rs @@ -5,10 +5,11 @@ // conflicts. This test uses this flag and checks for successful compilation. // See https://github.com/rust-lang/rust/pull/83846 -use run_make_support::{rfs, rustc}; use std::sync::{Arc, Barrier}; use std::thread; +use run_make_support::{rfs, rustc}; + fn main() { rfs::create_file("lib.rs"); let barrier = Arc::new(Barrier::new(2)); diff --git a/tests/run-make/pgo-branch-weights/rmake.rs b/tests/run-make/pgo-branch-weights/rmake.rs index 588c5c6dc31..ef33d009dbb 100644 --- a/tests/run-make/pgo-branch-weights/rmake.rs +++ b/tests/run-make/pgo-branch-weights/rmake.rs @@ -10,9 +10,10 @@ //@ needs-profiler-support //@ ignore-cross-compile -use run_make_support::{llvm_filecheck, llvm_profdata, rfs, run_with_args, rustc}; use std::path::Path; +use run_make_support::{llvm_filecheck, llvm_profdata, rfs, run_with_args, rustc}; + fn main() { let path_prof_data_dir = Path::new("prof_data_dir"); let path_merged_profdata = path_prof_data_dir.join("merged.profdata"); diff --git a/tests/run-make/pretty-print-with-dep-file/rmake.rs b/tests/run-make/pretty-print-with-dep-file/rmake.rs index d7a29ff7d19..5d422085834 100644 --- a/tests/run-make/pretty-print-with-dep-file/rmake.rs +++ b/tests/run-make/pretty-print-with-dep-file/rmake.rs @@ -5,9 +5,10 @@ // does not get an unexpected dep-info file. // See https://github.com/rust-lang/rust/issues/112898 -use run_make_support::{invalid_utf8_contains, rfs, rustc}; use std::path::Path; +use run_make_support::{invalid_utf8_contains, rfs, rustc}; + fn main() { rustc().emit("dep-info").arg("-Zunpretty=expanded").input("with-dep.rs").run(); invalid_utf8_contains("with-dep.d", "with-dep.rs"); diff --git a/tests/run-make/profile/rmake.rs b/tests/run-make/profile/rmake.rs index 8d41978baec..4c6f9c19091 100644 --- a/tests/run-make/profile/rmake.rs +++ b/tests/run-make/profile/rmake.rs @@ -8,9 +8,10 @@ //@ ignore-cross-compile //@ needs-profiler-support -use run_make_support::{run, rustc}; use std::path::Path; +use run_make_support::{run, rustc}; + fn main() { rustc().arg("-g").arg("-Zprofile").input("test.rs").run(); run("test"); diff --git a/tests/run-make/relro-levels/rmake.rs b/tests/run-make/relro-levels/rmake.rs index 56545ebc5aa..91d106a03e4 100644 --- a/tests/run-make/relro-levels/rmake.rs +++ b/tests/run-make/relro-levels/rmake.rs @@ -2,8 +2,7 @@ //@ only-linux -use run_make_support::llvm_readobj; -use run_make_support::rustc; +use run_make_support::{llvm_readobj, rustc}; fn compile(relro_level: &str) { rustc().arg(format!("-Crelro-level={relro_level}")).input("hello.rs").run(); diff --git a/tests/run-make/repr128-dwarf/rmake.rs b/tests/run-make/repr128-dwarf/rmake.rs index 824ca6e1876..2fd54c186b9 100644 --- a/tests/run-make/repr128-dwarf/rmake.rs +++ b/tests/run-make/repr128-dwarf/rmake.rs @@ -1,13 +1,14 @@ //@ ignore-windows // This test should be replaced with one in tests/debuginfo once GDB or LLDB support 128-bit enums. -use gimli::{AttributeValue, EndianRcSlice, Reader, RunTimeEndian}; -use object::{Object, ObjectSection}; -use run_make_support::{gimli, object, rfs, rustc}; use std::collections::HashMap; use std::path::PathBuf; use std::rc::Rc; +use gimli::{AttributeValue, EndianRcSlice, Reader, RunTimeEndian}; +use object::{Object, ObjectSection}; +use run_make_support::{gimli, object, rfs, rustc}; + fn main() { let output = PathBuf::from("repr128"); rustc().input("main.rs").output(&output).arg("-Cdebuginfo=2").run(); diff --git a/tests/run-make/reset-codegen-1/rmake.rs b/tests/run-make/reset-codegen-1/rmake.rs index cc6bb7d5e39..d19907a675e 100644 --- a/tests/run-make/reset-codegen-1/rmake.rs +++ b/tests/run-make/reset-codegen-1/rmake.rs @@ -7,9 +7,10 @@ //@ ignore-cross-compile -use run_make_support::{bin_name, rfs, rustc}; use std::path::Path; +use run_make_support::{bin_name, rfs, rustc}; + fn compile(output_file: &str, emit: Option<&str>) { let mut rustc = rustc(); let rustc = rustc.codegen_units(4).output(output_file).input("foo.rs"); diff --git a/tests/run-make/resolve-rename/rmake.rs b/tests/run-make/resolve-rename/rmake.rs index 16ee7b02885..21ec7f85274 100644 --- a/tests/run-make/resolve-rename/rmake.rs +++ b/tests/run-make/resolve-rename/rmake.rs @@ -5,8 +5,7 @@ // the renamed library. // See https://github.com/rust-lang/rust/pull/49253 -use run_make_support::rfs; -use run_make_support::rustc; +use run_make_support::{rfs, rustc}; fn main() { rustc().extra_filename("-hash").input("foo.rs").run(); diff --git a/tests/run-make/rust-lld-by-default-beta-stable/rmake.rs b/tests/run-make/rust-lld-by-default-beta-stable/rmake.rs index fc3dffdbaf4..2417a4274e4 100644 --- a/tests/run-make/rust-lld-by-default-beta-stable/rmake.rs +++ b/tests/run-make/rust-lld-by-default-beta-stable/rmake.rs @@ -4,9 +4,10 @@ //@ ignore-nightly //@ only-x86_64-unknown-linux-gnu +use std::process::Output; + use run_make_support::regex::Regex; use run_make_support::rustc; -use std::process::Output; fn main() { // A regular compilation should not use rust-lld by default. We'll check that by asking the diff --git a/tests/run-make/rust-lld-by-default-nightly/rmake.rs b/tests/run-make/rust-lld-by-default-nightly/rmake.rs index f3ce9ada157..79424984c21 100644 --- a/tests/run-make/rust-lld-by-default-nightly/rmake.rs +++ b/tests/run-make/rust-lld-by-default-nightly/rmake.rs @@ -6,9 +6,10 @@ //@ ignore-stable //@ only-x86_64-unknown-linux-gnu +use std::process::Output; + use run_make_support::regex::Regex; use run_make_support::rustc; -use std::process::Output; fn main() { // A regular compilation should use rust-lld by default. We'll check that by asking the linker diff --git a/tests/run-make/rust-lld-custom-target/rmake.rs b/tests/run-make/rust-lld-custom-target/rmake.rs index f3dc2275f62..17247125521 100644 --- a/tests/run-make/rust-lld-custom-target/rmake.rs +++ b/tests/run-make/rust-lld-custom-target/rmake.rs @@ -8,9 +8,10 @@ //@ needs-rust-lld //@ only-x86_64-unknown-linux-gnu +use std::process::Output; + use run_make_support::regex::Regex; use run_make_support::rustc; -use std::process::Output; fn main() { // Compile to a custom target spec with rust-lld enabled by default. We'll check that by asking diff --git a/tests/run-make/rust-lld/rmake.rs b/tests/run-make/rust-lld/rmake.rs index 3eb60367c7f..87477c12230 100644 --- a/tests/run-make/rust-lld/rmake.rs +++ b/tests/run-make/rust-lld/rmake.rs @@ -5,9 +5,10 @@ //@ ignore-msvc //@ ignore-s390x lld does not yet support s390x as target +use std::process::Output; + use run_make_support::regex::Regex; use run_make_support::rustc; -use std::process::Output; fn main() { // Opt-in to lld and the self-contained linker, to link with rust-lld. We'll check that by diff --git a/tests/run-make/rustdoc-determinism/rmake.rs b/tests/run-make/rustdoc-determinism/rmake.rs index 2d4f357d681..aa8090174d9 100644 --- a/tests/run-make/rustdoc-determinism/rmake.rs +++ b/tests/run-make/rustdoc-determinism/rmake.rs @@ -1,9 +1,10 @@ // Assert that the search index is generated deterministically, regardless of the // order that crates are documented in. -use run_make_support::{diff, rustdoc}; use std::path::Path; +use run_make_support::{diff, rustdoc}; + fn main() { let foo_first = Path::new("foo_first"); rustdoc().input("foo.rs").output(&foo_first).run(); diff --git a/tests/run-make/rustdoc-io-error/rmake.rs b/tests/run-make/rustdoc-io-error/rmake.rs index 69afea40162..d64c5106ffb 100644 --- a/tests/run-make/rustdoc-io-error/rmake.rs +++ b/tests/run-make/rustdoc-io-error/rmake.rs @@ -14,9 +14,10 @@ // `mkfs.ext4 -d`, as well as mounting a loop device for the rootfs. //@ ignore-windows - the `set_readonly` functions doesn't work on folders. -use run_make_support::{path, rustdoc}; use std::fs; +use run_make_support::{path, rustdoc}; + fn main() { let out_dir = path("rustdoc-io-error"); let output = fs::create_dir(&out_dir).unwrap(); diff --git a/tests/run-make/rustdoc-output-path/rmake.rs b/tests/run-make/rustdoc-output-path/rmake.rs index 28e0fd98f93..3c1ccd3a069 100644 --- a/tests/run-make/rustdoc-output-path/rmake.rs +++ b/tests/run-make/rustdoc-output-path/rmake.rs @@ -1,8 +1,9 @@ // Checks that if the output folder doesn't exist, rustdoc will create it. -use run_make_support::rustdoc; use std::path::Path; +use run_make_support::rustdoc; + fn main() { let out_dir = Path::new("foo/bar/doc"); rustdoc().input("foo.rs").output(&out_dir).run(); diff --git a/tests/run-make/rustdoc-scrape-examples-remap/scrape.rs b/tests/run-make/rustdoc-scrape-examples-remap/scrape.rs index 3feee78f2e1..4badc68845e 100644 --- a/tests/run-make/rustdoc-scrape-examples-remap/scrape.rs +++ b/tests/run-make/rustdoc-scrape-examples-remap/scrape.rs @@ -1,6 +1,7 @@ -use run_make_support::{htmldocck, rfs, rustc, rustdoc, source_root}; use std::path::Path; +use run_make_support::{htmldocck, rfs, rustc, rustdoc, source_root}; + pub fn scrape(extra_args: &[&str]) { let out_dir = Path::new("rustdoc"); let crate_name = "foobar"; diff --git a/tests/run-make/rustdoc-test-args/rmake.rs b/tests/run-make/rustdoc-test-args/rmake.rs index 69dea83de4f..fddb3795402 100644 --- a/tests/run-make/rustdoc-test-args/rmake.rs +++ b/tests/run-make/rustdoc-test-args/rmake.rs @@ -1,7 +1,8 @@ -use run_make_support::{rfs, rustdoc}; use std::iter; use std::path::Path; +use run_make_support::{rfs, rustdoc}; + fn generate_a_lot_of_cfgs(path: &Path) { let content = iter::repeat("--cfg=a\n").take(100_000).collect::<String>(); rfs::write(path, content.as_bytes()); diff --git a/tests/run-make/rustdoc-themes/rmake.rs b/tests/run-make/rustdoc-themes/rmake.rs index 981db358f29..8a961beb9f7 100644 --- a/tests/run-make/rustdoc-themes/rmake.rs +++ b/tests/run-make/rustdoc-themes/rmake.rs @@ -1,8 +1,9 @@ // Test that rustdoc will properly load in a theme file and display it in the theme selector. -use run_make_support::{htmldocck, rfs, rustdoc, source_root}; use std::path::Path; +use run_make_support::{htmldocck, rfs, rustdoc, source_root}; + fn main() { let out_dir = Path::new("rustdoc-themes"); let test_css = "test.css"; diff --git a/tests/run-make/rustdoc-verify-output-files/rmake.rs b/tests/run-make/rustdoc-verify-output-files/rmake.rs index d1ff2e330f5..a4d4050b745 100644 --- a/tests/run-make/rustdoc-verify-output-files/rmake.rs +++ b/tests/run-make/rustdoc-verify-output-files/rmake.rs @@ -1,7 +1,6 @@ -use run_make_support::rfs; use std::path::{Path, PathBuf}; -use run_make_support::{assert_dirs_are_equal, rustdoc}; +use run_make_support::{assert_dirs_are_equal, rfs, rustdoc}; #[derive(PartialEq)] enum JsonOutput { diff --git a/tests/run-make/sanitizer-cdylib-link/Makefile b/tests/run-make/sanitizer-cdylib-link/Makefile deleted file mode 100644 index 10d94afc39e..00000000000 --- a/tests/run-make/sanitizer-cdylib-link/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# needs-sanitizer-support -# needs-sanitizer-address - -include ../tools.mk - -LOG := $(TMPDIR)/log.txt - -# This test builds a shared object, then an executable that links it as a native -# rust library (contrast to an rlib). The shared library and executable both -# are compiled with address sanitizer, and we assert that a fault in the cdylib -# is correctly detected. - -all: - $(RUSTC) -g -Z sanitizer=address --crate-type cdylib --target $(TARGET) library.rs - $(RUSTC) -g -Z sanitizer=address --crate-type bin --target $(TARGET) program.rs - LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | $(CGREP) stack-buffer-overflow diff --git a/tests/run-make/sanitizer-cdylib-link/rmake.rs b/tests/run-make/sanitizer-cdylib-link/rmake.rs new file mode 100644 index 00000000000..f9d7fd98789 --- /dev/null +++ b/tests/run-make/sanitizer-cdylib-link/rmake.rs @@ -0,0 +1,17 @@ +// Identical to sanitizer-dylib-link, but with a cdylib. +// This test builds a shared object, then an executable that links it as a native +// rust library (contrast to an rlib). The shared library and executable both +// are compiled with address sanitizer, and we assert that a fault in the cdylib +// is correctly detected. +// See https://github.com/rust-lang/rust/pull/38699 + +//@ needs-sanitizer-support +//@ needs-sanitizer-address + +use run_make_support::{run_fail, rustc}; + +fn main() { + rustc().arg("-g").arg("-Zsanitizer=address").crate_type("cdylib").input("library.rs").run(); + rustc().arg("-g").arg("-Zsanitizer=address").crate_type("bin").input("program.rs").run(); + run_fail("program").assert_stderr_contains("stack-buffer-overflow"); +} diff --git a/tests/run-make/sanitizer-dylib-link/Makefile b/tests/run-make/sanitizer-dylib-link/Makefile deleted file mode 100644 index c5a698db3a0..00000000000 --- a/tests/run-make/sanitizer-dylib-link/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# needs-sanitizer-support -# needs-sanitizer-address - -include ../tools.mk - -LOG := $(TMPDIR)/log.txt - -# This test builds a shared object, then an executable that links it as a native -# rust library (contrast to an rlib). The shared library and executable both -# are compiled with address sanitizer, and we assert that a fault in the dylib -# is correctly detected. - -all: - $(RUSTC) -g -Z sanitizer=address --crate-type dylib --target $(TARGET) library.rs - $(RUSTC) -g -Z sanitizer=address --crate-type bin --target $(TARGET) program.rs - LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | $(CGREP) stack-buffer-overflow diff --git a/tests/run-make/sanitizer-dylib-link/rmake.rs b/tests/run-make/sanitizer-dylib-link/rmake.rs new file mode 100644 index 00000000000..b43420adc72 --- /dev/null +++ b/tests/run-make/sanitizer-dylib-link/rmake.rs @@ -0,0 +1,16 @@ +// This test builds a shared object, then an executable that links it as a native +// rust library (contrast to an rlib). The shared library and executable both +// are compiled with address sanitizer, and we assert that a fault in the dylib +// is correctly detected. +// See https://github.com/rust-lang/rust/pull/38699 + +//@ needs-sanitizer-support +//@ needs-sanitizer-address + +use run_make_support::{run_fail, rustc}; + +fn main() { + rustc().arg("-g").arg("-Zsanitizer=address").crate_type("dylib").input("library.rs").run(); + rustc().arg("-g").arg("-Zsanitizer=address").crate_type("bin").input("program.rs").run(); + run_fail("program").assert_stderr_contains("stack-buffer-overflow"); +} diff --git a/tests/run-make/sanitizer-staticlib-link/Makefile b/tests/run-make/sanitizer-staticlib-link/Makefile deleted file mode 100644 index 7b1a286ed12..00000000000 --- a/tests/run-make/sanitizer-staticlib-link/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -# needs-sanitizer-support -# needs-sanitizer-address - -include ../tools.mk - -# This test first builds a staticlib with AddressSanitizer and checks that -# linking it to an executable fails due to the missing sanitizer runtime. -# It then builds an executable linking to the staticlib and checks that -# the fault in the staticlib is detected correctly. - -# Note that checking for the link failure actually checks two things at once: -# 1) That the library has the sanitizer intrumentation -# 2) and that library does not have the sanitizer runtime - -all: - $(RUSTC) -g -Z sanitizer=address --crate-type staticlib --target $(TARGET) library.rs - ! $(CC) program.c $(call STATICLIB,library) $(call OUT_EXE,program) $(EXTRACFLAGS) $(EXTRACXXFLAGS) - $(RUSTC) -g -Z sanitizer=address --crate-type bin --target $(TARGET) -L . program.rs - LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | $(CGREP) stack-buffer-overflow - diff --git a/tests/run-make/sanitizer-staticlib-link/rmake.rs b/tests/run-make/sanitizer-staticlib-link/rmake.rs new file mode 100644 index 00000000000..e38d15a8a3c --- /dev/null +++ b/tests/run-make/sanitizer-staticlib-link/rmake.rs @@ -0,0 +1,26 @@ +// This test first builds a staticlib with AddressSanitizer and checks that +// linking it to an executable fails due to the missing sanitizer runtime. +// It then builds an executable linking to the staticlib and checks that +// the fault in the staticlib is detected correctly. + +// Note that checking for the link failure actually checks two things at once: +// 1) That the library has the sanitizer intrumentation +// 2) and that library does not have the sanitizer runtime +// See https://github.com/rust-lang/rust/pull/38699 + +//@ needs-sanitizer-support +//@ needs-sanitizer-address + +use run_make_support::{cc, extra_c_flags, extra_cxx_flags, run_fail, rustc, static_lib_name}; + +fn main() { + rustc().arg("-g").arg("-Zsanitizer=address").crate_type("staticlib").input("library.rs").run(); + cc().input("program.c") + .arg(static_lib_name("library")) + .out_exe("program") + .args(extra_c_flags()) + .args(extra_cxx_flags()) + .run_fail(); + rustc().arg("-g").arg("-Zsanitizer=address").crate_type("bin").input("program.rs").run(); + run_fail("program").assert_stderr_contains("stack-buffer-overflow"); +} diff --git a/tests/run-make/static-dylib-by-default/Makefile b/tests/run-make/static-dylib-by-default/Makefile deleted file mode 100644 index cdaab42d06c..00000000000 --- a/tests/run-make/static-dylib-by-default/Makefile +++ /dev/null @@ -1,17 +0,0 @@ -# ignore-cross-compile -include ../tools.mk - -TO_LINK := $(call DYLIB,bar) -ifdef IS_MSVC -LINK_ARG = $(TO_LINK:dll=dll.lib) -else -LINK_ARG = $(TO_LINK) -endif - -all: - $(RUSTC) foo.rs - $(RUSTC) bar.rs - $(CC) main.c $(call OUT_EXE,main) $(LINK_ARG) $(EXTRACFLAGS) - rm $(TMPDIR)/*.rlib - rm $(call DYLIB,foo) - $(call RUN,main) diff --git a/tests/run-make/static-dylib-by-default/rmake.rs b/tests/run-make/static-dylib-by-default/rmake.rs new file mode 100644 index 00000000000..133210c74e7 --- /dev/null +++ b/tests/run-make/static-dylib-by-default/rmake.rs @@ -0,0 +1,35 @@ +// If a dylib is being produced, the compiler will first check to see if it can +// be created entirely statically before falling back to dynamic dependencies. This +// behavior can be overridden with `-C prefer-dynamic`. +// In this test, bar depends on foo and is compiled fully statically despite the available +// `foo` dynamic library. This allows the main binary to be executed in the final step. +// See https://github.com/rust-lang/rust/commit/3036b001276a6e43409b08b7f2334ce72aeeb036 + +//@ ignore-cross-compile +// Reason: the compiled binary is executed + +use run_make_support::{ + cc, cwd, dynamic_lib_name, extra_c_flags, has_extension, is_msvc, rfs, run, rustc, + shallow_find_files, +}; + +fn main() { + rustc().input("foo.rs").run(); + rustc().input("bar.rs").run(); + // On msvc, dynamic libraries are compiled by rustc to: + // bar.dll // dylib + // bar.dll.lib // import library for the dylib + // bar.dll.exp // export library for the dylib + // msvc's underlying link.exe requires the import library for the dynamic library as input. + // That is why the library is bar.dll.lib, not bar.dll. + let library = if is_msvc() { "bar.dll.lib" } else { &dynamic_lib_name("bar") }; + cc().input("main.c").out_exe("main").arg(library).args(extra_c_flags()).run(); + for rlib in shallow_find_files(cwd(), |path| has_extension(path, "rlib")) { + rfs::remove_file(rlib); + } + rfs::remove_file(dynamic_lib_name("foo")); + if is_msvc() { + rfs::remove_file("foo.dll.lib"); + } + run("main"); +} diff --git a/tests/run-make/static-pie/rmake.rs b/tests/run-make/static-pie/rmake.rs index 6a92f92328e..74f86bb8163 100644 --- a/tests/run-make/static-pie/rmake.rs +++ b/tests/run-make/static-pie/rmake.rs @@ -7,10 +7,8 @@ use std::process::Command; -use run_make_support::llvm_readobj; use run_make_support::regex::Regex; -use run_make_support::rustc; -use run_make_support::{cmd, run_with_args, target}; +use run_make_support::{cmd, llvm_readobj, run_with_args, rustc, target}; // Minimum major versions supporting -static-pie const GCC_VERSION: u32 = 8; diff --git a/tests/run-make/stdin-rustc/rmake.rs b/tests/run-make/stdin-rustc/rmake.rs index d599f813563..68e9cf2fbd8 100644 --- a/tests/run-make/stdin-rustc/rmake.rs +++ b/tests/run-make/stdin-rustc/rmake.rs @@ -1,8 +1,9 @@ //! This test checks rustc `-` (stdin) support -use run_make_support::{is_windows, rustc}; use std::path::PathBuf; +use run_make_support::{is_windows, rustc}; + const HELLO_WORLD: &str = r#" fn main() { println!("Hello world!"); diff --git a/tests/run-make/stdin-rustdoc/rmake.rs b/tests/run-make/stdin-rustdoc/rmake.rs index a72fe1bc7da..de47a24fbdd 100644 --- a/tests/run-make/stdin-rustdoc/rmake.rs +++ b/tests/run-make/stdin-rustdoc/rmake.rs @@ -1,8 +1,9 @@ //! This test checks rustdoc `-` (stdin) handling -use run_make_support::rustdoc; use std::path::PathBuf; +use run_make_support::rustdoc; + static INPUT: &str = r#" //! ``` //! dbg!(()); diff --git a/tests/run-make/suspicious-library/rmake.rs b/tests/run-make/suspicious-library/rmake.rs index e789607482b..1dc9bc53b67 100644 --- a/tests/run-make/suspicious-library/rmake.rs +++ b/tests/run-make/suspicious-library/rmake.rs @@ -3,9 +3,10 @@ //@ ignore-cross-compile -use run_make_support::{dynamic_lib_name, rustc}; use std::fs::File; +use run_make_support::{dynamic_lib_name, rustc}; + fn main() { rustc().input("foo.rs").arg("-Cprefer-dynamic").run(); File::create(dynamic_lib_name("foo-something-special")).unwrap(); diff --git a/tests/run-make/thumb-none-qemu/example/src/main.rs b/tests/run-make/thumb-none-qemu/example/src/main.rs index 2abfde8e75f..4b8162c4120 100644 --- a/tests/run-make/thumb-none-qemu/example/src/main.rs +++ b/tests/run-make/thumb-none-qemu/example/src/main.rs @@ -1,11 +1,10 @@ #![no_main] #![no_std] use core::fmt::Write; + use cortex_m::asm; use cortex_m_rt::entry; -use cortex_m_semihosting as semihosting; - -use panic_halt as _; +use {cortex_m_semihosting as semihosting, panic_halt as _}; #[entry] fn main() -> ! { diff --git a/tests/run-make/volatile-intrinsics/rmake.rs b/tests/run-make/volatile-intrinsics/rmake.rs index 66bc6f953c2..1d19b652143 100644 --- a/tests/run-make/volatile-intrinsics/rmake.rs +++ b/tests/run-make/volatile-intrinsics/rmake.rs @@ -1,7 +1,6 @@ //@ ignore-cross-compile -use run_make_support::rfs; -use run_make_support::{assert_contains, run, rustc}; +use run_make_support::{assert_contains, rfs, run, rustc}; fn main() { // The tests must pass... diff --git a/tests/run-make/wasm-custom-section/rmake.rs b/tests/run-make/wasm-custom-section/rmake.rs index 756a72f11b1..ff4c29a9d30 100644 --- a/tests/run-make/wasm-custom-section/rmake.rs +++ b/tests/run-make/wasm-custom-section/rmake.rs @@ -1,8 +1,9 @@ //@ only-wasm32-wasip1 -use run_make_support::{rfs, rustc, wasmparser}; use std::collections::HashMap; +use run_make_support::{rfs, rustc, wasmparser}; + fn main() { rustc().input("foo.rs").target("wasm32-wasip1").run(); rustc().input("bar.rs").target("wasm32-wasip1").arg("-Clto").opt().run(); diff --git a/tests/run-make/wasm-custom-sections-opt/rmake.rs b/tests/run-make/wasm-custom-sections-opt/rmake.rs index 0be863fdb6e..063a4f2257c 100644 --- a/tests/run-make/wasm-custom-sections-opt/rmake.rs +++ b/tests/run-make/wasm-custom-sections-opt/rmake.rs @@ -1,9 +1,10 @@ //@ only-wasm32-wasip1 -use run_make_support::{rfs, rustc, wasmparser}; use std::collections::HashMap; use std::path::Path; +use run_make_support::{rfs, rustc, wasmparser}; + fn main() { rustc().input("foo.rs").target("wasm32-wasip1").opt().run(); diff --git a/tests/run-make/wasm-export-all-symbols/rmake.rs b/tests/run-make/wasm-export-all-symbols/rmake.rs index 9ea541a1752..4148cc29ec2 100644 --- a/tests/run-make/wasm-export-all-symbols/rmake.rs +++ b/tests/run-make/wasm-export-all-symbols/rmake.rs @@ -1,8 +1,9 @@ //@ only-wasm32-wasip1 -use run_make_support::{rfs, rustc, wasmparser}; use std::collections::HashMap; use std::path::Path; + +use run_make_support::{rfs, rustc, wasmparser}; use wasmparser::ExternalKind::*; fn main() { diff --git a/tests/run-make/wasm-import-module/rmake.rs b/tests/run-make/wasm-import-module/rmake.rs index c240d4780b2..3b74cb20558 100644 --- a/tests/run-make/wasm-import-module/rmake.rs +++ b/tests/run-make/wasm-import-module/rmake.rs @@ -1,7 +1,8 @@ //@ only-wasm32-wasip1 -use run_make_support::{rfs, rustc, wasmparser}; use std::collections::HashMap; + +use run_make_support::{rfs, rustc, wasmparser}; use wasmparser::TypeRef::Func; fn main() { diff --git a/tests/run-make/wasm-spurious-import/rmake.rs b/tests/run-make/wasm-spurious-import/rmake.rs index 9cfd202eae1..8fde8d295c7 100644 --- a/tests/run-make/wasm-spurious-import/rmake.rs +++ b/tests/run-make/wasm-spurious-import/rmake.rs @@ -1,8 +1,9 @@ //@ only-wasm32-wasip1 -use run_make_support::{rfs, rustc, wasmparser}; use std::collections::HashMap; +use run_make_support::{rfs, rustc, wasmparser}; + fn main() { rustc() .input("main.rs") diff --git a/tests/run-make/wasm-symbols-different-module/rmake.rs b/tests/run-make/wasm-symbols-different-module/rmake.rs index 6b69f76ee17..3cd459db02f 100644 --- a/tests/run-make/wasm-symbols-different-module/rmake.rs +++ b/tests/run-make/wasm-symbols-different-module/rmake.rs @@ -1,9 +1,10 @@ //@ only-wasm32-wasip1 -use run_make_support::{rfs, rustc, wasmparser}; use std::collections::{HashMap, HashSet}; use std::path::Path; +use run_make_support::{rfs, rustc, wasmparser}; + fn main() { test_file("foo.rs", &[("a", &["foo"]), ("b", &["foo"])]); test_file("bar.rs", &[("m1", &["f", "g"]), ("m2", &["f"])]); diff --git a/tests/run-make/wasm-symbols-not-exported/rmake.rs b/tests/run-make/wasm-symbols-not-exported/rmake.rs index ad31351ba95..0b9c9c6822e 100644 --- a/tests/run-make/wasm-symbols-not-exported/rmake.rs +++ b/tests/run-make/wasm-symbols-not-exported/rmake.rs @@ -1,8 +1,9 @@ //@ only-wasm32-wasip1 -use run_make_support::{rfs, rustc, wasmparser}; use std::path::Path; +use run_make_support::{rfs, rustc, wasmparser}; + fn main() { rustc().input("foo.rs").target("wasm32-wasip1").run(); verify_symbols(Path::new("foo.wasm")); diff --git a/tests/run-make/wasm-symbols-not-imported/rmake.rs b/tests/run-make/wasm-symbols-not-imported/rmake.rs index 36c600c49f5..fc22e31356a 100644 --- a/tests/run-make/wasm-symbols-not-imported/rmake.rs +++ b/tests/run-make/wasm-symbols-not-imported/rmake.rs @@ -1,8 +1,9 @@ //@ only-wasm32-wasip1 -use run_make_support::{rfs, rustc, wasmparser}; use std::path::Path; +use run_make_support::{rfs, rustc, wasmparser}; + fn main() { rustc().input("foo.rs").target("wasm32-wasip1").run(); verify_symbols(Path::new("foo.wasm")); diff --git a/tests/run-make/weird-output-filenames/rmake.rs b/tests/run-make/weird-output-filenames/rmake.rs index 3d1b5f4007c..9e451f7d7eb 100644 --- a/tests/run-make/weird-output-filenames/rmake.rs +++ b/tests/run-make/weird-output-filenames/rmake.rs @@ -1,6 +1,5 @@ use run_make_support::regex::Regex; -use run_make_support::rfs; -use run_make_support::{cwd, rustc}; +use run_make_support::{cwd, rfs, rustc}; fn main() { let invalid_characters = [".foo.rs", ".foo.bar", "+foo+bar.rs"]; diff --git a/tests/run-make/windows-binary-no-external-deps/rmake.rs b/tests/run-make/windows-binary-no-external-deps/rmake.rs index 61fdb202221..1706d757c3a 100644 --- a/tests/run-make/windows-binary-no-external-deps/rmake.rs +++ b/tests/run-make/windows-binary-no-external-deps/rmake.rs @@ -2,10 +2,11 @@ //! a "hello world" application by setting `PATH` to `C:\Windows\System32`. //@ only-windows -use run_make_support::{cwd, env_var, rustc}; use std::path::PathBuf; use std::process::Command; +use run_make_support::{cwd, env_var, rustc}; + fn main() { rustc().input("hello.rs").run(); diff --git a/tests/run-make/windows-ws2_32/rmake.rs b/tests/run-make/windows-ws2_32/rmake.rs index 6457d74f97e..1e426a8bffa 100644 --- a/tests/run-make/windows-ws2_32/rmake.rs +++ b/tests/run-make/windows-ws2_32/rmake.rs @@ -2,7 +2,8 @@ // Tests that WS2_32.dll is not unnecessarily linked, see issue #85441 -use run_make_support::object::{self, read::Object}; +use run_make_support::object::read::Object; +use run_make_support::object::{self}; use run_make_support::{rfs, rustc}; fn main() { diff --git a/tests/rustdoc-gui/copy-code.goml b/tests/rustdoc-gui/copy-code.goml new file mode 100644 index 00000000000..72a5bece175 --- /dev/null +++ b/tests/rustdoc-gui/copy-code.goml @@ -0,0 +1,54 @@ +// Checks that the "copy code" button is not triggering JS error and its display +// isn't broken. +go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" + +define-function: ( + "check-copy-button", + [], + block { + // First we ensure that there are no "copy code" currently existing. + assert-count: (".example-wrap .copy-button", 0) + move-cursor-to: ".example-wrap" + assert-count: (".example-wrap .copy-button", 1) + // We now ensure it's only displayed when the example is hovered. + assert-css: (".example-wrap .copy-button", { "visibility": "visible" }) + move-cursor-to: ".search-input" + assert-css: (".example-wrap .copy-button", { "visibility": "hidden" }) + // Checking that the copy button has the same size as the "copy path" button. + compare-elements-size: ( + "#copy-path", + ".example-wrap:nth-of-type(1) .copy-button", + ["height", "width"], + ) + }, +) + +call-function: ("check-copy-button", {}) +// Checking that the run button and the copy button have the same height. +compare-elements-size: ( + ".example-wrap:nth-of-type(1) .test-arrow", + ".example-wrap:nth-of-type(1) .copy-button", + ["height"], +) +// ... and the same y position. +compare-elements-position: ( + ".example-wrap:nth-of-type(1) .test-arrow", + ".example-wrap:nth-of-type(1) .copy-button", + ["y"], +) +store-size: (".example-wrap:nth-of-type(1) .copy-button", { + "height": copy_height, + "width": copy_width, +}) +assert: |copy_height| > 0 && |copy_width| > 0 + +// Checking same things for the copy button when there is no run button. +go-to: "file://" + |DOC_PATH| + "/lib2/sub_mod/struct.Foo.html" +call-function: ("check-copy-button", {}) +// Ensure there is no run button. +assert-count: (".example-wrap .test-arrow", 0) +// Check it's the same size without a run button. +assert-size: (".example-wrap:nth-of-type(1) .copy-button", { + "height": |copy_height|, + "width": |copy_width|, +}) diff --git a/tests/rustdoc-gui/run-on-hover.goml b/tests/rustdoc-gui/run-on-hover.goml index 087dd3374f8..b62da79b780 100644 --- a/tests/rustdoc-gui/run-on-hover.goml +++ b/tests/rustdoc-gui/run-on-hover.goml @@ -17,16 +17,16 @@ define-function: ( "visibility": "visible", "color": |color|, "background-color": |background|, - "font-size": "22px", - "border-radius": "5px", + "font-size": "16px", + "border-radius": "2px", }) move-cursor-to: ".test-arrow" assert-css: (".test-arrow:hover", { "visibility": "visible", "color": |hover_color|, "background-color": |hover_background|, - "font-size": "22px", - "border-radius": "5px", + "font-size": "16px", + "border-radius": "2px", }) }, ) diff --git a/tests/rustdoc-gui/search-title.goml b/tests/rustdoc-gui/search-title.goml new file mode 100644 index 00000000000..95bc36af449 --- /dev/null +++ b/tests/rustdoc-gui/search-title.goml @@ -0,0 +1,24 @@ +// Checks that the search changes the title +include: "utils.goml" +go-to: "file://" + |DOC_PATH| + "/test_docs/index.html" + +store-value: (title, "test_docs - Rust") +assert-document-property: {"title": |title|} + +write-into: (".search-input", "test") +// To be SURE that the search will be run. +press-key: 'Enter' +wait-for: "#crate-search" + +assert-document-property: {"title": '"test" Search - Rust'} + +set-property: (".search-input", {"value": "another one"}) +// To be SURE that the search will be run. +press-key: 'Enter' +wait-for: "#crate-search" + +assert-document-property: {"title": '"another one" Search - Rust'} + +press-key: "Escape" + +assert-document-property: {"title": |title|} diff --git a/tests/rustdoc-json/primitives/use_primitive.rs b/tests/rustdoc-json/primitives/use_primitive.rs index e97db42705f..27394a688c4 100644 --- a/tests/rustdoc-json/primitives/use_primitive.rs +++ b/tests/rustdoc-json/primitives/use_primitive.rs @@ -15,6 +15,5 @@ mod usize {} //@ is "$.index[*].inner.import[?(@.name=='my_i32')].id" null pub use i32 as my_i32; - //@ is "$.index[*].inner.import[?(@.name=='u32')].id" null pub use u32; diff --git a/tests/ui/array-slice-vec/slice_is_sorted_by_borrow.rs b/tests/ui/array-slice-vec/slice_is_sorted_by_borrow.rs index 31f59f8f724..6ac90953a05 100644 --- a/tests/ui/array-slice-vec/slice_is_sorted_by_borrow.rs +++ b/tests/ui/array-slice-vec/slice_is_sorted_by_borrow.rs @@ -1,8 +1,6 @@ //@ check-pass // regression test for https://github.com/rust-lang/rust/issues/53485#issuecomment-885393452 -#![feature(is_sorted)] - struct A { name: String, } diff --git a/tests/ui/asm/aarch64/bad-options.rs b/tests/ui/asm/aarch64/bad-options.rs index 33b77367a4f..9e721d55b2d 100644 --- a/tests/ui/asm/aarch64/bad-options.rs +++ b/tests/ui/asm/aarch64/bad-options.rs @@ -26,14 +26,14 @@ fn main() { } global_asm!("", options(nomem)); -//~^ ERROR expected one of +//~^ ERROR the `nomem` option cannot be used with `global_asm!` global_asm!("", options(readonly)); -//~^ ERROR expected one of +//~^ ERROR the `readonly` option cannot be used with `global_asm!` global_asm!("", options(noreturn)); -//~^ ERROR expected one of +//~^ ERROR the `noreturn` option cannot be used with `global_asm!` global_asm!("", options(pure)); -//~^ ERROR expected one of +//~^ ERROR the `pure` option cannot be used with `global_asm!` global_asm!("", options(nostack)); -//~^ ERROR expected one of +//~^ ERROR the `nostack` option cannot be used with `global_asm!` global_asm!("", options(preserves_flags)); -//~^ ERROR expected one of +//~^ ERROR the `preserves_flags` option cannot be used with `global_asm!` diff --git a/tests/ui/asm/aarch64/bad-options.stderr b/tests/ui/asm/aarch64/bad-options.stderr index 21bcc4a9c7b..54ab7cafa49 100644 --- a/tests/ui/asm/aarch64/bad-options.stderr +++ b/tests/ui/asm/aarch64/bad-options.stderr @@ -36,41 +36,41 @@ LL | asm!("{}", out(reg) foo, clobber_abi("C")); | | | generic outputs -error: expected one of `)`, `att_syntax`, or `raw`, found `nomem` +error: the `nomem` option cannot be used with `global_asm!` --> $DIR/bad-options.rs:28:25 | LL | global_asm!("", options(nomem)); - | ^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^ the `nomem` option is not meaningful for global-scoped inline assembly -error: expected one of `)`, `att_syntax`, or `raw`, found `readonly` +error: the `readonly` option cannot be used with `global_asm!` --> $DIR/bad-options.rs:30:25 | LL | global_asm!("", options(readonly)); - | ^^^^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^^^^ the `readonly` option is not meaningful for global-scoped inline assembly -error: expected one of `)`, `att_syntax`, or `raw`, found `noreturn` +error: the `noreturn` option cannot be used with `global_asm!` --> $DIR/bad-options.rs:32:25 | LL | global_asm!("", options(noreturn)); - | ^^^^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^^^^ the `noreturn` option is not meaningful for global-scoped inline assembly -error: expected one of `)`, `att_syntax`, or `raw`, found `pure` +error: the `pure` option cannot be used with `global_asm!` --> $DIR/bad-options.rs:34:25 | LL | global_asm!("", options(pure)); - | ^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^ the `pure` option is not meaningful for global-scoped inline assembly -error: expected one of `)`, `att_syntax`, or `raw`, found `nostack` +error: the `nostack` option cannot be used with `global_asm!` --> $DIR/bad-options.rs:36:25 | LL | global_asm!("", options(nostack)); - | ^^^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^^^ the `nostack` option is not meaningful for global-scoped inline assembly -error: expected one of `)`, `att_syntax`, or `raw`, found `preserves_flags` +error: the `preserves_flags` option cannot be used with `global_asm!` --> $DIR/bad-options.rs:38:25 | LL | global_asm!("", options(preserves_flags)); - | ^^^^^^^^^^^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^^^^^^^^^^^ the `preserves_flags` option is not meaningful for global-scoped inline assembly error: invalid ABI for `clobber_abi` --> $DIR/bad-options.rs:20:18 diff --git a/tests/ui/asm/aarch64/parse-error.rs b/tests/ui/asm/aarch64/parse-error.rs index fbb1e08df91..ac73bbf99c9 100644 --- a/tests/ui/asm/aarch64/parse-error.rs +++ b/tests/ui/asm/aarch64/parse-error.rs @@ -98,8 +98,10 @@ global_asm!("", options(FOO)); //~^ ERROR expected one of global_asm!("", options(nomem FOO)); //~^ ERROR expected one of +//~| ERROR the `nomem` option cannot be used with `global_asm!` global_asm!("", options(nomem, FOO)); //~^ ERROR expected one of +//~| ERROR the `nomem` option cannot be used with `global_asm!` global_asm!("{}", options(), const FOO); global_asm!("", clobber_abi(FOO)); //~^ ERROR expected string literal diff --git a/tests/ui/asm/aarch64/parse-error.stderr b/tests/ui/asm/aarch64/parse-error.stderr index d21a8ab1f85..e2c798c798e 100644 --- a/tests/ui/asm/aarch64/parse-error.stderr +++ b/tests/ui/asm/aarch64/parse-error.stderr @@ -218,56 +218,68 @@ error: expected one of `)`, `att_syntax`, or `raw`, found `FOO` LL | global_asm!("", options(FOO)); | ^^^ expected one of `)`, `att_syntax`, or `raw` -error: expected one of `)`, `att_syntax`, or `raw`, found `nomem` +error: the `nomem` option cannot be used with `global_asm!` --> $DIR/parse-error.rs:99:25 | LL | global_asm!("", options(nomem FOO)); - | ^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^ the `nomem` option is not meaningful for global-scoped inline assembly -error: expected one of `)`, `att_syntax`, or `raw`, found `nomem` - --> $DIR/parse-error.rs:101:25 +error: expected one of `)` or `,`, found `FOO` + --> $DIR/parse-error.rs:99:31 + | +LL | global_asm!("", options(nomem FOO)); + | ^^^ expected one of `)` or `,` + +error: the `nomem` option cannot be used with `global_asm!` + --> $DIR/parse-error.rs:102:25 + | +LL | global_asm!("", options(nomem, FOO)); + | ^^^^^ the `nomem` option is not meaningful for global-scoped inline assembly + +error: expected one of `)`, `att_syntax`, or `raw`, found `FOO` + --> $DIR/parse-error.rs:102:32 | LL | global_asm!("", options(nomem, FOO)); - | ^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^ expected one of `)`, `att_syntax`, or `raw` error: expected string literal - --> $DIR/parse-error.rs:104:29 + --> $DIR/parse-error.rs:106:29 | LL | global_asm!("", clobber_abi(FOO)); | ^^^ not a string literal error: expected one of `)` or `,`, found `FOO` - --> $DIR/parse-error.rs:106:33 + --> $DIR/parse-error.rs:108:33 | LL | global_asm!("", clobber_abi("C" FOO)); | ^^^ expected one of `)` or `,` error: expected string literal - --> $DIR/parse-error.rs:108:34 + --> $DIR/parse-error.rs:110:34 | LL | global_asm!("", clobber_abi("C", FOO)); | ^^^ not a string literal error: `clobber_abi` cannot be used with `global_asm!` - --> $DIR/parse-error.rs:110:19 + --> $DIR/parse-error.rs:112:19 | LL | global_asm!("{}", clobber_abi("C"), const FOO); | ^^^^^^^^^^^^^^^^ error: `clobber_abi` cannot be used with `global_asm!` - --> $DIR/parse-error.rs:112:28 + --> $DIR/parse-error.rs:114:28 | LL | global_asm!("", options(), clobber_abi("C")); | ^^^^^^^^^^^^^^^^ error: `clobber_abi` cannot be used with `global_asm!` - --> $DIR/parse-error.rs:114:30 + --> $DIR/parse-error.rs:116:30 | LL | global_asm!("{}", options(), clobber_abi("C"), const FOO); | ^^^^^^^^^^^^^^^^ error: duplicate argument named `a` - --> $DIR/parse-error.rs:116:35 + --> $DIR/parse-error.rs:118:35 | LL | global_asm!("{a}", a = const FOO, a = const BAR); | ------------- ^^^^^^^^^^^^^ duplicate argument @@ -275,7 +287,7 @@ LL | global_asm!("{a}", a = const FOO, a = const BAR); | previously here error: argument never used - --> $DIR/parse-error.rs:116:35 + --> $DIR/parse-error.rs:118:35 | LL | global_asm!("{a}", a = const FOO, a = const BAR); | ^^^^^^^^^^^^^ argument never used @@ -283,19 +295,19 @@ LL | global_asm!("{a}", a = const FOO, a = const BAR); = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {1} */"` error: expected one of `clobber_abi`, `const`, `options`, or `sym`, found `""` - --> $DIR/parse-error.rs:119:28 + --> $DIR/parse-error.rs:121:28 | LL | global_asm!("", options(), ""); | ^^ expected one of `clobber_abi`, `const`, `options`, or `sym` error: expected one of `clobber_abi`, `const`, `options`, or `sym`, found `"{}"` - --> $DIR/parse-error.rs:121:30 + --> $DIR/parse-error.rs:123:30 | LL | global_asm!("{}", const FOO, "{}", const FOO); | ^^^^ expected one of `clobber_abi`, `const`, `options`, or `sym` error: asm template must be a string literal - --> $DIR/parse-error.rs:123:13 + --> $DIR/parse-error.rs:125:13 | LL | global_asm!(format!("{{{}}}", 0), const FOO); | ^^^^^^^^^^^^^^^^^^^^ @@ -303,7 +315,7 @@ LL | global_asm!(format!("{{{}}}", 0), const FOO); = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) error: asm template must be a string literal - --> $DIR/parse-error.rs:125:20 + --> $DIR/parse-error.rs:127:20 | LL | global_asm!("{1}", format!("{{{}}}", 0), const FOO, const BAR); | ^^^^^^^^^^^^^^^^^^^^ @@ -398,6 +410,6 @@ help: consider using `const` instead of `let` LL | const bar: /* Type */ = 0; | ~~~~~ ++++++++++++ -error: aborting due to 57 previous errors +error: aborting due to 59 previous errors For more information about this error, try `rustc --explain E0435`. diff --git a/tests/ui/asm/naked-functions-inline.rs b/tests/ui/asm/naked-functions-inline.rs new file mode 100644 index 00000000000..cfb38f2e738 --- /dev/null +++ b/tests/ui/asm/naked-functions-inline.rs @@ -0,0 +1,38 @@ +//@ needs-asm-support +#![feature(naked_functions)] +#![crate_type = "lib"] + +use std::arch::asm; + +#[naked] +pub unsafe extern "C" fn inline_none() { + asm!("", options(noreturn)); +} + +#[naked] +#[inline] +//~^ ERROR [E0736] +pub unsafe extern "C" fn inline_hint() { + asm!("", options(noreturn)); +} + +#[naked] +#[inline(always)] +//~^ ERROR [E0736] +pub unsafe extern "C" fn inline_always() { + asm!("", options(noreturn)); +} + +#[naked] +#[inline(never)] +//~^ ERROR [E0736] +pub unsafe extern "C" fn inline_never() { + asm!("", options(noreturn)); +} + +#[naked] +#[cfg_attr(all(), inline(never))] +//~^ ERROR [E0736] +pub unsafe extern "C" fn conditional_inline_never() { + asm!("", options(noreturn)); +} diff --git a/tests/ui/asm/naked-functions-inline.stderr b/tests/ui/asm/naked-functions-inline.stderr new file mode 100644 index 00000000000..84a688f6f53 --- /dev/null +++ b/tests/ui/asm/naked-functions-inline.stderr @@ -0,0 +1,35 @@ +error[E0736]: attribute incompatible with `#[naked]` + --> $DIR/naked-functions-inline.rs:13:1 + | +LL | #[naked] + | -------- function marked with `#[naked]` here +LL | #[inline] + | ^^^^^^^^^ the `inline` attribute is incompatible with `#[naked]` + +error[E0736]: attribute incompatible with `#[naked]` + --> $DIR/naked-functions-inline.rs:20:1 + | +LL | #[naked] + | -------- function marked with `#[naked]` here +LL | #[inline(always)] + | ^^^^^^^^^^^^^^^^^ the `inline` attribute is incompatible with `#[naked]` + +error[E0736]: attribute incompatible with `#[naked]` + --> $DIR/naked-functions-inline.rs:27:1 + | +LL | #[naked] + | -------- function marked with `#[naked]` here +LL | #[inline(never)] + | ^^^^^^^^^^^^^^^^ the `inline` attribute is incompatible with `#[naked]` + +error[E0736]: attribute incompatible with `#[naked]` + --> $DIR/naked-functions-inline.rs:34:19 + | +LL | #[naked] + | -------- function marked with `#[naked]` here +LL | #[cfg_attr(all(), inline(never))] + | ^^^^^^^^^^^^^ the `inline` attribute is incompatible with `#[naked]` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0736`. diff --git a/tests/ui/asm/naked-functions-instruction-set.rs b/tests/ui/asm/naked-functions-instruction-set.rs new file mode 100644 index 00000000000..b81b65cff74 --- /dev/null +++ b/tests/ui/asm/naked-functions-instruction-set.rs @@ -0,0 +1,30 @@ +//@ compile-flags: --target armv5te-unknown-linux-gnueabi +//@ needs-llvm-components: arm +//@ needs-asm-support +//@ build-pass + +#![crate_type = "lib"] +#![feature(no_core, lang_items, rustc_attrs, naked_functions)] +#![no_core] + +#[rustc_builtin_macro] +macro_rules! asm { + () => {}; +} + +#[lang = "sized"] +trait Sized {} + +#[no_mangle] +#[naked] +#[instruction_set(arm::t32)] +unsafe extern "C" fn test_thumb() { + asm!("bx lr", options(noreturn)); +} + +#[no_mangle] +#[naked] +#[instruction_set(arm::t32)] +unsafe extern "C" fn test_arm() { + asm!("bx lr", options(noreturn)); +} diff --git a/tests/ui/asm/naked-functions-testattrs.rs b/tests/ui/asm/naked-functions-testattrs.rs new file mode 100644 index 00000000000..12943ac0378 --- /dev/null +++ b/tests/ui/asm/naked-functions-testattrs.rs @@ -0,0 +1,39 @@ +//@ needs-asm-support +//@ compile-flags: --test + +#![allow(undefined_naked_function_abi)] +#![feature(naked_functions)] +#![feature(test)] +#![crate_type = "lib"] + +use std::arch::asm; + +#[test] +#[naked] +//~^ ERROR [E0736] +fn test_naked() { + unsafe { asm!("", options(noreturn)) }; +} + +#[should_panic] +#[test] +#[naked] +//~^ ERROR [E0736] +fn test_naked_should_panic() { + unsafe { asm!("", options(noreturn)) }; +} + +#[ignore] +#[test] +#[naked] +//~^ ERROR [E0736] +fn test_naked_ignore() { + unsafe { asm!("", options(noreturn)) }; +} + +#[bench] +#[naked] +//~^ ERROR [E0736] +fn bench_naked() { + unsafe { asm!("", options(noreturn)) }; +} diff --git a/tests/ui/asm/naked-functions-testattrs.stderr b/tests/ui/asm/naked-functions-testattrs.stderr new file mode 100644 index 00000000000..4dabe41964a --- /dev/null +++ b/tests/ui/asm/naked-functions-testattrs.stderr @@ -0,0 +1,35 @@ +error[E0736]: cannot use `#[naked]` with testing attributes + --> $DIR/naked-functions-testattrs.rs:12:1 + | +LL | #[test] + | ------- function marked with testing attribute here +LL | #[naked] + | ^^^^^^^^ `#[naked]` is incompatible with testing attributes + +error[E0736]: cannot use `#[naked]` with testing attributes + --> $DIR/naked-functions-testattrs.rs:20:1 + | +LL | #[test] + | ------- function marked with testing attribute here +LL | #[naked] + | ^^^^^^^^ `#[naked]` is incompatible with testing attributes + +error[E0736]: cannot use `#[naked]` with testing attributes + --> $DIR/naked-functions-testattrs.rs:28:1 + | +LL | #[test] + | ------- function marked with testing attribute here +LL | #[naked] + | ^^^^^^^^ `#[naked]` is incompatible with testing attributes + +error[E0736]: cannot use `#[naked]` with testing attributes + --> $DIR/naked-functions-testattrs.rs:35:1 + | +LL | #[bench] + | -------- function marked with testing attribute here +LL | #[naked] + | ^^^^^^^^ `#[naked]` is incompatible with testing attributes + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0736`. diff --git a/tests/ui/asm/naked-functions.rs b/tests/ui/asm/naked-functions.rs index 6b2d2aea238..6d335ac2def 100644 --- a/tests/ui/asm/naked-functions.rs +++ b/tests/ui/asm/naked-functions.rs @@ -3,7 +3,7 @@ //@ ignore-spirv #![feature(naked_functions)] -#![feature(asm_const, asm_unwind)] +#![feature(asm_const, asm_unwind, linkage)] #![crate_type = "lib"] use std::arch::asm; @@ -163,57 +163,89 @@ pub unsafe extern "C" fn valid_att_syntax() { } #[naked] -pub unsafe extern "C" fn inline_none() { - asm!("", options(noreturn)); +#[naked] +pub unsafe extern "C" fn allow_compile_error(a: u32) -> u32 { + compile_error!("this is a user specified error") + //~^ ERROR this is a user specified error } #[naked] -#[inline] -//~^ ERROR naked functions cannot be inlined -pub unsafe extern "C" fn inline_hint() { - asm!("", options(noreturn)); +pub unsafe extern "C" fn allow_compile_error_and_asm(a: u32) -> u32 { + compile_error!("this is a user specified error"); + //~^ ERROR this is a user specified error + asm!("", options(noreturn)) } #[naked] -#[inline(always)] -//~^ ERROR naked functions cannot be inlined -pub unsafe extern "C" fn inline_always() { - asm!("", options(noreturn)); +pub unsafe extern "C" fn invalid_asm_syntax(a: u32) -> u32 { + asm!(invalid_syntax) + //~^ ERROR asm template must be a string literal } +#[cfg(target_arch = "x86_64")] +#[cfg_attr(target_pointer_width = "64", no_mangle)] #[naked] -#[inline(never)] -//~^ ERROR naked functions cannot be inlined -pub unsafe extern "C" fn inline_never() { - asm!("", options(noreturn)); +pub unsafe extern "C" fn compatible_cfg_attributes() { + asm!("", options(noreturn, att_syntax)); } +#[allow(dead_code)] +#[warn(dead_code)] +#[deny(dead_code)] +#[forbid(dead_code)] #[naked] -#[inline] -//~^ ERROR naked functions cannot be inlined -#[inline(always)] -//~^ ERROR naked functions cannot be inlined -#[inline(never)] -//~^ ERROR naked functions cannot be inlined -pub unsafe extern "C" fn inline_all() { - asm!("", options(noreturn)); +pub unsafe extern "C" fn compatible_diagnostic_attributes() { + asm!("", options(noreturn, raw)); } +#[deprecated = "test"] #[naked] -pub unsafe extern "C" fn allow_compile_error(a: u32) -> u32 { - compile_error!("this is a user specified error") - //~^ ERROR this is a user specified error +pub unsafe extern "C" fn compatible_deprecated_attributes() { + asm!("", options(noreturn, raw)); } +#[cfg(target_arch = "x86_64")] +#[must_use] #[naked] -pub unsafe extern "C" fn allow_compile_error_and_asm(a: u32) -> u32 { - compile_error!("this is a user specified error"); - //~^ ERROR this is a user specified error - asm!("", options(noreturn)) +pub unsafe extern "C" fn compatible_must_use_attributes() -> u64 { + asm!( + " + mov rax, 42 + ret + ", + options(noreturn) + ) } +#[export_name = "exported_function_name"] +#[link_section = ".custom_section"] +#[no_mangle] #[naked] -pub unsafe extern "C" fn invalid_asm_syntax(a: u32) -> u32 { - asm!(invalid_syntax) - //~^ ERROR asm template must be a string literal +pub unsafe extern "C" fn compatible_ffi_attributes_1() { + asm!("", options(noreturn, raw)); +} + +#[cold] +#[naked] +pub unsafe extern "C" fn compatible_codegen_attributes() { + asm!("", options(noreturn, raw)); +} + +#[cfg(target_arch = "x86_64")] +#[target_feature(enable = "sse2")] +#[naked] +pub unsafe extern "C" fn compatible_target_feature() { + asm!("", options(noreturn)); +} + +#[doc = "foo bar baz"] +#[naked] +pub unsafe extern "C" fn compatible_doc_attributes() { + asm!("", options(noreturn, raw)); +} + +#[linkage = "external"] +#[naked] +pub unsafe extern "C" fn compatible_linkage() { + asm!("", options(noreturn, raw)); } diff --git a/tests/ui/asm/naked-functions.stderr b/tests/ui/asm/naked-functions.stderr index 4dd9e29bdc6..93c02e2fbef 100644 --- a/tests/ui/asm/naked-functions.stderr +++ b/tests/ui/asm/naked-functions.stderr @@ -5,19 +5,19 @@ LL | asm!("", options(readonly, nostack), options(pure)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^ error: this is a user specified error - --> $DIR/naked-functions.rs:204:5 + --> $DIR/naked-functions.rs:168:5 | LL | compile_error!("this is a user specified error") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this is a user specified error - --> $DIR/naked-functions.rs:210:5 + --> $DIR/naked-functions.rs:174:5 | LL | compile_error!("this is a user specified error"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: asm template must be a string literal - --> $DIR/naked-functions.rs:217:10 + --> $DIR/naked-functions.rs:181:10 | LL | asm!(invalid_syntax) | ^^^^^^^^^^^^^^ @@ -249,42 +249,6 @@ warning: Rust ABI is unsupported in naked functions LL | pub unsafe fn rust_abi() { | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: naked functions cannot be inlined - --> $DIR/naked-functions.rs:171:1 - | -LL | #[inline] - | ^^^^^^^^^ - -error: naked functions cannot be inlined - --> $DIR/naked-functions.rs:178:1 - | -LL | #[inline(always)] - | ^^^^^^^^^^^^^^^^^ - -error: naked functions cannot be inlined - --> $DIR/naked-functions.rs:185:1 - | -LL | #[inline(never)] - | ^^^^^^^^^^^^^^^^ - -error: naked functions cannot be inlined - --> $DIR/naked-functions.rs:192:1 - | -LL | #[inline] - | ^^^^^^^^^ - -error: naked functions cannot be inlined - --> $DIR/naked-functions.rs:194:1 - | -LL | #[inline(always)] - | ^^^^^^^^^^^^^^^^^ - -error: naked functions cannot be inlined - --> $DIR/naked-functions.rs:196:1 - | -LL | #[inline(never)] - | ^^^^^^^^^^^^^^^^ - -error: aborting due to 33 previous errors; 2 warnings emitted +error: aborting due to 27 previous errors; 2 warnings emitted For more information about this error, try `rustc --explain E0787`. diff --git a/tests/ui/asm/parse-error.rs b/tests/ui/asm/parse-error.rs index a0251c6763b..9dec3a1c394 100644 --- a/tests/ui/asm/parse-error.rs +++ b/tests/ui/asm/parse-error.rs @@ -111,11 +111,15 @@ global_asm!("{}", const); global_asm!("{}", const(reg) FOO); //~^ ERROR expected one of global_asm!("", options(FOO)); -//~^ ERROR expected one of +//~^ ERROR expected one of `)`, `att_syntax`, or `raw`, found `FOO` +global_asm!("", options(FOO,)); +//~^ ERROR expected one of `)`, `att_syntax`, or `raw`, found `FOO` global_asm!("", options(nomem FOO)); -//~^ ERROR expected one of +//~^ ERROR the `nomem` option cannot be used with `global_asm!` +//~| ERROR expected one of `)` or `,`, found `FOO` global_asm!("", options(nomem, FOO)); -//~^ ERROR expected one of +//~^ ERROR the `nomem` option cannot be used with `global_asm!` +//~| ERROR expected one of `)`, `att_syntax`, or `raw`, found `FOO` global_asm!("{}", options(), const FOO); global_asm!("", clobber_abi(FOO)); //~^ ERROR expected string literal diff --git a/tests/ui/asm/parse-error.stderr b/tests/ui/asm/parse-error.stderr index 1999cd09aa3..e9ecd712bc3 100644 --- a/tests/ui/asm/parse-error.stderr +++ b/tests/ui/asm/parse-error.stderr @@ -264,62 +264,80 @@ error: expected one of `)`, `att_syntax`, or `raw`, found `FOO` LL | global_asm!("", options(FOO)); | ^^^ expected one of `)`, `att_syntax`, or `raw` -error: expected one of `)`, `att_syntax`, or `raw`, found `nomem` +error: expected one of `)`, `att_syntax`, or `raw`, found `FOO` --> $DIR/parse-error.rs:115:25 | -LL | global_asm!("", options(nomem FOO)); - | ^^^^^ expected one of `)`, `att_syntax`, or `raw` +LL | global_asm!("", options(FOO,)); + | ^^^ expected one of `)`, `att_syntax`, or `raw` -error: expected one of `)`, `att_syntax`, or `raw`, found `nomem` +error: the `nomem` option cannot be used with `global_asm!` --> $DIR/parse-error.rs:117:25 | +LL | global_asm!("", options(nomem FOO)); + | ^^^^^ the `nomem` option is not meaningful for global-scoped inline assembly + +error: expected one of `)` or `,`, found `FOO` + --> $DIR/parse-error.rs:117:31 + | +LL | global_asm!("", options(nomem FOO)); + | ^^^ expected one of `)` or `,` + +error: the `nomem` option cannot be used with `global_asm!` + --> $DIR/parse-error.rs:120:25 + | +LL | global_asm!("", options(nomem, FOO)); + | ^^^^^ the `nomem` option is not meaningful for global-scoped inline assembly + +error: expected one of `)`, `att_syntax`, or `raw`, found `FOO` + --> $DIR/parse-error.rs:120:32 + | LL | global_asm!("", options(nomem, FOO)); - | ^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^ expected one of `)`, `att_syntax`, or `raw` error: expected string literal - --> $DIR/parse-error.rs:120:29 + --> $DIR/parse-error.rs:124:29 | LL | global_asm!("", clobber_abi(FOO)); | ^^^ not a string literal error: expected one of `)` or `,`, found `FOO` - --> $DIR/parse-error.rs:122:33 + --> $DIR/parse-error.rs:126:33 | LL | global_asm!("", clobber_abi("C" FOO)); | ^^^ expected one of `)` or `,` error: expected string literal - --> $DIR/parse-error.rs:124:34 + --> $DIR/parse-error.rs:128:34 | LL | global_asm!("", clobber_abi("C", FOO)); | ^^^ not a string literal error: `clobber_abi` cannot be used with `global_asm!` - --> $DIR/parse-error.rs:126:19 + --> $DIR/parse-error.rs:130:19 | LL | global_asm!("{}", clobber_abi("C"), const FOO); | ^^^^^^^^^^^^^^^^ error: `clobber_abi` cannot be used with `global_asm!` - --> $DIR/parse-error.rs:128:28 + --> $DIR/parse-error.rs:132:28 | LL | global_asm!("", options(), clobber_abi("C")); | ^^^^^^^^^^^^^^^^ error: `clobber_abi` cannot be used with `global_asm!` - --> $DIR/parse-error.rs:130:30 + --> $DIR/parse-error.rs:134:30 | LL | global_asm!("{}", options(), clobber_abi("C"), const FOO); | ^^^^^^^^^^^^^^^^ error: `clobber_abi` cannot be used with `global_asm!` - --> $DIR/parse-error.rs:132:17 + --> $DIR/parse-error.rs:136:17 | LL | global_asm!("", clobber_abi("C"), clobber_abi("C")); | ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ error: duplicate argument named `a` - --> $DIR/parse-error.rs:134:35 + --> $DIR/parse-error.rs:138:35 | LL | global_asm!("{a}", a = const FOO, a = const BAR); | ------------- ^^^^^^^^^^^^^ duplicate argument @@ -327,7 +345,7 @@ LL | global_asm!("{a}", a = const FOO, a = const BAR); | previously here error: argument never used - --> $DIR/parse-error.rs:134:35 + --> $DIR/parse-error.rs:138:35 | LL | global_asm!("{a}", a = const FOO, a = const BAR); | ^^^^^^^^^^^^^ argument never used @@ -335,19 +353,19 @@ LL | global_asm!("{a}", a = const FOO, a = const BAR); = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {1} */"` error: expected one of `clobber_abi`, `const`, `options`, or `sym`, found `""` - --> $DIR/parse-error.rs:137:28 + --> $DIR/parse-error.rs:141:28 | LL | global_asm!("", options(), ""); | ^^ expected one of `clobber_abi`, `const`, `options`, or `sym` error: expected one of `clobber_abi`, `const`, `options`, or `sym`, found `"{}"` - --> $DIR/parse-error.rs:139:30 + --> $DIR/parse-error.rs:143:30 | LL | global_asm!("{}", const FOO, "{}", const FOO); | ^^^^ expected one of `clobber_abi`, `const`, `options`, or `sym` error: asm template must be a string literal - --> $DIR/parse-error.rs:141:13 + --> $DIR/parse-error.rs:145:13 | LL | global_asm!(format!("{{{}}}", 0), const FOO); | ^^^^^^^^^^^^^^^^^^^^ @@ -355,7 +373,7 @@ LL | global_asm!(format!("{{{}}}", 0), const FOO); = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) error: asm template must be a string literal - --> $DIR/parse-error.rs:143:20 + --> $DIR/parse-error.rs:147:20 | LL | global_asm!("{1}", format!("{{{}}}", 0), const FOO, const BAR); | ^^^^^^^^^^^^^^^^^^^^ @@ -363,7 +381,7 @@ LL | global_asm!("{1}", format!("{{{}}}", 0), const FOO, const BAR); = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected operand, options, or additional template string - --> $DIR/parse-error.rs:145:19 + --> $DIR/parse-error.rs:149:19 | LL | global_asm!("{}", label {}); | ^^^^^^^^ expected operand, options, or additional template string @@ -423,6 +441,6 @@ help: consider using `const` instead of `let` LL | const bar: /* Type */ = 0; | ~~~~~ ++++++++++++ -error: aborting due to 64 previous errors +error: aborting due to 67 previous errors For more information about this error, try `rustc --explain E0435`. diff --git a/tests/ui/asm/unsupported-option.fixed b/tests/ui/asm/unsupported-option.fixed new file mode 100644 index 00000000000..d313d8028b6 --- /dev/null +++ b/tests/ui/asm/unsupported-option.fixed @@ -0,0 +1,11 @@ +//@ needs-asm-support +//@ run-rustfix + +use std::arch::global_asm; + +fn main() {} + +global_asm!("", options( raw)); +//~^ ERROR the `nomem` option cannot be used with `global_asm!` +//~| ERROR the `readonly` option cannot be used with `global_asm!` +//~| ERROR the `noreturn` option cannot be used with `global_asm!` diff --git a/tests/ui/asm/unsupported-option.rs b/tests/ui/asm/unsupported-option.rs new file mode 100644 index 00000000000..d75f8e7f569 --- /dev/null +++ b/tests/ui/asm/unsupported-option.rs @@ -0,0 +1,11 @@ +//@ needs-asm-support +//@ run-rustfix + +use std::arch::global_asm; + +fn main() {} + +global_asm!("", options(nomem, readonly, noreturn, raw)); +//~^ ERROR the `nomem` option cannot be used with `global_asm!` +//~| ERROR the `readonly` option cannot be used with `global_asm!` +//~| ERROR the `noreturn` option cannot be used with `global_asm!` diff --git a/tests/ui/asm/unsupported-option.stderr b/tests/ui/asm/unsupported-option.stderr new file mode 100644 index 00000000000..7a6927152b6 --- /dev/null +++ b/tests/ui/asm/unsupported-option.stderr @@ -0,0 +1,20 @@ +error: the `nomem` option cannot be used with `global_asm!` + --> $DIR/unsupported-option.rs:8:25 + | +LL | global_asm!("", options(nomem, readonly, noreturn, raw)); + | ^^^^^ the `nomem` option is not meaningful for global-scoped inline assembly + +error: the `readonly` option cannot be used with `global_asm!` + --> $DIR/unsupported-option.rs:8:32 + | +LL | global_asm!("", options(nomem, readonly, noreturn, raw)); + | ^^^^^^^^ the `readonly` option is not meaningful for global-scoped inline assembly + +error: the `noreturn` option cannot be used with `global_asm!` + --> $DIR/unsupported-option.rs:8:42 + | +LL | global_asm!("", options(nomem, readonly, noreturn, raw)); + | ^^^^^^^^ the `noreturn` option is not meaningful for global-scoped inline assembly + +error: aborting due to 3 previous errors + diff --git a/tests/ui/asm/x86_64/bad-options.rs b/tests/ui/asm/x86_64/bad-options.rs index f9cc13cfc5a..6424a1b1d42 100644 --- a/tests/ui/asm/x86_64/bad-options.rs +++ b/tests/ui/asm/x86_64/bad-options.rs @@ -33,14 +33,14 @@ fn main() { } global_asm!("", options(nomem)); -//~^ ERROR expected one of +//~^ ERROR the `nomem` option cannot be used with `global_asm!` global_asm!("", options(readonly)); -//~^ ERROR expected one of +//~^ ERROR the `readonly` option cannot be used with `global_asm!` global_asm!("", options(noreturn)); -//~^ ERROR expected one of +//~^ ERROR the `noreturn` option cannot be used with `global_asm!` global_asm!("", options(pure)); -//~^ ERROR expected one of +//~^ ERROR the `pure` option cannot be used with `global_asm!` global_asm!("", options(nostack)); -//~^ ERROR expected one of +//~^ ERROR the `nostack` option cannot be used with `global_asm!` global_asm!("", options(preserves_flags)); -//~^ ERROR expected one of +//~^ ERROR the `preserves_flags` option cannot be used with `global_asm!` diff --git a/tests/ui/asm/x86_64/bad-options.stderr b/tests/ui/asm/x86_64/bad-options.stderr index aa167e7913c..366eb7cb90f 100644 --- a/tests/ui/asm/x86_64/bad-options.stderr +++ b/tests/ui/asm/x86_64/bad-options.stderr @@ -51,41 +51,41 @@ LL | asm!("{}", out(reg) foo, clobber_abi("C"), clobber_abi("C")); | | clobber_abi | generic outputs -error: expected one of `)`, `att_syntax`, or `raw`, found `nomem` +error: the `nomem` option cannot be used with `global_asm!` --> $DIR/bad-options.rs:35:25 | LL | global_asm!("", options(nomem)); - | ^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^ the `nomem` option is not meaningful for global-scoped inline assembly -error: expected one of `)`, `att_syntax`, or `raw`, found `readonly` +error: the `readonly` option cannot be used with `global_asm!` --> $DIR/bad-options.rs:37:25 | LL | global_asm!("", options(readonly)); - | ^^^^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^^^^ the `readonly` option is not meaningful for global-scoped inline assembly -error: expected one of `)`, `att_syntax`, or `raw`, found `noreturn` +error: the `noreturn` option cannot be used with `global_asm!` --> $DIR/bad-options.rs:39:25 | LL | global_asm!("", options(noreturn)); - | ^^^^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^^^^ the `noreturn` option is not meaningful for global-scoped inline assembly -error: expected one of `)`, `att_syntax`, or `raw`, found `pure` +error: the `pure` option cannot be used with `global_asm!` --> $DIR/bad-options.rs:41:25 | LL | global_asm!("", options(pure)); - | ^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^ the `pure` option is not meaningful for global-scoped inline assembly -error: expected one of `)`, `att_syntax`, or `raw`, found `nostack` +error: the `nostack` option cannot be used with `global_asm!` --> $DIR/bad-options.rs:43:25 | LL | global_asm!("", options(nostack)); - | ^^^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^^^ the `nostack` option is not meaningful for global-scoped inline assembly -error: expected one of `)`, `att_syntax`, or `raw`, found `preserves_flags` +error: the `preserves_flags` option cannot be used with `global_asm!` --> $DIR/bad-options.rs:45:25 | LL | global_asm!("", options(preserves_flags)); - | ^^^^^^^^^^^^^^^ expected one of `)`, `att_syntax`, or `raw` + | ^^^^^^^^^^^^^^^ the `preserves_flags` option is not meaningful for global-scoped inline assembly error: invalid ABI for `clobber_abi` --> $DIR/bad-options.rs:24:18 diff --git a/tests/ui/associated-types/associated-types-outlives.stderr b/tests/ui/associated-types/associated-types-outlives.stderr index c97af672c33..1164869bf19 100644 --- a/tests/ui/associated-types/associated-types-outlives.stderr +++ b/tests/ui/associated-types/associated-types-outlives.stderr @@ -11,10 +11,14 @@ LL | drop(x); LL | return f(y); | - borrow later used here | -help: consider cloning the value if the performance cost is acceptable +help: if `T` implemented `Clone`, you could clone the value + --> $DIR/associated-types-outlives.rs:17:21 | -LL | 's: loop { y = denormalise(&x).clone(); break } - | ++++++++ +LL | pub fn free_and_use<T: for<'a> Foo<'a>, + | ^ consider constraining this type parameter with `Clone` +... +LL | 's: loop { y = denormalise(&x); break } + | -- you could clone this value error: aborting due to 1 previous error diff --git a/tests/ui/async-await/for-await-consumes-iter.rs b/tests/ui/async-await/for-await-consumes-iter.rs index 38dfe46c814..7ea88c14cb5 100644 --- a/tests/ui/async-await/for-await-consumes-iter.rs +++ b/tests/ui/async-await/for-await-consumes-iter.rs @@ -1,5 +1,5 @@ //@ edition: 2021 -#![feature(async_iterator, async_iter_from_iter, const_waker, async_for_loop, noop_waker)] +#![feature(async_iterator, async_iter_from_iter, async_for_loop, noop_waker)] use std::future::Future; diff --git a/tests/ui/async-await/for-await-passthrough.rs b/tests/ui/async-await/for-await-passthrough.rs index e09e843332e..b4fba6b2f76 100644 --- a/tests/ui/async-await/for-await-passthrough.rs +++ b/tests/ui/async-await/for-await-passthrough.rs @@ -1,7 +1,7 @@ //@ run-pass //@ edition: 2024 //@ compile-flags: -Zunstable-options -#![feature(async_iterator, async_iter_from_iter, const_waker, async_for_loop, noop_waker, +#![feature(async_iterator, async_iter_from_iter, async_for_loop, noop_waker, gen_blocks)] async gen fn async_iter() -> i32 { diff --git a/tests/ui/async-await/for-await.rs b/tests/ui/async-await/for-await.rs index acd9f01640a..b4af38a82b3 100644 --- a/tests/ui/async-await/for-await.rs +++ b/tests/ui/async-await/for-await.rs @@ -1,6 +1,6 @@ //@ run-pass //@ edition: 2021 -#![feature(async_iterator, async_iter_from_iter, const_waker, async_for_loop, noop_waker)] +#![feature(async_iterator, async_iter_from_iter, async_for_loop, noop_waker)] use std::future::Future; diff --git a/tests/ui/feature-gates/feature-gate-is_sorted.rs b/tests/ui/feature-gates/feature-gate-is_sorted.rs deleted file mode 100644 index 359ed835bcb..00000000000 --- a/tests/ui/feature-gates/feature-gate-is_sorted.rs +++ /dev/null @@ -1,13 +0,0 @@ -fn main() { - // Assert `Iterator` methods are unstable - assert!([1, 2, 2, 9].iter().is_sorted()); - //~^ ERROR: use of unstable library feature 'is_sorted': new API - assert!(![-2i32, -1, 0, 3].iter().is_sorted_by_key(|n| n.abs())); - //~^ ERROR: use of unstable library feature 'is_sorted': new API - - // Assert `[T]` methods are unstable - assert!([1, 2, 2, 9].is_sorted()); - //~^ ERROR: use of unstable library feature 'is_sorted': new API - assert!(![-2i32, -1, 0, 3].is_sorted_by_key(|n| n.abs())); - //~^ ERROR: use of unstable library feature 'is_sorted': new API -} diff --git a/tests/ui/feature-gates/feature-gate-is_sorted.stderr b/tests/ui/feature-gates/feature-gate-is_sorted.stderr deleted file mode 100644 index f3e87659b02..00000000000 --- a/tests/ui/feature-gates/feature-gate-is_sorted.stderr +++ /dev/null @@ -1,43 +0,0 @@ -error[E0658]: use of unstable library feature 'is_sorted': new API - --> $DIR/feature-gate-is_sorted.rs:3:33 - | -LL | assert!([1, 2, 2, 9].iter().is_sorted()); - | ^^^^^^^^^ - | - = note: see issue #53485 <https://github.com/rust-lang/rust/issues/53485> for more information - = help: add `#![feature(is_sorted)]` 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[E0658]: use of unstable library feature 'is_sorted': new API - --> $DIR/feature-gate-is_sorted.rs:5:39 - | -LL | assert!(![-2i32, -1, 0, 3].iter().is_sorted_by_key(|n| n.abs())); - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #53485 <https://github.com/rust-lang/rust/issues/53485> for more information - = help: add `#![feature(is_sorted)]` 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[E0658]: use of unstable library feature 'is_sorted': new API - --> $DIR/feature-gate-is_sorted.rs:9:26 - | -LL | assert!([1, 2, 2, 9].is_sorted()); - | ^^^^^^^^^ - | - = note: see issue #53485 <https://github.com/rust-lang/rust/issues/53485> for more information - = help: add `#![feature(is_sorted)]` 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[E0658]: use of unstable library feature 'is_sorted': new API - --> $DIR/feature-gate-is_sorted.rs:11:32 - | -LL | assert!(![-2i32, -1, 0, 3].is_sorted_by_key(|n| n.abs())); - | ^^^^^^^^^^^^^^^^ - | - = note: see issue #53485 <https://github.com/rust-lang/rust/issues/53485> for more information - = help: add `#![feature(is_sorted)]` 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 4 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/macros/macro-missing-fragment.stderr b/tests/ui/macros/macro-missing-fragment.e2015.stderr index abe4d4cd68a..a068dc5c054 100644 --- a/tests/ui/macros/macro-missing-fragment.stderr +++ b/tests/ui/macros/macro-missing-fragment.e2015.stderr @@ -1,11 +1,11 @@ error: missing fragment specifier - --> $DIR/macro-missing-fragment.rs:4:20 + --> $DIR/macro-missing-fragment.rs:9:20 | LL | ( $( any_token $field_rust_type )* ) => {}; | ^^^^^^^^^^^^^^^^ warning: missing fragment specifier - --> $DIR/macro-missing-fragment.rs:4:20 + --> $DIR/macro-missing-fragment.rs:9:20 | LL | ( $( any_token $field_rust_type )* ) => {}; | ^^^^^^^^^^^^^^^^ @@ -13,13 +13,13 @@ LL | ( $( any_token $field_rust_type )* ) => {}; = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107> note: the lint level is defined here - --> $DIR/macro-missing-fragment.rs:1:9 + --> $DIR/macro-missing-fragment.rs:6:9 | LL | #![warn(missing_fragment_specifier)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: missing fragment specifier - --> $DIR/macro-missing-fragment.rs:12:7 + --> $DIR/macro-missing-fragment.rs:19:7 | LL | ( $name ) => {}; | ^^^^^ @@ -28,7 +28,7 @@ LL | ( $name ) => {}; = note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107> warning: missing fragment specifier - --> $DIR/macro-missing-fragment.rs:18:7 + --> $DIR/macro-missing-fragment.rs:26:7 | LL | ( $name ) => {}; | ^^^^^ @@ -40,7 +40,7 @@ error: aborting due to 1 previous error; 3 warnings emitted Future incompatibility report: Future breakage diagnostic: warning: missing fragment specifier - --> $DIR/macro-missing-fragment.rs:4:20 + --> $DIR/macro-missing-fragment.rs:9:20 | LL | ( $( any_token $field_rust_type )* ) => {}; | ^^^^^^^^^^^^^^^^ @@ -48,14 +48,14 @@ LL | ( $( any_token $field_rust_type )* ) => {}; = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107> note: the lint level is defined here - --> $DIR/macro-missing-fragment.rs:1:9 + --> $DIR/macro-missing-fragment.rs:6:9 | LL | #![warn(missing_fragment_specifier)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ Future breakage diagnostic: warning: missing fragment specifier - --> $DIR/macro-missing-fragment.rs:12:7 + --> $DIR/macro-missing-fragment.rs:19:7 | LL | ( $name ) => {}; | ^^^^^ @@ -63,14 +63,14 @@ LL | ( $name ) => {}; = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107> note: the lint level is defined here - --> $DIR/macro-missing-fragment.rs:1:9 + --> $DIR/macro-missing-fragment.rs:6:9 | LL | #![warn(missing_fragment_specifier)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ Future breakage diagnostic: warning: missing fragment specifier - --> $DIR/macro-missing-fragment.rs:18:7 + --> $DIR/macro-missing-fragment.rs:26:7 | LL | ( $name ) => {}; | ^^^^^ @@ -78,7 +78,7 @@ LL | ( $name ) => {}; = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #40107 <https://github.com/rust-lang/rust/issues/40107> note: the lint level is defined here - --> $DIR/macro-missing-fragment.rs:1:9 + --> $DIR/macro-missing-fragment.rs:6:9 | LL | #![warn(missing_fragment_specifier)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/macros/macro-missing-fragment.e2024.stderr b/tests/ui/macros/macro-missing-fragment.e2024.stderr new file mode 100644 index 00000000000..3afa069c170 --- /dev/null +++ b/tests/ui/macros/macro-missing-fragment.e2024.stderr @@ -0,0 +1,47 @@ +error: missing fragment specifier + --> $DIR/macro-missing-fragment.rs:9:20 + | +LL | ( $( any_token $field_rust_type )* ) => {}; + | ^^^^^^^^^^^^^^^^ + | + = note: fragment specifiers must be specified in the 2024 edition + = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `expr_2021`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis` +help: try adding a specifier here + | +LL | ( $( any_token $field_rust_type:spec )* ) => {}; + | +++++ + +error: missing fragment specifier + --> $DIR/macro-missing-fragment.rs:19:7 + | +LL | ( $name ) => {}; + | ^^^^^ + | + = note: fragment specifiers must be specified in the 2024 edition + = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `expr_2021`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis` +help: try adding a specifier here + | +LL | ( $name:spec ) => {}; + | +++++ + +error: missing fragment specifier + --> $DIR/macro-missing-fragment.rs:26:7 + | +LL | ( $name ) => {}; + | ^^^^^ + | + = note: fragment specifiers must be specified in the 2024 edition + = help: valid fragment specifiers are `ident`, `block`, `stmt`, `expr`, `expr_2021`, `pat`, `ty`, `lifetime`, `literal`, `path`, `meta`, `tt`, `item` and `vis` +help: try adding a specifier here + | +LL | ( $name:spec ) => {}; + | +++++ + +error: missing fragment specifier + --> $DIR/macro-missing-fragment.rs:9:20 + | +LL | ( $( any_token $field_rust_type )* ) => {}; + | ^^^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors + diff --git a/tests/ui/macros/macro-missing-fragment.rs b/tests/ui/macros/macro-missing-fragment.rs index 210c85ebbf2..b7da87ae610 100644 --- a/tests/ui/macros/macro-missing-fragment.rs +++ b/tests/ui/macros/macro-missing-fragment.rs @@ -1,23 +1,32 @@ +//@ revisions: e2015 e2024 +//@[e2015] edition:2015 +//@[e2024] edition:2024 +//@[e2024] compile-flags: -Zunstable-options + #![warn(missing_fragment_specifier)] macro_rules! used_arm { ( $( any_token $field_rust_type )* ) => {}; - //~^ ERROR missing fragment - //~| WARN missing fragment - //~| WARN this was previously accepted + //[e2015]~^ ERROR missing fragment + //[e2015]~| WARN missing fragment + //[e2015]~| WARN this was previously accepted + //[e2024]~^^^^ ERROR missing fragment + //[e2024]~| ERROR missing fragment } macro_rules! used_macro_unused_arm { () => {}; ( $name ) => {}; - //~^ WARN missing fragment - //~| WARN this was previously accepted + //[e2015]~^ WARN missing fragment + //[e2015]~| WARN this was previously accepted + //[e2024]~^^^ ERROR missing fragment } macro_rules! unused_macro { ( $name ) => {}; - //~^ WARN missing fragment - //~| WARN this was previously accepted + //[e2015]~^ WARN missing fragment + //[e2015]~| WARN this was previously accepted + //[e2024]~^^^ ERROR missing fragment } fn main() { diff --git a/tests/ui/rfcs/rfc-2091-track-caller/error-with-naked.rs b/tests/ui/rfcs/rfc-2091-track-caller/error-with-naked.rs index 6eaa7d4d9bc..0c73b9abf35 100644 --- a/tests/ui/rfcs/rfc-2091-track-caller/error-with-naked.rs +++ b/tests/ui/rfcs/rfc-2091-track-caller/error-with-naked.rs @@ -3,7 +3,7 @@ use std::arch::asm; -#[track_caller] //~ ERROR cannot use `#[track_caller]` with `#[naked]` +#[track_caller] //~ ERROR [E0736] //~^ ERROR `#[track_caller]` requires Rust ABI #[naked] extern "C" fn f() { @@ -15,7 +15,7 @@ extern "C" fn f() { struct S; impl S { - #[track_caller] //~ ERROR cannot use `#[track_caller]` with `#[naked]` + #[track_caller] //~ ERROR [E0736] //~^ ERROR `#[track_caller]` requires Rust ABI #[naked] extern "C" fn g() { diff --git a/tests/ui/rfcs/rfc-2091-track-caller/error-with-naked.stderr b/tests/ui/rfcs/rfc-2091-track-caller/error-with-naked.stderr index 04c5c649d7f..0625ed1183b 100644 --- a/tests/ui/rfcs/rfc-2091-track-caller/error-with-naked.stderr +++ b/tests/ui/rfcs/rfc-2091-track-caller/error-with-naked.stderr @@ -1,14 +1,20 @@ -error[E0736]: cannot use `#[track_caller]` with `#[naked]` +error[E0736]: attribute incompatible with `#[naked]` --> $DIR/error-with-naked.rs:6:1 | LL | #[track_caller] - | ^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ the `track_caller` attribute is incompatible with `#[naked]` +LL | +LL | #[naked] + | -------- function marked with `#[naked]` here -error[E0736]: cannot use `#[track_caller]` with `#[naked]` +error[E0736]: attribute incompatible with `#[naked]` --> $DIR/error-with-naked.rs:18:5 | LL | #[track_caller] - | ^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ the `track_caller` attribute is incompatible with `#[naked]` +LL | +LL | #[naked] + | -------- function marked with `#[naked]` here error[E0737]: `#[track_caller]` requires Rust ABI --> $DIR/error-with-naked.rs:6:1 diff --git a/tests/ui/rust-2024/prelude-migration/future-poll-already-future.rs b/tests/ui/rust-2024/prelude-migration/future-poll-already-future.rs new file mode 100644 index 00000000000..7bf5118c340 --- /dev/null +++ b/tests/ui/rust-2024/prelude-migration/future-poll-already-future.rs @@ -0,0 +1,17 @@ +//@ revisions: e2021 e2024 +//@[e2021] edition: 2021 +//@[e2024] edition: 2024 +//@[e2024] compile-flags: -Zunstable-options +//@ check-pass + +#![deny(rust_2024_prelude_collisions)] + +use std::future::Future; + +fn main() { + core::pin::pin!(async {}).poll(&mut context()); +} + +fn context() -> core::task::Context<'static> { + loop {} +} diff --git a/tests/ui/rust-2024/prelude-migration/future-poll-async-block.e2021.fixed b/tests/ui/rust-2024/prelude-migration/future-poll-async-block.e2021.fixed new file mode 100644 index 00000000000..44850c8c45b --- /dev/null +++ b/tests/ui/rust-2024/prelude-migration/future-poll-async-block.e2021.fixed @@ -0,0 +1,21 @@ +//@ revisions: e2021 e2024 +//@[e2021] edition: 2021 +//@[e2021] run-rustfix +//@[e2024] edition: 2024 +//@[e2024] compile-flags: -Zunstable-options +//@[e2024] check-pass + +#![deny(rust_2024_prelude_collisions)] +trait Meow { + fn poll(&self, _ctx: &mut core::task::Context<'_>) {} +} +impl<T> Meow for T {} +fn main() { + Meow::poll(&core::pin::pin!(async {}), &mut context()); + //[e2021]~^ ERROR trait method `poll` will become ambiguous in Rust 2024 + //[e2021]~| WARN this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! +} + +fn context() -> core::task::Context<'static> { + loop {} +} diff --git a/tests/ui/rust-2024/prelude-migration/future-poll-async-block.e2021.stderr b/tests/ui/rust-2024/prelude-migration/future-poll-async-block.e2021.stderr new file mode 100644 index 00000000000..496b3197c34 --- /dev/null +++ b/tests/ui/rust-2024/prelude-migration/future-poll-async-block.e2021.stderr @@ -0,0 +1,16 @@ +error: trait method `poll` will become ambiguous in Rust 2024 + --> $DIR/future-poll-async-block.rs:14:5 + | +LL | core::pin::pin!(async {}).poll(&mut context()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `Meow::poll(&core::pin::pin!(async {}), &mut context())` + | + = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! + = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/prelude.html> +note: the lint level is defined here + --> $DIR/future-poll-async-block.rs:8:9 + | +LL | #![deny(rust_2024_prelude_collisions)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/rust-2024/prelude-migration/future-poll-async-block.rs b/tests/ui/rust-2024/prelude-migration/future-poll-async-block.rs new file mode 100644 index 00000000000..614e4c786c5 --- /dev/null +++ b/tests/ui/rust-2024/prelude-migration/future-poll-async-block.rs @@ -0,0 +1,21 @@ +//@ revisions: e2021 e2024 +//@[e2021] edition: 2021 +//@[e2021] run-rustfix +//@[e2024] edition: 2024 +//@[e2024] compile-flags: -Zunstable-options +//@[e2024] check-pass + +#![deny(rust_2024_prelude_collisions)] +trait Meow { + fn poll(&self, _ctx: &mut core::task::Context<'_>) {} +} +impl<T> Meow for T {} +fn main() { + core::pin::pin!(async {}).poll(&mut context()); + //[e2021]~^ ERROR trait method `poll` will become ambiguous in Rust 2024 + //[e2021]~| WARN this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! +} + +fn context() -> core::task::Context<'static> { + loop {} +} diff --git a/tests/ui/rust-2024/prelude-migration/future-poll-not-future-pinned.e2021.fixed b/tests/ui/rust-2024/prelude-migration/future-poll-not-future-pinned.e2021.fixed new file mode 100644 index 00000000000..c96d1dcecc2 --- /dev/null +++ b/tests/ui/rust-2024/prelude-migration/future-poll-not-future-pinned.e2021.fixed @@ -0,0 +1,21 @@ +//@ revisions: e2021 e2024 +//@[e2021] edition: 2021 +//@[e2021] run-rustfix +//@[e2024] edition: 2024 +//@[e2024] compile-flags: -Zunstable-options +//@[e2024] check-pass + +#![deny(rust_2024_prelude_collisions)] +trait Meow { + fn poll(&self) {} +} +impl<T> Meow for T {} +fn main() { + // This is a deliberate false positive. + // While `()` does not implement `Future` and can therefore not be ambiguous, we + // do not check that in the lint, as that introduces additional complexities. + // Just checking whether the self type is `Pin<&mut _>` is enough. + Meow::poll(&core::pin::pin!(())); + //[e2021]~^ ERROR trait method `poll` will become ambiguous in Rust 2024 + //[e2021]~| WARN this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! +} diff --git a/tests/ui/rust-2024/prelude-migration/future-poll-not-future-pinned.e2021.stderr b/tests/ui/rust-2024/prelude-migration/future-poll-not-future-pinned.e2021.stderr new file mode 100644 index 00000000000..020a00ccdec --- /dev/null +++ b/tests/ui/rust-2024/prelude-migration/future-poll-not-future-pinned.e2021.stderr @@ -0,0 +1,16 @@ +error: trait method `poll` will become ambiguous in Rust 2024 + --> $DIR/future-poll-not-future-pinned.rs:18:5 + | +LL | core::pin::pin!(()).poll(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `Meow::poll(&core::pin::pin!(()))` + | + = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! + = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/prelude.html> +note: the lint level is defined here + --> $DIR/future-poll-not-future-pinned.rs:8:9 + | +LL | #![deny(rust_2024_prelude_collisions)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/rust-2024/prelude-migration/future-poll-not-future-pinned.rs b/tests/ui/rust-2024/prelude-migration/future-poll-not-future-pinned.rs new file mode 100644 index 00000000000..21b170a5f1d --- /dev/null +++ b/tests/ui/rust-2024/prelude-migration/future-poll-not-future-pinned.rs @@ -0,0 +1,21 @@ +//@ revisions: e2021 e2024 +//@[e2021] edition: 2021 +//@[e2021] run-rustfix +//@[e2024] edition: 2024 +//@[e2024] compile-flags: -Zunstable-options +//@[e2024] check-pass + +#![deny(rust_2024_prelude_collisions)] +trait Meow { + fn poll(&self) {} +} +impl<T> Meow for T {} +fn main() { + // This is a deliberate false positive. + // While `()` does not implement `Future` and can therefore not be ambiguous, we + // do not check that in the lint, as that introduces additional complexities. + // Just checking whether the self type is `Pin<&mut _>` is enough. + core::pin::pin!(()).poll(); + //[e2021]~^ ERROR trait method `poll` will become ambiguous in Rust 2024 + //[e2021]~| WARN this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! +} diff --git a/tests/ui/rust-2024/prelude-migration/future-poll-not-future.rs b/tests/ui/rust-2024/prelude-migration/future-poll-not-future.rs new file mode 100644 index 00000000000..899b69ebfc2 --- /dev/null +++ b/tests/ui/rust-2024/prelude-migration/future-poll-not-future.rs @@ -0,0 +1,15 @@ +//@ revisions: e2021 e2024 +//@[e2021] edition: 2021 +//@[e2024] edition: 2024 +//@[e2024] compile-flags: -Zunstable-options +//@ check-pass + +#![deny(rust_2024_prelude_collisions)] +trait Meow { + fn poll(&self) {} +} +impl<T> Meow for T {} +fn main() { + // As the self type here is not `Pin<&mut _>`, the lint does not fire. + ().poll(); +} diff --git a/tests/ui/rust-2024/prelude-migration/in_2024_compatibility.rs b/tests/ui/rust-2024/prelude-migration/in_2024_compatibility.rs new file mode 100644 index 00000000000..b6a5d278720 --- /dev/null +++ b/tests/ui/rust-2024/prelude-migration/in_2024_compatibility.rs @@ -0,0 +1,17 @@ +//@ edition: 2021 + +#![deny(rust_2024_compatibility)] + +trait Meow { + fn poll(&self, _ctx: &mut core::task::Context<'_>) {} +} +impl<T> Meow for T {} +fn main() { + core::pin::pin!(async {}).poll(&mut context()); + //~^ ERROR trait method `poll` will become ambiguous in Rust 2024 + //~| WARN this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! +} + +fn context() -> core::task::Context<'static> { + loop {} +} diff --git a/tests/ui/rust-2024/prelude-migration/in_2024_compatibility.stderr b/tests/ui/rust-2024/prelude-migration/in_2024_compatibility.stderr new file mode 100644 index 00000000000..5865029d65d --- /dev/null +++ b/tests/ui/rust-2024/prelude-migration/in_2024_compatibility.stderr @@ -0,0 +1,17 @@ +error: trait method `poll` will become ambiguous in Rust 2024 + --> $DIR/in_2024_compatibility.rs:10:5 + | +LL | core::pin::pin!(async {}).poll(&mut context()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `Meow::poll(&core::pin::pin!(async {}), &mut context())` + | + = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! + = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/prelude.html> +note: the lint level is defined here + --> $DIR/in_2024_compatibility.rs:3:9 + | +LL | #![deny(rust_2024_compatibility)] + | ^^^^^^^^^^^^^^^^^^^^^^^ + = note: `#[deny(rust_2024_prelude_collisions)]` implied by `#[deny(rust_2024_compatibility)]` + +error: aborting due to 1 previous error + diff --git a/tests/ui/rust-2024/prelude-migration/into-future-adt.e2021.fixed b/tests/ui/rust-2024/prelude-migration/into-future-adt.e2021.fixed new file mode 100644 index 00000000000..0b0873eb238 --- /dev/null +++ b/tests/ui/rust-2024/prelude-migration/into-future-adt.e2021.fixed @@ -0,0 +1,29 @@ +//@ revisions: e2021 e2024 +//@[e2021] edition: 2021 +//@[e2021] run-rustfix +//@[e2024] edition: 2024 +//@[e2024] compile-flags: -Zunstable-options +//@[e2024] check-pass + +#![deny(rust_2024_prelude_collisions)] +trait Meow { + fn into_future(&self) {} +} +impl Meow for Cat {} + +struct Cat; + +impl core::future::IntoFuture for Cat { + type Output = (); + type IntoFuture = core::future::Ready<()>; + + fn into_future(self) -> Self::IntoFuture { + core::future::ready(()) + } +} + +fn main() { + Meow::into_future(&Cat); + //[e2021]~^ ERROR trait method `into_future` will become ambiguous in Rust 2024 + //[e2021]~| WARN this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! +} diff --git a/tests/ui/rust-2024/prelude-migration/into-future-adt.e2021.stderr b/tests/ui/rust-2024/prelude-migration/into-future-adt.e2021.stderr new file mode 100644 index 00000000000..b74e80e2a4a --- /dev/null +++ b/tests/ui/rust-2024/prelude-migration/into-future-adt.e2021.stderr @@ -0,0 +1,16 @@ +error: trait method `into_future` will become ambiguous in Rust 2024 + --> $DIR/into-future-adt.rs:26:5 + | +LL | Cat.into_future(); + | ^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `Meow::into_future(&Cat)` + | + = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! + = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/prelude.html> +note: the lint level is defined here + --> $DIR/into-future-adt.rs:8:9 + | +LL | #![deny(rust_2024_prelude_collisions)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/rust-2024/prelude-migration/into-future-adt.rs b/tests/ui/rust-2024/prelude-migration/into-future-adt.rs new file mode 100644 index 00000000000..0db70930bc7 --- /dev/null +++ b/tests/ui/rust-2024/prelude-migration/into-future-adt.rs @@ -0,0 +1,29 @@ +//@ revisions: e2021 e2024 +//@[e2021] edition: 2021 +//@[e2021] run-rustfix +//@[e2024] edition: 2024 +//@[e2024] compile-flags: -Zunstable-options +//@[e2024] check-pass + +#![deny(rust_2024_prelude_collisions)] +trait Meow { + fn into_future(&self) {} +} +impl Meow for Cat {} + +struct Cat; + +impl core::future::IntoFuture for Cat { + type Output = (); + type IntoFuture = core::future::Ready<()>; + + fn into_future(self) -> Self::IntoFuture { + core::future::ready(()) + } +} + +fn main() { + Cat.into_future(); + //[e2021]~^ ERROR trait method `into_future` will become ambiguous in Rust 2024 + //[e2021]~| WARN this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! +} diff --git a/tests/ui/rust-2024/prelude-migration/into-future-already-into-future.rs b/tests/ui/rust-2024/prelude-migration/into-future-already-into-future.rs new file mode 100644 index 00000000000..6bc2ea31705 --- /dev/null +++ b/tests/ui/rust-2024/prelude-migration/into-future-already-into-future.rs @@ -0,0 +1,24 @@ +//@ revisions: e2021 e2024 +//@[e2021] edition: 2021 +//@[e2024] edition: 2024 +//@[e2024] compile-flags: -Zunstable-options +//@ check-pass + +#![deny(rust_2024_prelude_collisions)] + +use core::future::IntoFuture; + +struct Cat; + +impl IntoFuture for Cat { + type Output = (); + type IntoFuture = core::future::Ready<()>; + + fn into_future(self) -> Self::IntoFuture { + core::future::ready(()) + } +} + +fn main() { + let _ = Cat.into_future(); +} diff --git a/tests/ui/rust-2024/prelude-migration/into-future-not-into-future.e2021.fixed b/tests/ui/rust-2024/prelude-migration/into-future-not-into-future.e2021.fixed new file mode 100644 index 00000000000..a798014d93d --- /dev/null +++ b/tests/ui/rust-2024/prelude-migration/into-future-not-into-future.e2021.fixed @@ -0,0 +1,23 @@ +//@ revisions: e2021 e2024 +//@[e2021] edition: 2021 +//@[e2021] run-rustfix +//@[e2024] edition: 2024 +//@[e2024] compile-flags: -Zunstable-options +//@[e2024] check-pass + +#![deny(rust_2024_prelude_collisions)] +trait Meow { + fn into_future(&self) {} +} +impl Meow for Cat {} + +struct Cat; + +fn main() { + // This is a false positive, but it should be rare enough to not matter, and checking whether + // it implements the trait can have other nontrivial consequences, so it was decided to accept + // this. + Meow::into_future(&Cat); + //[e2021]~^ ERROR trait method `into_future` will become ambiguous in Rust 2024 + //[e2021]~| WARN this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! +} diff --git a/tests/ui/rust-2024/prelude-migration/into-future-not-into-future.e2021.stderr b/tests/ui/rust-2024/prelude-migration/into-future-not-into-future.e2021.stderr new file mode 100644 index 00000000000..6ea4580ca72 --- /dev/null +++ b/tests/ui/rust-2024/prelude-migration/into-future-not-into-future.e2021.stderr @@ -0,0 +1,16 @@ +error: trait method `into_future` will become ambiguous in Rust 2024 + --> $DIR/into-future-not-into-future.rs:20:5 + | +LL | Cat.into_future(); + | ^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `Meow::into_future(&Cat)` + | + = warning: this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! + = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/prelude.html> +note: the lint level is defined here + --> $DIR/into-future-not-into-future.rs:8:9 + | +LL | #![deny(rust_2024_prelude_collisions)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/rust-2024/prelude-migration/into-future-not-into-future.rs b/tests/ui/rust-2024/prelude-migration/into-future-not-into-future.rs new file mode 100644 index 00000000000..23e81cfe6b4 --- /dev/null +++ b/tests/ui/rust-2024/prelude-migration/into-future-not-into-future.rs @@ -0,0 +1,23 @@ +//@ revisions: e2021 e2024 +//@[e2021] edition: 2021 +//@[e2021] run-rustfix +//@[e2024] edition: 2024 +//@[e2024] compile-flags: -Zunstable-options +//@[e2024] check-pass + +#![deny(rust_2024_prelude_collisions)] +trait Meow { + fn into_future(&self) {} +} +impl Meow for Cat {} + +struct Cat; + +fn main() { + // This is a false positive, but it should be rare enough to not matter, and checking whether + // it implements the trait can have other nontrivial consequences, so it was decided to accept + // this. + Cat.into_future(); + //[e2021]~^ ERROR trait method `into_future` will become ambiguous in Rust 2024 + //[e2021]~| WARN this is accepted in the current edition (Rust 2021) but is a hard error in Rust 2024! +} diff --git a/tests/ui/variance/variance-issue-20533.stderr b/tests/ui/variance/variance-issue-20533.stderr index 03cada07a9e..0a810b7222e 100644 --- a/tests/ui/variance/variance-issue-20533.stderr +++ b/tests/ui/variance/variance-issue-20533.stderr @@ -73,10 +73,14 @@ LL | drop(a); LL | drop(x); | - borrow later used here | -help: consider cloning the value if the performance cost is acceptable +note: if `AffineU32` implemented `Clone`, you could clone the value + --> $DIR/variance-issue-20533.rs:26:1 | -LL | let x = bat(&a).clone(); - | ++++++++ +LL | struct AffineU32(u32); + | ^^^^^^^^^^^^^^^^ consider implementing `Clone` for this type +... +LL | let x = bat(&a); + | -- you could clone this value error[E0505]: cannot move out of `a` because it is borrowed --> $DIR/variance-issue-20533.rs:59:14 |
