diff options
Diffstat (limited to 'tests')
233 files changed, 9150 insertions, 575 deletions
diff --git a/tests/assembly/closure-inherit-target-feature.rs b/tests/assembly/closure-inherit-target-feature.rs new file mode 100644 index 00000000000..65728a15516 --- /dev/null +++ b/tests/assembly/closure-inherit-target-feature.rs @@ -0,0 +1,58 @@ +// only-x86_64 +// assembly-output: emit-asm +// make sure the feature is not enabled at compile-time +// compile-flags: -C opt-level=3 -C target-feature=-sse4.1 -C llvm-args=-x86-asm-syntax=intel + +#![feature(target_feature_11)] +#![crate_type = "rlib"] + +use std::arch::x86_64::{__m128, _mm_blend_ps}; + +#[no_mangle] +pub unsafe fn sse41_blend_nofeature(x: __m128, y: __m128) -> __m128 { + let f = { + // check that _mm_blend_ps is not being inlined into the closure + // CHECK-LABEL: {{sse41_blend_nofeature.*closure.*:}} + // CHECK-NOT: blendps + // CHECK: {{call .*_mm_blend_ps.*}} + // CHECK-NOT: blendps + // CHECK: ret + #[inline(never)] |x, y| _mm_blend_ps(x, y, 0b0101) + }; + f(x, y) +} + +#[target_feature(enable = "sse4.1")] +pub fn sse41_blend_noinline(x: __m128, y: __m128) -> __m128 { + let f = { + // check that _mm_blend_ps is being inlined into the closure + // CHECK-LABEL: {{sse41_blend_noinline.*closure.*:}} + // CHECK-NOT: _mm_blend_ps + // CHECK: blendps + // CHECK-NOT: _mm_blend_ps + // CHECK: ret + #[inline(never)] |x, y| unsafe { + _mm_blend_ps(x, y, 0b0101) + } + }; + f(x, y) +} + +#[no_mangle] +#[target_feature(enable = "sse4.1")] +pub fn sse41_blend_doinline(x: __m128, y: __m128) -> __m128 { + // check that the closure and _mm_blend_ps are being inlined into the function + // CHECK-LABEL: sse41_blend_doinline: + // CHECK-NOT: {{sse41_blend_doinline.*closure.*}} + // CHECK-NOT: _mm_blend_ps + // CHECK: blendps + // CHECK-NOT: {{sse41_blend_doinline.*closure.*}} + // CHECK-NOT: _mm_blend_ps + // CHECK: ret + let f = { + #[inline] |x, y| unsafe { + _mm_blend_ps(x, y, 0b0101) + } + }; + f(x, y) +} diff --git a/tests/coverage-map/unreachable.cov-map b/tests/coverage-map/unreachable.cov-map new file mode 100644 index 00000000000..495419820c1 --- /dev/null +++ b/tests/coverage-map/unreachable.cov-map @@ -0,0 +1,24 @@ +Function name: unreachable::UNREACHABLE_CLOSURE::{closure#0} +Raw bytes (9): 0x[01, 01, 00, 01, 01, 0f, 27, 00, 49] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 15, 39) to (start + 0, 73) + +Function name: unreachable::unreachable_function +Raw bytes (9): 0x[01, 01, 00, 01, 01, 11, 01, 02, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 17, 1) to (start + 2, 2) + +Function name: unreachable::unreachable_intrinsic +Raw bytes (9): 0x[01, 01, 00, 01, 01, 16, 01, 02, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 22, 1) to (start + 2, 2) + diff --git a/tests/coverage-map/unreachable.rs b/tests/coverage-map/unreachable.rs new file mode 100644 index 00000000000..6385bfa160d --- /dev/null +++ b/tests/coverage-map/unreachable.rs @@ -0,0 +1,37 @@ +#![feature(core_intrinsics)] +#![feature(coverage_attribute)] +// compile-flags: --edition=2021 + +// <https://github.com/rust-lang/rust/issues/116171> +// If we instrument a function for coverage, but all of its counter-increment +// statements are removed by MIR optimizations, LLVM will think it isn't +// instrumented and it will disappear from coverage maps and coverage reports. +// Most MIR opts won't cause this because they tend not to remove statements +// from bb0, but `UnreachablePropagation` can do so if it sees that bb0 ends +// with `TerminatorKind::Unreachable`. + +use std::hint::{black_box, unreachable_unchecked}; + +static UNREACHABLE_CLOSURE: fn() = || unsafe { unreachable_unchecked() }; + +fn unreachable_function() { + unsafe { unreachable_unchecked() } +} + +// Use an intrinsic to more reliably trigger unreachable-propagation. +fn unreachable_intrinsic() { + unsafe { std::intrinsics::unreachable() } +} + +#[coverage(off)] +fn main() { + if black_box(false) { + UNREACHABLE_CLOSURE(); + } + if black_box(false) { + unreachable_function(); + } + if black_box(false) { + unreachable_intrinsic(); + } +} diff --git a/tests/incremental/change_crate_dep_kind.rs b/tests/incremental/change_crate_dep_kind.rs index f518266016e..b9f74340472 100644 --- a/tests/incremental/change_crate_dep_kind.rs +++ b/tests/incremental/change_crate_dep_kind.rs @@ -5,6 +5,7 @@ // needs-unwind // revisions:cfail1 cfail2 // compile-flags: -Z query-dep-graph -Cpanic=unwind +// needs-unwind // build-pass (FIXME(62277): could be check-pass?) #![feature(panic_unwind)] diff --git a/tests/incremental/hashes/function_interfaces.rs b/tests/incremental/hashes/function_interfaces.rs index 182ca7d926c..23b81705f9a 100644 --- a/tests/incremental/hashes/function_interfaces.rs +++ b/tests/incremental/hashes/function_interfaces.rs @@ -302,7 +302,7 @@ pub fn return_impl_trait() -> i32 { } #[cfg(not(any(cfail1,cfail4)))] -#[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, typeck, fn_sig, optimized_mir")] +#[rustc_clean(cfg = "cfail2", except = "hir_owner, hir_owner_nodes, typeck, fn_sig")] #[rustc_clean(cfg = "cfail3")] #[rustc_clean(cfg = "cfail5", except = "hir_owner, hir_owner_nodes, typeck, fn_sig, optimized_mir")] #[rustc_clean(cfg = "cfail6")] diff --git a/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir b/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir index 4d3baee7f11..15330b13cc2 100644 --- a/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir +++ b/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir @@ -2,13 +2,16 @@ /* generator_layout = GeneratorLayout { field_tys: { _0: GeneratorSavedTy { - ty: Alias( - Opaque, - AliasTy { - args: [ - ], - def_id: DefId(0:7 ~ async_await[ccf8]::a::{opaque#0}), - }, + ty: Generator( + DefId(0:4 ~ async_await[ccf8]::a::{closure#0}), + [ + std::future::ResumeTy, + (), + (), + GeneratorWitness(DefId(0:4 ~ async_await[ccf8]::a::{closure#0}), []), + (), + ], + Static, ), source_info: SourceInfo { span: $DIR/async_await.rs:15:9: 15:14 (#8), @@ -17,13 +20,16 @@ ignore_for_traits: false, }, _1: GeneratorSavedTy { - ty: Alias( - Opaque, - AliasTy { - args: [ - ], - def_id: DefId(0:7 ~ async_await[ccf8]::a::{opaque#0}), - }, + ty: Generator( + DefId(0:4 ~ async_await[ccf8]::a::{closure#0}), + [ + std::future::ResumeTy, + (), + (), + GeneratorWitness(DefId(0:4 ~ async_await[ccf8]::a::{closure#0}), []), + (), + ], + Static, ), source_info: SourceInfo { span: $DIR/async_await.rs:16:9: 16:14 (#10), @@ -49,15 +55,15 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>, debug _task_context => _38; let mut _0: std::task::Poll<()>; let _3: (); - let mut _4: impl std::future::Future<Output = ()>; - let mut _5: impl std::future::Future<Output = ()>; - let mut _6: impl std::future::Future<Output = ()>; + let mut _4: {async fn body@$DIR/async_await.rs:11:14: 11:16}; + let mut _5: {async fn body@$DIR/async_await.rs:11:14: 11:16}; + let mut _6: {async fn body@$DIR/async_await.rs:11:14: 11:16}; let mut _7: (); let _8: (); let mut _9: std::task::Poll<()>; - let mut _10: std::pin::Pin<&mut impl std::future::Future<Output = ()>>; - let mut _11: &mut impl std::future::Future<Output = ()>; - let mut _12: &mut impl std::future::Future<Output = ()>; + let mut _10: std::pin::Pin<&mut {async fn body@$DIR/async_await.rs:11:14: 11:16}>; + let mut _11: &mut {async fn body@$DIR/async_await.rs:11:14: 11:16}; + let mut _12: &mut {async fn body@$DIR/async_await.rs:11:14: 11:16}; let mut _13: &mut std::task::Context<'_>; let mut _14: &mut std::task::Context<'_>; let mut _15: &mut std::task::Context<'_>; @@ -65,14 +71,14 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>, let mut _18: !; let mut _19: &mut std::task::Context<'_>; let mut _20: (); - let mut _21: impl std::future::Future<Output = ()>; - let mut _22: impl std::future::Future<Output = ()>; - let mut _23: impl std::future::Future<Output = ()>; + let mut _21: {async fn body@$DIR/async_await.rs:11:14: 11:16}; + let mut _22: {async fn body@$DIR/async_await.rs:11:14: 11:16}; + let mut _23: {async fn body@$DIR/async_await.rs:11:14: 11:16}; let _24: (); let mut _25: std::task::Poll<()>; - let mut _26: std::pin::Pin<&mut impl std::future::Future<Output = ()>>; - let mut _27: &mut impl std::future::Future<Output = ()>; - let mut _28: &mut impl std::future::Future<Output = ()>; + let mut _26: std::pin::Pin<&mut {async fn body@$DIR/async_await.rs:11:14: 11:16}>; + let mut _27: &mut {async fn body@$DIR/async_await.rs:11:14: 11:16}; + let mut _28: &mut {async fn body@$DIR/async_await.rs:11:14: 11:16}; let mut _29: &mut std::task::Context<'_>; let mut _30: &mut std::task::Context<'_>; let mut _31: &mut std::task::Context<'_>; @@ -84,7 +90,7 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>, let mut _38: &mut std::task::Context<'_>; let mut _39: u32; scope 1 { - debug __awaitee => (((*(_1.0: &mut {async fn body@$DIR/async_await.rs:14:18: 17:2})) as variant#3).0: impl std::future::Future<Output = ()>); + debug __awaitee => (((*(_1.0: &mut {async fn body@$DIR/async_await.rs:14:18: 17:2})) as variant#3).0: {async fn body@$DIR/async_await.rs:11:14: 11:16}); let _17: (); scope 2 { } @@ -93,7 +99,7 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>, } } scope 4 { - debug __awaitee => (((*(_1.0: &mut {async fn body@$DIR/async_await.rs:14:18: 17:2})) as variant#4).0: impl std::future::Future<Output = ()>); + debug __awaitee => (((*(_1.0: &mut {async fn body@$DIR/async_await.rs:14:18: 17:2})) as variant#4).0: {async fn body@$DIR/async_await.rs:11:14: 11:16}); let _33: (); scope 5 { } @@ -116,13 +122,13 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>, } bb2: { - _4 = <impl Future<Output = ()> as IntoFuture>::into_future(move _5) -> [return: bb3, unwind unreachable]; + _4 = <{async fn body@$DIR/async_await.rs:11:14: 11:16} as IntoFuture>::into_future(move _5) -> [return: bb3, unwind unreachable]; } bb3: { StorageDead(_5); nop; - (((*(_1.0: &mut {async fn body@$DIR/async_await.rs:14:18: 17:2})) as variant#3).0: impl std::future::Future<Output = ()>) = move _4; + (((*(_1.0: &mut {async fn body@$DIR/async_await.rs:14:18: 17:2})) as variant#3).0: {async fn body@$DIR/async_await.rs:11:14: 11:16}) = move _4; goto -> bb4; } @@ -132,9 +138,9 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>, StorageLive(_10); StorageLive(_11); StorageLive(_12); - _12 = &mut (((*(_1.0: &mut {async fn body@$DIR/async_await.rs:14:18: 17:2})) as variant#3).0: impl std::future::Future<Output = ()>); + _12 = &mut (((*(_1.0: &mut {async fn body@$DIR/async_await.rs:14:18: 17:2})) as variant#3).0: {async fn body@$DIR/async_await.rs:11:14: 11:16}); _11 = &mut (*_12); - _10 = Pin::<&mut impl Future<Output = ()>>::new_unchecked(move _11) -> [return: bb5, unwind unreachable]; + _10 = Pin::<&mut {async fn body@$DIR/async_await.rs:11:14: 11:16}>::new_unchecked(move _11) -> [return: bb5, unwind unreachable]; } bb5: { @@ -150,7 +156,7 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>, bb6: { _13 = &mut (*_14); StorageDead(_15); - _9 = <impl Future<Output = ()> as Future>::poll(move _10, move _13) -> [return: bb7, unwind unreachable]; + _9 = <{async fn body@$DIR/async_await.rs:11:14: 11:16} as Future>::poll(move _10, move _13) -> [return: bb7, unwind unreachable]; } bb7: { @@ -187,7 +193,7 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>, StorageDead(_12); StorageDead(_9); StorageDead(_8); - drop((((*(_1.0: &mut {async fn body@$DIR/async_await.rs:14:18: 17:2})) as variant#3).0: impl std::future::Future<Output = ()>)) -> [return: bb12, unwind unreachable]; + drop((((*(_1.0: &mut {async fn body@$DIR/async_await.rs:14:18: 17:2})) as variant#3).0: {async fn body@$DIR/async_await.rs:11:14: 11:16})) -> [return: bb12, unwind unreachable]; } bb11: { @@ -212,13 +218,13 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>, } bb14: { - _21 = <impl Future<Output = ()> as IntoFuture>::into_future(move _22) -> [return: bb15, unwind unreachable]; + _21 = <{async fn body@$DIR/async_await.rs:11:14: 11:16} as IntoFuture>::into_future(move _22) -> [return: bb15, unwind unreachable]; } bb15: { StorageDead(_22); nop; - (((*(_1.0: &mut {async fn body@$DIR/async_await.rs:14:18: 17:2})) as variant#4).0: impl std::future::Future<Output = ()>) = move _21; + (((*(_1.0: &mut {async fn body@$DIR/async_await.rs:14:18: 17:2})) as variant#4).0: {async fn body@$DIR/async_await.rs:11:14: 11:16}) = move _21; goto -> bb16; } @@ -228,9 +234,9 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>, StorageLive(_26); StorageLive(_27); StorageLive(_28); - _28 = &mut (((*(_1.0: &mut {async fn body@$DIR/async_await.rs:14:18: 17:2})) as variant#4).0: impl std::future::Future<Output = ()>); + _28 = &mut (((*(_1.0: &mut {async fn body@$DIR/async_await.rs:14:18: 17:2})) as variant#4).0: {async fn body@$DIR/async_await.rs:11:14: 11:16}); _27 = &mut (*_28); - _26 = Pin::<&mut impl Future<Output = ()>>::new_unchecked(move _27) -> [return: bb17, unwind unreachable]; + _26 = Pin::<&mut {async fn body@$DIR/async_await.rs:11:14: 11:16}>::new_unchecked(move _27) -> [return: bb17, unwind unreachable]; } bb17: { @@ -246,7 +252,7 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>, bb18: { _29 = &mut (*_30); StorageDead(_31); - _25 = <impl Future<Output = ()> as Future>::poll(move _26, move _29) -> [return: bb19, unwind unreachable]; + _25 = <{async fn body@$DIR/async_await.rs:11:14: 11:16} as Future>::poll(move _26, move _29) -> [return: bb19, unwind unreachable]; } bb19: { @@ -279,7 +285,7 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>, StorageDead(_28); StorageDead(_25); StorageDead(_24); - drop((((*(_1.0: &mut {async fn body@$DIR/async_await.rs:14:18: 17:2})) as variant#4).0: impl std::future::Future<Output = ()>)) -> [return: bb23, unwind unreachable]; + drop((((*(_1.0: &mut {async fn body@$DIR/async_await.rs:14:18: 17:2})) as variant#4).0: {async fn body@$DIR/async_await.rs:11:14: 11:16})) -> [return: bb23, unwind unreachable]; } bb22: { diff --git a/tests/mir-opt/gvn.arithmetic.GVN.panic-abort.diff b/tests/mir-opt/gvn.arithmetic.GVN.panic-abort.diff new file mode 100644 index 00000000000..3f5173c189e --- /dev/null +++ b/tests/mir-opt/gvn.arithmetic.GVN.panic-abort.diff @@ -0,0 +1,342 @@ +- // MIR for `arithmetic` before GVN ++ // MIR for `arithmetic` after GVN + + fn arithmetic(_1: u64) -> () { + debug x => _1; + let mut _0: (); + let _2: (); + let mut _3: u64; + let mut _4: u64; + let _5: (); + let mut _6: u64; + let mut _7: u64; + let _8: (); + let mut _9: u64; + let mut _10: u64; + let _11: (); + let mut _12: u64; + let mut _13: u64; + let _14: (); + let mut _15: u64; + let mut _16: u64; + let mut _17: bool; + let _18: (); + let mut _19: u64; + let mut _20: u64; + let mut _21: bool; + let _22: (); + let mut _23: u64; + let mut _24: u64; + let mut _25: bool; + let _26: (); + let mut _27: u64; + let mut _28: u64; + let mut _29: bool; + let _30: (); + let mut _31: u64; + let mut _32: u64; + let mut _33: bool; + let _34: (); + let mut _35: u64; + let mut _36: u64; + let mut _37: bool; + let _38: (); + let mut _39: u64; + let mut _40: u64; + let mut _41: bool; + let _42: (); + let mut _43: u64; + let mut _44: u64; + let mut _45: bool; + let _46: (); + let mut _47: u64; + let mut _48: u64; + let _49: (); + let mut _50: u64; + let mut _51: u64; + let _52: (); + let mut _53: u64; + let mut _54: u64; + let _55: (); + let mut _56: u64; + let mut _57: u64; + let _58: (); + let mut _59: u64; + let mut _60: u64; + + bb0: { + StorageLive(_2); + StorageLive(_3); +- StorageLive(_4); +- _4 = _1; +- _3 = Add(move _4, const 0_u64); +- StorageDead(_4); ++ _3 = Add(_1, const 0_u64); + _2 = opaque::<u64>(move _3) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_3); + StorageDead(_2); + StorageLive(_5); + StorageLive(_6); +- StorageLive(_7); +- _7 = _1; +- _6 = Sub(move _7, const 0_u64); +- StorageDead(_7); ++ _6 = Sub(_1, const 0_u64); + _5 = opaque::<u64>(move _6) -> [return: bb2, unwind unreachable]; + } + + bb2: { + StorageDead(_6); + StorageDead(_5); + StorageLive(_8); + StorageLive(_9); +- StorageLive(_10); +- _10 = _1; +- _9 = Mul(move _10, const 0_u64); +- StorageDead(_10); ++ _9 = Mul(_1, const 0_u64); + _8 = opaque::<u64>(move _9) -> [return: bb3, unwind unreachable]; + } + + bb3: { + StorageDead(_9); + StorageDead(_8); + StorageLive(_11); + StorageLive(_12); +- StorageLive(_13); +- _13 = _1; +- _12 = Mul(move _13, const 1_u64); +- StorageDead(_13); ++ _12 = Mul(_1, const 1_u64); + _11 = opaque::<u64>(move _12) -> [return: bb4, unwind unreachable]; + } + + bb4: { + StorageDead(_12); + StorageDead(_11); + StorageLive(_14); + StorageLive(_15); +- StorageLive(_16); +- _16 = _1; + _17 = Eq(const 0_u64, const 0_u64); +- assert(!move _17, "attempt to divide `{}` by zero", _16) -> [success: bb5, unwind unreachable]; ++ assert(!_17, "attempt to divide `{}` by zero", _1) -> [success: bb5, unwind unreachable]; + } + + bb5: { +- _15 = Div(move _16, const 0_u64); +- StorageDead(_16); ++ _15 = Div(_1, const 0_u64); + _14 = opaque::<u64>(move _15) -> [return: bb6, unwind unreachable]; + } + + bb6: { + StorageDead(_15); + StorageDead(_14); + StorageLive(_18); + StorageLive(_19); +- StorageLive(_20); +- _20 = _1; + _21 = Eq(const 1_u64, const 0_u64); +- assert(!move _21, "attempt to divide `{}` by zero", _20) -> [success: bb7, unwind unreachable]; ++ assert(!_21, "attempt to divide `{}` by zero", _1) -> [success: bb7, unwind unreachable]; + } + + bb7: { +- _19 = Div(move _20, const 1_u64); +- StorageDead(_20); ++ _19 = Div(_1, const 1_u64); + _18 = opaque::<u64>(move _19) -> [return: bb8, unwind unreachable]; + } + + bb8: { + StorageDead(_19); + StorageDead(_18); + StorageLive(_22); + StorageLive(_23); +- StorageLive(_24); +- _24 = _1; +- _25 = Eq(_24, const 0_u64); +- assert(!move _25, "attempt to divide `{}` by zero", const 0_u64) -> [success: bb9, unwind unreachable]; ++ _25 = Eq(_1, const 0_u64); ++ assert(!_25, "attempt to divide `{}` by zero", const 0_u64) -> [success: bb9, unwind unreachable]; + } + + bb9: { +- _23 = Div(const 0_u64, move _24); +- StorageDead(_24); ++ _23 = Div(const 0_u64, _1); + _22 = opaque::<u64>(move _23) -> [return: bb10, unwind unreachable]; + } + + bb10: { + StorageDead(_23); + StorageDead(_22); + StorageLive(_26); + StorageLive(_27); +- StorageLive(_28); +- _28 = _1; +- _29 = Eq(_28, const 0_u64); +- assert(!move _29, "attempt to divide `{}` by zero", const 1_u64) -> [success: bb11, unwind unreachable]; ++ assert(!_25, "attempt to divide `{}` by zero", const 1_u64) -> [success: bb11, unwind unreachable]; + } + + bb11: { +- _27 = Div(const 1_u64, move _28); +- StorageDead(_28); ++ _27 = Div(const 1_u64, _1); + _26 = opaque::<u64>(move _27) -> [return: bb12, unwind unreachable]; + } + + bb12: { + StorageDead(_27); + StorageDead(_26); + StorageLive(_30); + StorageLive(_31); +- StorageLive(_32); +- _32 = _1; +- _33 = Eq(const 0_u64, const 0_u64); +- assert(!move _33, "attempt to calculate the remainder of `{}` with a divisor of zero", _32) -> [success: bb13, unwind unreachable]; ++ assert(!_17, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb13, unwind unreachable]; + } + + bb13: { +- _31 = Rem(move _32, const 0_u64); +- StorageDead(_32); ++ _31 = Rem(_1, const 0_u64); + _30 = opaque::<u64>(move _31) -> [return: bb14, unwind unreachable]; + } + + bb14: { + StorageDead(_31); + StorageDead(_30); + StorageLive(_34); + StorageLive(_35); +- StorageLive(_36); +- _36 = _1; +- _37 = Eq(const 1_u64, const 0_u64); +- assert(!move _37, "attempt to calculate the remainder of `{}` with a divisor of zero", _36) -> [success: bb15, unwind unreachable]; ++ assert(!_21, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb15, unwind unreachable]; + } + + bb15: { +- _35 = Rem(move _36, const 1_u64); +- StorageDead(_36); ++ _35 = Rem(_1, const 1_u64); + _34 = opaque::<u64>(move _35) -> [return: bb16, unwind unreachable]; + } + + bb16: { + StorageDead(_35); + StorageDead(_34); + StorageLive(_38); + StorageLive(_39); +- StorageLive(_40); +- _40 = _1; +- _41 = Eq(_40, const 0_u64); +- assert(!move _41, "attempt to calculate the remainder of `{}` with a divisor of zero", const 0_u64) -> [success: bb17, unwind unreachable]; ++ assert(!_25, "attempt to calculate the remainder of `{}` with a divisor of zero", const 0_u64) -> [success: bb17, unwind unreachable]; + } + + bb17: { +- _39 = Rem(const 0_u64, move _40); +- StorageDead(_40); ++ _39 = Rem(const 0_u64, _1); + _38 = opaque::<u64>(move _39) -> [return: bb18, unwind unreachable]; + } + + bb18: { + StorageDead(_39); + StorageDead(_38); + StorageLive(_42); + StorageLive(_43); +- StorageLive(_44); +- _44 = _1; +- _45 = Eq(_44, const 0_u64); +- assert(!move _45, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_u64) -> [success: bb19, unwind unreachable]; ++ assert(!_25, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_u64) -> [success: bb19, unwind unreachable]; + } + + bb19: { +- _43 = Rem(const 1_u64, move _44); +- StorageDead(_44); ++ _43 = Rem(const 1_u64, _1); + _42 = opaque::<u64>(move _43) -> [return: bb20, unwind unreachable]; + } + + bb20: { + StorageDead(_43); + StorageDead(_42); + StorageLive(_46); + StorageLive(_47); +- StorageLive(_48); +- _48 = _1; +- _47 = BitAnd(move _48, const 0_u64); +- StorageDead(_48); ++ _47 = BitAnd(_1, const 0_u64); + _46 = opaque::<u64>(move _47) -> [return: bb21, unwind unreachable]; + } + + bb21: { + StorageDead(_47); + StorageDead(_46); + StorageLive(_49); + StorageLive(_50); +- StorageLive(_51); +- _51 = _1; +- _50 = BitOr(move _51, const 0_u64); +- StorageDead(_51); ++ _50 = BitOr(_1, const 0_u64); + _49 = opaque::<u64>(move _50) -> [return: bb22, unwind unreachable]; + } + + bb22: { + StorageDead(_50); + StorageDead(_49); + StorageLive(_52); + StorageLive(_53); +- StorageLive(_54); +- _54 = _1; +- _53 = BitXor(move _54, const 0_u64); +- StorageDead(_54); ++ _53 = BitXor(_1, const 0_u64); + _52 = opaque::<u64>(move _53) -> [return: bb23, unwind unreachable]; + } + + bb23: { + StorageDead(_53); + StorageDead(_52); + StorageLive(_55); + StorageLive(_56); +- StorageLive(_57); +- _57 = _1; +- _56 = Shr(move _57, const 0_i32); +- StorageDead(_57); ++ _56 = Shr(_1, const 0_i32); + _55 = opaque::<u64>(move _56) -> [return: bb24, unwind unreachable]; + } + + bb24: { + StorageDead(_56); + StorageDead(_55); + StorageLive(_58); + StorageLive(_59); +- StorageLive(_60); +- _60 = _1; +- _59 = Shl(move _60, const 0_i32); +- StorageDead(_60); ++ _59 = Shl(_1, const 0_i32); + _58 = opaque::<u64>(move _59) -> [return: bb25, unwind unreachable]; + } + + bb25: { + StorageDead(_59); + StorageDead(_58); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/gvn.arithmetic.GVN.panic-unwind.diff b/tests/mir-opt/gvn.arithmetic.GVN.panic-unwind.diff new file mode 100644 index 00000000000..38da21d91d4 --- /dev/null +++ b/tests/mir-opt/gvn.arithmetic.GVN.panic-unwind.diff @@ -0,0 +1,342 @@ +- // MIR for `arithmetic` before GVN ++ // MIR for `arithmetic` after GVN + + fn arithmetic(_1: u64) -> () { + debug x => _1; + let mut _0: (); + let _2: (); + let mut _3: u64; + let mut _4: u64; + let _5: (); + let mut _6: u64; + let mut _7: u64; + let _8: (); + let mut _9: u64; + let mut _10: u64; + let _11: (); + let mut _12: u64; + let mut _13: u64; + let _14: (); + let mut _15: u64; + let mut _16: u64; + let mut _17: bool; + let _18: (); + let mut _19: u64; + let mut _20: u64; + let mut _21: bool; + let _22: (); + let mut _23: u64; + let mut _24: u64; + let mut _25: bool; + let _26: (); + let mut _27: u64; + let mut _28: u64; + let mut _29: bool; + let _30: (); + let mut _31: u64; + let mut _32: u64; + let mut _33: bool; + let _34: (); + let mut _35: u64; + let mut _36: u64; + let mut _37: bool; + let _38: (); + let mut _39: u64; + let mut _40: u64; + let mut _41: bool; + let _42: (); + let mut _43: u64; + let mut _44: u64; + let mut _45: bool; + let _46: (); + let mut _47: u64; + let mut _48: u64; + let _49: (); + let mut _50: u64; + let mut _51: u64; + let _52: (); + let mut _53: u64; + let mut _54: u64; + let _55: (); + let mut _56: u64; + let mut _57: u64; + let _58: (); + let mut _59: u64; + let mut _60: u64; + + bb0: { + StorageLive(_2); + StorageLive(_3); +- StorageLive(_4); +- _4 = _1; +- _3 = Add(move _4, const 0_u64); +- StorageDead(_4); ++ _3 = Add(_1, const 0_u64); + _2 = opaque::<u64>(move _3) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_3); + StorageDead(_2); + StorageLive(_5); + StorageLive(_6); +- StorageLive(_7); +- _7 = _1; +- _6 = Sub(move _7, const 0_u64); +- StorageDead(_7); ++ _6 = Sub(_1, const 0_u64); + _5 = opaque::<u64>(move _6) -> [return: bb2, unwind continue]; + } + + bb2: { + StorageDead(_6); + StorageDead(_5); + StorageLive(_8); + StorageLive(_9); +- StorageLive(_10); +- _10 = _1; +- _9 = Mul(move _10, const 0_u64); +- StorageDead(_10); ++ _9 = Mul(_1, const 0_u64); + _8 = opaque::<u64>(move _9) -> [return: bb3, unwind continue]; + } + + bb3: { + StorageDead(_9); + StorageDead(_8); + StorageLive(_11); + StorageLive(_12); +- StorageLive(_13); +- _13 = _1; +- _12 = Mul(move _13, const 1_u64); +- StorageDead(_13); ++ _12 = Mul(_1, const 1_u64); + _11 = opaque::<u64>(move _12) -> [return: bb4, unwind continue]; + } + + bb4: { + StorageDead(_12); + StorageDead(_11); + StorageLive(_14); + StorageLive(_15); +- StorageLive(_16); +- _16 = _1; + _17 = Eq(const 0_u64, const 0_u64); +- assert(!move _17, "attempt to divide `{}` by zero", _16) -> [success: bb5, unwind continue]; ++ assert(!_17, "attempt to divide `{}` by zero", _1) -> [success: bb5, unwind continue]; + } + + bb5: { +- _15 = Div(move _16, const 0_u64); +- StorageDead(_16); ++ _15 = Div(_1, const 0_u64); + _14 = opaque::<u64>(move _15) -> [return: bb6, unwind continue]; + } + + bb6: { + StorageDead(_15); + StorageDead(_14); + StorageLive(_18); + StorageLive(_19); +- StorageLive(_20); +- _20 = _1; + _21 = Eq(const 1_u64, const 0_u64); +- assert(!move _21, "attempt to divide `{}` by zero", _20) -> [success: bb7, unwind continue]; ++ assert(!_21, "attempt to divide `{}` by zero", _1) -> [success: bb7, unwind continue]; + } + + bb7: { +- _19 = Div(move _20, const 1_u64); +- StorageDead(_20); ++ _19 = Div(_1, const 1_u64); + _18 = opaque::<u64>(move _19) -> [return: bb8, unwind continue]; + } + + bb8: { + StorageDead(_19); + StorageDead(_18); + StorageLive(_22); + StorageLive(_23); +- StorageLive(_24); +- _24 = _1; +- _25 = Eq(_24, const 0_u64); +- assert(!move _25, "attempt to divide `{}` by zero", const 0_u64) -> [success: bb9, unwind continue]; ++ _25 = Eq(_1, const 0_u64); ++ assert(!_25, "attempt to divide `{}` by zero", const 0_u64) -> [success: bb9, unwind continue]; + } + + bb9: { +- _23 = Div(const 0_u64, move _24); +- StorageDead(_24); ++ _23 = Div(const 0_u64, _1); + _22 = opaque::<u64>(move _23) -> [return: bb10, unwind continue]; + } + + bb10: { + StorageDead(_23); + StorageDead(_22); + StorageLive(_26); + StorageLive(_27); +- StorageLive(_28); +- _28 = _1; +- _29 = Eq(_28, const 0_u64); +- assert(!move _29, "attempt to divide `{}` by zero", const 1_u64) -> [success: bb11, unwind continue]; ++ assert(!_25, "attempt to divide `{}` by zero", const 1_u64) -> [success: bb11, unwind continue]; + } + + bb11: { +- _27 = Div(const 1_u64, move _28); +- StorageDead(_28); ++ _27 = Div(const 1_u64, _1); + _26 = opaque::<u64>(move _27) -> [return: bb12, unwind continue]; + } + + bb12: { + StorageDead(_27); + StorageDead(_26); + StorageLive(_30); + StorageLive(_31); +- StorageLive(_32); +- _32 = _1; +- _33 = Eq(const 0_u64, const 0_u64); +- assert(!move _33, "attempt to calculate the remainder of `{}` with a divisor of zero", _32) -> [success: bb13, unwind continue]; ++ assert(!_17, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb13, unwind continue]; + } + + bb13: { +- _31 = Rem(move _32, const 0_u64); +- StorageDead(_32); ++ _31 = Rem(_1, const 0_u64); + _30 = opaque::<u64>(move _31) -> [return: bb14, unwind continue]; + } + + bb14: { + StorageDead(_31); + StorageDead(_30); + StorageLive(_34); + StorageLive(_35); +- StorageLive(_36); +- _36 = _1; +- _37 = Eq(const 1_u64, const 0_u64); +- assert(!move _37, "attempt to calculate the remainder of `{}` with a divisor of zero", _36) -> [success: bb15, unwind continue]; ++ assert(!_21, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb15, unwind continue]; + } + + bb15: { +- _35 = Rem(move _36, const 1_u64); +- StorageDead(_36); ++ _35 = Rem(_1, const 1_u64); + _34 = opaque::<u64>(move _35) -> [return: bb16, unwind continue]; + } + + bb16: { + StorageDead(_35); + StorageDead(_34); + StorageLive(_38); + StorageLive(_39); +- StorageLive(_40); +- _40 = _1; +- _41 = Eq(_40, const 0_u64); +- assert(!move _41, "attempt to calculate the remainder of `{}` with a divisor of zero", const 0_u64) -> [success: bb17, unwind continue]; ++ assert(!_25, "attempt to calculate the remainder of `{}` with a divisor of zero", const 0_u64) -> [success: bb17, unwind continue]; + } + + bb17: { +- _39 = Rem(const 0_u64, move _40); +- StorageDead(_40); ++ _39 = Rem(const 0_u64, _1); + _38 = opaque::<u64>(move _39) -> [return: bb18, unwind continue]; + } + + bb18: { + StorageDead(_39); + StorageDead(_38); + StorageLive(_42); + StorageLive(_43); +- StorageLive(_44); +- _44 = _1; +- _45 = Eq(_44, const 0_u64); +- assert(!move _45, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_u64) -> [success: bb19, unwind continue]; ++ assert(!_25, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_u64) -> [success: bb19, unwind continue]; + } + + bb19: { +- _43 = Rem(const 1_u64, move _44); +- StorageDead(_44); ++ _43 = Rem(const 1_u64, _1); + _42 = opaque::<u64>(move _43) -> [return: bb20, unwind continue]; + } + + bb20: { + StorageDead(_43); + StorageDead(_42); + StorageLive(_46); + StorageLive(_47); +- StorageLive(_48); +- _48 = _1; +- _47 = BitAnd(move _48, const 0_u64); +- StorageDead(_48); ++ _47 = BitAnd(_1, const 0_u64); + _46 = opaque::<u64>(move _47) -> [return: bb21, unwind continue]; + } + + bb21: { + StorageDead(_47); + StorageDead(_46); + StorageLive(_49); + StorageLive(_50); +- StorageLive(_51); +- _51 = _1; +- _50 = BitOr(move _51, const 0_u64); +- StorageDead(_51); ++ _50 = BitOr(_1, const 0_u64); + _49 = opaque::<u64>(move _50) -> [return: bb22, unwind continue]; + } + + bb22: { + StorageDead(_50); + StorageDead(_49); + StorageLive(_52); + StorageLive(_53); +- StorageLive(_54); +- _54 = _1; +- _53 = BitXor(move _54, const 0_u64); +- StorageDead(_54); ++ _53 = BitXor(_1, const 0_u64); + _52 = opaque::<u64>(move _53) -> [return: bb23, unwind continue]; + } + + bb23: { + StorageDead(_53); + StorageDead(_52); + StorageLive(_55); + StorageLive(_56); +- StorageLive(_57); +- _57 = _1; +- _56 = Shr(move _57, const 0_i32); +- StorageDead(_57); ++ _56 = Shr(_1, const 0_i32); + _55 = opaque::<u64>(move _56) -> [return: bb24, unwind continue]; + } + + bb24: { + StorageDead(_56); + StorageDead(_55); + StorageLive(_58); + StorageLive(_59); +- StorageLive(_60); +- _60 = _1; +- _59 = Shl(move _60, const 0_i32); +- StorageDead(_60); ++ _59 = Shl(_1, const 0_i32); + _58 = opaque::<u64>(move _59) -> [return: bb25, unwind continue]; + } + + bb25: { + StorageDead(_59); + StorageDead(_58); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-abort.diff b/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-abort.diff new file mode 100644 index 00000000000..0c342799e07 --- /dev/null +++ b/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-abort.diff @@ -0,0 +1,389 @@ +- // MIR for `arithmetic_checked` before GVN ++ // MIR for `arithmetic_checked` after GVN + + fn arithmetic_checked(_1: u64) -> () { + debug x => _1; + let mut _0: (); + let _2: (); + let mut _3: u64; + let mut _4: u64; + let mut _5: (u64, bool); + let _6: (); + let mut _7: u64; + let mut _8: u64; + let mut _9: (u64, bool); + let _10: (); + let mut _11: u64; + let mut _12: u64; + let mut _13: (u64, bool); + let _14: (); + let mut _15: u64; + let mut _16: u64; + let mut _17: (u64, bool); + let _18: (); + let mut _19: u64; + let mut _20: u64; + let mut _21: bool; + let _22: (); + let mut _23: u64; + let mut _24: u64; + let mut _25: bool; + let _26: (); + let mut _27: u64; + let mut _28: u64; + let mut _29: bool; + let _30: (); + let mut _31: u64; + let mut _32: u64; + let mut _33: bool; + let _34: (); + let mut _35: u64; + let mut _36: u64; + let mut _37: bool; + let _38: (); + let mut _39: u64; + let mut _40: u64; + let mut _41: bool; + let _42: (); + let mut _43: u64; + let mut _44: u64; + let mut _45: bool; + let _46: (); + let mut _47: u64; + let mut _48: u64; + let mut _49: bool; + let _50: (); + let mut _51: u64; + let mut _52: u64; + let _53: (); + let mut _54: u64; + let mut _55: u64; + let _56: (); + let mut _57: u64; + let mut _58: u64; + let _59: (); + let mut _60: u64; + let mut _61: u64; + let mut _62: u32; + let mut _63: bool; + let _64: (); + let mut _65: u64; + let mut _66: u64; + let mut _67: u32; + let mut _68: bool; + + bb0: { + StorageLive(_2); + StorageLive(_3); +- StorageLive(_4); +- _4 = _1; +- _5 = CheckedAdd(_4, const 0_u64); +- assert(!move (_5.1: bool), "attempt to compute `{} + {}`, which would overflow", move _4, const 0_u64) -> [success: bb1, unwind unreachable]; ++ _5 = CheckedAdd(_1, const 0_u64); ++ assert(!move (_5.1: bool), "attempt to compute `{} + {}`, which would overflow", _1, const 0_u64) -> [success: bb1, unwind unreachable]; + } + + bb1: { + _3 = move (_5.0: u64); +- StorageDead(_4); + _2 = opaque::<u64>(move _3) -> [return: bb2, unwind unreachable]; + } + + bb2: { + StorageDead(_3); + StorageDead(_2); + StorageLive(_6); + StorageLive(_7); +- StorageLive(_8); +- _8 = _1; +- _9 = CheckedSub(_8, const 0_u64); +- assert(!move (_9.1: bool), "attempt to compute `{} - {}`, which would overflow", move _8, const 0_u64) -> [success: bb3, unwind unreachable]; ++ _9 = CheckedSub(_1, const 0_u64); ++ assert(!move (_9.1: bool), "attempt to compute `{} - {}`, which would overflow", _1, const 0_u64) -> [success: bb3, unwind unreachable]; + } + + bb3: { + _7 = move (_9.0: u64); +- StorageDead(_8); + _6 = opaque::<u64>(move _7) -> [return: bb4, unwind unreachable]; + } + + bb4: { + StorageDead(_7); + StorageDead(_6); + StorageLive(_10); + StorageLive(_11); +- StorageLive(_12); +- _12 = _1; +- _13 = CheckedMul(_12, const 0_u64); +- assert(!move (_13.1: bool), "attempt to compute `{} * {}`, which would overflow", move _12, const 0_u64) -> [success: bb5, unwind unreachable]; ++ _13 = CheckedMul(_1, const 0_u64); ++ assert(!move (_13.1: bool), "attempt to compute `{} * {}`, which would overflow", _1, const 0_u64) -> [success: bb5, unwind unreachable]; + } + + bb5: { + _11 = move (_13.0: u64); +- StorageDead(_12); + _10 = opaque::<u64>(move _11) -> [return: bb6, unwind unreachable]; + } + + bb6: { + StorageDead(_11); + StorageDead(_10); + StorageLive(_14); + StorageLive(_15); +- StorageLive(_16); +- _16 = _1; +- _17 = CheckedMul(_16, const 1_u64); +- assert(!move (_17.1: bool), "attempt to compute `{} * {}`, which would overflow", move _16, const 1_u64) -> [success: bb7, unwind unreachable]; ++ _17 = CheckedMul(_1, const 1_u64); ++ assert(!move (_17.1: bool), "attempt to compute `{} * {}`, which would overflow", _1, const 1_u64) -> [success: bb7, unwind unreachable]; + } + + bb7: { + _15 = move (_17.0: u64); +- StorageDead(_16); + _14 = opaque::<u64>(move _15) -> [return: bb8, unwind unreachable]; + } + + bb8: { + StorageDead(_15); + StorageDead(_14); + StorageLive(_18); + StorageLive(_19); +- StorageLive(_20); +- _20 = _1; + _21 = Eq(const 0_u64, const 0_u64); +- assert(!move _21, "attempt to divide `{}` by zero", _20) -> [success: bb9, unwind unreachable]; ++ assert(!_21, "attempt to divide `{}` by zero", _1) -> [success: bb9, unwind unreachable]; + } + + bb9: { +- _19 = Div(move _20, const 0_u64); +- StorageDead(_20); ++ _19 = Div(_1, const 0_u64); + _18 = opaque::<u64>(move _19) -> [return: bb10, unwind unreachable]; + } + + bb10: { + StorageDead(_19); + StorageDead(_18); + StorageLive(_22); + StorageLive(_23); +- StorageLive(_24); +- _24 = _1; + _25 = Eq(const 1_u64, const 0_u64); +- assert(!move _25, "attempt to divide `{}` by zero", _24) -> [success: bb11, unwind unreachable]; ++ assert(!_25, "attempt to divide `{}` by zero", _1) -> [success: bb11, unwind unreachable]; + } + + bb11: { +- _23 = Div(move _24, const 1_u64); +- StorageDead(_24); ++ _23 = Div(_1, const 1_u64); + _22 = opaque::<u64>(move _23) -> [return: bb12, unwind unreachable]; + } + + bb12: { + StorageDead(_23); + StorageDead(_22); + StorageLive(_26); + StorageLive(_27); +- StorageLive(_28); +- _28 = _1; +- _29 = Eq(_28, const 0_u64); +- assert(!move _29, "attempt to divide `{}` by zero", const 0_u64) -> [success: bb13, unwind unreachable]; ++ _29 = Eq(_1, const 0_u64); ++ assert(!_29, "attempt to divide `{}` by zero", const 0_u64) -> [success: bb13, unwind unreachable]; + } + + bb13: { +- _27 = Div(const 0_u64, move _28); +- StorageDead(_28); ++ _27 = Div(const 0_u64, _1); + _26 = opaque::<u64>(move _27) -> [return: bb14, unwind unreachable]; + } + + bb14: { + StorageDead(_27); + StorageDead(_26); + StorageLive(_30); + StorageLive(_31); +- StorageLive(_32); +- _32 = _1; +- _33 = Eq(_32, const 0_u64); +- assert(!move _33, "attempt to divide `{}` by zero", const 1_u64) -> [success: bb15, unwind unreachable]; ++ assert(!_29, "attempt to divide `{}` by zero", const 1_u64) -> [success: bb15, unwind unreachable]; + } + + bb15: { +- _31 = Div(const 1_u64, move _32); +- StorageDead(_32); ++ _31 = Div(const 1_u64, _1); + _30 = opaque::<u64>(move _31) -> [return: bb16, unwind unreachable]; + } + + bb16: { + StorageDead(_31); + StorageDead(_30); + StorageLive(_34); + StorageLive(_35); +- StorageLive(_36); +- _36 = _1; +- _37 = Eq(const 0_u64, const 0_u64); +- assert(!move _37, "attempt to calculate the remainder of `{}` with a divisor of zero", _36) -> [success: bb17, unwind unreachable]; ++ assert(!_21, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb17, unwind unreachable]; + } + + bb17: { +- _35 = Rem(move _36, const 0_u64); +- StorageDead(_36); ++ _35 = Rem(_1, const 0_u64); + _34 = opaque::<u64>(move _35) -> [return: bb18, unwind unreachable]; + } + + bb18: { + StorageDead(_35); + StorageDead(_34); + StorageLive(_38); + StorageLive(_39); +- StorageLive(_40); +- _40 = _1; +- _41 = Eq(const 1_u64, const 0_u64); +- assert(!move _41, "attempt to calculate the remainder of `{}` with a divisor of zero", _40) -> [success: bb19, unwind unreachable]; ++ assert(!_25, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb19, unwind unreachable]; + } + + bb19: { +- _39 = Rem(move _40, const 1_u64); +- StorageDead(_40); ++ _39 = Rem(_1, const 1_u64); + _38 = opaque::<u64>(move _39) -> [return: bb20, unwind unreachable]; + } + + bb20: { + StorageDead(_39); + StorageDead(_38); + StorageLive(_42); + StorageLive(_43); +- StorageLive(_44); +- _44 = _1; +- _45 = Eq(_44, const 0_u64); +- assert(!move _45, "attempt to calculate the remainder of `{}` with a divisor of zero", const 0_u64) -> [success: bb21, unwind unreachable]; ++ assert(!_29, "attempt to calculate the remainder of `{}` with a divisor of zero", const 0_u64) -> [success: bb21, unwind unreachable]; + } + + bb21: { +- _43 = Rem(const 0_u64, move _44); +- StorageDead(_44); ++ _43 = Rem(const 0_u64, _1); + _42 = opaque::<u64>(move _43) -> [return: bb22, unwind unreachable]; + } + + bb22: { + StorageDead(_43); + StorageDead(_42); + StorageLive(_46); + StorageLive(_47); +- StorageLive(_48); +- _48 = _1; +- _49 = Eq(_48, const 0_u64); +- assert(!move _49, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_u64) -> [success: bb23, unwind unreachable]; ++ assert(!_29, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_u64) -> [success: bb23, unwind unreachable]; + } + + bb23: { +- _47 = Rem(const 1_u64, move _48); +- StorageDead(_48); ++ _47 = Rem(const 1_u64, _1); + _46 = opaque::<u64>(move _47) -> [return: bb24, unwind unreachable]; + } + + bb24: { + StorageDead(_47); + StorageDead(_46); + StorageLive(_50); + StorageLive(_51); +- StorageLive(_52); +- _52 = _1; +- _51 = BitAnd(move _52, const 0_u64); +- StorageDead(_52); ++ _51 = BitAnd(_1, const 0_u64); + _50 = opaque::<u64>(move _51) -> [return: bb25, unwind unreachable]; + } + + bb25: { + StorageDead(_51); + StorageDead(_50); + StorageLive(_53); + StorageLive(_54); +- StorageLive(_55); +- _55 = _1; +- _54 = BitOr(move _55, const 0_u64); +- StorageDead(_55); ++ _54 = BitOr(_1, const 0_u64); + _53 = opaque::<u64>(move _54) -> [return: bb26, unwind unreachable]; + } + + bb26: { + StorageDead(_54); + StorageDead(_53); + StorageLive(_56); + StorageLive(_57); +- StorageLive(_58); +- _58 = _1; +- _57 = BitXor(move _58, const 0_u64); +- StorageDead(_58); ++ _57 = BitXor(_1, const 0_u64); + _56 = opaque::<u64>(move _57) -> [return: bb27, unwind unreachable]; + } + + bb27: { + StorageDead(_57); + StorageDead(_56); + StorageLive(_59); + StorageLive(_60); +- StorageLive(_61); +- _61 = _1; + _62 = const 0_i32 as u32 (IntToInt); +- _63 = Lt(move _62, const 64_u32); +- assert(move _63, "attempt to shift right by `{}`, which would overflow", const 0_i32) -> [success: bb28, unwind unreachable]; ++ _63 = Lt(_62, const 64_u32); ++ assert(_63, "attempt to shift right by `{}`, which would overflow", const 0_i32) -> [success: bb28, unwind unreachable]; + } + + bb28: { +- _60 = Shr(move _61, const 0_i32); +- StorageDead(_61); ++ _60 = Shr(_1, const 0_i32); + _59 = opaque::<u64>(move _60) -> [return: bb29, unwind unreachable]; + } + + bb29: { + StorageDead(_60); + StorageDead(_59); + StorageLive(_64); + StorageLive(_65); +- StorageLive(_66); +- _66 = _1; +- _67 = const 0_i32 as u32 (IntToInt); +- _68 = Lt(move _67, const 64_u32); +- assert(move _68, "attempt to shift left by `{}`, which would overflow", const 0_i32) -> [success: bb30, unwind unreachable]; ++ assert(_63, "attempt to shift left by `{}`, which would overflow", const 0_i32) -> [success: bb30, unwind unreachable]; + } + + bb30: { +- _65 = Shl(move _66, const 0_i32); +- StorageDead(_66); ++ _65 = Shl(_1, const 0_i32); + _64 = opaque::<u64>(move _65) -> [return: bb31, unwind unreachable]; + } + + bb31: { + StorageDead(_65); + StorageDead(_64); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-unwind.diff b/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-unwind.diff new file mode 100644 index 00000000000..7813c29b962 --- /dev/null +++ b/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-unwind.diff @@ -0,0 +1,389 @@ +- // MIR for `arithmetic_checked` before GVN ++ // MIR for `arithmetic_checked` after GVN + + fn arithmetic_checked(_1: u64) -> () { + debug x => _1; + let mut _0: (); + let _2: (); + let mut _3: u64; + let mut _4: u64; + let mut _5: (u64, bool); + let _6: (); + let mut _7: u64; + let mut _8: u64; + let mut _9: (u64, bool); + let _10: (); + let mut _11: u64; + let mut _12: u64; + let mut _13: (u64, bool); + let _14: (); + let mut _15: u64; + let mut _16: u64; + let mut _17: (u64, bool); + let _18: (); + let mut _19: u64; + let mut _20: u64; + let mut _21: bool; + let _22: (); + let mut _23: u64; + let mut _24: u64; + let mut _25: bool; + let _26: (); + let mut _27: u64; + let mut _28: u64; + let mut _29: bool; + let _30: (); + let mut _31: u64; + let mut _32: u64; + let mut _33: bool; + let _34: (); + let mut _35: u64; + let mut _36: u64; + let mut _37: bool; + let _38: (); + let mut _39: u64; + let mut _40: u64; + let mut _41: bool; + let _42: (); + let mut _43: u64; + let mut _44: u64; + let mut _45: bool; + let _46: (); + let mut _47: u64; + let mut _48: u64; + let mut _49: bool; + let _50: (); + let mut _51: u64; + let mut _52: u64; + let _53: (); + let mut _54: u64; + let mut _55: u64; + let _56: (); + let mut _57: u64; + let mut _58: u64; + let _59: (); + let mut _60: u64; + let mut _61: u64; + let mut _62: u32; + let mut _63: bool; + let _64: (); + let mut _65: u64; + let mut _66: u64; + let mut _67: u32; + let mut _68: bool; + + bb0: { + StorageLive(_2); + StorageLive(_3); +- StorageLive(_4); +- _4 = _1; +- _5 = CheckedAdd(_4, const 0_u64); +- assert(!move (_5.1: bool), "attempt to compute `{} + {}`, which would overflow", move _4, const 0_u64) -> [success: bb1, unwind continue]; ++ _5 = CheckedAdd(_1, const 0_u64); ++ assert(!move (_5.1: bool), "attempt to compute `{} + {}`, which would overflow", _1, const 0_u64) -> [success: bb1, unwind continue]; + } + + bb1: { + _3 = move (_5.0: u64); +- StorageDead(_4); + _2 = opaque::<u64>(move _3) -> [return: bb2, unwind continue]; + } + + bb2: { + StorageDead(_3); + StorageDead(_2); + StorageLive(_6); + StorageLive(_7); +- StorageLive(_8); +- _8 = _1; +- _9 = CheckedSub(_8, const 0_u64); +- assert(!move (_9.1: bool), "attempt to compute `{} - {}`, which would overflow", move _8, const 0_u64) -> [success: bb3, unwind continue]; ++ _9 = CheckedSub(_1, const 0_u64); ++ assert(!move (_9.1: bool), "attempt to compute `{} - {}`, which would overflow", _1, const 0_u64) -> [success: bb3, unwind continue]; + } + + bb3: { + _7 = move (_9.0: u64); +- StorageDead(_8); + _6 = opaque::<u64>(move _7) -> [return: bb4, unwind continue]; + } + + bb4: { + StorageDead(_7); + StorageDead(_6); + StorageLive(_10); + StorageLive(_11); +- StorageLive(_12); +- _12 = _1; +- _13 = CheckedMul(_12, const 0_u64); +- assert(!move (_13.1: bool), "attempt to compute `{} * {}`, which would overflow", move _12, const 0_u64) -> [success: bb5, unwind continue]; ++ _13 = CheckedMul(_1, const 0_u64); ++ assert(!move (_13.1: bool), "attempt to compute `{} * {}`, which would overflow", _1, const 0_u64) -> [success: bb5, unwind continue]; + } + + bb5: { + _11 = move (_13.0: u64); +- StorageDead(_12); + _10 = opaque::<u64>(move _11) -> [return: bb6, unwind continue]; + } + + bb6: { + StorageDead(_11); + StorageDead(_10); + StorageLive(_14); + StorageLive(_15); +- StorageLive(_16); +- _16 = _1; +- _17 = CheckedMul(_16, const 1_u64); +- assert(!move (_17.1: bool), "attempt to compute `{} * {}`, which would overflow", move _16, const 1_u64) -> [success: bb7, unwind continue]; ++ _17 = CheckedMul(_1, const 1_u64); ++ assert(!move (_17.1: bool), "attempt to compute `{} * {}`, which would overflow", _1, const 1_u64) -> [success: bb7, unwind continue]; + } + + bb7: { + _15 = move (_17.0: u64); +- StorageDead(_16); + _14 = opaque::<u64>(move _15) -> [return: bb8, unwind continue]; + } + + bb8: { + StorageDead(_15); + StorageDead(_14); + StorageLive(_18); + StorageLive(_19); +- StorageLive(_20); +- _20 = _1; + _21 = Eq(const 0_u64, const 0_u64); +- assert(!move _21, "attempt to divide `{}` by zero", _20) -> [success: bb9, unwind continue]; ++ assert(!_21, "attempt to divide `{}` by zero", _1) -> [success: bb9, unwind continue]; + } + + bb9: { +- _19 = Div(move _20, const 0_u64); +- StorageDead(_20); ++ _19 = Div(_1, const 0_u64); + _18 = opaque::<u64>(move _19) -> [return: bb10, unwind continue]; + } + + bb10: { + StorageDead(_19); + StorageDead(_18); + StorageLive(_22); + StorageLive(_23); +- StorageLive(_24); +- _24 = _1; + _25 = Eq(const 1_u64, const 0_u64); +- assert(!move _25, "attempt to divide `{}` by zero", _24) -> [success: bb11, unwind continue]; ++ assert(!_25, "attempt to divide `{}` by zero", _1) -> [success: bb11, unwind continue]; + } + + bb11: { +- _23 = Div(move _24, const 1_u64); +- StorageDead(_24); ++ _23 = Div(_1, const 1_u64); + _22 = opaque::<u64>(move _23) -> [return: bb12, unwind continue]; + } + + bb12: { + StorageDead(_23); + StorageDead(_22); + StorageLive(_26); + StorageLive(_27); +- StorageLive(_28); +- _28 = _1; +- _29 = Eq(_28, const 0_u64); +- assert(!move _29, "attempt to divide `{}` by zero", const 0_u64) -> [success: bb13, unwind continue]; ++ _29 = Eq(_1, const 0_u64); ++ assert(!_29, "attempt to divide `{}` by zero", const 0_u64) -> [success: bb13, unwind continue]; + } + + bb13: { +- _27 = Div(const 0_u64, move _28); +- StorageDead(_28); ++ _27 = Div(const 0_u64, _1); + _26 = opaque::<u64>(move _27) -> [return: bb14, unwind continue]; + } + + bb14: { + StorageDead(_27); + StorageDead(_26); + StorageLive(_30); + StorageLive(_31); +- StorageLive(_32); +- _32 = _1; +- _33 = Eq(_32, const 0_u64); +- assert(!move _33, "attempt to divide `{}` by zero", const 1_u64) -> [success: bb15, unwind continue]; ++ assert(!_29, "attempt to divide `{}` by zero", const 1_u64) -> [success: bb15, unwind continue]; + } + + bb15: { +- _31 = Div(const 1_u64, move _32); +- StorageDead(_32); ++ _31 = Div(const 1_u64, _1); + _30 = opaque::<u64>(move _31) -> [return: bb16, unwind continue]; + } + + bb16: { + StorageDead(_31); + StorageDead(_30); + StorageLive(_34); + StorageLive(_35); +- StorageLive(_36); +- _36 = _1; +- _37 = Eq(const 0_u64, const 0_u64); +- assert(!move _37, "attempt to calculate the remainder of `{}` with a divisor of zero", _36) -> [success: bb17, unwind continue]; ++ assert(!_21, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb17, unwind continue]; + } + + bb17: { +- _35 = Rem(move _36, const 0_u64); +- StorageDead(_36); ++ _35 = Rem(_1, const 0_u64); + _34 = opaque::<u64>(move _35) -> [return: bb18, unwind continue]; + } + + bb18: { + StorageDead(_35); + StorageDead(_34); + StorageLive(_38); + StorageLive(_39); +- StorageLive(_40); +- _40 = _1; +- _41 = Eq(const 1_u64, const 0_u64); +- assert(!move _41, "attempt to calculate the remainder of `{}` with a divisor of zero", _40) -> [success: bb19, unwind continue]; ++ assert(!_25, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb19, unwind continue]; + } + + bb19: { +- _39 = Rem(move _40, const 1_u64); +- StorageDead(_40); ++ _39 = Rem(_1, const 1_u64); + _38 = opaque::<u64>(move _39) -> [return: bb20, unwind continue]; + } + + bb20: { + StorageDead(_39); + StorageDead(_38); + StorageLive(_42); + StorageLive(_43); +- StorageLive(_44); +- _44 = _1; +- _45 = Eq(_44, const 0_u64); +- assert(!move _45, "attempt to calculate the remainder of `{}` with a divisor of zero", const 0_u64) -> [success: bb21, unwind continue]; ++ assert(!_29, "attempt to calculate the remainder of `{}` with a divisor of zero", const 0_u64) -> [success: bb21, unwind continue]; + } + + bb21: { +- _43 = Rem(const 0_u64, move _44); +- StorageDead(_44); ++ _43 = Rem(const 0_u64, _1); + _42 = opaque::<u64>(move _43) -> [return: bb22, unwind continue]; + } + + bb22: { + StorageDead(_43); + StorageDead(_42); + StorageLive(_46); + StorageLive(_47); +- StorageLive(_48); +- _48 = _1; +- _49 = Eq(_48, const 0_u64); +- assert(!move _49, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_u64) -> [success: bb23, unwind continue]; ++ assert(!_29, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_u64) -> [success: bb23, unwind continue]; + } + + bb23: { +- _47 = Rem(const 1_u64, move _48); +- StorageDead(_48); ++ _47 = Rem(const 1_u64, _1); + _46 = opaque::<u64>(move _47) -> [return: bb24, unwind continue]; + } + + bb24: { + StorageDead(_47); + StorageDead(_46); + StorageLive(_50); + StorageLive(_51); +- StorageLive(_52); +- _52 = _1; +- _51 = BitAnd(move _52, const 0_u64); +- StorageDead(_52); ++ _51 = BitAnd(_1, const 0_u64); + _50 = opaque::<u64>(move _51) -> [return: bb25, unwind continue]; + } + + bb25: { + StorageDead(_51); + StorageDead(_50); + StorageLive(_53); + StorageLive(_54); +- StorageLive(_55); +- _55 = _1; +- _54 = BitOr(move _55, const 0_u64); +- StorageDead(_55); ++ _54 = BitOr(_1, const 0_u64); + _53 = opaque::<u64>(move _54) -> [return: bb26, unwind continue]; + } + + bb26: { + StorageDead(_54); + StorageDead(_53); + StorageLive(_56); + StorageLive(_57); +- StorageLive(_58); +- _58 = _1; +- _57 = BitXor(move _58, const 0_u64); +- StorageDead(_58); ++ _57 = BitXor(_1, const 0_u64); + _56 = opaque::<u64>(move _57) -> [return: bb27, unwind continue]; + } + + bb27: { + StorageDead(_57); + StorageDead(_56); + StorageLive(_59); + StorageLive(_60); +- StorageLive(_61); +- _61 = _1; + _62 = const 0_i32 as u32 (IntToInt); +- _63 = Lt(move _62, const 64_u32); +- assert(move _63, "attempt to shift right by `{}`, which would overflow", const 0_i32) -> [success: bb28, unwind continue]; ++ _63 = Lt(_62, const 64_u32); ++ assert(_63, "attempt to shift right by `{}`, which would overflow", const 0_i32) -> [success: bb28, unwind continue]; + } + + bb28: { +- _60 = Shr(move _61, const 0_i32); +- StorageDead(_61); ++ _60 = Shr(_1, const 0_i32); + _59 = opaque::<u64>(move _60) -> [return: bb29, unwind continue]; + } + + bb29: { + StorageDead(_60); + StorageDead(_59); + StorageLive(_64); + StorageLive(_65); +- StorageLive(_66); +- _66 = _1; +- _67 = const 0_i32 as u32 (IntToInt); +- _68 = Lt(move _67, const 64_u32); +- assert(move _68, "attempt to shift left by `{}`, which would overflow", const 0_i32) -> [success: bb30, unwind continue]; ++ assert(_63, "attempt to shift left by `{}`, which would overflow", const 0_i32) -> [success: bb30, unwind continue]; + } + + bb30: { +- _65 = Shl(move _66, const 0_i32); +- StorageDead(_66); ++ _65 = Shl(_1, const 0_i32); + _64 = opaque::<u64>(move _65) -> [return: bb31, unwind continue]; + } + + bb31: { + StorageDead(_65); + StorageDead(_64); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/gvn.arithmetic_float.GVN.panic-abort.diff b/tests/mir-opt/gvn.arithmetic_float.GVN.panic-abort.diff new file mode 100644 index 00000000000..7d5ac8353fe --- /dev/null +++ b/tests/mir-opt/gvn.arithmetic_float.GVN.panic-abort.diff @@ -0,0 +1,165 @@ +- // MIR for `arithmetic_float` before GVN ++ // MIR for `arithmetic_float` after GVN + + fn arithmetic_float(_1: f64) -> () { + debug x => _1; + let mut _0: (); + let _2: (); + let mut _3: f64; + let mut _4: f64; + let _5: (); + let mut _6: f64; + let mut _7: f64; + let _8: (); + let mut _9: f64; + let mut _10: f64; + let _11: (); + let mut _12: f64; + let mut _13: f64; + let _14: (); + let mut _15: f64; + let mut _16: f64; + let _17: (); + let mut _18: f64; + let mut _19: f64; + let _20: (); + let mut _21: f64; + let mut _22: f64; + let _23: (); + let mut _24: bool; + let mut _25: f64; + let mut _26: f64; + let _27: (); + let mut _28: bool; + let mut _29: f64; + let mut _30: f64; + + bb0: { + StorageLive(_2); + StorageLive(_3); +- StorageLive(_4); +- _4 = _1; +- _3 = Add(move _4, const 0f64); +- StorageDead(_4); ++ _3 = Add(_1, const 0f64); + _2 = opaque::<f64>(move _3) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_3); + StorageDead(_2); + StorageLive(_5); + StorageLive(_6); +- StorageLive(_7); +- _7 = _1; +- _6 = Sub(move _7, const 0f64); +- StorageDead(_7); ++ _6 = Sub(_1, const 0f64); + _5 = opaque::<f64>(move _6) -> [return: bb2, unwind unreachable]; + } + + bb2: { + StorageDead(_6); + StorageDead(_5); + StorageLive(_8); + StorageLive(_9); +- StorageLive(_10); +- _10 = _1; +- _9 = Mul(move _10, const 0f64); +- StorageDead(_10); ++ _9 = Mul(_1, const 0f64); + _8 = opaque::<f64>(move _9) -> [return: bb3, unwind unreachable]; + } + + bb3: { + StorageDead(_9); + StorageDead(_8); + StorageLive(_11); + StorageLive(_12); +- StorageLive(_13); +- _13 = _1; +- _12 = Div(move _13, const 0f64); +- StorageDead(_13); ++ _12 = Div(_1, const 0f64); + _11 = opaque::<f64>(move _12) -> [return: bb4, unwind unreachable]; + } + + bb4: { + StorageDead(_12); + StorageDead(_11); + StorageLive(_14); + StorageLive(_15); +- StorageLive(_16); +- _16 = _1; +- _15 = Div(const 0f64, move _16); +- StorageDead(_16); ++ _15 = Div(const 0f64, _1); + _14 = opaque::<f64>(move _15) -> [return: bb5, unwind unreachable]; + } + + bb5: { + StorageDead(_15); + StorageDead(_14); + StorageLive(_17); + StorageLive(_18); +- StorageLive(_19); +- _19 = _1; +- _18 = Rem(move _19, const 0f64); +- StorageDead(_19); ++ _18 = Rem(_1, const 0f64); + _17 = opaque::<f64>(move _18) -> [return: bb6, unwind unreachable]; + } + + bb6: { + StorageDead(_18); + StorageDead(_17); + StorageLive(_20); + StorageLive(_21); +- StorageLive(_22); +- _22 = _1; +- _21 = Rem(const 0f64, move _22); +- StorageDead(_22); ++ _21 = Rem(const 0f64, _1); + _20 = opaque::<f64>(move _21) -> [return: bb7, unwind unreachable]; + } + + bb7: { + StorageDead(_21); + StorageDead(_20); + StorageLive(_23); + StorageLive(_24); +- StorageLive(_25); +- _25 = _1; +- StorageLive(_26); +- _26 = _1; +- _24 = Eq(move _25, move _26); +- StorageDead(_26); +- StorageDead(_25); ++ _24 = Eq(_1, _1); + _23 = opaque::<bool>(move _24) -> [return: bb8, unwind unreachable]; + } + + bb8: { + StorageDead(_24); + StorageDead(_23); + StorageLive(_27); + StorageLive(_28); +- StorageLive(_29); +- _29 = _1; +- StorageLive(_30); +- _30 = _1; +- _28 = Ne(move _29, move _30); +- StorageDead(_30); +- StorageDead(_29); ++ _28 = Ne(_1, _1); + _27 = opaque::<bool>(move _28) -> [return: bb9, unwind unreachable]; + } + + bb9: { + StorageDead(_28); + StorageDead(_27); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/gvn.arithmetic_float.GVN.panic-unwind.diff b/tests/mir-opt/gvn.arithmetic_float.GVN.panic-unwind.diff new file mode 100644 index 00000000000..36c26dc6605 --- /dev/null +++ b/tests/mir-opt/gvn.arithmetic_float.GVN.panic-unwind.diff @@ -0,0 +1,165 @@ +- // MIR for `arithmetic_float` before GVN ++ // MIR for `arithmetic_float` after GVN + + fn arithmetic_float(_1: f64) -> () { + debug x => _1; + let mut _0: (); + let _2: (); + let mut _3: f64; + let mut _4: f64; + let _5: (); + let mut _6: f64; + let mut _7: f64; + let _8: (); + let mut _9: f64; + let mut _10: f64; + let _11: (); + let mut _12: f64; + let mut _13: f64; + let _14: (); + let mut _15: f64; + let mut _16: f64; + let _17: (); + let mut _18: f64; + let mut _19: f64; + let _20: (); + let mut _21: f64; + let mut _22: f64; + let _23: (); + let mut _24: bool; + let mut _25: f64; + let mut _26: f64; + let _27: (); + let mut _28: bool; + let mut _29: f64; + let mut _30: f64; + + bb0: { + StorageLive(_2); + StorageLive(_3); +- StorageLive(_4); +- _4 = _1; +- _3 = Add(move _4, const 0f64); +- StorageDead(_4); ++ _3 = Add(_1, const 0f64); + _2 = opaque::<f64>(move _3) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_3); + StorageDead(_2); + StorageLive(_5); + StorageLive(_6); +- StorageLive(_7); +- _7 = _1; +- _6 = Sub(move _7, const 0f64); +- StorageDead(_7); ++ _6 = Sub(_1, const 0f64); + _5 = opaque::<f64>(move _6) -> [return: bb2, unwind continue]; + } + + bb2: { + StorageDead(_6); + StorageDead(_5); + StorageLive(_8); + StorageLive(_9); +- StorageLive(_10); +- _10 = _1; +- _9 = Mul(move _10, const 0f64); +- StorageDead(_10); ++ _9 = Mul(_1, const 0f64); + _8 = opaque::<f64>(move _9) -> [return: bb3, unwind continue]; + } + + bb3: { + StorageDead(_9); + StorageDead(_8); + StorageLive(_11); + StorageLive(_12); +- StorageLive(_13); +- _13 = _1; +- _12 = Div(move _13, const 0f64); +- StorageDead(_13); ++ _12 = Div(_1, const 0f64); + _11 = opaque::<f64>(move _12) -> [return: bb4, unwind continue]; + } + + bb4: { + StorageDead(_12); + StorageDead(_11); + StorageLive(_14); + StorageLive(_15); +- StorageLive(_16); +- _16 = _1; +- _15 = Div(const 0f64, move _16); +- StorageDead(_16); ++ _15 = Div(const 0f64, _1); + _14 = opaque::<f64>(move _15) -> [return: bb5, unwind continue]; + } + + bb5: { + StorageDead(_15); + StorageDead(_14); + StorageLive(_17); + StorageLive(_18); +- StorageLive(_19); +- _19 = _1; +- _18 = Rem(move _19, const 0f64); +- StorageDead(_19); ++ _18 = Rem(_1, const 0f64); + _17 = opaque::<f64>(move _18) -> [return: bb6, unwind continue]; + } + + bb6: { + StorageDead(_18); + StorageDead(_17); + StorageLive(_20); + StorageLive(_21); +- StorageLive(_22); +- _22 = _1; +- _21 = Rem(const 0f64, move _22); +- StorageDead(_22); ++ _21 = Rem(const 0f64, _1); + _20 = opaque::<f64>(move _21) -> [return: bb7, unwind continue]; + } + + bb7: { + StorageDead(_21); + StorageDead(_20); + StorageLive(_23); + StorageLive(_24); +- StorageLive(_25); +- _25 = _1; +- StorageLive(_26); +- _26 = _1; +- _24 = Eq(move _25, move _26); +- StorageDead(_26); +- StorageDead(_25); ++ _24 = Eq(_1, _1); + _23 = opaque::<bool>(move _24) -> [return: bb8, unwind continue]; + } + + bb8: { + StorageDead(_24); + StorageDead(_23); + StorageLive(_27); + StorageLive(_28); +- StorageLive(_29); +- _29 = _1; +- StorageLive(_30); +- _30 = _1; +- _28 = Ne(move _29, move _30); +- StorageDead(_30); +- StorageDead(_29); ++ _28 = Ne(_1, _1); + _27 = opaque::<bool>(move _28) -> [return: bb9, unwind continue]; + } + + bb9: { + StorageDead(_28); + StorageDead(_27); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/gvn.cast.GVN.panic-abort.diff b/tests/mir-opt/gvn.cast.GVN.panic-abort.diff new file mode 100644 index 00000000000..513fe60b65d --- /dev/null +++ b/tests/mir-opt/gvn.cast.GVN.panic-abort.diff @@ -0,0 +1,501 @@ +- // MIR for `cast` before GVN ++ // MIR for `cast` after GVN + + fn cast() -> () { + let mut _0: (); + let _1: i64; + let _4: (); + let mut _5: u8; + let mut _6: i64; + let _7: (); + let mut _8: u16; + let mut _9: i64; + let _10: (); + let mut _11: u32; + let mut _12: i64; + let _13: (); + let mut _14: u64; + let mut _15: i64; + let _16: (); + let mut _17: i8; + let mut _18: i64; + let _19: (); + let mut _20: i16; + let mut _21: i64; + let _22: (); + let mut _23: i32; + let mut _24: i64; + let _25: (); + let mut _26: i64; + let _27: (); + let mut _28: f32; + let mut _29: i64; + let _30: (); + let mut _31: f64; + let mut _32: i64; + let _33: (); + let mut _34: u8; + let mut _35: u64; + let _36: (); + let mut _37: u16; + let mut _38: u64; + let _39: (); + let mut _40: u32; + let mut _41: u64; + let _42: (); + let mut _43: u64; + let _44: (); + let mut _45: i8; + let mut _46: u64; + let _47: (); + let mut _48: i16; + let mut _49: u64; + let _50: (); + let mut _51: i32; + let mut _52: u64; + let _53: (); + let mut _54: i64; + let mut _55: u64; + let _56: (); + let mut _57: f32; + let mut _58: u64; + let _59: (); + let mut _60: f64; + let mut _61: u64; + let _62: (); + let mut _63: u8; + let mut _64: f64; + let _65: (); + let mut _66: u16; + let mut _67: f64; + let _68: (); + let mut _69: u32; + let mut _70: f64; + let _71: (); + let mut _72: u64; + let mut _73: f64; + let _74: (); + let mut _75: i8; + let mut _76: f64; + let _77: (); + let mut _78: i16; + let mut _79: f64; + let _80: (); + let mut _81: i32; + let mut _82: f64; + let _83: (); + let mut _84: i64; + let mut _85: f64; + let _86: (); + let mut _87: f32; + let mut _88: f64; + let _89: (); + let mut _90: f64; + scope 1 { + debug i => _1; + let _2: u64; + scope 2 { + debug u => _2; + let _3: f64; + scope 3 { + debug f => _3; + } + } + } + + bb0: { +- StorageLive(_1); + _1 = const 1_i64; +- StorageLive(_2); + _2 = const 1_u64; +- StorageLive(_3); + _3 = const 1f64; + StorageLive(_4); + StorageLive(_5); +- StorageLive(_6); +- _6 = _1; +- _5 = move _6 as u8 (IntToInt); +- StorageDead(_6); ++ _5 = const 1_i64 as u8 (IntToInt); + _4 = opaque::<u8>(move _5) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_5); + StorageDead(_4); + StorageLive(_7); + StorageLive(_8); +- StorageLive(_9); +- _9 = _1; +- _8 = move _9 as u16 (IntToInt); +- StorageDead(_9); ++ _8 = const 1_i64 as u16 (IntToInt); + _7 = opaque::<u16>(move _8) -> [return: bb2, unwind unreachable]; + } + + bb2: { + StorageDead(_8); + StorageDead(_7); + StorageLive(_10); + StorageLive(_11); +- StorageLive(_12); +- _12 = _1; +- _11 = move _12 as u32 (IntToInt); +- StorageDead(_12); ++ _11 = const 1_i64 as u32 (IntToInt); + _10 = opaque::<u32>(move _11) -> [return: bb3, unwind unreachable]; + } + + bb3: { + StorageDead(_11); + StorageDead(_10); + StorageLive(_13); + StorageLive(_14); +- StorageLive(_15); +- _15 = _1; +- _14 = move _15 as u64 (IntToInt); +- StorageDead(_15); ++ _14 = const 1_i64 as u64 (IntToInt); + _13 = opaque::<u64>(move _14) -> [return: bb4, unwind unreachable]; + } + + bb4: { + StorageDead(_14); + StorageDead(_13); + StorageLive(_16); + StorageLive(_17); +- StorageLive(_18); +- _18 = _1; +- _17 = move _18 as i8 (IntToInt); +- StorageDead(_18); ++ _17 = const 1_i64 as i8 (IntToInt); + _16 = opaque::<i8>(move _17) -> [return: bb5, unwind unreachable]; + } + + bb5: { + StorageDead(_17); + StorageDead(_16); + StorageLive(_19); + StorageLive(_20); +- StorageLive(_21); +- _21 = _1; +- _20 = move _21 as i16 (IntToInt); +- StorageDead(_21); ++ _20 = const 1_i64 as i16 (IntToInt); + _19 = opaque::<i16>(move _20) -> [return: bb6, unwind unreachable]; + } + + bb6: { + StorageDead(_20); + StorageDead(_19); + StorageLive(_22); + StorageLive(_23); +- StorageLive(_24); +- _24 = _1; +- _23 = move _24 as i32 (IntToInt); +- StorageDead(_24); ++ _23 = const 1_i64 as i32 (IntToInt); + _22 = opaque::<i32>(move _23) -> [return: bb7, unwind unreachable]; + } + + bb7: { + StorageDead(_23); + StorageDead(_22); + StorageLive(_25); +- StorageLive(_26); +- _26 = _1; +- _25 = opaque::<i64>(move _26) -> [return: bb8, unwind unreachable]; ++ _25 = opaque::<i64>(const 1_i64) -> [return: bb8, unwind unreachable]; + } + + bb8: { +- StorageDead(_26); + StorageDead(_25); + StorageLive(_27); + StorageLive(_28); +- StorageLive(_29); +- _29 = _1; +- _28 = move _29 as f32 (IntToFloat); +- StorageDead(_29); ++ _28 = const 1_i64 as f32 (IntToFloat); + _27 = opaque::<f32>(move _28) -> [return: bb9, unwind unreachable]; + } + + bb9: { + StorageDead(_28); + StorageDead(_27); + StorageLive(_30); + StorageLive(_31); +- StorageLive(_32); +- _32 = _1; +- _31 = move _32 as f64 (IntToFloat); +- StorageDead(_32); ++ _31 = const 1_i64 as f64 (IntToFloat); + _30 = opaque::<f64>(move _31) -> [return: bb10, unwind unreachable]; + } + + bb10: { + StorageDead(_31); + StorageDead(_30); + StorageLive(_33); + StorageLive(_34); +- StorageLive(_35); +- _35 = _2; +- _34 = move _35 as u8 (IntToInt); +- StorageDead(_35); ++ _34 = const 1_u64 as u8 (IntToInt); + _33 = opaque::<u8>(move _34) -> [return: bb11, unwind unreachable]; + } + + bb11: { + StorageDead(_34); + StorageDead(_33); + StorageLive(_36); + StorageLive(_37); +- StorageLive(_38); +- _38 = _2; +- _37 = move _38 as u16 (IntToInt); +- StorageDead(_38); ++ _37 = const 1_u64 as u16 (IntToInt); + _36 = opaque::<u16>(move _37) -> [return: bb12, unwind unreachable]; + } + + bb12: { + StorageDead(_37); + StorageDead(_36); + StorageLive(_39); + StorageLive(_40); +- StorageLive(_41); +- _41 = _2; +- _40 = move _41 as u32 (IntToInt); +- StorageDead(_41); ++ _40 = const 1_u64 as u32 (IntToInt); + _39 = opaque::<u32>(move _40) -> [return: bb13, unwind unreachable]; + } + + bb13: { + StorageDead(_40); + StorageDead(_39); + StorageLive(_42); +- StorageLive(_43); +- _43 = _2; +- _42 = opaque::<u64>(move _43) -> [return: bb14, unwind unreachable]; ++ _42 = opaque::<u64>(const 1_u64) -> [return: bb14, unwind unreachable]; + } + + bb14: { +- StorageDead(_43); + StorageDead(_42); + StorageLive(_44); + StorageLive(_45); +- StorageLive(_46); +- _46 = _2; +- _45 = move _46 as i8 (IntToInt); +- StorageDead(_46); ++ _45 = const 1_u64 as i8 (IntToInt); + _44 = opaque::<i8>(move _45) -> [return: bb15, unwind unreachable]; + } + + bb15: { + StorageDead(_45); + StorageDead(_44); + StorageLive(_47); + StorageLive(_48); +- StorageLive(_49); +- _49 = _2; +- _48 = move _49 as i16 (IntToInt); +- StorageDead(_49); ++ _48 = const 1_u64 as i16 (IntToInt); + _47 = opaque::<i16>(move _48) -> [return: bb16, unwind unreachable]; + } + + bb16: { + StorageDead(_48); + StorageDead(_47); + StorageLive(_50); + StorageLive(_51); +- StorageLive(_52); +- _52 = _2; +- _51 = move _52 as i32 (IntToInt); +- StorageDead(_52); ++ _51 = const 1_u64 as i32 (IntToInt); + _50 = opaque::<i32>(move _51) -> [return: bb17, unwind unreachable]; + } + + bb17: { + StorageDead(_51); + StorageDead(_50); + StorageLive(_53); + StorageLive(_54); +- StorageLive(_55); +- _55 = _2; +- _54 = move _55 as i64 (IntToInt); +- StorageDead(_55); ++ _54 = const 1_u64 as i64 (IntToInt); + _53 = opaque::<i64>(move _54) -> [return: bb18, unwind unreachable]; + } + + bb18: { + StorageDead(_54); + StorageDead(_53); + StorageLive(_56); + StorageLive(_57); +- StorageLive(_58); +- _58 = _2; +- _57 = move _58 as f32 (IntToFloat); +- StorageDead(_58); ++ _57 = const 1_u64 as f32 (IntToFloat); + _56 = opaque::<f32>(move _57) -> [return: bb19, unwind unreachable]; + } + + bb19: { + StorageDead(_57); + StorageDead(_56); + StorageLive(_59); + StorageLive(_60); +- StorageLive(_61); +- _61 = _2; +- _60 = move _61 as f64 (IntToFloat); +- StorageDead(_61); ++ _60 = const 1_u64 as f64 (IntToFloat); + _59 = opaque::<f64>(move _60) -> [return: bb20, unwind unreachable]; + } + + bb20: { + StorageDead(_60); + StorageDead(_59); + StorageLive(_62); + StorageLive(_63); +- StorageLive(_64); +- _64 = _3; +- _63 = move _64 as u8 (FloatToInt); +- StorageDead(_64); ++ _63 = const 1f64 as u8 (FloatToInt); + _62 = opaque::<u8>(move _63) -> [return: bb21, unwind unreachable]; + } + + bb21: { + StorageDead(_63); + StorageDead(_62); + StorageLive(_65); + StorageLive(_66); +- StorageLive(_67); +- _67 = _3; +- _66 = move _67 as u16 (FloatToInt); +- StorageDead(_67); ++ _66 = const 1f64 as u16 (FloatToInt); + _65 = opaque::<u16>(move _66) -> [return: bb22, unwind unreachable]; + } + + bb22: { + StorageDead(_66); + StorageDead(_65); + StorageLive(_68); + StorageLive(_69); +- StorageLive(_70); +- _70 = _3; +- _69 = move _70 as u32 (FloatToInt); +- StorageDead(_70); ++ _69 = const 1f64 as u32 (FloatToInt); + _68 = opaque::<u32>(move _69) -> [return: bb23, unwind unreachable]; + } + + bb23: { + StorageDead(_69); + StorageDead(_68); + StorageLive(_71); + StorageLive(_72); +- StorageLive(_73); +- _73 = _3; +- _72 = move _73 as u64 (FloatToInt); +- StorageDead(_73); ++ _72 = const 1f64 as u64 (FloatToInt); + _71 = opaque::<u64>(move _72) -> [return: bb24, unwind unreachable]; + } + + bb24: { + StorageDead(_72); + StorageDead(_71); + StorageLive(_74); + StorageLive(_75); +- StorageLive(_76); +- _76 = _3; +- _75 = move _76 as i8 (FloatToInt); +- StorageDead(_76); ++ _75 = const 1f64 as i8 (FloatToInt); + _74 = opaque::<i8>(move _75) -> [return: bb25, unwind unreachable]; + } + + bb25: { + StorageDead(_75); + StorageDead(_74); + StorageLive(_77); + StorageLive(_78); +- StorageLive(_79); +- _79 = _3; +- _78 = move _79 as i16 (FloatToInt); +- StorageDead(_79); ++ _78 = const 1f64 as i16 (FloatToInt); + _77 = opaque::<i16>(move _78) -> [return: bb26, unwind unreachable]; + } + + bb26: { + StorageDead(_78); + StorageDead(_77); + StorageLive(_80); + StorageLive(_81); +- StorageLive(_82); +- _82 = _3; +- _81 = move _82 as i32 (FloatToInt); +- StorageDead(_82); ++ _81 = const 1f64 as i32 (FloatToInt); + _80 = opaque::<i32>(move _81) -> [return: bb27, unwind unreachable]; + } + + bb27: { + StorageDead(_81); + StorageDead(_80); + StorageLive(_83); + StorageLive(_84); +- StorageLive(_85); +- _85 = _3; +- _84 = move _85 as i64 (FloatToInt); +- StorageDead(_85); ++ _84 = const 1f64 as i64 (FloatToInt); + _83 = opaque::<i64>(move _84) -> [return: bb28, unwind unreachable]; + } + + bb28: { + StorageDead(_84); + StorageDead(_83); + StorageLive(_86); + StorageLive(_87); +- StorageLive(_88); +- _88 = _3; +- _87 = move _88 as f32 (FloatToFloat); +- StorageDead(_88); ++ _87 = const 1f64 as f32 (FloatToFloat); + _86 = opaque::<f32>(move _87) -> [return: bb29, unwind unreachable]; + } + + bb29: { + StorageDead(_87); + StorageDead(_86); + StorageLive(_89); +- StorageLive(_90); +- _90 = _3; +- _89 = opaque::<f64>(move _90) -> [return: bb30, unwind unreachable]; ++ _89 = opaque::<f64>(const 1f64) -> [return: bb30, unwind unreachable]; + } + + bb30: { +- StorageDead(_90); + StorageDead(_89); + _0 = const (); +- StorageDead(_3); +- StorageDead(_2); +- StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/gvn.cast.GVN.panic-unwind.diff b/tests/mir-opt/gvn.cast.GVN.panic-unwind.diff new file mode 100644 index 00000000000..33192ed8de0 --- /dev/null +++ b/tests/mir-opt/gvn.cast.GVN.panic-unwind.diff @@ -0,0 +1,501 @@ +- // MIR for `cast` before GVN ++ // MIR for `cast` after GVN + + fn cast() -> () { + let mut _0: (); + let _1: i64; + let _4: (); + let mut _5: u8; + let mut _6: i64; + let _7: (); + let mut _8: u16; + let mut _9: i64; + let _10: (); + let mut _11: u32; + let mut _12: i64; + let _13: (); + let mut _14: u64; + let mut _15: i64; + let _16: (); + let mut _17: i8; + let mut _18: i64; + let _19: (); + let mut _20: i16; + let mut _21: i64; + let _22: (); + let mut _23: i32; + let mut _24: i64; + let _25: (); + let mut _26: i64; + let _27: (); + let mut _28: f32; + let mut _29: i64; + let _30: (); + let mut _31: f64; + let mut _32: i64; + let _33: (); + let mut _34: u8; + let mut _35: u64; + let _36: (); + let mut _37: u16; + let mut _38: u64; + let _39: (); + let mut _40: u32; + let mut _41: u64; + let _42: (); + let mut _43: u64; + let _44: (); + let mut _45: i8; + let mut _46: u64; + let _47: (); + let mut _48: i16; + let mut _49: u64; + let _50: (); + let mut _51: i32; + let mut _52: u64; + let _53: (); + let mut _54: i64; + let mut _55: u64; + let _56: (); + let mut _57: f32; + let mut _58: u64; + let _59: (); + let mut _60: f64; + let mut _61: u64; + let _62: (); + let mut _63: u8; + let mut _64: f64; + let _65: (); + let mut _66: u16; + let mut _67: f64; + let _68: (); + let mut _69: u32; + let mut _70: f64; + let _71: (); + let mut _72: u64; + let mut _73: f64; + let _74: (); + let mut _75: i8; + let mut _76: f64; + let _77: (); + let mut _78: i16; + let mut _79: f64; + let _80: (); + let mut _81: i32; + let mut _82: f64; + let _83: (); + let mut _84: i64; + let mut _85: f64; + let _86: (); + let mut _87: f32; + let mut _88: f64; + let _89: (); + let mut _90: f64; + scope 1 { + debug i => _1; + let _2: u64; + scope 2 { + debug u => _2; + let _3: f64; + scope 3 { + debug f => _3; + } + } + } + + bb0: { +- StorageLive(_1); + _1 = const 1_i64; +- StorageLive(_2); + _2 = const 1_u64; +- StorageLive(_3); + _3 = const 1f64; + StorageLive(_4); + StorageLive(_5); +- StorageLive(_6); +- _6 = _1; +- _5 = move _6 as u8 (IntToInt); +- StorageDead(_6); ++ _5 = const 1_i64 as u8 (IntToInt); + _4 = opaque::<u8>(move _5) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_5); + StorageDead(_4); + StorageLive(_7); + StorageLive(_8); +- StorageLive(_9); +- _9 = _1; +- _8 = move _9 as u16 (IntToInt); +- StorageDead(_9); ++ _8 = const 1_i64 as u16 (IntToInt); + _7 = opaque::<u16>(move _8) -> [return: bb2, unwind continue]; + } + + bb2: { + StorageDead(_8); + StorageDead(_7); + StorageLive(_10); + StorageLive(_11); +- StorageLive(_12); +- _12 = _1; +- _11 = move _12 as u32 (IntToInt); +- StorageDead(_12); ++ _11 = const 1_i64 as u32 (IntToInt); + _10 = opaque::<u32>(move _11) -> [return: bb3, unwind continue]; + } + + bb3: { + StorageDead(_11); + StorageDead(_10); + StorageLive(_13); + StorageLive(_14); +- StorageLive(_15); +- _15 = _1; +- _14 = move _15 as u64 (IntToInt); +- StorageDead(_15); ++ _14 = const 1_i64 as u64 (IntToInt); + _13 = opaque::<u64>(move _14) -> [return: bb4, unwind continue]; + } + + bb4: { + StorageDead(_14); + StorageDead(_13); + StorageLive(_16); + StorageLive(_17); +- StorageLive(_18); +- _18 = _1; +- _17 = move _18 as i8 (IntToInt); +- StorageDead(_18); ++ _17 = const 1_i64 as i8 (IntToInt); + _16 = opaque::<i8>(move _17) -> [return: bb5, unwind continue]; + } + + bb5: { + StorageDead(_17); + StorageDead(_16); + StorageLive(_19); + StorageLive(_20); +- StorageLive(_21); +- _21 = _1; +- _20 = move _21 as i16 (IntToInt); +- StorageDead(_21); ++ _20 = const 1_i64 as i16 (IntToInt); + _19 = opaque::<i16>(move _20) -> [return: bb6, unwind continue]; + } + + bb6: { + StorageDead(_20); + StorageDead(_19); + StorageLive(_22); + StorageLive(_23); +- StorageLive(_24); +- _24 = _1; +- _23 = move _24 as i32 (IntToInt); +- StorageDead(_24); ++ _23 = const 1_i64 as i32 (IntToInt); + _22 = opaque::<i32>(move _23) -> [return: bb7, unwind continue]; + } + + bb7: { + StorageDead(_23); + StorageDead(_22); + StorageLive(_25); +- StorageLive(_26); +- _26 = _1; +- _25 = opaque::<i64>(move _26) -> [return: bb8, unwind continue]; ++ _25 = opaque::<i64>(const 1_i64) -> [return: bb8, unwind continue]; + } + + bb8: { +- StorageDead(_26); + StorageDead(_25); + StorageLive(_27); + StorageLive(_28); +- StorageLive(_29); +- _29 = _1; +- _28 = move _29 as f32 (IntToFloat); +- StorageDead(_29); ++ _28 = const 1_i64 as f32 (IntToFloat); + _27 = opaque::<f32>(move _28) -> [return: bb9, unwind continue]; + } + + bb9: { + StorageDead(_28); + StorageDead(_27); + StorageLive(_30); + StorageLive(_31); +- StorageLive(_32); +- _32 = _1; +- _31 = move _32 as f64 (IntToFloat); +- StorageDead(_32); ++ _31 = const 1_i64 as f64 (IntToFloat); + _30 = opaque::<f64>(move _31) -> [return: bb10, unwind continue]; + } + + bb10: { + StorageDead(_31); + StorageDead(_30); + StorageLive(_33); + StorageLive(_34); +- StorageLive(_35); +- _35 = _2; +- _34 = move _35 as u8 (IntToInt); +- StorageDead(_35); ++ _34 = const 1_u64 as u8 (IntToInt); + _33 = opaque::<u8>(move _34) -> [return: bb11, unwind continue]; + } + + bb11: { + StorageDead(_34); + StorageDead(_33); + StorageLive(_36); + StorageLive(_37); +- StorageLive(_38); +- _38 = _2; +- _37 = move _38 as u16 (IntToInt); +- StorageDead(_38); ++ _37 = const 1_u64 as u16 (IntToInt); + _36 = opaque::<u16>(move _37) -> [return: bb12, unwind continue]; + } + + bb12: { + StorageDead(_37); + StorageDead(_36); + StorageLive(_39); + StorageLive(_40); +- StorageLive(_41); +- _41 = _2; +- _40 = move _41 as u32 (IntToInt); +- StorageDead(_41); ++ _40 = const 1_u64 as u32 (IntToInt); + _39 = opaque::<u32>(move _40) -> [return: bb13, unwind continue]; + } + + bb13: { + StorageDead(_40); + StorageDead(_39); + StorageLive(_42); +- StorageLive(_43); +- _43 = _2; +- _42 = opaque::<u64>(move _43) -> [return: bb14, unwind continue]; ++ _42 = opaque::<u64>(const 1_u64) -> [return: bb14, unwind continue]; + } + + bb14: { +- StorageDead(_43); + StorageDead(_42); + StorageLive(_44); + StorageLive(_45); +- StorageLive(_46); +- _46 = _2; +- _45 = move _46 as i8 (IntToInt); +- StorageDead(_46); ++ _45 = const 1_u64 as i8 (IntToInt); + _44 = opaque::<i8>(move _45) -> [return: bb15, unwind continue]; + } + + bb15: { + StorageDead(_45); + StorageDead(_44); + StorageLive(_47); + StorageLive(_48); +- StorageLive(_49); +- _49 = _2; +- _48 = move _49 as i16 (IntToInt); +- StorageDead(_49); ++ _48 = const 1_u64 as i16 (IntToInt); + _47 = opaque::<i16>(move _48) -> [return: bb16, unwind continue]; + } + + bb16: { + StorageDead(_48); + StorageDead(_47); + StorageLive(_50); + StorageLive(_51); +- StorageLive(_52); +- _52 = _2; +- _51 = move _52 as i32 (IntToInt); +- StorageDead(_52); ++ _51 = const 1_u64 as i32 (IntToInt); + _50 = opaque::<i32>(move _51) -> [return: bb17, unwind continue]; + } + + bb17: { + StorageDead(_51); + StorageDead(_50); + StorageLive(_53); + StorageLive(_54); +- StorageLive(_55); +- _55 = _2; +- _54 = move _55 as i64 (IntToInt); +- StorageDead(_55); ++ _54 = const 1_u64 as i64 (IntToInt); + _53 = opaque::<i64>(move _54) -> [return: bb18, unwind continue]; + } + + bb18: { + StorageDead(_54); + StorageDead(_53); + StorageLive(_56); + StorageLive(_57); +- StorageLive(_58); +- _58 = _2; +- _57 = move _58 as f32 (IntToFloat); +- StorageDead(_58); ++ _57 = const 1_u64 as f32 (IntToFloat); + _56 = opaque::<f32>(move _57) -> [return: bb19, unwind continue]; + } + + bb19: { + StorageDead(_57); + StorageDead(_56); + StorageLive(_59); + StorageLive(_60); +- StorageLive(_61); +- _61 = _2; +- _60 = move _61 as f64 (IntToFloat); +- StorageDead(_61); ++ _60 = const 1_u64 as f64 (IntToFloat); + _59 = opaque::<f64>(move _60) -> [return: bb20, unwind continue]; + } + + bb20: { + StorageDead(_60); + StorageDead(_59); + StorageLive(_62); + StorageLive(_63); +- StorageLive(_64); +- _64 = _3; +- _63 = move _64 as u8 (FloatToInt); +- StorageDead(_64); ++ _63 = const 1f64 as u8 (FloatToInt); + _62 = opaque::<u8>(move _63) -> [return: bb21, unwind continue]; + } + + bb21: { + StorageDead(_63); + StorageDead(_62); + StorageLive(_65); + StorageLive(_66); +- StorageLive(_67); +- _67 = _3; +- _66 = move _67 as u16 (FloatToInt); +- StorageDead(_67); ++ _66 = const 1f64 as u16 (FloatToInt); + _65 = opaque::<u16>(move _66) -> [return: bb22, unwind continue]; + } + + bb22: { + StorageDead(_66); + StorageDead(_65); + StorageLive(_68); + StorageLive(_69); +- StorageLive(_70); +- _70 = _3; +- _69 = move _70 as u32 (FloatToInt); +- StorageDead(_70); ++ _69 = const 1f64 as u32 (FloatToInt); + _68 = opaque::<u32>(move _69) -> [return: bb23, unwind continue]; + } + + bb23: { + StorageDead(_69); + StorageDead(_68); + StorageLive(_71); + StorageLive(_72); +- StorageLive(_73); +- _73 = _3; +- _72 = move _73 as u64 (FloatToInt); +- StorageDead(_73); ++ _72 = const 1f64 as u64 (FloatToInt); + _71 = opaque::<u64>(move _72) -> [return: bb24, unwind continue]; + } + + bb24: { + StorageDead(_72); + StorageDead(_71); + StorageLive(_74); + StorageLive(_75); +- StorageLive(_76); +- _76 = _3; +- _75 = move _76 as i8 (FloatToInt); +- StorageDead(_76); ++ _75 = const 1f64 as i8 (FloatToInt); + _74 = opaque::<i8>(move _75) -> [return: bb25, unwind continue]; + } + + bb25: { + StorageDead(_75); + StorageDead(_74); + StorageLive(_77); + StorageLive(_78); +- StorageLive(_79); +- _79 = _3; +- _78 = move _79 as i16 (FloatToInt); +- StorageDead(_79); ++ _78 = const 1f64 as i16 (FloatToInt); + _77 = opaque::<i16>(move _78) -> [return: bb26, unwind continue]; + } + + bb26: { + StorageDead(_78); + StorageDead(_77); + StorageLive(_80); + StorageLive(_81); +- StorageLive(_82); +- _82 = _3; +- _81 = move _82 as i32 (FloatToInt); +- StorageDead(_82); ++ _81 = const 1f64 as i32 (FloatToInt); + _80 = opaque::<i32>(move _81) -> [return: bb27, unwind continue]; + } + + bb27: { + StorageDead(_81); + StorageDead(_80); + StorageLive(_83); + StorageLive(_84); +- StorageLive(_85); +- _85 = _3; +- _84 = move _85 as i64 (FloatToInt); +- StorageDead(_85); ++ _84 = const 1f64 as i64 (FloatToInt); + _83 = opaque::<i64>(move _84) -> [return: bb28, unwind continue]; + } + + bb28: { + StorageDead(_84); + StorageDead(_83); + StorageLive(_86); + StorageLive(_87); +- StorageLive(_88); +- _88 = _3; +- _87 = move _88 as f32 (FloatToFloat); +- StorageDead(_88); ++ _87 = const 1f64 as f32 (FloatToFloat); + _86 = opaque::<f32>(move _87) -> [return: bb29, unwind continue]; + } + + bb29: { + StorageDead(_87); + StorageDead(_86); + StorageLive(_89); +- StorageLive(_90); +- _90 = _3; +- _89 = opaque::<f64>(move _90) -> [return: bb30, unwind continue]; ++ _89 = opaque::<f64>(const 1f64) -> [return: bb30, unwind continue]; + } + + bb30: { +- StorageDead(_90); + StorageDead(_89); + _0 = const (); +- StorageDead(_3); +- StorageDead(_2); +- StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/gvn.dereferences.GVN.panic-abort.diff b/tests/mir-opt/gvn.dereferences.GVN.panic-abort.diff new file mode 100644 index 00000000000..ee320cf6787 --- /dev/null +++ b/tests/mir-opt/gvn.dereferences.GVN.panic-abort.diff @@ -0,0 +1,191 @@ +- // MIR for `dereferences` before GVN ++ // MIR for `dereferences` after GVN + + fn dereferences(_1: &mut u32, _2: &impl Copy, _3: &S<u32>) -> () { + debug t => _1; + debug u => _2; + debug s => _3; + let mut _0: (); + let _4: (); + let mut _5: u32; + let _6: (); + let mut _7: u32; + let _8: *const u32; + let _9: (); + let mut _10: u32; + let _11: (); + let mut _12: u32; + let _14: (); + let mut _15: u32; + let _16: (); + let mut _17: u32; + let _19: (); + let mut _20: u32; + let _21: (); + let mut _22: u32; + let _23: (); + let mut _24: &u32; + let _25: (); + let mut _26: impl Copy; + let _27: (); + let mut _28: impl Copy; + let _29: (); + let mut _30: u32; + let _31: (); + let mut _32: u32; + scope 1 { + debug z => _8; + let _13: *mut u32; + scope 2 { + } + scope 3 { + } + scope 4 { + debug z => _13; + let _18: &u32; + scope 5 { + } + scope 6 { + } + scope 7 { + debug z => _18; + } + } + } + + bb0: { + StorageLive(_4); + StorageLive(_5); + _5 = (*_1); + _4 = opaque::<u32>(move _5) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_5); + StorageDead(_4); + StorageLive(_6); + StorageLive(_7); + _7 = (*_1); + _6 = opaque::<u32>(move _7) -> [return: bb2, unwind unreachable]; + } + + bb2: { + StorageDead(_7); + StorageDead(_6); + StorageLive(_8); + _8 = &raw const (*_1); + StorageLive(_9); + StorageLive(_10); + _10 = (*_8); + _9 = opaque::<u32>(move _10) -> [return: bb3, unwind unreachable]; + } + + bb3: { + StorageDead(_10); + StorageDead(_9); + StorageLive(_11); + StorageLive(_12); + _12 = (*_8); + _11 = opaque::<u32>(move _12) -> [return: bb4, unwind unreachable]; + } + + bb4: { + StorageDead(_12); + StorageDead(_11); + StorageLive(_13); + _13 = &raw mut (*_1); + StorageLive(_14); + StorageLive(_15); + _15 = (*_13); + _14 = opaque::<u32>(move _15) -> [return: bb5, unwind unreachable]; + } + + bb5: { + StorageDead(_15); + StorageDead(_14); + StorageLive(_16); + StorageLive(_17); + _17 = (*_13); + _16 = opaque::<u32>(move _17) -> [return: bb6, unwind unreachable]; + } + + bb6: { + StorageDead(_17); + StorageDead(_16); + StorageLive(_18); + _18 = &(*_1); + StorageLive(_19); +- StorageLive(_20); + _20 = (*_18); +- _19 = opaque::<u32>(move _20) -> [return: bb7, unwind unreachable]; ++ _19 = opaque::<u32>(_20) -> [return: bb7, unwind unreachable]; + } + + bb7: { +- StorageDead(_20); + StorageDead(_19); + StorageLive(_21); +- StorageLive(_22); +- _22 = (*_18); +- _21 = opaque::<u32>(move _22) -> [return: bb8, unwind unreachable]; ++ _21 = opaque::<u32>(_20) -> [return: bb8, unwind unreachable]; + } + + bb8: { +- StorageDead(_22); + StorageDead(_21); + StorageLive(_23); + StorageLive(_24); + _24 = &(*_18); + _23 = opaque::<&u32>(move _24) -> [return: bb9, unwind unreachable]; + } + + bb9: { + StorageDead(_24); + StorageDead(_23); + StorageLive(_25); + StorageLive(_26); + _26 = (*_2); + _25 = opaque::<impl Copy>(move _26) -> [return: bb10, unwind unreachable]; + } + + bb10: { + StorageDead(_26); + StorageDead(_25); + StorageLive(_27); + StorageLive(_28); + _28 = (*_2); + _27 = opaque::<impl Copy>(move _28) -> [return: bb11, unwind unreachable]; + } + + bb11: { + StorageDead(_28); + StorageDead(_27); + StorageLive(_29); +- StorageLive(_30); + _30 = ((*_3).0: u32); +- _29 = opaque::<u32>(move _30) -> [return: bb12, unwind unreachable]; ++ _29 = opaque::<u32>(_30) -> [return: bb12, unwind unreachable]; + } + + bb12: { +- StorageDead(_30); + StorageDead(_29); + StorageLive(_31); +- StorageLive(_32); +- _32 = ((*_3).0: u32); +- _31 = opaque::<u32>(move _32) -> [return: bb13, unwind unreachable]; ++ _31 = opaque::<u32>(_30) -> [return: bb13, unwind unreachable]; + } + + bb13: { +- StorageDead(_32); + StorageDead(_31); + _0 = const (); + StorageDead(_18); + StorageDead(_13); + StorageDead(_8); + return; + } + } + diff --git a/tests/mir-opt/gvn.dereferences.GVN.panic-unwind.diff b/tests/mir-opt/gvn.dereferences.GVN.panic-unwind.diff new file mode 100644 index 00000000000..f627b4d5988 --- /dev/null +++ b/tests/mir-opt/gvn.dereferences.GVN.panic-unwind.diff @@ -0,0 +1,191 @@ +- // MIR for `dereferences` before GVN ++ // MIR for `dereferences` after GVN + + fn dereferences(_1: &mut u32, _2: &impl Copy, _3: &S<u32>) -> () { + debug t => _1; + debug u => _2; + debug s => _3; + let mut _0: (); + let _4: (); + let mut _5: u32; + let _6: (); + let mut _7: u32; + let _8: *const u32; + let _9: (); + let mut _10: u32; + let _11: (); + let mut _12: u32; + let _14: (); + let mut _15: u32; + let _16: (); + let mut _17: u32; + let _19: (); + let mut _20: u32; + let _21: (); + let mut _22: u32; + let _23: (); + let mut _24: &u32; + let _25: (); + let mut _26: impl Copy; + let _27: (); + let mut _28: impl Copy; + let _29: (); + let mut _30: u32; + let _31: (); + let mut _32: u32; + scope 1 { + debug z => _8; + let _13: *mut u32; + scope 2 { + } + scope 3 { + } + scope 4 { + debug z => _13; + let _18: &u32; + scope 5 { + } + scope 6 { + } + scope 7 { + debug z => _18; + } + } + } + + bb0: { + StorageLive(_4); + StorageLive(_5); + _5 = (*_1); + _4 = opaque::<u32>(move _5) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_5); + StorageDead(_4); + StorageLive(_6); + StorageLive(_7); + _7 = (*_1); + _6 = opaque::<u32>(move _7) -> [return: bb2, unwind continue]; + } + + bb2: { + StorageDead(_7); + StorageDead(_6); + StorageLive(_8); + _8 = &raw const (*_1); + StorageLive(_9); + StorageLive(_10); + _10 = (*_8); + _9 = opaque::<u32>(move _10) -> [return: bb3, unwind continue]; + } + + bb3: { + StorageDead(_10); + StorageDead(_9); + StorageLive(_11); + StorageLive(_12); + _12 = (*_8); + _11 = opaque::<u32>(move _12) -> [return: bb4, unwind continue]; + } + + bb4: { + StorageDead(_12); + StorageDead(_11); + StorageLive(_13); + _13 = &raw mut (*_1); + StorageLive(_14); + StorageLive(_15); + _15 = (*_13); + _14 = opaque::<u32>(move _15) -> [return: bb5, unwind continue]; + } + + bb5: { + StorageDead(_15); + StorageDead(_14); + StorageLive(_16); + StorageLive(_17); + _17 = (*_13); + _16 = opaque::<u32>(move _17) -> [return: bb6, unwind continue]; + } + + bb6: { + StorageDead(_17); + StorageDead(_16); + StorageLive(_18); + _18 = &(*_1); + StorageLive(_19); +- StorageLive(_20); + _20 = (*_18); +- _19 = opaque::<u32>(move _20) -> [return: bb7, unwind continue]; ++ _19 = opaque::<u32>(_20) -> [return: bb7, unwind continue]; + } + + bb7: { +- StorageDead(_20); + StorageDead(_19); + StorageLive(_21); +- StorageLive(_22); +- _22 = (*_18); +- _21 = opaque::<u32>(move _22) -> [return: bb8, unwind continue]; ++ _21 = opaque::<u32>(_20) -> [return: bb8, unwind continue]; + } + + bb8: { +- StorageDead(_22); + StorageDead(_21); + StorageLive(_23); + StorageLive(_24); + _24 = &(*_18); + _23 = opaque::<&u32>(move _24) -> [return: bb9, unwind continue]; + } + + bb9: { + StorageDead(_24); + StorageDead(_23); + StorageLive(_25); + StorageLive(_26); + _26 = (*_2); + _25 = opaque::<impl Copy>(move _26) -> [return: bb10, unwind continue]; + } + + bb10: { + StorageDead(_26); + StorageDead(_25); + StorageLive(_27); + StorageLive(_28); + _28 = (*_2); + _27 = opaque::<impl Copy>(move _28) -> [return: bb11, unwind continue]; + } + + bb11: { + StorageDead(_28); + StorageDead(_27); + StorageLive(_29); +- StorageLive(_30); + _30 = ((*_3).0: u32); +- _29 = opaque::<u32>(move _30) -> [return: bb12, unwind continue]; ++ _29 = opaque::<u32>(_30) -> [return: bb12, unwind continue]; + } + + bb12: { +- StorageDead(_30); + StorageDead(_29); + StorageLive(_31); +- StorageLive(_32); +- _32 = ((*_3).0: u32); +- _31 = opaque::<u32>(move _32) -> [return: bb13, unwind continue]; ++ _31 = opaque::<u32>(_30) -> [return: bb13, unwind continue]; + } + + bb13: { +- StorageDead(_32); + StorageDead(_31); + _0 = const (); + StorageDead(_18); + StorageDead(_13); + StorageDead(_8); + return; + } + } + diff --git a/tests/mir-opt/gvn.multiple_branches.GVN.panic-abort.diff b/tests/mir-opt/gvn.multiple_branches.GVN.panic-abort.diff new file mode 100644 index 00000000000..0a66900283b --- /dev/null +++ b/tests/mir-opt/gvn.multiple_branches.GVN.panic-abort.diff @@ -0,0 +1,198 @@ +- // MIR for `multiple_branches` before GVN ++ // MIR for `multiple_branches` after GVN + + fn multiple_branches(_1: bool, _2: u8, _3: u8) -> () { + debug t => _1; + debug x => _2; + debug y => _3; + let mut _0: (); + let _4: (); + let mut _5: bool; + let _6: (); + let mut _7: u8; + let mut _8: u8; + let mut _9: u8; + let _10: (); + let mut _11: u8; + let mut _12: u8; + let mut _13: u8; + let _14: (); + let mut _15: u8; + let mut _16: u8; + let mut _17: u8; + let _18: (); + let mut _19: u8; + let mut _20: u8; + let mut _21: u8; + let _22: (); + let mut _23: u8; + let mut _24: u8; + let mut _25: u8; + let mut _26: bool; + let _27: (); + let mut _28: u8; + let mut _29: u8; + let mut _30: u8; + let _31: (); + let mut _32: u8; + let mut _33: u8; + let mut _34: u8; + + bb0: { +- StorageLive(_4); +- StorageLive(_5); +- _5 = _1; +- switchInt(move _5) -> [0: bb4, otherwise: bb1]; ++ switchInt(_1) -> [0: bb4, otherwise: bb1]; + } + + bb1: { + StorageLive(_6); +- StorageLive(_7); +- StorageLive(_8); +- _8 = _2; +- StorageLive(_9); +- _9 = _3; +- _7 = Add(move _8, move _9); +- StorageDead(_9); +- StorageDead(_8); +- _6 = opaque::<u8>(move _7) -> [return: bb2, unwind unreachable]; ++ _7 = Add(_2, _3); ++ _6 = opaque::<u8>(_7) -> [return: bb2, unwind unreachable]; + } + + bb2: { +- StorageDead(_7); + StorageDead(_6); + StorageLive(_10); +- StorageLive(_11); +- StorageLive(_12); +- _12 = _2; +- StorageLive(_13); +- _13 = _3; +- _11 = Add(move _12, move _13); +- StorageDead(_13); +- StorageDead(_12); +- _10 = opaque::<u8>(move _11) -> [return: bb3, unwind unreachable]; ++ _10 = opaque::<u8>(_7) -> [return: bb3, unwind unreachable]; + } + + bb3: { +- StorageDead(_11); + StorageDead(_10); +- _4 = const (); + goto -> bb7; + } + + bb4: { + StorageLive(_14); +- StorageLive(_15); +- StorageLive(_16); +- _16 = _2; +- StorageLive(_17); +- _17 = _3; +- _15 = Add(move _16, move _17); +- StorageDead(_17); +- StorageDead(_16); +- _14 = opaque::<u8>(move _15) -> [return: bb5, unwind unreachable]; ++ _15 = Add(_2, _3); ++ _14 = opaque::<u8>(_15) -> [return: bb5, unwind unreachable]; + } + + bb5: { +- StorageDead(_15); + StorageDead(_14); + StorageLive(_18); +- StorageLive(_19); +- StorageLive(_20); +- _20 = _2; +- StorageLive(_21); +- _21 = _3; +- _19 = Add(move _20, move _21); +- StorageDead(_21); +- StorageDead(_20); +- _18 = opaque::<u8>(move _19) -> [return: bb6, unwind unreachable]; ++ _18 = opaque::<u8>(_15) -> [return: bb6, unwind unreachable]; + } + + bb6: { +- StorageDead(_19); + StorageDead(_18); +- _4 = const (); + goto -> bb7; + } + + bb7: { +- StorageDead(_5); +- StorageDead(_4); + StorageLive(_22); +- StorageLive(_23); +- StorageLive(_24); +- _24 = _2; +- StorageLive(_25); +- _25 = _3; +- _23 = Add(move _24, move _25); +- StorageDead(_25); +- StorageDead(_24); +- _22 = opaque::<u8>(move _23) -> [return: bb8, unwind unreachable]; ++ _23 = Add(_2, _3); ++ _22 = opaque::<u8>(_23) -> [return: bb8, unwind unreachable]; + } + + bb8: { +- StorageDead(_23); + StorageDead(_22); +- StorageLive(_26); +- _26 = _1; +- switchInt(move _26) -> [0: bb11, otherwise: bb9]; ++ switchInt(_1) -> [0: bb11, otherwise: bb9]; + } + + bb9: { + StorageLive(_27); +- StorageLive(_28); +- StorageLive(_29); +- _29 = _2; +- StorageLive(_30); +- _30 = _3; +- _28 = Add(move _29, move _30); +- StorageDead(_30); +- StorageDead(_29); +- _27 = opaque::<u8>(move _28) -> [return: bb10, unwind unreachable]; ++ _27 = opaque::<u8>(_23) -> [return: bb10, unwind unreachable]; + } + + bb10: { +- StorageDead(_28); + StorageDead(_27); + _0 = const (); + goto -> bb13; + } + + bb11: { + StorageLive(_31); +- StorageLive(_32); +- StorageLive(_33); +- _33 = _2; +- StorageLive(_34); +- _34 = _3; +- _32 = Add(move _33, move _34); +- StorageDead(_34); +- StorageDead(_33); +- _31 = opaque::<u8>(move _32) -> [return: bb12, unwind unreachable]; ++ _31 = opaque::<u8>(_23) -> [return: bb12, unwind unreachable]; + } + + bb12: { +- StorageDead(_32); + StorageDead(_31); + _0 = const (); + goto -> bb13; + } + + bb13: { +- StorageDead(_26); + return; + } + } + diff --git a/tests/mir-opt/gvn.multiple_branches.GVN.panic-unwind.diff b/tests/mir-opt/gvn.multiple_branches.GVN.panic-unwind.diff new file mode 100644 index 00000000000..0199f2720a9 --- /dev/null +++ b/tests/mir-opt/gvn.multiple_branches.GVN.panic-unwind.diff @@ -0,0 +1,198 @@ +- // MIR for `multiple_branches` before GVN ++ // MIR for `multiple_branches` after GVN + + fn multiple_branches(_1: bool, _2: u8, _3: u8) -> () { + debug t => _1; + debug x => _2; + debug y => _3; + let mut _0: (); + let _4: (); + let mut _5: bool; + let _6: (); + let mut _7: u8; + let mut _8: u8; + let mut _9: u8; + let _10: (); + let mut _11: u8; + let mut _12: u8; + let mut _13: u8; + let _14: (); + let mut _15: u8; + let mut _16: u8; + let mut _17: u8; + let _18: (); + let mut _19: u8; + let mut _20: u8; + let mut _21: u8; + let _22: (); + let mut _23: u8; + let mut _24: u8; + let mut _25: u8; + let mut _26: bool; + let _27: (); + let mut _28: u8; + let mut _29: u8; + let mut _30: u8; + let _31: (); + let mut _32: u8; + let mut _33: u8; + let mut _34: u8; + + bb0: { +- StorageLive(_4); +- StorageLive(_5); +- _5 = _1; +- switchInt(move _5) -> [0: bb4, otherwise: bb1]; ++ switchInt(_1) -> [0: bb4, otherwise: bb1]; + } + + bb1: { + StorageLive(_6); +- StorageLive(_7); +- StorageLive(_8); +- _8 = _2; +- StorageLive(_9); +- _9 = _3; +- _7 = Add(move _8, move _9); +- StorageDead(_9); +- StorageDead(_8); +- _6 = opaque::<u8>(move _7) -> [return: bb2, unwind continue]; ++ _7 = Add(_2, _3); ++ _6 = opaque::<u8>(_7) -> [return: bb2, unwind continue]; + } + + bb2: { +- StorageDead(_7); + StorageDead(_6); + StorageLive(_10); +- StorageLive(_11); +- StorageLive(_12); +- _12 = _2; +- StorageLive(_13); +- _13 = _3; +- _11 = Add(move _12, move _13); +- StorageDead(_13); +- StorageDead(_12); +- _10 = opaque::<u8>(move _11) -> [return: bb3, unwind continue]; ++ _10 = opaque::<u8>(_7) -> [return: bb3, unwind continue]; + } + + bb3: { +- StorageDead(_11); + StorageDead(_10); +- _4 = const (); + goto -> bb7; + } + + bb4: { + StorageLive(_14); +- StorageLive(_15); +- StorageLive(_16); +- _16 = _2; +- StorageLive(_17); +- _17 = _3; +- _15 = Add(move _16, move _17); +- StorageDead(_17); +- StorageDead(_16); +- _14 = opaque::<u8>(move _15) -> [return: bb5, unwind continue]; ++ _15 = Add(_2, _3); ++ _14 = opaque::<u8>(_15) -> [return: bb5, unwind continue]; + } + + bb5: { +- StorageDead(_15); + StorageDead(_14); + StorageLive(_18); +- StorageLive(_19); +- StorageLive(_20); +- _20 = _2; +- StorageLive(_21); +- _21 = _3; +- _19 = Add(move _20, move _21); +- StorageDead(_21); +- StorageDead(_20); +- _18 = opaque::<u8>(move _19) -> [return: bb6, unwind continue]; ++ _18 = opaque::<u8>(_15) -> [return: bb6, unwind continue]; + } + + bb6: { +- StorageDead(_19); + StorageDead(_18); +- _4 = const (); + goto -> bb7; + } + + bb7: { +- StorageDead(_5); +- StorageDead(_4); + StorageLive(_22); +- StorageLive(_23); +- StorageLive(_24); +- _24 = _2; +- StorageLive(_25); +- _25 = _3; +- _23 = Add(move _24, move _25); +- StorageDead(_25); +- StorageDead(_24); +- _22 = opaque::<u8>(move _23) -> [return: bb8, unwind continue]; ++ _23 = Add(_2, _3); ++ _22 = opaque::<u8>(_23) -> [return: bb8, unwind continue]; + } + + bb8: { +- StorageDead(_23); + StorageDead(_22); +- StorageLive(_26); +- _26 = _1; +- switchInt(move _26) -> [0: bb11, otherwise: bb9]; ++ switchInt(_1) -> [0: bb11, otherwise: bb9]; + } + + bb9: { + StorageLive(_27); +- StorageLive(_28); +- StorageLive(_29); +- _29 = _2; +- StorageLive(_30); +- _30 = _3; +- _28 = Add(move _29, move _30); +- StorageDead(_30); +- StorageDead(_29); +- _27 = opaque::<u8>(move _28) -> [return: bb10, unwind continue]; ++ _27 = opaque::<u8>(_23) -> [return: bb10, unwind continue]; + } + + bb10: { +- StorageDead(_28); + StorageDead(_27); + _0 = const (); + goto -> bb13; + } + + bb11: { + StorageLive(_31); +- StorageLive(_32); +- StorageLive(_33); +- _33 = _2; +- StorageLive(_34); +- _34 = _3; +- _32 = Add(move _33, move _34); +- StorageDead(_34); +- StorageDead(_33); +- _31 = opaque::<u8>(move _32) -> [return: bb12, unwind continue]; ++ _31 = opaque::<u8>(_23) -> [return: bb12, unwind continue]; + } + + bb12: { +- StorageDead(_32); + StorageDead(_31); + _0 = const (); + goto -> bb13; + } + + bb13: { +- StorageDead(_26); + return; + } + } + diff --git a/tests/mir-opt/gvn.references.GVN.panic-abort.diff b/tests/mir-opt/gvn.references.GVN.panic-abort.diff new file mode 100644 index 00000000000..b7ad4ab1fd3 --- /dev/null +++ b/tests/mir-opt/gvn.references.GVN.panic-abort.diff @@ -0,0 +1,105 @@ +- // MIR for `references` before GVN ++ // MIR for `references` after GVN + + fn references(_1: impl Sized) -> () { + debug x => _1; + let mut _0: (); + let _2: (); + let mut _3: &impl Sized; + let _4: (); + let mut _5: &impl Sized; + let _6: (); + let mut _7: &mut impl Sized; + let _8: (); + let mut _9: &mut impl Sized; + let _10: (); + let mut _11: *const impl Sized; + let _12: (); + let mut _13: *const impl Sized; + let _14: (); + let mut _15: *mut impl Sized; + let _16: (); + let mut _17: *mut impl Sized; + + bb0: { + StorageLive(_2); + StorageLive(_3); + _3 = &_1; + _2 = opaque::<&impl Sized>(move _3) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_3); + StorageDead(_2); + StorageLive(_4); + StorageLive(_5); + _5 = &_1; + _4 = opaque::<&impl Sized>(move _5) -> [return: bb2, unwind unreachable]; + } + + bb2: { + StorageDead(_5); + StorageDead(_4); + StorageLive(_6); + StorageLive(_7); + _7 = &mut _1; + _6 = opaque::<&mut impl Sized>(move _7) -> [return: bb3, unwind unreachable]; + } + + bb3: { + StorageDead(_7); + StorageDead(_6); + StorageLive(_8); + StorageLive(_9); + _9 = &mut _1; + _8 = opaque::<&mut impl Sized>(move _9) -> [return: bb4, unwind unreachable]; + } + + bb4: { + StorageDead(_9); + StorageDead(_8); + StorageLive(_10); + StorageLive(_11); + _11 = &raw const _1; + _10 = opaque::<*const impl Sized>(move _11) -> [return: bb5, unwind unreachable]; + } + + bb5: { + StorageDead(_11); + StorageDead(_10); + StorageLive(_12); + StorageLive(_13); + _13 = &raw const _1; + _12 = opaque::<*const impl Sized>(move _13) -> [return: bb6, unwind unreachable]; + } + + bb6: { + StorageDead(_13); + StorageDead(_12); + StorageLive(_14); + StorageLive(_15); + _15 = &raw mut _1; + _14 = opaque::<*mut impl Sized>(move _15) -> [return: bb7, unwind unreachable]; + } + + bb7: { + StorageDead(_15); + StorageDead(_14); + StorageLive(_16); + StorageLive(_17); + _17 = &raw mut _1; + _16 = opaque::<*mut impl Sized>(move _17) -> [return: bb8, unwind unreachable]; + } + + bb8: { + StorageDead(_17); + StorageDead(_16); + _0 = const (); + drop(_1) -> [return: bb9, unwind unreachable]; + } + + bb9: { + return; + } + } + diff --git a/tests/mir-opt/gvn.references.GVN.panic-unwind.diff b/tests/mir-opt/gvn.references.GVN.panic-unwind.diff new file mode 100644 index 00000000000..08ed4c629a6 --- /dev/null +++ b/tests/mir-opt/gvn.references.GVN.panic-unwind.diff @@ -0,0 +1,113 @@ +- // MIR for `references` before GVN ++ // MIR for `references` after GVN + + fn references(_1: impl Sized) -> () { + debug x => _1; + let mut _0: (); + let _2: (); + let mut _3: &impl Sized; + let _4: (); + let mut _5: &impl Sized; + let _6: (); + let mut _7: &mut impl Sized; + let _8: (); + let mut _9: &mut impl Sized; + let _10: (); + let mut _11: *const impl Sized; + let _12: (); + let mut _13: *const impl Sized; + let _14: (); + let mut _15: *mut impl Sized; + let _16: (); + let mut _17: *mut impl Sized; + + bb0: { + StorageLive(_2); + StorageLive(_3); + _3 = &_1; + _2 = opaque::<&impl Sized>(move _3) -> [return: bb1, unwind: bb10]; + } + + bb1: { + StorageDead(_3); + StorageDead(_2); + StorageLive(_4); + StorageLive(_5); + _5 = &_1; + _4 = opaque::<&impl Sized>(move _5) -> [return: bb2, unwind: bb10]; + } + + bb2: { + StorageDead(_5); + StorageDead(_4); + StorageLive(_6); + StorageLive(_7); + _7 = &mut _1; + _6 = opaque::<&mut impl Sized>(move _7) -> [return: bb3, unwind: bb10]; + } + + bb3: { + StorageDead(_7); + StorageDead(_6); + StorageLive(_8); + StorageLive(_9); + _9 = &mut _1; + _8 = opaque::<&mut impl Sized>(move _9) -> [return: bb4, unwind: bb10]; + } + + bb4: { + StorageDead(_9); + StorageDead(_8); + StorageLive(_10); + StorageLive(_11); + _11 = &raw const _1; + _10 = opaque::<*const impl Sized>(move _11) -> [return: bb5, unwind: bb10]; + } + + bb5: { + StorageDead(_11); + StorageDead(_10); + StorageLive(_12); + StorageLive(_13); + _13 = &raw const _1; + _12 = opaque::<*const impl Sized>(move _13) -> [return: bb6, unwind: bb10]; + } + + bb6: { + StorageDead(_13); + StorageDead(_12); + StorageLive(_14); + StorageLive(_15); + _15 = &raw mut _1; + _14 = opaque::<*mut impl Sized>(move _15) -> [return: bb7, unwind: bb10]; + } + + bb7: { + StorageDead(_15); + StorageDead(_14); + StorageLive(_16); + StorageLive(_17); + _17 = &raw mut _1; + _16 = opaque::<*mut impl Sized>(move _17) -> [return: bb8, unwind: bb10]; + } + + bb8: { + StorageDead(_17); + StorageDead(_16); + _0 = const (); + drop(_1) -> [return: bb9, unwind: bb11]; + } + + bb9: { + return; + } + + bb10 (cleanup): { + drop(_1) -> [return: bb11, unwind terminate(cleanup)]; + } + + bb11 (cleanup): { + resume; + } + } + diff --git a/tests/mir-opt/gvn.repeated_index.GVN.panic-abort.diff b/tests/mir-opt/gvn.repeated_index.GVN.panic-abort.diff new file mode 100644 index 00000000000..4c29523d6b2 --- /dev/null +++ b/tests/mir-opt/gvn.repeated_index.GVN.panic-abort.diff @@ -0,0 +1,76 @@ +- // MIR for `repeated_index` before GVN ++ // MIR for `repeated_index` after GVN + + fn repeated_index(_1: T, _2: usize) -> () { + debug x => _1; + debug idx => _2; + let mut _0: (); + let _3: [T; N]; + let mut _4: T; + let _5: (); + let mut _6: T; + let _7: usize; + let mut _8: usize; + let mut _9: bool; + let _10: (); + let mut _11: T; + let _12: usize; + let mut _13: usize; + let mut _14: bool; + scope 1 { + debug a => _3; + } + + bb0: { + StorageLive(_3); +- StorageLive(_4); +- _4 = _1; +- _3 = [move _4; N]; +- StorageDead(_4); ++ _3 = [_1; N]; + StorageLive(_5); + StorageLive(_6); + StorageLive(_7); + _7 = const 0_usize; + _8 = Len(_3); +- _9 = Lt(_7, _8); +- assert(move _9, "index out of bounds: the length is {} but the index is {}", move _8, _7) -> [success: bb1, unwind unreachable]; ++ _9 = Lt(const 0_usize, _8); ++ assert(move _9, "index out of bounds: the length is {} but the index is {}", _8, const 0_usize) -> [success: bb1, unwind unreachable]; + } + + bb1: { + _6 = _3[_7]; + _5 = opaque::<T>(move _6) -> [return: bb2, unwind unreachable]; + } + + bb2: { + StorageDead(_6); + StorageDead(_7); + StorageDead(_5); + StorageLive(_10); + StorageLive(_11); + StorageLive(_12); + _12 = _2; +- _13 = Len(_3); +- _14 = Lt(_12, _13); +- assert(move _14, "index out of bounds: the length is {} but the index is {}", move _13, _12) -> [success: bb3, unwind unreachable]; ++ _14 = Lt(_2, _8); ++ assert(move _14, "index out of bounds: the length is {} but the index is {}", _8, _2) -> [success: bb3, unwind unreachable]; + } + + bb3: { + _11 = _3[_12]; + _10 = opaque::<T>(move _11) -> [return: bb4, unwind unreachable]; + } + + bb4: { + StorageDead(_11); + StorageDead(_12); + StorageDead(_10); + _0 = const (); + StorageDead(_3); + return; + } + } + diff --git a/tests/mir-opt/gvn.repeated_index.GVN.panic-unwind.diff b/tests/mir-opt/gvn.repeated_index.GVN.panic-unwind.diff new file mode 100644 index 00000000000..e44f54cf3cf --- /dev/null +++ b/tests/mir-opt/gvn.repeated_index.GVN.panic-unwind.diff @@ -0,0 +1,76 @@ +- // MIR for `repeated_index` before GVN ++ // MIR for `repeated_index` after GVN + + fn repeated_index(_1: T, _2: usize) -> () { + debug x => _1; + debug idx => _2; + let mut _0: (); + let _3: [T; N]; + let mut _4: T; + let _5: (); + let mut _6: T; + let _7: usize; + let mut _8: usize; + let mut _9: bool; + let _10: (); + let mut _11: T; + let _12: usize; + let mut _13: usize; + let mut _14: bool; + scope 1 { + debug a => _3; + } + + bb0: { + StorageLive(_3); +- StorageLive(_4); +- _4 = _1; +- _3 = [move _4; N]; +- StorageDead(_4); ++ _3 = [_1; N]; + StorageLive(_5); + StorageLive(_6); + StorageLive(_7); + _7 = const 0_usize; + _8 = Len(_3); +- _9 = Lt(_7, _8); +- assert(move _9, "index out of bounds: the length is {} but the index is {}", move _8, _7) -> [success: bb1, unwind continue]; ++ _9 = Lt(const 0_usize, _8); ++ assert(move _9, "index out of bounds: the length is {} but the index is {}", _8, const 0_usize) -> [success: bb1, unwind continue]; + } + + bb1: { + _6 = _3[_7]; + _5 = opaque::<T>(move _6) -> [return: bb2, unwind continue]; + } + + bb2: { + StorageDead(_6); + StorageDead(_7); + StorageDead(_5); + StorageLive(_10); + StorageLive(_11); + StorageLive(_12); + _12 = _2; +- _13 = Len(_3); +- _14 = Lt(_12, _13); +- assert(move _14, "index out of bounds: the length is {} but the index is {}", move _13, _12) -> [success: bb3, unwind continue]; ++ _14 = Lt(_2, _8); ++ assert(move _14, "index out of bounds: the length is {} but the index is {}", _8, _2) -> [success: bb3, unwind continue]; + } + + bb3: { + _11 = _3[_12]; + _10 = opaque::<T>(move _11) -> [return: bb4, unwind continue]; + } + + bb4: { + StorageDead(_11); + StorageDead(_12); + StorageDead(_10); + _0 = const (); + StorageDead(_3); + return; + } + } + diff --git a/tests/mir-opt/gvn.rs b/tests/mir-opt/gvn.rs new file mode 100644 index 00000000000..a85e2ae368b --- /dev/null +++ b/tests/mir-opt/gvn.rs @@ -0,0 +1,253 @@ +// unit-test: GVN +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY + +#![feature(raw_ref_op)] +#![feature(rustc_attrs)] +#![allow(unconditional_panic)] + +struct S<T>(T); + +fn subexpression_elimination(x: u64, y: u64, mut z: u64) { + opaque(x + y); + opaque(x * y); + opaque(x - y); + opaque(x / y); + opaque(x % y); + opaque(x & y); + opaque(x | y); + opaque(x ^ y); + opaque(x << y); + opaque(x >> y); + opaque(x as u32); + opaque(x as f32); + opaque(S(x)); + opaque(S(x).0); + + // Those are duplicates to substitute somehow. + opaque((x + y) + z); + opaque((x * y) + z); + opaque((x - y) + z); + opaque((x / y) + z); + opaque((x % y) + z); + opaque((x & y) + z); + opaque((x | y) + z); + opaque((x ^ y) + z); + opaque((x << y) + z); + opaque((x >> y) + z); + opaque(S(x)); + opaque(S(x).0); + + // We can substitute through an immutable reference too. + let a = &z; + opaque(*a + x); + opaque(*a + x); + + // But not through a mutable reference or a pointer. + let b = &mut z; + opaque(*b + x); + opaque(*b + x); + unsafe { + let c = &raw const z; + opaque(*c + x); + opaque(*c + x); + let d = &raw mut z; + opaque(*d + x); + opaque(*d + x); + } + + // We can substitute again, but not with the earlier computations. + // Important: `e` is not `a`! + let e = &z; + opaque(*e + x); + opaque(*e + x); + +} + +fn wrap_unwrap<T: Copy>(x: T) -> T { + match Some(x) { + Some(y) => y, + None => panic!(), + } +} + +fn repeated_index<T: Copy, const N: usize>(x: T, idx: usize) { + let a = [x; N]; + opaque(a[0]); + opaque(a[idx]); +} + +fn arithmetic(x: u64) { + opaque(x + 0); + opaque(x - 0); + opaque(x * 0); + opaque(x * 1); + opaque(x / 0); + opaque(x / 1); + opaque(0 / x); + opaque(1 / x); + opaque(x % 0); + opaque(x % 1); + opaque(0 % x); + opaque(1 % x); + opaque(x & 0); + opaque(x | 0); + opaque(x ^ 0); + opaque(x >> 0); + opaque(x << 0); +} + +#[rustc_inherit_overflow_checks] +fn arithmetic_checked(x: u64) { + opaque(x + 0); + opaque(x - 0); + opaque(x * 0); + opaque(x * 1); + opaque(x / 0); + opaque(x / 1); + opaque(0 / x); + opaque(1 / x); + opaque(x % 0); + opaque(x % 1); + opaque(0 % x); + opaque(1 % x); + opaque(x & 0); + opaque(x | 0); + opaque(x ^ 0); + opaque(x >> 0); + opaque(x << 0); +} + +fn arithmetic_float(x: f64) { + opaque(x + 0.); + opaque(x - 0.); + opaque(x * 0.); + opaque(x / 0.); + opaque(0. / x); + opaque(x % 0.); + opaque(0. % x); + // Those are not simplifiable to `true`/`false`, thanks to NaNs. + opaque(x == x); + opaque(x != x); +} + +fn cast() { + let i = 1_i64; + let u = 1_u64; + let f = 1_f64; + opaque(i as u8); + opaque(i as u16); + opaque(i as u32); + opaque(i as u64); + opaque(i as i8); + opaque(i as i16); + opaque(i as i32); + opaque(i as i64); + opaque(i as f32); + opaque(i as f64); + opaque(u as u8); + opaque(u as u16); + opaque(u as u32); + opaque(u as u64); + opaque(u as i8); + opaque(u as i16); + opaque(u as i32); + opaque(u as i64); + opaque(u as f32); + opaque(u as f64); + opaque(f as u8); + opaque(f as u16); + opaque(f as u32); + opaque(f as u64); + opaque(f as i8); + opaque(f as i16); + opaque(f as i32); + opaque(f as i64); + opaque(f as f32); + opaque(f as f64); +} + +fn multiple_branches(t: bool, x: u8, y: u8) { + if t { + opaque(x + y); // a + opaque(x + y); // should reuse a + } else { + opaque(x + y); // b + opaque(x + y); // shoud reuse b + } + opaque(x + y); // c + if t { + opaque(x + y); // should reuse c + } else { + opaque(x + y); // should reuse c + } +} + +fn references(mut x: impl Sized) { + opaque(&x); + opaque(&x); // should not reuse a + opaque(&mut x); + opaque(&mut x); // should not reuse a + opaque(&raw const x); + opaque(&raw const x); // should not reuse a + opaque(&raw mut x); + opaque(&raw mut x); // should not reuse a +} + +fn dereferences(t: &mut u32, u: &impl Copy, s: &S<u32>) { + opaque(*t); + opaque(*t); // this cannot reuse a, as x is &mut. + let z = &raw const *t; + unsafe { opaque(*z) }; + unsafe { opaque(*z) }; // this cannot reuse a, as x is *const. + let z = &raw mut *t; + unsafe { opaque(*z) }; + unsafe { opaque(*z) }; // this cannot reuse a, as x is *mut. + let z = &*t; + opaque(*z); + opaque(*z); // this can reuse, as `z` is immutable ref, Freeze and Copy. + opaque(&*z); // but not for a reborrow. + opaque(*u); + opaque(*u); // this cannot reuse, as `z` is not Freeze. + opaque(s.0); + opaque(s.0); // *s is not Copy, by (*s).0 is, so we can reuse. +} + +fn slices() { + let s = "my favourite slice"; // This is a `Const::Slice` in MIR. + opaque(s); + let t = s; // This should be the same pointer, so cannot be a `Const::Slice`. + opaque(t); + assert_eq!(s.as_ptr(), t.as_ptr()); + let u = unsafe { std::mem::transmute::<&str, &[u8]>(s) }; + opaque(u); + assert_eq!(s.as_ptr(), u.as_ptr()); +} + +fn main() { + subexpression_elimination(2, 4, 5); + wrap_unwrap(5); + repeated_index::<u32, 7>(5, 3); + arithmetic(5); + arithmetic_checked(5); + arithmetic_float(5.); + cast(); + multiple_branches(true, 5, 9); + references(5); + dereferences(&mut 5, &6, &S(7)); + slices(); +} + +#[inline(never)] +fn opaque(_: impl Sized) {} + +// EMIT_MIR gvn.subexpression_elimination.GVN.diff +// EMIT_MIR gvn.wrap_unwrap.GVN.diff +// EMIT_MIR gvn.repeated_index.GVN.diff +// EMIT_MIR gvn.arithmetic.GVN.diff +// EMIT_MIR gvn.arithmetic_checked.GVN.diff +// EMIT_MIR gvn.arithmetic_float.GVN.diff +// EMIT_MIR gvn.cast.GVN.diff +// EMIT_MIR gvn.multiple_branches.GVN.diff +// EMIT_MIR gvn.references.GVN.diff +// EMIT_MIR gvn.dereferences.GVN.diff +// EMIT_MIR gvn.slices.GVN.diff diff --git a/tests/mir-opt/gvn.slices.GVN.panic-abort.diff b/tests/mir-opt/gvn.slices.GVN.panic-abort.diff new file mode 100644 index 00000000000..de3d28d0575 --- /dev/null +++ b/tests/mir-opt/gvn.slices.GVN.panic-abort.diff @@ -0,0 +1,275 @@ +- // MIR for `slices` before GVN ++ // MIR for `slices` after GVN + + fn slices() -> () { + let mut _0: (); + let _1: &str; + let _2: (); + let mut _3: &str; + let _5: (); + let mut _6: &str; + let _7: (); + let mut _8: (&*const u8, &*const u8); + let mut _9: &*const u8; + let _10: *const u8; + let mut _11: &str; + let mut _12: &*const u8; + let _13: *const u8; + let mut _14: &str; + let mut _17: bool; + let mut _18: *const u8; + let mut _19: *const u8; + let mut _20: !; + let _22: !; + let mut _23: core::panicking::AssertKind; + let mut _24: &*const u8; + let _25: &*const u8; + let mut _26: &*const u8; + let _27: &*const u8; + let mut _28: std::option::Option<std::fmt::Arguments<'_>>; + let mut _30: &str; + let _31: (); + let mut _32: &[u8]; + let _33: (); + let mut _34: (&*const u8, &*const u8); + let mut _35: &*const u8; + let _36: *const u8; + let mut _37: &str; + let mut _38: &*const u8; + let _39: *const u8; + let mut _40: &[u8]; + let mut _43: bool; + let mut _44: *const u8; + let mut _45: *const u8; + let mut _46: !; + let _48: !; + let mut _49: core::panicking::AssertKind; + let mut _50: &*const u8; + let _51: &*const u8; + let mut _52: &*const u8; + let _53: &*const u8; + let mut _54: std::option::Option<std::fmt::Arguments<'_>>; + scope 1 { + debug s => _1; + let _4: &str; + scope 2 { + debug t => _4; + let _15: &*const u8; + let _16: &*const u8; + let _29: &[u8]; + scope 3 { + debug left_val => _15; + debug right_val => _16; + let _21: core::panicking::AssertKind; + scope 4 { + debug kind => _21; + } + } + scope 5 { + debug u => _29; + let _41: &*const u8; + let _42: &*const u8; + scope 7 { + debug left_val => _41; + debug right_val => _42; + let _47: core::panicking::AssertKind; + scope 8 { + debug kind => _47; + } + } + } + scope 6 { + } + } + } + + bb0: { +- StorageLive(_1); + _1 = const "my favourite slice"; + StorageLive(_2); +- StorageLive(_3); +- _3 = _1; +- _2 = opaque::<&str>(move _3) -> [return: bb1, unwind unreachable]; ++ _2 = opaque::<&str>(_1) -> [return: bb1, unwind unreachable]; + } + + bb1: { +- StorageDead(_3); + StorageDead(_2); + StorageLive(_4); + _4 = _1; + StorageLive(_5); +- StorageLive(_6); +- _6 = _4; +- _5 = opaque::<&str>(move _6) -> [return: bb2, unwind unreachable]; ++ _5 = opaque::<&str>(_1) -> [return: bb2, unwind unreachable]; + } + + bb2: { +- StorageDead(_6); + StorageDead(_5); +- StorageLive(_7); + StorageLive(_8); + StorageLive(_9); + StorageLive(_10); + StorageLive(_11); + _11 = &(*_1); + _10 = core::str::<impl str>::as_ptr(move _11) -> [return: bb3, unwind unreachable]; + } + + bb3: { + StorageDead(_11); + _9 = &_10; + StorageLive(_12); + StorageLive(_13); + StorageLive(_14); + _14 = &(*_4); + _13 = core::str::<impl str>::as_ptr(move _14) -> [return: bb4, unwind unreachable]; + } + + bb4: { + StorageDead(_14); + _12 = &_13; + _8 = (move _9, move _12); + StorageDead(_12); + StorageDead(_9); + StorageLive(_15); + _15 = (_8.0: &*const u8); + StorageLive(_16); + _16 = (_8.1: &*const u8); + StorageLive(_17); + StorageLive(_18); + _18 = (*_15); + StorageLive(_19); + _19 = (*_16); + _17 = Eq(move _18, move _19); + switchInt(move _17) -> [0: bb6, otherwise: bb5]; + } + + bb5: { + StorageDead(_19); + StorageDead(_18); +- _7 = const (); + StorageDead(_17); + StorageDead(_16); + StorageDead(_15); + StorageDead(_13); + StorageDead(_10); + StorageDead(_8); +- StorageDead(_7); +- StorageLive(_29); + StorageLive(_30); + _30 = &(*_1); + _29 = move _30 as &[u8] (Transmute); + StorageDead(_30); + StorageLive(_31); +- StorageLive(_32); +- _32 = _29; +- _31 = opaque::<&[u8]>(move _32) -> [return: bb7, unwind unreachable]; ++ _31 = opaque::<&[u8]>(_29) -> [return: bb7, unwind unreachable]; + } + + bb6: { + StorageDead(_19); + StorageDead(_18); +- StorageLive(_21); + _21 = core::panicking::AssertKind::Eq; + StorageLive(_22); +- StorageLive(_23); +- _23 = move _21; + StorageLive(_24); + StorageLive(_25); + _25 = &(*_15); + _24 = &(*_25); + StorageLive(_26); + StorageLive(_27); + _27 = &(*_16); + _26 = &(*_27); + StorageLive(_28); + _28 = Option::<Arguments<'_>>::None; +- _22 = core::panicking::assert_failed::<*const u8, *const u8>(move _23, move _24, move _26, move _28) -> unwind unreachable; ++ _22 = core::panicking::assert_failed::<*const u8, *const u8>(_21, move _24, move _26, move _28) -> unwind unreachable; + } + + bb7: { +- StorageDead(_32); + StorageDead(_31); +- StorageLive(_33); + StorageLive(_34); + StorageLive(_35); + StorageLive(_36); + StorageLive(_37); + _37 = &(*_1); + _36 = core::str::<impl str>::as_ptr(move _37) -> [return: bb8, unwind unreachable]; + } + + bb8: { + StorageDead(_37); + _35 = &_36; + StorageLive(_38); + StorageLive(_39); + StorageLive(_40); + _40 = &(*_29); + _39 = core::slice::<impl [u8]>::as_ptr(move _40) -> [return: bb9, unwind unreachable]; + } + + bb9: { + StorageDead(_40); + _38 = &_39; + _34 = (move _35, move _38); + StorageDead(_38); + StorageDead(_35); + StorageLive(_41); + _41 = (_34.0: &*const u8); + StorageLive(_42); + _42 = (_34.1: &*const u8); + StorageLive(_43); + StorageLive(_44); + _44 = (*_41); + StorageLive(_45); + _45 = (*_42); + _43 = Eq(move _44, move _45); + switchInt(move _43) -> [0: bb11, otherwise: bb10]; + } + + bb10: { + StorageDead(_45); + StorageDead(_44); +- _33 = const (); + StorageDead(_43); + StorageDead(_42); + StorageDead(_41); + StorageDead(_39); + StorageDead(_36); + StorageDead(_34); +- StorageDead(_33); + _0 = const (); +- StorageDead(_29); + StorageDead(_4); +- StorageDead(_1); + return; + } + + bb11: { + StorageDead(_45); + StorageDead(_44); +- StorageLive(_47); + _47 = core::panicking::AssertKind::Eq; + StorageLive(_48); +- StorageLive(_49); +- _49 = move _47; + StorageLive(_50); + StorageLive(_51); + _51 = &(*_41); + _50 = &(*_51); + StorageLive(_52); + StorageLive(_53); + _53 = &(*_42); + _52 = &(*_53); + StorageLive(_54); + _54 = Option::<Arguments<'_>>::None; +- _48 = core::panicking::assert_failed::<*const u8, *const u8>(move _49, move _50, move _52, move _54) -> unwind unreachable; ++ _48 = core::panicking::assert_failed::<*const u8, *const u8>(_47, move _50, move _52, move _54) -> unwind unreachable; + } + } + diff --git a/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff b/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff new file mode 100644 index 00000000000..f22bb25436f --- /dev/null +++ b/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff @@ -0,0 +1,275 @@ +- // MIR for `slices` before GVN ++ // MIR for `slices` after GVN + + fn slices() -> () { + let mut _0: (); + let _1: &str; + let _2: (); + let mut _3: &str; + let _5: (); + let mut _6: &str; + let _7: (); + let mut _8: (&*const u8, &*const u8); + let mut _9: &*const u8; + let _10: *const u8; + let mut _11: &str; + let mut _12: &*const u8; + let _13: *const u8; + let mut _14: &str; + let mut _17: bool; + let mut _18: *const u8; + let mut _19: *const u8; + let mut _20: !; + let _22: !; + let mut _23: core::panicking::AssertKind; + let mut _24: &*const u8; + let _25: &*const u8; + let mut _26: &*const u8; + let _27: &*const u8; + let mut _28: std::option::Option<std::fmt::Arguments<'_>>; + let mut _30: &str; + let _31: (); + let mut _32: &[u8]; + let _33: (); + let mut _34: (&*const u8, &*const u8); + let mut _35: &*const u8; + let _36: *const u8; + let mut _37: &str; + let mut _38: &*const u8; + let _39: *const u8; + let mut _40: &[u8]; + let mut _43: bool; + let mut _44: *const u8; + let mut _45: *const u8; + let mut _46: !; + let _48: !; + let mut _49: core::panicking::AssertKind; + let mut _50: &*const u8; + let _51: &*const u8; + let mut _52: &*const u8; + let _53: &*const u8; + let mut _54: std::option::Option<std::fmt::Arguments<'_>>; + scope 1 { + debug s => _1; + let _4: &str; + scope 2 { + debug t => _4; + let _15: &*const u8; + let _16: &*const u8; + let _29: &[u8]; + scope 3 { + debug left_val => _15; + debug right_val => _16; + let _21: core::panicking::AssertKind; + scope 4 { + debug kind => _21; + } + } + scope 5 { + debug u => _29; + let _41: &*const u8; + let _42: &*const u8; + scope 7 { + debug left_val => _41; + debug right_val => _42; + let _47: core::panicking::AssertKind; + scope 8 { + debug kind => _47; + } + } + } + scope 6 { + } + } + } + + bb0: { +- StorageLive(_1); + _1 = const "my favourite slice"; + StorageLive(_2); +- StorageLive(_3); +- _3 = _1; +- _2 = opaque::<&str>(move _3) -> [return: bb1, unwind continue]; ++ _2 = opaque::<&str>(_1) -> [return: bb1, unwind continue]; + } + + bb1: { +- StorageDead(_3); + StorageDead(_2); + StorageLive(_4); + _4 = _1; + StorageLive(_5); +- StorageLive(_6); +- _6 = _4; +- _5 = opaque::<&str>(move _6) -> [return: bb2, unwind continue]; ++ _5 = opaque::<&str>(_1) -> [return: bb2, unwind continue]; + } + + bb2: { +- StorageDead(_6); + StorageDead(_5); +- StorageLive(_7); + StorageLive(_8); + StorageLive(_9); + StorageLive(_10); + StorageLive(_11); + _11 = &(*_1); + _10 = core::str::<impl str>::as_ptr(move _11) -> [return: bb3, unwind continue]; + } + + bb3: { + StorageDead(_11); + _9 = &_10; + StorageLive(_12); + StorageLive(_13); + StorageLive(_14); + _14 = &(*_4); + _13 = core::str::<impl str>::as_ptr(move _14) -> [return: bb4, unwind continue]; + } + + bb4: { + StorageDead(_14); + _12 = &_13; + _8 = (move _9, move _12); + StorageDead(_12); + StorageDead(_9); + StorageLive(_15); + _15 = (_8.0: &*const u8); + StorageLive(_16); + _16 = (_8.1: &*const u8); + StorageLive(_17); + StorageLive(_18); + _18 = (*_15); + StorageLive(_19); + _19 = (*_16); + _17 = Eq(move _18, move _19); + switchInt(move _17) -> [0: bb6, otherwise: bb5]; + } + + bb5: { + StorageDead(_19); + StorageDead(_18); +- _7 = const (); + StorageDead(_17); + StorageDead(_16); + StorageDead(_15); + StorageDead(_13); + StorageDead(_10); + StorageDead(_8); +- StorageDead(_7); +- StorageLive(_29); + StorageLive(_30); + _30 = &(*_1); + _29 = move _30 as &[u8] (Transmute); + StorageDead(_30); + StorageLive(_31); +- StorageLive(_32); +- _32 = _29; +- _31 = opaque::<&[u8]>(move _32) -> [return: bb7, unwind continue]; ++ _31 = opaque::<&[u8]>(_29) -> [return: bb7, unwind continue]; + } + + bb6: { + StorageDead(_19); + StorageDead(_18); +- StorageLive(_21); + _21 = core::panicking::AssertKind::Eq; + StorageLive(_22); +- StorageLive(_23); +- _23 = move _21; + StorageLive(_24); + StorageLive(_25); + _25 = &(*_15); + _24 = &(*_25); + StorageLive(_26); + StorageLive(_27); + _27 = &(*_16); + _26 = &(*_27); + StorageLive(_28); + _28 = Option::<Arguments<'_>>::None; +- _22 = core::panicking::assert_failed::<*const u8, *const u8>(move _23, move _24, move _26, move _28) -> unwind continue; ++ _22 = core::panicking::assert_failed::<*const u8, *const u8>(_21, move _24, move _26, move _28) -> unwind continue; + } + + bb7: { +- StorageDead(_32); + StorageDead(_31); +- StorageLive(_33); + StorageLive(_34); + StorageLive(_35); + StorageLive(_36); + StorageLive(_37); + _37 = &(*_1); + _36 = core::str::<impl str>::as_ptr(move _37) -> [return: bb8, unwind continue]; + } + + bb8: { + StorageDead(_37); + _35 = &_36; + StorageLive(_38); + StorageLive(_39); + StorageLive(_40); + _40 = &(*_29); + _39 = core::slice::<impl [u8]>::as_ptr(move _40) -> [return: bb9, unwind continue]; + } + + bb9: { + StorageDead(_40); + _38 = &_39; + _34 = (move _35, move _38); + StorageDead(_38); + StorageDead(_35); + StorageLive(_41); + _41 = (_34.0: &*const u8); + StorageLive(_42); + _42 = (_34.1: &*const u8); + StorageLive(_43); + StorageLive(_44); + _44 = (*_41); + StorageLive(_45); + _45 = (*_42); + _43 = Eq(move _44, move _45); + switchInt(move _43) -> [0: bb11, otherwise: bb10]; + } + + bb10: { + StorageDead(_45); + StorageDead(_44); +- _33 = const (); + StorageDead(_43); + StorageDead(_42); + StorageDead(_41); + StorageDead(_39); + StorageDead(_36); + StorageDead(_34); +- StorageDead(_33); + _0 = const (); +- StorageDead(_29); + StorageDead(_4); +- StorageDead(_1); + return; + } + + bb11: { + StorageDead(_45); + StorageDead(_44); +- StorageLive(_47); + _47 = core::panicking::AssertKind::Eq; + StorageLive(_48); +- StorageLive(_49); +- _49 = move _47; + StorageLive(_50); + StorageLive(_51); + _51 = &(*_41); + _50 = &(*_51); + StorageLive(_52); + StorageLive(_53); + _53 = &(*_42); + _52 = &(*_53); + StorageLive(_54); + _54 = Option::<Arguments<'_>>::None; +- _48 = core::panicking::assert_failed::<*const u8, *const u8>(move _49, move _50, move _52, move _54) -> unwind continue; ++ _48 = core::panicking::assert_failed::<*const u8, *const u8>(_47, move _50, move _52, move _54) -> unwind continue; + } + } + diff --git a/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-abort.diff b/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-abort.diff new file mode 100644 index 00000000000..bf866e2f4d2 --- /dev/null +++ b/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-abort.diff @@ -0,0 +1,883 @@ +- // MIR for `subexpression_elimination` before GVN ++ // MIR for `subexpression_elimination` after GVN + + fn subexpression_elimination(_1: u64, _2: u64, _3: u64) -> () { + debug x => _1; + debug y => _2; + debug z => _3; + let mut _0: (); + let _4: (); + let mut _5: u64; + let mut _6: u64; + let mut _7: u64; + let _8: (); + let mut _9: u64; + let mut _10: u64; + let mut _11: u64; + let _12: (); + let mut _13: u64; + let mut _14: u64; + let mut _15: u64; + let _16: (); + let mut _17: u64; + let mut _18: u64; + let mut _19: u64; + let mut _20: bool; + let _21: (); + let mut _22: u64; + let mut _23: u64; + let mut _24: u64; + let mut _25: bool; + let _26: (); + let mut _27: u64; + let mut _28: u64; + let mut _29: u64; + let _30: (); + let mut _31: u64; + let mut _32: u64; + let mut _33: u64; + let _34: (); + let mut _35: u64; + let mut _36: u64; + let mut _37: u64; + let _38: (); + let mut _39: u64; + let mut _40: u64; + let mut _41: u64; + let _42: (); + let mut _43: u64; + let mut _44: u64; + let mut _45: u64; + let _46: (); + let mut _47: u32; + let mut _48: u64; + let _49: (); + let mut _50: f32; + let mut _51: u64; + let _52: (); + let mut _53: S<u64>; + let mut _54: u64; + let _55: (); + let mut _56: u64; + let mut _57: S<u64>; + let mut _58: u64; + let _59: (); + let mut _60: u64; + let mut _61: u64; + let mut _62: u64; + let mut _63: u64; + let mut _64: u64; + let _65: (); + let mut _66: u64; + let mut _67: u64; + let mut _68: u64; + let mut _69: u64; + let mut _70: u64; + let _71: (); + let mut _72: u64; + let mut _73: u64; + let mut _74: u64; + let mut _75: u64; + let mut _76: u64; + let _77: (); + let mut _78: u64; + let mut _79: u64; + let mut _80: u64; + let mut _81: u64; + let mut _82: bool; + let mut _83: u64; + let _84: (); + let mut _85: u64; + let mut _86: u64; + let mut _87: u64; + let mut _88: u64; + let mut _89: bool; + let mut _90: u64; + let _91: (); + let mut _92: u64; + let mut _93: u64; + let mut _94: u64; + let mut _95: u64; + let mut _96: u64; + let _97: (); + let mut _98: u64; + let mut _99: u64; + let mut _100: u64; + let mut _101: u64; + let mut _102: u64; + let _103: (); + let mut _104: u64; + let mut _105: u64; + let mut _106: u64; + let mut _107: u64; + let mut _108: u64; + let _109: (); + let mut _110: u64; + let mut _111: u64; + let mut _112: u64; + let mut _113: u64; + let mut _114: u64; + let _115: (); + let mut _116: u64; + let mut _117: u64; + let mut _118: u64; + let mut _119: u64; + let mut _120: u64; + let _121: (); + let mut _122: S<u64>; + let mut _123: u64; + let _124: (); + let mut _125: u64; + let mut _126: S<u64>; + let mut _127: u64; + let _128: &u64; + let _129: (); + let mut _130: u64; + let mut _131: u64; + let mut _132: u64; + let _133: (); + let mut _134: u64; + let mut _135: u64; + let mut _136: u64; + let _138: (); + let mut _139: u64; + let mut _140: u64; + let mut _141: u64; + let _142: (); + let mut _143: u64; + let mut _144: u64; + let mut _145: u64; + let _146: (); + let _148: (); + let mut _149: u64; + let mut _150: u64; + let mut _151: u64; + let _152: (); + let mut _153: u64; + let mut _154: u64; + let mut _155: u64; + let _157: (); + let mut _158: u64; + let mut _159: u64; + let mut _160: u64; + let _161: (); + let mut _162: u64; + let mut _163: u64; + let mut _164: u64; + let _166: (); + let mut _167: u64; + let mut _168: u64; + let mut _169: u64; + let _170: (); + let mut _171: u64; + let mut _172: u64; + let mut _173: u64; + scope 1 { + debug a => _128; + let _137: &mut u64; + scope 2 { + debug b => _137; + let _165: &u64; + scope 3 { + let _147: *const u64; + scope 4 { + debug c => _147; + let _156: *mut u64; + scope 5 { + debug d => _156; + } + } + } + scope 6 { + debug e => _165; + } + } + } + + bb0: { + StorageLive(_4); +- StorageLive(_5); +- StorageLive(_6); +- _6 = _1; +- StorageLive(_7); +- _7 = _2; +- _5 = Add(move _6, move _7); +- StorageDead(_7); +- StorageDead(_6); +- _4 = opaque::<u64>(move _5) -> [return: bb1, unwind unreachable]; ++ _5 = Add(_1, _2); ++ _4 = opaque::<u64>(_5) -> [return: bb1, unwind unreachable]; + } + + bb1: { +- StorageDead(_5); + StorageDead(_4); + StorageLive(_8); +- StorageLive(_9); +- StorageLive(_10); +- _10 = _1; +- StorageLive(_11); +- _11 = _2; +- _9 = Mul(move _10, move _11); +- StorageDead(_11); +- StorageDead(_10); +- _8 = opaque::<u64>(move _9) -> [return: bb2, unwind unreachable]; ++ _9 = Mul(_1, _2); ++ _8 = opaque::<u64>(_9) -> [return: bb2, unwind unreachable]; + } + + bb2: { +- StorageDead(_9); + StorageDead(_8); + StorageLive(_12); +- StorageLive(_13); +- StorageLive(_14); +- _14 = _1; +- StorageLive(_15); +- _15 = _2; +- _13 = Sub(move _14, move _15); +- StorageDead(_15); +- StorageDead(_14); +- _12 = opaque::<u64>(move _13) -> [return: bb3, unwind unreachable]; ++ _13 = Sub(_1, _2); ++ _12 = opaque::<u64>(_13) -> [return: bb3, unwind unreachable]; + } + + bb3: { +- StorageDead(_13); + StorageDead(_12); + StorageLive(_16); +- StorageLive(_17); +- StorageLive(_18); +- _18 = _1; +- StorageLive(_19); +- _19 = _2; +- _20 = Eq(_19, const 0_u64); +- assert(!move _20, "attempt to divide `{}` by zero", _18) -> [success: bb4, unwind unreachable]; ++ _20 = Eq(_2, const 0_u64); ++ assert(!_20, "attempt to divide `{}` by zero", _1) -> [success: bb4, unwind unreachable]; + } + + bb4: { +- _17 = Div(move _18, move _19); +- StorageDead(_19); +- StorageDead(_18); +- _16 = opaque::<u64>(move _17) -> [return: bb5, unwind unreachable]; ++ _17 = Div(_1, _2); ++ _16 = opaque::<u64>(_17) -> [return: bb5, unwind unreachable]; + } + + bb5: { +- StorageDead(_17); + StorageDead(_16); + StorageLive(_21); +- StorageLive(_22); +- StorageLive(_23); +- _23 = _1; +- StorageLive(_24); +- _24 = _2; +- _25 = Eq(_24, const 0_u64); +- assert(!move _25, "attempt to calculate the remainder of `{}` with a divisor of zero", _23) -> [success: bb6, unwind unreachable]; ++ assert(!_20, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb6, unwind unreachable]; + } + + bb6: { +- _22 = Rem(move _23, move _24); +- StorageDead(_24); +- StorageDead(_23); +- _21 = opaque::<u64>(move _22) -> [return: bb7, unwind unreachable]; ++ _22 = Rem(_1, _2); ++ _21 = opaque::<u64>(_22) -> [return: bb7, unwind unreachable]; + } + + bb7: { +- StorageDead(_22); + StorageDead(_21); + StorageLive(_26); +- StorageLive(_27); +- StorageLive(_28); +- _28 = _1; +- StorageLive(_29); +- _29 = _2; +- _27 = BitAnd(move _28, move _29); +- StorageDead(_29); +- StorageDead(_28); +- _26 = opaque::<u64>(move _27) -> [return: bb8, unwind unreachable]; ++ _27 = BitAnd(_1, _2); ++ _26 = opaque::<u64>(_27) -> [return: bb8, unwind unreachable]; + } + + bb8: { +- StorageDead(_27); + StorageDead(_26); + StorageLive(_30); +- StorageLive(_31); +- StorageLive(_32); +- _32 = _1; +- StorageLive(_33); +- _33 = _2; +- _31 = BitOr(move _32, move _33); +- StorageDead(_33); +- StorageDead(_32); +- _30 = opaque::<u64>(move _31) -> [return: bb9, unwind unreachable]; ++ _31 = BitOr(_1, _2); ++ _30 = opaque::<u64>(_31) -> [return: bb9, unwind unreachable]; + } + + bb9: { +- StorageDead(_31); + StorageDead(_30); + StorageLive(_34); +- StorageLive(_35); +- StorageLive(_36); +- _36 = _1; +- StorageLive(_37); +- _37 = _2; +- _35 = BitXor(move _36, move _37); +- StorageDead(_37); +- StorageDead(_36); +- _34 = opaque::<u64>(move _35) -> [return: bb10, unwind unreachable]; ++ _35 = BitXor(_1, _2); ++ _34 = opaque::<u64>(_35) -> [return: bb10, unwind unreachable]; + } + + bb10: { +- StorageDead(_35); + StorageDead(_34); + StorageLive(_38); +- StorageLive(_39); +- StorageLive(_40); +- _40 = _1; +- StorageLive(_41); +- _41 = _2; +- _39 = Shl(move _40, move _41); +- StorageDead(_41); +- StorageDead(_40); +- _38 = opaque::<u64>(move _39) -> [return: bb11, unwind unreachable]; ++ _39 = Shl(_1, _2); ++ _38 = opaque::<u64>(_39) -> [return: bb11, unwind unreachable]; + } + + bb11: { +- StorageDead(_39); + StorageDead(_38); + StorageLive(_42); +- StorageLive(_43); +- StorageLive(_44); +- _44 = _1; +- StorageLive(_45); +- _45 = _2; +- _43 = Shr(move _44, move _45); +- StorageDead(_45); +- StorageDead(_44); +- _42 = opaque::<u64>(move _43) -> [return: bb12, unwind unreachable]; ++ _43 = Shr(_1, _2); ++ _42 = opaque::<u64>(_43) -> [return: bb12, unwind unreachable]; + } + + bb12: { +- StorageDead(_43); + StorageDead(_42); + StorageLive(_46); + StorageLive(_47); +- StorageLive(_48); +- _48 = _1; +- _47 = move _48 as u32 (IntToInt); +- StorageDead(_48); ++ _47 = _1 as u32 (IntToInt); + _46 = opaque::<u32>(move _47) -> [return: bb13, unwind unreachable]; + } + + bb13: { + StorageDead(_47); + StorageDead(_46); + StorageLive(_49); + StorageLive(_50); +- StorageLive(_51); +- _51 = _1; +- _50 = move _51 as f32 (IntToFloat); +- StorageDead(_51); ++ _50 = _1 as f32 (IntToFloat); + _49 = opaque::<f32>(move _50) -> [return: bb14, unwind unreachable]; + } + + bb14: { + StorageDead(_50); + StorageDead(_49); + StorageLive(_52); +- StorageLive(_53); +- StorageLive(_54); +- _54 = _1; +- _53 = S::<u64>(move _54); +- StorageDead(_54); +- _52 = opaque::<S<u64>>(move _53) -> [return: bb15, unwind unreachable]; ++ _53 = S::<u64>(_1); ++ _52 = opaque::<S<u64>>(_53) -> [return: bb15, unwind unreachable]; + } + + bb15: { +- StorageDead(_53); + StorageDead(_52); + StorageLive(_55); +- StorageLive(_56); +- StorageLive(_57); +- StorageLive(_58); +- _58 = _1; +- _57 = S::<u64>(move _58); +- StorageDead(_58); +- _56 = (_57.0: u64); +- _55 = opaque::<u64>(move _56) -> [return: bb16, unwind unreachable]; ++ _56 = (_53.0: u64); ++ _55 = opaque::<u64>(_56) -> [return: bb16, unwind unreachable]; + } + + bb16: { +- StorageDead(_56); +- StorageDead(_57); + StorageDead(_55); + StorageLive(_59); + StorageLive(_60); +- StorageLive(_61); +- StorageLive(_62); +- _62 = _1; +- StorageLive(_63); +- _63 = _2; +- _61 = Add(move _62, move _63); +- StorageDead(_63); +- StorageDead(_62); + StorageLive(_64); + _64 = _3; +- _60 = Add(move _61, move _64); ++ _60 = Add(_5, move _64); + StorageDead(_64); +- StorageDead(_61); + _59 = opaque::<u64>(move _60) -> [return: bb17, unwind unreachable]; + } + + bb17: { + StorageDead(_60); + StorageDead(_59); + StorageLive(_65); + StorageLive(_66); +- StorageLive(_67); +- StorageLive(_68); +- _68 = _1; +- StorageLive(_69); +- _69 = _2; +- _67 = Mul(move _68, move _69); +- StorageDead(_69); +- StorageDead(_68); + StorageLive(_70); + _70 = _3; +- _66 = Add(move _67, move _70); ++ _66 = Add(_9, move _70); + StorageDead(_70); +- StorageDead(_67); + _65 = opaque::<u64>(move _66) -> [return: bb18, unwind unreachable]; + } + + bb18: { + StorageDead(_66); + StorageDead(_65); + StorageLive(_71); + StorageLive(_72); +- StorageLive(_73); +- StorageLive(_74); +- _74 = _1; +- StorageLive(_75); +- _75 = _2; +- _73 = Sub(move _74, move _75); +- StorageDead(_75); +- StorageDead(_74); + StorageLive(_76); + _76 = _3; +- _72 = Add(move _73, move _76); ++ _72 = Add(_13, move _76); + StorageDead(_76); +- StorageDead(_73); + _71 = opaque::<u64>(move _72) -> [return: bb19, unwind unreachable]; + } + + bb19: { + StorageDead(_72); + StorageDead(_71); + StorageLive(_77); + StorageLive(_78); +- StorageLive(_79); +- StorageLive(_80); +- _80 = _1; +- StorageLive(_81); +- _81 = _2; +- _82 = Eq(_81, const 0_u64); +- assert(!move _82, "attempt to divide `{}` by zero", _80) -> [success: bb20, unwind unreachable]; ++ assert(!_20, "attempt to divide `{}` by zero", _1) -> [success: bb20, unwind unreachable]; + } + + bb20: { +- _79 = Div(move _80, move _81); +- StorageDead(_81); +- StorageDead(_80); + StorageLive(_83); + _83 = _3; +- _78 = Add(move _79, move _83); ++ _78 = Add(_17, move _83); + StorageDead(_83); +- StorageDead(_79); + _77 = opaque::<u64>(move _78) -> [return: bb21, unwind unreachable]; + } + + bb21: { + StorageDead(_78); + StorageDead(_77); + StorageLive(_84); + StorageLive(_85); +- StorageLive(_86); +- StorageLive(_87); +- _87 = _1; +- StorageLive(_88); +- _88 = _2; +- _89 = Eq(_88, const 0_u64); +- assert(!move _89, "attempt to calculate the remainder of `{}` with a divisor of zero", _87) -> [success: bb22, unwind unreachable]; ++ assert(!_20, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb22, unwind unreachable]; + } + + bb22: { +- _86 = Rem(move _87, move _88); +- StorageDead(_88); +- StorageDead(_87); + StorageLive(_90); + _90 = _3; +- _85 = Add(move _86, move _90); ++ _85 = Add(_22, move _90); + StorageDead(_90); +- StorageDead(_86); + _84 = opaque::<u64>(move _85) -> [return: bb23, unwind unreachable]; + } + + bb23: { + StorageDead(_85); + StorageDead(_84); + StorageLive(_91); + StorageLive(_92); +- StorageLive(_93); +- StorageLive(_94); +- _94 = _1; +- StorageLive(_95); +- _95 = _2; +- _93 = BitAnd(move _94, move _95); +- StorageDead(_95); +- StorageDead(_94); + StorageLive(_96); + _96 = _3; +- _92 = Add(move _93, move _96); ++ _92 = Add(_27, move _96); + StorageDead(_96); +- StorageDead(_93); + _91 = opaque::<u64>(move _92) -> [return: bb24, unwind unreachable]; + } + + bb24: { + StorageDead(_92); + StorageDead(_91); + StorageLive(_97); + StorageLive(_98); +- StorageLive(_99); +- StorageLive(_100); +- _100 = _1; +- StorageLive(_101); +- _101 = _2; +- _99 = BitOr(move _100, move _101); +- StorageDead(_101); +- StorageDead(_100); + StorageLive(_102); + _102 = _3; +- _98 = Add(move _99, move _102); ++ _98 = Add(_31, move _102); + StorageDead(_102); +- StorageDead(_99); + _97 = opaque::<u64>(move _98) -> [return: bb25, unwind unreachable]; + } + + bb25: { + StorageDead(_98); + StorageDead(_97); + StorageLive(_103); + StorageLive(_104); +- StorageLive(_105); +- StorageLive(_106); +- _106 = _1; +- StorageLive(_107); +- _107 = _2; +- _105 = BitXor(move _106, move _107); +- StorageDead(_107); +- StorageDead(_106); + StorageLive(_108); + _108 = _3; +- _104 = Add(move _105, move _108); ++ _104 = Add(_35, move _108); + StorageDead(_108); +- StorageDead(_105); + _103 = opaque::<u64>(move _104) -> [return: bb26, unwind unreachable]; + } + + bb26: { + StorageDead(_104); + StorageDead(_103); + StorageLive(_109); + StorageLive(_110); +- StorageLive(_111); +- StorageLive(_112); +- _112 = _1; +- StorageLive(_113); +- _113 = _2; +- _111 = Shl(move _112, move _113); +- StorageDead(_113); +- StorageDead(_112); + StorageLive(_114); + _114 = _3; +- _110 = Add(move _111, move _114); ++ _110 = Add(_39, move _114); + StorageDead(_114); +- StorageDead(_111); + _109 = opaque::<u64>(move _110) -> [return: bb27, unwind unreachable]; + } + + bb27: { + StorageDead(_110); + StorageDead(_109); + StorageLive(_115); + StorageLive(_116); +- StorageLive(_117); +- StorageLive(_118); +- _118 = _1; +- StorageLive(_119); +- _119 = _2; +- _117 = Shr(move _118, move _119); +- StorageDead(_119); +- StorageDead(_118); + StorageLive(_120); + _120 = _3; +- _116 = Add(move _117, move _120); ++ _116 = Add(_43, move _120); + StorageDead(_120); +- StorageDead(_117); + _115 = opaque::<u64>(move _116) -> [return: bb28, unwind unreachable]; + } + + bb28: { + StorageDead(_116); + StorageDead(_115); + StorageLive(_121); +- StorageLive(_122); +- StorageLive(_123); +- _123 = _1; +- _122 = S::<u64>(move _123); +- StorageDead(_123); +- _121 = opaque::<S<u64>>(move _122) -> [return: bb29, unwind unreachable]; ++ _121 = opaque::<S<u64>>(_53) -> [return: bb29, unwind unreachable]; + } + + bb29: { +- StorageDead(_122); + StorageDead(_121); + StorageLive(_124); +- StorageLive(_125); +- StorageLive(_126); +- StorageLive(_127); +- _127 = _1; +- _126 = S::<u64>(move _127); +- StorageDead(_127); +- _125 = (_126.0: u64); +- _124 = opaque::<u64>(move _125) -> [return: bb30, unwind unreachable]; ++ _124 = opaque::<u64>(_56) -> [return: bb30, unwind unreachable]; + } + + bb30: { +- StorageDead(_125); +- StorageDead(_126); + StorageDead(_124); + StorageLive(_128); + _128 = &_3; + StorageLive(_129); +- StorageLive(_130); +- StorageLive(_131); + _131 = (*_128); +- StorageLive(_132); +- _132 = _1; +- _130 = Add(move _131, move _132); +- StorageDead(_132); +- StorageDead(_131); +- _129 = opaque::<u64>(move _130) -> [return: bb31, unwind unreachable]; ++ _130 = Add(_131, _1); ++ _129 = opaque::<u64>(_130) -> [return: bb31, unwind unreachable]; + } + + bb31: { +- StorageDead(_130); + StorageDead(_129); + StorageLive(_133); +- StorageLive(_134); +- StorageLive(_135); +- _135 = (*_128); +- StorageLive(_136); +- _136 = _1; +- _134 = Add(move _135, move _136); +- StorageDead(_136); +- StorageDead(_135); +- _133 = opaque::<u64>(move _134) -> [return: bb32, unwind unreachable]; ++ _133 = opaque::<u64>(_130) -> [return: bb32, unwind unreachable]; + } + + bb32: { +- StorageDead(_134); + StorageDead(_133); + StorageLive(_137); + _137 = &mut _3; + StorageLive(_138); + StorageLive(_139); + StorageLive(_140); + _140 = (*_137); +- StorageLive(_141); +- _141 = _1; +- _139 = Add(move _140, move _141); +- StorageDead(_141); ++ _139 = Add(move _140, _1); + StorageDead(_140); + _138 = opaque::<u64>(move _139) -> [return: bb33, unwind unreachable]; + } + + bb33: { + StorageDead(_139); + StorageDead(_138); + StorageLive(_142); + StorageLive(_143); + StorageLive(_144); + _144 = (*_137); +- StorageLive(_145); +- _145 = _1; +- _143 = Add(move _144, move _145); +- StorageDead(_145); ++ _143 = Add(move _144, _1); + StorageDead(_144); + _142 = opaque::<u64>(move _143) -> [return: bb34, unwind unreachable]; + } + + bb34: { + StorageDead(_143); + StorageDead(_142); +- StorageLive(_146); + StorageLive(_147); + _147 = &raw const _3; + StorageLive(_148); + StorageLive(_149); + StorageLive(_150); + _150 = (*_147); +- StorageLive(_151); +- _151 = _1; +- _149 = Add(move _150, move _151); +- StorageDead(_151); ++ _149 = Add(move _150, _1); + StorageDead(_150); + _148 = opaque::<u64>(move _149) -> [return: bb35, unwind unreachable]; + } + + bb35: { + StorageDead(_149); + StorageDead(_148); + StorageLive(_152); + StorageLive(_153); + StorageLive(_154); + _154 = (*_147); +- StorageLive(_155); +- _155 = _1; +- _153 = Add(move _154, move _155); +- StorageDead(_155); ++ _153 = Add(move _154, _1); + StorageDead(_154); + _152 = opaque::<u64>(move _153) -> [return: bb36, unwind unreachable]; + } + + bb36: { + StorageDead(_153); + StorageDead(_152); + StorageLive(_156); + _156 = &raw mut _3; + StorageLive(_157); + StorageLive(_158); + StorageLive(_159); + _159 = (*_156); +- StorageLive(_160); +- _160 = _1; +- _158 = Add(move _159, move _160); +- StorageDead(_160); ++ _158 = Add(move _159, _1); + StorageDead(_159); + _157 = opaque::<u64>(move _158) -> [return: bb37, unwind unreachable]; + } + + bb37: { + StorageDead(_158); + StorageDead(_157); + StorageLive(_161); + StorageLive(_162); + StorageLive(_163); + _163 = (*_156); +- StorageLive(_164); +- _164 = _1; +- _162 = Add(move _163, move _164); +- StorageDead(_164); ++ _162 = Add(move _163, _1); + StorageDead(_163); + _161 = opaque::<u64>(move _162) -> [return: bb38, unwind unreachable]; + } + + bb38: { + StorageDead(_162); + StorageDead(_161); +- _146 = const (); + StorageDead(_156); + StorageDead(_147); +- StorageDead(_146); + StorageLive(_165); + _165 = &_3; + StorageLive(_166); +- StorageLive(_167); +- StorageLive(_168); + _168 = (*_165); +- StorageLive(_169); +- _169 = _1; +- _167 = Add(move _168, move _169); +- StorageDead(_169); +- StorageDead(_168); +- _166 = opaque::<u64>(move _167) -> [return: bb39, unwind unreachable]; ++ _167 = Add(_168, _1); ++ _166 = opaque::<u64>(_167) -> [return: bb39, unwind unreachable]; + } + + bb39: { +- StorageDead(_167); + StorageDead(_166); + StorageLive(_170); +- StorageLive(_171); +- StorageLive(_172); +- _172 = (*_165); +- StorageLive(_173); +- _173 = _1; +- _171 = Add(move _172, move _173); +- StorageDead(_173); +- StorageDead(_172); +- _170 = opaque::<u64>(move _171) -> [return: bb40, unwind unreachable]; ++ _170 = opaque::<u64>(_167) -> [return: bb40, unwind unreachable]; + } + + bb40: { +- StorageDead(_171); + StorageDead(_170); + _0 = const (); + StorageDead(_165); + StorageDead(_137); + StorageDead(_128); + return; + } + } + diff --git a/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-unwind.diff b/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-unwind.diff new file mode 100644 index 00000000000..68b05290719 --- /dev/null +++ b/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-unwind.diff @@ -0,0 +1,883 @@ +- // MIR for `subexpression_elimination` before GVN ++ // MIR for `subexpression_elimination` after GVN + + fn subexpression_elimination(_1: u64, _2: u64, _3: u64) -> () { + debug x => _1; + debug y => _2; + debug z => _3; + let mut _0: (); + let _4: (); + let mut _5: u64; + let mut _6: u64; + let mut _7: u64; + let _8: (); + let mut _9: u64; + let mut _10: u64; + let mut _11: u64; + let _12: (); + let mut _13: u64; + let mut _14: u64; + let mut _15: u64; + let _16: (); + let mut _17: u64; + let mut _18: u64; + let mut _19: u64; + let mut _20: bool; + let _21: (); + let mut _22: u64; + let mut _23: u64; + let mut _24: u64; + let mut _25: bool; + let _26: (); + let mut _27: u64; + let mut _28: u64; + let mut _29: u64; + let _30: (); + let mut _31: u64; + let mut _32: u64; + let mut _33: u64; + let _34: (); + let mut _35: u64; + let mut _36: u64; + let mut _37: u64; + let _38: (); + let mut _39: u64; + let mut _40: u64; + let mut _41: u64; + let _42: (); + let mut _43: u64; + let mut _44: u64; + let mut _45: u64; + let _46: (); + let mut _47: u32; + let mut _48: u64; + let _49: (); + let mut _50: f32; + let mut _51: u64; + let _52: (); + let mut _53: S<u64>; + let mut _54: u64; + let _55: (); + let mut _56: u64; + let mut _57: S<u64>; + let mut _58: u64; + let _59: (); + let mut _60: u64; + let mut _61: u64; + let mut _62: u64; + let mut _63: u64; + let mut _64: u64; + let _65: (); + let mut _66: u64; + let mut _67: u64; + let mut _68: u64; + let mut _69: u64; + let mut _70: u64; + let _71: (); + let mut _72: u64; + let mut _73: u64; + let mut _74: u64; + let mut _75: u64; + let mut _76: u64; + let _77: (); + let mut _78: u64; + let mut _79: u64; + let mut _80: u64; + let mut _81: u64; + let mut _82: bool; + let mut _83: u64; + let _84: (); + let mut _85: u64; + let mut _86: u64; + let mut _87: u64; + let mut _88: u64; + let mut _89: bool; + let mut _90: u64; + let _91: (); + let mut _92: u64; + let mut _93: u64; + let mut _94: u64; + let mut _95: u64; + let mut _96: u64; + let _97: (); + let mut _98: u64; + let mut _99: u64; + let mut _100: u64; + let mut _101: u64; + let mut _102: u64; + let _103: (); + let mut _104: u64; + let mut _105: u64; + let mut _106: u64; + let mut _107: u64; + let mut _108: u64; + let _109: (); + let mut _110: u64; + let mut _111: u64; + let mut _112: u64; + let mut _113: u64; + let mut _114: u64; + let _115: (); + let mut _116: u64; + let mut _117: u64; + let mut _118: u64; + let mut _119: u64; + let mut _120: u64; + let _121: (); + let mut _122: S<u64>; + let mut _123: u64; + let _124: (); + let mut _125: u64; + let mut _126: S<u64>; + let mut _127: u64; + let _128: &u64; + let _129: (); + let mut _130: u64; + let mut _131: u64; + let mut _132: u64; + let _133: (); + let mut _134: u64; + let mut _135: u64; + let mut _136: u64; + let _138: (); + let mut _139: u64; + let mut _140: u64; + let mut _141: u64; + let _142: (); + let mut _143: u64; + let mut _144: u64; + let mut _145: u64; + let _146: (); + let _148: (); + let mut _149: u64; + let mut _150: u64; + let mut _151: u64; + let _152: (); + let mut _153: u64; + let mut _154: u64; + let mut _155: u64; + let _157: (); + let mut _158: u64; + let mut _159: u64; + let mut _160: u64; + let _161: (); + let mut _162: u64; + let mut _163: u64; + let mut _164: u64; + let _166: (); + let mut _167: u64; + let mut _168: u64; + let mut _169: u64; + let _170: (); + let mut _171: u64; + let mut _172: u64; + let mut _173: u64; + scope 1 { + debug a => _128; + let _137: &mut u64; + scope 2 { + debug b => _137; + let _165: &u64; + scope 3 { + let _147: *const u64; + scope 4 { + debug c => _147; + let _156: *mut u64; + scope 5 { + debug d => _156; + } + } + } + scope 6 { + debug e => _165; + } + } + } + + bb0: { + StorageLive(_4); +- StorageLive(_5); +- StorageLive(_6); +- _6 = _1; +- StorageLive(_7); +- _7 = _2; +- _5 = Add(move _6, move _7); +- StorageDead(_7); +- StorageDead(_6); +- _4 = opaque::<u64>(move _5) -> [return: bb1, unwind continue]; ++ _5 = Add(_1, _2); ++ _4 = opaque::<u64>(_5) -> [return: bb1, unwind continue]; + } + + bb1: { +- StorageDead(_5); + StorageDead(_4); + StorageLive(_8); +- StorageLive(_9); +- StorageLive(_10); +- _10 = _1; +- StorageLive(_11); +- _11 = _2; +- _9 = Mul(move _10, move _11); +- StorageDead(_11); +- StorageDead(_10); +- _8 = opaque::<u64>(move _9) -> [return: bb2, unwind continue]; ++ _9 = Mul(_1, _2); ++ _8 = opaque::<u64>(_9) -> [return: bb2, unwind continue]; + } + + bb2: { +- StorageDead(_9); + StorageDead(_8); + StorageLive(_12); +- StorageLive(_13); +- StorageLive(_14); +- _14 = _1; +- StorageLive(_15); +- _15 = _2; +- _13 = Sub(move _14, move _15); +- StorageDead(_15); +- StorageDead(_14); +- _12 = opaque::<u64>(move _13) -> [return: bb3, unwind continue]; ++ _13 = Sub(_1, _2); ++ _12 = opaque::<u64>(_13) -> [return: bb3, unwind continue]; + } + + bb3: { +- StorageDead(_13); + StorageDead(_12); + StorageLive(_16); +- StorageLive(_17); +- StorageLive(_18); +- _18 = _1; +- StorageLive(_19); +- _19 = _2; +- _20 = Eq(_19, const 0_u64); +- assert(!move _20, "attempt to divide `{}` by zero", _18) -> [success: bb4, unwind continue]; ++ _20 = Eq(_2, const 0_u64); ++ assert(!_20, "attempt to divide `{}` by zero", _1) -> [success: bb4, unwind continue]; + } + + bb4: { +- _17 = Div(move _18, move _19); +- StorageDead(_19); +- StorageDead(_18); +- _16 = opaque::<u64>(move _17) -> [return: bb5, unwind continue]; ++ _17 = Div(_1, _2); ++ _16 = opaque::<u64>(_17) -> [return: bb5, unwind continue]; + } + + bb5: { +- StorageDead(_17); + StorageDead(_16); + StorageLive(_21); +- StorageLive(_22); +- StorageLive(_23); +- _23 = _1; +- StorageLive(_24); +- _24 = _2; +- _25 = Eq(_24, const 0_u64); +- assert(!move _25, "attempt to calculate the remainder of `{}` with a divisor of zero", _23) -> [success: bb6, unwind continue]; ++ assert(!_20, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb6, unwind continue]; + } + + bb6: { +- _22 = Rem(move _23, move _24); +- StorageDead(_24); +- StorageDead(_23); +- _21 = opaque::<u64>(move _22) -> [return: bb7, unwind continue]; ++ _22 = Rem(_1, _2); ++ _21 = opaque::<u64>(_22) -> [return: bb7, unwind continue]; + } + + bb7: { +- StorageDead(_22); + StorageDead(_21); + StorageLive(_26); +- StorageLive(_27); +- StorageLive(_28); +- _28 = _1; +- StorageLive(_29); +- _29 = _2; +- _27 = BitAnd(move _28, move _29); +- StorageDead(_29); +- StorageDead(_28); +- _26 = opaque::<u64>(move _27) -> [return: bb8, unwind continue]; ++ _27 = BitAnd(_1, _2); ++ _26 = opaque::<u64>(_27) -> [return: bb8, unwind continue]; + } + + bb8: { +- StorageDead(_27); + StorageDead(_26); + StorageLive(_30); +- StorageLive(_31); +- StorageLive(_32); +- _32 = _1; +- StorageLive(_33); +- _33 = _2; +- _31 = BitOr(move _32, move _33); +- StorageDead(_33); +- StorageDead(_32); +- _30 = opaque::<u64>(move _31) -> [return: bb9, unwind continue]; ++ _31 = BitOr(_1, _2); ++ _30 = opaque::<u64>(_31) -> [return: bb9, unwind continue]; + } + + bb9: { +- StorageDead(_31); + StorageDead(_30); + StorageLive(_34); +- StorageLive(_35); +- StorageLive(_36); +- _36 = _1; +- StorageLive(_37); +- _37 = _2; +- _35 = BitXor(move _36, move _37); +- StorageDead(_37); +- StorageDead(_36); +- _34 = opaque::<u64>(move _35) -> [return: bb10, unwind continue]; ++ _35 = BitXor(_1, _2); ++ _34 = opaque::<u64>(_35) -> [return: bb10, unwind continue]; + } + + bb10: { +- StorageDead(_35); + StorageDead(_34); + StorageLive(_38); +- StorageLive(_39); +- StorageLive(_40); +- _40 = _1; +- StorageLive(_41); +- _41 = _2; +- _39 = Shl(move _40, move _41); +- StorageDead(_41); +- StorageDead(_40); +- _38 = opaque::<u64>(move _39) -> [return: bb11, unwind continue]; ++ _39 = Shl(_1, _2); ++ _38 = opaque::<u64>(_39) -> [return: bb11, unwind continue]; + } + + bb11: { +- StorageDead(_39); + StorageDead(_38); + StorageLive(_42); +- StorageLive(_43); +- StorageLive(_44); +- _44 = _1; +- StorageLive(_45); +- _45 = _2; +- _43 = Shr(move _44, move _45); +- StorageDead(_45); +- StorageDead(_44); +- _42 = opaque::<u64>(move _43) -> [return: bb12, unwind continue]; ++ _43 = Shr(_1, _2); ++ _42 = opaque::<u64>(_43) -> [return: bb12, unwind continue]; + } + + bb12: { +- StorageDead(_43); + StorageDead(_42); + StorageLive(_46); + StorageLive(_47); +- StorageLive(_48); +- _48 = _1; +- _47 = move _48 as u32 (IntToInt); +- StorageDead(_48); ++ _47 = _1 as u32 (IntToInt); + _46 = opaque::<u32>(move _47) -> [return: bb13, unwind continue]; + } + + bb13: { + StorageDead(_47); + StorageDead(_46); + StorageLive(_49); + StorageLive(_50); +- StorageLive(_51); +- _51 = _1; +- _50 = move _51 as f32 (IntToFloat); +- StorageDead(_51); ++ _50 = _1 as f32 (IntToFloat); + _49 = opaque::<f32>(move _50) -> [return: bb14, unwind continue]; + } + + bb14: { + StorageDead(_50); + StorageDead(_49); + StorageLive(_52); +- StorageLive(_53); +- StorageLive(_54); +- _54 = _1; +- _53 = S::<u64>(move _54); +- StorageDead(_54); +- _52 = opaque::<S<u64>>(move _53) -> [return: bb15, unwind continue]; ++ _53 = S::<u64>(_1); ++ _52 = opaque::<S<u64>>(_53) -> [return: bb15, unwind continue]; + } + + bb15: { +- StorageDead(_53); + StorageDead(_52); + StorageLive(_55); +- StorageLive(_56); +- StorageLive(_57); +- StorageLive(_58); +- _58 = _1; +- _57 = S::<u64>(move _58); +- StorageDead(_58); +- _56 = (_57.0: u64); +- _55 = opaque::<u64>(move _56) -> [return: bb16, unwind continue]; ++ _56 = (_53.0: u64); ++ _55 = opaque::<u64>(_56) -> [return: bb16, unwind continue]; + } + + bb16: { +- StorageDead(_56); +- StorageDead(_57); + StorageDead(_55); + StorageLive(_59); + StorageLive(_60); +- StorageLive(_61); +- StorageLive(_62); +- _62 = _1; +- StorageLive(_63); +- _63 = _2; +- _61 = Add(move _62, move _63); +- StorageDead(_63); +- StorageDead(_62); + StorageLive(_64); + _64 = _3; +- _60 = Add(move _61, move _64); ++ _60 = Add(_5, move _64); + StorageDead(_64); +- StorageDead(_61); + _59 = opaque::<u64>(move _60) -> [return: bb17, unwind continue]; + } + + bb17: { + StorageDead(_60); + StorageDead(_59); + StorageLive(_65); + StorageLive(_66); +- StorageLive(_67); +- StorageLive(_68); +- _68 = _1; +- StorageLive(_69); +- _69 = _2; +- _67 = Mul(move _68, move _69); +- StorageDead(_69); +- StorageDead(_68); + StorageLive(_70); + _70 = _3; +- _66 = Add(move _67, move _70); ++ _66 = Add(_9, move _70); + StorageDead(_70); +- StorageDead(_67); + _65 = opaque::<u64>(move _66) -> [return: bb18, unwind continue]; + } + + bb18: { + StorageDead(_66); + StorageDead(_65); + StorageLive(_71); + StorageLive(_72); +- StorageLive(_73); +- StorageLive(_74); +- _74 = _1; +- StorageLive(_75); +- _75 = _2; +- _73 = Sub(move _74, move _75); +- StorageDead(_75); +- StorageDead(_74); + StorageLive(_76); + _76 = _3; +- _72 = Add(move _73, move _76); ++ _72 = Add(_13, move _76); + StorageDead(_76); +- StorageDead(_73); + _71 = opaque::<u64>(move _72) -> [return: bb19, unwind continue]; + } + + bb19: { + StorageDead(_72); + StorageDead(_71); + StorageLive(_77); + StorageLive(_78); +- StorageLive(_79); +- StorageLive(_80); +- _80 = _1; +- StorageLive(_81); +- _81 = _2; +- _82 = Eq(_81, const 0_u64); +- assert(!move _82, "attempt to divide `{}` by zero", _80) -> [success: bb20, unwind continue]; ++ assert(!_20, "attempt to divide `{}` by zero", _1) -> [success: bb20, unwind continue]; + } + + bb20: { +- _79 = Div(move _80, move _81); +- StorageDead(_81); +- StorageDead(_80); + StorageLive(_83); + _83 = _3; +- _78 = Add(move _79, move _83); ++ _78 = Add(_17, move _83); + StorageDead(_83); +- StorageDead(_79); + _77 = opaque::<u64>(move _78) -> [return: bb21, unwind continue]; + } + + bb21: { + StorageDead(_78); + StorageDead(_77); + StorageLive(_84); + StorageLive(_85); +- StorageLive(_86); +- StorageLive(_87); +- _87 = _1; +- StorageLive(_88); +- _88 = _2; +- _89 = Eq(_88, const 0_u64); +- assert(!move _89, "attempt to calculate the remainder of `{}` with a divisor of zero", _87) -> [success: bb22, unwind continue]; ++ assert(!_20, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb22, unwind continue]; + } + + bb22: { +- _86 = Rem(move _87, move _88); +- StorageDead(_88); +- StorageDead(_87); + StorageLive(_90); + _90 = _3; +- _85 = Add(move _86, move _90); ++ _85 = Add(_22, move _90); + StorageDead(_90); +- StorageDead(_86); + _84 = opaque::<u64>(move _85) -> [return: bb23, unwind continue]; + } + + bb23: { + StorageDead(_85); + StorageDead(_84); + StorageLive(_91); + StorageLive(_92); +- StorageLive(_93); +- StorageLive(_94); +- _94 = _1; +- StorageLive(_95); +- _95 = _2; +- _93 = BitAnd(move _94, move _95); +- StorageDead(_95); +- StorageDead(_94); + StorageLive(_96); + _96 = _3; +- _92 = Add(move _93, move _96); ++ _92 = Add(_27, move _96); + StorageDead(_96); +- StorageDead(_93); + _91 = opaque::<u64>(move _92) -> [return: bb24, unwind continue]; + } + + bb24: { + StorageDead(_92); + StorageDead(_91); + StorageLive(_97); + StorageLive(_98); +- StorageLive(_99); +- StorageLive(_100); +- _100 = _1; +- StorageLive(_101); +- _101 = _2; +- _99 = BitOr(move _100, move _101); +- StorageDead(_101); +- StorageDead(_100); + StorageLive(_102); + _102 = _3; +- _98 = Add(move _99, move _102); ++ _98 = Add(_31, move _102); + StorageDead(_102); +- StorageDead(_99); + _97 = opaque::<u64>(move _98) -> [return: bb25, unwind continue]; + } + + bb25: { + StorageDead(_98); + StorageDead(_97); + StorageLive(_103); + StorageLive(_104); +- StorageLive(_105); +- StorageLive(_106); +- _106 = _1; +- StorageLive(_107); +- _107 = _2; +- _105 = BitXor(move _106, move _107); +- StorageDead(_107); +- StorageDead(_106); + StorageLive(_108); + _108 = _3; +- _104 = Add(move _105, move _108); ++ _104 = Add(_35, move _108); + StorageDead(_108); +- StorageDead(_105); + _103 = opaque::<u64>(move _104) -> [return: bb26, unwind continue]; + } + + bb26: { + StorageDead(_104); + StorageDead(_103); + StorageLive(_109); + StorageLive(_110); +- StorageLive(_111); +- StorageLive(_112); +- _112 = _1; +- StorageLive(_113); +- _113 = _2; +- _111 = Shl(move _112, move _113); +- StorageDead(_113); +- StorageDead(_112); + StorageLive(_114); + _114 = _3; +- _110 = Add(move _111, move _114); ++ _110 = Add(_39, move _114); + StorageDead(_114); +- StorageDead(_111); + _109 = opaque::<u64>(move _110) -> [return: bb27, unwind continue]; + } + + bb27: { + StorageDead(_110); + StorageDead(_109); + StorageLive(_115); + StorageLive(_116); +- StorageLive(_117); +- StorageLive(_118); +- _118 = _1; +- StorageLive(_119); +- _119 = _2; +- _117 = Shr(move _118, move _119); +- StorageDead(_119); +- StorageDead(_118); + StorageLive(_120); + _120 = _3; +- _116 = Add(move _117, move _120); ++ _116 = Add(_43, move _120); + StorageDead(_120); +- StorageDead(_117); + _115 = opaque::<u64>(move _116) -> [return: bb28, unwind continue]; + } + + bb28: { + StorageDead(_116); + StorageDead(_115); + StorageLive(_121); +- StorageLive(_122); +- StorageLive(_123); +- _123 = _1; +- _122 = S::<u64>(move _123); +- StorageDead(_123); +- _121 = opaque::<S<u64>>(move _122) -> [return: bb29, unwind continue]; ++ _121 = opaque::<S<u64>>(_53) -> [return: bb29, unwind continue]; + } + + bb29: { +- StorageDead(_122); + StorageDead(_121); + StorageLive(_124); +- StorageLive(_125); +- StorageLive(_126); +- StorageLive(_127); +- _127 = _1; +- _126 = S::<u64>(move _127); +- StorageDead(_127); +- _125 = (_126.0: u64); +- _124 = opaque::<u64>(move _125) -> [return: bb30, unwind continue]; ++ _124 = opaque::<u64>(_56) -> [return: bb30, unwind continue]; + } + + bb30: { +- StorageDead(_125); +- StorageDead(_126); + StorageDead(_124); + StorageLive(_128); + _128 = &_3; + StorageLive(_129); +- StorageLive(_130); +- StorageLive(_131); + _131 = (*_128); +- StorageLive(_132); +- _132 = _1; +- _130 = Add(move _131, move _132); +- StorageDead(_132); +- StorageDead(_131); +- _129 = opaque::<u64>(move _130) -> [return: bb31, unwind continue]; ++ _130 = Add(_131, _1); ++ _129 = opaque::<u64>(_130) -> [return: bb31, unwind continue]; + } + + bb31: { +- StorageDead(_130); + StorageDead(_129); + StorageLive(_133); +- StorageLive(_134); +- StorageLive(_135); +- _135 = (*_128); +- StorageLive(_136); +- _136 = _1; +- _134 = Add(move _135, move _136); +- StorageDead(_136); +- StorageDead(_135); +- _133 = opaque::<u64>(move _134) -> [return: bb32, unwind continue]; ++ _133 = opaque::<u64>(_130) -> [return: bb32, unwind continue]; + } + + bb32: { +- StorageDead(_134); + StorageDead(_133); + StorageLive(_137); + _137 = &mut _3; + StorageLive(_138); + StorageLive(_139); + StorageLive(_140); + _140 = (*_137); +- StorageLive(_141); +- _141 = _1; +- _139 = Add(move _140, move _141); +- StorageDead(_141); ++ _139 = Add(move _140, _1); + StorageDead(_140); + _138 = opaque::<u64>(move _139) -> [return: bb33, unwind continue]; + } + + bb33: { + StorageDead(_139); + StorageDead(_138); + StorageLive(_142); + StorageLive(_143); + StorageLive(_144); + _144 = (*_137); +- StorageLive(_145); +- _145 = _1; +- _143 = Add(move _144, move _145); +- StorageDead(_145); ++ _143 = Add(move _144, _1); + StorageDead(_144); + _142 = opaque::<u64>(move _143) -> [return: bb34, unwind continue]; + } + + bb34: { + StorageDead(_143); + StorageDead(_142); +- StorageLive(_146); + StorageLive(_147); + _147 = &raw const _3; + StorageLive(_148); + StorageLive(_149); + StorageLive(_150); + _150 = (*_147); +- StorageLive(_151); +- _151 = _1; +- _149 = Add(move _150, move _151); +- StorageDead(_151); ++ _149 = Add(move _150, _1); + StorageDead(_150); + _148 = opaque::<u64>(move _149) -> [return: bb35, unwind continue]; + } + + bb35: { + StorageDead(_149); + StorageDead(_148); + StorageLive(_152); + StorageLive(_153); + StorageLive(_154); + _154 = (*_147); +- StorageLive(_155); +- _155 = _1; +- _153 = Add(move _154, move _155); +- StorageDead(_155); ++ _153 = Add(move _154, _1); + StorageDead(_154); + _152 = opaque::<u64>(move _153) -> [return: bb36, unwind continue]; + } + + bb36: { + StorageDead(_153); + StorageDead(_152); + StorageLive(_156); + _156 = &raw mut _3; + StorageLive(_157); + StorageLive(_158); + StorageLive(_159); + _159 = (*_156); +- StorageLive(_160); +- _160 = _1; +- _158 = Add(move _159, move _160); +- StorageDead(_160); ++ _158 = Add(move _159, _1); + StorageDead(_159); + _157 = opaque::<u64>(move _158) -> [return: bb37, unwind continue]; + } + + bb37: { + StorageDead(_158); + StorageDead(_157); + StorageLive(_161); + StorageLive(_162); + StorageLive(_163); + _163 = (*_156); +- StorageLive(_164); +- _164 = _1; +- _162 = Add(move _163, move _164); +- StorageDead(_164); ++ _162 = Add(move _163, _1); + StorageDead(_163); + _161 = opaque::<u64>(move _162) -> [return: bb38, unwind continue]; + } + + bb38: { + StorageDead(_162); + StorageDead(_161); +- _146 = const (); + StorageDead(_156); + StorageDead(_147); +- StorageDead(_146); + StorageLive(_165); + _165 = &_3; + StorageLive(_166); +- StorageLive(_167); +- StorageLive(_168); + _168 = (*_165); +- StorageLive(_169); +- _169 = _1; +- _167 = Add(move _168, move _169); +- StorageDead(_169); +- StorageDead(_168); +- _166 = opaque::<u64>(move _167) -> [return: bb39, unwind continue]; ++ _167 = Add(_168, _1); ++ _166 = opaque::<u64>(_167) -> [return: bb39, unwind continue]; + } + + bb39: { +- StorageDead(_167); + StorageDead(_166); + StorageLive(_170); +- StorageLive(_171); +- StorageLive(_172); +- _172 = (*_165); +- StorageLive(_173); +- _173 = _1; +- _171 = Add(move _172, move _173); +- StorageDead(_173); +- StorageDead(_172); +- _170 = opaque::<u64>(move _171) -> [return: bb40, unwind continue]; ++ _170 = opaque::<u64>(_167) -> [return: bb40, unwind continue]; + } + + bb40: { +- StorageDead(_171); + StorageDead(_170); + _0 = const (); + StorageDead(_165); + StorageDead(_137); + StorageDead(_128); + return; + } + } + diff --git a/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-abort.diff b/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-abort.diff new file mode 100644 index 00000000000..f33845502ad --- /dev/null +++ b/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-abort.diff @@ -0,0 +1,45 @@ +- // MIR for `wrap_unwrap` before GVN ++ // MIR for `wrap_unwrap` after GVN + + fn wrap_unwrap(_1: T) -> T { + debug x => _1; + let mut _0: T; + let mut _2: std::option::Option<T>; + let mut _3: T; + let mut _4: isize; + let _5: T; + let mut _6: !; + scope 1 { + debug y => _5; + } + + bb0: { + StorageLive(_2); +- StorageLive(_3); +- _3 = _1; +- _2 = Option::<T>::Some(move _3); +- StorageDead(_3); ++ _2 = Option::<T>::Some(_1); + _4 = discriminant(_2); + switchInt(move _4) -> [0: bb1, 1: bb3, otherwise: bb2]; + } + + bb1: { + StorageLive(_6); + _6 = begin_panic::<&str>(const "explicit panic") -> unwind unreachable; + } + + bb2: { + unreachable; + } + + bb3: { +- StorageLive(_5); + _5 = ((_2 as Some).0: T); + _0 = _5; +- StorageDead(_5); + StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-unwind.diff b/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-unwind.diff new file mode 100644 index 00000000000..edc05f99fe2 --- /dev/null +++ b/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-unwind.diff @@ -0,0 +1,45 @@ +- // MIR for `wrap_unwrap` before GVN ++ // MIR for `wrap_unwrap` after GVN + + fn wrap_unwrap(_1: T) -> T { + debug x => _1; + let mut _0: T; + let mut _2: std::option::Option<T>; + let mut _3: T; + let mut _4: isize; + let _5: T; + let mut _6: !; + scope 1 { + debug y => _5; + } + + bb0: { + StorageLive(_2); +- StorageLive(_3); +- _3 = _1; +- _2 = Option::<T>::Some(move _3); +- StorageDead(_3); ++ _2 = Option::<T>::Some(_1); + _4 = discriminant(_2); + switchInt(move _4) -> [0: bb1, 1: bb3, otherwise: bb2]; + } + + bb1: { + StorageLive(_6); + _6 = begin_panic::<&str>(const "explicit panic") -> unwind continue; + } + + bb2: { + unreachable; + } + + bb3: { +- StorageLive(_5); + _5 = ((_2 as Some).0: T); + _0 = _5; +- StorageDead(_5); + StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir b/tests/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir index 549306071ad..721fac27d88 100644 --- a/tests/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir +++ b/tests/mir-opt/inline/inline_closure_captures.foo.Inline.after.mir @@ -42,10 +42,10 @@ fn foo(_1: T, _2: i32) -> (i32, T) { StorageLive(_9); _9 = move (_7.0: i32); StorageLive(_11); - _10 = deref_copy ((*_6).0: &i32); + _10 = ((*_6).0: &i32); _11 = (*_10); StorageLive(_13); - _12 = deref_copy ((*_6).1: &T); + _12 = ((*_6).1: &T); _13 = (*_12); _0 = (move _11, move _13); StorageDead(_13); diff --git a/tests/mir-opt/inline/inline_generator.main.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_generator.main.Inline.panic-abort.diff index 3f093a02dd2..6779003b693 100644 --- a/tests/mir-opt/inline/inline_generator.main.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/inline_generator.main.Inline.panic-abort.diff @@ -26,8 +26,6 @@ + let mut _6: &mut {generator@$DIR/inline_generator.rs:16:5: 16:8}; + let mut _7: u32; + let mut _8: i32; -+ let mut _9: &mut {generator@$DIR/inline_generator.rs:16:5: 16:8}; -+ let mut _10: &mut {generator@$DIR/inline_generator.rs:16:5: 16:8}; + } bb0: { @@ -42,7 +40,7 @@ + StorageDead(_3); + StorageLive(_5); + _5 = const false; -+ _6 = deref_copy (_2.0: &mut {generator@$DIR/inline_generator.rs:16:5: 16:8}); ++ _6 = (_2.0: &mut {generator@$DIR/inline_generator.rs:16:5: 16:8}); + _7 = discriminant((*_6)); + switchInt(move _7) -> [0: bb3, 1: bb7, 3: bb8, otherwise: bb9]; } @@ -87,8 +85,7 @@ + + bb6: { + _1 = GeneratorState::<i32, bool>::Yielded(move _8); -+ _9 = deref_copy (_2.0: &mut {generator@$DIR/inline_generator.rs:16:5: 16:8}); -+ discriminant((*_9)) = 3; ++ discriminant((*_6)) = 3; + goto -> bb1; + } + @@ -100,8 +97,7 @@ + StorageLive(_8); + StorageDead(_8); + _1 = GeneratorState::<i32, bool>::Complete(_5); -+ _10 = deref_copy (_2.0: &mut {generator@$DIR/inline_generator.rs:16:5: 16:8}); -+ discriminant((*_10)) = 1; ++ discriminant((*_6)) = 1; + goto -> bb1; + } + diff --git a/tests/mir-opt/inline/inline_generator.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_generator.main.Inline.panic-unwind.diff index 3d76262c266..31744be99ec 100644 --- a/tests/mir-opt/inline/inline_generator.main.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_generator.main.Inline.panic-unwind.diff @@ -26,8 +26,6 @@ + let mut _6: &mut {generator@$DIR/inline_generator.rs:16:5: 16:8}; + let mut _7: u32; + let mut _8: i32; -+ let mut _9: &mut {generator@$DIR/inline_generator.rs:16:5: 16:8}; -+ let mut _10: &mut {generator@$DIR/inline_generator.rs:16:5: 16:8}; + } bb0: { @@ -50,7 +48,7 @@ - _1 = <{generator@$DIR/inline_generator.rs:16:5: 16:8} as Generator<bool>>::resume(move _2, const false) -> [return: bb3, unwind: bb5]; + StorageLive(_5); + _5 = const false; -+ _6 = deref_copy (_2.0: &mut {generator@$DIR/inline_generator.rs:16:5: 16:8}); ++ _6 = (_2.0: &mut {generator@$DIR/inline_generator.rs:16:5: 16:8}); + _7 = discriminant((*_6)); + switchInt(move _7) -> [0: bb5, 1: bb9, 3: bb10, otherwise: bb11]; } @@ -99,8 +97,7 @@ + + bb8: { + _1 = GeneratorState::<i32, bool>::Yielded(move _8); -+ _9 = deref_copy (_2.0: &mut {generator@$DIR/inline_generator.rs:16:5: 16:8}); -+ discriminant((*_9)) = 3; ++ discriminant((*_6)) = 3; + goto -> bb1; + } + @@ -112,8 +109,7 @@ + StorageLive(_8); + StorageDead(_8); + _1 = GeneratorState::<i32, bool>::Complete(_5); -+ _10 = deref_copy (_2.0: &mut {generator@$DIR/inline_generator.rs:16:5: 16:8}); -+ discriminant((*_10)) = 1; ++ discriminant((*_6)) = 1; + goto -> bb1; + } + diff --git a/tests/mir-opt/inline/issue_78442.bar.RevealAll.panic-abort.diff b/tests/mir-opt/inline/issue_78442.bar.RevealAll.panic-abort.diff index c94dd255695..b532b133a83 100644 --- a/tests/mir-opt/inline/issue_78442.bar.RevealAll.panic-abort.diff +++ b/tests/mir-opt/inline/issue_78442.bar.RevealAll.panic-abort.diff @@ -15,28 +15,44 @@ StorageLive(_2); StorageLive(_3); StorageLive(_4); - _4 = hide_foo() -> [return: bb1, unwind unreachable]; + _4 = hide_foo() -> [return: bb1, unwind: bb6]; } bb1: { _3 = &_4; StorageLive(_5); _5 = (); -- _2 = <impl Fn() as Fn<()>>::call(move _3, move _5) -> [return: bb2, unwind unreachable]; -+ _2 = <fn() {foo} as Fn<()>>::call(move _3, move _5) -> [return: bb2, unwind unreachable]; +- _2 = <impl Fn() as Fn<()>>::call(move _3, move _5) -> [return: bb2, unwind: bb5]; ++ _2 = <fn() {foo} as Fn<()>>::call(move _3, move _5) -> [return: bb2, unwind: bb5]; } bb2: { StorageDead(_5); StorageDead(_3); + drop(_4) -> [return: bb3, unwind: bb6]; + } + + bb3: { StorageDead(_4); StorageDead(_2); _0 = const (); - drop(_1) -> [return: bb3, unwind unreachable]; + drop(_1) -> [return: bb4, unwind: bb7]; } - bb3: { + bb4: { return; } + + bb5 (cleanup): { + drop(_4) -> [return: bb6, unwind terminate(cleanup)]; + } + + bb6 (cleanup): { + drop(_1) -> [return: bb7, unwind terminate(cleanup)]; + } + + bb7 (cleanup): { + resume; + } } diff --git a/tests/mir-opt/inline/issue_78442.bar.RevealAll.panic-unwind.diff b/tests/mir-opt/inline/issue_78442.bar.RevealAll.panic-unwind.diff index cbfb39115b3..bcebcf297c2 100644 --- a/tests/mir-opt/inline/issue_78442.bar.RevealAll.panic-unwind.diff +++ b/tests/mir-opt/inline/issue_78442.bar.RevealAll.panic-unwind.diff @@ -15,35 +15,43 @@ StorageLive(_2); StorageLive(_3); StorageLive(_4); - _4 = hide_foo() -> [return: bb1, unwind: bb4]; + _4 = hide_foo() -> [return: bb1, unwind: bb6]; } bb1: { _3 = &_4; StorageLive(_5); _5 = (); -- _2 = <impl Fn() as Fn<()>>::call(move _3, move _5) -> [return: bb2, unwind: bb4]; -+ _2 = <fn() {foo} as Fn<()>>::call(move _3, move _5) -> [return: bb2, unwind: bb4]; +- _2 = <impl Fn() as Fn<()>>::call(move _3, move _5) -> [return: bb2, unwind: bb5]; ++ _2 = <fn() {foo} as Fn<()>>::call(move _3, move _5) -> [return: bb2, unwind: bb5]; } bb2: { StorageDead(_5); StorageDead(_3); + drop(_4) -> [return: bb3, unwind: bb6]; + } + + bb3: { StorageDead(_4); StorageDead(_2); _0 = const (); - drop(_1) -> [return: bb3, unwind: bb5]; + drop(_1) -> [return: bb4, unwind continue]; } - bb3: { + bb4: { return; } - bb4 (cleanup): { - drop(_1) -> [return: bb5, unwind terminate(cleanup)]; + bb5 (cleanup): { + drop(_4) -> [return: bb6, unwind terminate(cleanup)]; } - bb5 (cleanup): { + bb6 (cleanup): { + drop(_1) -> [return: bb7, unwind terminate(cleanup)]; + } + + bb7 (cleanup): { resume; } } diff --git a/tests/mir-opt/ssa_unreachable_116212.rs b/tests/mir-opt/ssa_unreachable_116212.rs new file mode 100644 index 00000000000..f588665876c --- /dev/null +++ b/tests/mir-opt/ssa_unreachable_116212.rs @@ -0,0 +1,14 @@ +// Regression test for issue #116212. + +#![feature(never_type)] + +use std::mem::MaybeUninit; + +struct Foo { + x: u8, + y: !, +} + +fn main() { + let foo = unsafe { MaybeUninit::<Foo>::uninit().assume_init() }; +} diff --git a/tests/run-coverage/unreachable.coverage b/tests/run-coverage/unreachable.coverage new file mode 100644 index 00000000000..fa0ac9ccfa1 --- /dev/null +++ b/tests/run-coverage/unreachable.coverage @@ -0,0 +1,38 @@ + LL| |#![feature(core_intrinsics)] + LL| |#![feature(coverage_attribute)] + LL| |// compile-flags: --edition=2021 + LL| | + LL| |// <https://github.com/rust-lang/rust/issues/116171> + LL| |// If we instrument a function for coverage, but all of its counter-increment + LL| |// statements are removed by MIR optimizations, LLVM will think it isn't + LL| |// instrumented and it will disappear from coverage maps and coverage reports. + LL| |// Most MIR opts won't cause this because they tend not to remove statements + LL| |// from bb0, but `UnreachablePropagation` can do so if it sees that bb0 ends + LL| |// with `TerminatorKind::Unreachable`. + LL| | + LL| |use std::hint::{black_box, unreachable_unchecked}; + LL| | + LL| 0|static UNREACHABLE_CLOSURE: fn() = || unsafe { unreachable_unchecked() }; + LL| | + LL| 0|fn unreachable_function() { + LL| 0| unsafe { unreachable_unchecked() } + LL| 0|} + LL| | + LL| |// Use an intrinsic to more reliably trigger unreachable-propagation. + LL| 0|fn unreachable_intrinsic() { + LL| 0| unsafe { std::intrinsics::unreachable() } + LL| 0|} + LL| | + LL| |#[coverage(off)] + LL| |fn main() { + LL| | if black_box(false) { + LL| | UNREACHABLE_CLOSURE(); + LL| | } + LL| | if black_box(false) { + LL| | unreachable_function(); + LL| | } + LL| | if black_box(false) { + LL| | unreachable_intrinsic(); + LL| | } + LL| |} + diff --git a/tests/run-coverage/unreachable.rs b/tests/run-coverage/unreachable.rs new file mode 100644 index 00000000000..6385bfa160d --- /dev/null +++ b/tests/run-coverage/unreachable.rs @@ -0,0 +1,37 @@ +#![feature(core_intrinsics)] +#![feature(coverage_attribute)] +// compile-flags: --edition=2021 + +// <https://github.com/rust-lang/rust/issues/116171> +// If we instrument a function for coverage, but all of its counter-increment +// statements are removed by MIR optimizations, LLVM will think it isn't +// instrumented and it will disappear from coverage maps and coverage reports. +// Most MIR opts won't cause this because they tend not to remove statements +// from bb0, but `UnreachablePropagation` can do so if it sees that bb0 ends +// with `TerminatorKind::Unreachable`. + +use std::hint::{black_box, unreachable_unchecked}; + +static UNREACHABLE_CLOSURE: fn() = || unsafe { unreachable_unchecked() }; + +fn unreachable_function() { + unsafe { unreachable_unchecked() } +} + +// Use an intrinsic to more reliably trigger unreachable-propagation. +fn unreachable_intrinsic() { + unsafe { std::intrinsics::unreachable() } +} + +#[coverage(off)] +fn main() { + if black_box(false) { + UNREACHABLE_CLOSURE(); + } + if black_box(false) { + unreachable_function(); + } + if black_box(false) { + unreachable_intrinsic(); + } +} diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/Makefile b/tests/run-make/rlib-format-packed-bundled-libs-3/Makefile index 1f2812cb087..9ba077b1854 100644 --- a/tests/run-make/rlib-format-packed-bundled-libs-3/Makefile +++ b/tests/run-make/rlib-format-packed-bundled-libs-3/Makefile @@ -3,7 +3,7 @@ include ../tools.mk # ignore-cross-compile # only-linux -# Make sure -Zpacked_bundled_libs-like behavior activates with whole-archive. +# Make sure -Zpacked_bundled_libs-like behavior activates with +bundle,+whole-archive. # We're using the llvm-nm instead of the system nm to ensure it is compatible # with the LLVM bitcode generated by rustc. @@ -11,7 +11,7 @@ NM = "$(LLVM_BIN_DIR)"/llvm-nm all: $(call NATIVE_STATICLIB,native_dep_1) $(call NATIVE_STATICLIB,native_dep_2) $(call NATIVE_STATICLIB,native_dep_3) $(call NATIVE_STATICLIB,native_dep_4) # test cfg with packed bundle - $(RUSTC) rust_dep_cfg.rs --crate-type=rlib -Zpacked_bundled_libs + $(RUSTC) rust_dep_cfg.rs --crate-type=rlib $(RUSTC) main.rs --extern rust_dep=$(TMPDIR)/librust_dep_cfg.rlib --crate-type=staticlib --cfg should_add $(AR) t $(TMPDIR)/librust_dep_cfg.rlib | $(CGREP) -e "libnative_dep_1.a" $(AR) t $(TMPDIR)/librust_dep_cfg.rlib | $(CGREP) -e "libnative_dep_2.a" diff --git a/tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep.rs b/tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep.rs index abd846b6862..bde9b739de6 100644 --- a/tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep.rs +++ b/tests/run-make/rlib-format-packed-bundled-libs-3/rust_dep.rs @@ -1,5 +1,3 @@ -#![feature(packed_bundled_libs)] - #[link(name = "native_dep_1", kind = "static", modifiers = "+whole-archive,+bundle")] extern "C" {} diff --git a/tests/rustdoc-ui/issue-102467.rs b/tests/rustdoc-ui/issue-102467.rs new file mode 100644 index 00000000000..bff876e41d6 --- /dev/null +++ b/tests/rustdoc-ui/issue-102467.rs @@ -0,0 +1,15 @@ +// Regression test for <https://github.com/rust-lang/rust/issues/102467>. +// It ensures that the expected error is displayed. + +#![feature(associated_const_equality)] + +trait T { + type A: S<C<X = 0i32> = 34>; + //~^ ERROR associated type bindings are not allowed here +} + +trait S { + const C: i32; +} + +fn main() {} diff --git a/tests/rustdoc-ui/issue-102467.stderr b/tests/rustdoc-ui/issue-102467.stderr new file mode 100644 index 00000000000..a337293f7a0 --- /dev/null +++ b/tests/rustdoc-ui/issue-102467.stderr @@ -0,0 +1,9 @@ +error[E0229]: associated type bindings are not allowed here + --> $DIR/issue-102467.rs:7:17 + | +LL | type A: S<C<X = 0i32> = 34>; + | ^^^^^^^^ associated type not allowed here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0229`. diff --git a/tests/rustdoc/issue-15169.rs b/tests/rustdoc/anchor-id-trait-method-15169.rs index e525d85e21e..26bb59c1875 100644 --- a/tests/rustdoc/issue-15169.rs +++ b/tests/rustdoc/anchor-id-trait-method-15169.rs @@ -1,3 +1,7 @@ // @has issue_15169/struct.Foo.html '//*[@id="method.eq"]' 'fn eq' + +// https://github.com/rust-lang/rust/issues/15169 +#![crate_name="issue_15169"] + #[derive(PartialEq)] pub struct Foo; diff --git a/tests/rustdoc/issue-20646.rs b/tests/rustdoc/assoc-type-bindings-20646.rs index b2ee9c26014..375b5b5b23e 100644 --- a/tests/rustdoc/issue-20646.rs +++ b/tests/rustdoc/assoc-type-bindings-20646.rs @@ -1,6 +1,8 @@ // aux-build:issue-20646.rs // ignore-cross-compile +// https://github.com/rust-lang/rust/issues/20646 +#![crate_name="issue_20646"] #![feature(associated_types)] extern crate issue_20646; diff --git a/tests/rustdoc/issue-19190-2.rs b/tests/rustdoc/deref-methods-19190-foreign-type.rs index b6416e2e5b9..c8326992115 100644 --- a/tests/rustdoc/issue-19190-2.rs +++ b/tests/rustdoc/deref-methods-19190-foreign-type.rs @@ -1,3 +1,7 @@ +// https://github.com/rust-lang/rust/issues/19190 + +#![crate_name="issue_19190_2"] + use std::ops::Deref; pub struct Bar; diff --git a/tests/rustdoc/issue-19190-3.rs b/tests/rustdoc/deref-methods-19190-inline.rs index 4d34ce6509f..619b268d68b 100644 --- a/tests/rustdoc/issue-19190-3.rs +++ b/tests/rustdoc/deref-methods-19190-inline.rs @@ -1,6 +1,9 @@ // aux-build:issue-19190-3.rs // ignore-cross-compile +// https://github.com/rust-lang/rust/issues/19190 +#![crate_name="issue_19190_3"] + extern crate issue_19190_3; use std::ops::Deref; diff --git a/tests/rustdoc/issue-19190.rs b/tests/rustdoc/deref-methods-19190.rs index 2046273e2c1..4c274d82ff7 100644 --- a/tests/rustdoc/issue-19190.rs +++ b/tests/rustdoc/deref-methods-19190.rs @@ -1,3 +1,6 @@ +// https://github.com/rust-lang/rust/issues/19190 +#![crate_name="issue_19190"] + use std::ops::Deref; pub struct Foo; diff --git a/tests/rustdoc/issue-13698.rs b/tests/rustdoc/doc-hidden-method-13698.rs index 3046a8a2862..f1bd6e73bab 100644 --- a/tests/rustdoc/issue-13698.rs +++ b/tests/rustdoc/doc-hidden-method-13698.rs @@ -1,6 +1,9 @@ // aux-build:issue-13698.rs // ignore-cross-compile +// https://github.com/rust-lang/rust/issues/13698 +#![crate_name="issue_13698"] + extern crate issue_13698; pub struct Foo; diff --git a/tests/rustdoc/issue-18199.rs b/tests/rustdoc/doc-test-attr-18199.rs index 9cc58b162f3..c9d2235321c 100644 --- a/tests/rustdoc/issue-18199.rs +++ b/tests/rustdoc/doc-test-attr-18199.rs @@ -1,4 +1,5 @@ // compile-flags:--test +// https://github.com/rust-lang/rust/issues/18199 #![doc(test(attr(feature(staged_api))))] diff --git a/tests/rustdoc/issue-15347.rs b/tests/rustdoc/document-hidden-items-15347.rs index e93d7401168..d8a760e5666 100644 --- a/tests/rustdoc/issue-15347.rs +++ b/tests/rustdoc/document-hidden-items-15347.rs @@ -1,4 +1,7 @@ // compile-flags: -Z unstable-options --document-hidden-items +// https://github.com/rust-lang/rust/issues/15347 + +#![crate_name="issue_15347"] // @has issue_15347/fn.foo.html #[doc(hidden)] diff --git a/tests/rustdoc/issue-12834.rs b/tests/rustdoc/highlight-invalid-rust-12834.rs index 9605a1e78c1..f8acc500264 100644 --- a/tests/rustdoc/issue-12834.rs +++ b/tests/rustdoc/highlight-invalid-rust-12834.rs @@ -1,6 +1,8 @@ // Tests that failing to syntax highlight a rust code-block doesn't cause // rustdoc to fail, while still rendering the code-block (without highlighting). +// https://github.com/rust-lang/rust/issues/12834 +#![crate_name="issue_12834"] #![allow(rustdoc::invalid_rust_codeblocks)] // @has issue_12834/fn.foo.html diff --git a/tests/rustdoc/issue-19181.rs b/tests/rustdoc/ice-type-error-19181.rs index 3dea152fc6e..3ced6136664 100644 --- a/tests/rustdoc/issue-19181.rs +++ b/tests/rustdoc/ice-type-error-19181.rs @@ -1,4 +1,5 @@ // compile-flags:--test +// https://github.com/rust-lang/rust/issues/19181 // rustdoc should not panic when target crate has compilation errors diff --git a/tests/rustdoc/issue-20175.rs b/tests/rustdoc/impl-ref-20175.rs index 6a42e2afbf4..a92db2d0a66 100644 --- a/tests/rustdoc/issue-20175.rs +++ b/tests/rustdoc/impl-ref-20175.rs @@ -1,3 +1,7 @@ +// https://github.com/rust-lang/rust/issues/20175 + +#![crate_name="issue_20175"] + pub trait Foo { fn foo(&self) {} } diff --git a/tests/rustdoc/issue-16265-1.rs b/tests/rustdoc/infinite-redirection-16265-1.rs index 2fda637a641..7d72469bd72 100644 --- a/tests/rustdoc/issue-16265-1.rs +++ b/tests/rustdoc/infinite-redirection-16265-1.rs @@ -1,3 +1,6 @@ +// https://github.com/rust-lang/rust/issues/16265 +#![crate_name="issue_16265_1"] + pub struct Foo; // @hasraw issue_16265_1/traits/index.html 'source' diff --git a/tests/rustdoc/issue-16265-2.rs b/tests/rustdoc/infinite-redirection-16265-2.rs index c3eb356171e..7a4791c5fd4 100644 --- a/tests/rustdoc/issue-16265-2.rs +++ b/tests/rustdoc/infinite-redirection-16265-2.rs @@ -1,3 +1,6 @@ +// https://github.com/rust-lang/rust/issues/16265 +#![crate_name="issue_16265_2"] + // @hasraw issue_16265_2/index.html 'source' trait Y {} diff --git a/tests/rustdoc/issue-20727-2.rs b/tests/rustdoc/inline-assoc-type-20727-bindings.rs index c1aa9617b2e..e59dec29d03 100644 --- a/tests/rustdoc/issue-20727-2.rs +++ b/tests/rustdoc/inline-assoc-type-20727-bindings.rs @@ -1,6 +1,9 @@ // aux-build:issue-20727.rs // ignore-cross-compile +// https://github.com/rust-lang/rust/issues/20727 +#![crate_name="issue_20727_2"] + extern crate issue_20727; // @has issue_20727_2/trait.Add.html diff --git a/tests/rustdoc/issue-20727-3.rs b/tests/rustdoc/inline-assoc-type-20727-bounds-deref.rs index 2f9d91fc5f7..005ee3e3294 100644 --- a/tests/rustdoc/issue-20727-3.rs +++ b/tests/rustdoc/inline-assoc-type-20727-bounds-deref.rs @@ -1,6 +1,9 @@ // aux-build:issue-20727.rs // ignore-cross-compile +// https://github.com/rust-lang/rust/issues/20727 +#![crate_name="issue_20727_3"] + extern crate issue_20727; pub trait Bar {} diff --git a/tests/rustdoc/issue-20727-4.rs b/tests/rustdoc/inline-assoc-type-20727-bounds-index.rs index ec9f18fc3fe..1a3f4cd20c1 100644 --- a/tests/rustdoc/issue-20727-4.rs +++ b/tests/rustdoc/inline-assoc-type-20727-bounds-index.rs @@ -1,6 +1,9 @@ // aux-build:issue-20727.rs // ignore-cross-compile +// https://github.com/rust-lang/rust/issues/20727 +#![crate_name="issue_20727_4"] + extern crate issue_20727; // @has issue_20727_4/trait.Index.html diff --git a/tests/rustdoc/issue-20727.rs b/tests/rustdoc/inline-assoc-type-20727-bounds.rs index 266848beef9..7cbc8d38107 100644 --- a/tests/rustdoc/issue-20727.rs +++ b/tests/rustdoc/inline-assoc-type-20727-bounds.rs @@ -1,6 +1,9 @@ // aux-build:issue-20727.rs // ignore-cross-compile +// https://github.com/rust-lang/rust/issues/20727 +#![crate_name="issue_20727"] + extern crate issue_20727; // @has issue_20727/trait.Deref.html diff --git a/tests/rustdoc/inline_cross/async-fn.rs b/tests/rustdoc/inline_cross/async-fn.rs new file mode 100644 index 00000000000..95e175aabd0 --- /dev/null +++ b/tests/rustdoc/inline_cross/async-fn.rs @@ -0,0 +1,19 @@ +// Regression test for issue #115760. +// Check that we render the correct return type of free and +// associated async functions reexported from external crates. + +// aux-crate:async_fn=async-fn.rs +// edition: 2021 +#![crate_name = "user"] + +// @has user/fn.load.html +// @has - '//pre[@class="rust item-decl"]' "pub async fn load() -> i32" +pub use async_fn::load; + +// @has user/trait.Load.html +// @has - '//*[@id="tymethod.run"]' 'async fn run(&self) -> i32' +pub use async_fn::Load; + +// @has user/struct.Loader.html +// @has - '//*[@id="method.run"]' 'async fn run(&self) -> i32' +pub use async_fn::Loader; diff --git a/tests/rustdoc/inline_cross/auxiliary/async-fn.rs b/tests/rustdoc/inline_cross/auxiliary/async-fn.rs new file mode 100644 index 00000000000..767564ed145 --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/async-fn.rs @@ -0,0 +1,18 @@ +#![feature(async_fn_in_trait)] +// edition: 2021 + +pub async fn load() -> i32 { + 0 +} + +pub trait Load { + async fn run(&self) -> i32; +} + +pub struct Loader; + +impl Load for Loader { + async fn run(&self) -> i32 { + 1 + } +} diff --git a/tests/rustdoc/inline_cross/auxiliary/impl_trait_aux.rs b/tests/rustdoc/inline_cross/auxiliary/impl_trait_aux.rs index 19433c9682b..42cfc3dc319 100644 --- a/tests/rustdoc/inline_cross/auxiliary/impl_trait_aux.rs +++ b/tests/rustdoc/inline_cross/auxiliary/impl_trait_aux.rs @@ -33,9 +33,3 @@ pub struct Foo; impl Foo { pub fn method<'a>(_x: impl Clone + Into<Vec<u8>> + 'a) {} } - -pub struct Bar; - -impl Bar { - pub async fn async_foo(&self) {} -} diff --git a/tests/rustdoc/inline_cross/impl_trait.rs b/tests/rustdoc/inline_cross/impl_trait.rs index b6a1552bc00..5c802c51486 100644 --- a/tests/rustdoc/inline_cross/impl_trait.rs +++ b/tests/rustdoc/inline_cross/impl_trait.rs @@ -33,15 +33,7 @@ pub use impl_trait_aux::func4; // @!has - '//pre[@class="rust item-decl"]' 'where' pub use impl_trait_aux::func5; -// @has impl_trait/fn.async_fn.html -// @has - '//pre[@class="rust item-decl"]' "pub async fn async_fn()" -pub use impl_trait_aux::async_fn; - // @has impl_trait/struct.Foo.html // @has - '//*[@id="method.method"]//h4[@class="code-header"]' "pub fn method<'a>(_x: impl Clone + Into<Vec<u8, Global>> + 'a)" // @!has - '//*[@id="method.method"]//h4[@class="code-header"]' 'where' pub use impl_trait_aux::Foo; - -// @has impl_trait/struct.Bar.html -// @has - '//*[@id="method.async_foo"]' "pub async fn async_foo(" -pub use impl_trait_aux::Bar; diff --git a/tests/rustdoc/issue-16019.rs b/tests/rustdoc/macro-ice-16019.rs index 239d92378d9..d0f82e0a314 100644 --- a/tests/rustdoc/issue-16019.rs +++ b/tests/rustdoc/macro-ice-16019.rs @@ -1,3 +1,5 @@ +// https://github.com/rust-lang/rust/issues/16019 + macro_rules! define_struct { ($rounds:expr) => ( struct Struct { diff --git a/tests/rustdoc/issue-17476.rs b/tests/rustdoc/method-link-foreign-trait-impl-17476.rs index a5b484c985f..e52ab6f38c2 100644 --- a/tests/rustdoc/issue-17476.rs +++ b/tests/rustdoc/method-link-foreign-trait-impl-17476.rs @@ -1,5 +1,8 @@ // aux-build:issue-17476.rs // ignore-cross-compile +// https://github.com/rust-lang/rust/issues/17476 + +#![crate_name="issue_17476"] extern crate issue_17476; diff --git a/tests/rustdoc/issue-15318-3.rs b/tests/rustdoc/primitive-raw-pointer-dox-15318-3.rs index 2dab8f94883..80c55975687 100644 --- a/tests/rustdoc/issue-15318-3.rs +++ b/tests/rustdoc/primitive-raw-pointer-dox-15318-3.rs @@ -1,3 +1,5 @@ +// https://github.com/rust-lang/rust/issues/15318 +#![crate_name="issue_15318_3"] #![feature(rustc_attrs)] // @has issue_15318_3/primitive.pointer.html diff --git a/tests/rustdoc/issue-15318.rs b/tests/rustdoc/primitive-raw-pointer-link-15318.rs index 0349fe2854c..77f25ff4cff 100644 --- a/tests/rustdoc/issue-15318.rs +++ b/tests/rustdoc/primitive-raw-pointer-link-15318.rs @@ -1,6 +1,8 @@ // aux-build:issue-15318.rs // ignore-cross-compile +// https://github.com/rust-lang/rust/issues/15318 +#![crate_name="issue_15318"] #![no_std] extern crate issue_15318; diff --git a/tests/rustdoc/issue-15318-2.rs b/tests/rustdoc/primitive-raw-pointer-link-no-inlined-15318-2.rs index 614f2c1c08e..1b35bb185ed 100644 --- a/tests/rustdoc/issue-15318-2.rs +++ b/tests/rustdoc/primitive-raw-pointer-link-no-inlined-15318-2.rs @@ -1,5 +1,8 @@ // aux-build:issue-15318.rs // ignore-cross-compile +// https://github.com/rust-lang/rust/issues/15318 + +#![crate_name="issue_15318_2"] #![no_std] extern crate issue_15318; diff --git a/tests/ui-fulldeps/internal-lints/lint_pass_impl_without_macro.rs b/tests/ui-fulldeps/internal-lints/lint_pass_impl_without_macro.rs index f6f0c038536..fa6734b6c6c 100644 --- a/tests/ui-fulldeps/internal-lints/lint_pass_impl_without_macro.rs +++ b/tests/ui-fulldeps/internal-lints/lint_pass_impl_without_macro.rs @@ -6,7 +6,7 @@ extern crate rustc_middle; extern crate rustc_session; -use rustc_session::lint::{LintArray, LintPass}; +use rustc_session::lint::{LintPass, LintVec}; use rustc_session::{declare_lint, declare_lint_pass, impl_lint_pass}; declare_lint! { diff --git a/tests/ui-fulldeps/lint-pass-macros.rs b/tests/ui-fulldeps/lint-pass-macros.rs index b3c2a542792..4c61783418f 100644 --- a/tests/ui-fulldeps/lint-pass-macros.rs +++ b/tests/ui-fulldeps/lint-pass-macros.rs @@ -5,7 +5,7 @@ extern crate rustc_session; -use rustc_session::lint::{LintArray, LintPass}; +use rustc_session::lint::{LintPass, LintVec}; use rustc_session::{declare_lint, declare_lint_pass, impl_lint_pass}; declare_lint! { diff --git a/tests/ui-fulldeps/plugin/auxiliary/lint-group-plugin-test.rs b/tests/ui-fulldeps/plugin/auxiliary/lint-group-plugin-test.rs index 4a41e7fbb72..150f0c6b9a2 100644 --- a/tests/ui-fulldeps/plugin/auxiliary/lint-group-plugin-test.rs +++ b/tests/ui-fulldeps/plugin/auxiliary/lint-group-plugin-test.rs @@ -5,13 +5,12 @@ // Load rustc as a plugin to get macros. extern crate rustc_driver; extern crate rustc_hir; -#[macro_use] extern crate rustc_lint; #[macro_use] extern crate rustc_session; use rustc_driver::plugin::Registry; -use rustc_lint::{LateContext, LateLintPass, LintArray, LintContext, LintId, LintPass}; +use rustc_lint::{LateContext, LateLintPass, LintContext, LintId}; declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'"); diff --git a/tests/ui-fulldeps/plugin/auxiliary/lint-plugin-test.rs b/tests/ui-fulldeps/plugin/auxiliary/lint-plugin-test.rs index 30956deb799..acc5fe76051 100644 --- a/tests/ui-fulldeps/plugin/auxiliary/lint-plugin-test.rs +++ b/tests/ui-fulldeps/plugin/auxiliary/lint-plugin-test.rs @@ -6,14 +6,14 @@ extern crate rustc_ast; // Load rustc as a plugin to get macros extern crate rustc_driver; -#[macro_use] extern crate rustc_lint; #[macro_use] extern crate rustc_session; +use rustc_ast::ast; use rustc_driver::plugin::Registry; -use rustc_lint::{EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass}; -use rustc_ast as ast; +use rustc_lint::{EarlyContext, EarlyLintPass, LintContext}; + declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'"); declare_lint_pass!(Pass => [TEST_LINT]); diff --git a/tests/ui-fulldeps/plugin/auxiliary/lint-tool-test.rs b/tests/ui-fulldeps/plugin/auxiliary/lint-tool-test.rs index c2c024865e8..21de4aa7008 100644 --- a/tests/ui-fulldeps/plugin/auxiliary/lint-tool-test.rs +++ b/tests/ui-fulldeps/plugin/auxiliary/lint-tool-test.rs @@ -4,14 +4,14 @@ extern crate rustc_ast; // Load rustc as a plugin to get macros extern crate rustc_driver; -#[macro_use] extern crate rustc_lint; #[macro_use] extern crate rustc_session; -use rustc_driver::plugin::Registry; -use rustc_lint::{EarlyContext, EarlyLintPass, LintArray, LintContext, LintId, LintPass}; use rustc_ast as ast; +use rustc_driver::plugin::Registry; +use rustc_lint::{EarlyContext, EarlyLintPass, LintContext, LintId}; + declare_tool_lint!(pub clippy::TEST_LINT, Warn, "Warn about stuff"); declare_tool_lint!( /// Some docs diff --git a/tests/ui-fulldeps/stable-mir/compilation-result.rs b/tests/ui-fulldeps/stable-mir/compilation-result.rs index 23a9e2a064c..3ec1519fb13 100644 --- a/tests/ui-fulldeps/stable-mir/compilation-result.rs +++ b/tests/ui-fulldeps/stable-mir/compilation-result.rs @@ -11,9 +11,10 @@ extern crate rustc_middle; extern crate rustc_smir; +extern crate stable_mir; use rustc_middle::ty::TyCtxt; -use rustc_smir::{rustc_internal, stable_mir}; +use rustc_smir::rustc_internal; use std::io::Write; use std::ops::ControlFlow; diff --git a/tests/ui-fulldeps/stable-mir/crate-info.rs b/tests/ui-fulldeps/stable-mir/crate-info.rs index a11720c4b55..ce4ee3c2463 100644 --- a/tests/ui-fulldeps/stable-mir/crate-info.rs +++ b/tests/ui-fulldeps/stable-mir/crate-info.rs @@ -13,13 +13,13 @@ extern crate rustc_hir; extern crate rustc_middle; extern crate rustc_smir; +extern crate stable_mir; use rustc_hir::def::DefKind; use rustc_middle::ty::TyCtxt; -use rustc_smir::{ - rustc_internal, - stable_mir::{self, fold::Foldable}, -}; +use rustc_smir::rustc_internal; + +use stable_mir::fold::Foldable; use std::assert_matches::assert_matches; use std::io::Write; use std::ops::ControlFlow; @@ -27,7 +27,7 @@ use std::ops::ControlFlow; const CRATE_NAME: &str = "input"; /// This function uses the Stable MIR APIs to get information about the test crate. -fn test_stable_mir(tcx: TyCtxt<'_>) -> ControlFlow<()> { +fn test_stable_mir(_tcx: TyCtxt<'_>) -> ControlFlow<()> { // Get the local crate using stable_mir API. let local = stable_mir::local_crate(); assert_eq!(&local.name, CRATE_NAME); @@ -36,12 +36,12 @@ fn test_stable_mir(tcx: TyCtxt<'_>) -> ControlFlow<()> { // Find items in the local crate. let items = stable_mir::all_local_items(); - assert!(get_item(tcx, &items, (DefKind::Fn, "foo::bar")).is_some()); + assert!(get_item(&items, (DefKind::Fn, "foo::bar")).is_some()); // Find the `std` crate. assert!(stable_mir::find_crate("std").is_some()); - let bar = get_item(tcx, &items, (DefKind::Fn, "bar")).unwrap(); + let bar = get_item(&items, (DefKind::Fn, "bar")).unwrap(); let body = bar.body(); assert_eq!(body.locals.len(), 2); assert_eq!(body.blocks.len(), 1); @@ -56,7 +56,7 @@ fn test_stable_mir(tcx: TyCtxt<'_>) -> ControlFlow<()> { other => panic!("{other:?}"), } - let foo_bar = get_item(tcx, &items, (DefKind::Fn, "foo_bar")).unwrap(); + let foo_bar = get_item(&items, (DefKind::Fn, "foo_bar")).unwrap(); let body = foo_bar.body(); assert_eq!(body.locals.len(), 7); assert_eq!(body.blocks.len(), 4); @@ -66,7 +66,7 @@ fn test_stable_mir(tcx: TyCtxt<'_>) -> ControlFlow<()> { other => panic!("{other:?}"), } - let types = get_item(tcx, &items, (DefKind::Fn, "types")).unwrap(); + let types = get_item(&items, (DefKind::Fn, "types")).unwrap(); let body = types.body(); assert_eq!(body.locals.len(), 6); assert_matches!( @@ -96,7 +96,7 @@ fn test_stable_mir(tcx: TyCtxt<'_>) -> ControlFlow<()> { )) ); - let drop = get_item(tcx, &items, (DefKind::Fn, "drop")).unwrap(); + let drop = get_item(&items, (DefKind::Fn, "drop")).unwrap(); let body = drop.body(); assert_eq!(body.blocks.len(), 2); let block = &body.blocks[0]; @@ -105,7 +105,7 @@ fn test_stable_mir(tcx: TyCtxt<'_>) -> ControlFlow<()> { other => panic!("{other:?}"), } - let assert = get_item(tcx, &items, (DefKind::Fn, "assert")).unwrap(); + let assert = get_item(&items, (DefKind::Fn, "assert")).unwrap(); let body = assert.body(); assert_eq!(body.blocks.len(), 2); let block = &body.blocks[0]; @@ -114,7 +114,7 @@ fn test_stable_mir(tcx: TyCtxt<'_>) -> ControlFlow<()> { other => panic!("{other:?}"), } - let monomorphic = get_item(tcx, &items, (DefKind::Fn, "monomorphic")).unwrap(); + let monomorphic = get_item(&items, (DefKind::Fn, "monomorphic")).unwrap(); for block in monomorphic.body().blocks { match &block.terminator { stable_mir::mir::Terminator::Call { func, .. } => match func { @@ -154,7 +154,7 @@ fn test_stable_mir(tcx: TyCtxt<'_>) -> ControlFlow<()> { } } - let foo_const = get_item(tcx, &items, (DefKind::Const, "FOO")).unwrap(); + let foo_const = get_item(&items, (DefKind::Const, "FOO")).unwrap(); // Ensure we don't panic trying to get the body of a constant. foo_const.body(); @@ -163,13 +163,11 @@ fn test_stable_mir(tcx: TyCtxt<'_>) -> ControlFlow<()> { // Use internal API to find a function in a crate. fn get_item<'a>( - tcx: TyCtxt, items: &'a stable_mir::CrateItems, item: (DefKind, &str), ) -> Option<&'a stable_mir::CrateItem> { items.iter().find(|crate_item| { - let def_id = rustc_internal::item_def_id(crate_item); - tcx.def_kind(def_id) == item.0 && tcx.def_path_str(def_id) == item.1 + crate_item.kind().to_string() == format!("{:?}", item.0) && crate_item.name() == item.1 }) } diff --git a/tests/ui/abi/compatibility.rs b/tests/ui/abi/compatibility.rs index 249e8176283..1f049b1785a 100644 --- a/tests/ui/abi/compatibility.rs +++ b/tests/ui/abi/compatibility.rs @@ -1,16 +1,174 @@ // check-pass +// revisions: host +// revisions: arm +//[arm] compile-flags: --target arm-unknown-linux-gnueabi +//[arm] needs-llvm-components: arm +// revisions: aarch64 +//[aarch64] compile-flags: --target aarch64-unknown-linux-gnu +//[aarch64] needs-llvm-components: aarch64 +// revisions: s390x +//[s390x] compile-flags: --target s390x-unknown-linux-gnu +//[s390x] needs-llvm-components: systemz +// revisions: mips +//[mips] compile-flags: --target mips-unknown-linux-gnu +//[mips] needs-llvm-components: mips +// revisions: mips64 +//[mips64] compile-flags: --target mips64-unknown-linux-gnuabi64 +//[mips64] needs-llvm-components: mips +// revisions: sparc +//[sparc] compile-flags: --target sparc-unknown-linux-gnu +//[sparc] needs-llvm-components: sparc +// revisions: sparc64 +//[sparc64] compile-flags: --target sparc64-unknown-linux-gnu +//[sparc64] needs-llvm-components: sparc +// revisions: powerpc64 +//[powerpc64] compile-flags: --target powerpc64-unknown-linux-gnu +//[powerpc64] needs-llvm-components: powerpc +// revisions: riscv +//[riscv] compile-flags: --target riscv64gc-unknown-linux-gnu +//[riscv] needs-llvm-components: riscv +// revisions: loongarch64 +//[loongarch64] compile-flags: --target loongarch64-unknown-linux-gnu +//[loongarch64] needs-llvm-components: loongarch +// revisions: wasm +//[wasm] compile-flags: --target wasm32-unknown-unknown +//[wasm] needs-llvm-components: webassembly +// revisions: wasi +//[wasi] compile-flags: --target wasm32-wasi +//[wasi] needs-llvm-components: webassembly +// revisions: nvptx64 +//[nvptx64] compile-flags: --target nvptx64-nvidia-cuda +//[nvptx64] needs-llvm-components: nvptx #![feature(rustc_attrs, unsized_fn_params, transparent_unions)] +#![cfg_attr(not(host), feature(no_core, lang_items), no_std, no_core)] #![allow(unused, improper_ctypes_definitions, internal_features)] -use std::marker::PhantomData; -use std::mem::ManuallyDrop; -use std::num::NonZeroI32; -use std::ptr::NonNull; -// FIXME: a bunch of targets are broken in various ways. +// FIXME: some targets are broken in various ways. // Hence there are `cfg` throughout this test to disable parts of it on those targets. // sparc64: https://github.com/rust-lang/rust/issues/115336 // mips64: https://github.com/rust-lang/rust/issues/115404 +#[cfg(host)] +use std::{ + any::Any, marker::PhantomData, mem::ManuallyDrop, num::NonZeroI32, ptr::NonNull, rc::Rc, + sync::Arc, +}; + +/// To work cross-target this test must be no_core. +/// This little prelude supplies what we need. +#[cfg(not(host))] +mod prelude { + #[lang = "sized"] + pub trait Sized {} + + #[lang = "receiver"] + pub trait Receiver {} + impl<T: ?Sized> Receiver for &T {} + impl<T: ?Sized> Receiver for &mut T {} + + #[lang = "copy"] + pub trait Copy: Sized {} + impl Copy for i32 {} + impl Copy for f32 {} + impl<T: ?Sized> Copy for &T {} + impl<T: ?Sized> Copy for *const T {} + impl<T: ?Sized> Copy for *mut T {} + + #[lang = "clone"] + pub trait Clone: Sized { + fn clone(&self) -> Self; + } + + #[lang = "phantom_data"] + pub struct PhantomData<T: ?Sized>; + impl<T: ?Sized> Copy for PhantomData<T> {} + + #[lang = "unsafe_cell"] + #[repr(transparent)] + pub struct UnsafeCell<T: ?Sized> { + value: T, + } + + pub trait Any: 'static {} + + pub enum Option<T> { + None, + Some(T), + } + impl<T: Copy> Copy for Option<T> {} + + pub enum Result<T, E> { + Ok(T), + Err(E), + } + impl<T: Copy, E: Copy> Copy for Result<T, E> {} + + #[lang = "manually_drop"] + #[repr(transparent)] + pub struct ManuallyDrop<T: ?Sized> { + value: T, + } + impl<T: Copy + ?Sized> Copy for ManuallyDrop<T> {} + + #[repr(transparent)] + #[rustc_layout_scalar_valid_range_start(1)] + #[rustc_nonnull_optimization_guaranteed] + pub struct NonNull<T: ?Sized> { + pointer: *const T, + } + impl<T: ?Sized> Copy for NonNull<T> {} + + #[repr(transparent)] + #[rustc_layout_scalar_valid_range_start(1)] + #[rustc_nonnull_optimization_guaranteed] + pub struct NonZeroI32(i32); + + // This just stands in for a non-trivial type. + pub struct Vec<T> { + ptr: NonNull<T>, + cap: usize, + len: usize, + } + + pub struct Unique<T: ?Sized> { + pub pointer: NonNull<T>, + pub _marker: PhantomData<T>, + } + + pub struct Global; + + #[lang = "owned_box"] + pub struct Box<T: ?Sized, A = Global>(Unique<T>, A); + + #[repr(C)] + struct RcBox<T: ?Sized> { + strong: UnsafeCell<usize>, + weak: UnsafeCell<usize>, + value: T, + } + pub struct Rc<T: ?Sized, A = Global> { + ptr: NonNull<RcBox<T>>, + phantom: PhantomData<RcBox<T>>, + alloc: A, + } + + #[repr(C, align(8))] + struct AtomicUsize(usize); + #[repr(C)] + struct ArcInner<T: ?Sized> { + strong: AtomicUsize, + weak: AtomicUsize, + data: T, + } + pub struct Arc<T: ?Sized, A = Global> { + ptr: NonNull<ArcInner<T>>, + phantom: PhantomData<ArcInner<T>>, + alloc: A, + } +} +#[cfg(not(host))] +use prelude::*; + macro_rules! assert_abi_compatible { ($name:ident, $t1:ty, $t2:ty) => { mod $name { @@ -26,8 +184,13 @@ macro_rules! assert_abi_compatible { }; } -#[derive(Copy, Clone)] struct Zst; +impl Copy for Zst {} +impl Clone for Zst { + fn clone(&self) -> Self { + Zst + } +} #[repr(C)] struct ReprC1<T: ?Sized>(T); @@ -85,8 +248,8 @@ test_abi_compatible!(nonzero_int, NonZeroI32, i32); // `DispatchFromDyn` relies on ABI compatibility. // This is interesting since these types are not `repr(transparent)`. -test_abi_compatible!(rc, std::rc::Rc<i32>, *mut i32); -test_abi_compatible!(arc, std::sync::Arc<i32>, *mut i32); +test_abi_compatible!(rc, Rc<i32>, *mut i32); +test_abi_compatible!(arc, Arc<i32>, *mut i32); // `repr(transparent)` compatibility. #[repr(transparent)] @@ -160,7 +323,7 @@ mod unsized_ { use super::*; test_transparent_unsized!(str_, str); test_transparent_unsized!(slice, [u8]); - test_transparent_unsized!(dyn_trait, dyn std::any::Any); + test_transparent_unsized!(dyn_trait, dyn Any); } // RFC 3391 <https://rust-lang.github.io/rfcs/3391-result_ffi_guarantees.html>. @@ -185,7 +348,7 @@ test_nonnull!(ref_unsized, &[i32]); test_nonnull!(mut_unsized, &mut [i32]); test_nonnull!(fn_, fn()); test_nonnull!(nonnull, NonNull<i32>); -test_nonnull!(nonnull_unsized, NonNull<dyn std::fmt::Debug>); +test_nonnull!(nonnull_unsized, NonNull<dyn Any>); test_nonnull!(non_zero, NonZeroI32); fn main() {} diff --git a/tests/ui/abi/relocation_model_pic.rs b/tests/ui/abi/relocation_model_pic.rs index 0cfc44cd09d..cca2e8db74d 100644 --- a/tests/ui/abi/relocation_model_pic.rs +++ b/tests/ui/abi/relocation_model_pic.rs @@ -1,7 +1,6 @@ // run-pass // compile-flags: -C relocation-model=pic -// ignore-emscripten no pic -// ignore-wasm +// needs-relocation-model-pic #![feature(cfg_relocation_model)] diff --git a/tests/ui/associated-inherent-types/type-alias-bounds-are-enforced.rs b/tests/ui/associated-inherent-types/type-alias-bounds-are-enforced.rs index 5c59f217be6..99769692342 100644 --- a/tests/ui/associated-inherent-types/type-alias-bounds-are-enforced.rs +++ b/tests/ui/associated-inherent-types/type-alias-bounds-are-enforced.rs @@ -1,6 +1,5 @@ -// FIXME(inherent_associated_types): This should be `check-pass` -// known-bug: #108491 // compile-flags: --crate-type=lib +// check-pass #![feature(inherent_associated_types)] #![allow(incomplete_features)] @@ -8,11 +7,6 @@ // Bounds on the self type play a major role in the resolution of inherent associated types (*). // As a result of that, if a type alias contains any then its bounds have to be respected and the // lint `type_alias_bounds` should not fire. -// -// FIXME(inherent_associated_types): In the current implementation that is. We might move the -// selection phase of IATs from hir_typeck to trait_selection resulting in us not requiring the -// ParamEnv that early allowing us to ignore bounds on type aliases again. -// Triage this before stabilization. #![deny(type_alias_bounds)] diff --git a/tests/ui/associated-inherent-types/type-alias-bounds-are-enforced.stderr b/tests/ui/associated-inherent-types/type-alias-bounds-are-enforced.stderr deleted file mode 100644 index 5e18543fc90..00000000000 --- a/tests/ui/associated-inherent-types/type-alias-bounds-are-enforced.stderr +++ /dev/null @@ -1,55 +0,0 @@ -error[E0391]: cycle detected when expanding type alias `Alias` - --> $DIR/type-alias-bounds-are-enforced.rs:19:1 - | -LL | pub type Alias<T: Bound> = (Source<T>::Assoc,); - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: ...which requires computing the variances of `Source`... - --> $DIR/type-alias-bounds-are-enforced.rs:21:1 - | -LL | pub struct Source<T>(T); - | ^^^^^^^^^^^^^^^^^^^^ - = note: ...which requires computing the variances for items in this crate... - = note: ...which again requires expanding type alias `Alias`, completing the cycle -note: cycle used when collecting item types in top-level module - --> $DIR/type-alias-bounds-are-enforced.rs:5:1 - | -LL | / #![feature(inherent_associated_types)] -LL | | #![allow(incomplete_features)] -LL | | -LL | | // Bounds on the self type play a major role in the resolution of inherent associated types (*). -... | -LL | | pub type Assoc = (); -LL | | } - | |_^ - = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information - -error[E0391]: cycle detected when expanding type alias `Alias` - --> $DIR/type-alias-bounds-are-enforced.rs:19:1 - | -LL | pub type Alias<T: Bound> = (Source<T>::Assoc,); - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: ...which requires computing the variances of `Source`... - --> $DIR/type-alias-bounds-are-enforced.rs:21:1 - | -LL | pub struct Source<T>(T); - | ^^^^^^^^^^^^^^^^^^^^ - = note: ...which requires computing the variances for items in this crate... - = note: ...which again requires expanding type alias `Alias`, completing the cycle -note: cycle used when collecting item types in top-level module - --> $DIR/type-alias-bounds-are-enforced.rs:5:1 - | -LL | / #![feature(inherent_associated_types)] -LL | | #![allow(incomplete_features)] -LL | | -LL | | // Bounds on the self type play a major role in the resolution of inherent associated types (*). -... | -LL | | pub type Assoc = (); -LL | | } - | |_^ - = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/async-await/const-async-fn-in-main.rs b/tests/ui/async-await/const-async-fn-in-main.rs new file mode 100644 index 00000000000..5d1aa4d83f3 --- /dev/null +++ b/tests/ui/async-await/const-async-fn-in-main.rs @@ -0,0 +1,7 @@ +// edition:2021 +// Check what happens when a const async fn is in the main function (#102796) + +fn main() { + const async fn a() {} +//~^ ERROR functions cannot be both `const` and `async` +} diff --git a/tests/ui/async-await/const-async-fn-in-main.stderr b/tests/ui/async-await/const-async-fn-in-main.stderr new file mode 100644 index 00000000000..10b15170922 --- /dev/null +++ b/tests/ui/async-await/const-async-fn-in-main.stderr @@ -0,0 +1,11 @@ +error: functions cannot be both `const` and `async` + --> $DIR/const-async-fn-in-main.rs:5:5 + | +LL | const async fn a() {} + | ^^^^^-^^^^^---------- + | | | + | | `async` because of this + | `const` because of this + +error: aborting due to previous error + diff --git a/tests/ui/async-await/feature-self-return-type.rs b/tests/ui/async-await/feature-self-return-type.rs index 41f887430c1..ae6f766d247 100644 --- a/tests/ui/async-await/feature-self-return-type.rs +++ b/tests/ui/async-await/feature-self-return-type.rs @@ -1,5 +1,4 @@ // edition:2018 -#![feature(impl_trait_projections)] // This test checks that we emit the correct borrowck error when `Self` is used as a return type. // See #61949 for context. diff --git a/tests/ui/async-await/feature-self-return-type.stderr b/tests/ui/async-await/feature-self-return-type.stderr index 747c54b6694..dc160bfbf61 100644 --- a/tests/ui/async-await/feature-self-return-type.stderr +++ b/tests/ui/async-await/feature-self-return-type.stderr @@ -1,5 +1,5 @@ error[E0597]: `bar` does not live long enough - --> $DIR/feature-self-return-type.rs:22:18 + --> $DIR/feature-self-return-type.rs:21:18 | LL | let x = { | - borrow later stored here diff --git a/tests/ui/async-await/in-trait/async-associated-types.rs b/tests/ui/async-await/in-trait/async-associated-types.rs index 974f5aaff83..3e2739a164f 100644 --- a/tests/ui/async-await/in-trait/async-associated-types.rs +++ b/tests/ui/async-await/in-trait/async-associated-types.rs @@ -2,7 +2,6 @@ // edition: 2021 #![feature(async_fn_in_trait)] -#![feature(impl_trait_projections)] #![allow(incomplete_features)] use std::fmt::Debug; diff --git a/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.stderr b/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.stderr index e0c1acfedfc..41e84466a14 100644 --- a/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.stderr +++ b/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.stderr @@ -2,7 +2,7 @@ error[E0391]: cycle detected when computing layout of `{async fn body@$DIR/indir | = note: ...which requires computing layout of `<<A as First>::Second as Second>::{opaque#0}`... = note: ...which again requires computing layout of `{async fn body@$DIR/indirect-recursion-issue-112047.rs:35:27: 37:6}`, completing the cycle - = note: cycle used when computing layout of `<impl at $DIR/indirect-recursion-issue-112047.rs:31:1: 31:21>::second::{opaque#0}` + = note: cycle used when computing layout of `{async block@$DIR/indirect-recursion-issue-112047.rs:8:13: 10:6}` = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error diff --git a/tests/ui/async-await/issue-61949-self-return-type.rs b/tests/ui/async-await/issue-61949-self-return-type.rs deleted file mode 100644 index d73dbc6e828..00000000000 --- a/tests/ui/async-await/issue-61949-self-return-type.rs +++ /dev/null @@ -1,28 +0,0 @@ -// edition:2018 -// gate-test-impl_trait_projections - -// This test checks that `Self` is prohibited as a return type. See #61949 for context. - -pub struct Foo<'a> { - pub bar: &'a i32, -} - -impl<'a> Foo<'a> { - pub async fn new(_bar: &'a i32) -> Self { - //~^ ERROR `async fn` return type cannot contain a projection or `Self` that references lifetimes from a parent scope - Foo { - bar: &22 - } - } -} - -async fn foo() { - let x = { - let bar = 22; - Foo::new(&bar).await - //~^ ERROR `bar` does not live long enough - }; - drop(x); -} - -fn main() { } diff --git a/tests/ui/async-await/issue-61949-self-return-type.stderr b/tests/ui/async-await/issue-61949-self-return-type.stderr deleted file mode 100644 index ac85ed2887a..00000000000 --- a/tests/ui/async-await/issue-61949-self-return-type.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error[E0658]: `async fn` return type cannot contain a projection or `Self` that references lifetimes from a parent scope - --> $DIR/issue-61949-self-return-type.rs:11:40 - | -LL | pub async fn new(_bar: &'a i32) -> Self { - | ^^^^ help: consider spelling out the type instead: `Foo<'a>` - | - = note: see issue #103532 <https://github.com/rust-lang/rust/issues/103532> for more information - = help: add `#![feature(impl_trait_projections)]` to the crate attributes to enable - -error[E0597]: `bar` does not live long enough - --> $DIR/issue-61949-self-return-type.rs:22:18 - | -LL | let x = { - | - borrow later stored here -LL | let bar = 22; - | --- binding `bar` declared here -LL | Foo::new(&bar).await - | ^^^^ borrowed value does not live long enough -LL | -LL | }; - | - `bar` dropped here while still borrowed - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0597, E0658. -For more information about an error, try `rustc --explain E0597`. diff --git a/tests/ui/async-await/issues/issue-78600.rs b/tests/ui/async-await/issues/issue-78600.rs index 8aaeaecf3e1..4303fc7952f 100644 --- a/tests/ui/async-await/issues/issue-78600.rs +++ b/tests/ui/async-await/issues/issue-78600.rs @@ -1,10 +1,10 @@ +// check-pass // edition:2018 struct S<'a>(&'a i32); impl<'a> S<'a> { async fn new(i: &'a i32) -> Result<Self, ()> { - //~^ ERROR: `async fn` Ok(S(&22)) } } diff --git a/tests/ui/async-await/issues/issue-78600.stderr b/tests/ui/async-await/issues/issue-78600.stderr deleted file mode 100644 index 37eafa996c5..00000000000 --- a/tests/ui/async-await/issues/issue-78600.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0658]: `async fn` return type cannot contain a projection or `Self` that references lifetimes from a parent scope - --> $DIR/issue-78600.rs:6:33 - | -LL | async fn new(i: &'a i32) -> Result<Self, ()> { - | ^^^^^^^----^^^^^ - | | - | help: consider spelling out the type instead: `S<'a>` - | - = note: see issue #103532 <https://github.com/rust-lang/rust/issues/103532> for more information - = help: add `#![feature(impl_trait_projections)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/closures/issue-112547.rs b/tests/ui/closures/issue-112547.rs new file mode 100644 index 00000000000..8ecb2abccd4 --- /dev/null +++ b/tests/ui/closures/issue-112547.rs @@ -0,0 +1,15 @@ +#![feature(non_lifetime_binders)] + //~^ WARNING the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes + +pub fn bar() +where + for<const N: usize = { + (||1usize)() +}> V: IntoIterator +//~^ ERROR cannot find type `V` in this scope [E0412] +{ +} + +fn main() { + bar(); +} diff --git a/tests/ui/closures/issue-112547.stderr b/tests/ui/closures/issue-112547.stderr new file mode 100644 index 00000000000..d86b05dc6a7 --- /dev/null +++ b/tests/ui/closures/issue-112547.stderr @@ -0,0 +1,23 @@ +error[E0412]: cannot find type `V` in this scope + --> $DIR/issue-112547.rs:8:4 + | +LL | }> V: IntoIterator + | ^ not found in this scope + | +help: you might be missing a type parameter + | +LL | pub fn bar<V>() + | +++ + +warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/issue-112547.rs:1:12 + | +LL | #![feature(non_lifetime_binders)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information + = note: `#[warn(incomplete_features)]` on by default + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0412`. diff --git a/tests/ui/codegen/issue-79865-llvm-miscompile.rs b/tests/ui/codegen/issue-79865-llvm-miscompile.rs new file mode 100644 index 00000000000..b77f09f8e9a --- /dev/null +++ b/tests/ui/codegen/issue-79865-llvm-miscompile.rs @@ -0,0 +1,38 @@ +// run-pass +// only-x86_64 +// compile-flags: -C opt-level=3 + +// Regression test for issue #79865. +// The assertion will fail when compiled with Rust 1.56..=1.59 +// due to a LLVM miscompilation. + +use std::arch::x86_64::*; + +fn main() { + if is_x86_feature_detected!("avx") { + let res: [f64; 4] = unsafe { std::mem::transmute::<_, _>(first()) }; + assert_eq!(res, [22.0, 44.0, 66.0, 88.0]); + } +} + +#[target_feature(enable = "avx")] +unsafe fn first() -> __m256d { + second() +} + +unsafe fn second() -> __m256d { + let v0 = _mm256_setr_pd(1.0, 2.0, 3.0, 4.0); + let v1 = _mm256_setr_pd(10.0, 20.0, 30.0, 40.0); + + // needs to be called twice to hit the miscompilation + let (add, _) = add_sub(v0, v1); + let (add, _) = add_sub(add, add); + add +} + +#[inline(never)] // needed to hit the miscompilation +unsafe fn add_sub(v1: __m256d, v0: __m256d) -> (__m256d, __m256d) { + let add = _mm256_add_pd(v0, v1); + let sub = _mm256_sub_pd(v0, v1); + (add, sub) +} diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.rs b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.rs index 08f7c5cb542..7174d1ec4f2 100644 --- a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.rs +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.rs @@ -10,10 +10,12 @@ struct CantParam(ImplementsConstParamTy); impl std::marker::ConstParamTy for CantParam {} //~^ error: the type `CantParam` does not `#[derive(Eq)]` //~| error: the type `CantParam` does not `#[derive(PartialEq)]` +//~| the trait bound `CantParam: Eq` is not satisfied #[derive(std::marker::ConstParamTy)] //~^ error: the type `CantParamDerive` does not `#[derive(Eq)]` //~| error: the type `CantParamDerive` does not `#[derive(PartialEq)]` +//~| the trait bound `CantParamDerive: Eq` is not satisfied struct CantParamDerive(ImplementsConstParamTy); fn check<T: std::marker::ConstParamTy>() {} diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.stderr b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.stderr index 43c5b96dc7c..2cf7cc07dbe 100644 --- a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.stderr +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_no_structural_eq.stderr @@ -1,3 +1,17 @@ +error[E0277]: the trait bound `CantParam: Eq` is not satisfied + --> $DIR/const_param_ty_impl_no_structural_eq.rs:10:36 + | +LL | impl std::marker::ConstParamTy for CantParam {} + | ^^^^^^^^^ the trait `Eq` is not implemented for `CantParam` + | +note: required by a bound in `ConstParamTy` + --> $SRC_DIR/core/src/marker.rs:LL:COL +help: consider annotating `CantParam` with `#[derive(Eq)]` + | +LL + #[derive(Eq)] +LL | struct CantParam(ImplementsConstParamTy); + | + error[E0277]: the type `CantParam` does not `#[derive(PartialEq)]` --> $DIR/const_param_ty_impl_no_structural_eq.rs:10:36 | @@ -16,8 +30,23 @@ LL | impl std::marker::ConstParamTy for CantParam {} note: required by a bound in `ConstParamTy` --> $SRC_DIR/core/src/marker.rs:LL:COL +error[E0277]: the trait bound `CantParamDerive: Eq` is not satisfied + --> $DIR/const_param_ty_impl_no_structural_eq.rs:15:10 + | +LL | #[derive(std::marker::ConstParamTy)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Eq` is not implemented for `CantParamDerive` + | +note: required by a bound in `ConstParamTy` + --> $SRC_DIR/core/src/marker.rs:LL:COL + = note: this error originates in the derive macro `std::marker::ConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `CantParamDerive` with `#[derive(Eq)]` + | +LL + #[derive(Eq)] +LL | struct CantParamDerive(ImplementsConstParamTy); + | + error[E0277]: the type `CantParamDerive` does not `#[derive(PartialEq)]` - --> $DIR/const_param_ty_impl_no_structural_eq.rs:14:10 + --> $DIR/const_param_ty_impl_no_structural_eq.rs:15:10 | LL | #[derive(std::marker::ConstParamTy)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `StructuralPartialEq` is not implemented for `CantParamDerive` @@ -27,7 +56,7 @@ note: required by a bound in `ConstParamTy` = note: this error originates in the derive macro `std::marker::ConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the type `CantParamDerive` does not `#[derive(Eq)]` - --> $DIR/const_param_ty_impl_no_structural_eq.rs:14:10 + --> $DIR/const_param_ty_impl_no_structural_eq.rs:15:10 | LL | #[derive(std::marker::ConstParamTy)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `StructuralEq` is not implemented for `CantParamDerive` @@ -36,6 +65,6 @@ note: required by a bound in `ConstParamTy` --> $SRC_DIR/core/src/marker.rs:LL:COL = note: this error originates in the derive macro `std::marker::ConstParamTy` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 4 previous errors +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/const-generics/adt_const_params/suggest_feature_only_when_possible.rs b/tests/ui/const-generics/adt_const_params/suggest_feature_only_when_possible.rs new file mode 100644 index 00000000000..a83830178d4 --- /dev/null +++ b/tests/ui/const-generics/adt_const_params/suggest_feature_only_when_possible.rs @@ -0,0 +1,44 @@ +// Test that when adt_const_params is not enabled, we suggest adding the feature only when +// it would be possible for the type to be used as a const generic or when it's likely +// possible for the user to fix their type to be used. + +// Can never be used as const generics. +fn uwu_0<const N: &'static mut ()>() {} +//~^ ERROR: forbidden as the type of a const generic + +// Needs the feature but can be used, so suggest adding the feature. +fn owo_0<const N: &'static u32>() {} +//~^ ERROR: forbidden as the type of a const generic +//~^^ HELP: add `#![feature(adt_const_params)]` + +// Can only be used in const generics with changes. +struct Meow { + meow: u8, +} + +fn meow_0<const N: Meow>() {} +//~^ ERROR: forbidden as the type of a const generic +//~^^ HELP: add `#![feature(adt_const_params)]` +fn meow_1<const N: &'static Meow>() {} +//~^ ERROR: forbidden as the type of a const generic +//~^^ HELP: add `#![feature(adt_const_params)]` +fn meow_2<const N: [Meow; 100]>() {} +//~^ ERROR: forbidden as the type of a const generic +//~^^ HELP: add `#![feature(adt_const_params)]` +fn meow_3<const N: (Meow, u8)>() {} +//~^ ERROR: forbidden as the type of a const generic +//~^^ HELP: add `#![feature(adt_const_params)]` + +// This is suboptimal that it thinks it can be used +// but better to suggest the feature to the user. +fn meow_4<const N: (Meow, String)>() {} +//~^ ERROR: forbidden as the type of a const generic +//~^^ HELP: add `#![feature(adt_const_params)]` + +// Non-local ADT that does not impl `ConstParamTy` +fn nya_0<const N: String>() {} +//~^ ERROR: forbidden as the type of a const generic +fn nya_1<const N: Vec<u32>>() {} +//~^ ERROR: forbidden as the type of a const generic + +fn main() {} diff --git a/tests/ui/const-generics/adt_const_params/suggest_feature_only_when_possible.stderr b/tests/ui/const-generics/adt_const_params/suggest_feature_only_when_possible.stderr new file mode 100644 index 00000000000..04527e3158e --- /dev/null +++ b/tests/ui/const-generics/adt_const_params/suggest_feature_only_when_possible.stderr @@ -0,0 +1,80 @@ +error: `&'static mut ()` is forbidden as the type of a const generic parameter + --> $DIR/suggest_feature_only_when_possible.rs:6:19 + | +LL | fn uwu_0<const N: &'static mut ()>() {} + | ^^^^^^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + +error: `&'static u32` is forbidden as the type of a const generic parameter + --> $DIR/suggest_feature_only_when_possible.rs:10:19 + | +LL | fn owo_0<const N: &'static u32>() {} + | ^^^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types + +error: `Meow` is forbidden as the type of a const generic parameter + --> $DIR/suggest_feature_only_when_possible.rs:19:20 + | +LL | fn meow_0<const N: Meow>() {} + | ^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types + +error: `&'static Meow` is forbidden as the type of a const generic parameter + --> $DIR/suggest_feature_only_when_possible.rs:22:20 + | +LL | fn meow_1<const N: &'static Meow>() {} + | ^^^^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types + +error: `[Meow; 100]` is forbidden as the type of a const generic parameter + --> $DIR/suggest_feature_only_when_possible.rs:25:20 + | +LL | fn meow_2<const N: [Meow; 100]>() {} + | ^^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types + +error: `(Meow, u8)` is forbidden as the type of a const generic parameter + --> $DIR/suggest_feature_only_when_possible.rs:28:20 + | +LL | fn meow_3<const N: (Meow, u8)>() {} + | ^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types + +error: `(Meow, String)` is forbidden as the type of a const generic parameter + --> $DIR/suggest_feature_only_when_possible.rs:34:20 + | +LL | fn meow_4<const N: (Meow, String)>() {} + | ^^^^^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types + +error: `String` is forbidden as the type of a const generic parameter + --> $DIR/suggest_feature_only_when_possible.rs:39:19 + | +LL | fn nya_0<const N: String>() {} + | ^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + +error: `Vec<u32>` is forbidden as the type of a const generic parameter + --> $DIR/suggest_feature_only_when_possible.rs:41:19 + | +LL | fn nya_1<const N: Vec<u32>>() {} + | ^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + +error: aborting due to 9 previous errors + diff --git a/tests/ui/const-generics/const-param-elided-lifetime.min.stderr b/tests/ui/const-generics/const-param-elided-lifetime.min.stderr index 656bc29466f..ffe45285988 100644 --- a/tests/ui/const-generics/const-param-elided-lifetime.min.stderr +++ b/tests/ui/const-generics/const-param-elided-lifetime.min.stderr @@ -35,7 +35,7 @@ LL | struct A<const N: &u8>; | ^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: `&u8` is forbidden as the type of a const generic parameter --> $DIR/const-param-elided-lifetime.rs:14:15 @@ -44,7 +44,7 @@ LL | impl<const N: &u8> A<N> { | ^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: `&u8` is forbidden as the type of a const generic parameter --> $DIR/const-param-elided-lifetime.rs:22:15 @@ -53,7 +53,7 @@ LL | impl<const N: &u8> B for A<N> {} | ^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: `&u8` is forbidden as the type of a const generic parameter --> $DIR/const-param-elided-lifetime.rs:26:17 @@ -62,7 +62,7 @@ LL | fn bar<const N: &u8>() {} | ^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: `&u8` is forbidden as the type of a const generic parameter --> $DIR/const-param-elided-lifetime.rs:17:21 @@ -71,7 +71,7 @@ LL | fn foo<const M: &u8>(&self) {} | ^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: aborting due to 10 previous errors diff --git a/tests/ui/const-generics/const-param-type-depends-on-const-param.min.stderr b/tests/ui/const-generics/const-param-type-depends-on-const-param.min.stderr index f829526ca1d..daeeadeed7c 100644 --- a/tests/ui/const-generics/const-param-type-depends-on-const-param.min.stderr +++ b/tests/ui/const-generics/const-param-type-depends-on-const-param.min.stderr @@ -21,7 +21,7 @@ LL | pub struct Dependent<const N: usize, const X: [u8; N]>([(); N]); | ^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: `[u8; N]` is forbidden as the type of a const generic parameter --> $DIR/const-param-type-depends-on-const-param.rs:15:35 @@ -30,7 +30,7 @@ LL | pub struct SelfDependent<const N: [u8; N]>; | ^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: aborting due to 4 previous errors diff --git a/tests/ui/const-generics/float-generic.simple.stderr b/tests/ui/const-generics/float-generic.simple.stderr index 89ca36b0f63..aeb19dc7532 100644 --- a/tests/ui/const-generics/float-generic.simple.stderr +++ b/tests/ui/const-generics/float-generic.simple.stderr @@ -5,7 +5,6 @@ LL | fn foo<const F: f32>() {} | ^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` error: aborting due to previous error diff --git a/tests/ui/const-generics/fn-const-param-call.min.stderr b/tests/ui/const-generics/fn-const-param-call.min.stderr index d984449e6ca..2d316fba1e9 100644 --- a/tests/ui/const-generics/fn-const-param-call.min.stderr +++ b/tests/ui/const-generics/fn-const-param-call.min.stderr @@ -3,12 +3,16 @@ error: using function pointers as const generic parameters is forbidden | LL | struct Wrapper<const F: fn() -> u32>; | ^^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` error: using function pointers as const generic parameters is forbidden --> $DIR/fn-const-param-call.rs:13:15 | LL | impl<const F: fn() -> u32> Wrapper<F> { | ^^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/fn-const-param-infer.min.stderr b/tests/ui/const-generics/fn-const-param-infer.min.stderr index f0767a10994..a7afa484275 100644 --- a/tests/ui/const-generics/fn-const-param-infer.min.stderr +++ b/tests/ui/const-generics/fn-const-param-infer.min.stderr @@ -3,6 +3,8 @@ error: using function pointers as const generic parameters is forbidden | LL | struct Checked<const F: fn(usize) -> bool>; | ^^^^^^^^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` error: aborting due to previous error diff --git a/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.min.stderr b/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.min.stderr index 956e9c9c988..64d1e0bcff4 100644 --- a/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.min.stderr +++ b/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.min.stderr @@ -23,7 +23,7 @@ LL | struct B<const CFG: Config> { | ^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: aborting due to 3 previous errors diff --git a/tests/ui/const-generics/intrinsics-type_name-as-const-argument.min.stderr b/tests/ui/const-generics/intrinsics-type_name-as-const-argument.min.stderr index b8a1027c9eb..4c45339b93b 100644 --- a/tests/ui/const-generics/intrinsics-type_name-as-const-argument.min.stderr +++ b/tests/ui/const-generics/intrinsics-type_name-as-const-argument.min.stderr @@ -14,7 +14,7 @@ LL | trait Trait<const S: &'static str> {} | ^^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/issues/issue-56445-1.min.stderr b/tests/ui/const-generics/issues/issue-56445-1.min.stderr index 71a7051f25b..fc10aba0fec 100644 --- a/tests/ui/const-generics/issues/issue-56445-1.min.stderr +++ b/tests/ui/const-generics/issues/issue-56445-1.min.stderr @@ -13,7 +13,7 @@ LL | struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>); | ^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/issues/issue-62878.min.stderr b/tests/ui/const-generics/issues/issue-62878.min.stderr index 9c0e5179cc4..eb8b9732f58 100644 --- a/tests/ui/const-generics/issues/issue-62878.min.stderr +++ b/tests/ui/const-generics/issues/issue-62878.min.stderr @@ -13,7 +13,7 @@ LL | fn foo<const N: usize, const A: [u8; N]>() {} | ^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/issues/issue-63322-forbid-dyn.min.stderr b/tests/ui/const-generics/issues/issue-63322-forbid-dyn.min.stderr index 9f6c7ccf3fe..9d80f1cd01b 100644 --- a/tests/ui/const-generics/issues/issue-63322-forbid-dyn.min.stderr +++ b/tests/ui/const-generics/issues/issue-63322-forbid-dyn.min.stderr @@ -5,7 +5,7 @@ LL | fn test<const T: &'static dyn A>() { | ^^^^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: aborting due to previous error diff --git a/tests/ui/const-generics/issues/issue-68615-adt.min.stderr b/tests/ui/const-generics/issues/issue-68615-adt.min.stderr index df04c4896b4..c8b9f17196a 100644 --- a/tests/ui/const-generics/issues/issue-68615-adt.min.stderr +++ b/tests/ui/const-generics/issues/issue-68615-adt.min.stderr @@ -5,7 +5,7 @@ LL | struct Const<const V: [usize; 0]> {} | ^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: aborting due to previous error diff --git a/tests/ui/const-generics/issues/issue-68615-array.min.stderr b/tests/ui/const-generics/issues/issue-68615-array.min.stderr index 1b4517087e2..fc6cef9d44e 100644 --- a/tests/ui/const-generics/issues/issue-68615-array.min.stderr +++ b/tests/ui/const-generics/issues/issue-68615-array.min.stderr @@ -5,7 +5,7 @@ LL | struct Foo<const V: [usize; 0] > {} | ^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: aborting due to previous error diff --git a/tests/ui/const-generics/issues/issue-71169.min.stderr b/tests/ui/const-generics/issues/issue-71169.min.stderr index ebfb24bec28..bba92f32a78 100644 --- a/tests/ui/const-generics/issues/issue-71169.min.stderr +++ b/tests/ui/const-generics/issues/issue-71169.min.stderr @@ -13,7 +13,7 @@ LL | fn foo<const LEN: usize, const DATA: [u8; LEN]>() {} | ^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/issues/issue-71381.min.stderr b/tests/ui/const-generics/issues/issue-71381.min.stderr index e1e140071fc..e16d3b7a8a4 100644 --- a/tests/ui/const-generics/issues/issue-71381.min.stderr +++ b/tests/ui/const-generics/issues/issue-71381.min.stderr @@ -19,12 +19,16 @@ error: using function pointers as const generic parameters is forbidden | LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&self) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` error: using function pointers as const generic parameters is forbidden --> $DIR/issue-71381.rs:23:19 | LL | const FN: unsafe extern "C" fn(Args), | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` error: aborting due to 4 previous errors diff --git a/tests/ui/const-generics/issues/issue-71382.min.stderr b/tests/ui/const-generics/issues/issue-71382.min.stderr index 715037bd5f1..217166d8479 100644 --- a/tests/ui/const-generics/issues/issue-71382.min.stderr +++ b/tests/ui/const-generics/issues/issue-71382.min.stderr @@ -3,6 +3,8 @@ error: using function pointers as const generic parameters is forbidden | LL | fn test<const FN: fn()>(&self) { | ^^^^ + | + = note: the only supported types are integers, `bool` and `char` error: aborting due to previous error diff --git a/tests/ui/const-generics/issues/issue-71611.min.stderr b/tests/ui/const-generics/issues/issue-71611.min.stderr index b33d7cf9850..b01936f4d25 100644 --- a/tests/ui/const-generics/issues/issue-71611.min.stderr +++ b/tests/ui/const-generics/issues/issue-71611.min.stderr @@ -11,6 +11,8 @@ error: using function pointers as const generic parameters is forbidden | LL | fn func<A, const F: fn(inner: A)>(outer: A) { | ^^^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/issues/issue-72352.min.stderr b/tests/ui/const-generics/issues/issue-72352.min.stderr index eedd73c4dcc..b010996b896 100644 --- a/tests/ui/const-generics/issues/issue-72352.min.stderr +++ b/tests/ui/const-generics/issues/issue-72352.min.stderr @@ -3,6 +3,8 @@ error: using function pointers as const generic parameters is forbidden | LL | unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const i8) -> usize { | ^^^^^^^^^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` error: aborting due to previous error diff --git a/tests/ui/const-generics/issues/issue-73491.min.stderr b/tests/ui/const-generics/issues/issue-73491.min.stderr index f03354fc472..fdf057bdbe4 100644 --- a/tests/ui/const-generics/issues/issue-73491.min.stderr +++ b/tests/ui/const-generics/issues/issue-73491.min.stderr @@ -5,7 +5,7 @@ LL | fn hoge<const IN: [u32; LEN]>() {} | ^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: aborting due to previous error diff --git a/tests/ui/const-generics/issues/issue-73727-static-reference-array-const-param.min.stderr b/tests/ui/const-generics/issues/issue-73727-static-reference-array-const-param.min.stderr index 0a7db62472a..bed0a02a726 100644 --- a/tests/ui/const-generics/issues/issue-73727-static-reference-array-const-param.min.stderr +++ b/tests/ui/const-generics/issues/issue-73727-static-reference-array-const-param.min.stderr @@ -5,7 +5,7 @@ LL | fn a<const X: &'static [u32]>() {} | ^^^^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: aborting due to previous error diff --git a/tests/ui/const-generics/issues/issue-74101.min.stderr b/tests/ui/const-generics/issues/issue-74101.min.stderr index 134c248347d..7852ce5bcfc 100644 --- a/tests/ui/const-generics/issues/issue-74101.min.stderr +++ b/tests/ui/const-generics/issues/issue-74101.min.stderr @@ -5,7 +5,7 @@ LL | fn test<const N: [u8; 1 + 2]>() {} | ^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: `[u8; 1 + 2]` is forbidden as the type of a const generic parameter --> $DIR/issue-74101.rs:9:21 @@ -14,7 +14,7 @@ LL | struct Foo<const N: [u8; 1 + 2]>; | ^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/issues/issue-74255.min.stderr b/tests/ui/const-generics/issues/issue-74255.min.stderr index bbcf8682b71..affeca167e9 100644 --- a/tests/ui/const-generics/issues/issue-74255.min.stderr +++ b/tests/ui/const-generics/issues/issue-74255.min.stderr @@ -5,7 +5,7 @@ LL | fn ice_struct_fn<const I: IceEnum>() {} | ^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: aborting due to previous error diff --git a/tests/ui/const-generics/issues/issue-74950.min.stderr b/tests/ui/const-generics/issues/issue-74950.min.stderr index c37ee93d420..a5dbe10b78a 100644 --- a/tests/ui/const-generics/issues/issue-74950.min.stderr +++ b/tests/ui/const-generics/issues/issue-74950.min.stderr @@ -5,7 +5,7 @@ LL | struct Outer<const I: Inner>; | ^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: `Inner` is forbidden as the type of a const generic parameter --> $DIR/issue-74950.rs:20:23 @@ -14,7 +14,7 @@ LL | struct Outer<const I: Inner>; | ^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: `Inner` is forbidden as the type of a const generic parameter --> $DIR/issue-74950.rs:20:23 @@ -23,7 +23,7 @@ LL | struct Outer<const I: Inner>; | ^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: `Inner` is forbidden as the type of a const generic parameter --> $DIR/issue-74950.rs:20:23 @@ -32,7 +32,7 @@ LL | struct Outer<const I: Inner>; | ^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: `Inner` is forbidden as the type of a const generic parameter --> $DIR/issue-74950.rs:20:23 @@ -41,7 +41,7 @@ LL | struct Outer<const I: Inner>; | ^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: aborting due to 5 previous errors diff --git a/tests/ui/const-generics/issues/issue-75047.min.stderr b/tests/ui/const-generics/issues/issue-75047.min.stderr index 46af19ef395..e316b4624a0 100644 --- a/tests/ui/const-generics/issues/issue-75047.min.stderr +++ b/tests/ui/const-generics/issues/issue-75047.min.stderr @@ -5,7 +5,7 @@ LL | struct Foo<const N: [u8; Bar::<u32>::value()]>; | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: aborting due to previous error diff --git a/tests/ui/const-generics/lifetime-in-const-param.stderr b/tests/ui/const-generics/lifetime-in-const-param.stderr index 8fd9068e8ef..c2fcdcf1a71 100644 --- a/tests/ui/const-generics/lifetime-in-const-param.stderr +++ b/tests/ui/const-generics/lifetime-in-const-param.stderr @@ -11,7 +11,7 @@ LL | struct S<'a, const N: S2>(&'a ()); | ^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/min_const_generics/complex-types.stderr b/tests/ui/const-generics/min_const_generics/complex-types.stderr index 4ddbadb5466..8cc75dbaff9 100644 --- a/tests/ui/const-generics/min_const_generics/complex-types.stderr +++ b/tests/ui/const-generics/min_const_generics/complex-types.stderr @@ -5,7 +5,7 @@ LL | struct Foo<const N: [u8; 0]>; | ^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: `()` is forbidden as the type of a const generic parameter --> $DIR/complex-types.rs:6:21 @@ -14,7 +14,7 @@ LL | struct Bar<const N: ()>; | ^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: `No` is forbidden as the type of a const generic parameter --> $DIR/complex-types.rs:11:21 @@ -23,7 +23,7 @@ LL | struct Fez<const N: No>; | ^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: `&'static u8` is forbidden as the type of a const generic parameter --> $DIR/complex-types.rs:14:21 @@ -32,7 +32,7 @@ LL | struct Faz<const N: &'static u8>; | ^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: `!` is forbidden as the type of a const generic parameter --> $DIR/complex-types.rs:17:21 @@ -41,7 +41,6 @@ LL | struct Fiz<const N: !>; | ^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` error: `()` is forbidden as the type of a const generic parameter --> $DIR/complex-types.rs:20:19 @@ -50,7 +49,7 @@ LL | enum Goo<const N: ()> { A, B } | ^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: `()` is forbidden as the type of a const generic parameter --> $DIR/complex-types.rs:23:20 @@ -59,7 +58,7 @@ LL | union Boo<const N: ()> { a: () } | ^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: aborting due to 7 previous errors diff --git a/tests/ui/const-generics/nested-type.min.stderr b/tests/ui/const-generics/nested-type.min.stderr index 257a9e31e14..ca5af5f969f 100644 --- a/tests/ui/const-generics/nested-type.min.stderr +++ b/tests/ui/const-generics/nested-type.min.stderr @@ -30,7 +30,7 @@ LL | | }]>; | |__^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/projection-as-arg-const.stderr b/tests/ui/const-generics/projection-as-arg-const.stderr index 803ed9c9597..9f727231edf 100644 --- a/tests/ui/const-generics/projection-as-arg-const.stderr +++ b/tests/ui/const-generics/projection-as-arg-const.stderr @@ -5,7 +5,6 @@ LL | pub fn foo<const X: <i32 as Identity>::Identity>() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` error: aborting due to previous error diff --git a/tests/ui/const-generics/raw-ptr-const-param-deref.min.stderr b/tests/ui/const-generics/raw-ptr-const-param-deref.min.stderr index 04bc46cb4ab..1eb238255ab 100644 --- a/tests/ui/const-generics/raw-ptr-const-param-deref.min.stderr +++ b/tests/ui/const-generics/raw-ptr-const-param-deref.min.stderr @@ -3,12 +3,16 @@ error: using raw pointers as const generic parameters is forbidden | LL | struct Const<const P: *const u32>; | ^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` error: using raw pointers as const generic parameters is forbidden --> $DIR/raw-ptr-const-param-deref.rs:11:15 | LL | impl<const P: *const u32> Const<P> { | ^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/raw-ptr-const-param.min.stderr b/tests/ui/const-generics/raw-ptr-const-param.min.stderr index 310422aafcd..13fbc34e51a 100644 --- a/tests/ui/const-generics/raw-ptr-const-param.min.stderr +++ b/tests/ui/const-generics/raw-ptr-const-param.min.stderr @@ -3,6 +3,8 @@ error: using raw pointers as const generic parameters is forbidden | LL | struct Const<const P: *const u32>; | ^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` error: aborting due to previous error diff --git a/tests/ui/const-generics/slice-const-param-mismatch.min.stderr b/tests/ui/const-generics/slice-const-param-mismatch.min.stderr index fed802f6adc..3c086f59b27 100644 --- a/tests/ui/const-generics/slice-const-param-mismatch.min.stderr +++ b/tests/ui/const-generics/slice-const-param-mismatch.min.stderr @@ -5,7 +5,7 @@ LL | struct ConstString<const T: &'static str>; | ^^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: `&'static [u8]` is forbidden as the type of a const generic parameter --> $DIR/slice-const-param-mismatch.rs:9:28 @@ -14,7 +14,7 @@ LL | struct ConstBytes<const T: &'static [u8]>; | ^^^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/std/const-generics-range.min.stderr b/tests/ui/const-generics/std/const-generics-range.min.stderr index 53fca6e884a..d45f749246c 100644 --- a/tests/ui/const-generics/std/const-generics-range.min.stderr +++ b/tests/ui/const-generics/std/const-generics-range.min.stderr @@ -5,7 +5,7 @@ LL | struct _Range<const R: std::ops::Range<usize>>; | ^^^^^^^^^^^^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: `RangeFrom<usize>` is forbidden as the type of a const generic parameter --> $DIR/const-generics-range.rs:13:28 @@ -14,7 +14,7 @@ LL | struct _RangeFrom<const R: std::ops::RangeFrom<usize>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: `RangeFull` is forbidden as the type of a const generic parameter --> $DIR/const-generics-range.rs:18:28 @@ -23,7 +23,7 @@ LL | struct _RangeFull<const R: std::ops::RangeFull>; | ^^^^^^^^^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: `RangeInclusive<usize>` is forbidden as the type of a const generic parameter --> $DIR/const-generics-range.rs:24:33 @@ -32,7 +32,7 @@ LL | struct _RangeInclusive<const R: std::ops::RangeInclusive<usize>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: `RangeTo<usize>` is forbidden as the type of a const generic parameter --> $DIR/const-generics-range.rs:29:26 @@ -41,7 +41,7 @@ LL | struct _RangeTo<const R: std::ops::RangeTo<usize>>; | ^^^^^^^^^^^^^^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: `RangeToInclusive<usize>` is forbidden as the type of a const generic parameter --> $DIR/const-generics-range.rs:34:35 @@ -50,7 +50,7 @@ LL | struct _RangeToInclusive<const R: std::ops::RangeToInclusive<usize>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: aborting due to 6 previous errors diff --git a/tests/ui/const-generics/transmute-const-param-static-reference.min.stderr b/tests/ui/const-generics/transmute-const-param-static-reference.min.stderr index 039c4276c8b..f18e149464d 100644 --- a/tests/ui/const-generics/transmute-const-param-static-reference.min.stderr +++ b/tests/ui/const-generics/transmute-const-param-static-reference.min.stderr @@ -5,7 +5,7 @@ LL | struct Const<const P: &'static ()>; | ^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: aborting due to previous error diff --git a/tests/ui/const-generics/type-dependent/issue-71348.min.stderr b/tests/ui/const-generics/type-dependent/issue-71348.min.stderr index b8fbb397979..6490592c1e1 100644 --- a/tests/ui/const-generics/type-dependent/issue-71348.min.stderr +++ b/tests/ui/const-generics/type-dependent/issue-71348.min.stderr @@ -5,7 +5,7 @@ LL | trait Get<'a, const N: &'static str> { | ^^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: `&'static str` is forbidden as the type of a const generic parameter --> $DIR/issue-71348.rs:18:25 @@ -14,7 +14,7 @@ LL | fn ask<'a, const N: &'static str>(&'a self) -> &'a <Self as Get<N>>::Ta | ^^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/type-dependent/issue-71382.stderr b/tests/ui/const-generics/type-dependent/issue-71382.stderr index ad522aead90..3f42feea562 100644 --- a/tests/ui/const-generics/type-dependent/issue-71382.stderr +++ b/tests/ui/const-generics/type-dependent/issue-71382.stderr @@ -3,6 +3,8 @@ error: using function pointers as const generic parameters is forbidden | LL | fn test<const FN: fn() -> u8>(&self) -> u8 { | ^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` error: aborting due to previous error diff --git a/tests/ui/consts/const_in_pattern/issue-65466.rs b/tests/ui/consts/const_in_pattern/issue-65466.rs index 2b421f4c705..d45c32e170a 100644 --- a/tests/ui/consts/const_in_pattern/issue-65466.rs +++ b/tests/ui/consts/const_in_pattern/issue-65466.rs @@ -15,7 +15,8 @@ const C: &[O<B>] = &[O::None]; fn main() { let x = O::None; match &[x][..] { - C => (), + C => (), //~WARN: the type must implement `PartialEq` + //~| previously accepted _ => (), } } diff --git a/tests/ui/consts/const_in_pattern/issue-65466.stderr b/tests/ui/consts/const_in_pattern/issue-65466.stderr new file mode 100644 index 00000000000..9c80cb3a849 --- /dev/null +++ b/tests/ui/consts/const_in_pattern/issue-65466.stderr @@ -0,0 +1,23 @@ +warning: to use a constant of type `&[O<B>]` in a pattern, the type must implement `PartialEq` + --> $DIR/issue-65466.rs:18:9 + | +LL | C => (), + | ^ + | + = 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 #116122 <https://github.com/rust-lang/rust/issues/116122> + = note: `#[warn(const_patterns_without_partial_eq)]` on by default + +warning: 1 warning emitted + +Future incompatibility report: Future breakage diagnostic: +warning: to use a constant of type `&[O<B>]` in a pattern, the type must implement `PartialEq` + --> $DIR/issue-65466.rs:18:9 + | +LL | C => (), + | ^ + | + = 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 #116122 <https://github.com/rust-lang/rust/issues/116122> + = note: `#[warn(const_patterns_without_partial_eq)]` on by default + diff --git a/tests/ui/did_you_mean/bad-assoc-expr.stderr b/tests/ui/did_you_mean/bad-assoc-expr.stderr index c295cac9aa4..b83078e21b6 100644 --- a/tests/ui/did_you_mean/bad-assoc-expr.stderr +++ b/tests/ui/did_you_mean/bad-assoc-expr.stderr @@ -2,60 +2,104 @@ error: missing angle brackets in associated item path --> $DIR/bad-assoc-expr.rs:3:5 | LL | [i32; 4]::clone(&a); - | ^^^^^^^^^^^^^^^ help: try: `<[i32; 4]>::clone` + | ^^^^^^^^ + | +help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths + | +LL | <[i32; 4]>::clone(&a); + | + + error: missing angle brackets in associated item path --> $DIR/bad-assoc-expr.rs:6:5 | LL | [i32]::as_ref(&a); - | ^^^^^^^^^^^^^ help: try: `<[i32]>::as_ref` + | ^^^^^ + | +help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths + | +LL | <[i32]>::as_ref(&a); + | + + error: missing angle brackets in associated item path --> $DIR/bad-assoc-expr.rs:9:5 | LL | (u8)::clone(&0); - | ^^^^^^^^^^^ help: try: `<(u8)>::clone` + | ^^^^ + | +help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths + | +LL | <(u8)>::clone(&0); + | + + error: missing angle brackets in associated item path --> $DIR/bad-assoc-expr.rs:12:5 | LL | (u8, u8)::clone(&(0, 0)); - | ^^^^^^^^^^^^^^^ help: try: `<(u8, u8)>::clone` + | ^^^^^^^^ + | +help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths + | +LL | <(u8, u8)>::clone(&(0, 0)); + | + + error: missing angle brackets in associated item path --> $DIR/bad-assoc-expr.rs:15:6 | LL | &(u8)::clone(&0); - | ^^^^^^^^^^^ help: try: `<(u8)>::clone` + | ^^^^ + | +help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths + | +LL | &<(u8)>::clone(&0); + | + + error: missing angle brackets in associated item path --> $DIR/bad-assoc-expr.rs:18:10 | LL | 10 + (u8)::clone(&0); - | ^^^^^^^^^^^ help: try: `<(u8)>::clone` + | ^^^^ + | +help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths + | +LL | 10 + <(u8)>::clone(&0); + | + + error: missing angle brackets in associated item path --> $DIR/bad-assoc-expr.rs:32:13 | LL | let _ = ty!()::clone(&0); - | ^^^^^^^^^^^^ help: try: `<ty!()>::clone` + | ^^^^^ + | +help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths + | +LL | let _ = <ty!()>::clone(&0); + | + + error: missing angle brackets in associated item path --> $DIR/bad-assoc-expr.rs:34:5 | LL | ty!()::clone(&0); - | ^^^^^^^^^^^^ help: try: `<ty!()>::clone` + | ^^^^^ + | +help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths + | +LL | <ty!()>::clone(&0); + | + + error: missing angle brackets in associated item path --> $DIR/bad-assoc-expr.rs:23:19 | LL | ($ty: ty) => ($ty::clone(&0)) - | ^^^^^^^^^^ help: try: `<$ty>::clone` + | ^^^ ... LL | expr!(u8); | --------- in this macro invocation | = note: this error originates in the macro `expr` (in Nightly builds, run with -Z macro-backtrace for more info) +help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths + | +LL | ($ty: ty) => (<$ty>::clone(&0)) + | + + error: aborting due to 9 previous errors diff --git a/tests/ui/did_you_mean/bad-assoc-pat.stderr b/tests/ui/did_you_mean/bad-assoc-pat.stderr index 19d173f1b42..8bdeb8ffdd0 100644 --- a/tests/ui/did_you_mean/bad-assoc-pat.stderr +++ b/tests/ui/did_you_mean/bad-assoc-pat.stderr @@ -2,42 +2,71 @@ error: missing angle brackets in associated item path --> $DIR/bad-assoc-pat.rs:3:9 | LL | [u8]::AssocItem => {} - | ^^^^^^^^^^^^^^^ help: try: `<[u8]>::AssocItem` + | ^^^^ + | +help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths + | +LL | <[u8]>::AssocItem => {} + | + + error: missing angle brackets in associated item path --> $DIR/bad-assoc-pat.rs:6:9 | LL | (u8, u8)::AssocItem => {} - | ^^^^^^^^^^^^^^^^^^^ help: try: `<(u8, u8)>::AssocItem` + | ^^^^^^^^ + | +help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths + | +LL | <(u8, u8)>::AssocItem => {} + | + + error: missing angle brackets in associated item path --> $DIR/bad-assoc-pat.rs:9:9 | LL | _::AssocItem => {} - | ^^^^^^^^^^^^ help: try: `<_>::AssocItem` + | ^ + | +help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths + | +LL | <_>::AssocItem => {} + | + + error: missing angle brackets in associated item path --> $DIR/bad-assoc-pat.rs:14:10 | LL | &(u8,)::AssocItem => {} - | ^^^^^^^^^^^^^^^^ help: try: `<(u8,)>::AssocItem` + | ^^^^^ + | +help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths + | +LL | &<(u8,)>::AssocItem => {} + | + + error: missing angle brackets in associated item path --> $DIR/bad-assoc-pat.rs:32:9 | LL | ty!()::AssocItem => {} - | ^^^^^^^^^^^^^^^^ help: try: `<ty!()>::AssocItem` + | ^^^^^ + | +help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths + | +LL | <ty!()>::AssocItem => {} + | + + error: missing angle brackets in associated item path --> $DIR/bad-assoc-pat.rs:21:19 | LL | ($ty: ty) => ($ty::AssocItem) - | ^^^^^^^^^^^^^^ help: try: `<$ty>::AssocItem` + | ^^^ ... LL | pat!(u8) => {} | -------- in this macro invocation | = note: this error originates in the macro `pat` (in Nightly builds, run with -Z macro-backtrace for more info) +help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths + | +LL | ($ty: ty) => (<$ty>::AssocItem) + | + + error[E0599]: no associated item named `AssocItem` found for slice `[u8]` in the current scope --> $DIR/bad-assoc-pat.rs:3:15 diff --git a/tests/ui/did_you_mean/bad-assoc-ty.stderr b/tests/ui/did_you_mean/bad-assoc-ty.stderr index 55096e95df7..efa6bb66824 100644 --- a/tests/ui/did_you_mean/bad-assoc-ty.stderr +++ b/tests/ui/did_you_mean/bad-assoc-ty.stderr @@ -2,60 +2,104 @@ error: missing angle brackets in associated item path --> $DIR/bad-assoc-ty.rs:1:10 | LL | type A = [u8; 4]::AssocTy; - | ^^^^^^^^^^^^^^^^ help: try: `<[u8; 4]>::AssocTy` + | ^^^^^^^ + | +help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths + | +LL | type A = <[u8; 4]>::AssocTy; + | + + error: missing angle brackets in associated item path --> $DIR/bad-assoc-ty.rs:5:10 | LL | type B = [u8]::AssocTy; - | ^^^^^^^^^^^^^ help: try: `<[u8]>::AssocTy` + | ^^^^ + | +help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths + | +LL | type B = <[u8]>::AssocTy; + | + + error: missing angle brackets in associated item path --> $DIR/bad-assoc-ty.rs:9:10 | LL | type C = (u8)::AssocTy; - | ^^^^^^^^^^^^^ help: try: `<(u8)>::AssocTy` + | ^^^^ + | +help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths + | +LL | type C = <(u8)>::AssocTy; + | + + error: missing angle brackets in associated item path --> $DIR/bad-assoc-ty.rs:13:10 | LL | type D = (u8, u8)::AssocTy; - | ^^^^^^^^^^^^^^^^^ help: try: `<(u8, u8)>::AssocTy` + | ^^^^^^^^ + | +help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths + | +LL | type D = <(u8, u8)>::AssocTy; + | + + error: missing angle brackets in associated item path --> $DIR/bad-assoc-ty.rs:17:10 | LL | type E = _::AssocTy; - | ^^^^^^^^^^ help: try: `<_>::AssocTy` + | ^ + | +help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths + | +LL | type E = <_>::AssocTy; + | + + error: missing angle brackets in associated item path --> $DIR/bad-assoc-ty.rs:21:19 | LL | type F = &'static (u8)::AssocTy; - | ^^^^^^^^^^^^^ help: try: `<(u8)>::AssocTy` + | ^^^^ + | +help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths + | +LL | type F = &'static <(u8)>::AssocTy; + | + + error: missing angle brackets in associated item path --> $DIR/bad-assoc-ty.rs:27:10 | LL | type G = dyn 'static + (Send)::AssocTy; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `<dyn 'static + (Send)>::AssocTy` + | ^^^^^^^^^^^^^^^^^^^^ + | +help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths + | +LL | type G = <dyn 'static + (Send)>::AssocTy; + | + + error: missing angle brackets in associated item path --> $DIR/bad-assoc-ty.rs:46:10 | LL | type I = ty!()::AssocTy; - | ^^^^^^^^^^^^^^ help: try: `<ty!()>::AssocTy` + | ^^^^^ + | +help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths + | +LL | type I = <ty!()>::AssocTy; + | + + error: missing angle brackets in associated item path --> $DIR/bad-assoc-ty.rs:39:19 | LL | ($ty: ty) => ($ty::AssocTy); - | ^^^^^^^^^^^^ help: try: `<$ty>::AssocTy` + | ^^^ ... LL | type J = ty!(u8); | ------- in this macro invocation | = note: this error originates in the macro `ty` (in Nightly builds, run with -Z macro-backtrace for more info) +help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths + | +LL | ($ty: ty) => (<$ty>::AssocTy); + | + + error[E0223]: ambiguous associated type --> $DIR/bad-assoc-ty.rs:1:10 diff --git a/tests/ui/error-codes/E0094.rs b/tests/ui/error-codes/E0094.rs index a2ec932c124..97ebcff99dc 100644 --- a/tests/ui/error-codes/E0094.rs +++ b/tests/ui/error-codes/E0094.rs @@ -1,4 +1,4 @@ -#![feature(intrinsics)] +#![feature(intrinsics, rustc_attrs)] extern "rust-intrinsic" { #[rustc_safe_intrinsic] diff --git a/tests/ui/error-codes/E0374.stderr b/tests/ui/error-codes/E0374.stderr index 68e15e6f8fe..a7792043067 100644 --- a/tests/ui/error-codes/E0374.stderr +++ b/tests/ui/error-codes/E0374.stderr @@ -1,8 +1,10 @@ -error[E0374]: the trait `CoerceUnsized` may only be implemented for a coercion between structures with one field being coerced, none found +error[E0374]: the trait `CoerceUnsized` may only be implemented for a coercion between structures --> $DIR/E0374.rs:8:1 | LL | impl<T, U> CoerceUnsized<Foo<U>> for Foo<T> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: expected a single field to be coerced, none found error: aborting due to previous error diff --git a/tests/ui/error-codes/E0377.stderr b/tests/ui/error-codes/E0377.stderr index bf7d8c8d39d..664e499ec23 100644 --- a/tests/ui/error-codes/E0377.stderr +++ b/tests/ui/error-codes/E0377.stderr @@ -1,8 +1,10 @@ -error[E0377]: the trait `CoerceUnsized` may only be implemented for a coercion between structures with the same definition; expected `Foo`, found `Bar` +error[E0377]: the trait `CoerceUnsized` may only be implemented for a coercion between structures --> $DIR/E0377.rs:12:1 | LL | impl<T, U> CoerceUnsized<Bar<U>> for Foo<T> where T: CoerceUnsized<U> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: expected coercion between the same definition; expected `Foo`, found `Bar` error: aborting due to previous error diff --git a/tests/ui/extern/extern-with-type-bounds.rs b/tests/ui/extern/extern-with-type-bounds.rs index a72aa4171a1..99e9801fd40 100644 --- a/tests/ui/extern/extern-with-type-bounds.rs +++ b/tests/ui/extern/extern-with-type-bounds.rs @@ -1,4 +1,4 @@ -#![feature(intrinsics)] +#![feature(intrinsics, rustc_attrs)] extern "rust-intrinsic" { // Real example from libcore diff --git a/tests/ui/feature-gates/feature-gate-adt_const_params.stderr b/tests/ui/feature-gates/feature-gate-adt_const_params.stderr index d8f089a28b7..13b9b84f0be 100644 --- a/tests/ui/feature-gates/feature-gate-adt_const_params.stderr +++ b/tests/ui/feature-gates/feature-gate-adt_const_params.stderr @@ -5,7 +5,7 @@ LL | struct Foo<const NAME: &'static str>; | ^^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: aborting due to previous error diff --git a/tests/ui/foreign/foreign-fn-linkname.rs b/tests/ui/foreign/foreign-fn-linkname.rs index f6d820594f9..d1d6e703e3d 100644 --- a/tests/ui/foreign/foreign-fn-linkname.rs +++ b/tests/ui/foreign/foreign-fn-linkname.rs @@ -2,6 +2,9 @@ // ignore-wasm32-bare no libc to test ffi with // ignore-sgx no libc +// Ensure no false positive on "unused extern crate" lint +#![deny(unused_extern_crates)] + #![feature(rustc_private)] extern crate libc; diff --git a/tests/ui/generic-const-items/elided-lifetimes.stderr b/tests/ui/generic-const-items/elided-lifetimes.stderr index 8cd3f9ee7a9..e7df8ca5cfd 100644 --- a/tests/ui/generic-const-items/elided-lifetimes.stderr +++ b/tests/ui/generic-const-items/elided-lifetimes.stderr @@ -28,7 +28,7 @@ LL | const I<const S: &str>: &str = ""; | ^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: aborting due to 4 previous errors diff --git a/tests/ui/impl-trait/bound-normalization-fail.rs b/tests/ui/impl-trait/bound-normalization-fail.rs index 3329592478d..566a4a7adcc 100644 --- a/tests/ui/impl-trait/bound-normalization-fail.rs +++ b/tests/ui/impl-trait/bound-normalization-fail.rs @@ -39,8 +39,7 @@ mod lifetimes { /// Missing bound constraining `Assoc`, `T::Assoc` can't be normalized further. fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike<Output = T::Assoc> { - //~^ ERROR `impl Trait` return type cannot contain a projection or `Self` that references lifetimes from a parent scope - //~| ERROR: type mismatch + //~^ ERROR: type mismatch Foo(()) } } diff --git a/tests/ui/impl-trait/bound-normalization-fail.stderr b/tests/ui/impl-trait/bound-normalization-fail.stderr index f04a753a0e8..fcac9ac34db 100644 --- a/tests/ui/impl-trait/bound-normalization-fail.stderr +++ b/tests/ui/impl-trait/bound-normalization-fail.stderr @@ -19,21 +19,12 @@ help: consider constraining the associated type `<T as impl_trait::Trait>::Assoc LL | fn foo_fail<T: Trait<Assoc = ()>>() -> impl FooLike<Output = T::Assoc> { | ++++++++++++ -error[E0658]: `impl Trait` return type cannot contain a projection or `Self` that references lifetimes from a parent scope - --> $DIR/bound-normalization-fail.rs:41:41 - | -LL | fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike<Output = T::Assoc> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #103532 <https://github.com/rust-lang/rust/issues/103532> for more information - = help: add `#![feature(impl_trait_projections)]` to the crate attributes to enable - error[E0271]: type mismatch resolving `<Foo<()> as FooLike>::Output == <T as Trait<'a>>::Assoc` --> $DIR/bound-normalization-fail.rs:41:41 | LL | fn foo2_fail<'a, T: Trait<'a>>() -> impl FooLike<Output = T::Assoc> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch resolving `<Foo<()> as FooLike>::Output == <T as Trait<'a>>::Assoc` -... +LL | LL | Foo(()) | ------- return type was inferred to be `Foo<()>` here | @@ -49,7 +40,6 @@ help: consider constraining the associated type `<T as lifetimes::Trait<'a>>::As LL | fn foo2_fail<'a, T: Trait<'a, Assoc = ()>>() -> impl FooLike<Output = T::Assoc> { | ++++++++++++ -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0271, E0658. -For more information about an error, try `rustc --explain E0271`. +For more information about this error, try `rustc --explain E0271`. diff --git a/tests/ui/impl-trait/capture-lifetime-not-in-hir.rs b/tests/ui/impl-trait/capture-lifetime-not-in-hir.rs new file mode 100644 index 00000000000..9c067cb6934 --- /dev/null +++ b/tests/ui/impl-trait/capture-lifetime-not-in-hir.rs @@ -0,0 +1,21 @@ +#![feature(rustc_attrs)] +#![rustc_variance_of_opaques] + +trait Bar<'a> { + type Assoc: From<()>; +} + +fn foo<'a, T: Bar<'a>>() -> impl Into<T::Assoc> { + //~^ ERROR [o, o] + // captures both T and 'a invariantly + () +} + +fn foo2<'a, T: Bar<'a>>() -> impl Into<T::Assoc> + 'a { + //~^ ERROR [o, o, o] + // captures both T and 'a invariantly, and also duplicates `'a` + // i.e. the opaque looks like `impl Into<<T as Bar<'a>>::Assoc> + 'a_duplicated` + () +} + +fn main() {} diff --git a/tests/ui/impl-trait/capture-lifetime-not-in-hir.stderr b/tests/ui/impl-trait/capture-lifetime-not-in-hir.stderr new file mode 100644 index 00000000000..9d52001b024 --- /dev/null +++ b/tests/ui/impl-trait/capture-lifetime-not-in-hir.stderr @@ -0,0 +1,14 @@ +error: [o, o] + --> $DIR/capture-lifetime-not-in-hir.rs:8:29 + | +LL | fn foo<'a, T: Bar<'a>>() -> impl Into<T::Assoc> { + | ^^^^^^^^^^^^^^^^^^^ + +error: [o, o, o] + --> $DIR/capture-lifetime-not-in-hir.rs:14:30 + | +LL | fn foo2<'a, T: Bar<'a>>() -> impl Into<T::Assoc> + 'a { + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/impl-trait/feature-self-return-type.rs b/tests/ui/impl-trait/feature-self-return-type.rs index 51877e9cc3c..7555df1b2c7 100644 --- a/tests/ui/impl-trait/feature-self-return-type.rs +++ b/tests/ui/impl-trait/feature-self-return-type.rs @@ -1,5 +1,4 @@ // edition:2018 -#![feature(impl_trait_projections)] // This test checks that we emit the correct borrowck error when `Self` or a projection is used as // a return type. See #61949 for context. diff --git a/tests/ui/impl-trait/feature-self-return-type.stderr b/tests/ui/impl-trait/feature-self-return-type.stderr index b9b8d00ce30..e7113a9dfb1 100644 --- a/tests/ui/impl-trait/feature-self-return-type.stderr +++ b/tests/ui/impl-trait/feature-self-return-type.stderr @@ -1,5 +1,5 @@ error[E0597]: `bar` does not live long enough - --> $DIR/feature-self-return-type.rs:23:22 + --> $DIR/feature-self-return-type.rs:22:22 | LL | let x = { | - borrow later stored here @@ -12,7 +12,7 @@ LL | }; | - `bar` dropped here while still borrowed error[E0597]: `y` does not live long enough - --> $DIR/feature-self-return-type.rs:63:17 + --> $DIR/feature-self-return-type.rs:62:17 | LL | let x = { | - borrow later stored here @@ -25,7 +25,7 @@ LL | }; | - `y` dropped here while still borrowed error[E0597]: `y` does not live long enough - --> $DIR/feature-self-return-type.rs:95:17 + --> $DIR/feature-self-return-type.rs:94:17 | LL | let x = { | - borrow later stored here diff --git a/tests/ui/impl-trait/in-trait/anonymize-binders-for-refine.rs b/tests/ui/impl-trait/in-trait/anonymize-binders-for-refine.rs new file mode 100644 index 00000000000..e62662f2f07 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/anonymize-binders-for-refine.rs @@ -0,0 +1,13 @@ +// compile-flags: --crate-type=lib +// check-pass + +#![feature(return_position_impl_trait_in_trait)] +#![deny(refining_impl_trait)] + +pub trait Tr<T> { + fn foo() -> impl for<'a> Tr<&'a Self>; +} + +impl<T> Tr<T> for () { + fn foo() -> impl for<'a> Tr<&'a Self> {} +} diff --git a/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf-via-param.rs b/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf-via-param.rs new file mode 100644 index 00000000000..5e14a7f8e72 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf-via-param.rs @@ -0,0 +1,26 @@ +#![feature(return_position_impl_trait_in_trait)] + +trait Extend { + fn extend<'a: 'a>(_: &'a str) -> (impl Sized + 'a, &'static str); +} + +impl Extend for () { + fn extend<'a: 'a>(s: &'a str) -> (Option<&'static &'a ()>, &'static str) + //~^ ERROR in type `&'static &'a ()`, reference has a longer lifetime than the data it references + where + 'a: 'static, + { + (None, s) + } +} + +// This indirection is not necessary for reproduction, +// but it makes this test future-proof against #114936. +fn extend<T: Extend>(s: &str) -> &'static str { + <T as Extend>::extend(s).1 +} + +fn main() { + let use_after_free = extend::<()>(&String::from("temporary")); + println!("{}", use_after_free); +} diff --git a/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf-via-param.stderr b/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf-via-param.stderr new file mode 100644 index 00000000000..1d947310e12 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf-via-param.stderr @@ -0,0 +1,16 @@ +error[E0491]: in type `&'static &'a ()`, reference has a longer lifetime than the data it references + --> $DIR/rpitit-hidden-types-self-implied-wf-via-param.rs:8:38 + | +LL | fn extend<'a: 'a>(s: &'a str) -> (Option<&'static &'a ()>, &'static str) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the pointer is valid for the static lifetime +note: but the referenced data is only valid for the lifetime `'a` as defined here + --> $DIR/rpitit-hidden-types-self-implied-wf-via-param.rs:8:15 + | +LL | fn extend<'a: 'a>(s: &'a str) -> (Option<&'static &'a ()>, &'static str) + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff --git a/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf.rs b/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf.rs new file mode 100644 index 00000000000..c1885af4e5e --- /dev/null +++ b/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf.rs @@ -0,0 +1,23 @@ +#![feature(return_position_impl_trait_in_trait)] + +trait Extend { + fn extend(_: &str) -> (impl Sized + '_, &'static str); +} + +impl Extend for () { + fn extend(s: &str) -> (Option<&'static &'_ ()>, &'static str) { + //~^ ERROR in type `&'static &()`, reference has a longer lifetime than the data it references + (None, s) + } +} + +// This indirection is not necessary for reproduction, +// but it makes this test future-proof against #114936. +fn extend<T: Extend>(s: &str) -> &'static str { + <T as Extend>::extend(s).1 +} + +fn main() { + let use_after_free = extend::<()>(&String::from("temporary")); + println!("{}", use_after_free); +} diff --git a/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf.stderr b/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf.stderr new file mode 100644 index 00000000000..7b63e72acbf --- /dev/null +++ b/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf.stderr @@ -0,0 +1,16 @@ +error[E0491]: in type `&'static &()`, reference has a longer lifetime than the data it references + --> $DIR/rpitit-hidden-types-self-implied-wf.rs:8:27 + | +LL | fn extend(s: &str) -> (Option<&'static &'_ ()>, &'static str) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the pointer is valid for the static lifetime +note: but the referenced data is only valid for the anonymous lifetime defined here + --> $DIR/rpitit-hidden-types-self-implied-wf.rs:8:18 + | +LL | fn extend(s: &str) -> (Option<&'static &'_ ()>, &'static str) { + | ^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff --git a/tests/ui/impl-trait/opaque-cast-field-access-in-future.rs b/tests/ui/impl-trait/opaque-cast-field-access-in-future.rs new file mode 100644 index 00000000000..3e3bc09a62a --- /dev/null +++ b/tests/ui/impl-trait/opaque-cast-field-access-in-future.rs @@ -0,0 +1,27 @@ +// edition: 2021 + +use std::future::Future; + +async fn bop() { + fold(run(), |mut foo| async move { + &mut foo.bar; + }) +} + +fn fold<Fut, F, U>(_: Foo<U>, f: F) +where + F: FnMut(Foo<U>) -> Fut, +{ + loop {} +} + +struct Foo<F> { + bar: Vec<F>, +} + +fn run() -> Foo<impl Future<Output = ()>> { + //~^ ERROR type annotations needed + loop {} +} + +fn main() {} diff --git a/tests/ui/impl-trait/opaque-cast-field-access-in-future.stderr b/tests/ui/impl-trait/opaque-cast-field-access-in-future.stderr new file mode 100644 index 00000000000..ee4343b110f --- /dev/null +++ b/tests/ui/impl-trait/opaque-cast-field-access-in-future.stderr @@ -0,0 +1,9 @@ +error[E0282]: type annotations needed + --> $DIR/opaque-cast-field-access-in-future.rs:22:17 + | +LL | fn run() -> Foo<impl Future<Output = ()>> { + | ^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/intrinsics/feature-gate-safe-intrinsic.rs b/tests/ui/intrinsics/feature-gate-safe-intrinsic.rs new file mode 100644 index 00000000000..ffaa4d771d9 --- /dev/null +++ b/tests/ui/intrinsics/feature-gate-safe-intrinsic.rs @@ -0,0 +1,6 @@ +#[rustc_safe_intrinsic] +//~^ ERROR the `#[rustc_safe_intrinsic]` attribute is used internally to mark intrinsics as safe +//~| ERROR attribute should be applied to intrinsic functions +fn safe() {} + +fn main() {} diff --git a/tests/ui/intrinsics/feature-gate-safe-intrinsic.stderr b/tests/ui/intrinsics/feature-gate-safe-intrinsic.stderr new file mode 100644 index 00000000000..8aeb56598ec --- /dev/null +++ b/tests/ui/intrinsics/feature-gate-safe-intrinsic.stderr @@ -0,0 +1,20 @@ +error[E0658]: the `#[rustc_safe_intrinsic]` attribute is used internally to mark intrinsics as safe + --> $DIR/feature-gate-safe-intrinsic.rs:1:1 + | +LL | #[rustc_safe_intrinsic] + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable + +error: attribute should be applied to intrinsic functions + --> $DIR/feature-gate-safe-intrinsic.rs:1:1 + | +LL | #[rustc_safe_intrinsic] + | ^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn safe() {} + | ------------ not an intrinsic function + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/intrinsics/intrinsic-alignment.rs b/tests/ui/intrinsics/intrinsic-alignment.rs index 30b8a21269a..6f9df64417e 100644 --- a/tests/ui/intrinsics/intrinsic-alignment.rs +++ b/tests/ui/intrinsics/intrinsic-alignment.rs @@ -1,7 +1,7 @@ // run-pass // ignore-wasm32-bare seems not important to test here -#![feature(intrinsics)] +#![feature(intrinsics, rustc_attrs)] mod rusti { extern "rust-intrinsic" { diff --git a/tests/ui/invalid_dispatch_from_dyn_impls.stderr b/tests/ui/invalid_dispatch_from_dyn_impls.stderr index b5b32d2f0bd..172ee7ade49 100644 --- a/tests/ui/invalid_dispatch_from_dyn_impls.stderr +++ b/tests/ui/invalid_dispatch_from_dyn_impls.stderr @@ -15,11 +15,13 @@ LL | impl<T: ?Sized, U: ?Sized> DispatchFromDyn<MultiplePointers<U>> for Multipl = note: the trait `DispatchFromDyn` may only be implemented for a coercion between structures with a single field being coerced = note: currently, 2 fields need coercions: `ptr1` (`*const T` to `*const U`), `ptr2` (`*const T` to `*const U`) -error[E0378]: the trait `DispatchFromDyn` may only be implemented for a coercion between structures with a single field being coerced, none found +error[E0378]: the trait `DispatchFromDyn` may only be implemented for a coercion between structures --> $DIR/invalid_dispatch_from_dyn_impls.rs:31:1 | LL | impl<T: ?Sized, U: ?Sized> DispatchFromDyn<NothingToCoerce<T>> for NothingToCoerce<U> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: expected a single field to be coerced, none found error[E0378]: structs implementing `DispatchFromDyn` may not have `#[repr(packed)]` or `#[repr(C)]` --> $DIR/invalid_dispatch_from_dyn_impls.rs:37:1 diff --git a/tests/ui/issues/issue-27042.stderr b/tests/ui/issues/issue-27042.stderr index 59ef28481d0..01532de999e 100644 --- a/tests/ui/issues/issue-27042.stderr +++ b/tests/ui/issues/issue-27042.stderr @@ -11,11 +11,18 @@ LL | | while true { break }; // but here we cite the whole loop error[E0308]: mismatched types --> $DIR/issue-27042.rs:6:16 | +LL | let _: i32 = + | - expected because of this assignment +LL | 'a: // in this case, the citation is just the `break`: LL | loop { break }; - | ^^^^^ - | | - | expected `i32`, found `()` - | help: give it a value of the expected type: `break 42` + | ---- ^^^^^ expected `i32`, found `()` + | | + | this loop is expected to be of type `i32` + | +help: give it a value of the expected type + | +LL | loop { break 42 }; + | ++ error[E0308]: mismatched types --> $DIR/issue-27042.rs:8:9 diff --git a/tests/ui/lifetimes/unusual-rib-combinations.stderr b/tests/ui/lifetimes/unusual-rib-combinations.stderr index 01ec69a6110..92a2ef2f432 100644 --- a/tests/ui/lifetimes/unusual-rib-combinations.stderr +++ b/tests/ui/lifetimes/unusual-rib-combinations.stderr @@ -56,7 +56,7 @@ LL | fn d<const C: S>() {} | ^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: `&dyn for<'a> Foo<'a>` is forbidden as the type of a const generic parameter --> $DIR/unusual-rib-combinations.rs:29:21 @@ -65,7 +65,7 @@ LL | struct Bar<const N: &'a (dyn for<'a> Foo<'a>)>; | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` - = help: more complex types are supported with `#![feature(adt_const_params)]` + = help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types error: aborting due to 9 previous errors diff --git a/tests/ui/lint/noop-method-call.fixed b/tests/ui/lint/noop-method-call.fixed index eeb80279fd8..4d9834f7df6 100644 --- a/tests/ui/lint/noop-method-call.fixed +++ b/tests/ui/lint/noop-method-call.fixed @@ -1,6 +1,7 @@ // check-pass // run-rustfix +#![feature(rustc_attrs)] #![allow(unused)] use std::borrow::Borrow; @@ -49,3 +50,15 @@ fn non_generic(non_clone_type: &PlainType<u32>) { non_clone_type; //~^ WARN call to `.clone()` on a reference in this situation does nothing } + +struct DiagnosticClone; +impl Clone for DiagnosticClone { + #[rustc_diagnostic_item = "other_clone"] + fn clone(&self) -> Self { + DiagnosticClone + } +} + +fn with_other_diagnostic_item(x: DiagnosticClone) { + x.clone(); +} diff --git a/tests/ui/lint/noop-method-call.rs b/tests/ui/lint/noop-method-call.rs index 9569a0dfc61..6242a00e033 100644 --- a/tests/ui/lint/noop-method-call.rs +++ b/tests/ui/lint/noop-method-call.rs @@ -1,6 +1,7 @@ // check-pass // run-rustfix +#![feature(rustc_attrs)] #![allow(unused)] use std::borrow::Borrow; @@ -49,3 +50,15 @@ fn non_generic(non_clone_type: &PlainType<u32>) { non_clone_type.clone(); //~^ WARN call to `.clone()` on a reference in this situation does nothing } + +struct DiagnosticClone; +impl Clone for DiagnosticClone { + #[rustc_diagnostic_item = "other_clone"] + fn clone(&self) -> Self { + DiagnosticClone + } +} + +fn with_other_diagnostic_item(x: DiagnosticClone) { + x.clone(); +} diff --git a/tests/ui/lint/noop-method-call.stderr b/tests/ui/lint/noop-method-call.stderr index aefc2706fd5..d04f44022ee 100644 --- a/tests/ui/lint/noop-method-call.stderr +++ b/tests/ui/lint/noop-method-call.stderr @@ -1,5 +1,5 @@ warning: call to `.clone()` on a reference in this situation does nothing - --> $DIR/noop-method-call.rs:15:25 + --> $DIR/noop-method-call.rs:16:25 | LL | let _ = &mut encoded.clone(); | ^^^^^^^^ help: remove this redundant call @@ -8,7 +8,7 @@ LL | let _ = &mut encoded.clone(); = note: `#[warn(noop_method_call)]` on by default warning: call to `.clone()` on a reference in this situation does nothing - --> $DIR/noop-method-call.rs:17:21 + --> $DIR/noop-method-call.rs:18:21 | LL | let _ = &encoded.clone(); | ^^^^^^^^ help: remove this redundant call @@ -16,7 +16,7 @@ LL | let _ = &encoded.clone(); = note: the type `[u8]` does not implement `Clone`, so calling `clone` on `&[u8]` copies the reference, which does not do anything and can be removed warning: call to `.clone()` on a reference in this situation does nothing - --> $DIR/noop-method-call.rs:23:71 + --> $DIR/noop-method-call.rs:24:71 | LL | let non_clone_type_ref_clone: &PlainType<u32> = non_clone_type_ref.clone(); | ^^^^^^^^ help: remove this redundant call @@ -24,7 +24,7 @@ LL | let non_clone_type_ref_clone: &PlainType<u32> = non_clone_type_ref.clon = note: the type `PlainType<u32>` does not implement `Clone`, so calling `clone` on `&PlainType<u32>` copies the reference, which does not do anything and can be removed warning: call to `.deref()` on a reference in this situation does nothing - --> $DIR/noop-method-call.rs:31:63 + --> $DIR/noop-method-call.rs:32:63 | LL | let non_deref_type_deref: &PlainType<u32> = non_deref_type.deref(); | ^^^^^^^^ help: remove this redundant call @@ -32,7 +32,7 @@ LL | let non_deref_type_deref: &PlainType<u32> = non_deref_type.deref(); = note: the type `PlainType<u32>` does not implement `Deref`, so calling `deref` on `&PlainType<u32>` copies the reference, which does not do anything and can be removed warning: call to `.borrow()` on a reference in this situation does nothing - --> $DIR/noop-method-call.rs:35:66 + --> $DIR/noop-method-call.rs:36:66 | LL | let non_borrow_type_borrow: &PlainType<u32> = non_borrow_type.borrow(); | ^^^^^^^^^ help: remove this redundant call @@ -40,7 +40,7 @@ LL | let non_borrow_type_borrow: &PlainType<u32> = non_borrow_type.borrow(); = note: the type `PlainType<u32>` does not implement `Borrow`, so calling `borrow` on `&PlainType<u32>` copies the reference, which does not do anything and can be removed warning: call to `.clone()` on a reference in this situation does nothing - --> $DIR/noop-method-call.rs:44:19 + --> $DIR/noop-method-call.rs:45:19 | LL | non_clone_type.clone(); | ^^^^^^^^ help: remove this redundant call @@ -48,7 +48,7 @@ LL | non_clone_type.clone(); = note: the type `PlainType<T>` does not implement `Clone`, so calling `clone` on `&PlainType<T>` copies the reference, which does not do anything and can be removed warning: call to `.clone()` on a reference in this situation does nothing - --> $DIR/noop-method-call.rs:49:19 + --> $DIR/noop-method-call.rs:50:19 | LL | non_clone_type.clone(); | ^^^^^^^^ help: remove this redundant call diff --git a/tests/ui/lint/reference_casting.rs b/tests/ui/lint/reference_casting.rs index 7745d4ef4c3..fba8789e999 100644 --- a/tests/ui/lint/reference_casting.rs +++ b/tests/ui/lint/reference_casting.rs @@ -36,6 +36,8 @@ unsafe fn ref_to_mut() { //~^ ERROR casting `&T` to `&mut T` is undefined behavior let _num = &mut *std::mem::transmute::<_, *mut i32>(num); //~^ ERROR casting `&T` to `&mut T` is undefined behavior + let _num = &mut *(std::mem::transmute::<_, *mut i32>(num) as *mut i32); + //~^ ERROR casting `&T` to `&mut T` is undefined behavior let _num = &mut *std::cell::UnsafeCell::raw_get( //~^ ERROR casting `&T` to `&mut T` is undefined behavior num as *const i32 as *const std::cell::UnsafeCell<i32> @@ -47,8 +49,20 @@ unsafe fn ref_to_mut() { let deferred = (std::ptr::from_ref(num) as *const i32 as *const i32).cast_mut() as *mut i32; let _num = &mut *deferred; //~^ ERROR casting `&T` to `&mut T` is undefined behavior + let deferred_rebind = deferred; + let _num = &mut *deferred_rebind; + //~^ ERROR casting `&T` to `&mut T` is undefined behavior let _num = &mut *(num as *const _ as usize as *mut i32); //~^ ERROR casting `&T` to `&mut T` is undefined behavior + let _num = &mut *(std::mem::transmute::<_, *mut _>(num as *const i32) as *mut i32); + //~^ ERROR casting `&T` to `&mut T` is undefined behavior + + static NUM: &'static i32 = &2; + let num = NUM as *const i32 as *mut i32; + let num = num; + let num = num; + let _num = &mut *num; + //~^ ERROR casting `&T` to `&mut T` is undefined behavior unsafe fn generic_ref_cast_mut<T>(this: &T) -> &mut T { &mut *((this as *const _) as *mut _) @@ -85,6 +99,8 @@ unsafe fn assign_to_ref() { //~^ ERROR assigning to `&T` is undefined behavior *std::mem::transmute::<_, *mut i32>(num) += 1; //~^ ERROR assigning to `&T` is undefined behavior + *(std::mem::transmute::<_, *mut i32>(num) as *mut i32) += 1; + //~^ ERROR assigning to `&T` is undefined behavior std::ptr::write( //~^ ERROR assigning to `&T` is undefined behavior std::mem::transmute::<*const i32, *mut i32>(num), @@ -94,6 +110,9 @@ unsafe fn assign_to_ref() { let value = num as *const i32 as *mut i32; *value = 1; //~^ ERROR assigning to `&T` is undefined behavior + let value_rebind = value; + *value_rebind = 1; + //~^ ERROR assigning to `&T` is undefined behavior *(num as *const i32).cast::<i32>().cast_mut() = 2; //~^ ERROR assigning to `&T` is undefined behavior *(num as *const _ as usize as *mut i32) = 2; @@ -111,6 +130,7 @@ unsafe fn assign_to_ref() { } } +const RAW_PTR: *mut u8 = 1 as *mut u8; unsafe fn no_warn() { let num = &3i32; let mut_num = &mut 3i32; @@ -125,6 +145,9 @@ unsafe fn no_warn() { let mut value = 3; let value: *const i32 = &mut value; *(value as *const i16 as *mut i16) = 42; + *RAW_PTR = 42; // RAW_PTR is defined outside the function body, + // make sure we don't ICE on it when trying to + // determine if we should lint on it or not. fn safe_as_mut<T>(x: &std::cell::UnsafeCell<T>) -> &mut T { unsafe { &mut *std::cell::UnsafeCell::raw_get(x as *const _ as *const _) } diff --git a/tests/ui/lint/reference_casting.stderr b/tests/ui/lint/reference_casting.stderr index 1189942c809..8f89cf9805b 100644 --- a/tests/ui/lint/reference_casting.stderr +++ b/tests/ui/lint/reference_casting.stderr @@ -82,6 +82,14 @@ LL | let _num = &mut *std::mem::transmute::<_, *mut i32>(num); error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` --> $DIR/reference_casting.rs:39:16 | +LL | let _num = &mut *(std::mem::transmute::<_, *mut i32>(num) as *mut i32); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> + +error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` + --> $DIR/reference_casting.rs:41:16 + | LL | let _num = &mut *std::cell::UnsafeCell::raw_get( | ________________^ LL | | @@ -92,7 +100,7 @@ LL | | ); = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:45:16 + --> $DIR/reference_casting.rs:47:16 | LL | let deferred = num as *const i32 as *mut i32; | ----------------------------- casting happend here @@ -102,7 +110,7 @@ LL | let _num = &mut *deferred; = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:48:16 + --> $DIR/reference_casting.rs:50:16 | LL | let deferred = (std::ptr::from_ref(num) as *const i32 as *const i32).cast_mut() as *mut i32; | ---------------------------------------------------------------------------- casting happend here @@ -112,7 +120,18 @@ LL | let _num = &mut *deferred; = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:50:16 + --> $DIR/reference_casting.rs:53:16 + | +LL | let deferred = (std::ptr::from_ref(num) as *const i32 as *const i32).cast_mut() as *mut i32; + | ---------------------------------------------------------------------------- casting happend here +... +LL | let _num = &mut *deferred_rebind; + | ^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> + +error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` + --> $DIR/reference_casting.rs:55:16 | LL | let _num = &mut *(num as *const _ as usize as *mut i32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -120,7 +139,26 @@ LL | let _num = &mut *(num as *const _ as usize as *mut i32); = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:54:9 + --> $DIR/reference_casting.rs:57:16 + | +LL | let _num = &mut *(std::mem::transmute::<_, *mut _>(num as *const i32) as *mut i32); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> + +error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` + --> $DIR/reference_casting.rs:64:16 + | +LL | let num = NUM as *const i32 as *mut i32; + | ----------------------------- casting happend here +... +LL | let _num = &mut *num; + | ^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> + +error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` + --> $DIR/reference_casting.rs:68:9 | LL | &mut *((this as *const _) as *mut _) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -128,7 +166,7 @@ LL | &mut *((this as *const _) as *mut _) = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:59:18 + --> $DIR/reference_casting.rs:73:18 | LL | unsafe { &mut *std::cell::UnsafeCell::raw_get(x as *const _ as *const _) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -136,7 +174,7 @@ LL | unsafe { &mut *std::cell::UnsafeCell::raw_get(x as *const _ as *con = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` - --> $DIR/reference_casting.rs:64:18 + --> $DIR/reference_casting.rs:78:18 | LL | unsafe { &mut *std::cell::UnsafeCell::raw_get(x as *const _ as *const _) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -144,7 +182,7 @@ LL | unsafe { &mut *std::cell::UnsafeCell::raw_get(x as *const _ as *con = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:74:5 + --> $DIR/reference_casting.rs:88:5 | LL | *(a as *const _ as *mut _) = String::from("Replaced"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -152,7 +190,7 @@ LL | *(a as *const _ as *mut _) = String::from("Replaced"); = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:76:5 + --> $DIR/reference_casting.rs:90:5 | LL | *(a as *const _ as *mut String) += " world"; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -160,7 +198,7 @@ LL | *(a as *const _ as *mut String) += " world"; = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:78:5 + --> $DIR/reference_casting.rs:92:5 | LL | *std::ptr::from_ref(num).cast_mut() += 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -168,7 +206,7 @@ LL | *std::ptr::from_ref(num).cast_mut() += 1; = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:80:5 + --> $DIR/reference_casting.rs:94:5 | LL | *std::ptr::from_ref({ num }).cast_mut() += 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -176,7 +214,7 @@ LL | *std::ptr::from_ref({ num }).cast_mut() += 1; = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:82:5 + --> $DIR/reference_casting.rs:96:5 | LL | *{ std::ptr::from_ref(num) }.cast_mut() += 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -184,7 +222,7 @@ LL | *{ std::ptr::from_ref(num) }.cast_mut() += 1; = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:84:5 + --> $DIR/reference_casting.rs:98:5 | LL | *(std::ptr::from_ref({ num }) as *mut i32) += 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -192,7 +230,7 @@ LL | *(std::ptr::from_ref({ num }) as *mut i32) += 1; = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:86:5 + --> $DIR/reference_casting.rs:100:5 | LL | *std::mem::transmute::<_, *mut i32>(num) += 1; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -200,7 +238,15 @@ LL | *std::mem::transmute::<_, *mut i32>(num) += 1; = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:88:5 + --> $DIR/reference_casting.rs:102:5 + | +LL | *(std::mem::transmute::<_, *mut i32>(num) as *mut i32) += 1; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> + +error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` + --> $DIR/reference_casting.rs:104:5 | LL | / std::ptr::write( LL | | @@ -212,7 +258,7 @@ LL | | ); = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:95:5 + --> $DIR/reference_casting.rs:111:5 | LL | let value = num as *const i32 as *mut i32; | ----------------------------- casting happend here @@ -222,7 +268,18 @@ LL | *value = 1; = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:97:5 + --> $DIR/reference_casting.rs:114:5 + | +LL | let value = num as *const i32 as *mut i32; + | ----------------------------- casting happend here +... +LL | *value_rebind = 1; + | ^^^^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> + +error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` + --> $DIR/reference_casting.rs:116:5 | LL | *(num as *const i32).cast::<i32>().cast_mut() = 2; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -230,7 +287,7 @@ LL | *(num as *const i32).cast::<i32>().cast_mut() = 2; = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:99:5 + --> $DIR/reference_casting.rs:118:5 | LL | *(num as *const _ as usize as *mut i32) = 2; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -238,7 +295,7 @@ LL | *(num as *const _ as usize as *mut i32) = 2; = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:101:5 + --> $DIR/reference_casting.rs:120:5 | LL | let value = num as *const i32 as *mut i32; | ----------------------------- casting happend here @@ -249,7 +306,7 @@ LL | std::ptr::write(value, 2); = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:103:5 + --> $DIR/reference_casting.rs:122:5 | LL | let value = num as *const i32 as *mut i32; | ----------------------------- casting happend here @@ -260,7 +317,7 @@ LL | std::ptr::write_unaligned(value, 2); = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:105:5 + --> $DIR/reference_casting.rs:124:5 | LL | let value = num as *const i32 as *mut i32; | ----------------------------- casting happend here @@ -271,12 +328,12 @@ LL | std::ptr::write_volatile(value, 2); = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> error: assigning to `&T` is undefined behavior, consider using an `UnsafeCell` - --> $DIR/reference_casting.rs:109:9 + --> $DIR/reference_casting.rs:128:9 | LL | *(this as *const _ as *mut _) = a; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> -error: aborting due to 32 previous errors +error: aborting due to 38 previous errors diff --git a/tests/ui/loops/loop-break-value.rs b/tests/ui/loops/loop-break-value.rs index f334f9d464a..c35200520cb 100644 --- a/tests/ui/loops/loop-break-value.rs +++ b/tests/ui/loops/loop-break-value.rs @@ -95,6 +95,66 @@ fn main() { break LOOP; //~^ ERROR cannot find value `LOOP` in this scope } + + let _ = 'a: loop { + loop { + break; // This doesn't affect the expected break type of the 'a loop + loop { + loop { + break 'a 1; + } + } + } + break; //~ ERROR mismatched types + }; + + let _ = 'a: loop { + loop { + break; // This doesn't affect the expected break type of the 'a loop + loop { + loop { + break 'a 1; + } + } + } + break 'a; //~ ERROR mismatched types + }; + + loop { + break; + let _ = loop { + break 2; + loop { + break; + } + }; + break 2; //~ ERROR mismatched types + } + + 'a: loop { + break; + let _ = 'a: loop { + //~^ WARNING label name `'a` shadows a label name that is already in scope + break 2; + loop { + break 'a; //~ ERROR mismatched types + } + }; + break 2; //~ ERROR mismatched types + } + + 'a: loop { + break; + let _ = 'a: loop { + //~^ WARNING label name `'a` shadows a label name that is already in scope + break 'a 2; + loop { + break 'a; //~ ERROR mismatched types + } + }; + break 2; //~ ERROR mismatched types + }; + loop { // point at the return type break 2; //~ ERROR mismatched types } diff --git a/tests/ui/loops/loop-break-value.stderr b/tests/ui/loops/loop-break-value.stderr index 76d12b7c1b3..6c83bc7575c 100644 --- a/tests/ui/loops/loop-break-value.stderr +++ b/tests/ui/loops/loop-break-value.stderr @@ -1,3 +1,21 @@ +warning: label name `'a` shadows a label name that is already in scope + --> $DIR/loop-break-value.rs:136:17 + | +LL | 'a: loop { + | -- first declared here +LL | break; +LL | let _ = 'a: loop { + | ^^ label `'a` already in scope + +warning: label name `'a` shadows a label name that is already in scope + --> $DIR/loop-break-value.rs:148:17 + | +LL | 'a: loop { + | -- first declared here +LL | break; +LL | let _ = 'a: loop { + | ^^ label `'a` already in scope + error[E0425]: cannot find value `LOOP` in this scope --> $DIR/loop-break-value.rs:95:15 | @@ -134,7 +152,10 @@ error[E0308]: mismatched types --> $DIR/loop-break-value.rs:4:31 | LL | let val: ! = loop { break break; }; - | ^^^^^ expected `!`, found `()` + | --- ---- ^^^^^ expected `!`, found `()` + | | | + | | this loop is expected to be of type `!` + | expected because of this assignment | = note: expected type `!` found unit type `()` @@ -142,6 +163,9 @@ LL | let val: ! = loop { break break; }; error[E0308]: mismatched types --> $DIR/loop-break-value.rs:11:19 | +LL | break "asdf"; + | ------------ expected because of this `break` +LL | } else { LL | break 123; | ^^^ expected `&str`, found integer @@ -169,6 +193,8 @@ LL | break 'outer_loop "nope"; error[E0308]: mismatched types --> $DIR/loop-break-value.rs:73:26 | +LL | break; + | ----- expected because of this `break` LL | break 'c 123; | ^^^ expected `()`, found integer @@ -176,7 +202,11 @@ error[E0308]: mismatched types --> $DIR/loop-break-value.rs:80:15 | LL | break (break, break); - | ^^^^^^^^^^^^^^ expected `()`, found `(!, !)` + | ^-----^^-----^ + | || | + | || expected because of this `break` + | |expected because of this `break` + | expected `()`, found `(!, !)` | = note: expected unit type `()` found tuple `(!, !)` @@ -184,20 +214,109 @@ LL | break (break, break); error[E0308]: mismatched types --> $DIR/loop-break-value.rs:85:15 | +LL | break; + | ----- expected because of this `break` LL | break 2; | ^ expected `()`, found integer error[E0308]: mismatched types --> $DIR/loop-break-value.rs:90:9 | +LL | break 2; + | ------- expected because of this `break` LL | break; - | ^^^^^ - | | - | expected integer, found `()` - | help: give it a value of the expected type: `break value` + | ^^^^^ expected integer, found `()` + | +help: give it a value of the expected type + | +LL | break value; + | +++++ + +error[E0308]: mismatched types + --> $DIR/loop-break-value.rs:108:9 + | +LL | break 'a 1; + | ---------- expected because of this `break` +... +LL | break; + | ^^^^^ expected integer, found `()` + | +help: give it a value of the expected type + | +LL | break value; + | +++++ + +error[E0308]: mismatched types + --> $DIR/loop-break-value.rs:120:9 + | +LL | break 'a 1; + | ---------- expected because of this `break` +... +LL | break 'a; + | ^^^^^^^^ expected integer, found `()` + | +help: give it a value of the expected type + | +LL | break 'a value; + | +++++ + +error[E0308]: mismatched types + --> $DIR/loop-break-value.rs:131:15 + | +LL | break; + | ----- expected because of this `break` +... +LL | break 2; + | ^ expected `()`, found integer + +error[E0308]: mismatched types + --> $DIR/loop-break-value.rs:140:17 + | +LL | break 2; + | ------- expected because of this `break` +LL | loop { +LL | break 'a; + | ^^^^^^^^ expected integer, found `()` + | +help: give it a value of the expected type + | +LL | break 'a value; + | +++++ + +error[E0308]: mismatched types + --> $DIR/loop-break-value.rs:143:15 + | +LL | break; + | ----- expected because of this `break` +... +LL | break 2; + | ^ expected `()`, found integer + +error[E0308]: mismatched types + --> $DIR/loop-break-value.rs:152:17 + | +LL | break 'a 2; + | ---------- expected because of this `break` +LL | loop { +LL | break 'a; + | ^^^^^^^^ expected integer, found `()` + | +help: give it a value of the expected type + | +LL | break 'a value; + | +++++ + +error[E0308]: mismatched types + --> $DIR/loop-break-value.rs:155:15 + | +LL | break; + | ----- expected because of this `break` +... +LL | break 2; + | ^ expected `()`, found integer error[E0308]: mismatched types - --> $DIR/loop-break-value.rs:99:15 + --> $DIR/loop-break-value.rs:159:15 | LL | fn main() { | - expected `()` because of this return type @@ -207,7 +326,7 @@ LL | loop { // point at the return type LL | break 2; | ^ expected `()`, found integer -error: aborting due to 18 previous errors; 1 warning emitted +error: aborting due to 25 previous errors; 3 warnings emitted Some errors have detailed explanations: E0308, E0425, E0571. For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/loops/loop-labeled-break-value.stderr b/tests/ui/loops/loop-labeled-break-value.stderr index aa04d330f25..694d6c306f6 100644 --- a/tests/ui/loops/loop-labeled-break-value.stderr +++ b/tests/ui/loops/loop-labeled-break-value.stderr @@ -2,28 +2,43 @@ error[E0308]: mismatched types --> $DIR/loop-labeled-break-value.rs:3:29 | LL | let _: i32 = loop { break }; - | ^^^^^ - | | - | expected `i32`, found `()` - | help: give it a value of the expected type: `break 42` + | - ---- ^^^^^ expected `i32`, found `()` + | | | + | | this loop is expected to be of type `i32` + | expected because of this assignment + | +help: give it a value of the expected type + | +LL | let _: i32 = loop { break 42 }; + | ++ error[E0308]: mismatched types --> $DIR/loop-labeled-break-value.rs:6:37 | LL | let _: i32 = 'inner: loop { break 'inner }; - | ^^^^^^^^^^^^ - | | - | expected `i32`, found `()` - | help: give it a value of the expected type: `break 'inner 42` + | - ---- ^^^^^^^^^^^^ expected `i32`, found `()` + | | | + | | this loop is expected to be of type `i32` + | expected because of this assignment + | +help: give it a value of the expected type + | +LL | let _: i32 = 'inner: loop { break 'inner 42 }; + | ++ error[E0308]: mismatched types --> $DIR/loop-labeled-break-value.rs:9:45 | LL | let _: i32 = 'inner2: loop { loop { break 'inner2 } }; - | ^^^^^^^^^^^^^ - | | - | expected `i32`, found `()` - | help: give it a value of the expected type: `break 'inner2 42` + | - ---- ^^^^^^^^^^^^^ expected `i32`, found `()` + | | | + | | this loop is expected to be of type `i32` + | expected because of this assignment + | +help: give it a value of the expected type + | +LL | let _: i32 = 'inner2: loop { loop { break 'inner2 42 } }; + | ++ error: aborting due to 3 previous errors diff --git a/tests/ui/loops/loop-properly-diverging-2.stderr b/tests/ui/loops/loop-properly-diverging-2.stderr index 5030a2935b9..1d1ae60cda1 100644 --- a/tests/ui/loops/loop-properly-diverging-2.stderr +++ b/tests/ui/loops/loop-properly-diverging-2.stderr @@ -2,10 +2,15 @@ error[E0308]: mismatched types --> $DIR/loop-properly-diverging-2.rs:2:23 | LL | let x: i32 = loop { break }; - | ^^^^^ - | | - | expected `i32`, found `()` - | help: give it a value of the expected type: `break 42` + | - ---- ^^^^^ expected `i32`, found `()` + | | | + | | this loop is expected to be of type `i32` + | expected because of this assignment + | +help: give it a value of the expected type + | +LL | let x: i32 = loop { break 42 }; + | ++ error: aborting due to previous error diff --git a/tests/ui/match/issue-72896.rs b/tests/ui/match/issue-72896-non-partial-eq-const.rs index 3a8b8203731..a3095f0be83 100644 --- a/tests/ui/match/issue-72896.rs +++ b/tests/ui/match/issue-72896-non-partial-eq-const.rs @@ -17,7 +17,8 @@ const CONST_SET: EnumSet<Enum8> = EnumSet { __enumset_underlying: 3 }; fn main() { match CONST_SET { - CONST_SET => { /* ok */ } + CONST_SET => { /* ok */ } //~WARN: must implement `PartialEq` + //~| previously accepted _ => panic!("match fell through?"), } } diff --git a/tests/ui/match/issue-72896-non-partial-eq-const.stderr b/tests/ui/match/issue-72896-non-partial-eq-const.stderr new file mode 100644 index 00000000000..a7fc0cfc054 --- /dev/null +++ b/tests/ui/match/issue-72896-non-partial-eq-const.stderr @@ -0,0 +1,23 @@ +warning: to use a constant of type `EnumSet<Enum8>` in a pattern, the type must implement `PartialEq` + --> $DIR/issue-72896-non-partial-eq-const.rs:20:9 + | +LL | CONST_SET => { /* ok */ } + | ^^^^^^^^^ + | + = 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 #116122 <https://github.com/rust-lang/rust/issues/116122> + = note: `#[warn(const_patterns_without_partial_eq)]` on by default + +warning: 1 warning emitted + +Future incompatibility report: Future breakage diagnostic: +warning: to use a constant of type `EnumSet<Enum8>` in a pattern, the type must implement `PartialEq` + --> $DIR/issue-72896-non-partial-eq-const.rs:20:9 + | +LL | CONST_SET => { /* ok */ } + | ^^^^^^^^^ + | + = 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 #116122 <https://github.com/rust-lang/rust/issues/116122> + = note: `#[warn(const_patterns_without_partial_eq)]` on by default + diff --git a/tests/ui/native-library-link-flags/mix-bundle-and-whole-archive-link-attr.rs b/tests/ui/native-library-link-flags/mix-bundle-and-whole-archive-link-attr.rs deleted file mode 100644 index 0ccd441cc64..00000000000 --- a/tests/ui/native-library-link-flags/mix-bundle-and-whole-archive-link-attr.rs +++ /dev/null @@ -1,11 +0,0 @@ -// gate-test-packed_bundled_libs - -// ignore-wasm32-bare -// compile-flags: --crate-type rlib -// error-pattern: link modifiers combination `+bundle,+whole-archive` is unstable when generating rlibs -// build-fail - -#[link(name = "rust_test_helpers", kind = "static", modifiers = "+bundle,+whole-archive")] -extern "C" {} - -fn main() {} diff --git a/tests/ui/native-library-link-flags/mix-bundle-and-whole-archive-link-attr.stderr b/tests/ui/native-library-link-flags/mix-bundle-and-whole-archive-link-attr.stderr deleted file mode 100644 index 8a9fed740b0..00000000000 --- a/tests/ui/native-library-link-flags/mix-bundle-and-whole-archive-link-attr.stderr +++ /dev/null @@ -1,4 +0,0 @@ -error: link modifiers combination `+bundle,+whole-archive` is unstable when generating rlibs - -error: aborting due to previous error - diff --git a/tests/ui/native-library-link-flags/mix-bundle-and-whole-archive.rs b/tests/ui/native-library-link-flags/mix-bundle-and-whole-archive.rs deleted file mode 100644 index 18d4b52a34c..00000000000 --- a/tests/ui/native-library-link-flags/mix-bundle-and-whole-archive.rs +++ /dev/null @@ -1,8 +0,0 @@ -// gate-test-packed_bundled_libs - -// ignore-wasm32-bare -// compile-flags: -l static:+bundle,+whole-archive=rust_test_helpers --crate-type rlib -// error-pattern: link modifiers combination `+bundle,+whole-archive` is unstable when generating rlibs -// build-fail - -fn main() {} diff --git a/tests/ui/native-library-link-flags/mix-bundle-and-whole-archive.stderr b/tests/ui/native-library-link-flags/mix-bundle-and-whole-archive.stderr deleted file mode 100644 index 8a9fed740b0..00000000000 --- a/tests/ui/native-library-link-flags/mix-bundle-and-whole-archive.stderr +++ /dev/null @@ -1,4 +0,0 @@ -error: link modifiers combination `+bundle,+whole-archive` is unstable when generating rlibs - -error: aborting due to previous error - diff --git a/tests/ui/never_type/issue-52443.stderr b/tests/ui/never_type/issue-52443.stderr index 99dfce86903..59292ed68a3 100644 --- a/tests/ui/never_type/issue-52443.stderr +++ b/tests/ui/never_type/issue-52443.stderr @@ -33,10 +33,12 @@ error[E0308]: mismatched types --> $DIR/issue-52443.rs:4:17 | LL | [(); loop { break }]; - | ^^^^^ - | | - | expected `usize`, found `()` - | help: give it a value of the expected type: `break 42` + | ^^^^^ expected `usize`, found `()` + | +help: give it a value of the expected type + | +LL | [(); loop { break 42 }]; + | ++ error[E0015]: cannot convert `RangeFrom<usize>` into an iterator in constants --> $DIR/issue-52443.rs:9:21 diff --git a/tests/ui/nll/closure-requirements/escape-argument-callee.stderr b/tests/ui/nll/closure-requirements/escape-argument-callee.stderr index 1e3a5328d3d..b3cb7813e19 100644 --- a/tests/ui/nll/closure-requirements/escape-argument-callee.stderr +++ b/tests/ui/nll/closure-requirements/escape-argument-callee.stderr @@ -6,7 +6,7 @@ LL | let mut closure = expect_sig(|p, y| *p = y); | = note: defining type: test::{closure#0} with closure args [ i16, - for<Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) mut &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) i32, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(None) }) i32)), + for<Region(BrAnon), Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) mut &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) i32, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon }) i32)), (), ] diff --git a/tests/ui/nll/closure-requirements/escape-argument.stderr b/tests/ui/nll/closure-requirements/escape-argument.stderr index bc4ba93f884..4f0156728ac 100644 --- a/tests/ui/nll/closure-requirements/escape-argument.stderr +++ b/tests/ui/nll/closure-requirements/escape-argument.stderr @@ -6,7 +6,7 @@ LL | let mut closure = expect_sig(|p, y| *p = y); | = note: defining type: test::{closure#0} with closure args [ i16, - for<Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) mut &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) i32, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) i32)), + for<Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) mut &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) i32, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) i32)), (), ] diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr index f8383cc42a2..ccf56bf6f37 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr @@ -6,7 +6,7 @@ LL | |_outlives1, _outlives2, _outlives3, x, y| { | = note: defining type: supply::{closure#0} with closure args [ i16, - for<Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>, std::cell::Cell<&'?2 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) &'?3 u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>)), + for<Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) u32>, std::cell::Cell<&'?2 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) &'?3 u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) u32>)), (), ] = note: late-bound region is '?4 diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-ref.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-ref.stderr index 113173d8f76..a16433c9d37 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-ref.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-ref.stderr @@ -6,7 +6,7 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y | = note: defining type: supply::{closure#0} with closure args [ i16, - for<Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) &'?2 u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) u32>)), + for<Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon }) &'?2 u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrAnon }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon }) u32>)), (), ] = note: late-bound region is '?3 diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr index ba15199ab5a..9e0f16c0fc7 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr @@ -6,7 +6,7 @@ LL | foo(cell, |cell_a, cell_x| { | = note: defining type: case1::{closure#0} with closure args [ i32, - for<Region(BrAnon(None))> extern "rust-call" fn((std::cell::Cell<&'?1 u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>)), + for<Region(BrAnon)> extern "rust-call" fn((std::cell::Cell<&'?1 u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) u32>)), (), ] @@ -36,7 +36,7 @@ LL | foo(cell, |cell_a, cell_x| { | = note: defining type: case2::{closure#0} with closure args [ i32, - for<Region(BrAnon(None))> extern "rust-call" fn((std::cell::Cell<&'?1 u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>)), + for<Region(BrAnon)> extern "rust-call" fn((std::cell::Cell<&'?1 u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) u32>)), (), ] = note: number of external vids: 2 diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr index f2bf83c6c59..e4989e32155 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr @@ -6,7 +6,7 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { | = note: defining type: supply::{closure#0} with closure args [ i16, - for<Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon(None) }) u32>)), + for<Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon }) u32>)), (), ] = note: late-bound region is '?2 diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr index 2734326ed64..be35e62d070 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr @@ -6,7 +6,7 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y | = note: defining type: supply::{closure#0} with closure args [ i16, - for<Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(None) }) std::cell::Cell<&'?2 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) u32>)), + for<Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon }) std::cell::Cell<&'?2 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrAnon }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon }) u32>)), (), ] = note: late-bound region is '?3 diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-val.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-val.stderr index 5ab321eb666..8880dd816a1 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-val.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-val.stderr @@ -6,7 +6,7 @@ LL | establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| { | = note: defining type: test::{closure#0} with closure args [ i16, - for<Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) &'?2 u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>)), + for<Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) &'?2 u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) u32>)), (), ] = note: late-bound region is '?3 diff --git a/tests/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr b/tests/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr index 595fd5ff565..47774b63f81 100644 --- a/tests/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr +++ b/tests/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr @@ -6,7 +6,7 @@ LL | |_outlives1, _outlives2, x, y| { | = note: defining type: supply::{closure#0} with closure args [ i16, - for<Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) &'?2 u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>)), + for<Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) &'?2 u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) u32>)), (), ] = note: late-bound region is '?3 diff --git a/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr b/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr index 62b0e3eed85..3404bb12827 100644 --- a/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr +++ b/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr @@ -6,7 +6,7 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { | = note: defining type: supply::{closure#0} with closure args [ i16, - for<Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) &'?1 u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>)), + for<Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) &'?1 u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) u32>)), (), ] = note: late-bound region is '?2 diff --git a/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr b/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr index 6f2044d621e..e40648912e3 100644 --- a/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr +++ b/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr @@ -6,7 +6,7 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y | = note: defining type: supply::{closure#0} with closure args [ i16, - for<Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) &'?1 u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) &'?2 u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) u32>)), + for<Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) &'?1 u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon }) &'?2 u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrAnon }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon }) u32>)), (), ] = note: late-bound region is '?3 diff --git a/tests/ui/nll/closure-requirements/return-wrong-bound-region.stderr b/tests/ui/nll/closure-requirements/return-wrong-bound-region.stderr index 7635f2ede0a..18fb7195d02 100644 --- a/tests/ui/nll/closure-requirements/return-wrong-bound-region.stderr +++ b/tests/ui/nll/closure-requirements/return-wrong-bound-region.stderr @@ -6,7 +6,7 @@ LL | expect_sig(|a, b| b); // ought to return `a` | = note: defining type: test::{closure#0} with closure args [ i16, - for<Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) i32, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) i32)) -> &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) i32, + for<Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) i32, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) i32)) -> &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) i32, (), ] diff --git a/tests/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr b/tests/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr index 660211fe21a..f58d49d8461 100644 --- a/tests/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr +++ b/tests/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr @@ -6,7 +6,7 @@ LL | twice(cell, value, |a, b| invoke(a, b)); | = note: defining type: generic::<T>::{closure#0} with closure args [ i16, - for<Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((std::option::Option<std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) ()>>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) T)), + for<Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((std::option::Option<std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) ()>>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) T)), (), ] = note: number of external vids: 2 @@ -28,7 +28,7 @@ LL | twice(cell, value, |a, b| invoke(a, b)); | = note: defining type: generic_fail::<T>::{closure#0} with closure args [ i16, - for<Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((std::option::Option<std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) ()>>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) T)), + for<Region(BrAnon), Region(BrAnon)> extern "rust-call" fn((std::option::Option<std::cell::Cell<&'?1 &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon }) ()>>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon }) T)), (), ] = note: late-bound region is '?2 diff --git a/tests/ui/panics/short-ice-remove-middle-frames-2.rs b/tests/ui/panics/short-ice-remove-middle-frames-2.rs index 38a80f8b670..751959f55bb 100644 --- a/tests/ui/panics/short-ice-remove-middle-frames-2.rs +++ b/tests/ui/panics/short-ice-remove-middle-frames-2.rs @@ -2,6 +2,7 @@ // run-fail // check-run-results // exec-env:RUST_BACKTRACE=1 +// needs-unwind // ignore-android FIXME #17520 // ignore-wasm no panic support // ignore-openbsd no support for libbacktrace without filename diff --git a/tests/ui/panics/short-ice-remove-middle-frames-2.run.stderr b/tests/ui/panics/short-ice-remove-middle-frames-2.run.stderr index 2b648a0cad2..664ebaa4c51 100644 --- a/tests/ui/panics/short-ice-remove-middle-frames-2.run.stderr +++ b/tests/ui/panics/short-ice-remove-middle-frames-2.run.stderr @@ -1,4 +1,4 @@ -thread 'main' panicked at $DIR/short-ice-remove-middle-frames-2.rs:56:5: +thread 'main' panicked at $DIR/short-ice-remove-middle-frames-2.rs:57:5: debug!!! stack backtrace: 0: std::panicking::begin_panic diff --git a/tests/ui/panics/short-ice-remove-middle-frames.rs b/tests/ui/panics/short-ice-remove-middle-frames.rs index c872084f033..134e13233da 100644 --- a/tests/ui/panics/short-ice-remove-middle-frames.rs +++ b/tests/ui/panics/short-ice-remove-middle-frames.rs @@ -2,6 +2,7 @@ // run-fail // check-run-results // exec-env:RUST_BACKTRACE=1 +// needs-unwind // ignore-android FIXME #17520 // ignore-wasm no panic support // ignore-openbsd no support for libbacktrace without filename diff --git a/tests/ui/panics/short-ice-remove-middle-frames.run.stderr b/tests/ui/panics/short-ice-remove-middle-frames.run.stderr index 5b372684096..bc252fde1f6 100644 --- a/tests/ui/panics/short-ice-remove-middle-frames.run.stderr +++ b/tests/ui/panics/short-ice-remove-middle-frames.run.stderr @@ -1,4 +1,4 @@ -thread 'main' panicked at $DIR/short-ice-remove-middle-frames.rs:52:5: +thread 'main' panicked at $DIR/short-ice-remove-middle-frames.rs:53:5: debug!!! stack backtrace: 0: std::panicking::begin_panic diff --git a/tests/ui/parser/issues/issue-89388.stderr b/tests/ui/parser/issues/issue-89388.stderr index cf28bef0f4a..366d05c2d94 100644 --- a/tests/ui/parser/issues/issue-89388.stderr +++ b/tests/ui/parser/issues/issue-89388.stderr @@ -2,7 +2,12 @@ error: missing angle brackets in associated item path --> $DIR/issue-89388.rs:5:24 | LL | let _ = option.map([_]::to_vec); - | ^^^^^^^^^^^ help: try: `<[_]>::to_vec` + | ^^^ + | +help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths + | +LL | let _ = option.map(<[_]>::to_vec); + | + + error: aborting due to previous error diff --git a/tests/ui/pattern/usefulness/floats.rs b/tests/ui/pattern/usefulness/floats.rs index 095f5ac9a89..2616dfadb85 100644 --- a/tests/ui/pattern/usefulness/floats.rs +++ b/tests/ui/pattern/usefulness/floats.rs @@ -1,19 +1,45 @@ +#![feature(exclusive_range_pattern)] #![allow(illegal_floating_point_literal_pattern)] #![deny(unreachable_patterns)] fn main() { match 0.0 { - 0.0..=1.0 => {} - _ => {} // ok + 0.0..=1.0 => {} + _ => {} // ok } - match 0.0 { //~ ERROR non-exhaustive patterns - 0.0..=1.0 => {} + match 0.0 { + //~^ ERROR non-exhaustive patterns + 0.0..=1.0 => {} } match 1.0f64 { - 0.01f64 ..= 6.5f64 => {} - 0.02f64 => {} //~ ERROR unreachable pattern - _ => {} + 0.01f64..=6.5f64 => {} + 0.005f64 => {} + 0.01f64 => {} //~ ERROR unreachable pattern + 0.02f64 => {} //~ ERROR unreachable pattern + 6.5f64 => {} //~ ERROR unreachable pattern + 6.6f64 => {} + 1.0f64..=4.0f64 => {} //~ ERROR unreachable pattern + 5.0f64..=7.0f64 => {} + _ => {} + }; + match 1.0f64 { + 0.01f64..6.5f64 => {} + 6.5f64 => {} // this is reachable + _ => {} + }; + + match 1.0f32 { + 0.01f32..=6.5f32 => {} + 0.01f32 => {} //~ ERROR unreachable pattern + 0.02f32 => {} //~ ERROR unreachable pattern + 6.5f32 => {} //~ ERROR unreachable pattern + _ => {} + }; + match 1.0f32 { + 0.01f32..6.5f32 => {} + 6.5f32 => {} // this is reachable + _ => {} }; } diff --git a/tests/ui/pattern/usefulness/floats.stderr b/tests/ui/pattern/usefulness/floats.stderr index d66d4ba298b..f5041911824 100644 --- a/tests/ui/pattern/usefulness/floats.stderr +++ b/tests/ui/pattern/usefulness/floats.stderr @@ -1,5 +1,5 @@ error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/floats.rs:10:11 + --> $DIR/floats.rs:11:11 | LL | match 0.0 { | ^^^ pattern `_` not covered @@ -7,22 +7,58 @@ LL | match 0.0 { = note: the matched value is of type `f64` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ 0.0..=1.0 => {}, -LL + _ => todo!() +LL ~ 0.0..=1.0 => {}, +LL + _ => todo!() | error: unreachable pattern - --> $DIR/floats.rs:16:7 + --> $DIR/floats.rs:19:9 | -LL | 0.02f64 => {} - | ^^^^^^^ +LL | 0.01f64 => {} + | ^^^^^^^ | note: the lint level is defined here - --> $DIR/floats.rs:2:9 + --> $DIR/floats.rs:3:9 | LL | #![deny(unreachable_patterns)] | ^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 2 previous errors +error: unreachable pattern + --> $DIR/floats.rs:20:9 + | +LL | 0.02f64 => {} + | ^^^^^^^ + +error: unreachable pattern + --> $DIR/floats.rs:21:9 + | +LL | 6.5f64 => {} + | ^^^^^^ + +error: unreachable pattern + --> $DIR/floats.rs:23:9 + | +LL | 1.0f64..=4.0f64 => {} + | ^^^^^^^^^^^^^^^ + +error: unreachable pattern + --> $DIR/floats.rs:35:9 + | +LL | 0.01f32 => {} + | ^^^^^^^ + +error: unreachable pattern + --> $DIR/floats.rs:36:9 + | +LL | 0.02f32 => {} + | ^^^^^^^ + +error: unreachable pattern + --> $DIR/floats.rs:37:9 + | +LL | 6.5f32 => {} + | ^^^^^^ + +error: aborting due to 8 previous errors For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/proc-macro/auxiliary/print-tokens.rs b/tests/ui/proc-macro/auxiliary/print-tokens.rs new file mode 100644 index 00000000000..3a5767edb15 --- /dev/null +++ b/tests/ui/proc-macro/auxiliary/print-tokens.rs @@ -0,0 +1,16 @@ +// force-host +// no-prefer-dynamic +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::{TokenStream, TokenTree}; + +#[proc_macro] +pub fn print_tokens(input: TokenStream) -> TokenStream { + println!("{:#?}", input); + for token in input { + println!("{token}"); + } + TokenStream::new() +} diff --git a/tests/ui/proc-macro/literal-to-string.rs b/tests/ui/proc-macro/literal-to-string.rs new file mode 100644 index 00000000000..494d17cbeea --- /dev/null +++ b/tests/ui/proc-macro/literal-to-string.rs @@ -0,0 +1,26 @@ +// check-pass +// edition: 2021 +#![feature(c_str_literals)] + +// aux-build: print-tokens.rs +extern crate print_tokens; + +fn main() { + print_tokens::print_tokens! { + 1 + 17u8 + 42. + 3.14f32 + b'a' + b'\xFF' + 'c' + '\x32' + "\"str\"" + r#""raw" str"# + r###"very ##"raw"## str"### + b"\"byte\" str" + br#""raw" "byte" str"# + c"\"c\" str" + cr#""raw" "c" str"# + } +} diff --git a/tests/ui/proc-macro/literal-to-string.stdout b/tests/ui/proc-macro/literal-to-string.stdout new file mode 100644 index 00000000000..7b27fcf798b --- /dev/null +++ b/tests/ui/proc-macro/literal-to-string.stdout @@ -0,0 +1,107 @@ +TokenStream [ + Literal { + kind: Integer, + symbol: "1", + suffix: None, + span: #0 bytes(172..173), + }, + Literal { + kind: Integer, + symbol: "17", + suffix: Some("u8"), + span: #0 bytes(182..186), + }, + Literal { + kind: Float, + symbol: "42.", + suffix: None, + span: #0 bytes(195..198), + }, + Literal { + kind: Float, + symbol: "3.14", + suffix: Some("f32"), + span: #0 bytes(207..214), + }, + Literal { + kind: Byte, + symbol: "a", + suffix: None, + span: #0 bytes(223..227), + }, + Literal { + kind: Byte, + symbol: "\xFF", + suffix: None, + span: #0 bytes(236..243), + }, + Literal { + kind: Char, + symbol: "c", + suffix: None, + span: #0 bytes(252..255), + }, + Literal { + kind: Char, + symbol: "\x32", + suffix: None, + span: #0 bytes(264..270), + }, + Literal { + kind: Str, + symbol: "\\"str\\"", + suffix: None, + span: #0 bytes(279..288), + }, + Literal { + kind: StrRaw(1), + symbol: "\"raw\" str", + suffix: None, + span: #0 bytes(297..311), + }, + Literal { + kind: StrRaw(3), + symbol: "very ##\"raw\"## str", + suffix: None, + span: #0 bytes(320..347), + }, + Literal { + kind: ByteStr, + symbol: "\\"byte\\" str", + suffix: None, + span: #0 bytes(356..371), + }, + Literal { + kind: ByteStrRaw(1), + symbol: "\"raw\" \"byte\" str", + suffix: None, + span: #0 bytes(380..402), + }, + Literal { + kind: CStr, + symbol: "\\"c\\" str", + suffix: None, + span: #0 bytes(411..423), + }, + Literal { + kind: CStrRaw(1), + symbol: "\"raw\" \"c\" str", + suffix: None, + span: #0 bytes(432..451), + }, +] +1 +17u8 +42. +3.14f32 +b'a' +b'\xFF' +'c' +'\x32' +"\"str\"" +r#""raw" str"# +r###"very ##"raw"## str"### +b"\"byte\" str" +br#""raw" "byte" str"# +c"\"c\" str" +cr#""raw" "c" str"# diff --git a/tests/ui/repr/16-bit-repr-c-enum.rs b/tests/ui/repr/16-bit-repr-c-enum.rs index 2acfde4be46..d4fea2b192b 100644 --- a/tests/ui/repr/16-bit-repr-c-enum.rs +++ b/tests/ui/repr/16-bit-repr-c-enum.rs @@ -5,7 +5,7 @@ // [avr] compile-flags: --target=avr-unknown-gnu-atmega328 --crate-type=rlib // [msp430] needs-llvm-components: msp430 // [msp430] compile-flags: --target=msp430-none-elf --crate-type=rlib -#![feature(no_core, lang_items, intrinsics, staged_api)] +#![feature(no_core, lang_items, intrinsics, staged_api, rustc_attrs)] #![no_core] #![crate_type = "lib"] #![stable(feature = "", since = "")] diff --git a/tests/ui/resolve/associated-fn-called-as-fn.stderr b/tests/ui/resolve/associated-fn-called-as-fn.stderr index fbdea30d551..7d28b959a1a 100644 --- a/tests/ui/resolve/associated-fn-called-as-fn.stderr +++ b/tests/ui/resolve/associated-fn-called-as-fn.stderr @@ -2,13 +2,23 @@ error[E0425]: cannot find function `collect_primary` in this scope --> $DIR/associated-fn-called-as-fn.rs:6:30 | LL | '0'..='9' => collect_primary(&c), - | ^^^^^^^^^^^^^^^ help: you might have meant to call the associated function: `Self::collect_primary` + | ^^^^^^^^^^^^^^^ + | +help: you might have meant to call the associated function + | +LL | '0'..='9' => Self::collect_primary(&c), + | ++++++ error[E0425]: cannot find function `collect_primary` in this scope --> $DIR/associated-fn-called-as-fn.rs:23:30 | LL | '0'..='9' => collect_primary(&c), - | ^^^^^^^^^^^^^^^ help: you might have meant to call the associated function: `Self::collect_primary` + | ^^^^^^^^^^^^^^^ + | +help: you might have meant to call the associated function + | +LL | '0'..='9' => Self::collect_primary(&c), + | ++++++ error: aborting due to 2 previous errors diff --git a/tests/ui/resolve/field-and-method-in-self-not-available-in-assoc-fn.rs b/tests/ui/resolve/field-and-method-in-self-not-available-in-assoc-fn.rs index 9e72c36151e..b5f13959081 100644 --- a/tests/ui/resolve/field-and-method-in-self-not-available-in-assoc-fn.rs +++ b/tests/ui/resolve/field-and-method-in-self-not-available-in-assoc-fn.rs @@ -11,5 +11,8 @@ impl Foo { field; //~ ERROR cannot find value `field` in this scope Foo { field } //~ ERROR cannot find value `field` in this scope } + fn clone(&self) -> Foo { + Foo { field } //~ ERROR cannot find value `field` in this scope + } } fn main() {} diff --git a/tests/ui/resolve/field-and-method-in-self-not-available-in-assoc-fn.stderr b/tests/ui/resolve/field-and-method-in-self-not-available-in-assoc-fn.stderr index 2eb3861e5f1..3c44c1c249c 100644 --- a/tests/ui/resolve/field-and-method-in-self-not-available-in-assoc-fn.stderr +++ b/tests/ui/resolve/field-and-method-in-self-not-available-in-assoc-fn.stderr @@ -1,21 +1,41 @@ error[E0425]: cannot find value `field` in this scope --> $DIR/field-and-method-in-self-not-available-in-assoc-fn.rs:11:9 | +LL | field: u32, + | ---------- a field by that name exists in `Self` +... LL | fn field(&self) -> u32 { | ----- a method by that name is available on `Self` here ... LL | field; - | ^^^^^ a field by this name exists in `Self` + | ^^^^^ error[E0425]: cannot find value `field` in this scope --> $DIR/field-and-method-in-self-not-available-in-assoc-fn.rs:12:15 | +LL | field: u32, + | ---------- a field by that name exists in `Self` +... LL | fn field(&self) -> u32 { | ----- a method by that name is available on `Self` here ... LL | Foo { field } - | ^^^^^ a field by this name exists in `Self` + | ^^^^^ + +error[E0425]: cannot find value `field` in this scope + --> $DIR/field-and-method-in-self-not-available-in-assoc-fn.rs:15:15 + | +LL | fn field(&self) -> u32 { + | ----- a method by that name is available on `Self` here +... +LL | Foo { field } + | ^^^^^ + | +help: you might have meant to use the available field + | +LL | Foo { field: self.field } + | ++++++++++++ -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/resolve/issue-116164.rs b/tests/ui/resolve/issue-116164.rs new file mode 100644 index 00000000000..d30c8f514b3 --- /dev/null +++ b/tests/ui/resolve/issue-116164.rs @@ -0,0 +1,19 @@ +#![allow(unused_imports)] + +mod inner { + pub enum Example { + ExOne, + } +} + +mod reexports { + pub use crate::inner::Example as _; +} + +use crate::reexports::*; +//~^ SUGGESTION: use inner::Example::ExOne + +fn main() { + ExOne; + //~^ ERROR: cannot find value `ExOne` in this scope +} diff --git a/tests/ui/resolve/issue-116164.stderr b/tests/ui/resolve/issue-116164.stderr new file mode 100644 index 00000000000..5820a189fd5 --- /dev/null +++ b/tests/ui/resolve/issue-116164.stderr @@ -0,0 +1,14 @@ +error[E0425]: cannot find value `ExOne` in this scope + --> $DIR/issue-116164.rs:17:5 + | +LL | ExOne; + | ^^^^^ not found in this scope + | +help: consider importing this unit variant + | +LL + use inner::Example::ExOne; + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/resolve/issue-14254.stderr b/tests/ui/resolve/issue-14254.stderr index 690a40f7edd..9284b4babc5 100644 --- a/tests/ui/resolve/issue-14254.stderr +++ b/tests/ui/resolve/issue-14254.stderr @@ -8,13 +8,23 @@ error[E0425]: cannot find value `x` in this scope --> $DIR/issue-14254.rs:30:9 | LL | x; - | ^ help: you might have meant to use the available field: `self.x` + | ^ + | +help: you might have meant to use the available field + | +LL | self.x; + | +++++ error[E0425]: cannot find value `y` in this scope --> $DIR/issue-14254.rs:32:9 | LL | y; - | ^ help: you might have meant to use the available field: `self.y` + | ^ + | +help: you might have meant to use the available field + | +LL | self.y; + | +++++ error[E0425]: cannot find value `a` in this scope --> $DIR/issue-14254.rs:34:9 @@ -31,7 +41,7 @@ LL | bah; help: you might have meant to refer to the associated function | LL | Self::bah; - | ~~~~~~~~~ + | ++++++ error[E0425]: cannot find value `b` in this scope --> $DIR/issue-14254.rs:38:9 @@ -43,13 +53,23 @@ error[E0425]: cannot find value `x` in this scope --> $DIR/issue-14254.rs:47:9 | LL | x; - | ^ help: you might have meant to use the available field: `self.x` + | ^ + | +help: you might have meant to use the available field + | +LL | self.x; + | +++++ error[E0425]: cannot find value `y` in this scope --> $DIR/issue-14254.rs:49:9 | LL | y; - | ^ help: you might have meant to use the available field: `self.y` + | ^ + | +help: you might have meant to use the available field + | +LL | self.y; + | +++++ error[E0425]: cannot find value `a` in this scope --> $DIR/issue-14254.rs:51:9 @@ -66,7 +86,7 @@ LL | bah; help: you might have meant to refer to the associated function | LL | Self::bah; - | ~~~~~~~~~ + | ++++++ error[E0425]: cannot find value `b` in this scope --> $DIR/issue-14254.rs:55:9 @@ -83,7 +103,7 @@ LL | bah; help: you might have meant to refer to the associated function | LL | Self::bah; - | ~~~~~~~~~ + | ++++++ error[E0425]: cannot find value `bah` in this scope --> $DIR/issue-14254.rs:73:9 @@ -94,7 +114,7 @@ LL | bah; help: you might have meant to refer to the associated function | LL | Self::bah; - | ~~~~~~~~~ + | ++++++ error[E0425]: cannot find value `bah` in this scope --> $DIR/issue-14254.rs:82:9 @@ -105,7 +125,7 @@ LL | bah; help: you might have meant to refer to the associated function | LL | Self::bah; - | ~~~~~~~~~ + | ++++++ error[E0425]: cannot find value `bah` in this scope --> $DIR/issue-14254.rs:91:9 @@ -116,7 +136,7 @@ LL | bah; help: you might have meant to refer to the associated function | LL | Self::bah; - | ~~~~~~~~~ + | ++++++ error[E0425]: cannot find value `bah` in this scope --> $DIR/issue-14254.rs:100:9 @@ -127,55 +147,95 @@ LL | bah; help: you might have meant to refer to the associated function | LL | Self::bah; - | ~~~~~~~~~ + | ++++++ error[E0425]: cannot find function `baz` in this scope --> $DIR/issue-14254.rs:19:9 | LL | baz(); - | ^^^ help: you might have meant to call the method: `self.baz` + | ^^^ + | +help: you might have meant to call the method + | +LL | self.baz(); + | +++++ error[E0425]: cannot find function `baz` in this scope --> $DIR/issue-14254.rs:28:9 | LL | baz(); - | ^^^ help: you might have meant to call the method: `self.baz` + | ^^^ + | +help: you might have meant to call the method + | +LL | self.baz(); + | +++++ error[E0425]: cannot find function `baz` in this scope --> $DIR/issue-14254.rs:45:9 | LL | baz(); - | ^^^ help: you might have meant to call the method: `self.baz` + | ^^^ + | +help: you might have meant to call the method + | +LL | self.baz(); + | +++++ error[E0425]: cannot find function `baz` in this scope --> $DIR/issue-14254.rs:62:9 | LL | baz(); - | ^^^ help: you might have meant to call the method: `self.baz` + | ^^^ + | +help: you might have meant to call the method + | +LL | self.baz(); + | +++++ error[E0425]: cannot find function `baz` in this scope --> $DIR/issue-14254.rs:71:9 | LL | baz(); - | ^^^ help: you might have meant to call the method: `self.baz` + | ^^^ + | +help: you might have meant to call the method + | +LL | self.baz(); + | +++++ error[E0425]: cannot find function `baz` in this scope --> $DIR/issue-14254.rs:80:9 | LL | baz(); - | ^^^ help: you might have meant to call the method: `self.baz` + | ^^^ + | +help: you might have meant to call the method + | +LL | self.baz(); + | +++++ error[E0425]: cannot find function `baz` in this scope --> $DIR/issue-14254.rs:89:9 | LL | baz(); - | ^^^ help: you might have meant to call the method: `self.baz` + | ^^^ + | +help: you might have meant to call the method + | +LL | self.baz(); + | +++++ error[E0425]: cannot find function `baz` in this scope --> $DIR/issue-14254.rs:98:9 | LL | baz(); - | ^^^ help: you might have meant to call the method: `self.baz` + | ^^^ + | +help: you might have meant to call the method + | +LL | self.baz(); + | +++++ error: aborting due to 24 previous errors diff --git a/tests/ui/resolve/issue-2356.stderr b/tests/ui/resolve/issue-2356.stderr index 273e8b2a661..5f75ae98870 100644 --- a/tests/ui/resolve/issue-2356.stderr +++ b/tests/ui/resolve/issue-2356.stderr @@ -1,8 +1,11 @@ error[E0425]: cannot find value `whiskers` in this scope --> $DIR/issue-2356.rs:39:5 | +LL | whiskers: isize, + | --------------- a field by that name exists in `Self` +... LL | whiskers -= other; - | ^^^^^^^^ a field by this name exists in `Self` + | ^^^^^^^^ error[E0424]: expected value, found module `self` --> $DIR/issue-2356.rs:65:8 @@ -21,13 +24,21 @@ error[E0425]: cannot find value `whiskers` in this scope --> $DIR/issue-2356.rs:79:5 | LL | whiskers = 0; - | ^^^^^^^^ help: you might have meant to use the available field: `self.whiskers` + | ^^^^^^^^ + | +help: you might have meant to use the available field + | +LL | self.whiskers = 0; + | +++++ error[E0425]: cannot find value `whiskers` in this scope --> $DIR/issue-2356.rs:84:5 | +LL | whiskers: isize, + | --------------- a field by that name exists in `Self` +... LL | whiskers = 4; - | ^^^^^^^^ a field by this name exists in `Self` + | ^^^^^^^^ error[E0424]: expected value, found module `self` --> $DIR/issue-2356.rs:92:5 @@ -47,19 +58,34 @@ error[E0425]: cannot find function `clone` in this scope --> $DIR/issue-2356.rs:24:5 | LL | clone(); - | ^^^^^ help: you might have meant to call the method: `self.clone` + | ^^^^^ + | +help: you might have meant to call the method + | +LL | self.clone(); + | +++++ error[E0425]: cannot find function `default` in this scope --> $DIR/issue-2356.rs:31:5 | LL | default(); - | ^^^^^^^ help: you might have meant to call the associated function: `Self::default` + | ^^^^^^^ + | +help: you might have meant to call the associated function + | +LL | Self::default(); + | ++++++ error[E0425]: cannot find function `shave` in this scope --> $DIR/issue-2356.rs:41:5 | LL | shave(4); - | ^^^^^ help: you might have meant to call the associated function: `Self::shave` + | ^^^^^ + | +help: you might have meant to call the associated function + | +LL | Self::shave(4); + | ++++++ error[E0425]: cannot find function `purr` in this scope --> $DIR/issue-2356.rs:43:5 diff --git a/tests/ui/resolve/issue-60057.stderr b/tests/ui/resolve/issue-60057.stderr index 4d915fcd9fe..a2ab8644353 100644 --- a/tests/ui/resolve/issue-60057.stderr +++ b/tests/ui/resolve/issue-60057.stderr @@ -1,14 +1,22 @@ error[E0425]: cannot find value `banana` in this scope --> $DIR/issue-60057.rs:8:21 | +LL | banana: u8, + | ---------- a field by that name exists in `Self` +... LL | banana: banana - | ^^^^^^ a field by this name exists in `Self` + | ^^^^^^ error[E0425]: cannot find value `banana` in this scope --> $DIR/issue-60057.rs:14:21 | LL | banana: banana - | ^^^^^^ help: you might have meant to use the available field: `self.banana` + | ^^^^^^ + | +help: you might have meant to use the available field + | +LL | banana: self.banana + | +++++ error: aborting due to 2 previous errors diff --git a/tests/ui/resolve/resolve-assoc-suggestions.stderr b/tests/ui/resolve/resolve-assoc-suggestions.stderr index 8def9aa2025..3d9d4ffaa10 100644 --- a/tests/ui/resolve/resolve-assoc-suggestions.stderr +++ b/tests/ui/resolve/resolve-assoc-suggestions.stderr @@ -14,13 +14,23 @@ error[E0425]: cannot find value `field` in this scope --> $DIR/resolve-assoc-suggestions.rs:20:9 | LL | field; - | ^^^^^ help: you might have meant to use the available field: `self.field` + | ^^^^^ + | +help: you might have meant to use the available field + | +LL | self.field; + | +++++ error[E0412]: cannot find type `Type` in this scope --> $DIR/resolve-assoc-suggestions.rs:23:16 | LL | let _: Type; - | ^^^^ help: you might have meant to use the associated type: `Self::Type` + | ^^^^ + | +help: you might have meant to use the associated type + | +LL | let _: Self::Type; + | ++++++ error[E0531]: cannot find tuple struct or tuple variant `Type` in this scope --> $DIR/resolve-assoc-suggestions.rs:25:13 @@ -50,7 +60,12 @@ error[E0425]: cannot find value `method` in this scope --> $DIR/resolve-assoc-suggestions.rs:34:9 | LL | method; - | ^^^^^^ help: you might have meant to refer to the method: `self.method` + | ^^^^^^ + | +help: you might have meant to refer to the method + | +LL | self.method; + | +++++ error: aborting due to 9 previous errors diff --git a/tests/ui/resolve/resolve-speculative-adjustment.stderr b/tests/ui/resolve/resolve-speculative-adjustment.stderr index be11a7ebeca..fb15472bdae 100644 --- a/tests/ui/resolve/resolve-speculative-adjustment.stderr +++ b/tests/ui/resolve/resolve-speculative-adjustment.stderr @@ -8,13 +8,23 @@ error[E0425]: cannot find value `field` in this scope --> $DIR/resolve-speculative-adjustment.rs:23:9 | LL | field; - | ^^^^^ help: you might have meant to use the available field: `self.field` + | ^^^^^ + | +help: you might have meant to use the available field + | +LL | self.field; + | +++++ error[E0425]: cannot find function `method` in this scope --> $DIR/resolve-speculative-adjustment.rs:25:9 | LL | method(); - | ^^^^^^ help: you might have meant to call the method: `self.method` + | ^^^^^^ + | +help: you might have meant to call the method + | +LL | self.method(); + | +++++ error[E0425]: cannot find function `method` in this scope --> $DIR/resolve-speculative-adjustment.rs:19:13 diff --git a/tests/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.stderr b/tests/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.stderr index f32e0404e46..0306c8af87d 100644 --- a/tests/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.stderr +++ b/tests/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.stderr @@ -1,20 +1,20 @@ error[E0425]: cannot find value `config` in this scope --> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:7:16 | +LL | config: String, + | -------------- a field by that name exists in `Self` +... LL | Self { config } - | ^^^^^^ - | | - | a field by this name exists in `Self` - | help: a local variable with a similar name exists: `cofig` + | ^^^^^^ help: a local variable with a similar name exists: `cofig` error[E0425]: cannot find value `config` in this scope --> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:11:20 | +LL | config: String, + | -------------- a field by that name exists in `Self` +... LL | println!("{config}"); - | ^^^^^^ - | | - | a field by this name exists in `Self` - | help: a local variable with a similar name exists: `cofig` + | ^^^^^^ help: a local variable with a similar name exists: `cofig` error[E0425]: cannot find value `config` in this scope --> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:15:20 @@ -25,7 +25,7 @@ LL | println!("{config}"); help: you might have meant to use the available field | LL | println!("{self.config}"); - | ~~~~~~~~~~~ + | +++++ help: a local variable with a similar name exists | LL | println!("{cofig}"); @@ -43,7 +43,7 @@ LL | fn ba() {} help: you might have meant to refer to the associated function | LL | Self::bah; - | ~~~~~~~~~ + | ++++++ help: a function with a similar name exists | LL | ba; @@ -61,7 +61,7 @@ LL | const BARR: u32 = 3; help: you might have meant to use the associated `const` | LL | Self::BAR; - | ~~~~~~~~~ + | ++++++ help: a constant with a similar name exists | LL | BARR; @@ -79,7 +79,7 @@ LL | type Bar = String; help: you might have meant to use the associated type | LL | let foo: Self::Baz = "".to_string(); - | ~~~~~~~~~ + | ++++++ help: a type alias with a similar name exists | LL | let foo: Bar = "".to_string(); @@ -97,7 +97,7 @@ LL | fn ba() {} help: you might have meant to call the method | LL | self.baz(); - | ~~~~~~~~ + | +++++ help: a function with a similar name exists | LL | ba(); diff --git a/tests/ui/resolve/unresolved_static_type_field.stderr b/tests/ui/resolve/unresolved_static_type_field.stderr index 06926b53ddd..035dc9b9656 100644 --- a/tests/ui/resolve/unresolved_static_type_field.stderr +++ b/tests/ui/resolve/unresolved_static_type_field.stderr @@ -1,8 +1,11 @@ error[E0425]: cannot find value `cx` in this scope --> $DIR/unresolved_static_type_field.rs:9:11 | +LL | cx: bool, + | -------- a field by that name exists in `Self` +... LL | f(cx); - | ^^ a field by this name exists in `Self` + | ^^ error: aborting due to previous error diff --git a/tests/ui/self/class-missing-self.stderr b/tests/ui/self/class-missing-self.stderr index 08493b4f9a2..ca7a896200f 100644 --- a/tests/ui/self/class-missing-self.stderr +++ b/tests/ui/self/class-missing-self.stderr @@ -2,7 +2,12 @@ error[E0425]: cannot find value `meows` in this scope --> $DIR/class-missing-self.rs:9:7 | LL | meows += 1; - | ^^^^^ help: you might have meant to use the available field: `self.meows` + | ^^^^^ + | +help: you might have meant to use the available field + | +LL | self.meows += 1; + | +++++ error[E0425]: cannot find function `sleep` in this scope --> $DIR/class-missing-self.rs:10:7 diff --git a/tests/ui/simd/intrinsic/generic-elements.rs b/tests/ui/simd/intrinsic/generic-elements.rs index 0ff2203ec72..6ba93e46f75 100644 --- a/tests/ui/simd/intrinsic/generic-elements.rs +++ b/tests/ui/simd/intrinsic/generic-elements.rs @@ -1,6 +1,7 @@ // build-fail -#![feature(repr_simd, platform_intrinsics, rustc_attrs)] +#![feature(repr_simd, platform_intrinsics, rustc_attrs, adt_const_params)] +#![allow(incomplete_features)] #[repr(simd)] #[derive(Copy, Clone)] @@ -35,6 +36,7 @@ extern "platform-intrinsic" { fn simd_extract<T, E>(x: T, idx: u32) -> E; fn simd_shuffle<T, I, U>(x: T, y: T, idx: I) -> U; + fn simd_shuffle_generic<T, U, const IDX: &'static [u32]>(x: T, y: T) -> U; } fn main() { @@ -71,5 +73,29 @@ fn main() { //~^ ERROR expected return type of length 4, found `i32x8` with length 8 simd_shuffle::<_, _, i32x2>(x, x, IDX8); //~^ ERROR expected return type of length 8, found `i32x2` with length 2 + + const I2: &[u32] = &[0; 2]; + simd_shuffle_generic::<i32, i32, I2>(0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + const I4: &[u32] = &[0; 4]; + simd_shuffle_generic::<i32, i32, I4>(0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + const I8: &[u32] = &[0; 8]; + simd_shuffle_generic::<i32, i32, I8>(0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + + simd_shuffle_generic::<_, f32x2, I2>(x, x); +//~^ ERROR element type `i32` (element of input `i32x4`), found `f32x2` with element type `f32` + simd_shuffle_generic::<_, f32x4, I4>(x, x); +//~^ ERROR element type `i32` (element of input `i32x4`), found `f32x4` with element type `f32` + simd_shuffle_generic::<_, f32x8, I8>(x, x); +//~^ ERROR element type `i32` (element of input `i32x4`), found `f32x8` with element type `f32` + + simd_shuffle_generic::<_, i32x8, I2>(x, x); + //~^ ERROR expected return type of length 2, found `i32x8` with length 8 + simd_shuffle_generic::<_, i32x8, I4>(x, x); + //~^ ERROR expected return type of length 4, found `i32x8` with length 8 + simd_shuffle_generic::<_, i32x2, I8>(x, x); + //~^ ERROR expected return type of length 8, found `i32x2` with length 2 } } diff --git a/tests/ui/simd/intrinsic/generic-elements.stderr b/tests/ui/simd/intrinsic/generic-elements.stderr index 115d9d4b3f3..26e01344939 100644 --- a/tests/ui/simd/intrinsic/generic-elements.stderr +++ b/tests/ui/simd/intrinsic/generic-elements.stderr @@ -1,75 +1,129 @@ error[E0511]: invalid monomorphization of `simd_insert` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-elements.rs:44:9 + --> $DIR/generic-elements.rs:46:9 | LL | simd_insert(0, 0, 0); | ^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_insert` intrinsic: expected inserted type `i32` (element of input `i32x4`), found `f64` - --> $DIR/generic-elements.rs:46:9 + --> $DIR/generic-elements.rs:48:9 | LL | simd_insert(x, 0, 1.0); | ^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_extract` intrinsic: expected return type `i32` (element of input `i32x4`), found `f32` - --> $DIR/generic-elements.rs:48:9 + --> $DIR/generic-elements.rs:50:9 | LL | simd_extract::<_, f32>(x, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-elements.rs:52:9 + --> $DIR/generic-elements.rs:54:9 | LL | simd_shuffle::<i32, _, i32>(0, 0, IDX2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-elements.rs:55:9 + --> $DIR/generic-elements.rs:57:9 | LL | simd_shuffle::<i32, _, i32>(0, 0, IDX4); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-elements.rs:58:9 + --> $DIR/generic-elements.rs:60:9 | LL | simd_shuffle::<i32, _, i32>(0, 0, IDX8); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x2` with element type `f32` - --> $DIR/generic-elements.rs:61:9 + --> $DIR/generic-elements.rs:63:9 | LL | simd_shuffle::<_, _, f32x2>(x, x, IDX2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x4` with element type `f32` - --> $DIR/generic-elements.rs:63:9 + --> $DIR/generic-elements.rs:65:9 | LL | simd_shuffle::<_, _, f32x4>(x, x, IDX4); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x8` with element type `f32` - --> $DIR/generic-elements.rs:65:9 + --> $DIR/generic-elements.rs:67:9 | LL | simd_shuffle::<_, _, f32x8>(x, x, IDX8); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return type of length 2, found `i32x8` with length 8 - --> $DIR/generic-elements.rs:68:9 + --> $DIR/generic-elements.rs:70:9 | LL | simd_shuffle::<_, _, i32x8>(x, x, IDX2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return type of length 4, found `i32x8` with length 8 - --> $DIR/generic-elements.rs:70:9 + --> $DIR/generic-elements.rs:72:9 | LL | simd_shuffle::<_, _, i32x8>(x, x, IDX4); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return type of length 8, found `i32x2` with length 2 - --> $DIR/generic-elements.rs:72:9 + --> $DIR/generic-elements.rs:74:9 | LL | simd_shuffle::<_, _, i32x2>(x, x, IDX8); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 12 previous errors +error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-elements.rs:78:9 + | +LL | simd_shuffle_generic::<i32, i32, I2>(0, 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-elements.rs:81:9 + | +LL | simd_shuffle_generic::<i32, i32, I4>(0, 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-elements.rs:84:9 + | +LL | simd_shuffle_generic::<i32, i32, I8>(0, 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x2` with element type `f32` + --> $DIR/generic-elements.rs:87:9 + | +LL | simd_shuffle_generic::<_, f32x2, I2>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x4` with element type `f32` + --> $DIR/generic-elements.rs:89:9 + | +LL | simd_shuffle_generic::<_, f32x4, I4>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x8` with element type `f32` + --> $DIR/generic-elements.rs:91:9 + | +LL | simd_shuffle_generic::<_, f32x8, I8>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected return type of length 2, found `i32x8` with length 8 + --> $DIR/generic-elements.rs:94:9 + | +LL | simd_shuffle_generic::<_, i32x8, I2>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected return type of length 4, found `i32x8` with length 8 + --> $DIR/generic-elements.rs:96:9 + | +LL | simd_shuffle_generic::<_, i32x8, I4>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected return type of length 8, found `i32x2` with length 2 + --> $DIR/generic-elements.rs:98:9 + | +LL | simd_shuffle_generic::<_, i32x2, I8>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 21 previous errors For more information about this error, try `rustc --explain E0511`. diff --git a/tests/ui/simd/monomorphize-shuffle-index.generic.stderr b/tests/ui/simd/monomorphize-shuffle-index.generic.stderr new file mode 100644 index 00000000000..fc66b195674 --- /dev/null +++ b/tests/ui/simd/monomorphize-shuffle-index.generic.stderr @@ -0,0 +1,12 @@ +error: overly complex generic constant + --> $DIR/monomorphize-shuffle-index.rs:29:45 + | +LL | return simd_shuffle_generic::<_, _, { &Self::I }>(a, b); + | ^^--------^^ + | | + | pointer casts are not allowed in generic constants + | + = help: consider moving this anonymous constant into a `const` function + +error: aborting due to previous error + diff --git a/tests/ui/simd/monomorphize-shuffle-index.rs b/tests/ui/simd/monomorphize-shuffle-index.rs index 2467baa08b0..db7953f06dd 100644 --- a/tests/ui/simd/monomorphize-shuffle-index.rs +++ b/tests/ui/simd/monomorphize-shuffle-index.rs @@ -1,8 +1,14 @@ -//run-pass -#![feature(repr_simd, platform_intrinsics)] +//[old]run-pass +//[generic_with_fn]run-pass +// revisions: old generic generic_with_fn +#![feature(repr_simd, platform_intrinsics, adt_const_params, generic_const_exprs)] +#![allow(incomplete_features)] extern "platform-intrinsic" { + #[cfg(old)] fn simd_shuffle<T, I, U>(a: T, b: T, i: I) -> U; + #[cfg(any(generic, generic_with_fn))] + fn simd_shuffle_generic<T, U, const I: &'static [u32]>(a: T, b: T) -> U; } #[derive(Copy, Clone)] @@ -11,12 +17,24 @@ struct Simd<T, const N: usize>([T; N]); trait Shuffle<const N: usize> { const I: [u32; N]; - - unsafe fn shuffle<T, const M: usize>(&self, a: Simd<T, M>, b: Simd<T, M>) -> Simd<T, N> { - simd_shuffle(a, b, Self::I) + const J: &'static [u32] = &Self::I; + + unsafe fn shuffle<T, const M: usize>(&self, a: Simd<T, M>, b: Simd<T, M>) -> Simd<T, N> + where + Thing<{ Self::J }>:, + { + #[cfg(old)] + return simd_shuffle(a, b, Self::I); + #[cfg(generic)] + return simd_shuffle_generic::<_, _, { &Self::I }>(a, b); + //[generic]~^ overly complex generic constant + #[cfg(generic_with_fn)] + return simd_shuffle_generic::<_, _, { Self::J }>(a, b); } } +struct Thing<const X: &'static [u32]>; + fn main() { struct I1; impl Shuffle<4> for I1 { diff --git a/tests/ui/structs-enums/rec-align-u32.rs b/tests/ui/structs-enums/rec-align-u32.rs index ee704198d19..b3c323d2a29 100644 --- a/tests/ui/structs-enums/rec-align-u32.rs +++ b/tests/ui/structs-enums/rec-align-u32.rs @@ -3,7 +3,7 @@ #![allow(unused_unsafe)] // Issue #2303 -#![feature(intrinsics)] +#![feature(intrinsics, rustc_attrs)] use std::mem; diff --git a/tests/ui/structs-enums/rec-align-u64.rs b/tests/ui/structs-enums/rec-align-u64.rs index c3b201fb1c6..de008bcc01d 100644 --- a/tests/ui/structs-enums/rec-align-u64.rs +++ b/tests/ui/structs-enums/rec-align-u64.rs @@ -5,7 +5,7 @@ // Issue #2303 -#![feature(intrinsics)] +#![feature(intrinsics, rustc_attrs)] use std::mem; diff --git a/tests/ui/suggestions/assoc-type-in-method-return.stderr b/tests/ui/suggestions/assoc-type-in-method-return.stderr index 202e4a16ead..df3828ad411 100644 --- a/tests/ui/suggestions/assoc-type-in-method-return.stderr +++ b/tests/ui/suggestions/assoc-type-in-method-return.stderr @@ -2,7 +2,12 @@ error[E0412]: cannot find type `Bla` in this scope --> $DIR/assoc-type-in-method-return.rs:3:25 | LL | fn to_bla(&self) -> Bla; - | ^^^ help: you might have meant to use the associated type: `Self::Bla` + | ^^^ + | +help: you might have meant to use the associated type + | +LL | fn to_bla(&self) -> Self::Bla; + | ++++++ error: aborting due to previous error diff --git a/tests/ui/suggestions/auxiliary/extern-issue-98562.rs b/tests/ui/suggestions/auxiliary/extern-issue-98562.rs new file mode 100644 index 00000000000..948e40549c6 --- /dev/null +++ b/tests/ui/suggestions/auxiliary/extern-issue-98562.rs @@ -0,0 +1,26 @@ +pub trait TraitE { + type I3; +} + +pub trait TraitD { + type I3; +} + +pub trait TraitC { + type I1; + type I2; +} + +pub trait TraitB { + type Item; +} + +pub trait TraitA<G1, G2, G3> { + fn baz< + U: TraitC<I1 = G1, I2 = G2> + TraitD<I3 = G3> + TraitE, + V: TraitD<I3 = G1> + >(_: U, _: V) -> Self + where + U: TraitB, + <U as TraitB>::Item: Copy; +} diff --git a/tests/ui/suggestions/issue-98562.rs b/tests/ui/suggestions/issue-98562.rs new file mode 100644 index 00000000000..de04050d593 --- /dev/null +++ b/tests/ui/suggestions/issue-98562.rs @@ -0,0 +1,12 @@ +// aux-build:extern-issue-98562.rs + +extern crate extern_issue_98562; +use extern_issue_98562::TraitA; + +struct X; +impl TraitA<u8, u16, u32> for X { + //~^ ERROR not all trait items implemented +} +//~^ HELP implement the missing item: `fn baz<U: TraitC<I1 = u8, I2 = u16> + TraitD<I3 = u32>, V: TraitD<I3 = u8>>(_: U, _: V) -> Self where U: TraitE, U: TraitB, <U as TraitB>::Item: Copy { todo!() }` + +fn main() {} diff --git a/tests/ui/suggestions/issue-98562.stderr b/tests/ui/suggestions/issue-98562.stderr new file mode 100644 index 00000000000..7897fa441a2 --- /dev/null +++ b/tests/ui/suggestions/issue-98562.stderr @@ -0,0 +1,11 @@ +error[E0046]: not all trait items implemented, missing: `baz` + --> $DIR/issue-98562.rs:7:1 + | +LL | impl TraitA<u8, u16, u32> for X { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `baz` in implementation + | + = help: implement the missing item: `fn baz<U: TraitC<I1 = u8, I2 = u16> + TraitD<I3 = u32>, V: TraitD<I3 = u8>>(_: U, _: V) -> Self where U: TraitE, U: TraitB, <U as TraitB>::Item: Copy { todo!() }` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0046`. diff --git a/tests/ui/suggestions/missing-assoc-fn.stderr b/tests/ui/suggestions/missing-assoc-fn.stderr index 77fa9562878..84cb6e98553 100644 --- a/tests/ui/suggestions/missing-assoc-fn.stderr +++ b/tests/ui/suggestions/missing-assoc-fn.stderr @@ -28,7 +28,7 @@ error[E0046]: not all trait items implemented, missing: `from_iter` LL | impl FromIterator<()> for X { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `from_iter` in implementation | - = help: implement the missing item: `fn from_iter<T>(_: T) -> Self where T: IntoIterator, std::iter::IntoIterator::Item = () { todo!() }` + = help: implement the missing item: `fn from_iter<T: IntoIterator<Item = ()>>(_: T) -> Self { todo!() }` error: aborting due to 3 previous errors diff --git a/tests/ui/traits/new-solver/cycles/fixpoint-rerun-all-cycle-heads.rs b/tests/ui/traits/new-solver/cycles/fixpoint-rerun-all-cycle-heads.rs new file mode 100644 index 00000000000..27906392340 --- /dev/null +++ b/tests/ui/traits/new-solver/cycles/fixpoint-rerun-all-cycle-heads.rs @@ -0,0 +1,53 @@ +// compile-flags: -Ztrait-solver=next +#![feature(rustc_attrs)] + +// Check that we correctly rerun the trait solver for heads of cycles, +// even if they are not the root. + +struct A<T: ?Sized>(*const T); +struct B<T: ?Sized>(*const T); +struct C<T: ?Sized>(*const T); + +#[rustc_coinductive] +trait Trait<'a, 'b> {} +trait NotImplemented {} + +impl<'a, 'b, T: ?Sized> Trait<'a, 'b> for A<T> where B<T>: Trait<'a, 'b> {} + +// With this the root of `B<T>` is `A<T>`, even if the other impl does +// not have a cycle with `A<T>`. This candidate never applies because of +// the `A<T>: NotImplemented` bound. +impl<'a, 'b, T: ?Sized> Trait<'a, 'b> for B<T> +where + A<T>: Trait<'a, 'b>, + A<T>: NotImplemented, +{ +} + +// This impl directly requires 'b to be equal to 'static. +// +// Because of the coinductive cycle through `C<T>` it also requires +// 'a to be 'static. +impl<'a, T: ?Sized> Trait<'a, 'static> for B<T> +where + C<T>: Trait<'a, 'a>, +{} + +// In the first iteration of `B<T>: Trait<'a, 'b>` we don't add any +// constraints here, only after setting the provisional result to require +// `'b == 'static` do we also add that constraint for `'a`. +impl<'a, 'b, T: ?Sized> Trait<'a, 'b> for C<T> +where + B<T>: Trait<'a, 'b>, +{} + +fn impls_trait<'a, 'b, T: Trait<'a, 'b> + ?Sized>() {} + +fn check<'a, T: ?Sized>() { + impls_trait::<'a, 'static, A<T>>(); + //~^ ERROR lifetime may not live long enough +} + +fn main() { + check::<()>(); +} diff --git a/tests/ui/traits/new-solver/cycles/fixpoint-rerun-all-cycle-heads.stderr b/tests/ui/traits/new-solver/cycles/fixpoint-rerun-all-cycle-heads.stderr new file mode 100644 index 00000000000..4cbd0898148 --- /dev/null +++ b/tests/ui/traits/new-solver/cycles/fixpoint-rerun-all-cycle-heads.stderr @@ -0,0 +1,10 @@ +error: lifetime may not live long enough + --> $DIR/fixpoint-rerun-all-cycle-heads.rs:47:5 + | +LL | fn check<'a, T: ?Sized>() { + | -- lifetime `'a` defined here +LL | impls_trait::<'a, 'static, A<T>>(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` + +error: aborting due to previous error + diff --git a/tests/ui/traits/new-solver/cycles/inductive-not-on-stack.rs b/tests/ui/traits/new-solver/cycles/inductive-not-on-stack.rs index 3cfe7ab87f6..f06b98a79cf 100644 --- a/tests/ui/traits/new-solver/cycles/inductive-not-on-stack.rs +++ b/tests/ui/traits/new-solver/cycles/inductive-not-on-stack.rs @@ -39,7 +39,7 @@ fn impls_ar<T: AR>() {} fn main() { impls_a::<()>(); - // FIXME(-Ztrait-solver=next): This is broken and should error. + //~^ ERROR overflow evaluating the requirement `(): A` impls_ar::<()>(); //~^ ERROR overflow evaluating the requirement `(): AR` diff --git a/tests/ui/traits/new-solver/cycles/inductive-not-on-stack.stderr b/tests/ui/traits/new-solver/cycles/inductive-not-on-stack.stderr index 34115334063..859b3f3f1c7 100644 --- a/tests/ui/traits/new-solver/cycles/inductive-not-on-stack.stderr +++ b/tests/ui/traits/new-solver/cycles/inductive-not-on-stack.stderr @@ -1,3 +1,16 @@ +error[E0275]: overflow evaluating the requirement `(): A` + --> $DIR/inductive-not-on-stack.rs:41:15 + | +LL | impls_a::<()>(); + | ^^ + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`inductive_not_on_stack`) +note: required by a bound in `impls_a` + --> $DIR/inductive-not-on-stack.rs:25:15 + | +LL | fn impls_a<T: A>() {} + | ^ required by this bound in `impls_a` + error[E0275]: overflow evaluating the requirement `(): AR` --> $DIR/inductive-not-on-stack.rs:44:16 | @@ -11,6 +24,6 @@ note: required by a bound in `impls_ar` LL | fn impls_ar<T: AR>() {} | ^^ required by this bound in `impls_ar` -error: aborting due to previous error +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/type-alias-impl-trait/cross_inference_pattern_bug.rs b/tests/ui/type-alias-impl-trait/cross_inference_pattern_bug.rs index 9a50c0f988a..31fea42fa5d 100644 --- a/tests/ui/type-alias-impl-trait/cross_inference_pattern_bug.rs +++ b/tests/ui/type-alias-impl-trait/cross_inference_pattern_bug.rs @@ -1,5 +1,5 @@ // compile-flags: --edition=2021 -// check-pass +// build-pass #![feature(type_alias_impl_trait)] fn main() { diff --git a/tests/ui/type-alias-impl-trait/destructure_tait-ice-113594.rs b/tests/ui/type-alias-impl-trait/destructure_tait-ice-113594.rs new file mode 100644 index 00000000000..7c2d68cceb8 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/destructure_tait-ice-113594.rs @@ -0,0 +1,19 @@ +// build-pass +// edition: 2021 + +#![feature(type_alias_impl_trait)] + +pub struct Foo { + /// This type must have nontrivial drop glue + field: String, +} + +pub type Tait = impl Sized; + +pub async fn ice_cold(beverage: Tait) { + // Must destructure at least one field of `Foo` + let Foo { field } = beverage; + _ = field; +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/destructure_tait-layout_of-ice-113594.rs b/tests/ui/type-alias-impl-trait/destructure_tait-layout_of-ice-113594.rs new file mode 100644 index 00000000000..8568b26bea2 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/destructure_tait-layout_of-ice-113594.rs @@ -0,0 +1,23 @@ +// build-pass +// edition: 2021 + +#![feature(type_alias_impl_trait)] + +fn foo<T>(x: T) { + type Opaque<T> = impl Sized; + let foo: Opaque<T> = (x,); + let (a,): (T,) = foo; +} + +const fn bar<T: Copy>(x: T) { + type Opaque<T: Copy> = impl Copy; + let foo: Opaque<T> = (x, 2u32); + let (a, b): (T, u32) = foo; +} + +fn main() { + foo::<u32>(1); + bar::<u32>(1); + const CONST: () = bar::<u32>(42u32); + CONST +} diff --git a/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.stderr b/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.stderr index 3312230bc81..2063becdb08 100644 --- a/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.stderr +++ b/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.stderr @@ -1,6 +1,5 @@ error[E0391]: cycle detected when computing layout of `{async block@$DIR/indirect-recursion-issue-112047.rs:23:9: 23:42}` | - = note: ...which requires computing layout of `core::mem::maybe_uninit::MaybeUninit<recur::{opaque#0}>`... = note: ...which requires computing layout of `core::mem::maybe_uninit::MaybeUninit<{async fn body@$DIR/indirect-recursion-issue-112047.rs:15:31: 17:2}>`... = note: ...which requires computing layout of `core::mem::manually_drop::ManuallyDrop<{async fn body@$DIR/indirect-recursion-issue-112047.rs:15:31: 17:2}>`... = note: ...which requires computing layout of `{async fn body@$DIR/indirect-recursion-issue-112047.rs:15:31: 17:2}`... @@ -8,7 +7,11 @@ error[E0391]: cycle detected when computing layout of `{async block@$DIR/indirec = note: ...which requires computing layout of `core::mem::maybe_uninit::MaybeUninit<{async block@$DIR/indirect-recursion-issue-112047.rs:23:9: 23:42}>`... = note: ...which requires computing layout of `core::mem::manually_drop::ManuallyDrop<{async block@$DIR/indirect-recursion-issue-112047.rs:23:9: 23:42}>`... = note: ...which again requires computing layout of `{async block@$DIR/indirect-recursion-issue-112047.rs:23:9: 23:42}`, completing the cycle - = note: cycle used when computing layout of `<impl at $DIR/indirect-recursion-issue-112047.rs:19:1: 19:18>::Recur` +note: cycle used when elaborating drops for `<impl at $DIR/indirect-recursion-issue-112047.rs:19:1: 19:18>::recur` + --> $DIR/indirect-recursion-issue-112047.rs:22:5 + | +LL | fn recur(self) -> Self::Recur { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to previous error diff --git a/tests/ui/type/type-error-break-tail.stderr b/tests/ui/type/type-error-break-tail.stderr index 16dc6475c6f..9a02bc28752 100644 --- a/tests/ui/type/type-error-break-tail.stderr +++ b/tests/ui/type/type-error-break-tail.stderr @@ -2,13 +2,16 @@ error[E0308]: mismatched types --> $DIR/type-error-break-tail.rs:3:20 | LL | fn loop_ending() -> i32 { - | --- expected `i32` because of return type + | --- expected `i32` because of this return type LL | loop { + | ---- this loop is expected to be of type `i32` LL | if false { break; } - | ^^^^^ - | | - | expected `i32`, found `()` - | help: give it a value of the expected type: `break 42` + | ^^^^^ expected `i32`, found `()` + | +help: give it a value of the expected type + | +LL | if false { break 42; } + | ++ error: aborting due to previous error |
