diff options
Diffstat (limited to 'tests')
200 files changed, 3449 insertions, 1972 deletions
diff --git a/tests/codegen/box-maybe-uninit-llvm14.rs b/tests/codegen/box-maybe-uninit-llvm14.rs index b0c88f76c43..c9f88fb3fe4 100644 --- a/tests/codegen/box-maybe-uninit-llvm14.rs +++ b/tests/codegen/box-maybe-uninit-llvm14.rs @@ -31,4 +31,4 @@ pub fn box_uninitialized2() -> Box<MaybeUninit<[usize; 1024 * 1024]>> { // Hide the LLVM 15+ `allocalign` attribute in the declaration of __rust_alloc // from the CHECK-NOT above. We don't check the attributes here because we can't rely // on all of them being set until LLVM 15. -// CHECK: declare noalias{{.*}} @__rust_alloc(i{{[0-9]+}} noundef, i{{[0-9]+.*}} noundef) +// CHECK: declare {{(dso_local )?}}noalias{{.*}} @__rust_alloc(i{{[0-9]+}} noundef, i{{[0-9]+.*}} noundef) diff --git a/tests/codegen/box-maybe-uninit.rs b/tests/codegen/box-maybe-uninit.rs index 2f88966996a..5c08b5832ad 100644 --- a/tests/codegen/box-maybe-uninit.rs +++ b/tests/codegen/box-maybe-uninit.rs @@ -28,6 +28,6 @@ pub fn box_uninitialized2() -> Box<MaybeUninit<[usize; 1024 * 1024]>> { // Hide the `allocalign` attribute in the declaration of __rust_alloc // from the CHECK-NOT above, and also verify the attributes got set reasonably. -// CHECK: declare noalias noundef ptr @__rust_alloc(i{{[0-9]+}} noundef, i{{[0-9]+}} allocalign noundef) unnamed_addr [[RUST_ALLOC_ATTRS:#[0-9]+]] +// CHECK: declare {{(dso_local )?}}noalias noundef ptr @__rust_alloc(i{{[0-9]+}} noundef, i{{[0-9]+}} allocalign noundef) unnamed_addr [[RUST_ALLOC_ATTRS:#[0-9]+]] -// CHECK-DAG: attributes [[RUST_ALLOC_ATTRS]] = { {{.*}} allockind("alloc,uninitialized,aligned") allocsize(0) uwtable "alloc-family"="__rust_alloc" {{.*}} } +// CHECK-DAG: attributes [[RUST_ALLOC_ATTRS]] = { {{.*}} allockind("alloc,uninitialized,aligned") allocsize(0) {{(uwtable )?}}"alloc-family"="__rust_alloc" {{.*}} } diff --git a/tests/codegen/call-metadata.rs b/tests/codegen/call-metadata.rs index 1c30c08d3b2..07cc0c96371 100644 --- a/tests/codegen/call-metadata.rs +++ b/tests/codegen/call-metadata.rs @@ -6,7 +6,7 @@ #![crate_type = "lib"] pub fn test() { - // CHECK: call noundef i8 @some_true(), !range [[R0:![0-9]+]] + // CHECK: call noundef i8 @some_true(){{( #[0-9]+)?}}, !range [[R0:![0-9]+]] // CHECK: [[R0]] = !{i8 0, i8 3} some_true(); } diff --git a/tests/codegen/debug-column.rs b/tests/codegen/debug-column.rs index e61642b8e1b..f3b19a2eb2f 100644 --- a/tests/codegen/debug-column.rs +++ b/tests/codegen/debug-column.rs @@ -6,11 +6,11 @@ fn main() { unsafe { // Column numbers are 1-based. Regression test for #65437. - // CHECK: call void @giraffe(), !dbg [[A:!.*]] + // CHECK: call void @giraffe(){{( #[0-9]+)?}}, !dbg [[A:!.*]] giraffe(); // Column numbers use byte offests. Regression test for #67360 - // CHECK: call void @turtle(), !dbg [[B:!.*]] + // CHECK: call void @turtle(){{( #[0-9]+)?}}, !dbg [[B:!.*]] /* ż */ turtle(); // CHECK: [[A]] = !DILocation(line: 10, column: 9, diff --git a/tests/codegen/drop.rs b/tests/codegen/drop.rs index 99402827158..3615ef47b53 100644 --- a/tests/codegen/drop.rs +++ b/tests/codegen/drop.rs @@ -1,4 +1,5 @@ // ignore-wasm32-bare compiled with panic=abort by default +// needs-unwind - this test verifies the amount of drop calls when unwinding is used // compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] diff --git a/tests/codegen/external-no-mangle-statics.rs b/tests/codegen/external-no-mangle-statics.rs index c6ecb7aa96a..48023a2a901 100644 --- a/tests/codegen/external-no-mangle-statics.rs +++ b/tests/codegen/external-no-mangle-statics.rs @@ -6,72 +6,72 @@ // `#[no_mangle]`d static variables always have external linkage, i.e., no `internal` in their // definitions -// CHECK: @A = local_unnamed_addr constant +// CHECK: @A = {{(dso_local )?}}local_unnamed_addr constant #[no_mangle] static A: u8 = 0; -// CHECK: @B = local_unnamed_addr global +// CHECK: @B = {{(dso_local )?}}local_unnamed_addr global #[no_mangle] static mut B: u8 = 0; -// CHECK: @C = local_unnamed_addr constant +// CHECK: @C = {{(dso_local )?}}local_unnamed_addr constant #[no_mangle] pub static C: u8 = 0; -// CHECK: @D = local_unnamed_addr global +// CHECK: @D = {{(dso_local )?}}local_unnamed_addr global #[no_mangle] pub static mut D: u8 = 0; mod private { - // CHECK: @E = local_unnamed_addr constant + // CHECK: @E = {{(dso_local )?}}local_unnamed_addr constant #[no_mangle] static E: u8 = 0; - // CHECK: @F = local_unnamed_addr global + // CHECK: @F = {{(dso_local )?}}local_unnamed_addr global #[no_mangle] static mut F: u8 = 0; - // CHECK: @G = local_unnamed_addr constant + // CHECK: @G = {{(dso_local )?}}local_unnamed_addr constant #[no_mangle] pub static G: u8 = 0; - // CHECK: @H = local_unnamed_addr global + // CHECK: @H = {{(dso_local )?}}local_unnamed_addr global #[no_mangle] pub static mut H: u8 = 0; } const HIDDEN: () = { - // CHECK: @I = local_unnamed_addr constant + // CHECK: @I = {{(dso_local )?}}local_unnamed_addr constant #[no_mangle] static I: u8 = 0; - // CHECK: @J = local_unnamed_addr global + // CHECK: @J = {{(dso_local )?}}local_unnamed_addr global #[no_mangle] static mut J: u8 = 0; - // CHECK: @K = local_unnamed_addr constant + // CHECK: @K = {{(dso_local )?}}local_unnamed_addr constant #[no_mangle] pub static K: u8 = 0; - // CHECK: @L = local_unnamed_addr global + // CHECK: @L = {{(dso_local )?}}local_unnamed_addr global #[no_mangle] pub static mut L: u8 = 0; }; fn x() { - // CHECK: @M = local_unnamed_addr constant + // CHECK: @M = {{(dso_local )?}}local_unnamed_addr constant #[no_mangle] static M: fn() = x; - // CHECK: @N = local_unnamed_addr global + // CHECK: @N = {{(dso_local )?}}local_unnamed_addr global #[no_mangle] static mut N: u8 = 0; - // CHECK: @O = local_unnamed_addr constant + // CHECK: @O = {{(dso_local )?}}local_unnamed_addr constant #[no_mangle] pub static O: u8 = 0; - // CHECK: @P = local_unnamed_addr global + // CHECK: @P = {{(dso_local )?}}local_unnamed_addr global #[no_mangle] pub static mut P: u8 = 0; } diff --git a/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs b/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs index 2ee4d7cca0e..6e0eacfe400 100644 --- a/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs +++ b/tests/codegen/issues/issue-105386-ub-in-debuginfo.rs @@ -1,4 +1,5 @@ -// compile-flags: --crate-type=lib -O -Cdebuginfo=2 -Cno-prepopulate-passes +// compile-flags: --crate-type=lib -O -Cdebuginfo=2 -Cno-prepopulate-passes -Zmir-enable-passes=-ScalarReplacementOfAggregates +// MIR SROA will decompose the closure // min-llvm-version: 15.0 # this test uses opaque pointer notation #![feature(stmt_expr_attributes)] @@ -15,8 +16,8 @@ pub fn outer_function(x: S, y: S) -> usize { // Check that we do not attempt to load from the spilled arg before it is assigned to // when generating debuginfo. // CHECK-LABEL: @outer_function -// CHECK: [[spill:%.*]] = alloca %"[closure@{{.*.rs}}:9:23: 9:25]" -// CHECK-NOT: [[ptr_tmp:%.*]] = getelementptr inbounds %"[closure@{{.*.rs}}:9:23: 9:25]", ptr [[spill]] +// CHECK: [[spill:%.*]] = alloca %"[closure@{{.*.rs}}:10:23: 10:25]" +// CHECK-NOT: [[ptr_tmp:%.*]] = getelementptr inbounds %"[closure@{{.*.rs}}:10:23: 10:25]", ptr [[spill]] // CHECK-NOT: [[load:%.*]] = load ptr, ptr // CHECK: call void @llvm.lifetime.start{{.*}}({{.*}}, ptr [[spill]]) // CHECK: [[inner:%.*]] = getelementptr inbounds %"{{.*}}", ptr [[spill]] diff --git a/tests/codegen/issues/issue-86106.rs b/tests/codegen/issues/issue-86106.rs index c0be7fab2f3..be5034dcfbd 100644 --- a/tests/codegen/issues/issue-86106.rs +++ b/tests/codegen/issues/issue-86106.rs @@ -7,7 +7,7 @@ #![crate_type = "lib"] -// CHECK-LABEL: define void @string_new +// CHECK-LABEL: define {{(dso_local )?}}void @string_new #[no_mangle] pub fn string_new() -> String { // CHECK: store ptr inttoptr @@ -17,7 +17,7 @@ pub fn string_new() -> String { String::new() } -// CHECK-LABEL: define void @empty_to_string +// CHECK-LABEL: define {{(dso_local )?}}void @empty_to_string #[no_mangle] pub fn empty_to_string() -> String { // CHECK: store ptr inttoptr diff --git a/tests/codegen/link_section.rs b/tests/codegen/link_section.rs index 88b8692b0ac..2b26b604ad3 100644 --- a/tests/codegen/link_section.rs +++ b/tests/codegen/link_section.rs @@ -3,7 +3,7 @@ #![crate_type = "lib"] -// CHECK: @VAR1 = constant <{ [4 x i8] }> <{ [4 x i8] c"\01\00\00\00" }>, section ".test_one" +// CHECK: @VAR1 = {{(dso_local )?}}constant <{ [4 x i8] }> <{ [4 x i8] c"\01\00\00\00" }>, section ".test_one" #[no_mangle] #[link_section = ".test_one"] #[cfg(target_endian = "little")] @@ -19,17 +19,17 @@ pub enum E { B(f32) } -// CHECK: @VAR2 = constant {{.*}}, section ".test_two" +// CHECK: @VAR2 = {{(dso_local )?}}constant {{.*}}, section ".test_two" #[no_mangle] #[link_section = ".test_two"] pub static VAR2: E = E::A(666); -// CHECK: @VAR3 = constant {{.*}}, section ".test_three" +// CHECK: @VAR3 = {{(dso_local )?}}constant {{.*}}, section ".test_three" #[no_mangle] #[link_section = ".test_three"] pub static VAR3: E = E::B(1.); -// CHECK: define void @fn1() {{.*}} section ".test_four" { +// CHECK: define {{(dso_local )?}}void @fn1() {{.*}} section ".test_four" { #[no_mangle] #[link_section = ".test_four"] pub fn fn1() {} diff --git a/tests/codegen/mir-inlined-line-numbers.rs b/tests/codegen/mir-inlined-line-numbers.rs index 19d83f0eee7..d13527b9521 100644 --- a/tests/codegen/mir-inlined-line-numbers.rs +++ b/tests/codegen/mir-inlined-line-numbers.rs @@ -19,7 +19,7 @@ pub fn example() { } // CHECK-LABEL: @example -// CHECK: tail call void @bar(), !dbg [[DBG_ID:![0-9]+]] +// CHECK: tail call void @bar(){{( #[0-9]+)?}}, !dbg [[DBG_ID:![0-9]+]] // CHECK: [[DBG_ID]] = !DILocation(line: 7, // CHECK-SAME: inlinedAt: [[INLINE_ID:![0-9]+]]) // CHECK: [[INLINE_ID]] = !DILocation(line: 18, diff --git a/tests/codegen/naked-noinline.rs b/tests/codegen/naked-noinline.rs index c0ac69f4ed7..5cfb500c0ef 100644 --- a/tests/codegen/naked-noinline.rs +++ b/tests/codegen/naked-noinline.rs @@ -12,7 +12,7 @@ use std::arch::asm; pub unsafe extern "C" fn f() { // Check that f has naked and noinline attributes. // - // CHECK: define void @f() unnamed_addr [[ATTR:#[0-9]+]] + // CHECK: define {{(dso_local )?}}void @f() unnamed_addr [[ATTR:#[0-9]+]] // CHECK-NEXT: start: // CHECK-NEXT: call void asm asm!("", options(noreturn)); @@ -22,7 +22,7 @@ pub unsafe extern "C" fn f() { pub unsafe fn g() { // Check that call to f is not inlined. // - // CHECK-LABEL: define void @g() + // CHECK-LABEL: define {{(dso_local )?}}void @g() // CHECK-NEXT: start: // CHECK-NEXT: call void @f() f(); diff --git a/tests/codegen/personality_lifetimes.rs b/tests/codegen/personality_lifetimes.rs index 2104022f578..9ff7a9b3e88 100644 --- a/tests/codegen/personality_lifetimes.rs +++ b/tests/codegen/personality_lifetimes.rs @@ -1,5 +1,6 @@ // ignore-msvc // ignore-wasm32-bare compiled with panic=abort by default +// needs-unwind // compile-flags: -O -C no-prepopulate-passes diff --git a/tests/codegen/ptr-read-metadata.rs b/tests/codegen/ptr-read-metadata.rs index e1e3272662c..73d1db6df27 100644 --- a/tests/codegen/ptr-read-metadata.rs +++ b/tests/codegen/ptr-read-metadata.rs @@ -9,7 +9,7 @@ use std::mem::MaybeUninit; -// CHECK-LABEL: define noundef i8 @copy_byte( +// CHECK-LABEL: define {{(dso_local )?}}noundef i8 @copy_byte( #[no_mangle] pub unsafe fn copy_byte(p: *const u8) -> u8 { // CHECK-NOT: load @@ -19,7 +19,7 @@ pub unsafe fn copy_byte(p: *const u8) -> u8 { *p } -// CHECK-LABEL: define noundef i8 @read_byte( +// CHECK-LABEL: define {{(dso_local )?}}noundef i8 @read_byte( #[no_mangle] pub unsafe fn read_byte(p: *const u8) -> u8 { // CHECK-NOT: load @@ -29,7 +29,7 @@ pub unsafe fn read_byte(p: *const u8) -> u8 { p.read() } -// CHECK-LABEL: define i8 @read_byte_maybe_uninit( +// CHECK-LABEL: define {{(dso_local )?}}i8 @read_byte_maybe_uninit( #[no_mangle] pub unsafe fn read_byte_maybe_uninit(p: *const MaybeUninit<u8>) -> MaybeUninit<u8> { // CHECK-NOT: load @@ -39,7 +39,7 @@ pub unsafe fn read_byte_maybe_uninit(p: *const MaybeUninit<u8>) -> MaybeUninit<u p.read() } -// CHECK-LABEL: define noundef i8 @read_byte_assume_init( +// CHECK-LABEL: define {{(dso_local )?}}noundef i8 @read_byte_assume_init( #[no_mangle] pub unsafe fn read_byte_assume_init(p: &MaybeUninit<u8>) -> u8 { // CHECK-NOT: load @@ -49,7 +49,7 @@ pub unsafe fn read_byte_assume_init(p: &MaybeUninit<u8>) -> u8 { p.assume_init_read() } -// CHECK-LABEL: define noundef i32 @copy_char( +// CHECK-LABEL: define {{(dso_local )?}}noundef i32 @copy_char( #[no_mangle] pub unsafe fn copy_char(p: *const char) -> char { // CHECK-NOT: load @@ -60,7 +60,7 @@ pub unsafe fn copy_char(p: *const char) -> char { *p } -// CHECK-LABEL: define noundef i32 @read_char( +// CHECK-LABEL: define {{(dso_local )?}}noundef i32 @read_char( #[no_mangle] pub unsafe fn read_char(p: *const char) -> char { // CHECK-NOT: load @@ -71,7 +71,7 @@ pub unsafe fn read_char(p: *const char) -> char { p.read() } -// CHECK-LABEL: define i32 @read_char_maybe_uninit( +// CHECK-LABEL: define {{(dso_local )?}}i32 @read_char_maybe_uninit( #[no_mangle] pub unsafe fn read_char_maybe_uninit(p: *const MaybeUninit<char>) -> MaybeUninit<char> { // CHECK-NOT: load @@ -82,7 +82,7 @@ pub unsafe fn read_char_maybe_uninit(p: *const MaybeUninit<char>) -> MaybeUninit p.read() } -// CHECK-LABEL: define noundef i32 @read_char_assume_init( +// CHECK-LABEL: define {{(dso_local )?}}noundef i32 @read_char_assume_init( #[no_mangle] pub unsafe fn read_char_assume_init(p: &MaybeUninit<char>) -> char { // CHECK-NOT: load diff --git a/tests/codegen/sanitizer-cfi-emit-type-metadata-id-itanium-cxx-abi.rs b/tests/codegen/sanitizer-cfi-emit-type-metadata-id-itanium-cxx-abi.rs index ebb26cd35c0..472d921ace0 100644 --- a/tests/codegen/sanitizer-cfi-emit-type-metadata-id-itanium-cxx-abi.rs +++ b/tests/codegen/sanitizer-cfi-emit-type-metadata-id-itanium-cxx-abi.rs @@ -587,6 +587,6 @@ pub fn foo149(_: Type14<Bar>, _: Type14<Bar>, _: Type14<Bar>) { } // CHECK: ![[TYPE144]] = !{i64 0, !"_ZTSFvu3refIvEE"} // CHECK: ![[TYPE145]] = !{i64 0, !"_ZTSFvu3refIvES_E"} // CHECK: ![[TYPE146]] = !{i64 0, !"_ZTSFvu3refIvES_S_E"} -// CHECK: ![[TYPE147]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3BarE -// CHECK: ![[TYPE148]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3BarS_E -// CHECK: ![[TYPE149]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3BarS_S_E +// CHECK: ![[TYPE147]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3BarE"} +// CHECK: ![[TYPE148]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3BarS_E"} +// CHECK: ![[TYPE149]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtC{{[[:print:]]+}}_51sanitizer_cfi_emit_type_metadata_id_itanium_cxx_abi3BarS_S_E"} diff --git a/tests/codegen/tuple-layout-opt.rs b/tests/codegen/tuple-layout-opt.rs index 35f76085145..309fe1d5ec9 100644 --- a/tests/codegen/tuple-layout-opt.rs +++ b/tests/codegen/tuple-layout-opt.rs @@ -6,31 +6,31 @@ #![crate_type="lib"] type ScalarZstLast = (u128, ()); -// CHECK: define i128 @test_ScalarZstLast(i128 %_1) +// CHECK: define {{(dso_local )?}}i128 @test_ScalarZstLast(i128 %_1) #[no_mangle] pub fn test_ScalarZstLast(_: ScalarZstLast) -> ScalarZstLast { loop {} } type ScalarZstFirst = ((), u128); -// CHECK: define i128 @test_ScalarZstFirst(i128 %_1) +// CHECK: define {{(dso_local )?}}i128 @test_ScalarZstFirst(i128 %_1) #[no_mangle] pub fn test_ScalarZstFirst(_: ScalarZstFirst) -> ScalarZstFirst { loop {} } type ScalarPairZstLast = (u8, u128, ()); -// CHECK: define { i128, i8 } @test_ScalarPairZstLast(i128 %_1.0, i8 %_1.1) +// CHECK: define {{(dso_local )?}}{ i128, i8 } @test_ScalarPairZstLast(i128 %_1.0, i8 %_1.1) #[no_mangle] pub fn test_ScalarPairZstLast(_: ScalarPairZstLast) -> ScalarPairZstLast { loop {} } type ScalarPairZstFirst = ((), u8, u128); -// CHECK: define { i8, i128 } @test_ScalarPairZstFirst(i8 %_1.0, i128 %_1.1) +// CHECK: define {{(dso_local )?}}{ i8, i128 } @test_ScalarPairZstFirst(i8 %_1.0, i128 %_1.1) #[no_mangle] pub fn test_ScalarPairZstFirst(_: ScalarPairZstFirst) -> ScalarPairZstFirst { loop {} } type ScalarPairLotsOfZsts = ((), u8, (), u128, ()); -// CHECK: define { i128, i8 } @test_ScalarPairLotsOfZsts(i128 %_1.0, i8 %_1.1) +// CHECK: define {{(dso_local )?}}{ i128, i8 } @test_ScalarPairLotsOfZsts(i128 %_1.0, i8 %_1.1) #[no_mangle] pub fn test_ScalarPairLotsOfZsts(_: ScalarPairLotsOfZsts) -> ScalarPairLotsOfZsts { loop {} } type ScalarPairLottaNesting = (((), ((), u8, (), u128, ())), ()); -// CHECK: define { i128, i8 } @test_ScalarPairLottaNesting(i128 %_1.0, i8 %_1.1) +// CHECK: define {{(dso_local )?}}{ i128, i8 } @test_ScalarPairLottaNesting(i128 %_1.0, i8 %_1.1) #[no_mangle] pub fn test_ScalarPairLottaNesting(_: ScalarPairLottaNesting) -> ScalarPairLottaNesting { loop {} } diff --git a/tests/codegen/union-abi.rs b/tests/codegen/union-abi.rs index c18f2a49fc3..8481ca8ccfa 100644 --- a/tests/codegen/union-abi.rs +++ b/tests/codegen/union-abi.rs @@ -17,60 +17,60 @@ pub struct i64x4(i64, i64, i64, i64); #[derive(Copy, Clone)] pub union UnionI64x4{ a:(), b: i64x4 } -// CHECK: define void @test_UnionI64x4({{<4 x i64>\*|ptr}} {{.*}} %_1) +// CHECK: define {{(dso_local )?}}void @test_UnionI64x4({{<4 x i64>\*|ptr}} {{.*}} %_1) #[no_mangle] pub fn test_UnionI64x4(_: UnionI64x4) { loop {} } pub union UnionI64x4_{ a: i64x4, b: (), c:i64x4, d: Unhab, e: ((),()), f: UnionI64x4 } -// CHECK: define void @test_UnionI64x4_({{<4 x i64>\*|ptr}} {{.*}} %_1) +// CHECK: define {{(dso_local )?}}void @test_UnionI64x4_({{<4 x i64>\*|ptr}} {{.*}} %_1) #[no_mangle] pub fn test_UnionI64x4_(_: UnionI64x4_) { loop {} } pub union UnionI64x4I64{ a: i64x4, b: i64 } -// CHECK: define void @test_UnionI64x4I64({{%UnionI64x4I64\*|ptr}} {{.*}} %_1) +// CHECK: define {{(dso_local )?}}void @test_UnionI64x4I64({{%UnionI64x4I64\*|ptr}} {{.*}} %_1) #[no_mangle] pub fn test_UnionI64x4I64(_: UnionI64x4I64) { loop {} } pub union UnionI64x4Tuple{ a: i64x4, b: (i64, i64, i64, i64) } -// CHECK: define void @test_UnionI64x4Tuple({{%UnionI64x4Tuple\*|ptr}} {{.*}} %_1) +// CHECK: define {{(dso_local )?}}void @test_UnionI64x4Tuple({{%UnionI64x4Tuple\*|ptr}} {{.*}} %_1) #[no_mangle] pub fn test_UnionI64x4Tuple(_: UnionI64x4Tuple) { loop {} } pub union UnionF32{a:f32} -// CHECK: define float @test_UnionF32(float %_1) +// CHECK: define {{(dso_local )?}}float @test_UnionF32(float %_1) #[no_mangle] pub fn test_UnionF32(_: UnionF32) -> UnionF32 { loop {} } pub union UnionF32F32{a:f32, b:f32} -// CHECK: define float @test_UnionF32F32(float %_1) +// CHECK: define {{(dso_local )?}}float @test_UnionF32F32(float %_1) #[no_mangle] pub fn test_UnionF32F32(_: UnionF32F32) -> UnionF32F32 { loop {} } pub union UnionF32U32{a:f32, b:u32} -// CHECK: define i32 @test_UnionF32U32(i32{{( %0)?}}) +// CHECK: define {{(dso_local )?}}i32 @test_UnionF32U32(i32{{( %0)?}}) #[no_mangle] pub fn test_UnionF32U32(_: UnionF32U32) -> UnionF32U32 { loop {} } pub union UnionU128{a:u128} -// CHECK: define i128 @test_UnionU128(i128 %_1) +// CHECK: define {{(dso_local )?}}i128 @test_UnionU128(i128 %_1) #[no_mangle] pub fn test_UnionU128(_: UnionU128) -> UnionU128 { loop {} } #[repr(C)] pub union CUnionU128{a:u128} -// CHECK: define void @test_CUnionU128({{%CUnionU128\*|ptr}} {{.*}} %_1) +// CHECK: define {{(dso_local )?}}void @test_CUnionU128({{%CUnionU128\*|ptr}} {{.*}} %_1) #[no_mangle] pub fn test_CUnionU128(_: CUnionU128) { loop {} } pub union UnionBool { b:bool } -// CHECK: define noundef zeroext i1 @test_UnionBool(i8 %b) +// CHECK: define {{(dso_local )?}}noundef zeroext i1 @test_UnionBool(i8 %b) #[no_mangle] pub fn test_UnionBool(b: UnionBool) -> bool { unsafe { b.b } } // CHECK: %0 = trunc i8 %b to i1 diff --git a/tests/codegen/unwind-abis/c-unwind-abi.rs b/tests/codegen/unwind-abis/c-unwind-abi.rs index e258dbcacd2..fa5b6bad75c 100644 --- a/tests/codegen/unwind-abis/c-unwind-abi.rs +++ b/tests/codegen/unwind-abis/c-unwind-abi.rs @@ -1,4 +1,5 @@ // compile-flags: -C opt-level=0 +// needs-unwind // Test that `nounwind` attributes are correctly applied to exported `C` and `C-unwind` extern // functions. `C-unwind` functions MUST NOT have this attribute. We disable optimizations above diff --git a/tests/codegen/unwind-abis/cdecl-unwind-abi.rs b/tests/codegen/unwind-abis/cdecl-unwind-abi.rs index 19a7228839a..64746d32175 100644 --- a/tests/codegen/unwind-abis/cdecl-unwind-abi.rs +++ b/tests/codegen/unwind-abis/cdecl-unwind-abi.rs @@ -1,4 +1,5 @@ // compile-flags: -C opt-level=0 +// needs-unwind // Test that `nounwind` attributes are correctly applied to exported `cdecl` and // `cdecl-unwind` extern functions. `cdecl-unwind` functions MUST NOT have this attribute. We diff --git a/tests/codegen/unwind-abis/nounwind-on-stable-panic-unwind.rs b/tests/codegen/unwind-abis/nounwind-on-stable-panic-unwind.rs index c1c5bbdda34..dc3911cd4eb 100644 --- a/tests/codegen/unwind-abis/nounwind-on-stable-panic-unwind.rs +++ b/tests/codegen/unwind-abis/nounwind-on-stable-panic-unwind.rs @@ -1,5 +1,6 @@ // compile-flags: -C opt-level=0 // ignore-wasm32-bare compiled with panic=abort by default +// needs-unwind #![crate_type = "lib"] diff --git a/tests/codegen/unwind-abis/system-unwind-abi.rs b/tests/codegen/unwind-abis/system-unwind-abi.rs index 2591c1d4814..f274a33b099 100644 --- a/tests/codegen/unwind-abis/system-unwind-abi.rs +++ b/tests/codegen/unwind-abis/system-unwind-abi.rs @@ -1,4 +1,5 @@ // compile-flags: -C opt-level=0 +// needs-unwind // Test that `nounwind` attributes are correctly applied to exported `system` and `system-unwind` // extern functions. `system-unwind` functions MUST NOT have this attribute. We disable diff --git a/tests/codegen/unwind-extern-exports.rs b/tests/codegen/unwind-extern-exports.rs index 6ac3c079f81..4e1e719d5cd 100644 --- a/tests/codegen/unwind-extern-exports.rs +++ b/tests/codegen/unwind-extern-exports.rs @@ -1,5 +1,6 @@ // compile-flags: -C opt-level=0 // ignore-wasm32-bare compiled with panic=abort by default +// needs-unwind #![crate_type = "lib"] #![feature(c_unwind)] diff --git a/tests/codegen/unwind-extern-imports.rs b/tests/codegen/unwind-extern-imports.rs index e33e3e80521..260dcc628cc 100644 --- a/tests/codegen/unwind-extern-imports.rs +++ b/tests/codegen/unwind-extern-imports.rs @@ -1,5 +1,6 @@ // compile-flags: -C no-prepopulate-passes // ignore-wasm32-bare compiled with panic=abort by default +// needs-unwind #![crate_type = "lib"] #![feature(c_unwind)] diff --git a/tests/codegen/vec-shrink-panik.rs b/tests/codegen/vec-shrink-panik.rs index 88b7edff260..606d68ff3ab 100644 --- a/tests/codegen/vec-shrink-panik.rs +++ b/tests/codegen/vec-shrink-panik.rs @@ -5,6 +5,7 @@ // [new]min-llvm-version: 17 // compile-flags: -O // ignore-debug: the debug assertions get in the way +// needs-unwind #![crate_type = "lib"] #![feature(shrink_to)] diff --git a/tests/incremental/const-generics/hash-tyvid-regression-1.rs b/tests/incremental/const-generics/hash-tyvid-regression-1.rs index 5ff7b19d894..06d67423451 100644 --- a/tests/incremental/const-generics/hash-tyvid-regression-1.rs +++ b/tests/incremental/const-generics/hash-tyvid-regression-1.rs @@ -1,8 +1,20 @@ // revisions: cfail #![feature(generic_const_exprs, adt_const_params)] #![allow(incomplete_features)] + +use std::marker::ConstParamTy; + +#[derive(PartialEq, Eq, ConstParamTy)] +struct NonZeroUsize(usize); + +impl NonZeroUsize { + const fn get(self) -> usize { + self.0 + } +} + // regression test for #77650 -fn c<T, const N: std::num::NonZeroUsize>() +fn c<T, const N: NonZeroUsize>() where [T; N.get()]: Sized, { diff --git a/tests/incremental/const-generics/hash-tyvid-regression-2.rs b/tests/incremental/const-generics/hash-tyvid-regression-2.rs index 5cdd43cd782..33f226ff611 100644 --- a/tests/incremental/const-generics/hash-tyvid-regression-2.rs +++ b/tests/incremental/const-generics/hash-tyvid-regression-2.rs @@ -1,11 +1,23 @@ // revisions: cfail #![feature(generic_const_exprs, adt_const_params)] #![allow(incomplete_features)] + +use std::marker::ConstParamTy; + +#[derive(PartialEq, Eq, ConstParamTy)] +struct NonZeroUsize(usize); + +impl NonZeroUsize { + const fn get(self) -> usize { + self.0 + } +} + // regression test for #77650 -struct C<T, const N: core::num::NonZeroUsize>([T; N.get()]) +struct C<T, const N: NonZeroUsize>([T; N.get()]) where [T; N.get()]: Sized; -impl<'a, const N: core::num::NonZeroUsize, A, B: PartialEq<A>> PartialEq<&'a [A]> for C<B, N> +impl<'a, const N: NonZeroUsize, A, B: PartialEq<A>> PartialEq<&'a [A]> for C<B, N> where [B; N.get()]: Sized, { diff --git a/tests/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-77708-3.rs b/tests/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-77708-3.rs index fc114f224a2..f1c108fed11 100644 --- a/tests/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-77708-3.rs +++ b/tests/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-77708-3.rs @@ -2,7 +2,18 @@ #![feature(generic_const_exprs, adt_const_params)] #![allow(incomplete_features)] -use std::{convert::TryFrom, num::NonZeroUsize}; +use std::{convert::TryFrom}; + +use std::marker::ConstParamTy; + +#[derive(PartialEq, Eq, ConstParamTy)] +struct NonZeroUsize(usize); + +impl NonZeroUsize { + const fn get(self) -> usize { + self.0 + } +} struct A<const N: NonZeroUsize>([u8; N.get()]) where diff --git a/tests/incremental/hashes/match_expressions.rs b/tests/incremental/hashes/match_expressions.rs index 4429df6833e..ecb19480d65 100644 --- a/tests/incremental/hashes/match_expressions.rs +++ b/tests/incremental/hashes/match_expressions.rs @@ -225,8 +225,9 @@ pub fn change_mutability_of_binding_in_pattern(x: u32) -> u32 { } } +// Ignore optimized_mir in cfail2, the only change to optimized MIR is a span. #[cfg(not(any(cfail1,cfail4)))] -#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,optimized_mir,typeck")] +#[rustc_clean(cfg="cfail2", except="hir_owner_nodes,typeck")] #[rustc_clean(cfg="cfail3")] #[rustc_clean(cfg="cfail5", except="hir_owner_nodes,optimized_mir,typeck")] #[rustc_clean(cfg="cfail6")] diff --git a/tests/mir-opt/inline/cycle.main.Inline.diff b/tests/mir-opt/inline/cycle.main.Inline.diff index fdf6337a9be..7a39aae1baf 100644 --- a/tests/mir-opt/inline/cycle.main.Inline.diff +++ b/tests/mir-opt/inline/cycle.main.Inline.diff @@ -11,6 +11,14 @@ + let mut _3: &fn() {g}; // in scope 1 at $DIR/cycle.rs:6:5: 6:6 + let _4: (); // in scope 1 at $DIR/cycle.rs:6:5: 6:8 + scope 2 (inlined <fn() {g} as Fn<()>>::call - shim(fn() {g})) { // at $DIR/cycle.rs:6:5: 6:8 ++ scope 3 (inlined g) { // at $SRC_DIR/core/src/ops/function.rs:LL:COL ++ scope 4 (inlined f::<fn() {main}>) { // at $DIR/cycle.rs:12:5: 12:12 ++ debug g => main; // in scope 4 at $DIR/cycle.rs:5:6: 5:7 ++ let _6: (); // in scope 4 at $DIR/cycle.rs:6:5: 6:8 ++ scope 5 (inlined <fn() {main} as Fn<()>>::call - shim(fn() {main})) { // at $DIR/cycle.rs:6:5: 6:8 ++ } ++ } ++ } + } + } @@ -30,7 +38,11 @@ + _3 = &_2; // scope 1 at $DIR/cycle.rs:6:5: 6:6 + StorageLive(_5); // scope 1 at $DIR/cycle.rs:6:5: 6:8 + _5 = const (); // scope 1 at $DIR/cycle.rs:6:5: 6:8 -+ _4 = move (*_3)() -> [return: bb4, unwind: bb2]; // scope 2 at $SRC_DIR/core/src/ops/function.rs:LL:COL ++ StorageLive(_6); // scope 2 at $SRC_DIR/core/src/ops/function.rs:LL:COL ++ _6 = main() -> [return: bb4, unwind: bb2]; // scope 5 at $SRC_DIR/core/src/ops/function.rs:LL:COL ++ // mir::Constant ++ // + span: no-location ++ // + literal: Const { ty: fn() {main}, val: Value(<ZST>) } } bb1: { @@ -50,6 +62,7 @@ + } + + bb4: { ++ StorageDead(_6); // scope 2 at $SRC_DIR/core/src/ops/function.rs:LL:COL + StorageDead(_5); // scope 1 at $DIR/cycle.rs:6:5: 6:8 + StorageDead(_3); // scope 1 at $DIR/cycle.rs:6:7: 6:8 + drop(_2) -> bb1; // scope 1 at $DIR/cycle.rs:7:1: 7:2 diff --git a/tests/mir-opt/inline/exponential_runtime.main.Inline.diff b/tests/mir-opt/inline/exponential_runtime.main.Inline.diff index 30af8661dec..7fad6aba82e 100644 --- a/tests/mir-opt/inline/exponential_runtime.main.Inline.diff +++ b/tests/mir-opt/inline/exponential_runtime.main.Inline.diff @@ -12,6 +12,26 @@ + let _5: (); // in scope 2 at $DIR/exponential_runtime.rs:62:9: 62:25 + let _6: (); // in scope 2 at $DIR/exponential_runtime.rs:63:9: 63:25 + let _7: (); // in scope 2 at $DIR/exponential_runtime.rs:64:9: 64:25 ++ scope 3 (inlined <() as E>::call) { // at $DIR/exponential_runtime.rs:62:9: 62:25 ++ let _8: (); // in scope 3 at $DIR/exponential_runtime.rs:50:9: 50:25 ++ let _9: (); // in scope 3 at $DIR/exponential_runtime.rs:51:9: 51:25 ++ let _10: (); // in scope 3 at $DIR/exponential_runtime.rs:52:9: 52:25 ++ scope 4 (inlined <() as D>::call) { // at $DIR/exponential_runtime.rs:50:9: 50:25 ++ let _11: (); // in scope 4 at $DIR/exponential_runtime.rs:38:9: 38:25 ++ let _12: (); // in scope 4 at $DIR/exponential_runtime.rs:39:9: 39:25 ++ let _13: (); // in scope 4 at $DIR/exponential_runtime.rs:40:9: 40:25 ++ scope 5 (inlined <() as C>::call) { // at $DIR/exponential_runtime.rs:38:9: 38:25 ++ let _14: (); // in scope 5 at $DIR/exponential_runtime.rs:26:9: 26:25 ++ let _15: (); // in scope 5 at $DIR/exponential_runtime.rs:27:9: 27:25 ++ let _16: (); // in scope 5 at $DIR/exponential_runtime.rs:28:9: 28:25 ++ scope 6 (inlined <() as B>::call) { // at $DIR/exponential_runtime.rs:26:9: 26:25 ++ let _17: (); // in scope 6 at $DIR/exponential_runtime.rs:14:9: 14:25 ++ let _18: (); // in scope 6 at $DIR/exponential_runtime.rs:15:9: 15:25 ++ let _19: (); // in scope 6 at $DIR/exponential_runtime.rs:16:9: 16:25 ++ } ++ } ++ } ++ } + } + } @@ -24,12 +44,24 @@ + StorageLive(_5); // scope 1 at $DIR/exponential_runtime.rs:74:9: 74:25 + StorageLive(_6); // scope 1 at $DIR/exponential_runtime.rs:74:9: 74:25 + StorageLive(_7); // scope 1 at $DIR/exponential_runtime.rs:74:9: 74:25 -+ _5 = <() as E>::call() -> bb4; // scope 2 at $DIR/exponential_runtime.rs:62:9: 62:25 ++ StorageLive(_8); // scope 2 at $DIR/exponential_runtime.rs:62:9: 62:25 ++ StorageLive(_9); // scope 2 at $DIR/exponential_runtime.rs:62:9: 62:25 ++ StorageLive(_10); // scope 2 at $DIR/exponential_runtime.rs:62:9: 62:25 ++ StorageLive(_11); // scope 3 at $DIR/exponential_runtime.rs:50:9: 50:25 ++ StorageLive(_12); // scope 3 at $DIR/exponential_runtime.rs:50:9: 50:25 ++ StorageLive(_13); // scope 3 at $DIR/exponential_runtime.rs:50:9: 50:25 ++ StorageLive(_14); // scope 4 at $DIR/exponential_runtime.rs:38:9: 38:25 ++ StorageLive(_15); // scope 4 at $DIR/exponential_runtime.rs:38:9: 38:25 ++ StorageLive(_16); // scope 4 at $DIR/exponential_runtime.rs:38:9: 38:25 ++ StorageLive(_17); // scope 5 at $DIR/exponential_runtime.rs:26:9: 26:25 ++ StorageLive(_18); // scope 5 at $DIR/exponential_runtime.rs:26:9: 26:25 ++ StorageLive(_19); // scope 5 at $DIR/exponential_runtime.rs:26:9: 26:25 ++ _17 = <() as A>::call() -> bb12; // scope 6 at $DIR/exponential_runtime.rs:14:9: 14:25 // mir::Constant - // + span: $DIR/exponential_runtime.rs:87:5: 87:20 - // + literal: Const { ty: fn() {<() as G>::call}, val: Value(<ZST>) } -+ // + span: $DIR/exponential_runtime.rs:62:9: 62:23 -+ // + literal: Const { ty: fn() {<() as E>::call}, val: Value(<ZST>) } ++ // + span: $DIR/exponential_runtime.rs:14:9: 14:23 ++ // + literal: Const { ty: fn() {<() as A>::call}, val: Value(<ZST>) } } bb1: { @@ -59,6 +91,9 @@ + } + + bb4: { ++ StorageDead(_10); // scope 2 at $DIR/exponential_runtime.rs:62:9: 62:25 ++ StorageDead(_9); // scope 2 at $DIR/exponential_runtime.rs:62:9: 62:25 ++ StorageDead(_8); // scope 2 at $DIR/exponential_runtime.rs:62:9: 62:25 + _6 = <() as E>::call() -> bb5; // scope 2 at $DIR/exponential_runtime.rs:63:9: 63:25 + // mir::Constant + // + span: $DIR/exponential_runtime.rs:63:9: 63:23 @@ -70,6 +105,71 @@ + // mir::Constant + // + span: $DIR/exponential_runtime.rs:64:9: 64:23 + // + literal: Const { ty: fn() {<() as E>::call}, val: Value(<ZST>) } ++ } ++ ++ bb6: { ++ StorageDead(_13); // scope 3 at $DIR/exponential_runtime.rs:50:9: 50:25 ++ StorageDead(_12); // scope 3 at $DIR/exponential_runtime.rs:50:9: 50:25 ++ StorageDead(_11); // scope 3 at $DIR/exponential_runtime.rs:50:9: 50:25 ++ _9 = <() as D>::call() -> bb7; // scope 3 at $DIR/exponential_runtime.rs:51:9: 51:25 ++ // mir::Constant ++ // + span: $DIR/exponential_runtime.rs:51:9: 51:23 ++ // + literal: Const { ty: fn() {<() as D>::call}, val: Value(<ZST>) } ++ } ++ ++ bb7: { ++ _10 = <() as D>::call() -> bb4; // scope 3 at $DIR/exponential_runtime.rs:52:9: 52:25 ++ // mir::Constant ++ // + span: $DIR/exponential_runtime.rs:52:9: 52:23 ++ // + literal: Const { ty: fn() {<() as D>::call}, val: Value(<ZST>) } ++ } ++ ++ bb8: { ++ StorageDead(_16); // scope 4 at $DIR/exponential_runtime.rs:38:9: 38:25 ++ StorageDead(_15); // scope 4 at $DIR/exponential_runtime.rs:38:9: 38:25 ++ StorageDead(_14); // scope 4 at $DIR/exponential_runtime.rs:38:9: 38:25 ++ _12 = <() as C>::call() -> bb9; // scope 4 at $DIR/exponential_runtime.rs:39:9: 39:25 ++ // mir::Constant ++ // + span: $DIR/exponential_runtime.rs:39:9: 39:23 ++ // + literal: Const { ty: fn() {<() as C>::call}, val: Value(<ZST>) } ++ } ++ ++ bb9: { ++ _13 = <() as C>::call() -> bb6; // scope 4 at $DIR/exponential_runtime.rs:40:9: 40:25 ++ // mir::Constant ++ // + span: $DIR/exponential_runtime.rs:40:9: 40:23 ++ // + literal: Const { ty: fn() {<() as C>::call}, val: Value(<ZST>) } ++ } ++ ++ bb10: { ++ StorageDead(_19); // scope 5 at $DIR/exponential_runtime.rs:26:9: 26:25 ++ StorageDead(_18); // scope 5 at $DIR/exponential_runtime.rs:26:9: 26:25 ++ StorageDead(_17); // scope 5 at $DIR/exponential_runtime.rs:26:9: 26:25 ++ _15 = <() as B>::call() -> bb11; // scope 5 at $DIR/exponential_runtime.rs:27:9: 27:25 ++ // mir::Constant ++ // + span: $DIR/exponential_runtime.rs:27:9: 27:23 ++ // + literal: Const { ty: fn() {<() as B>::call}, val: Value(<ZST>) } ++ } ++ ++ bb11: { ++ _16 = <() as B>::call() -> bb8; // scope 5 at $DIR/exponential_runtime.rs:28:9: 28:25 ++ // mir::Constant ++ // + span: $DIR/exponential_runtime.rs:28:9: 28:23 ++ // + literal: Const { ty: fn() {<() as B>::call}, val: Value(<ZST>) } ++ } ++ ++ bb12: { ++ _18 = <() as A>::call() -> bb13; // scope 6 at $DIR/exponential_runtime.rs:15:9: 15:25 ++ // mir::Constant ++ // + span: $DIR/exponential_runtime.rs:15:9: 15:23 ++ // + literal: Const { ty: fn() {<() as A>::call}, val: Value(<ZST>) } ++ } ++ ++ bb13: { ++ _19 = <() as A>::call() -> bb10; // scope 6 at $DIR/exponential_runtime.rs:16:9: 16:25 ++ // mir::Constant ++ // + span: $DIR/exponential_runtime.rs:16:9: 16:23 ++ // + literal: Const { ty: fn() {<() as A>::call}, val: Value(<ZST>) } } } diff --git a/tests/mir-opt/inline/inline_cycle.two.Inline.diff b/tests/mir-opt/inline/inline_cycle.two.Inline.diff index c8f58111da7..48f0bd10301 100644 --- a/tests/mir-opt/inline/inline_cycle.two.Inline.diff +++ b/tests/mir-opt/inline/inline_cycle.two.Inline.diff @@ -10,6 +10,14 @@ + debug f => _2; // in scope 1 at $DIR/inline_cycle.rs:54:22: 54:23 + let _3: (); // in scope 1 at $DIR/inline_cycle.rs:55:5: 55:8 + scope 2 (inlined <fn() {f} as FnOnce<()>>::call_once - shim(fn() {f})) { // at $DIR/inline_cycle.rs:55:5: 55:8 ++ scope 3 (inlined f) { // at $SRC_DIR/core/src/ops/function.rs:LL:COL ++ scope 4 (inlined call::<fn() {f}>) { // at $DIR/inline_cycle.rs:60:5: 60:12 ++ debug f => f; // in scope 4 at $DIR/inline_cycle.rs:54:22: 54:23 ++ let _5: (); // in scope 4 at $DIR/inline_cycle.rs:55:5: 55:8 ++ scope 5 (inlined <fn() {f} as FnOnce<()>>::call_once - shim(fn() {f})) { // at $DIR/inline_cycle.rs:55:5: 55:8 ++ } ++ } ++ } + } + } @@ -27,10 +35,15 @@ + StorageLive(_3); // scope 0 at $DIR/inline_cycle.rs:+1:5: +1:12 + StorageLive(_4); // scope 1 at $DIR/inline_cycle.rs:55:5: 55:8 + _4 = const (); // scope 1 at $DIR/inline_cycle.rs:55:5: 55:8 -+ _3 = move _2() -> bb1; // scope 2 at $SRC_DIR/core/src/ops/function.rs:LL:COL ++ StorageLive(_5); // scope 2 at $SRC_DIR/core/src/ops/function.rs:LL:COL ++ _5 = f() -> bb1; // scope 5 at $SRC_DIR/core/src/ops/function.rs:LL:COL ++ // mir::Constant ++ // + span: no-location ++ // + literal: Const { ty: fn() {f}, val: Value(<ZST>) } } bb1: { ++ StorageDead(_5); // scope 2 at $SRC_DIR/core/src/ops/function.rs:LL:COL + StorageDead(_4); // scope 1 at $DIR/inline_cycle.rs:55:5: 55:8 + StorageDead(_3); // scope 0 at $DIR/inline_cycle.rs:+1:5: +1:12 + StorageDead(_2); // scope 0 at $DIR/inline_cycle.rs:+1:5: +1:12 diff --git a/tests/mir-opt/inline/inline_cycle_generic.main.Inline.diff b/tests/mir-opt/inline/inline_cycle_generic.main.Inline.diff index 9429ca59364..8696e624b22 100644 --- a/tests/mir-opt/inline/inline_cycle_generic.main.Inline.diff +++ b/tests/mir-opt/inline/inline_cycle_generic.main.Inline.diff @@ -6,18 +6,20 @@ let _1: (); // in scope 0 at $DIR/inline_cycle_generic.rs:+1:5: +1:24 + scope 1 (inlined <C as Call>::call) { // at $DIR/inline_cycle_generic.rs:10:5: 10:24 + scope 2 (inlined <B<A> as Call>::call) { // at $DIR/inline_cycle_generic.rs:39:9: 39:31 ++ scope 3 (inlined <A as Call>::call) { // at $DIR/inline_cycle_generic.rs:32:9: 32:28 ++ } + } + } bb0: { StorageLive(_1); // scope 0 at $DIR/inline_cycle_generic.rs:+1:5: +1:24 - _1 = <C as Call>::call() -> bb1; // scope 0 at $DIR/inline_cycle_generic.rs:+1:5: +1:24 -+ _1 = <A as Call>::call() -> bb1; // scope 2 at $DIR/inline_cycle_generic.rs:32:9: 32:28 ++ _1 = <B<C> as Call>::call() -> bb1; // scope 3 at $DIR/inline_cycle_generic.rs:24:9: 24:31 // mir::Constant - // + span: $DIR/inline_cycle_generic.rs:10:5: 10:22 - // + literal: Const { ty: fn() {<C as Call>::call}, val: Value(<ZST>) } -+ // + span: $DIR/inline_cycle_generic.rs:32:9: 32:26 -+ // + literal: Const { ty: fn() {<A as Call>::call}, val: Value(<ZST>) } ++ // + span: $DIR/inline_cycle_generic.rs:24:9: 24:29 ++ // + literal: Const { ty: fn() {<B<C> as Call>::call}, val: Value(<ZST>) } } bb1: { diff --git a/tests/mir-opt/inline/inline_diverging.h.Inline.diff b/tests/mir-opt/inline/inline_diverging.h.Inline.diff index 255451e8670..78cd47c5f4b 100644 --- a/tests/mir-opt/inline/inline_diverging.h.Inline.diff +++ b/tests/mir-opt/inline/inline_diverging.h.Inline.diff @@ -20,6 +20,8 @@ + } + } + scope 4 (inlined <fn() -> ! {sleep} as Fn<()>>::call - shim(fn() -> ! {sleep})) { // at $DIR/inline_diverging.rs:27:13: 27:16 ++ scope 5 (inlined sleep) { // at $SRC_DIR/core/src/ops/function.rs:LL:COL ++ } + } + } @@ -40,44 +42,11 @@ + _3 = &_2; // scope 1 at $DIR/inline_diverging.rs:27:13: 27:14 + StorageLive(_8); // scope 1 at $DIR/inline_diverging.rs:27:13: 27:16 + _8 = const (); // scope 1 at $DIR/inline_diverging.rs:27:13: 27:16 -+ _4 = move (*_3)() -> [return: bb6, unwind: bb4]; // scope 4 at $SRC_DIR/core/src/ops/function.rs:LL:COL ++ goto -> bb1; // scope 5 at $DIR/inline_diverging.rs:39:5: 39:12 + } + + bb1: { -+ StorageDead(_5); // scope 2 at $DIR/inline_diverging.rs:28:15: 28:16 -+ StorageLive(_7); // scope 3 at $DIR/inline_diverging.rs:29:6: 29:7 -+ _7 = move _4; // scope 3 at $DIR/inline_diverging.rs:29:6: 29:7 -+ _1 = (move _7, move _6); // scope 3 at $DIR/inline_diverging.rs:29:5: 29:11 -+ StorageDead(_7); // scope 3 at $DIR/inline_diverging.rs:29:10: 29:11 -+ StorageDead(_4); // scope 1 at $DIR/inline_diverging.rs:30:1: 30:2 -+ drop(_2) -> bb2; // scope 1 at $DIR/inline_diverging.rs:30:1: 30:2 -+ } -+ -+ bb2: { -+ unreachable; // scope 0 at $DIR/inline_diverging.rs:30:2: 30:2 -+ } -+ -+ bb3 (cleanup): { -+ drop(_4) -> [return: bb4, unwind terminate]; // scope 1 at $DIR/inline_diverging.rs:30:1: 30:2 -+ } -+ -+ bb4 (cleanup): { -+ drop(_2) -> [return: bb5, unwind terminate]; // scope 1 at $DIR/inline_diverging.rs:30:1: 30:2 -+ } -+ -+ bb5 (cleanup): { -+ resume; // scope 1 at $DIR/inline_diverging.rs:26:1: 30:2 -+ } -+ -+ bb6: { -+ StorageDead(_8); // scope 1 at $DIR/inline_diverging.rs:27:13: 27:16 -+ StorageDead(_3); // scope 1 at $DIR/inline_diverging.rs:27:15: 27:16 -+ StorageLive(_5); // scope 2 at $DIR/inline_diverging.rs:28:13: 28:14 -+ _5 = &_2; // scope 2 at $DIR/inline_diverging.rs:28:13: 28:14 -+ _6 = <fn() -> ! {sleep} as Fn<()>>::call(move _5, const ()) -> [return: bb1, unwind: bb3]; // scope 2 at $DIR/inline_diverging.rs:28:13: 28:16 -+ // mir::Constant -+ // + span: $DIR/inline_diverging.rs:28:13: 28:14 -+ // + literal: Const { ty: for<'a> extern "rust-call" fn(&'a fn() -> ! {sleep}, ()) -> <fn() -> ! {sleep} as FnOnce<()>>::Output {<fn() -> ! {sleep} as Fn<()>>::call}, val: Value(<ZST>) } ++ goto -> bb1; // scope 5 at $DIR/inline_diverging.rs:39:5: 39:12 } } diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.diff index d76cd0e2bb8..e82e3f18811 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.diff @@ -11,35 +11,33 @@ + debug self => _3; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + debug rhs => _4; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + let mut _5: u16; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ let mut _6: (u32,); // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ let mut _7: u32; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL + scope 2 { + scope 3 (inlined core::num::<impl u16>::unchecked_shl::conv) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ debug x => _7; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ let mut _8: std::option::Option<u16>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ let mut _9: std::result::Result<u16, std::num::TryFromIntError>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ debug x => _4; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ let mut _6: std::option::Option<u16>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ let mut _7: std::result::Result<u16, std::num::TryFromIntError>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL + scope 4 { + scope 5 (inlined <u32 as TryInto<u16>>::try_into) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ debug self => _7; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL ++ debug self => _4; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + scope 6 (inlined convert::num::<impl TryFrom<u32> for u16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL -+ debug u => _7; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ let mut _10: bool; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ let mut _11: u32; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ let mut _12: u16; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ debug u => _4; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _8: bool; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _9: u32; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _10: u16; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } + } + scope 7 (inlined Result::<u16, TryFromIntError>::ok) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ debug self => _9; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ let mut _13: isize; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ let _14: u16; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ debug self => _7; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ let mut _11: isize; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ let _12: u16; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + scope 8 { -+ debug x => _14; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL ++ debug x => _12; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + } + } + scope 9 (inlined #[track_caller] Option::<u16>::unwrap_unchecked) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ debug self => _8; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ let mut _15: &std::option::Option<u16>; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ let mut _16: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ debug self => _6; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ let mut _13: &std::option::Option<u16>; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ let mut _14: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + scope 10 { + debug val => _5; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL + } @@ -52,7 +50,7 @@ + } + } + scope 12 (inlined Option::<u16>::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL -+ debug self => _15; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL ++ debug self => _13; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL + } + } + } @@ -70,18 +68,14 @@ - // + span: $DIR/unchecked_shifts.rs:11:7: 11:20 - // + literal: Const { ty: unsafe fn(u16, u32) -> u16 {core::num::<impl u16>::unchecked_shl}, val: Value(<ZST>) } + StorageLive(_5); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_6); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ _6 = (_4,); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_7); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ _7 = move (_6.0: u32); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_8); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_9); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ StorageLive(_11); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ _11 = const 65535_u32; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ _10 = Gt(_7, move _11); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ StorageDead(_11); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ switchInt(move _10) -> [0: bb3, otherwise: bb2]; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageLive(_6); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageLive(_7); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageLive(_8); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageLive(_9); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _9 = const 65535_u32; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _8 = Gt(_4, move _9); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageDead(_9); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ switchInt(move _8) -> [0: bb3, otherwise: bb2]; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL } bb1: { @@ -92,7 +86,7 @@ + } + + bb2: { -+ _9 = Result::<u16, TryFromIntError>::Err(const TryFromIntError(())); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _7 = Result::<u16, TryFromIntError>::Err(const TryFromIntError(())); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + // mir::Constant + // + span: no-location + // + literal: Const { ty: TryFromIntError, val: Value(<ZST>) } @@ -100,22 +94,22 @@ + } + + bb3: { -+ StorageLive(_12); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ _12 = _7 as u16 (IntToInt); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ _9 = Result::<u16, TryFromIntError>::Ok(move _12); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ StorageDead(_12); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageLive(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _10 = _4 as u16 (IntToInt); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _7 = Result::<u16, TryFromIntError>::Ok(move _10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageDead(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + goto -> bb4; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } + + bb4: { -+ StorageDead(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ StorageLive(_14); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ _13 = discriminant(_9); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ switchInt(move _13) -> [0: bb7, 1: bb5, otherwise: bb6]; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ StorageDead(_8); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageLive(_12); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ _11 = discriminant(_7); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ switchInt(move _11) -> [0: bb7, 1: bb5, otherwise: bb6]; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb5: { -+ _8 = Option::<u16>::None; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ _6 = Option::<u16>::None; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + goto -> bb8; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + } + @@ -124,25 +118,23 @@ + } + + bb7: { -+ _14 = move ((_9 as Ok).0: u16); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ _8 = Option::<u16>::Some(move _14); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL ++ _12 = move ((_7 as Ok).0: u16); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ _6 = Option::<u16>::Some(move _12); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + goto -> bb8; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb8: { -+ StorageDead(_14); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageDead(_9); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_15); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ _16 = discriminant(_8); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ switchInt(move _16) -> [1: bb9, otherwise: bb6]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ StorageDead(_12); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageDead(_7); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageLive(_13); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ _14 = discriminant(_6); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ switchInt(move _14) -> [1: bb9, otherwise: bb6]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + } + + bb9: { -+ _5 = move ((_8 as Some).0: u16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ StorageDead(_15); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageDead(_8); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageDead(_7); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageDead(_6); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ _5 = move ((_6 as Some).0: u16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ StorageDead(_13); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageDead(_6); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + _0 = unchecked_shl::<u16>(_3, move _5) -> [return: bb1, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + // mir::Constant + // + span: $SRC_DIR/core/src/num/uint_macros.rs:LL:COL diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.mir index f4b2416eaab..8fa4fdaa49a 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.mir +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.mir @@ -7,38 +7,36 @@ fn unchecked_shl_unsigned_smaller(_1: u16, _2: u32) -> u16 { scope 1 (inlined core::num::<impl u16>::unchecked_shl) { // at $DIR/unchecked_shifts.rs:11:7: 11:23 debug self => _1; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL debug rhs => _2; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL - let mut _3: (u32,); // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL - let mut _4: u32; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL - let mut _13: u16; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL + let mut _11: u16; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL scope 2 { scope 3 (inlined core::num::<impl u16>::unchecked_shl::conv) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL - debug x => _4; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL - let mut _8: std::result::Result<u16, std::num::TryFromIntError>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL - let mut _11: std::option::Option<u16>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL + debug x => _2; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL + let mut _6: std::result::Result<u16, std::num::TryFromIntError>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL + let mut _9: std::option::Option<u16>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL scope 4 { scope 5 (inlined <u32 as TryInto<u16>>::try_into) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL - debug self => _4; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + debug self => _2; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL scope 6 (inlined convert::num::<impl TryFrom<u32> for u16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL - debug u => _4; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - let mut _5: u32; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - let mut _6: bool; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - let mut _7: u16; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + debug u => _2; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _3: u32; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _4: bool; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _5: u16; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL } } scope 7 (inlined Result::<u16, TryFromIntError>::ok) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL - debug self => _8; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - let mut _9: isize; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - let _10: u16; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + debug self => _6; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + let mut _7: isize; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + let _8: u16; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL scope 8 { - debug x => _10; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + debug x => _8; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL } } scope 9 (inlined #[track_caller] Option::<u16>::unwrap_unchecked) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL - debug self => _11; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - let mut _12: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - let mut _14: &std::option::Option<u16>; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + debug self => _9; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _10: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _12: &std::option::Option<u16>; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL scope 10 { - debug val => _13; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL + debug val => _11; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL } scope 11 { scope 13 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL @@ -49,7 +47,7 @@ fn unchecked_shl_unsigned_smaller(_1: u16, _2: u32) -> u16 { } } scope 12 (inlined Option::<u16>::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL - debug self => _14; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL + debug self => _12; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL } } } @@ -58,31 +56,27 @@ fn unchecked_shl_unsigned_smaller(_1: u16, _2: u32) -> u16 { } bb0: { - StorageLive(_13); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_3); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - _3 = (_2,); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_4); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - _4 = move (_3.0: u32); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_11); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_8); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_6); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - StorageLive(_5); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - _5 = const 65535_u32; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - _6 = Gt(_4, move _5); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - StorageDead(_5); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - switchInt(move _6) -> [0: bb1, otherwise: bb2]; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageLive(_11); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageLive(_9); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageLive(_6); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageLive(_4); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageLive(_3); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _3 = const 65535_u32; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _4 = Gt(_2, move _3); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageDead(_3); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + switchInt(move _4) -> [0: bb1, otherwise: bb2]; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL } bb1: { - StorageLive(_7); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - _7 = _4 as u16 (IntToInt); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - _8 = Result::<u16, TryFromIntError>::Ok(move _7); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - StorageDead(_7); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageLive(_5); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _5 = _2 as u16 (IntToInt); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _6 = Result::<u16, TryFromIntError>::Ok(move _5); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageDead(_5); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL goto -> bb3; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL } bb2: { - _8 = Result::<u16, TryFromIntError>::Err(const TryFromIntError(())); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _6 = Result::<u16, TryFromIntError>::Err(const TryFromIntError(())); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL // mir::Constant // + span: no-location // + literal: Const { ty: TryFromIntError, val: Value(<ZST>) } @@ -90,45 +84,43 @@ fn unchecked_shl_unsigned_smaller(_1: u16, _2: u32) -> u16 { } bb3: { - StorageDead(_6); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - StorageLive(_10); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - _9 = discriminant(_8); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - switchInt(move _9) -> [0: bb4, 1: bb5, otherwise: bb9]; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + StorageDead(_4); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageLive(_8); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + _7 = discriminant(_6); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + switchInt(move _7) -> [0: bb4, 1: bb5, otherwise: bb9]; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL } bb4: { - _10 = move ((_8 as Ok).0: u16); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - _11 = Option::<u16>::Some(move _10); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + _8 = move ((_6 as Ok).0: u16); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + _9 = Option::<u16>::Some(move _8); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL goto -> bb6; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL } bb5: { - _11 = Option::<u16>::None; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + _9 = Option::<u16>::None; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL goto -> bb6; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL } bb6: { - StorageDead(_10); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL StorageDead(_8); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_14); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - _12 = discriminant(_11); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - switchInt(move _12) -> [1: bb7, otherwise: bb9]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + StorageDead(_6); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageLive(_12); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + _10 = discriminant(_9); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + switchInt(move _10) -> [1: bb7, otherwise: bb9]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL } bb7: { - _13 = move ((_11 as Some).0: u16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - StorageDead(_14); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageDead(_11); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageDead(_4); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageDead(_3); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - _0 = unchecked_shl::<u16>(_1, move _13) -> [return: bb8, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + _11 = move ((_9 as Some).0: u16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + StorageDead(_12); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageDead(_9); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + _0 = unchecked_shl::<u16>(_1, move _11) -> [return: bb8, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/num/uint_macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(u16, u16) -> u16 {unchecked_shl::<u16>}, val: Value(<ZST>) } } bb8: { - StorageDead(_13); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + StorageDead(_11); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL return; // scope 0 at $DIR/unchecked_shifts.rs:+2:2: +2:2 } diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.diff b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.diff index f3d3e6090bb..f20c7da4747 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.diff +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.Inline.diff @@ -11,35 +11,33 @@ + debug self => _3; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + debug rhs => _4; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + let mut _5: i16; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ let mut _6: (u32,); // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ let mut _7: u32; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL + scope 2 { + scope 3 (inlined core::num::<impl i16>::unchecked_shr::conv) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ debug x => _7; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ let mut _8: std::option::Option<i16>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ let mut _9: std::result::Result<i16, std::num::TryFromIntError>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ debug x => _4; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ let mut _6: std::option::Option<i16>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ let mut _7: std::result::Result<i16, std::num::TryFromIntError>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL + scope 4 { + scope 5 (inlined <u32 as TryInto<i16>>::try_into) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ debug self => _7; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL ++ debug self => _4; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + scope 6 (inlined convert::num::<impl TryFrom<u32> for i16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL -+ debug u => _7; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ let mut _10: bool; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ let mut _11: u32; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ let mut _12: i16; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ debug u => _4; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _8: bool; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _9: u32; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ let mut _10: i16; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } + } + scope 7 (inlined Result::<i16, TryFromIntError>::ok) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ debug self => _9; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ let mut _13: isize; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ let _14: i16; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ debug self => _7; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ let mut _11: isize; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ let _12: i16; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + scope 8 { -+ debug x => _14; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL ++ debug x => _12; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + } + } + scope 9 (inlined #[track_caller] Option::<i16>::unwrap_unchecked) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ debug self => _8; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ let mut _15: &std::option::Option<i16>; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ let mut _16: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ debug self => _6; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ let mut _13: &std::option::Option<i16>; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ let mut _14: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + scope 10 { + debug val => _5; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL + } @@ -52,7 +50,7 @@ + } + } + scope 12 (inlined Option::<i16>::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL -+ debug self => _15; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL ++ debug self => _13; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL + } + } + } @@ -70,18 +68,14 @@ - // + span: $DIR/unchecked_shifts.rs:17:7: 17:20 - // + literal: Const { ty: unsafe fn(i16, u32) -> i16 {core::num::<impl i16>::unchecked_shr}, val: Value(<ZST>) } + StorageLive(_5); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_6); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ _6 = (_4,); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_7); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ _7 = move (_6.0: u32); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_8); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_9); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ StorageLive(_11); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ _11 = const 32767_u32; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ _10 = Gt(_7, move _11); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ StorageDead(_11); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ switchInt(move _10) -> [0: bb3, otherwise: bb2]; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageLive(_6); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageLive(_7); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageLive(_8); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageLive(_9); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _9 = const 32767_u32; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _8 = Gt(_4, move _9); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageDead(_9); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ switchInt(move _8) -> [0: bb3, otherwise: bb2]; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL } bb1: { @@ -92,7 +86,7 @@ + } + + bb2: { -+ _9 = Result::<i16, TryFromIntError>::Err(const TryFromIntError(())); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _7 = Result::<i16, TryFromIntError>::Err(const TryFromIntError(())); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + // mir::Constant + // + span: no-location + // + literal: Const { ty: TryFromIntError, val: Value(<ZST>) } @@ -100,22 +94,22 @@ + } + + bb3: { -+ StorageLive(_12); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ _12 = _7 as i16 (IntToInt); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ _9 = Result::<i16, TryFromIntError>::Ok(move _12); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ StorageDead(_12); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageLive(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _10 = _4 as i16 (IntToInt); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ _7 = Result::<i16, TryFromIntError>::Ok(move _10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageDead(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + goto -> bb4; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + } + + bb4: { -+ StorageDead(_10); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL -+ StorageLive(_14); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ _13 = discriminant(_9); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ switchInt(move _13) -> [0: bb7, 1: bb5, otherwise: bb6]; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ StorageDead(_8); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL ++ StorageLive(_12); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ _11 = discriminant(_7); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ switchInt(move _11) -> [0: bb7, 1: bb5, otherwise: bb6]; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb5: { -+ _8 = Option::<i16>::None; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ _6 = Option::<i16>::None; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + goto -> bb8; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + } + @@ -124,25 +118,23 @@ + } + + bb7: { -+ _14 = move ((_9 as Ok).0: i16); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL -+ _8 = Option::<i16>::Some(move _14); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL ++ _12 = move ((_7 as Ok).0: i16); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL ++ _6 = Option::<i16>::Some(move _12); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + goto -> bb8; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + } + + bb8: { -+ StorageDead(_14); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageDead(_9); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageLive(_15); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ _16 = discriminant(_8); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ switchInt(move _16) -> [1: bb9, otherwise: bb6]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ StorageDead(_12); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageDead(_7); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageLive(_13); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ _14 = discriminant(_6); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ switchInt(move _14) -> [1: bb9, otherwise: bb6]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + } + + bb9: { -+ _5 = move ((_8 as Some).0: i16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL -+ StorageDead(_15); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageDead(_8); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageDead(_7); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL -+ StorageDead(_6); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ _5 = move ((_6 as Some).0: i16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL ++ StorageDead(_13); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL ++ StorageDead(_6); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + _0 = unchecked_shr::<i16>(_3, move _5) -> [return: bb1, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + // mir::Constant + // + span: $SRC_DIR/core/src/num/int_macros.rs:LL:COL diff --git a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.mir b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.mir index 67f0fe8932f..7f737abb936 100644 --- a/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.mir +++ b/tests/mir-opt/inline/unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.mir @@ -7,38 +7,36 @@ fn unchecked_shr_signed_smaller(_1: i16, _2: u32) -> i16 { scope 1 (inlined core::num::<impl i16>::unchecked_shr) { // at $DIR/unchecked_shifts.rs:17:7: 17:23 debug self => _1; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL debug rhs => _2; // in scope 1 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL - let mut _3: (u32,); // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL - let mut _4: u32; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL - let mut _13: i16; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL + let mut _11: i16; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL scope 2 { scope 3 (inlined core::num::<impl i16>::unchecked_shr::conv) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL - debug x => _4; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL - let mut _8: std::result::Result<i16, std::num::TryFromIntError>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL - let mut _11: std::option::Option<i16>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL + debug x => _2; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL + let mut _6: std::result::Result<i16, std::num::TryFromIntError>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL + let mut _9: std::option::Option<i16>; // in scope 3 at $SRC_DIR/core/src/num/mod.rs:LL:COL scope 4 { scope 5 (inlined <u32 as TryInto<i16>>::try_into) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL - debug self => _4; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + debug self => _2; // in scope 5 at $SRC_DIR/core/src/convert/mod.rs:LL:COL scope 6 (inlined convert::num::<impl TryFrom<u32> for i16>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL - debug u => _4; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - let mut _5: u32; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - let mut _6: bool; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - let mut _7: i16; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + debug u => _2; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _3: u32; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _4: bool; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + let mut _5: i16; // in scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL } } scope 7 (inlined Result::<i16, TryFromIntError>::ok) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL - debug self => _8; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - let mut _9: isize; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - let _10: i16; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + debug self => _6; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + let mut _7: isize; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + let _8: i16; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL scope 8 { - debug x => _10; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + debug x => _8; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL } } scope 9 (inlined #[track_caller] Option::<i16>::unwrap_unchecked) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL - debug self => _11; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - let mut _12: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - let mut _14: &std::option::Option<i16>; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + debug self => _9; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _10: isize; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _12: &std::option::Option<i16>; // in scope 9 at $SRC_DIR/core/src/option.rs:LL:COL scope 10 { - debug val => _13; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL + debug val => _11; // in scope 10 at $SRC_DIR/core/src/option.rs:LL:COL } scope 11 { scope 13 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL @@ -49,7 +47,7 @@ fn unchecked_shr_signed_smaller(_1: i16, _2: u32) -> i16 { } } scope 12 (inlined Option::<i16>::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL - debug self => _14; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL + debug self => _12; // in scope 12 at $SRC_DIR/core/src/option.rs:LL:COL } } } @@ -58,31 +56,27 @@ fn unchecked_shr_signed_smaller(_1: i16, _2: u32) -> i16 { } bb0: { - StorageLive(_13); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_3); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - _3 = (_2,); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_4); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - _4 = move (_3.0: u32); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_11); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_8); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_6); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - StorageLive(_5); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - _5 = const 32767_u32; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - _6 = Gt(_4, move _5); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - StorageDead(_5); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - switchInt(move _6) -> [0: bb1, otherwise: bb2]; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageLive(_11); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageLive(_9); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageLive(_6); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageLive(_4); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageLive(_3); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _3 = const 32767_u32; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _4 = Gt(_2, move _3); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageDead(_3); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + switchInt(move _4) -> [0: bb1, otherwise: bb2]; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL } bb1: { - StorageLive(_7); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - _7 = _4 as i16 (IntToInt); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - _8 = Result::<i16, TryFromIntError>::Ok(move _7); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - StorageDead(_7); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageLive(_5); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _5 = _2 as i16 (IntToInt); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _6 = Result::<i16, TryFromIntError>::Ok(move _5); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageDead(_5); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL goto -> bb3; // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL } bb2: { - _8 = Result::<i16, TryFromIntError>::Err(const TryFromIntError(())); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + _6 = Result::<i16, TryFromIntError>::Err(const TryFromIntError(())); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL // mir::Constant // + span: no-location // + literal: Const { ty: TryFromIntError, val: Value(<ZST>) } @@ -90,45 +84,43 @@ fn unchecked_shr_signed_smaller(_1: i16, _2: u32) -> i16 { } bb3: { - StorageDead(_6); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL - StorageLive(_10); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - _9 = discriminant(_8); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - switchInt(move _9) -> [0: bb4, 1: bb5, otherwise: bb9]; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + StorageDead(_4); // scope 6 at $SRC_DIR/core/src/convert/num.rs:LL:COL + StorageLive(_8); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + _7 = discriminant(_6); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + switchInt(move _7) -> [0: bb4, 1: bb5, otherwise: bb9]; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL } bb4: { - _10 = move ((_8 as Ok).0: i16); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - _11 = Option::<i16>::Some(move _10); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + _8 = move ((_6 as Ok).0: i16); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + _9 = Option::<i16>::Some(move _8); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL goto -> bb6; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL } bb5: { - _11 = Option::<i16>::None; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + _9 = Option::<i16>::None; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL goto -> bb6; // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL } bb6: { - StorageDead(_10); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL StorageDead(_8); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageLive(_14); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - _12 = discriminant(_11); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - switchInt(move _12) -> [1: bb7, otherwise: bb9]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + StorageDead(_6); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageLive(_12); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + _10 = discriminant(_9); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + switchInt(move _10) -> [1: bb7, otherwise: bb9]; // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL } bb7: { - _13 = move ((_11 as Some).0: i16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL - StorageDead(_14); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageDead(_11); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageDead(_4); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - StorageDead(_3); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL - _0 = unchecked_shr::<i16>(_1, move _13) -> [return: bb8, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + _11 = move ((_9 as Some).0: i16); // scope 9 at $SRC_DIR/core/src/option.rs:LL:COL + StorageDead(_12); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageDead(_9); // scope 4 at $SRC_DIR/core/src/num/mod.rs:LL:COL + _0 = unchecked_shr::<i16>(_1, move _11) -> [return: bb8, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/num/int_macros.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(i16, i16) -> i16 {unchecked_shr::<i16>}, val: Value(<ZST>) } } bb8: { - StorageDead(_13); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL + StorageDead(_11); // scope 2 at $SRC_DIR/core/src/num/int_macros.rs:LL:COL return; // scope 0 at $DIR/unchecked_shifts.rs:+2:2: +2:2 } diff --git a/tests/mir-opt/lower_intrinsics.align_of.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.align_of.LowerIntrinsics.diff index dd742d87a29..3530f4a807f 100644 --- a/tests/mir-opt/lower_intrinsics.align_of.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.align_of.LowerIntrinsics.diff @@ -7,7 +7,7 @@ bb0: { - _0 = std::intrinsics::min_align_of::<T>() -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:42 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:21:5: 21:40 +- // + span: $DIR/lower_intrinsics.rs:27:5: 27:40 - // + literal: Const { ty: extern "rust-intrinsic" fn() -> usize {std::intrinsics::min_align_of::<T>}, val: Value(<ZST>) } + _0 = AlignOf(T); // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:42 + goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:42 diff --git a/tests/mir-opt/lower_intrinsics.assume.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.assume.LowerIntrinsics.diff index e95c3f9bcc7..158ce62e209 100644 --- a/tests/mir-opt/lower_intrinsics.assume.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.assume.LowerIntrinsics.diff @@ -11,7 +11,7 @@ StorageLive(_1); // scope 1 at $DIR/lower_intrinsics.rs:+2:9: +2:38 - _1 = std::intrinsics::assume(const true) -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics.rs:+2:9: +2:38 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:106:9: 106:32 +- // + span: $DIR/lower_intrinsics.rs:112:9: 112:32 - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(bool) {std::intrinsics::assume}, val: Value(<ZST>) } + assume(const true); // scope 1 at $DIR/lower_intrinsics.rs:+2:9: +2:38 + goto -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:+2:9: +2:38 diff --git a/tests/mir-opt/lower_intrinsics.discriminant.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.discriminant.LowerIntrinsics.diff index 1f03b7b0baf..6fc9616d855 100644 --- a/tests/mir-opt/lower_intrinsics.discriminant.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.discriminant.LowerIntrinsics.diff @@ -31,7 +31,7 @@ _3 = &(*_4); // scope 0 at $DIR/lower_intrinsics.rs:+1:42: +1:44 - _2 = discriminant_value::<T>(move _3) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:45 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:82:5: 82:41 +- // + span: $DIR/lower_intrinsics.rs:88:5: 88:41 - // + literal: Const { ty: for<'a> extern "rust-intrinsic" fn(&'a T) -> <T as DiscriminantKind>::Discriminant {discriminant_value::<T>}, val: Value(<ZST>) } + _2 = discriminant((*_3)); // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:45 + goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:45 @@ -46,13 +46,13 @@ StorageLive(_7); // scope 0 at $DIR/lower_intrinsics.rs:+2:42: +2:44 _19 = const _; // scope 0 at $DIR/lower_intrinsics.rs:+2:42: +2:44 // mir::Constant - // + span: $DIR/lower_intrinsics.rs:83:42: 83:44 + // + span: $DIR/lower_intrinsics.rs:89:42: 89:44 // + literal: Const { ty: &i32, val: Unevaluated(discriminant, [T], Some(promoted[2])) } _7 = &(*_19); // scope 0 at $DIR/lower_intrinsics.rs:+2:42: +2:44 _6 = &(*_7); // scope 0 at $DIR/lower_intrinsics.rs:+2:42: +2:44 - _5 = discriminant_value::<i32>(move _6) -> [return: bb2, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+2:5: +2:45 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:83:5: 83:41 +- // + span: $DIR/lower_intrinsics.rs:89:5: 89:41 - // + literal: Const { ty: for<'a> extern "rust-intrinsic" fn(&'a i32) -> <i32 as DiscriminantKind>::Discriminant {discriminant_value::<i32>}, val: Value(<ZST>) } + _5 = discriminant((*_6)); // scope 0 at $DIR/lower_intrinsics.rs:+2:5: +2:45 + goto -> bb2; // scope 0 at $DIR/lower_intrinsics.rs:+2:5: +2:45 @@ -67,13 +67,13 @@ StorageLive(_11); // scope 0 at $DIR/lower_intrinsics.rs:+3:42: +3:45 _18 = const _; // scope 0 at $DIR/lower_intrinsics.rs:+3:42: +3:45 // mir::Constant - // + span: $DIR/lower_intrinsics.rs:84:42: 84:45 + // + span: $DIR/lower_intrinsics.rs:90:42: 90:45 // + literal: Const { ty: &(), val: Unevaluated(discriminant, [T], Some(promoted[1])) } _11 = &(*_18); // scope 0 at $DIR/lower_intrinsics.rs:+3:42: +3:45 _10 = &(*_11); // scope 0 at $DIR/lower_intrinsics.rs:+3:42: +3:45 - _9 = discriminant_value::<()>(move _10) -> [return: bb3, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+3:5: +3:46 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:84:5: 84:41 +- // + span: $DIR/lower_intrinsics.rs:90:5: 90:41 - // + literal: Const { ty: for<'a> extern "rust-intrinsic" fn(&'a ()) -> <() as DiscriminantKind>::Discriminant {discriminant_value::<()>}, val: Value(<ZST>) } + _9 = discriminant((*_10)); // scope 0 at $DIR/lower_intrinsics.rs:+3:5: +3:46 + goto -> bb3; // scope 0 at $DIR/lower_intrinsics.rs:+3:5: +3:46 @@ -88,13 +88,13 @@ StorageLive(_15); // scope 0 at $DIR/lower_intrinsics.rs:+4:42: +4:47 _17 = const _; // scope 0 at $DIR/lower_intrinsics.rs:+4:42: +4:47 // mir::Constant - // + span: $DIR/lower_intrinsics.rs:85:42: 85:47 + // + span: $DIR/lower_intrinsics.rs:91:42: 91:47 // + literal: Const { ty: &E, val: Unevaluated(discriminant, [T], Some(promoted[0])) } _15 = &(*_17); // scope 0 at $DIR/lower_intrinsics.rs:+4:42: +4:47 _14 = &(*_15); // scope 0 at $DIR/lower_intrinsics.rs:+4:42: +4:47 - _13 = discriminant_value::<E>(move _14) -> [return: bb4, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+4:5: +4:48 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:85:5: 85:41 +- // + span: $DIR/lower_intrinsics.rs:91:5: 91:41 - // + literal: Const { ty: for<'a> extern "rust-intrinsic" fn(&'a E) -> <E as DiscriminantKind>::Discriminant {discriminant_value::<E>}, val: Value(<ZST>) } + _13 = discriminant((*_14)); // scope 0 at $DIR/lower_intrinsics.rs:+4:5: +4:48 + goto -> bb4; // scope 0 at $DIR/lower_intrinsics.rs:+4:5: +4:48 diff --git a/tests/mir-opt/lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.diff index a54e9a9320e..5b870ccf5ee 100644 --- a/tests/mir-opt/lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.f_copy_nonoverlapping.LowerIntrinsics.diff @@ -49,7 +49,7 @@ StorageDead(_9); // scope 3 at $DIR/lower_intrinsics.rs:+4:90: +4:91 - _3 = copy_nonoverlapping::<i32>(move _4, move _8, const 0_usize) -> [return: bb1, unwind unreachable]; // scope 3 at $DIR/lower_intrinsics.rs:+4:9: +4:95 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:99:9: 99:28 +- // + span: $DIR/lower_intrinsics.rs:105:9: 105:28 - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(*const i32, *mut i32, usize) {copy_nonoverlapping::<i32>}, val: Value(<ZST>) } + copy_nonoverlapping(dst = move _8, src = move _4, count = const 0_usize); // scope 3 at $DIR/lower_intrinsics.rs:+4:9: +4:95 + goto -> bb1; // scope 3 at $DIR/lower_intrinsics.rs:+4:9: +4:95 diff --git a/tests/mir-opt/lower_intrinsics.forget.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.forget.LowerIntrinsics.diff index bfb000ccdb5..582a79f48d8 100644 --- a/tests/mir-opt/lower_intrinsics.forget.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.forget.LowerIntrinsics.diff @@ -11,7 +11,7 @@ _2 = move _1; // scope 0 at $DIR/lower_intrinsics.rs:+1:30: +1:31 - _0 = std::intrinsics::forget::<T>(move _2) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:32 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:26:5: 26:29 +- // + span: $DIR/lower_intrinsics.rs:32:5: 32:29 - // + literal: Const { ty: extern "rust-intrinsic" fn(T) {std::intrinsics::forget::<T>}, val: Value(<ZST>) } + _0 = const (); // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:32 + goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:32 diff --git a/tests/mir-opt/lower_intrinsics.non_const.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.non_const.LowerIntrinsics.diff index 64d82907c7e..81ad97077b4 100644 --- a/tests/mir-opt/lower_intrinsics.non_const.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.non_const.LowerIntrinsics.diff @@ -13,7 +13,7 @@ StorageLive(_1); // scope 0 at $DIR/lower_intrinsics.rs:+2:9: +2:18 _1 = std::intrinsics::size_of::<T>; // scope 0 at $DIR/lower_intrinsics.rs:+2:21: +2:51 // mir::Constant - // + span: $DIR/lower_intrinsics.rs:37:21: 37:51 + // + span: $DIR/lower_intrinsics.rs:43:21: 43:51 // + literal: Const { ty: extern "rust-intrinsic" fn() -> usize {std::intrinsics::size_of::<T>}, val: Value(<ZST>) } StorageLive(_2); // scope 1 at $DIR/lower_intrinsics.rs:+3:5: +3:14 _2 = _1; // scope 1 at $DIR/lower_intrinsics.rs:+3:5: +3:14 diff --git a/tests/mir-opt/lower_intrinsics.option_payload.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.option_payload.LowerIntrinsics.diff index b022e2ba42b..edc66e2c75c 100644 --- a/tests/mir-opt/lower_intrinsics.option_payload.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.option_payload.LowerIntrinsics.diff @@ -24,7 +24,7 @@ _4 = &raw const (*_1); // scope 1 at $DIR/lower_intrinsics.rs:+2:55: +2:56 - _3 = option_payload_ptr::<usize>(move _4) -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics.rs:+2:18: +2:57 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:137:18: 137:54 +- // + span: $DIR/lower_intrinsics.rs:143:18: 143:54 - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(*const Option<usize>) -> *const usize {option_payload_ptr::<usize>}, val: Value(<ZST>) } + _3 = &raw const (((*_4) as Some).0: usize); // scope 1 at $DIR/lower_intrinsics.rs:+2:18: +2:57 + goto -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:+2:18: +2:57 @@ -37,7 +37,7 @@ _6 = &raw const (*_2); // scope 2 at $DIR/lower_intrinsics.rs:+3:55: +3:56 - _5 = option_payload_ptr::<String>(move _6) -> [return: bb2, unwind unreachable]; // scope 2 at $DIR/lower_intrinsics.rs:+3:18: +3:57 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:138:18: 138:54 +- // + span: $DIR/lower_intrinsics.rs:144:18: 144:54 - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(*const Option<String>) -> *const String {option_payload_ptr::<String>}, val: Value(<ZST>) } + _5 = &raw const (((*_6) as Some).0: std::string::String); // scope 2 at $DIR/lower_intrinsics.rs:+3:18: +3:57 + goto -> bb2; // scope 2 at $DIR/lower_intrinsics.rs:+3:18: +3:57 diff --git a/tests/mir-opt/lower_intrinsics.ptr_offset.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.ptr_offset.LowerIntrinsics.diff index 60a1dd0ba7d..1760efe77d9 100644 --- a/tests/mir-opt/lower_intrinsics.ptr_offset.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.ptr_offset.LowerIntrinsics.diff @@ -15,7 +15,7 @@ _4 = _2; // scope 0 at $DIR/lower_intrinsics.rs:+1:33: +1:34 - _0 = offset::<*const i32, isize>(move _3, move _4) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:35 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:144:5: 144:29 +- // + span: $DIR/lower_intrinsics.rs:150:5: 150:29 - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(*const i32, isize) -> *const i32 {offset::<*const i32, isize>}, val: Value(<ZST>) } + _0 = Offset(move _3, move _4); // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:35 + goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:35 diff --git a/tests/mir-opt/lower_intrinsics.read_via_copy_primitive.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.read_via_copy_primitive.LowerIntrinsics.diff index 5805df48f54..8583766348a 100644 --- a/tests/mir-opt/lower_intrinsics.read_via_copy_primitive.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.read_via_copy_primitive.LowerIntrinsics.diff @@ -13,7 +13,7 @@ _2 = &raw const (*_1); // scope 1 at $DIR/lower_intrinsics.rs:+1:46: +1:47 - _0 = read_via_copy::<i32>(move _2) -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:48 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:119:14: 119:45 +- // + span: $DIR/lower_intrinsics.rs:125:14: 125:45 - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(*const i32) -> i32 {read_via_copy::<i32>}, val: Value(<ZST>) } + _0 = (*_2); // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:48 + goto -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:48 diff --git a/tests/mir-opt/lower_intrinsics.read_via_copy_uninhabited.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.read_via_copy_uninhabited.LowerIntrinsics.diff index 95b2ec49d80..f64bc9dcf62 100644 --- a/tests/mir-opt/lower_intrinsics.read_via_copy_uninhabited.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.read_via_copy_uninhabited.LowerIntrinsics.diff @@ -13,7 +13,7 @@ _2 = &raw const (*_1); // scope 1 at $DIR/lower_intrinsics.rs:+1:46: +1:47 - _0 = read_via_copy::<Never>(move _2) -> unwind unreachable; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:48 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:124:14: 124:45 +- // + span: $DIR/lower_intrinsics.rs:130:14: 130:45 - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(*const Never) -> Never {read_via_copy::<Never>}, val: Value(<ZST>) } + unreachable; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:48 } diff --git a/tests/mir-opt/lower_intrinsics.rs b/tests/mir-opt/lower_intrinsics.rs index 0ca88a42e3f..30b5c78e647 100644 --- a/tests/mir-opt/lower_intrinsics.rs +++ b/tests/mir-opt/lower_intrinsics.rs @@ -11,6 +11,12 @@ pub fn wrapping(a: i32, b: i32) { let _z = core::intrinsics::wrapping_mul(a, b); } +// EMIT_MIR lower_intrinsics.unchecked.LowerIntrinsics.diff +pub unsafe fn unchecked(a: i32, b: i32) { + let _x = core::intrinsics::unchecked_div(a, b); + let _y = core::intrinsics::unchecked_rem(a, b); +} + // EMIT_MIR lower_intrinsics.size_of.LowerIntrinsics.diff pub fn size_of<T>() -> usize { core::intrinsics::size_of::<T>() diff --git a/tests/mir-opt/lower_intrinsics.size_of.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.size_of.LowerIntrinsics.diff index 27e8accea8b..a880df6a5c2 100644 --- a/tests/mir-opt/lower_intrinsics.size_of.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.size_of.LowerIntrinsics.diff @@ -7,7 +7,7 @@ bb0: { - _0 = std::intrinsics::size_of::<T>() -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:37 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:16:5: 16:35 +- // + span: $DIR/lower_intrinsics.rs:22:5: 22:35 - // + literal: Const { ty: extern "rust-intrinsic" fn() -> usize {std::intrinsics::size_of::<T>}, val: Value(<ZST>) } + _0 = SizeOf(T); // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:37 + goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:5: +1:37 diff --git a/tests/mir-opt/lower_intrinsics.transmute_inhabited.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.transmute_inhabited.LowerIntrinsics.diff index 1b3b7685185..cde7c64c57a 100644 --- a/tests/mir-opt/lower_intrinsics.transmute_inhabited.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.transmute_inhabited.LowerIntrinsics.diff @@ -13,7 +13,7 @@ _2 = _1; // scope 1 at $DIR/lower_intrinsics.rs:+1:34: +1:35 - _0 = transmute::<std::cmp::Ordering, i8>(move _2) -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:36 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:43:14: 43:33 +- // + span: $DIR/lower_intrinsics.rs:49:14: 49:33 - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(std::cmp::Ordering) -> i8 {transmute::<std::cmp::Ordering, i8>}, val: Value(<ZST>) } + _0 = move _2 as i8 (Transmute); // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:36 + goto -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:36 diff --git a/tests/mir-opt/lower_intrinsics.transmute_ref_dst.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.transmute_ref_dst.LowerIntrinsics.diff index c6a7d2287e7..6fc0f3d3e3f 100644 --- a/tests/mir-opt/lower_intrinsics.transmute_ref_dst.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.transmute_ref_dst.LowerIntrinsics.diff @@ -13,7 +13,7 @@ _2 = _1; // scope 1 at $DIR/lower_intrinsics.rs:+1:34: +1:35 - _0 = transmute::<&T, *const T>(move _2) -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:36 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:53:14: 53:33 +- // + span: $DIR/lower_intrinsics.rs:59:14: 59:33 - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&T) -> *const T {transmute::<&T, *const T>}, val: Value(<ZST>) } + _0 = move _2 as *const T (Transmute); // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:36 + goto -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:36 diff --git a/tests/mir-opt/lower_intrinsics.transmute_to_box_uninhabited.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.transmute_to_box_uninhabited.LowerIntrinsics.diff index aa5d9619d10..e6887a382a2 100644 --- a/tests/mir-opt/lower_intrinsics.transmute_to_box_uninhabited.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.transmute_to_box_uninhabited.LowerIntrinsics.diff @@ -12,7 +12,7 @@ StorageLive(_1); // scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10 - _1 = transmute::<usize, Box<Never>>(const 1_usize) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:70:25: 70:44 +- // + span: $DIR/lower_intrinsics.rs:76:25: 76:44 - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(usize) -> Box<Never> {transmute::<usize, Box<Never>>}, val: Value(<ZST>) } + _1 = const 1_usize as std::boxed::Box<Never> (Transmute); // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52 + goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52 diff --git a/tests/mir-opt/lower_intrinsics.transmute_to_mut_uninhabited.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.transmute_to_mut_uninhabited.LowerIntrinsics.diff index 5fafd45fe85..b2a44b7c561 100644 --- a/tests/mir-opt/lower_intrinsics.transmute_to_mut_uninhabited.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.transmute_to_mut_uninhabited.LowerIntrinsics.diff @@ -12,7 +12,7 @@ StorageLive(_1); // scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10 - _1 = transmute::<usize, &mut Never>(const 1_usize) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:64:25: 64:44 +- // + span: $DIR/lower_intrinsics.rs:70:25: 70:44 - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(usize) -> &mut Never {transmute::<usize, &mut Never>}, val: Value(<ZST>) } + _1 = const 1_usize as &mut Never (Transmute); // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52 + goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:25: +1:52 diff --git a/tests/mir-opt/lower_intrinsics.transmute_to_ref_uninhabited.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.transmute_to_ref_uninhabited.LowerIntrinsics.diff index 08dead13211..c49d3aeff70 100644 --- a/tests/mir-opt/lower_intrinsics.transmute_to_ref_uninhabited.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.transmute_to_ref_uninhabited.LowerIntrinsics.diff @@ -12,7 +12,7 @@ StorageLive(_1); // scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:10 - _1 = transmute::<usize, &Never>(const 1_usize) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:21: +1:48 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:58:21: 58:40 +- // + span: $DIR/lower_intrinsics.rs:64:21: 64:40 - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(usize) -> &Never {transmute::<usize, &Never>}, val: Value(<ZST>) } + _1 = const 1_usize as &Never (Transmute); // scope 0 at $DIR/lower_intrinsics.rs:+1:21: +1:48 + goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:21: +1:48 diff --git a/tests/mir-opt/lower_intrinsics.transmute_uninhabited.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.transmute_uninhabited.LowerIntrinsics.diff index f0b76127dd5..06759d74a32 100644 --- a/tests/mir-opt/lower_intrinsics.transmute_uninhabited.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.transmute_uninhabited.LowerIntrinsics.diff @@ -13,7 +13,7 @@ _2 = _1; // scope 1 at $DIR/lower_intrinsics.rs:+1:47: +1:48 - _0 = transmute::<(), Never>(move _2) -> unwind unreachable; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:49 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:48:14: 48:46 +- // + span: $DIR/lower_intrinsics.rs:54:14: 54:46 - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(()) -> Never {transmute::<(), Never>}, val: Value(<ZST>) } + _0 = move _2 as Never (Transmute); // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:49 + unreachable; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:49 diff --git a/tests/mir-opt/lower_intrinsics.unchecked.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.unchecked.LowerIntrinsics.diff new file mode 100644 index 00000000000..9bb43d850eb --- /dev/null +++ b/tests/mir-opt/lower_intrinsics.unchecked.LowerIntrinsics.diff @@ -0,0 +1,60 @@ +- // MIR for `unchecked` before LowerIntrinsics ++ // MIR for `unchecked` after LowerIntrinsics + + fn unchecked(_1: i32, _2: i32) -> () { + debug a => _1; // in scope 0 at $DIR/lower_intrinsics.rs:+0:25: +0:26 + debug b => _2; // in scope 0 at $DIR/lower_intrinsics.rs:+0:33: +0:34 + let mut _0: (); // return place in scope 0 at $DIR/lower_intrinsics.rs:+0:41: +0:41 + let _3: i32; // in scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:11 + let mut _4: i32; // in scope 0 at $DIR/lower_intrinsics.rs:+1:46: +1:47 + let mut _5: i32; // in scope 0 at $DIR/lower_intrinsics.rs:+1:49: +1:50 + let mut _7: i32; // in scope 0 at $DIR/lower_intrinsics.rs:+2:46: +2:47 + let mut _8: i32; // in scope 0 at $DIR/lower_intrinsics.rs:+2:49: +2:50 + scope 1 { + debug _x => _3; // in scope 1 at $DIR/lower_intrinsics.rs:+1:9: +1:11 + let _6: i32; // in scope 1 at $DIR/lower_intrinsics.rs:+2:9: +2:11 + scope 2 { + debug _y => _6; // in scope 2 at $DIR/lower_intrinsics.rs:+2:9: +2:11 + } + } + + bb0: { + StorageLive(_3); // scope 0 at $DIR/lower_intrinsics.rs:+1:9: +1:11 + StorageLive(_4); // scope 0 at $DIR/lower_intrinsics.rs:+1:46: +1:47 + _4 = _1; // scope 0 at $DIR/lower_intrinsics.rs:+1:46: +1:47 + StorageLive(_5); // scope 0 at $DIR/lower_intrinsics.rs:+1:49: +1:50 + _5 = _2; // scope 0 at $DIR/lower_intrinsics.rs:+1:49: +1:50 +- _3 = unchecked_div::<i32>(move _4, move _5) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:51 +- // mir::Constant +- // + span: $DIR/lower_intrinsics.rs:16:14: 16:45 +- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(i32, i32) -> i32 {unchecked_div::<i32>}, val: Value(<ZST>) } ++ _3 = Div(move _4, move _5); // scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:51 ++ goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:51 + } + + bb1: { + StorageDead(_5); // scope 0 at $DIR/lower_intrinsics.rs:+1:50: +1:51 + StorageDead(_4); // scope 0 at $DIR/lower_intrinsics.rs:+1:50: +1:51 + StorageLive(_6); // scope 1 at $DIR/lower_intrinsics.rs:+2:9: +2:11 + StorageLive(_7); // scope 1 at $DIR/lower_intrinsics.rs:+2:46: +2:47 + _7 = _1; // scope 1 at $DIR/lower_intrinsics.rs:+2:46: +2:47 + StorageLive(_8); // scope 1 at $DIR/lower_intrinsics.rs:+2:49: +2:50 + _8 = _2; // scope 1 at $DIR/lower_intrinsics.rs:+2:49: +2:50 +- _6 = unchecked_rem::<i32>(move _7, move _8) -> [return: bb2, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics.rs:+2:14: +2:51 +- // mir::Constant +- // + span: $DIR/lower_intrinsics.rs:17:14: 17:45 +- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(i32, i32) -> i32 {unchecked_rem::<i32>}, val: Value(<ZST>) } ++ _6 = Rem(move _7, move _8); // scope 1 at $DIR/lower_intrinsics.rs:+2:14: +2:51 ++ goto -> bb2; // scope 1 at $DIR/lower_intrinsics.rs:+2:14: +2:51 + } + + bb2: { + StorageDead(_8); // scope 1 at $DIR/lower_intrinsics.rs:+2:50: +2:51 + StorageDead(_7); // scope 1 at $DIR/lower_intrinsics.rs:+2:50: +2:51 + _0 = const (); // scope 0 at $DIR/lower_intrinsics.rs:+0:41: +3:2 + StorageDead(_6); // scope 1 at $DIR/lower_intrinsics.rs:+3:1: +3:2 + StorageDead(_3); // scope 0 at $DIR/lower_intrinsics.rs:+3:1: +3:2 + return; // scope 0 at $DIR/lower_intrinsics.rs:+3:2: +3:2 + } + } + diff --git a/tests/mir-opt/lower_intrinsics.unreachable.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.unreachable.LowerIntrinsics.diff index 28e45909c33..83c9c508bc0 100644 --- a/tests/mir-opt/lower_intrinsics.unreachable.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.unreachable.LowerIntrinsics.diff @@ -13,7 +13,7 @@ StorageLive(_2); // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:45 - _2 = std::intrinsics::unreachable() -> unwind unreachable; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:45 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:31:14: 31:43 +- // + span: $DIR/lower_intrinsics.rs:37:14: 37:43 - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn() -> ! {std::intrinsics::unreachable}, val: Value(<ZST>) } + unreachable; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:45 } diff --git a/tests/mir-opt/lower_intrinsics.with_overflow.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.with_overflow.LowerIntrinsics.diff index 9cf4fbb88f3..4ae4466a600 100644 --- a/tests/mir-opt/lower_intrinsics.with_overflow.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.with_overflow.LowerIntrinsics.diff @@ -32,7 +32,7 @@ _5 = _2; // scope 0 at $DIR/lower_intrinsics.rs:+1:53: +1:54 - _3 = add_with_overflow::<i32>(move _4, move _5) -> [return: bb1, unwind unreachable]; // scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:55 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:112:14: 112:49 +- // + span: $DIR/lower_intrinsics.rs:118:14: 118:49 - // + literal: Const { ty: extern "rust-intrinsic" fn(i32, i32) -> (i32, bool) {add_with_overflow::<i32>}, val: Value(<ZST>) } + _3 = CheckedAdd(move _4, move _5); // scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:55 + goto -> bb1; // scope 0 at $DIR/lower_intrinsics.rs:+1:14: +1:55 @@ -48,7 +48,7 @@ _8 = _2; // scope 1 at $DIR/lower_intrinsics.rs:+2:53: +2:54 - _6 = sub_with_overflow::<i32>(move _7, move _8) -> [return: bb2, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics.rs:+2:14: +2:55 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:113:14: 113:49 +- // + span: $DIR/lower_intrinsics.rs:119:14: 119:49 - // + literal: Const { ty: extern "rust-intrinsic" fn(i32, i32) -> (i32, bool) {sub_with_overflow::<i32>}, val: Value(<ZST>) } + _6 = CheckedSub(move _7, move _8); // scope 1 at $DIR/lower_intrinsics.rs:+2:14: +2:55 + goto -> bb2; // scope 1 at $DIR/lower_intrinsics.rs:+2:14: +2:55 @@ -64,7 +64,7 @@ _11 = _2; // scope 2 at $DIR/lower_intrinsics.rs:+3:53: +3:54 - _9 = mul_with_overflow::<i32>(move _10, move _11) -> [return: bb3, unwind unreachable]; // scope 2 at $DIR/lower_intrinsics.rs:+3:14: +3:55 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:114:14: 114:49 +- // + span: $DIR/lower_intrinsics.rs:120:14: 120:49 - // + literal: Const { ty: extern "rust-intrinsic" fn(i32, i32) -> (i32, bool) {mul_with_overflow::<i32>}, val: Value(<ZST>) } + _9 = CheckedMul(move _10, move _11); // scope 2 at $DIR/lower_intrinsics.rs:+3:14: +3:55 + goto -> bb3; // scope 2 at $DIR/lower_intrinsics.rs:+3:14: +3:55 diff --git a/tests/mir-opt/lower_intrinsics.write_via_move_string.LowerIntrinsics.diff b/tests/mir-opt/lower_intrinsics.write_via_move_string.LowerIntrinsics.diff index 38d99f661dc..2eabd7f626b 100644 --- a/tests/mir-opt/lower_intrinsics.write_via_move_string.LowerIntrinsics.diff +++ b/tests/mir-opt/lower_intrinsics.write_via_move_string.LowerIntrinsics.diff @@ -17,7 +17,7 @@ _4 = move _2; // scope 1 at $DIR/lower_intrinsics.rs:+1:50: +1:51 - _0 = write_via_move::<String>(move _3, move _4) -> [return: bb1, unwind unreachable]; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:52 - // mir::Constant -- // + span: $DIR/lower_intrinsics.rs:129:14: 129:46 +- // + span: $DIR/lower_intrinsics.rs:135:14: 135:46 - // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(*mut String, String) {write_via_move::<String>}, val: Value(<ZST>) } + (*_3) = move _4; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:52 + goto -> bb1; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:52 diff --git a/tests/mir-opt/pre-codegen/chained_comparison.bitand.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/chained_comparison.bitand.PreCodegen.after.mir new file mode 100644 index 00000000000..40ddf82f4cf --- /dev/null +++ b/tests/mir-opt/pre-codegen/chained_comparison.bitand.PreCodegen.after.mir @@ -0,0 +1,84 @@ +// MIR for `bitand` after PreCodegen + +fn bitand(_1: &Blueprint, _2: &Blueprint) -> bool { + debug a => _1; // in scope 0 at $DIR/chained_comparison.rs:+0:15: +0:16 + debug b => _2; // in scope 0 at $DIR/chained_comparison.rs:+0:30: +0:31 + let mut _0: bool; // return place in scope 0 at $DIR/chained_comparison.rs:+0:48: +0:52 + let mut _3: u32; // in scope 0 at $DIR/chained_comparison.rs:+1:6: +1:22 + let mut _4: u32; // in scope 0 at $DIR/chained_comparison.rs:+1:26: +1:42 + let mut _5: bool; // in scope 0 at $DIR/chained_comparison.rs:+1:5: +1:43 + let mut _6: u32; // in scope 0 at $DIR/chained_comparison.rs:+2:12: +2:21 + let mut _7: u32; // in scope 0 at $DIR/chained_comparison.rs:+2:25: +2:34 + let mut _8: bool; // in scope 0 at $DIR/chained_comparison.rs:+2:11: +2:35 + let mut _9: bool; // in scope 0 at $DIR/chained_comparison.rs:+1:5: +2:35 + let mut _10: u32; // in scope 0 at $DIR/chained_comparison.rs:+3:12: +3:28 + let mut _11: u32; // in scope 0 at $DIR/chained_comparison.rs:+3:32: +3:48 + let mut _12: bool; // in scope 0 at $DIR/chained_comparison.rs:+3:11: +3:49 + let mut _13: bool; // in scope 0 at $DIR/chained_comparison.rs:+1:5: +3:49 + let mut _14: u32; // in scope 0 at $DIR/chained_comparison.rs:+4:12: +4:25 + let mut _15: u32; // in scope 0 at $DIR/chained_comparison.rs:+4:29: +4:42 + let mut _16: bool; // in scope 0 at $DIR/chained_comparison.rs:+4:11: +4:43 + let mut _17: bool; // in scope 0 at $DIR/chained_comparison.rs:+1:5: +4:43 + let mut _18: u32; // in scope 0 at $DIR/chained_comparison.rs:+5:12: +5:21 + let mut _19: u32; // in scope 0 at $DIR/chained_comparison.rs:+5:25: +5:34 + let mut _20: bool; // in scope 0 at $DIR/chained_comparison.rs:+5:11: +5:35 + + bb0: { + StorageLive(_17); // scope 0 at $DIR/chained_comparison.rs:+1:5: +4:43 + StorageLive(_13); // scope 0 at $DIR/chained_comparison.rs:+1:5: +3:49 + StorageLive(_9); // scope 0 at $DIR/chained_comparison.rs:+1:5: +2:35 + StorageLive(_5); // scope 0 at $DIR/chained_comparison.rs:+1:5: +1:43 + StorageLive(_3); // scope 0 at $DIR/chained_comparison.rs:+1:6: +1:22 + _3 = ((*_1).0: u32); // scope 0 at $DIR/chained_comparison.rs:+1:6: +1:22 + StorageLive(_4); // scope 0 at $DIR/chained_comparison.rs:+1:26: +1:42 + _4 = ((*_2).0: u32); // scope 0 at $DIR/chained_comparison.rs:+1:26: +1:42 + _5 = Eq(move _3, move _4); // scope 0 at $DIR/chained_comparison.rs:+1:5: +1:43 + StorageDead(_4); // scope 0 at $DIR/chained_comparison.rs:+1:42: +1:43 + StorageDead(_3); // scope 0 at $DIR/chained_comparison.rs:+1:42: +1:43 + StorageLive(_8); // scope 0 at $DIR/chained_comparison.rs:+2:11: +2:35 + StorageLive(_6); // scope 0 at $DIR/chained_comparison.rs:+2:12: +2:21 + _6 = ((*_1).1: u32); // scope 0 at $DIR/chained_comparison.rs:+2:12: +2:21 + StorageLive(_7); // scope 0 at $DIR/chained_comparison.rs:+2:25: +2:34 + _7 = ((*_2).1: u32); // scope 0 at $DIR/chained_comparison.rs:+2:25: +2:34 + _8 = Eq(move _6, move _7); // scope 0 at $DIR/chained_comparison.rs:+2:11: +2:35 + StorageDead(_7); // scope 0 at $DIR/chained_comparison.rs:+2:34: +2:35 + StorageDead(_6); // scope 0 at $DIR/chained_comparison.rs:+2:34: +2:35 + _9 = BitAnd(move _5, move _8); // scope 0 at $DIR/chained_comparison.rs:+1:5: +2:35 + StorageDead(_8); // scope 0 at $DIR/chained_comparison.rs:+2:34: +2:35 + StorageDead(_5); // scope 0 at $DIR/chained_comparison.rs:+2:34: +2:35 + StorageLive(_12); // scope 0 at $DIR/chained_comparison.rs:+3:11: +3:49 + StorageLive(_10); // scope 0 at $DIR/chained_comparison.rs:+3:12: +3:28 + _10 = ((*_1).2: u32); // scope 0 at $DIR/chained_comparison.rs:+3:12: +3:28 + StorageLive(_11); // scope 0 at $DIR/chained_comparison.rs:+3:32: +3:48 + _11 = ((*_2).2: u32); // scope 0 at $DIR/chained_comparison.rs:+3:32: +3:48 + _12 = Eq(move _10, move _11); // scope 0 at $DIR/chained_comparison.rs:+3:11: +3:49 + StorageDead(_11); // scope 0 at $DIR/chained_comparison.rs:+3:48: +3:49 + StorageDead(_10); // scope 0 at $DIR/chained_comparison.rs:+3:48: +3:49 + _13 = BitAnd(move _9, move _12); // scope 0 at $DIR/chained_comparison.rs:+1:5: +3:49 + StorageDead(_12); // scope 0 at $DIR/chained_comparison.rs:+3:48: +3:49 + StorageDead(_9); // scope 0 at $DIR/chained_comparison.rs:+3:48: +3:49 + StorageLive(_16); // scope 0 at $DIR/chained_comparison.rs:+4:11: +4:43 + StorageLive(_14); // scope 0 at $DIR/chained_comparison.rs:+4:12: +4:25 + _14 = ((*_1).3: u32); // scope 0 at $DIR/chained_comparison.rs:+4:12: +4:25 + StorageLive(_15); // scope 0 at $DIR/chained_comparison.rs:+4:29: +4:42 + _15 = ((*_2).3: u32); // scope 0 at $DIR/chained_comparison.rs:+4:29: +4:42 + _16 = Eq(move _14, move _15); // scope 0 at $DIR/chained_comparison.rs:+4:11: +4:43 + StorageDead(_15); // scope 0 at $DIR/chained_comparison.rs:+4:42: +4:43 + StorageDead(_14); // scope 0 at $DIR/chained_comparison.rs:+4:42: +4:43 + _17 = BitAnd(move _13, move _16); // scope 0 at $DIR/chained_comparison.rs:+1:5: +4:43 + StorageDead(_16); // scope 0 at $DIR/chained_comparison.rs:+4:42: +4:43 + StorageDead(_13); // scope 0 at $DIR/chained_comparison.rs:+4:42: +4:43 + StorageLive(_20); // scope 0 at $DIR/chained_comparison.rs:+5:11: +5:35 + StorageLive(_18); // scope 0 at $DIR/chained_comparison.rs:+5:12: +5:21 + _18 = ((*_1).4: u32); // scope 0 at $DIR/chained_comparison.rs:+5:12: +5:21 + StorageLive(_19); // scope 0 at $DIR/chained_comparison.rs:+5:25: +5:34 + _19 = ((*_2).4: u32); // scope 0 at $DIR/chained_comparison.rs:+5:25: +5:34 + _20 = Eq(move _18, move _19); // scope 0 at $DIR/chained_comparison.rs:+5:11: +5:35 + StorageDead(_19); // scope 0 at $DIR/chained_comparison.rs:+5:34: +5:35 + StorageDead(_18); // scope 0 at $DIR/chained_comparison.rs:+5:34: +5:35 + _0 = BitAnd(move _17, move _20); // scope 0 at $DIR/chained_comparison.rs:+1:5: +5:35 + StorageDead(_20); // scope 0 at $DIR/chained_comparison.rs:+5:34: +5:35 + StorageDead(_17); // scope 0 at $DIR/chained_comparison.rs:+5:34: +5:35 + return; // scope 0 at $DIR/chained_comparison.rs:+6:2: +6:2 + } +} diff --git a/tests/mir-opt/pre-codegen/chained_comparison.naive.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/chained_comparison.naive.PreCodegen.after.mir new file mode 100644 index 00000000000..26ce7fda4ed --- /dev/null +++ b/tests/mir-opt/pre-codegen/chained_comparison.naive.PreCodegen.after.mir @@ -0,0 +1,127 @@ +// MIR for `naive` after PreCodegen + +fn naive(_1: &Blueprint, _2: &Blueprint) -> bool { + debug a => _1; // in scope 0 at $DIR/chained_comparison.rs:+0:14: +0:15 + debug b => _2; // in scope 0 at $DIR/chained_comparison.rs:+0:29: +0:30 + let mut _0: bool; // return place in scope 0 at $DIR/chained_comparison.rs:+0:47: +0:51 + let mut _3: u32; // in scope 0 at $DIR/chained_comparison.rs:+1:6: +1:22 + let mut _4: u32; // in scope 0 at $DIR/chained_comparison.rs:+1:26: +1:42 + let mut _5: bool; // in scope 0 at $DIR/chained_comparison.rs:+1:5: +1:43 + let mut _6: u32; // in scope 0 at $DIR/chained_comparison.rs:+2:13: +2:22 + let mut _7: u32; // in scope 0 at $DIR/chained_comparison.rs:+2:26: +2:35 + let mut _8: bool; // in scope 0 at $DIR/chained_comparison.rs:+2:12: +2:36 + let mut _9: bool; // in scope 0 at $DIR/chained_comparison.rs:+1:5: +2:36 + let mut _10: u32; // in scope 0 at $DIR/chained_comparison.rs:+3:13: +3:29 + let mut _11: u32; // in scope 0 at $DIR/chained_comparison.rs:+3:33: +3:49 + let mut _12: bool; // in scope 0 at $DIR/chained_comparison.rs:+3:12: +3:50 + let mut _13: bool; // in scope 0 at $DIR/chained_comparison.rs:+1:5: +3:50 + let mut _14: u32; // in scope 0 at $DIR/chained_comparison.rs:+4:13: +4:26 + let mut _15: u32; // in scope 0 at $DIR/chained_comparison.rs:+4:30: +4:43 + let mut _16: bool; // in scope 0 at $DIR/chained_comparison.rs:+4:12: +4:44 + let mut _17: bool; // in scope 0 at $DIR/chained_comparison.rs:+1:5: +4:44 + let mut _18: u32; // in scope 0 at $DIR/chained_comparison.rs:+5:13: +5:22 + let mut _19: u32; // in scope 0 at $DIR/chained_comparison.rs:+5:26: +5:35 + let mut _20: bool; // in scope 0 at $DIR/chained_comparison.rs:+5:12: +5:36 + + bb0: { + StorageLive(_17); // scope 0 at $DIR/chained_comparison.rs:+1:5: +4:44 + StorageLive(_13); // scope 0 at $DIR/chained_comparison.rs:+1:5: +3:50 + StorageLive(_9); // scope 0 at $DIR/chained_comparison.rs:+1:5: +2:36 + StorageLive(_5); // scope 0 at $DIR/chained_comparison.rs:+1:5: +1:43 + StorageLive(_3); // scope 0 at $DIR/chained_comparison.rs:+1:6: +1:22 + _3 = ((*_1).0: u32); // scope 0 at $DIR/chained_comparison.rs:+1:6: +1:22 + StorageLive(_4); // scope 0 at $DIR/chained_comparison.rs:+1:26: +1:42 + _4 = ((*_2).0: u32); // scope 0 at $DIR/chained_comparison.rs:+1:26: +1:42 + _5 = Eq(move _3, move _4); // scope 0 at $DIR/chained_comparison.rs:+1:5: +1:43 + StorageDead(_4); // scope 0 at $DIR/chained_comparison.rs:+1:42: +1:43 + StorageDead(_3); // scope 0 at $DIR/chained_comparison.rs:+1:42: +1:43 + switchInt(move _5) -> [0: bb1, otherwise: bb2]; // scope 0 at $DIR/chained_comparison.rs:+1:5: +2:36 + } + + bb1: { + StorageDead(_8); // scope 0 at $DIR/chained_comparison.rs:+2:35: +2:36 + StorageDead(_5); // scope 0 at $DIR/chained_comparison.rs:+2:35: +2:36 + goto -> bb3; // scope 0 at $DIR/chained_comparison.rs:+1:5: +2:36 + } + + bb2: { + StorageLive(_8); // scope 0 at $DIR/chained_comparison.rs:+2:12: +2:36 + StorageLive(_6); // scope 0 at $DIR/chained_comparison.rs:+2:13: +2:22 + _6 = ((*_1).1: u32); // scope 0 at $DIR/chained_comparison.rs:+2:13: +2:22 + StorageLive(_7); // scope 0 at $DIR/chained_comparison.rs:+2:26: +2:35 + _7 = ((*_2).1: u32); // scope 0 at $DIR/chained_comparison.rs:+2:26: +2:35 + _8 = Eq(move _6, move _7); // scope 0 at $DIR/chained_comparison.rs:+2:12: +2:36 + StorageDead(_7); // scope 0 at $DIR/chained_comparison.rs:+2:35: +2:36 + StorageDead(_6); // scope 0 at $DIR/chained_comparison.rs:+2:35: +2:36 + _9 = move _8; // scope 0 at $DIR/chained_comparison.rs:+1:5: +2:36 + StorageDead(_8); // scope 0 at $DIR/chained_comparison.rs:+2:35: +2:36 + StorageDead(_5); // scope 0 at $DIR/chained_comparison.rs:+2:35: +2:36 + switchInt(move _9) -> [0: bb3, otherwise: bb4]; // scope 0 at $DIR/chained_comparison.rs:+1:5: +3:50 + } + + bb3: { + StorageDead(_12); // scope 0 at $DIR/chained_comparison.rs:+3:49: +3:50 + StorageDead(_9); // scope 0 at $DIR/chained_comparison.rs:+3:49: +3:50 + goto -> bb5; // scope 0 at $DIR/chained_comparison.rs:+1:5: +3:50 + } + + bb4: { + StorageLive(_12); // scope 0 at $DIR/chained_comparison.rs:+3:12: +3:50 + StorageLive(_10); // scope 0 at $DIR/chained_comparison.rs:+3:13: +3:29 + _10 = ((*_1).2: u32); // scope 0 at $DIR/chained_comparison.rs:+3:13: +3:29 + StorageLive(_11); // scope 0 at $DIR/chained_comparison.rs:+3:33: +3:49 + _11 = ((*_2).2: u32); // scope 0 at $DIR/chained_comparison.rs:+3:33: +3:49 + _12 = Eq(move _10, move _11); // scope 0 at $DIR/chained_comparison.rs:+3:12: +3:50 + StorageDead(_11); // scope 0 at $DIR/chained_comparison.rs:+3:49: +3:50 + StorageDead(_10); // scope 0 at $DIR/chained_comparison.rs:+3:49: +3:50 + _13 = move _12; // scope 0 at $DIR/chained_comparison.rs:+1:5: +3:50 + StorageDead(_12); // scope 0 at $DIR/chained_comparison.rs:+3:49: +3:50 + StorageDead(_9); // scope 0 at $DIR/chained_comparison.rs:+3:49: +3:50 + switchInt(move _13) -> [0: bb5, otherwise: bb6]; // scope 0 at $DIR/chained_comparison.rs:+1:5: +4:44 + } + + bb5: { + StorageDead(_16); // scope 0 at $DIR/chained_comparison.rs:+4:43: +4:44 + StorageDead(_13); // scope 0 at $DIR/chained_comparison.rs:+4:43: +4:44 + goto -> bb7; // scope 0 at $DIR/chained_comparison.rs:+1:5: +4:44 + } + + bb6: { + StorageLive(_16); // scope 0 at $DIR/chained_comparison.rs:+4:12: +4:44 + StorageLive(_14); // scope 0 at $DIR/chained_comparison.rs:+4:13: +4:26 + _14 = ((*_1).3: u32); // scope 0 at $DIR/chained_comparison.rs:+4:13: +4:26 + StorageLive(_15); // scope 0 at $DIR/chained_comparison.rs:+4:30: +4:43 + _15 = ((*_2).3: u32); // scope 0 at $DIR/chained_comparison.rs:+4:30: +4:43 + _16 = Eq(move _14, move _15); // scope 0 at $DIR/chained_comparison.rs:+4:12: +4:44 + StorageDead(_15); // scope 0 at $DIR/chained_comparison.rs:+4:43: +4:44 + StorageDead(_14); // scope 0 at $DIR/chained_comparison.rs:+4:43: +4:44 + _17 = move _16; // scope 0 at $DIR/chained_comparison.rs:+1:5: +4:44 + StorageDead(_16); // scope 0 at $DIR/chained_comparison.rs:+4:43: +4:44 + StorageDead(_13); // scope 0 at $DIR/chained_comparison.rs:+4:43: +4:44 + switchInt(move _17) -> [0: bb7, otherwise: bb8]; // scope 0 at $DIR/chained_comparison.rs:+1:5: +5:36 + } + + bb7: { + _0 = const false; // scope 0 at $DIR/chained_comparison.rs:+1:5: +5:36 + goto -> bb9; // scope 0 at $DIR/chained_comparison.rs:+1:5: +5:36 + } + + bb8: { + StorageLive(_20); // scope 0 at $DIR/chained_comparison.rs:+5:12: +5:36 + StorageLive(_18); // scope 0 at $DIR/chained_comparison.rs:+5:13: +5:22 + _18 = ((*_1).4: u32); // scope 0 at $DIR/chained_comparison.rs:+5:13: +5:22 + StorageLive(_19); // scope 0 at $DIR/chained_comparison.rs:+5:26: +5:35 + _19 = ((*_2).4: u32); // scope 0 at $DIR/chained_comparison.rs:+5:26: +5:35 + _20 = Eq(move _18, move _19); // scope 0 at $DIR/chained_comparison.rs:+5:12: +5:36 + StorageDead(_19); // scope 0 at $DIR/chained_comparison.rs:+5:35: +5:36 + StorageDead(_18); // scope 0 at $DIR/chained_comparison.rs:+5:35: +5:36 + _0 = move _20; // scope 0 at $DIR/chained_comparison.rs:+1:5: +5:36 + goto -> bb9; // scope 0 at $DIR/chained_comparison.rs:+1:5: +5:36 + } + + bb9: { + StorageDead(_20); // scope 0 at $DIR/chained_comparison.rs:+5:35: +5:36 + StorageDead(_17); // scope 0 at $DIR/chained_comparison.rs:+5:35: +5:36 + return; // scope 0 at $DIR/chained_comparison.rs:+6:2: +6:2 + } +} diff --git a/tests/mir-opt/pre-codegen/chained_comparison.returning.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/chained_comparison.returning.PreCodegen.after.mir new file mode 100644 index 00000000000..7560e1e26ce --- /dev/null +++ b/tests/mir-opt/pre-codegen/chained_comparison.returning.PreCodegen.after.mir @@ -0,0 +1,126 @@ +// MIR for `returning` after PreCodegen + +fn returning(_1: &Blueprint, _2: &Blueprint) -> bool { + debug a => _1; // in scope 0 at $DIR/chained_comparison.rs:+0:18: +0:19 + debug b => _2; // in scope 0 at $DIR/chained_comparison.rs:+0:33: +0:34 + let mut _0: bool; // return place in scope 0 at $DIR/chained_comparison.rs:+0:51: +0:55 + let mut _3: u32; // in scope 0 at $DIR/chained_comparison.rs:+1:8: +1:24 + let mut _4: u32; // in scope 0 at $DIR/chained_comparison.rs:+1:28: +1:44 + let mut _5: bool; // in scope 0 at $DIR/chained_comparison.rs:+1:8: +1:44 + let mut _6: u32; // in scope 0 at $DIR/chained_comparison.rs:+4:8: +4:17 + let mut _7: u32; // in scope 0 at $DIR/chained_comparison.rs:+4:21: +4:30 + let mut _8: bool; // in scope 0 at $DIR/chained_comparison.rs:+4:8: +4:30 + let mut _9: u32; // in scope 0 at $DIR/chained_comparison.rs:+7:8: +7:24 + let mut _10: u32; // in scope 0 at $DIR/chained_comparison.rs:+7:28: +7:44 + let mut _11: bool; // in scope 0 at $DIR/chained_comparison.rs:+7:8: +7:44 + let mut _12: u32; // in scope 0 at $DIR/chained_comparison.rs:+10:8: +10:21 + let mut _13: u32; // in scope 0 at $DIR/chained_comparison.rs:+10:25: +10:38 + let mut _14: bool; // in scope 0 at $DIR/chained_comparison.rs:+10:8: +10:38 + let mut _15: u32; // in scope 0 at $DIR/chained_comparison.rs:+13:8: +13:17 + let mut _16: u32; // in scope 0 at $DIR/chained_comparison.rs:+13:21: +13:30 + let mut _17: bool; // in scope 0 at $DIR/chained_comparison.rs:+13:8: +13:30 + + bb0: { + StorageLive(_5); // scope 0 at $DIR/chained_comparison.rs:+1:8: +1:44 + StorageLive(_3); // scope 0 at $DIR/chained_comparison.rs:+1:8: +1:24 + _3 = ((*_1).0: u32); // scope 0 at $DIR/chained_comparison.rs:+1:8: +1:24 + StorageLive(_4); // scope 0 at $DIR/chained_comparison.rs:+1:28: +1:44 + _4 = ((*_2).0: u32); // scope 0 at $DIR/chained_comparison.rs:+1:28: +1:44 + _5 = Ne(move _3, move _4); // scope 0 at $DIR/chained_comparison.rs:+1:8: +1:44 + StorageDead(_4); // scope 0 at $DIR/chained_comparison.rs:+1:43: +1:44 + StorageDead(_3); // scope 0 at $DIR/chained_comparison.rs:+1:43: +1:44 + switchInt(move _5) -> [0: bb1, otherwise: bb10]; // scope 0 at $DIR/chained_comparison.rs:+1:8: +1:44 + } + + bb1: { + StorageDead(_5); // scope 0 at $DIR/chained_comparison.rs:+3:5: +3:6 + StorageLive(_8); // scope 0 at $DIR/chained_comparison.rs:+4:8: +4:30 + StorageLive(_6); // scope 0 at $DIR/chained_comparison.rs:+4:8: +4:17 + _6 = ((*_1).1: u32); // scope 0 at $DIR/chained_comparison.rs:+4:8: +4:17 + StorageLive(_7); // scope 0 at $DIR/chained_comparison.rs:+4:21: +4:30 + _7 = ((*_2).1: u32); // scope 0 at $DIR/chained_comparison.rs:+4:21: +4:30 + _8 = Ne(move _6, move _7); // scope 0 at $DIR/chained_comparison.rs:+4:8: +4:30 + StorageDead(_7); // scope 0 at $DIR/chained_comparison.rs:+4:29: +4:30 + StorageDead(_6); // scope 0 at $DIR/chained_comparison.rs:+4:29: +4:30 + switchInt(move _8) -> [0: bb2, otherwise: bb9]; // scope 0 at $DIR/chained_comparison.rs:+4:8: +4:30 + } + + bb2: { + StorageDead(_8); // scope 0 at $DIR/chained_comparison.rs:+6:5: +6:6 + StorageLive(_11); // scope 0 at $DIR/chained_comparison.rs:+7:8: +7:44 + StorageLive(_9); // scope 0 at $DIR/chained_comparison.rs:+7:8: +7:24 + _9 = ((*_1).2: u32); // scope 0 at $DIR/chained_comparison.rs:+7:8: +7:24 + StorageLive(_10); // scope 0 at $DIR/chained_comparison.rs:+7:28: +7:44 + _10 = ((*_2).2: u32); // scope 0 at $DIR/chained_comparison.rs:+7:28: +7:44 + _11 = Ne(move _9, move _10); // scope 0 at $DIR/chained_comparison.rs:+7:8: +7:44 + StorageDead(_10); // scope 0 at $DIR/chained_comparison.rs:+7:43: +7:44 + StorageDead(_9); // scope 0 at $DIR/chained_comparison.rs:+7:43: +7:44 + switchInt(move _11) -> [0: bb3, otherwise: bb8]; // scope 0 at $DIR/chained_comparison.rs:+7:8: +7:44 + } + + bb3: { + StorageDead(_11); // scope 0 at $DIR/chained_comparison.rs:+9:5: +9:6 + StorageLive(_14); // scope 0 at $DIR/chained_comparison.rs:+10:8: +10:38 + StorageLive(_12); // scope 0 at $DIR/chained_comparison.rs:+10:8: +10:21 + _12 = ((*_1).3: u32); // scope 0 at $DIR/chained_comparison.rs:+10:8: +10:21 + StorageLive(_13); // scope 0 at $DIR/chained_comparison.rs:+10:25: +10:38 + _13 = ((*_2).3: u32); // scope 0 at $DIR/chained_comparison.rs:+10:25: +10:38 + _14 = Ne(move _12, move _13); // scope 0 at $DIR/chained_comparison.rs:+10:8: +10:38 + StorageDead(_13); // scope 0 at $DIR/chained_comparison.rs:+10:37: +10:38 + StorageDead(_12); // scope 0 at $DIR/chained_comparison.rs:+10:37: +10:38 + switchInt(move _14) -> [0: bb4, otherwise: bb7]; // scope 0 at $DIR/chained_comparison.rs:+10:8: +10:38 + } + + bb4: { + StorageDead(_14); // scope 0 at $DIR/chained_comparison.rs:+12:5: +12:6 + StorageLive(_17); // scope 0 at $DIR/chained_comparison.rs:+13:8: +13:30 + StorageLive(_15); // scope 0 at $DIR/chained_comparison.rs:+13:8: +13:17 + _15 = ((*_1).4: u32); // scope 0 at $DIR/chained_comparison.rs:+13:8: +13:17 + StorageLive(_16); // scope 0 at $DIR/chained_comparison.rs:+13:21: +13:30 + _16 = ((*_2).4: u32); // scope 0 at $DIR/chained_comparison.rs:+13:21: +13:30 + _17 = Ne(move _15, move _16); // scope 0 at $DIR/chained_comparison.rs:+13:8: +13:30 + StorageDead(_16); // scope 0 at $DIR/chained_comparison.rs:+13:29: +13:30 + StorageDead(_15); // scope 0 at $DIR/chained_comparison.rs:+13:29: +13:30 + switchInt(move _17) -> [0: bb5, otherwise: bb6]; // scope 0 at $DIR/chained_comparison.rs:+13:8: +13:30 + } + + bb5: { + StorageDead(_17); // scope 0 at $DIR/chained_comparison.rs:+15:5: +15:6 + _0 = const true; // scope 0 at $DIR/chained_comparison.rs:+16:5: +16:9 + goto -> bb11; // scope 0 at $DIR/chained_comparison.rs:+17:2: +17:2 + } + + bb6: { + _0 = const false; // scope 0 at $DIR/chained_comparison.rs:+14:16: +14:21 + StorageDead(_17); // scope 0 at $DIR/chained_comparison.rs:+15:5: +15:6 + goto -> bb11; // scope 0 at no-location + } + + bb7: { + _0 = const false; // scope 0 at $DIR/chained_comparison.rs:+11:16: +11:21 + StorageDead(_14); // scope 0 at $DIR/chained_comparison.rs:+12:5: +12:6 + goto -> bb11; // scope 0 at no-location + } + + bb8: { + _0 = const false; // scope 0 at $DIR/chained_comparison.rs:+8:16: +8:21 + StorageDead(_11); // scope 0 at $DIR/chained_comparison.rs:+9:5: +9:6 + goto -> bb11; // scope 0 at no-location + } + + bb9: { + _0 = const false; // scope 0 at $DIR/chained_comparison.rs:+5:16: +5:21 + StorageDead(_8); // scope 0 at $DIR/chained_comparison.rs:+6:5: +6:6 + goto -> bb11; // scope 0 at no-location + } + + bb10: { + _0 = const false; // scope 0 at $DIR/chained_comparison.rs:+2:16: +2:21 + StorageDead(_5); // scope 0 at $DIR/chained_comparison.rs:+3:5: +3:6 + goto -> bb11; // scope 0 at no-location + } + + bb11: { + return; // scope 0 at $DIR/chained_comparison.rs:+17:2: +17:2 + } +} diff --git a/tests/mir-opt/pre-codegen/chained_comparison.rs b/tests/mir-opt/pre-codegen/chained_comparison.rs new file mode 100644 index 00000000000..f7879140f81 --- /dev/null +++ b/tests/mir-opt/pre-codegen/chained_comparison.rs @@ -0,0 +1,51 @@ +// compile-flags: -O -Zmir-opt-level=2 -Cdebuginfo=2 +// ignore-debug + +#![crate_type = "lib"] + +pub struct Blueprint { + pub fuel_tank_size: u32, + pub payload: u32, + pub wheel_diameter: u32, + pub wheel_width: u32, + pub storage: u32, +} + +pub fn naive(a: &Blueprint, b: &Blueprint) -> bool { + (a.fuel_tank_size == b.fuel_tank_size) + && (a.payload == b.payload) + && (a.wheel_diameter == b.wheel_diameter) + && (a.wheel_width == b.wheel_width) + && (a.storage == b.storage) +} + +pub fn bitand(a: &Blueprint, b: &Blueprint) -> bool { + (a.fuel_tank_size == b.fuel_tank_size) + & (a.payload == b.payload) + & (a.wheel_diameter == b.wheel_diameter) + & (a.wheel_width == b.wheel_width) + & (a.storage == b.storage) +} + +pub fn returning(a: &Blueprint, b: &Blueprint) -> bool { + if a.fuel_tank_size != b.fuel_tank_size { + return false; + } + if a.payload != b.payload { + return false; + } + if a.wheel_diameter != b.wheel_diameter { + return false; + } + if a.wheel_width != b.wheel_width { + return false; + } + if a.storage != b.storage { + return false; + } + true +} + +// EMIT_MIR chained_comparison.naive.PreCodegen.after.mir +// EMIT_MIR chained_comparison.bitand.PreCodegen.after.mir +// EMIT_MIR chained_comparison.returning.PreCodegen.after.mir diff --git a/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.mir new file mode 100644 index 00000000000..dff3cbbe76d --- /dev/null +++ b/tests/mir-opt/pre-codegen/checked_ops.checked_shl.PreCodegen.after.mir @@ -0,0 +1,144 @@ +// MIR for `checked_shl` after PreCodegen + +fn checked_shl(_1: u32, _2: u32) -> Option<u32> { + debug x => _1; // in scope 0 at $DIR/checked_ops.rs:+0:20: +0:21 + debug rhs => _2; // in scope 0 at $DIR/checked_ops.rs:+0:28: +0:31 + let mut _0: std::option::Option<u32>; // return place in scope 0 at $DIR/checked_ops.rs:+0:41: +0:52 + scope 1 (inlined core::num::<impl u32>::checked_shl) { // at $DIR/checked_ops.rs:16:7: 16:23 + debug self => _1; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + debug rhs => _2; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + let mut _11: u32; // in scope 1 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + let mut _12: bool; // in scope 1 at $SRC_DIR/core/src/num/mod.rs:LL:COL + scope 2 { + debug a => _11; // in scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + debug b => _10; // in scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + } + scope 3 (inlined core::num::<impl u32>::overflowing_shl) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + debug self => _1; // in scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + debug rhs => _2; // in scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + let mut _9: u32; // in scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + let mut _10: bool; // in scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + scope 4 (inlined core::num::<impl u32>::wrapping_shl) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + debug self => _1; // in scope 4 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + debug rhs => _2; // in scope 4 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + let mut _3: u32; // in scope 4 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + let mut _4: u32; // in scope 4 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + scope 5 { + scope 6 (inlined core::num::<impl u32>::unchecked_shl) { // at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + debug self => _1; // in scope 6 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + debug rhs => _4; // in scope 6 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + let mut _8: u32; // in scope 6 at $SRC_DIR/core/src/num/mod.rs:LL:COL + scope 7 { + scope 8 (inlined core::num::<impl u32>::unchecked_shl::conv) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL + debug x => _4; // in scope 8 at $SRC_DIR/core/src/num/mod.rs:LL:COL + let mut _5: std::result::Result<u32, std::convert::Infallible>; // in scope 8 at $SRC_DIR/core/src/num/mod.rs:LL:COL + let mut _7: std::option::Option<u32>; // in scope 8 at $SRC_DIR/core/src/num/mod.rs:LL:COL + scope 9 { + scope 10 (inlined <u32 as TryInto<u32>>::try_into) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL + debug self => _4; // in scope 10 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + scope 11 (inlined <u32 as TryFrom<u32>>::try_from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL + debug value => _4; // in scope 11 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + scope 12 (inlined <u32 as Into<u32>>::into) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL + debug self => _4; // in scope 12 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + scope 13 (inlined <u32 as From<u32>>::from) { // at $SRC_DIR/core/src/convert/mod.rs:LL:COL + debug t => _4; // in scope 13 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + } + } + } + } + scope 14 (inlined Result::<u32, Infallible>::ok) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL + debug self => _5; // in scope 14 at $SRC_DIR/core/src/result.rs:LL:COL + let _6: u32; // in scope 14 at $SRC_DIR/core/src/result.rs:LL:COL + scope 15 { + debug x => _6; // in scope 15 at $SRC_DIR/core/src/result.rs:LL:COL + } + } + scope 16 (inlined #[track_caller] Option::<u32>::unwrap_unchecked) { // at $SRC_DIR/core/src/num/mod.rs:LL:COL + debug self => _7; // in scope 16 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _13: &std::option::Option<u32>; // in scope 16 at $SRC_DIR/core/src/option.rs:LL:COL + scope 17 { + debug val => _8; // in scope 17 at $SRC_DIR/core/src/option.rs:LL:COL + } + scope 18 { + scope 20 (inlined unreachable_unchecked) { // at $SRC_DIR/core/src/option.rs:LL:COL + scope 21 { + scope 22 (inlined unreachable_unchecked::runtime) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL + } + } + } + } + scope 19 (inlined Option::<u32>::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL + debug self => _13; // in scope 19 at $SRC_DIR/core/src/option.rs:LL:COL + } + } + } + } + } + } + } + } + } + } + + bb0: { + StorageLive(_10); // scope 0 at $DIR/checked_ops.rs:+1:7: +1:23 + StorageLive(_11); // scope 0 at $DIR/checked_ops.rs:+1:7: +1:23 + StorageLive(_9); // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + StorageLive(_4); // scope 5 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + StorageLive(_3); // scope 5 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + _3 = const 31_u32; // scope 5 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + _4 = BitAnd(_2, move _3); // scope 5 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + StorageDead(_3); // scope 5 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + StorageLive(_8); // scope 7 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageLive(_7); // scope 9 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageLive(_5); // scope 9 at $SRC_DIR/core/src/num/mod.rs:LL:COL + _5 = Result::<u32, Infallible>::Ok(_4); // scope 11 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + StorageLive(_6); // scope 9 at $SRC_DIR/core/src/num/mod.rs:LL:COL + _6 = move ((_5 as Ok).0: u32); // scope 14 at $SRC_DIR/core/src/result.rs:LL:COL + _7 = Option::<u32>::Some(move _6); // scope 15 at $SRC_DIR/core/src/result.rs:LL:COL + StorageDead(_6); // scope 9 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageDead(_5); // scope 9 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageLive(_13); // scope 9 at $SRC_DIR/core/src/num/mod.rs:LL:COL + _8 = move ((_7 as Some).0: u32); // scope 16 at $SRC_DIR/core/src/option.rs:LL:COL + StorageDead(_13); // scope 9 at $SRC_DIR/core/src/num/mod.rs:LL:COL + StorageDead(_7); // scope 9 at $SRC_DIR/core/src/num/mod.rs:LL:COL + _9 = unchecked_shl::<u32>(_1, move _8) -> [return: bb1, unwind unreachable]; // scope 7 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + // mir::Constant + // + span: $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(u32, u32) -> u32 {unchecked_shl::<u32>}, val: Value(<ZST>) } + } + + bb1: { + StorageDead(_8); // scope 7 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + StorageDead(_4); // scope 5 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + _10 = Ge(_2, const _); // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + _11 = move _9; // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + StorageDead(_9); // scope 3 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + StorageLive(_12); // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL + _12 = unlikely(_10) -> [return: bb2, unwind unreachable]; // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL + // mir::Constant + // + span: $SRC_DIR/core/src/num/mod.rs:LL:COL + // + literal: Const { ty: extern "rust-intrinsic" fn(bool) -> bool {unlikely}, val: Value(<ZST>) } + } + + bb2: { + switchInt(move _12) -> [0: bb3, otherwise: bb4]; // scope 2 at $SRC_DIR/core/src/num/mod.rs:LL:COL + } + + bb3: { + _0 = Option::<u32>::Some(_11); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + goto -> bb5; // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + } + + bb4: { + _0 = Option::<u32>::None; // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + goto -> bb5; // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + } + + bb5: { + StorageDead(_12); // scope 2 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + StorageDead(_11); // scope 0 at $DIR/checked_ops.rs:+1:7: +1:23 + StorageDead(_10); // scope 0 at $DIR/checked_ops.rs:+1:7: +1:23 + return; // scope 0 at $DIR/checked_ops.rs:+2:2: +2:2 + } +} diff --git a/tests/mir-opt/pre-codegen/checked_ops.rs b/tests/mir-opt/pre-codegen/checked_ops.rs new file mode 100644 index 00000000000..dee43b0c6f8 --- /dev/null +++ b/tests/mir-opt/pre-codegen/checked_ops.rs @@ -0,0 +1,17 @@ +// compile-flags: -O -Zmir-opt-level=2 -Cdebuginfo=2 +// needs-unwind +// ignore-debug +// only-x86_64 + +#![crate_type = "lib"] +#![feature(step_trait)] + +// EMIT_MIR checked_ops.step_forward.PreCodegen.after.mir +pub fn step_forward(x: u32, n: usize) -> u32 { + std::iter::Step::forward(x, n) +} + +// EMIT_MIR checked_ops.checked_shl.PreCodegen.after.mir +pub fn checked_shl(x: u32, rhs: u32) -> Option<u32> { + x.checked_shl(rhs) +} diff --git a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.mir new file mode 100644 index 00000000000..78f68e8ffe6 --- /dev/null +++ b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.mir @@ -0,0 +1,64 @@ +// MIR for `step_forward` after PreCodegen + +fn step_forward(_1: u32, _2: usize) -> u32 { + debug x => _1; // in scope 0 at $DIR/checked_ops.rs:+0:21: +0:22 + debug n => _2; // in scope 0 at $DIR/checked_ops.rs:+0:29: +0:30 + let mut _0: u32; // return place in scope 0 at $DIR/checked_ops.rs:+0:42: +0:45 + scope 1 (inlined <u32 as Step>::forward) { // at $DIR/checked_ops.rs:11:5: 11:35 + debug start => _1; // in scope 1 at $SRC_DIR/core/src/iter/range.rs:LL:COL + debug n => _2; // in scope 1 at $SRC_DIR/core/src/iter/range.rs:LL:COL + let _3: std::option::Option<u32>; // in scope 1 at $SRC_DIR/core/src/iter/range.rs:LL:COL + let mut _4: &std::option::Option<u32>; // in scope 1 at $SRC_DIR/core/src/iter/range.rs:LL:COL + let mut _7: bool; // in scope 1 at $SRC_DIR/core/src/iter/range.rs:LL:COL + let mut _8: u32; // in scope 1 at $SRC_DIR/core/src/iter/range.rs:LL:COL + scope 2 { + } + scope 3 (inlined Option::<u32>::is_none) { // at $SRC_DIR/core/src/iter/range.rs:LL:COL + debug self => _4; // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _6: bool; // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + scope 4 (inlined Option::<u32>::is_some) { // at $SRC_DIR/core/src/option.rs:LL:COL + debug self => _4; // in scope 4 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _5: isize; // in scope 4 at $SRC_DIR/core/src/option.rs:LL:COL + } + } + scope 5 (inlined core::num::<impl u32>::wrapping_add) { // at $SRC_DIR/core/src/iter/range.rs:LL:COL + debug self => _1; // in scope 5 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + debug rhs => _8; // in scope 5 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + } + } + + bb0: { + StorageLive(_7); // scope 1 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageLive(_4); // scope 1 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageLive(_3); // scope 1 at $SRC_DIR/core/src/iter/range.rs:LL:COL + _3 = <u32 as Step>::forward_checked(_1, _2) -> bb1; // scope 1 at $SRC_DIR/core/src/iter/range.rs:LL:COL + // mir::Constant + // + span: $SRC_DIR/core/src/iter/range.rs:LL:COL + // + literal: Const { ty: fn(u32, usize) -> Option<u32> {<u32 as Step>::forward_checked}, val: Value(<ZST>) } + } + + bb1: { + _4 = &_3; // scope 1 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageLive(_6); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + _5 = discriminant((*_4)); // scope 4 at $SRC_DIR/core/src/option.rs:LL:COL + _6 = Eq(_5, const 1_isize); // scope 4 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _7 = Not(move _6); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + StorageDead(_6); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + StorageDead(_3); // scope 1 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageDead(_4); // scope 1 at $SRC_DIR/core/src/iter/range.rs:LL:COL + switchInt(move _7) -> [0: bb3, otherwise: bb2]; // scope 1 at $SRC_DIR/core/src/iter/range.rs:LL:COL + } + + bb2: { + assert(!const true, "attempt to compute `{} + {}`, which would overflow", const _, const 1_u32) -> bb3; // scope 1 at $SRC_DIR/core/src/iter/range.rs:LL:COL + } + + bb3: { + StorageDead(_7); // scope 1 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageLive(_8); // scope 1 at $SRC_DIR/core/src/iter/range.rs:LL:COL + _8 = _2 as u32 (IntToInt); // scope 1 at $SRC_DIR/core/src/iter/range.rs:LL:COL + _0 = Add(_1, _8); // scope 5 at $SRC_DIR/core/src/num/uint_macros.rs:LL:COL + StorageDead(_8); // scope 1 at $SRC_DIR/core/src/iter/range.rs:LL:COL + return; // scope 0 at $DIR/checked_ops.rs:+2:2: +2:2 + } +} diff --git a/tests/mir-opt/pre-codegen/loops.filter_mapped.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.filter_mapped.PreCodegen.after.mir new file mode 100644 index 00000000000..dce9feddfc5 --- /dev/null +++ b/tests/mir-opt/pre-codegen/loops.filter_mapped.PreCodegen.after.mir @@ -0,0 +1,102 @@ +// MIR for `filter_mapped` after PreCodegen + +fn filter_mapped(_1: impl Iterator<Item = T>, _2: impl Fn(T) -> Option<U>) -> () { + debug iter => _1; // in scope 0 at $DIR/loops.rs:+0:28: +0:32 + debug f => _2; // in scope 0 at $DIR/loops.rs:+0:59: +0:60 + let mut _0: (); // return place in scope 0 at $DIR/loops.rs:+0:87: +0:87 + let mut _3: std::iter::FilterMap<impl Iterator<Item = T>, impl Fn(T) -> Option<U>>; // in scope 0 at $DIR/loops.rs:+1:14: +1:32 + let mut _4: std::iter::FilterMap<impl Iterator<Item = T>, impl Fn(T) -> Option<U>>; // in scope 0 at $DIR/loops.rs:+1:14: +1:32 + let mut _5: std::iter::FilterMap<impl Iterator<Item = T>, impl Fn(T) -> Option<U>>; // in scope 0 at $DIR/loops.rs:+1:14: +1:32 + let mut _6: &mut std::iter::FilterMap<impl Iterator<Item = T>, impl Fn(T) -> Option<U>>; // in scope 0 at $DIR/loops.rs:+1:14: +1:32 + let mut _9: std::option::Option<U>; // in scope 0 at $DIR/loops.rs:+1:14: +1:32 + let mut _10: isize; // in scope 0 at $DIR/loops.rs:+1:5: +3:6 + let _12: (); // in scope 0 at $DIR/loops.rs:+1:14: +1:32 + scope 1 { + debug iter => _5; // in scope 1 at $DIR/loops.rs:+1:14: +1:32 + let _11: U; // in scope 1 at $DIR/loops.rs:+1:9: +1:10 + scope 2 { + debug x => _11; // in scope 2 at $DIR/loops.rs:+1:9: +1:10 + } + scope 4 (inlined <FilterMap<impl Iterator<Item = T>, impl Fn(T) -> Option<U>> as Iterator>::next) { // at $DIR/loops.rs:20:14: 20:32 + debug self => _6; // in scope 4 at $SRC_DIR/core/src/iter/adapters/filter_map.rs:LL:COL + let mut _7: &mut impl Iterator<Item = T>; // in scope 4 at $SRC_DIR/core/src/iter/adapters/filter_map.rs:LL:COL + let mut _8: &mut impl Fn(T) -> Option<U>; // in scope 4 at $SRC_DIR/core/src/iter/adapters/filter_map.rs:LL:COL + } + } + scope 3 (inlined <FilterMap<impl Iterator<Item = T>, impl Fn(T) -> Option<U>> as IntoIterator>::into_iter) { // at $DIR/loops.rs:20:14: 20:32 + debug self => _3; // in scope 3 at $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL + } + + bb0: { + StorageLive(_4); // scope 0 at $DIR/loops.rs:+1:14: +1:32 + StorageLive(_3); // scope 0 at $DIR/loops.rs:+1:14: +1:32 + _3 = <impl Iterator<Item = T> as Iterator>::filter_map::<U, impl Fn(T) -> Option<U>>(move _1, move _2) -> bb1; // scope 0 at $DIR/loops.rs:+1:14: +1:32 + // mir::Constant + // + span: $DIR/loops.rs:20:19: 20:29 + // + literal: Const { ty: fn(impl Iterator<Item = T>, impl Fn(T) -> Option<U>) -> FilterMap<impl Iterator<Item = T>, impl Fn(T) -> Option<U>> {<impl Iterator<Item = T> as Iterator>::filter_map::<U, impl Fn(T) -> Option<U>>}, val: Value(<ZST>) } + } + + bb1: { + _4 = move _3; // scope 3 at $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL + StorageDead(_3); // scope 0 at $DIR/loops.rs:+1:31: +1:32 + StorageLive(_5); // scope 0 at $DIR/loops.rs:+1:14: +1:32 + _5 = move _4; // scope 0 at $DIR/loops.rs:+1:14: +1:32 + goto -> bb2; // scope 1 at $DIR/loops.rs:+1:5: +3:6 + } + + bb2: { + StorageLive(_9); // scope 1 at $DIR/loops.rs:+1:14: +1:32 + _6 = &mut _5; // scope 1 at $DIR/loops.rs:+1:14: +1:32 + StorageLive(_7); // scope 4 at $SRC_DIR/core/src/iter/adapters/filter_map.rs:LL:COL + _7 = &mut ((*_6).0: impl Iterator<Item = T>); // scope 4 at $SRC_DIR/core/src/iter/adapters/filter_map.rs:LL:COL + StorageLive(_8); // scope 4 at $SRC_DIR/core/src/iter/adapters/filter_map.rs:LL:COL + _8 = &mut ((*_6).1: impl Fn(T) -> Option<U>); // scope 4 at $SRC_DIR/core/src/iter/adapters/filter_map.rs:LL:COL + _9 = <impl Iterator<Item = T> as Iterator>::find_map::<U, &mut impl Fn(T) -> Option<U>>(move _7, move _8) -> [return: bb3, unwind: bb9]; // scope 4 at $SRC_DIR/core/src/iter/adapters/filter_map.rs:LL:COL + // mir::Constant + // + span: $SRC_DIR/core/src/iter/adapters/filter_map.rs:LL:COL + // + literal: Const { ty: for<'a> fn(&'a mut impl Iterator<Item = T>, &mut impl Fn(T) -> Option<U>) -> Option<U> {<impl Iterator<Item = T> as Iterator>::find_map::<U, &mut impl Fn(T) -> Option<U>>}, val: Value(<ZST>) } + } + + bb3: { + StorageDead(_8); // scope 4 at $SRC_DIR/core/src/iter/adapters/filter_map.rs:LL:COL + StorageDead(_7); // scope 4 at $SRC_DIR/core/src/iter/adapters/filter_map.rs:LL:COL + _10 = discriminant(_9); // scope 1 at $DIR/loops.rs:+1:14: +1:32 + switchInt(move _10) -> [0: bb4, 1: bb6, otherwise: bb8]; // scope 1 at $DIR/loops.rs:+1:14: +1:32 + } + + bb4: { + StorageDead(_9); // scope 1 at $DIR/loops.rs:+3:5: +3:6 + drop(_5) -> bb5; // scope 0 at $DIR/loops.rs:+3:5: +3:6 + } + + bb5: { + StorageDead(_5); // scope 0 at $DIR/loops.rs:+3:5: +3:6 + StorageDead(_4); // scope 0 at $DIR/loops.rs:+3:5: +3:6 + return; // scope 0 at $DIR/loops.rs:+4:2: +4:2 + } + + bb6: { + _11 = move ((_9 as Some).0: U); // scope 1 at $DIR/loops.rs:+1:9: +1:10 + _12 = opaque::<U>(move _11) -> [return: bb7, unwind: bb9]; // scope 2 at $DIR/loops.rs:+2:9: +2:18 + // mir::Constant + // + span: $DIR/loops.rs:21:9: 21:15 + // + literal: Const { ty: fn(U) {opaque::<U>}, val: Value(<ZST>) } + } + + bb7: { + StorageDead(_9); // scope 1 at $DIR/loops.rs:+3:5: +3:6 + goto -> bb2; // scope 1 at $DIR/loops.rs:+1:5: +3:6 + } + + bb8: { + unreachable; // scope 1 at $DIR/loops.rs:+1:14: +1:32 + } + + bb9 (cleanup): { + drop(_5) -> [return: bb10, unwind terminate]; // scope 0 at $DIR/loops.rs:+3:5: +3:6 + } + + bb10 (cleanup): { + resume; // scope 0 at $DIR/loops.rs:+0:1: +4:2 + } +} diff --git a/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir new file mode 100644 index 00000000000..86e0a62b6f9 --- /dev/null +++ b/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir @@ -0,0 +1,124 @@ +// MIR for `int_range` after PreCodegen + +fn int_range(_1: usize, _2: usize) -> () { + debug start => _1; // in scope 0 at $DIR/loops.rs:+0:18: +0:23 + debug end => _2; // in scope 0 at $DIR/loops.rs:+0:32: +0:35 + let mut _0: (); // return place in scope 0 at $DIR/loops.rs:+0:44: +0:44 + let mut _3: std::ops::Range<usize>; // in scope 0 at $DIR/loops.rs:+1:14: +1:24 + let mut _4: std::ops::Range<usize>; // in scope 0 at $DIR/loops.rs:+1:14: +1:24 + let mut _5: &mut std::ops::Range<usize>; // in scope 0 at $DIR/loops.rs:+1:14: +1:24 + let mut _11: std::option::Option<usize>; // in scope 0 at $DIR/loops.rs:+1:14: +1:24 + let mut _14: isize; // in scope 0 at $DIR/loops.rs:+1:5: +3:6 + let _16: (); // in scope 0 at $DIR/loops.rs:+1:14: +1:24 + scope 1 { + debug iter => _4; // in scope 1 at $DIR/loops.rs:+1:14: +1:24 + let _15: usize; // in scope 1 at $DIR/loops.rs:+1:9: +1:10 + scope 2 { + debug i => _15; // in scope 2 at $DIR/loops.rs:+1:9: +1:10 + } + scope 4 (inlined iter::range::<impl Iterator for std::ops::Range<usize>>::next) { // at $DIR/loops.rs:8:14: 8:24 + debug self => _5; // in scope 4 at $SRC_DIR/core/src/iter/range.rs:LL:COL + scope 5 (inlined <std::ops::Range<usize> as iter::range::RangeIteratorImpl>::spec_next) { // at $SRC_DIR/core/src/iter/range.rs:LL:COL + debug self => _5; // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + let mut _6: &usize; // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + let mut _7: &usize; // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + let mut _10: bool; // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + let _12: usize; // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + let mut _13: usize; // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + scope 6 { + debug old => _12; // in scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + scope 7 { + } + } + scope 8 (inlined cmp::impls::<impl PartialOrd for usize>::lt) { // at $SRC_DIR/core/src/iter/range.rs:LL:COL + debug self => _6; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug other => _7; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _8: usize; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _9: usize; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + } + } + } + } + scope 3 (inlined <std::ops::Range<usize> as IntoIterator>::into_iter) { // at $DIR/loops.rs:8:14: 8:24 + debug self => _3; // in scope 3 at $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL + } + + bb0: { + _3 = std::ops::Range::<usize> { start: _1, end: _2 }; // scope 0 at $DIR/loops.rs:+1:14: +1:24 + StorageLive(_4); // scope 0 at $DIR/loops.rs:+1:14: +1:24 + _4 = move _3; // scope 0 at $DIR/loops.rs:+1:14: +1:24 + goto -> bb1; // scope 1 at $DIR/loops.rs:+1:5: +3:6 + } + + bb1: { + StorageLive(_11); // scope 1 at $DIR/loops.rs:+1:14: +1:24 + _5 = &mut _4; // scope 1 at $DIR/loops.rs:+1:14: +1:24 + StorageLive(_12); // scope 4 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageLive(_10); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageLive(_6); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + _6 = &((*_5).0: usize); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageLive(_7); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + _7 = &((*_5).1: usize); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageLive(_8); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + _8 = (*_6); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_9); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + _9 = (*_7); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + _10 = Lt(move _8, move _9); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_9); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_8); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_7); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageDead(_6); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + switchInt(move _10) -> [0: bb2, otherwise: bb3]; // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + } + + bb2: { + _11 = Option::<usize>::None; // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + goto -> bb5; // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + } + + bb3: { + _12 = ((*_5).0: usize); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageLive(_13); // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + _13 = <usize as Step>::forward_unchecked(_12, const 1_usize) -> bb4; // scope 7 at $SRC_DIR/core/src/iter/range.rs:LL:COL + // mir::Constant + // + span: $SRC_DIR/core/src/iter/range.rs:LL:COL + // + literal: Const { ty: unsafe fn(usize, usize) -> usize {<usize as Step>::forward_unchecked}, val: Value(<ZST>) } + } + + bb4: { + ((*_5).0: usize) = move _13; // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageDead(_13); // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + _11 = Option::<usize>::Some(_12); // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + goto -> bb5; // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + } + + bb5: { + StorageDead(_10); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageDead(_12); // scope 4 at $SRC_DIR/core/src/iter/range.rs:LL:COL + _14 = discriminant(_11); // scope 1 at $DIR/loops.rs:+1:14: +1:24 + switchInt(move _14) -> [0: bb6, 1: bb7, otherwise: bb9]; // scope 1 at $DIR/loops.rs:+1:14: +1:24 + } + + bb6: { + StorageDead(_11); // scope 1 at $DIR/loops.rs:+3:5: +3:6 + StorageDead(_4); // scope 0 at $DIR/loops.rs:+3:5: +3:6 + return; // scope 0 at $DIR/loops.rs:+4:2: +4:2 + } + + bb7: { + _15 = ((_11 as Some).0: usize); // scope 1 at $DIR/loops.rs:+1:9: +1:10 + _16 = opaque::<usize>(_15) -> bb8; // scope 2 at $DIR/loops.rs:+2:9: +2:18 + // mir::Constant + // + span: $DIR/loops.rs:9:9: 9:15 + // + literal: Const { ty: fn(usize) {opaque::<usize>}, val: Value(<ZST>) } + } + + bb8: { + StorageDead(_11); // scope 1 at $DIR/loops.rs:+3:5: +3:6 + goto -> bb1; // scope 1 at $DIR/loops.rs:+1:5: +3:6 + } + + bb9: { + unreachable; // scope 1 at $DIR/loops.rs:+1:14: +1:24 + } +} diff --git a/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir new file mode 100644 index 00000000000..bf1380b30ff --- /dev/null +++ b/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir @@ -0,0 +1,91 @@ +// MIR for `mapped` after PreCodegen + +fn mapped(_1: impl Iterator<Item = T>, _2: impl Fn(T) -> U) -> () { + debug iter => _1; // in scope 0 at $DIR/loops.rs:+0:21: +0:25 + debug f => _2; // in scope 0 at $DIR/loops.rs:+0:52: +0:53 + let mut _0: (); // return place in scope 0 at $DIR/loops.rs:+0:72: +0:72 + let mut _3: std::iter::Map<impl Iterator<Item = T>, impl Fn(T) -> U>; // in scope 0 at $DIR/loops.rs:+1:14: +1:25 + let mut _4: std::iter::Map<impl Iterator<Item = T>, impl Fn(T) -> U>; // in scope 0 at $DIR/loops.rs:+1:14: +1:25 + let mut _5: std::iter::Map<impl Iterator<Item = T>, impl Fn(T) -> U>; // in scope 0 at $DIR/loops.rs:+1:14: +1:25 + let mut _6: &mut std::iter::Map<impl Iterator<Item = T>, impl Fn(T) -> U>; // in scope 0 at $DIR/loops.rs:+1:14: +1:25 + let mut _7: std::option::Option<U>; // in scope 0 at $DIR/loops.rs:+1:14: +1:25 + let mut _8: isize; // in scope 0 at $DIR/loops.rs:+1:5: +3:6 + let _10: (); // in scope 0 at $DIR/loops.rs:+1:14: +1:25 + scope 1 { + debug iter => _5; // in scope 1 at $DIR/loops.rs:+1:14: +1:25 + let _9: U; // in scope 1 at $DIR/loops.rs:+1:9: +1:10 + scope 2 { + debug x => _9; // in scope 2 at $DIR/loops.rs:+1:9: +1:10 + } + } + scope 3 (inlined <Map<impl Iterator<Item = T>, impl Fn(T) -> U> as IntoIterator>::into_iter) { // at $DIR/loops.rs:14:14: 14:25 + debug self => _3; // in scope 3 at $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL + } + + bb0: { + StorageLive(_4); // scope 0 at $DIR/loops.rs:+1:14: +1:25 + StorageLive(_3); // scope 0 at $DIR/loops.rs:+1:14: +1:25 + _3 = <impl Iterator<Item = T> as Iterator>::map::<U, impl Fn(T) -> U>(move _1, move _2) -> bb1; // scope 0 at $DIR/loops.rs:+1:14: +1:25 + // mir::Constant + // + span: $DIR/loops.rs:14:19: 14:22 + // + literal: Const { ty: fn(impl Iterator<Item = T>, impl Fn(T) -> U) -> Map<impl Iterator<Item = T>, impl Fn(T) -> U> {<impl Iterator<Item = T> as Iterator>::map::<U, impl Fn(T) -> U>}, val: Value(<ZST>) } + } + + bb1: { + _4 = move _3; // scope 3 at $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL + StorageDead(_3); // scope 0 at $DIR/loops.rs:+1:24: +1:25 + StorageLive(_5); // scope 0 at $DIR/loops.rs:+1:14: +1:25 + _5 = move _4; // scope 0 at $DIR/loops.rs:+1:14: +1:25 + goto -> bb2; // scope 1 at $DIR/loops.rs:+1:5: +3:6 + } + + bb2: { + StorageLive(_7); // scope 1 at $DIR/loops.rs:+1:14: +1:25 + _6 = &mut _5; // scope 1 at $DIR/loops.rs:+1:14: +1:25 + _7 = <Map<impl Iterator<Item = T>, impl Fn(T) -> U> as Iterator>::next(_6) -> [return: bb3, unwind: bb9]; // scope 1 at $DIR/loops.rs:+1:14: +1:25 + // mir::Constant + // + span: $DIR/loops.rs:14:14: 14:25 + // + literal: Const { ty: for<'a> fn(&'a mut Map<impl Iterator<Item = T>, impl Fn(T) -> U>) -> Option<<Map<impl Iterator<Item = T>, impl Fn(T) -> U> as Iterator>::Item> {<Map<impl Iterator<Item = T>, impl Fn(T) -> U> as Iterator>::next}, val: Value(<ZST>) } + } + + bb3: { + _8 = discriminant(_7); // scope 1 at $DIR/loops.rs:+1:14: +1:25 + switchInt(move _8) -> [0: bb4, 1: bb6, otherwise: bb8]; // scope 1 at $DIR/loops.rs:+1:14: +1:25 + } + + bb4: { + StorageDead(_7); // scope 1 at $DIR/loops.rs:+3:5: +3:6 + drop(_5) -> bb5; // scope 0 at $DIR/loops.rs:+3:5: +3:6 + } + + bb5: { + StorageDead(_5); // scope 0 at $DIR/loops.rs:+3:5: +3:6 + StorageDead(_4); // scope 0 at $DIR/loops.rs:+3:5: +3:6 + return; // scope 0 at $DIR/loops.rs:+4:2: +4:2 + } + + bb6: { + _9 = move ((_7 as Some).0: U); // scope 1 at $DIR/loops.rs:+1:9: +1:10 + _10 = opaque::<U>(move _9) -> [return: bb7, unwind: bb9]; // scope 2 at $DIR/loops.rs:+2:9: +2:18 + // mir::Constant + // + span: $DIR/loops.rs:15:9: 15:15 + // + literal: Const { ty: fn(U) {opaque::<U>}, val: Value(<ZST>) } + } + + bb7: { + StorageDead(_7); // scope 1 at $DIR/loops.rs:+3:5: +3:6 + goto -> bb2; // scope 1 at $DIR/loops.rs:+1:5: +3:6 + } + + bb8: { + unreachable; // scope 1 at $DIR/loops.rs:+1:14: +1:25 + } + + bb9 (cleanup): { + drop(_5) -> [return: bb10, unwind terminate]; // scope 0 at $DIR/loops.rs:+3:5: +3:6 + } + + bb10 (cleanup): { + resume; // scope 0 at $DIR/loops.rs:+0:1: +4:2 + } +} diff --git a/tests/mir-opt/pre-codegen/loops.rs b/tests/mir-opt/pre-codegen/loops.rs new file mode 100644 index 00000000000..67f549a511c --- /dev/null +++ b/tests/mir-opt/pre-codegen/loops.rs @@ -0,0 +1,37 @@ +// compile-flags: -O -Zmir-opt-level=2 -g +// needs-unwind +// ignore-debug + +#![crate_type = "lib"] + +pub fn int_range(start: usize, end: usize) { + for i in start..end { + opaque(i) + } +} + +pub fn mapped<T, U>(iter: impl Iterator<Item = T>, f: impl Fn(T) -> U) { + for x in iter.map(f) { + opaque(x) + } +} + +pub fn filter_mapped<T, U>(iter: impl Iterator<Item = T>, f: impl Fn(T) -> Option<U>) { + for x in iter.filter_map(f) { + opaque(x) + } +} + +pub fn vec_move(mut v: Vec<impl Sized>) { + for x in v { + opaque(x) + } +} + +#[inline(never)] +fn opaque(_: impl Sized) {} + +// EMIT_MIR loops.int_range.PreCodegen.after.mir +// EMIT_MIR loops.mapped.PreCodegen.after.mir +// EMIT_MIR loops.filter_mapped.PreCodegen.after.mir +// EMIT_MIR loops.vec_move.PreCodegen.after.mir diff --git a/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir new file mode 100644 index 00000000000..6cd5a66de00 --- /dev/null +++ b/tests/mir-opt/pre-codegen/loops.vec_move.PreCodegen.after.mir @@ -0,0 +1,83 @@ +// MIR for `vec_move` after PreCodegen + +fn vec_move(_1: Vec<impl Sized>) -> () { + debug v => _1; // in scope 0 at $DIR/loops.rs:+0:17: +0:22 + let mut _0: (); // return place in scope 0 at $DIR/loops.rs:+0:41: +0:41 + let mut _2: std::vec::IntoIter<impl Sized>; // in scope 0 at $DIR/loops.rs:+1:14: +1:15 + let mut _3: std::vec::IntoIter<impl Sized>; // in scope 0 at $DIR/loops.rs:+1:14: +1:15 + let mut _4: &mut std::vec::IntoIter<impl Sized>; // in scope 0 at $DIR/loops.rs:+1:14: +1:15 + let mut _5: std::option::Option<impl Sized>; // in scope 0 at $DIR/loops.rs:+1:14: +1:15 + let mut _6: isize; // in scope 0 at $DIR/loops.rs:+1:5: +3:6 + let _8: (); // in scope 0 at $DIR/loops.rs:+1:14: +1:15 + scope 1 { + debug iter => _3; // in scope 1 at $DIR/loops.rs:+1:14: +1:15 + let _7: impl Sized; // in scope 1 at $DIR/loops.rs:+1:9: +1:10 + scope 2 { + debug x => _7; // in scope 2 at $DIR/loops.rs:+1:9: +1:10 + } + } + + bb0: { + StorageLive(_2); // scope 0 at $DIR/loops.rs:+1:14: +1:15 + _2 = <Vec<impl Sized> as IntoIterator>::into_iter(move _1) -> bb1; // scope 0 at $DIR/loops.rs:+1:14: +1:15 + // mir::Constant + // + span: $DIR/loops.rs:26:14: 26:15 + // + literal: Const { ty: fn(Vec<impl Sized>) -> <Vec<impl Sized> as IntoIterator>::IntoIter {<Vec<impl Sized> as IntoIterator>::into_iter}, val: Value(<ZST>) } + } + + bb1: { + StorageLive(_3); // scope 0 at $DIR/loops.rs:+1:14: +1:15 + _3 = move _2; // scope 0 at $DIR/loops.rs:+1:14: +1:15 + goto -> bb2; // scope 1 at $DIR/loops.rs:+1:5: +3:6 + } + + bb2: { + StorageLive(_5); // scope 1 at $DIR/loops.rs:+1:14: +1:15 + _4 = &mut _3; // scope 1 at $DIR/loops.rs:+1:14: +1:15 + _5 = <std::vec::IntoIter<impl Sized> as Iterator>::next(_4) -> [return: bb3, unwind: bb9]; // scope 1 at $DIR/loops.rs:+1:14: +1:15 + // mir::Constant + // + span: $DIR/loops.rs:26:14: 26:15 + // + literal: Const { ty: for<'a> fn(&'a mut std::vec::IntoIter<impl Sized>) -> Option<<std::vec::IntoIter<impl Sized> as Iterator>::Item> {<std::vec::IntoIter<impl Sized> as Iterator>::next}, val: Value(<ZST>) } + } + + bb3: { + _6 = discriminant(_5); // scope 1 at $DIR/loops.rs:+1:14: +1:15 + switchInt(move _6) -> [0: bb4, 1: bb6, otherwise: bb8]; // scope 1 at $DIR/loops.rs:+1:14: +1:15 + } + + bb4: { + StorageDead(_5); // scope 1 at $DIR/loops.rs:+3:5: +3:6 + drop(_3) -> bb5; // scope 0 at $DIR/loops.rs:+3:5: +3:6 + } + + bb5: { + StorageDead(_3); // scope 0 at $DIR/loops.rs:+3:5: +3:6 + StorageDead(_2); // scope 0 at $DIR/loops.rs:+3:5: +3:6 + return; // scope 0 at $DIR/loops.rs:+4:2: +4:2 + } + + bb6: { + _7 = move ((_5 as Some).0: impl Sized); // scope 1 at $DIR/loops.rs:+1:9: +1:10 + _8 = opaque::<impl Sized>(move _7) -> [return: bb7, unwind: bb9]; // scope 2 at $DIR/loops.rs:+2:9: +2:18 + // mir::Constant + // + span: $DIR/loops.rs:27:9: 27:15 + // + literal: Const { ty: fn(impl Sized) {opaque::<impl Sized>}, val: Value(<ZST>) } + } + + bb7: { + StorageDead(_5); // scope 1 at $DIR/loops.rs:+3:5: +3:6 + goto -> bb2; // scope 1 at $DIR/loops.rs:+1:5: +3:6 + } + + bb8: { + unreachable; // scope 1 at $DIR/loops.rs:+1:14: +1:15 + } + + bb9 (cleanup): { + drop(_3) -> [return: bb10, unwind terminate]; // scope 0 at $DIR/loops.rs:+3:5: +3:6 + } + + bb10 (cleanup): { + resume; // scope 0 at $DIR/loops.rs:+0:1: +4:2 + } +} diff --git a/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir index 50e0538c133..0cf9643dfc2 100644 --- a/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir @@ -15,20 +15,18 @@ fn mem_replace(_1: &mut u32, _2: u32) -> u32 { scope 7 (inlined std::ptr::write::<u32>) { // at $SRC_DIR/core/src/mem/mod.rs:LL:COL debug dst => _4; // in scope 7 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL debug src => _2; // in scope 7 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL - let mut _6: *mut u32; // in scope 7 at $SRC_DIR/core/src/intrinsics.rs:LL:COL scope 8 { scope 9 (inlined std::ptr::write::runtime::<u32>) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL - debug dst => _6; // in scope 9 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + debug dst => _4; // in scope 9 at $SRC_DIR/core/src/intrinsics.rs:LL:COL } } } } scope 4 (inlined std::ptr::read::<u32>) { // at $SRC_DIR/core/src/mem/mod.rs:LL:COL debug src => _3; // in scope 4 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL - let mut _5: *const u32; // in scope 4 at $SRC_DIR/core/src/intrinsics.rs:LL:COL scope 5 { scope 6 (inlined std::ptr::read::runtime::<u32>) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL - debug src => _5; // in scope 6 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + debug src => _3; // in scope 6 at $SRC_DIR/core/src/intrinsics.rs:LL:COL } } } @@ -38,15 +36,11 @@ fn mem_replace(_1: &mut u32, _2: u32) -> u32 { bb0: { StorageLive(_3); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL _3 = &raw const (*_1); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL - StorageLive(_5); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL _0 = (*_3); // scope 5 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL - StorageDead(_5); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL StorageDead(_3); // scope 2 at $SRC_DIR/core/src/mem/mod.rs:LL:COL StorageLive(_4); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL _4 = &raw mut (*_1); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL - StorageLive(_6); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL (*_4) = _2; // scope 8 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL - StorageDead(_6); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL StorageDead(_4); // scope 3 at $SRC_DIR/core/src/mem/mod.rs:LL:COL return; // scope 0 at $DIR/mem_replace.rs:+2:2: +2:2 } diff --git a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.mir index 693939e75f4..06a4e35f1f9 100644 --- a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.mir @@ -8,16 +8,16 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { let mut _4: std::ops::Range<u32>; // in scope 0 at $DIR/range_iter.rs:+1:14: +1:24 let mut _5: std::ops::Range<u32>; // in scope 0 at $DIR/range_iter.rs:+1:14: +1:24 let mut _6: &mut std::ops::Range<u32>; // in scope 0 at $DIR/range_iter.rs:+1:14: +1:24 - let mut _10: std::option::Option<u32>; // in scope 0 at $DIR/range_iter.rs:+1:14: +1:24 - let mut _13: isize; // in scope 0 at $DIR/range_iter.rs:+1:5: +3:6 - let mut _15: &impl Fn(u32); // in scope 0 at $DIR/range_iter.rs:+2:9: +2:10 - let mut _16: (u32,); // in scope 0 at $DIR/range_iter.rs:+2:9: +2:13 - let _17: (); // in scope 0 at $DIR/range_iter.rs:+1:14: +1:24 + let mut _12: std::option::Option<u32>; // in scope 0 at $DIR/range_iter.rs:+1:14: +1:24 + let mut _15: isize; // in scope 0 at $DIR/range_iter.rs:+1:5: +3:6 + let mut _17: &impl Fn(u32); // in scope 0 at $DIR/range_iter.rs:+2:9: +2:10 + let mut _18: (u32,); // in scope 0 at $DIR/range_iter.rs:+2:9: +2:13 + let _19: (); // in scope 0 at $DIR/range_iter.rs:+1:14: +1:24 scope 1 { debug iter => _5; // in scope 1 at $DIR/range_iter.rs:+1:14: +1:24 - let _14: u32; // in scope 1 at $DIR/range_iter.rs:+1:9: +1:10 + let _16: u32; // in scope 1 at $DIR/range_iter.rs:+1:9: +1:10 scope 2 { - debug x => _14; // in scope 2 at $DIR/range_iter.rs:+1:9: +1:10 + debug x => _16; // in scope 2 at $DIR/range_iter.rs:+1:9: +1:10 } scope 4 (inlined iter::range::<impl Iterator for std::ops::Range<u32>>::next) { // at $DIR/range_iter.rs:21:14: 21:24 debug self => _6; // in scope 4 at $SRC_DIR/core/src/iter/range.rs:LL:COL @@ -25,14 +25,20 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { debug self => _6; // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL let mut _7: &u32; // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL let mut _8: &u32; // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL - let mut _9: bool; // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL - let _11: u32; // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL - let mut _12: u32; // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + let mut _11: bool; // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + let _13: u32; // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + let mut _14: u32; // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL scope 6 { - debug old => _11; // in scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + debug old => _13; // in scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL scope 7 { } } + scope 8 (inlined cmp::impls::<impl PartialOrd for u32>::lt) { // at $SRC_DIR/core/src/iter/range.rs:LL:COL + debug self => _7; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug other => _8; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _9: u32; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _10: u32; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + } } } } @@ -48,92 +54,92 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb1: { - StorageLive(_10); // scope 1 at $DIR/range_iter.rs:+1:14: +1:24 + StorageLive(_12); // scope 1 at $DIR/range_iter.rs:+1:14: +1:24 _6 = &mut _5; // scope 1 at $DIR/range_iter.rs:+1:14: +1:24 - StorageLive(_11); // scope 4 at $SRC_DIR/core/src/iter/range.rs:LL:COL - StorageLive(_9); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageLive(_13); // scope 4 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageLive(_11); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL StorageLive(_7); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL _7 = &((*_6).0: u32); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL StorageLive(_8); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL _8 = &((*_6).1: u32); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL - _9 = <u32 as PartialOrd>::lt(move _7, move _8) -> [return: bb2, unwind: bb12]; // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL - // mir::Constant - // + span: $SRC_DIR/core/src/iter/range.rs:LL:COL - // + literal: Const { ty: for<'a, 'b> fn(&'a u32, &'b u32) -> bool {<u32 as PartialOrd>::lt}, val: Value(<ZST>) } - } - - bb2: { + StorageLive(_9); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + _9 = (*_7); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_10); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + _10 = (*_8); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + _11 = Lt(move _9, move _10); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_10); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_9); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL StorageDead(_8); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL StorageDead(_7); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL - switchInt(move _9) -> [0: bb3, otherwise: bb4]; // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + switchInt(move _11) -> [0: bb2, otherwise: bb3]; // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL } - bb3: { - _10 = Option::<u32>::None; // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL - goto -> bb6; // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + bb2: { + _12 = Option::<u32>::None; // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + goto -> bb5; // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL } - bb4: { - _11 = ((*_6).0: u32); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL - StorageLive(_12); // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL - _12 = <u32 as Step>::forward_unchecked(_11, const 1_usize) -> [return: bb5, unwind: bb12]; // scope 7 at $SRC_DIR/core/src/iter/range.rs:LL:COL + bb3: { + _13 = ((*_6).0: u32); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageLive(_14); // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + _14 = <u32 as Step>::forward_unchecked(_13, const 1_usize) -> [return: bb4, unwind: bb11]; // scope 7 at $SRC_DIR/core/src/iter/range.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/iter/range.rs:LL:COL // + literal: Const { ty: unsafe fn(u32, usize) -> u32 {<u32 as Step>::forward_unchecked}, val: Value(<ZST>) } } - bb5: { - ((*_6).0: u32) = move _12; // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL - StorageDead(_12); // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL - _10 = Option::<u32>::Some(_11); // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL - goto -> bb6; // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + bb4: { + ((*_6).0: u32) = move _14; // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageDead(_14); // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + _12 = Option::<u32>::Some(_13); // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + goto -> bb5; // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL } - bb6: { - StorageDead(_9); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL - StorageDead(_11); // scope 4 at $SRC_DIR/core/src/iter/range.rs:LL:COL - _13 = discriminant(_10); // scope 1 at $DIR/range_iter.rs:+1:14: +1:24 - switchInt(move _13) -> [0: bb7, 1: bb9, otherwise: bb11]; // scope 1 at $DIR/range_iter.rs:+1:14: +1:24 + bb5: { + StorageDead(_11); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageDead(_13); // scope 4 at $SRC_DIR/core/src/iter/range.rs:LL:COL + _15 = discriminant(_12); // scope 1 at $DIR/range_iter.rs:+1:14: +1:24 + switchInt(move _15) -> [0: bb6, 1: bb8, otherwise: bb10]; // scope 1 at $DIR/range_iter.rs:+1:14: +1:24 } - bb7: { - StorageDead(_10); // scope 1 at $DIR/range_iter.rs:+3:5: +3:6 + bb6: { + StorageDead(_12); // scope 1 at $DIR/range_iter.rs:+3:5: +3:6 StorageDead(_5); // scope 0 at $DIR/range_iter.rs:+3:5: +3:6 - drop(_3) -> bb8; // scope 0 at $DIR/range_iter.rs:+4:1: +4:2 + drop(_3) -> bb7; // scope 0 at $DIR/range_iter.rs:+4:1: +4:2 } - bb8: { + bb7: { return; // scope 0 at $DIR/range_iter.rs:+4:2: +4:2 } - bb9: { - _14 = ((_10 as Some).0: u32); // scope 1 at $DIR/range_iter.rs:+1:9: +1:10 - StorageLive(_15); // scope 2 at $DIR/range_iter.rs:+2:9: +2:10 - _15 = &_3; // scope 2 at $DIR/range_iter.rs:+2:9: +2:10 - StorageLive(_16); // scope 2 at $DIR/range_iter.rs:+2:9: +2:13 - _16 = (_14,); // scope 2 at $DIR/range_iter.rs:+2:9: +2:13 - _17 = <impl Fn(u32) as Fn<(u32,)>>::call(move _15, move _16) -> [return: bb10, unwind: bb12]; // scope 2 at $DIR/range_iter.rs:+2:9: +2:13 + bb8: { + _16 = ((_12 as Some).0: u32); // scope 1 at $DIR/range_iter.rs:+1:9: +1:10 + StorageLive(_17); // scope 2 at $DIR/range_iter.rs:+2:9: +2:10 + _17 = &_3; // scope 2 at $DIR/range_iter.rs:+2:9: +2:10 + StorageLive(_18); // scope 2 at $DIR/range_iter.rs:+2:9: +2:13 + _18 = (_16,); // scope 2 at $DIR/range_iter.rs:+2:9: +2:13 + _19 = <impl Fn(u32) as Fn<(u32,)>>::call(move _17, move _18) -> [return: bb9, unwind: bb11]; // scope 2 at $DIR/range_iter.rs:+2:9: +2:13 // mir::Constant // + span: $DIR/range_iter.rs:22:9: 22:10 // + literal: Const { ty: for<'a> extern "rust-call" fn(&'a impl Fn(u32), (u32,)) -> <impl Fn(u32) as FnOnce<(u32,)>>::Output {<impl Fn(u32) as Fn<(u32,)>>::call}, val: Value(<ZST>) } } - bb10: { - StorageDead(_16); // scope 2 at $DIR/range_iter.rs:+2:12: +2:13 - StorageDead(_15); // scope 2 at $DIR/range_iter.rs:+2:12: +2:13 - StorageDead(_10); // scope 1 at $DIR/range_iter.rs:+3:5: +3:6 + bb9: { + StorageDead(_18); // scope 2 at $DIR/range_iter.rs:+2:12: +2:13 + StorageDead(_17); // scope 2 at $DIR/range_iter.rs:+2:12: +2:13 + StorageDead(_12); // scope 1 at $DIR/range_iter.rs:+3:5: +3:6 goto -> bb1; // scope 1 at $DIR/range_iter.rs:+1:5: +3:6 } - bb11: { + bb10: { unreachable; // scope 1 at $DIR/range_iter.rs:+1:14: +1:24 } - bb12 (cleanup): { - drop(_3) -> [return: bb13, unwind terminate]; // scope 0 at $DIR/range_iter.rs:+4:1: +4:2 + bb11 (cleanup): { + drop(_3) -> [return: bb12, unwind terminate]; // scope 0 at $DIR/range_iter.rs:+4:1: +4:2 } - bb13 (cleanup): { + bb12 (cleanup): { resume; // scope 0 at $DIR/range_iter.rs:+0:1: +4:2 } } diff --git a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.mir index 668ec31c6c1..f15722deee0 100644 --- a/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/range_iter.range_iter_next.PreCodegen.after.mir @@ -9,60 +9,66 @@ fn range_iter_next(_1: &mut std::ops::Range<u32>) -> Option<u32> { debug self => _1; // in scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL let mut _2: &u32; // in scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL let mut _3: &u32; // in scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL - let mut _4: bool; // in scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL - let _5: u32; // in scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL - let mut _6: u32; // in scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL + let mut _6: bool; // in scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL + let _7: u32; // in scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL + let mut _8: u32; // in scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL scope 3 { - debug old => _5; // in scope 3 at $SRC_DIR/core/src/iter/range.rs:LL:COL + debug old => _7; // in scope 3 at $SRC_DIR/core/src/iter/range.rs:LL:COL scope 4 { } } + scope 5 (inlined cmp::impls::<impl PartialOrd for u32>::lt) { // at $SRC_DIR/core/src/iter/range.rs:LL:COL + debug self => _2; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug other => _3; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _4: u32; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _5: u32; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + } } } bb0: { - StorageLive(_5); // scope 1 at $SRC_DIR/core/src/iter/range.rs:LL:COL - StorageLive(_4); // scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageLive(_7); // scope 1 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageLive(_6); // scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL StorageLive(_2); // scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL _2 = &((*_1).0: u32); // scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL StorageLive(_3); // scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL _3 = &((*_1).1: u32); // scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL - _4 = <u32 as PartialOrd>::lt(move _2, move _3) -> bb1; // scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL - // mir::Constant - // + span: $SRC_DIR/core/src/iter/range.rs:LL:COL - // + literal: Const { ty: for<'a, 'b> fn(&'a u32, &'b u32) -> bool {<u32 as PartialOrd>::lt}, val: Value(<ZST>) } - } - - bb1: { + StorageLive(_4); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + _4 = (*_2); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_5); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + _5 = (*_3); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + _6 = Lt(move _4, move _5); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_5); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_4); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL StorageDead(_3); // scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL StorageDead(_2); // scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL - switchInt(move _4) -> [0: bb2, otherwise: bb3]; // scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL + switchInt(move _6) -> [0: bb1, otherwise: bb2]; // scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL } - bb2: { + bb1: { _0 = Option::<u32>::None; // scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL - goto -> bb5; // scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL + goto -> bb4; // scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL } - bb3: { - _5 = ((*_1).0: u32); // scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL - StorageLive(_6); // scope 3 at $SRC_DIR/core/src/iter/range.rs:LL:COL - _6 = <u32 as Step>::forward_unchecked(_5, const 1_usize) -> bb4; // scope 4 at $SRC_DIR/core/src/iter/range.rs:LL:COL + bb2: { + _7 = ((*_1).0: u32); // scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageLive(_8); // scope 3 at $SRC_DIR/core/src/iter/range.rs:LL:COL + _8 = <u32 as Step>::forward_unchecked(_7, const 1_usize) -> bb3; // scope 4 at $SRC_DIR/core/src/iter/range.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/iter/range.rs:LL:COL // + literal: Const { ty: unsafe fn(u32, usize) -> u32 {<u32 as Step>::forward_unchecked}, val: Value(<ZST>) } } - bb4: { - ((*_1).0: u32) = move _6; // scope 3 at $SRC_DIR/core/src/iter/range.rs:LL:COL - StorageDead(_6); // scope 3 at $SRC_DIR/core/src/iter/range.rs:LL:COL - _0 = Option::<u32>::Some(_5); // scope 3 at $SRC_DIR/core/src/iter/range.rs:LL:COL - goto -> bb5; // scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL + bb3: { + ((*_1).0: u32) = move _8; // scope 3 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageDead(_8); // scope 3 at $SRC_DIR/core/src/iter/range.rs:LL:COL + _0 = Option::<u32>::Some(_7); // scope 3 at $SRC_DIR/core/src/iter/range.rs:LL:COL + goto -> bb4; // scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL } - bb5: { - StorageDead(_4); // scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL - StorageDead(_5); // scope 1 at $SRC_DIR/core/src/iter/range.rs:LL:COL + bb4: { + StorageDead(_6); // scope 2 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageDead(_7); // scope 1 at $SRC_DIR/core/src/iter/range.rs:LL:COL return; // scope 0 at $DIR/range_iter.rs:+2:2: +2:2 } } diff --git a/tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.mir index 089b0c23e2c..73b5678ce04 100644 --- a/tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/simple_option_map.ezmap.PreCodegen.after.mir @@ -3,24 +3,21 @@ fn ezmap(_1: Option<i32>) -> Option<i32> { debug x => _1; // in scope 0 at $DIR/simple_option_map.rs:+0:14: +0:15 let mut _0: std::option::Option<i32>; // return place in scope 0 at $DIR/simple_option_map.rs:+0:33: +0:44 - let mut _5: i32; // in scope 0 at $DIR/simple_option_map.rs:11:25: 11:29 scope 1 (inlined map::<i32, i32, [closure@$DIR/simple_option_map.rs:18:12: 18:15]>) { // at $DIR/simple_option_map.rs:18:5: 18:22 debug slf => _1; // in scope 1 at $DIR/simple_option_map.rs:6:17: 6:20 debug f => const ZeroSized: [closure@$DIR/simple_option_map.rs:18:12: 18:15]; // in scope 1 at $DIR/simple_option_map.rs:6:33: 6:34 let mut _2: isize; // in scope 1 at $DIR/simple_option_map.rs:11:9: 11:16 let _3: i32; // in scope 1 at $DIR/simple_option_map.rs:11:14: 11:15 - let mut _4: (i32,); // in scope 1 at $DIR/simple_option_map.rs:11:25: 11:29 - let mut _6: i32; // in scope 1 at $DIR/simple_option_map.rs:11:25: 11:29 + let mut _4: i32; // in scope 1 at $DIR/simple_option_map.rs:11:25: 11:29 scope 2 { debug x => _3; // in scope 2 at $DIR/simple_option_map.rs:11:14: 11:15 scope 3 (inlined ezmap::{closure#0}) { // at $DIR/simple_option_map.rs:11:25: 11:29 - debug n => _5; // in scope 3 at $DIR/simple_option_map.rs:+1:13: +1:14 + debug n => _3; // in scope 3 at $DIR/simple_option_map.rs:+1:13: +1:14 } } } bb0: { - StorageLive(_3); // scope 0 at $DIR/simple_option_map.rs:+1:5: +1:22 _2 = discriminant(_1); // scope 1 at $DIR/simple_option_map.rs:10:11: 10:14 switchInt(move _2) -> [0: bb1, 1: bb2, otherwise: bb4]; // scope 1 at $DIR/simple_option_map.rs:10:5: 10:14 } @@ -32,21 +29,14 @@ fn ezmap(_1: Option<i32>) -> Option<i32> { bb2: { _3 = ((_1 as Some).0: i32); // scope 1 at $DIR/simple_option_map.rs:11:14: 11:15 - StorageLive(_6); // scope 2 at $DIR/simple_option_map.rs:11:25: 11:29 StorageLive(_4); // scope 2 at $DIR/simple_option_map.rs:11:25: 11:29 - _4 = (move _3,); // scope 2 at $DIR/simple_option_map.rs:11:25: 11:29 - StorageLive(_5); // scope 2 at $DIR/simple_option_map.rs:11:25: 11:29 - _5 = move (_4.0: i32); // scope 2 at $DIR/simple_option_map.rs:11:25: 11:29 - _6 = Add(_5, const 1_i32); // scope 3 at $DIR/simple_option_map.rs:+1:16: +1:21 - StorageDead(_5); // scope 2 at $DIR/simple_option_map.rs:11:25: 11:29 - StorageDead(_4); // scope 2 at $DIR/simple_option_map.rs:11:28: 11:29 - _0 = Option::<i32>::Some(move _6); // scope 2 at $DIR/simple_option_map.rs:11:20: 11:30 - StorageDead(_6); // scope 2 at $DIR/simple_option_map.rs:11:29: 11:30 + _4 = Add(_3, const 1_i32); // scope 3 at $DIR/simple_option_map.rs:+1:16: +1:21 + _0 = Option::<i32>::Some(move _4); // scope 2 at $DIR/simple_option_map.rs:11:20: 11:30 + StorageDead(_4); // scope 2 at $DIR/simple_option_map.rs:11:29: 11:30 goto -> bb3; // scope 1 at $DIR/simple_option_map.rs:14:1: 14:2 } bb3: { - StorageDead(_3); // scope 0 at $DIR/simple_option_map.rs:+1:5: +1:22 return; // scope 0 at $DIR/simple_option_map.rs:+2:2: +2:2 } diff --git a/tests/mir-opt/pre-codegen/slice_filter.rs b/tests/mir-opt/pre-codegen/slice_filter.rs new file mode 100644 index 00000000000..aba951acdd0 --- /dev/null +++ b/tests/mir-opt/pre-codegen/slice_filter.rs @@ -0,0 +1,15 @@ +// compile-flags: -O -Zmir-opt-level=2 -Cdebuginfo=2 +// ignore-debug: standard library debug assertions add a panic that breaks this optimization + +#![crate_type = "lib"] + +pub fn variant_a(input: &[(usize, usize, usize, usize)]) -> usize { + input.iter().filter(|(a, b, c, d)| a <= c && d <= b || c <= a && b <= d).count() +} + +pub fn variant_b(input: &[(usize, usize, usize, usize)]) -> usize { + input.iter().filter(|&&(a, b, c, d)| a <= c && d <= b || c <= a && b <= d).count() +} + +// EMIT_MIR slice_filter.variant_a-{closure#0}.PreCodegen.after.mir +// EMIT_MIR slice_filter.variant_b-{closure#0}.PreCodegen.after.mir diff --git a/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir new file mode 100644 index 00000000000..91c8f299fdb --- /dev/null +++ b/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir @@ -0,0 +1,228 @@ +// MIR for `variant_a::{closure#0}` after PreCodegen + +fn variant_a::{closure#0}(_1: &mut [closure@$DIR/slice_filter.rs:7:25: 7:39], _2: &&(usize, usize, usize, usize)) -> bool { + let mut _0: bool; // return place in scope 0 at $DIR/slice_filter.rs:+0:40: +0:40 + let mut _3: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 + let _4: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:27: +0:28 + let mut _5: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 + let _6: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:30: +0:31 + let mut _7: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 + let _8: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:33: +0:34 + let mut _9: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 + let _10: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:36: +0:37 + let mut _11: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:40: +0:41 + let _12: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:45: +0:46 + let mut _13: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:45: +0:46 + let mut _18: bool; // in scope 0 at $DIR/slice_filter.rs:+0:40: +0:46 + let mut _19: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:50: +0:51 + let _20: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:55: +0:56 + let mut _21: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:55: +0:56 + let mut _26: bool; // in scope 0 at $DIR/slice_filter.rs:+0:50: +0:56 + let mut _27: bool; // in scope 0 at $DIR/slice_filter.rs:+0:40: +0:56 + let mut _28: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:60: +0:61 + let _29: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:65: +0:66 + let mut _30: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:65: +0:66 + let mut _35: bool; // in scope 0 at $DIR/slice_filter.rs:+0:60: +0:66 + let mut _36: bool; // in scope 0 at $DIR/slice_filter.rs:+0:60: +0:76 + let mut _37: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:70: +0:71 + let _38: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 + let mut _39: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 + let mut _44: bool; // in scope 0 at $DIR/slice_filter.rs:+0:70: +0:76 + scope 1 { + debug a => _4; // in scope 1 at $DIR/slice_filter.rs:+0:27: +0:28 + debug b => _6; // in scope 1 at $DIR/slice_filter.rs:+0:30: +0:31 + debug c => _8; // in scope 1 at $DIR/slice_filter.rs:+0:33: +0:34 + debug d => _10; // in scope 1 at $DIR/slice_filter.rs:+0:36: +0:37 + scope 2 (inlined cmp::impls::<impl PartialOrd for &usize>::le) { // at $DIR/slice_filter.rs:7:40: 7:46 + debug self => _11; // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug other => _13; // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _14: &usize; // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _15: &usize; // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL + scope 3 (inlined cmp::impls::<impl PartialOrd for usize>::le) { // at $SRC_DIR/core/src/cmp.rs:LL:COL + debug self => _14; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug other => _15; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _16: usize; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _17: usize; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + } + } + scope 4 (inlined cmp::impls::<impl PartialOrd for &usize>::le) { // at $DIR/slice_filter.rs:7:60: 7:66 + debug self => _28; // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug other => _30; // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _31: &usize; // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _32: &usize; // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL + scope 5 (inlined cmp::impls::<impl PartialOrd for usize>::le) { // at $SRC_DIR/core/src/cmp.rs:LL:COL + debug self => _31; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug other => _32; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _33: usize; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _34: usize; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + } + } + scope 6 (inlined cmp::impls::<impl PartialOrd for &usize>::le) { // at $DIR/slice_filter.rs:7:50: 7:56 + debug self => _19; // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug other => _21; // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _22: &usize; // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _23: &usize; // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL + scope 7 (inlined cmp::impls::<impl PartialOrd for usize>::le) { // at $SRC_DIR/core/src/cmp.rs:LL:COL + debug self => _22; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug other => _23; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _24: usize; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _25: usize; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + } + } + scope 8 (inlined cmp::impls::<impl PartialOrd for &usize>::le) { // at $DIR/slice_filter.rs:7:70: 7:76 + debug self => _37; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug other => _39; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _40: &usize; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _41: &usize; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + scope 9 (inlined cmp::impls::<impl PartialOrd for usize>::le) { // at $SRC_DIR/core/src/cmp.rs:LL:COL + debug self => _40; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug other => _41; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _42: usize; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _43: usize; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + } + } + } + + bb0: { + StorageLive(_4); // scope 0 at $DIR/slice_filter.rs:+0:27: +0:28 + _3 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:27: +0:28 + _4 = &((*_3).0: usize); // scope 0 at $DIR/slice_filter.rs:+0:27: +0:28 + StorageLive(_6); // scope 0 at $DIR/slice_filter.rs:+0:30: +0:31 + _5 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:30: +0:31 + _6 = &((*_5).1: usize); // scope 0 at $DIR/slice_filter.rs:+0:30: +0:31 + StorageLive(_8); // scope 0 at $DIR/slice_filter.rs:+0:33: +0:34 + _7 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:33: +0:34 + _8 = &((*_7).2: usize); // scope 0 at $DIR/slice_filter.rs:+0:33: +0:34 + StorageLive(_10); // scope 0 at $DIR/slice_filter.rs:+0:36: +0:37 + _9 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:36: +0:37 + _10 = &((*_9).3: usize); // scope 0 at $DIR/slice_filter.rs:+0:36: +0:37 + StorageLive(_27); // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 + StorageLive(_18); // scope 1 at $DIR/slice_filter.rs:+0:40: +0:46 + StorageLive(_11); // scope 1 at $DIR/slice_filter.rs:+0:40: +0:41 + _11 = &_4; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:41 + StorageLive(_13); // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 + StorageLive(_12); // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 + _12 = _8; // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 + _13 = &_12; // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 + _14 = deref_copy (*_11); // scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL + _15 = deref_copy (*_13); // scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_16); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + _16 = (*_14); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_17); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + _17 = (*_15); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + _18 = Le(move _16, move _17); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_17); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_16); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_12); // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 + StorageDead(_13); // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 + StorageDead(_11); // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 + switchInt(move _18) -> [0: bb1, otherwise: bb2]; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 + } + + bb1: { + StorageDead(_26); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + StorageDead(_18); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + goto -> bb3; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 + } + + bb2: { + StorageLive(_26); // scope 1 at $DIR/slice_filter.rs:+0:50: +0:56 + StorageLive(_19); // scope 1 at $DIR/slice_filter.rs:+0:50: +0:51 + _19 = &_10; // scope 1 at $DIR/slice_filter.rs:+0:50: +0:51 + StorageLive(_21); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + StorageLive(_20); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + _20 = _6; // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + _21 = &_20; // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + _22 = deref_copy (*_19); // scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL + _23 = deref_copy (*_21); // scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_24); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + _24 = (*_22); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_25); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + _25 = (*_23); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + _26 = Le(move _24, move _25); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_25); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_24); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_20); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + StorageDead(_21); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + StorageDead(_19); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + _27 = move _26; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 + StorageDead(_26); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + StorageDead(_18); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 + switchInt(move _27) -> [0: bb3, otherwise: bb7]; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 + } + + bb3: { + StorageLive(_36); // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 + StorageLive(_35); // scope 1 at $DIR/slice_filter.rs:+0:60: +0:66 + StorageLive(_28); // scope 1 at $DIR/slice_filter.rs:+0:60: +0:61 + _28 = &_8; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:61 + StorageLive(_30); // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 + StorageLive(_29); // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 + _29 = _4; // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 + _30 = &_29; // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 + _31 = deref_copy (*_28); // scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL + _32 = deref_copy (*_30); // scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_33); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + _33 = (*_31); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_34); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + _34 = (*_32); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + _35 = Le(move _33, move _34); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_34); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_33); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_29); // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 + StorageDead(_30); // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 + StorageDead(_28); // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 + switchInt(move _35) -> [0: bb4, otherwise: bb5]; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 + } + + bb4: { + _36 = const false; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 + goto -> bb6; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 + } + + bb5: { + StorageLive(_44); // scope 1 at $DIR/slice_filter.rs:+0:70: +0:76 + StorageLive(_37); // scope 1 at $DIR/slice_filter.rs:+0:70: +0:71 + _37 = &_6; // scope 1 at $DIR/slice_filter.rs:+0:70: +0:71 + StorageLive(_39); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + StorageLive(_38); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + _38 = _10; // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + _39 = &_38; // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + _40 = deref_copy (*_37); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + _41 = deref_copy (*_39); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_42); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + _42 = (*_40); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_43); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + _43 = (*_41); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + _44 = Le(move _42, move _43); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_43); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_42); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_38); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + StorageDead(_39); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + StorageDead(_37); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + _36 = move _44; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 + goto -> bb6; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 + } + + bb6: { + StorageDead(_44); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + StorageDead(_35); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + _0 = move _36; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 + goto -> bb8; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 + } + + bb7: { + _0 = const true; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 + goto -> bb8; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 + } + + bb8: { + StorageDead(_36); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + StorageDead(_27); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 + StorageDead(_10); // scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 + StorageDead(_8); // scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 + StorageDead(_6); // scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 + StorageDead(_4); // scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 + return; // scope 0 at $DIR/slice_filter.rs:+0:76: +0:76 + } +} diff --git a/tests/mir-opt/pre-codegen/slice_filter.variant_b-{closure#0}.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_filter.variant_b-{closure#0}.PreCodegen.after.mir new file mode 100644 index 00000000000..9f5fe95a8b4 --- /dev/null +++ b/tests/mir-opt/pre-codegen/slice_filter.variant_b-{closure#0}.PreCodegen.after.mir @@ -0,0 +1,92 @@ +// MIR for `variant_b::{closure#0}` after PreCodegen + +fn variant_b::{closure#0}(_1: &mut [closure@$DIR/slice_filter.rs:11:25: 11:41], _2: &&(usize, usize, usize, usize)) -> bool { + let mut _0: bool; // return place in scope 0 at $DIR/slice_filter.rs:+0:42: +0:42 + let mut _3: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:40 + let _4: usize; // in scope 0 at $DIR/slice_filter.rs:+0:29: +0:30 + let mut _5: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:40 + let _6: usize; // in scope 0 at $DIR/slice_filter.rs:+0:32: +0:33 + let mut _7: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:40 + let _8: usize; // in scope 0 at $DIR/slice_filter.rs:+0:35: +0:36 + let mut _9: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:40 + let _10: usize; // in scope 0 at $DIR/slice_filter.rs:+0:38: +0:39 + let mut _11: bool; // in scope 0 at $DIR/slice_filter.rs:+0:42: +0:48 + let mut _12: bool; // in scope 0 at $DIR/slice_filter.rs:+0:52: +0:58 + let mut _13: bool; // in scope 0 at $DIR/slice_filter.rs:+0:42: +0:58 + let mut _14: bool; // in scope 0 at $DIR/slice_filter.rs:+0:62: +0:68 + let mut _15: bool; // in scope 0 at $DIR/slice_filter.rs:+0:62: +0:78 + let mut _16: bool; // in scope 0 at $DIR/slice_filter.rs:+0:72: +0:78 + scope 1 { + debug a => _4; // in scope 1 at $DIR/slice_filter.rs:+0:29: +0:30 + debug b => _6; // in scope 1 at $DIR/slice_filter.rs:+0:32: +0:33 + debug c => _8; // in scope 1 at $DIR/slice_filter.rs:+0:35: +0:36 + debug d => _10; // in scope 1 at $DIR/slice_filter.rs:+0:38: +0:39 + } + + bb0: { + _3 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:29: +0:30 + _4 = ((*_3).0: usize); // scope 0 at $DIR/slice_filter.rs:+0:29: +0:30 + _5 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:32: +0:33 + _6 = ((*_5).1: usize); // scope 0 at $DIR/slice_filter.rs:+0:32: +0:33 + _7 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:35: +0:36 + _8 = ((*_7).2: usize); // scope 0 at $DIR/slice_filter.rs:+0:35: +0:36 + _9 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:38: +0:39 + _10 = ((*_9).3: usize); // scope 0 at $DIR/slice_filter.rs:+0:38: +0:39 + StorageLive(_13); // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 + StorageLive(_11); // scope 1 at $DIR/slice_filter.rs:+0:42: +0:48 + _11 = Le(_4, _8); // scope 1 at $DIR/slice_filter.rs:+0:42: +0:48 + switchInt(move _11) -> [0: bb1, otherwise: bb2]; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 + } + + bb1: { + StorageDead(_12); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 + StorageDead(_11); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 + goto -> bb3; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 + } + + bb2: { + StorageLive(_12); // scope 1 at $DIR/slice_filter.rs:+0:52: +0:58 + _12 = Le(_10, _6); // scope 1 at $DIR/slice_filter.rs:+0:52: +0:58 + _13 = move _12; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 + StorageDead(_12); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 + StorageDead(_11); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 + switchInt(move _13) -> [0: bb3, otherwise: bb7]; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 + } + + bb3: { + StorageLive(_15); // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 + StorageLive(_14); // scope 1 at $DIR/slice_filter.rs:+0:62: +0:68 + _14 = Le(_8, _4); // scope 1 at $DIR/slice_filter.rs:+0:62: +0:68 + switchInt(move _14) -> [0: bb4, otherwise: bb5]; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 + } + + bb4: { + _15 = const false; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 + goto -> bb6; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 + } + + bb5: { + StorageLive(_16); // scope 1 at $DIR/slice_filter.rs:+0:72: +0:78 + _16 = Le(_6, _10); // scope 1 at $DIR/slice_filter.rs:+0:72: +0:78 + _15 = move _16; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 + goto -> bb6; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 + } + + bb6: { + StorageDead(_16); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 + StorageDead(_14); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 + _0 = move _15; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 + goto -> bb8; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 + } + + bb7: { + _0 = const true; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 + goto -> bb8; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 + } + + bb8: { + StorageDead(_15); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 + StorageDead(_13); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 + return; // scope 0 at $DIR/slice_filter.rs:+0:78: +0:78 + } +} diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.mir index b05d44f4d60..6c306280536 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.mir @@ -21,19 +21,17 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { debug self => _2; // in scope 4 at $SRC_DIR/core/src/slice/index.rs:LL:COL debug slice => _6; // in scope 4 at $SRC_DIR/core/src/slice/index.rs:LL:COL let mut _7: *mut u32; // in scope 4 at $SRC_DIR/core/src/slice/index.rs:LL:COL - let mut _10: usize; // in scope 4 at $SRC_DIR/core/src/intrinsics.rs:LL:COL - let mut _11: *mut [u32]; // in scope 4 at $SRC_DIR/core/src/intrinsics.rs:LL:COL scope 5 { debug this => _2; // in scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL scope 6 { scope 7 (inlined <usize as SliceIndex<[T]>>::get_unchecked_mut::runtime::<u32>) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL - debug this => _10; // in scope 7 at $SRC_DIR/core/src/intrinsics.rs:LL:COL - debug slice => _11; // in scope 7 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + debug this => _2; // in scope 7 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + debug slice => _6; // in scope 7 at $SRC_DIR/core/src/intrinsics.rs:LL:COL scope 8 (inlined ptr::mut_ptr::<impl *mut [u32]>::len) { // at $SRC_DIR/core/src/slice/index.rs:LL:COL - debug self => _11; // in scope 8 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - let mut _12: *const [u32]; // in scope 8 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug self => _6; // in scope 8 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + let mut _10: *const [u32]; // in scope 8 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL scope 9 (inlined std::ptr::metadata::<[u32]>) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - debug ptr => _12; // in scope 9 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + debug ptr => _10; // in scope 9 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL scope 10 { } } @@ -81,14 +79,10 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { StorageLive(_6); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL _6 = &raw mut (*_1); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL StorageLive(_10); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL - StorageLive(_11); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL - StorageLive(_12); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL StorageLive(_7); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL _7 = _6 as *mut u32 (PtrToPtr); // scope 11 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL _8 = Offset(_7, _2); // scope 13 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL StorageDead(_7); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL - StorageDead(_12); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL - StorageDead(_11); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL StorageDead(_10); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL StorageDead(_6); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL _9 = &mut (*_8); // scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.mir index 6d9ec5d9a27..727ccc1de53 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.mir @@ -4,65 +4,63 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) -> debug slice => _1; // in scope 0 at $DIR/slice_index.rs:+0:45: +0:50 debug index => _2; // in scope 0 at $DIR/slice_index.rs:+0:64: +0:69 let mut _0: &mut [u32]; // return place in scope 0 at $DIR/slice_index.rs:+0:88: +0:98 + let mut _3: usize; // in scope 0 at $DIR/slice_index.rs:+1:29: +1:34 + let mut _4: usize; // in scope 0 at $DIR/slice_index.rs:+1:29: +1:34 scope 1 (inlined core::slice::<impl [u32]>::get_unchecked_mut::<std::ops::Range<usize>>) { // at $DIR/slice_index.rs:26:11: 26:35 debug self => _1; // in scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL - debug index => _2; // in scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL - let mut _3: *mut [u32]; // in scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL - let mut _15: *mut [u32]; // in scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + debug index => std::ops::Range<usize>{ .0 => _3, .1 => _4, }; // in scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + let mut _5: *mut [u32]; // in scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + let mut _14: *mut [u32]; // in scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL scope 2 { scope 3 (inlined <std::ops::Range<usize> as SliceIndex<[u32]>>::get_unchecked_mut) { // at $SRC_DIR/core/src/slice/mod.rs:LL:COL - debug self => _2; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL - debug slice => _3; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL - let mut _4: usize; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL - let mut _5: usize; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL + debug self => std::ops::Range<usize>{ .0 => _3, .1 => _4, }; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL + debug slice => _5; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL let mut _7: *mut u32; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL - let mut _8: usize; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL - let mut _9: *mut u32; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL - let mut _10: usize; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL - let _16: std::ops::Range<usize>; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL - let mut _17: std::ops::Range<usize>; // in scope 3 at $SRC_DIR/core/src/intrinsics.rs:LL:COL - let mut _18: *mut [u32]; // in scope 3 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + let mut _8: *mut u32; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL + let mut _9: usize; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL + let _16: usize; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL + let _17: usize; // in scope 3 at $SRC_DIR/core/src/slice/index.rs:LL:COL scope 4 { - debug this => _16; // in scope 4 at $SRC_DIR/core/src/slice/index.rs:LL:COL + debug this => std::ops::Range<usize>{ .0 => _16, .1 => _17, }; // in scope 4 at $SRC_DIR/core/src/slice/index.rs:LL:COL scope 5 { let _6: usize; // in scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL scope 6 { debug new_len => _6; // in scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL scope 11 (inlined ptr::mut_ptr::<impl *mut [u32]>::as_mut_ptr) { // at $SRC_DIR/core/src/slice/index.rs:LL:COL - debug self => _3; // in scope 11 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug self => _5; // in scope 11 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL } scope 12 (inlined ptr::mut_ptr::<impl *mut u32>::add) { // at $SRC_DIR/core/src/slice/index.rs:LL:COL debug self => _7; // in scope 12 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - debug count => _8; // in scope 12 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug count => _3; // in scope 12 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL scope 13 { } } scope 14 (inlined slice_from_raw_parts_mut::<u32>) { // at $SRC_DIR/core/src/slice/index.rs:LL:COL - debug data => _9; // in scope 14 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL - debug len => _10; // in scope 14 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL - let mut _11: *mut (); // in scope 14 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + debug data => _8; // in scope 14 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + debug len => _9; // in scope 14 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + let mut _10: *mut (); // in scope 14 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL scope 15 (inlined ptr::mut_ptr::<impl *mut u32>::cast::<()>) { // at $SRC_DIR/core/src/ptr/mod.rs:LL:COL - debug self => _9; // in scope 15 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug self => _8; // in scope 15 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL } scope 16 (inlined std::ptr::from_raw_parts_mut::<[u32]>) { // at $SRC_DIR/core/src/ptr/mod.rs:LL:COL - debug data_address => _11; // in scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL - debug metadata => _10; // in scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL - let mut _12: *const (); // in scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL - let mut _13: std::ptr::metadata::PtrComponents<[u32]>; // in scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL - let mut _14: std::ptr::metadata::PtrRepr<[u32]>; // in scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + debug data_address => _10; // in scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + debug metadata => _9; // in scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + let mut _11: *const (); // in scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + let mut _12: std::ptr::metadata::PtrComponents<[u32]>; // in scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + let mut _13: std::ptr::metadata::PtrRepr<[u32]>; // in scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL scope 17 { } } } } scope 7 (inlined <std::ops::Range<usize> as SliceIndex<[T]>>::get_unchecked_mut::runtime::<u32>) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL - debug this => _17; // in scope 7 at $SRC_DIR/core/src/intrinsics.rs:LL:COL - debug slice => _18; // in scope 7 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + debug this => std::ops::Range<usize>{ .0 => _16, .1 => _17, }; // in scope 7 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + debug slice => _5; // in scope 7 at $SRC_DIR/core/src/intrinsics.rs:LL:COL scope 8 (inlined ptr::mut_ptr::<impl *mut [u32]>::len) { // at $SRC_DIR/core/src/slice/index.rs:LL:COL - debug self => _18; // in scope 8 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - let mut _19: *const [u32]; // in scope 8 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug self => _5; // in scope 8 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + let mut _15: *const [u32]; // in scope 8 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL scope 9 (inlined std::ptr::metadata::<[u32]>) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - debug ptr => _19; // in scope 9 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + debug ptr => _15; // in scope 9 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL scope 10 { } } @@ -75,60 +73,51 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) -> } bb0: { + _3 = move (_2.0: usize); // scope 0 at $DIR/slice_index.rs:+1:29: +1:34 + _4 = move (_2.1: usize); // scope 0 at $DIR/slice_index.rs:+1:29: +1:34 + StorageLive(_14); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + StorageLive(_5); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + _5 = &raw mut (*_1); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL StorageLive(_15); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL - StorageLive(_3); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL - _3 = &raw mut (*_1); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL StorageLive(_16); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL StorageLive(_17); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL - StorageLive(_18); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL - StorageLive(_19); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL StorageLive(_6); // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL - StorageLive(_4); // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL - _4 = (_2.1: usize); // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL - StorageLive(_5); // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL - _5 = (_2.0: usize); // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL - _6 = unchecked_sub::<usize>(move _4, move _5) -> [return: bb1, unwind unreachable]; // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL + _6 = unchecked_sub::<usize>(_4, _3) -> [return: bb1, unwind unreachable]; // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/slice/index.rs:LL:COL // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(usize, usize) -> usize {unchecked_sub::<usize>}, val: Value(<ZST>) } } bb1: { - StorageDead(_5); // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL - StorageDead(_4); // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL - StorageLive(_9); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL - StorageLive(_7); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL - _7 = _3 as *mut u32 (PtrToPtr); // scope 11 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL StorageLive(_8); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL - _8 = (_2.0: usize); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL - _9 = Offset(_7, _8); // scope 13 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - StorageDead(_8); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL + StorageLive(_7); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL + _7 = _5 as *mut u32 (PtrToPtr); // scope 11 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + _8 = Offset(_7, _3); // scope 13 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL StorageDead(_7); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL - StorageLive(_10); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL - _10 = _6; // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL - StorageLive(_11); // scope 14 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL - _11 = _9 as *mut () (PtrToPtr); // scope 15 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - StorageLive(_14); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + StorageLive(_9); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL + _9 = _6; // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL + StorageLive(_10); // scope 14 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + _10 = _8 as *mut () (PtrToPtr); // scope 15 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL StorageLive(_13); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL StorageLive(_12); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL - _12 = _11 as *const () (Pointer(MutToConstPointer)); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL - _13 = ptr::metadata::PtrComponents::<[u32]> { data_address: move _12, metadata: _10 }; // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + StorageLive(_11); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + _11 = _10 as *const () (Pointer(MutToConstPointer)); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + _12 = ptr::metadata::PtrComponents::<[u32]> { data_address: move _11, metadata: _9 }; // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + StorageDead(_11); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + _13 = ptr::metadata::PtrRepr::<[u32]> { const_ptr: move _12 }; // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL StorageDead(_12); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL - _14 = ptr::metadata::PtrRepr::<[u32]> { const_ptr: move _13 }; // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL - StorageDead(_13); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL - _15 = (_14.1: *mut [u32]); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL - StorageDead(_14); // scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL - StorageDead(_11); // scope 14 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL - StorageDead(_10); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL + _14 = (_13.1: *mut [u32]); // scope 17 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + StorageDead(_13); // scope 16 at $SRC_DIR/core/src/ptr/metadata.rs:LL:COL + StorageDead(_10); // scope 14 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL StorageDead(_9); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL + StorageDead(_8); // scope 6 at $SRC_DIR/core/src/slice/index.rs:LL:COL StorageDead(_6); // scope 5 at $SRC_DIR/core/src/slice/index.rs:LL:COL - StorageDead(_19); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL - StorageDead(_18); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL StorageDead(_17); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL StorageDead(_16); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL - StorageDead(_3); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL - _0 = &mut (*_15); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL - StorageDead(_15); // scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + StorageDead(_15); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + StorageDead(_5); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + _0 = &mut (*_14); // scope 2 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + StorageDead(_14); // scope 1 at $SRC_DIR/core/src/slice/mod.rs:LL:COL return; // scope 0 at $DIR/slice_index.rs:+2:2: +2:2 } } diff --git a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.mir new file mode 100644 index 00000000000..4dd11c1e529 --- /dev/null +++ b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.mir @@ -0,0 +1,213 @@ +// MIR for `enumerated_loop` after PreCodegen + +fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { + debug slice => _1; // in scope 0 at $DIR/slice_iter.rs:+0:31: +0:36 + debug f => _2; // in scope 0 at $DIR/slice_iter.rs:+0:47: +0:48 + let mut _0: (); // return place in scope 0 at $DIR/slice_iter.rs:+0:70: +0:70 + let mut _13: std::slice::Iter<'_, T>; // in scope 0 at $DIR/slice_iter.rs:+1:19: +1:31 + let mut _14: std::iter::Enumerate<std::slice::Iter<'_, T>>; // in scope 0 at $DIR/slice_iter.rs:+1:19: +1:43 + let mut _15: std::iter::Enumerate<std::slice::Iter<'_, T>>; // in scope 0 at $DIR/slice_iter.rs:+1:19: +1:43 + let mut _16: &mut std::iter::Enumerate<std::slice::Iter<'_, T>>; // in scope 0 at $DIR/slice_iter.rs:+1:19: +1:43 + let mut _17: std::option::Option<(usize, &T)>; // in scope 0 at $DIR/slice_iter.rs:+1:19: +1:43 + let mut _18: isize; // in scope 0 at $DIR/slice_iter.rs:+1:5: +3:6 + let mut _21: &impl Fn(usize, &T); // in scope 0 at $DIR/slice_iter.rs:+2:9: +2:10 + let mut _22: (usize, &T); // in scope 0 at $DIR/slice_iter.rs:+2:9: +2:16 + let _23: (); // in scope 0 at $DIR/slice_iter.rs:+1:19: +1:43 + scope 1 { + debug iter => _15; // in scope 1 at $DIR/slice_iter.rs:+1:19: +1:43 + let _19: usize; // in scope 1 at $DIR/slice_iter.rs:+1:10: +1:11 + let _20: &T; // in scope 1 at $DIR/slice_iter.rs:+1:13: +1:14 + scope 2 { + debug i => _19; // in scope 2 at $DIR/slice_iter.rs:+1:10: +1:11 + debug x => _20; // in scope 2 at $DIR/slice_iter.rs:+1:13: +1:14 + } + } + scope 3 (inlined core::slice::<impl [T]>::iter) { // at $DIR/slice_iter.rs:42:25: 42:31 + debug self => _1; // in scope 3 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + scope 4 (inlined std::slice::Iter::<'_, T>::new) { // at $SRC_DIR/core/src/slice/mod.rs:LL:COL + debug slice => _1; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + let _4: *const T; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + let mut _5: bool; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + let mut _6: usize; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + let mut _8: usize; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + let mut _9: *mut T; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + let mut _11: std::ptr::NonNull<T>; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + let mut _12: *const T; // in scope 4 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + scope 5 { + debug ptr => _4; // in scope 5 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + scope 6 { + let _7: *const T; // in scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + scope 7 { + debug end => _7; // in scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + scope 13 (inlined NonNull::<T>::new_unchecked) { // at $SRC_DIR/core/src/slice/iter.rs:LL:COL + debug ptr => _9; // in scope 13 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL + let mut _10: *const T; // in scope 13 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL + scope 14 { + scope 15 (inlined NonNull::<T>::new_unchecked::runtime::<T>) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL + debug ptr => _9; // in scope 15 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + scope 16 (inlined ptr::mut_ptr::<impl *mut T>::is_null) { // at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL + debug self => _9; // in scope 16 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + let mut _24: *mut u8; // in scope 16 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + scope 17 { + scope 18 (inlined ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug ptr => _24; // in scope 18 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + scope 19 (inlined ptr::mut_ptr::<impl *mut u8>::addr) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug self => _24; // in scope 19 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + scope 20 { + scope 21 (inlined ptr::mut_ptr::<impl *mut u8>::cast::<()>) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug self => _24; // in scope 21 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + } + } + } + } + } + } + } + } + } + } + scope 9 (inlined invalid::<T>) { // at $SRC_DIR/core/src/slice/iter.rs:LL:COL + debug addr => _8; // in scope 9 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + scope 10 { + } + } + scope 11 (inlined ptr::const_ptr::<impl *const T>::add) { // at $SRC_DIR/core/src/slice/iter.rs:LL:COL + debug self => _4; // in scope 11 at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + debug count => _6; // in scope 11 at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + scope 12 { + } + } + } + } + scope 8 (inlined core::slice::<impl [T]>::as_ptr) { // at $SRC_DIR/core/src/slice/iter.rs:LL:COL + debug self => _1; // in scope 8 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + let mut _3: *const [T]; // in scope 8 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + } + } + } + scope 22 (inlined <std::slice::Iter<'_, T> as Iterator>::enumerate) { // at $DIR/slice_iter.rs:42:32: 42:43 + debug self => _13; // in scope 22 at $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL + scope 23 (inlined Enumerate::<std::slice::Iter<'_, T>>::new) { // at $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL + debug iter => _13; // in scope 23 at $SRC_DIR/core/src/iter/adapters/enumerate.rs:LL:COL + } + } + scope 24 (inlined <Enumerate<std::slice::Iter<'_, T>> as IntoIterator>::into_iter) { // at $DIR/slice_iter.rs:42:19: 42:43 + debug self => _14; // in scope 24 at $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL + } + + bb0: { + StorageLive(_13); // scope 0 at $DIR/slice_iter.rs:+1:19: +1:31 + StorageLive(_4); // scope 3 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + StorageLive(_3); // scope 8 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + _3 = &raw const (*_1); // scope 8 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + _4 = move _3 as *const T (PtrToPtr); // scope 8 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + StorageDead(_3); // scope 8 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + StorageLive(_7); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageLive(_5); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + _5 = const _; // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + switchInt(move _5) -> [0: bb1, otherwise: bb2]; // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + } + + bb1: { + StorageLive(_6); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + _6 = Len((*_1)); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + _7 = Offset(_4, _6); // scope 12 at $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL + StorageDead(_6); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + goto -> bb3; // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + } + + bb2: { + StorageLive(_8); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + _8 = Len((*_1)); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + _7 = _8 as *const T (Transmute); // scope 10 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL + StorageDead(_8); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + goto -> bb3; // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + } + + bb3: { + StorageDead(_5); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageLive(_11); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageLive(_9); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + _9 = _4 as *mut T (PtrToPtr); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageLive(_10); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageLive(_24); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + _10 = _9 as *const T (Pointer(MutToConstPointer)); // scope 14 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL + _11 = NonNull::<T> { pointer: _10 }; // scope 14 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL + StorageDead(_24); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageDead(_10); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageDead(_9); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageLive(_12); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + _12 = _7; // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + _13 = std::slice::Iter::<'_, T> { ptr: move _11, end: move _12, _marker: const ZeroSized: PhantomData<&T> }; // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + // mir::Constant + // + span: no-location + // + literal: Const { ty: PhantomData<&T>, val: Value(<ZST>) } + // adt + // + user_ty: UserType(1) + StorageDead(_12); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageDead(_11); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageDead(_7); // scope 6 at $SRC_DIR/core/src/slice/iter.rs:LL:COL + StorageDead(_4); // scope 3 at $SRC_DIR/core/src/slice/mod.rs:LL:COL + _14 = Enumerate::<std::slice::Iter<'_, T>> { iter: move _13, count: const 0_usize }; // scope 23 at $SRC_DIR/core/src/iter/adapters/enumerate.rs:LL:COL + StorageDead(_13); // scope 0 at $DIR/slice_iter.rs:+1:42: +1:43 + StorageLive(_15); // scope 0 at $DIR/slice_iter.rs:+1:19: +1:43 + _15 = move _14; // scope 0 at $DIR/slice_iter.rs:+1:19: +1:43 + goto -> bb4; // scope 1 at $DIR/slice_iter.rs:+1:5: +3:6 + } + + bb4: { + StorageLive(_17); // scope 1 at $DIR/slice_iter.rs:+1:19: +1:43 + _16 = &mut _15; // scope 1 at $DIR/slice_iter.rs:+1:19: +1:43 + _17 = <Enumerate<std::slice::Iter<'_, T>> as Iterator>::next(_16) -> [return: bb5, unwind: bb11]; // scope 1 at $DIR/slice_iter.rs:+1:19: +1:43 + // mir::Constant + // + span: $DIR/slice_iter.rs:42:19: 42:43 + // + literal: Const { ty: for<'a> fn(&'a mut Enumerate<std::slice::Iter<'_, T>>) -> Option<<Enumerate<std::slice::Iter<'_, T>> as Iterator>::Item> {<Enumerate<std::slice::Iter<'_, T>> as Iterator>::next}, val: Value(<ZST>) } + } + + bb5: { + _18 = discriminant(_17); // scope 1 at $DIR/slice_iter.rs:+1:19: +1:43 + switchInt(move _18) -> [0: bb6, 1: bb8, otherwise: bb10]; // scope 1 at $DIR/slice_iter.rs:+1:19: +1:43 + } + + bb6: { + StorageDead(_17); // scope 1 at $DIR/slice_iter.rs:+3:5: +3:6 + StorageDead(_15); // scope 0 at $DIR/slice_iter.rs:+3:5: +3:6 + drop(_2) -> bb7; // scope 0 at $DIR/slice_iter.rs:+4:1: +4:2 + } + + bb7: { + return; // scope 0 at $DIR/slice_iter.rs:+4:2: +4:2 + } + + bb8: { + _19 = (((_17 as Some).0: (usize, &T)).0: usize); // scope 1 at $DIR/slice_iter.rs:+1:10: +1:11 + _20 = (((_17 as Some).0: (usize, &T)).1: &T); // scope 1 at $DIR/slice_iter.rs:+1:13: +1:14 + StorageLive(_21); // scope 2 at $DIR/slice_iter.rs:+2:9: +2:10 + _21 = &_2; // scope 2 at $DIR/slice_iter.rs:+2:9: +2:10 + StorageLive(_22); // scope 2 at $DIR/slice_iter.rs:+2:9: +2:16 + _22 = (_19, _20); // scope 2 at $DIR/slice_iter.rs:+2:9: +2:16 + _23 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _21, move _22) -> [return: bb9, unwind: bb11]; // scope 2 at $DIR/slice_iter.rs:+2:9: +2:16 + // mir::Constant + // + span: $DIR/slice_iter.rs:43:9: 43:10 + // + literal: Const { ty: for<'a> extern "rust-call" fn(&'a impl Fn(usize, &T), (usize, &T)) -> <impl Fn(usize, &T) as FnOnce<(usize, &T)>>::Output {<impl Fn(usize, &T) as Fn<(usize, &T)>>::call}, val: Value(<ZST>) } + } + + bb9: { + StorageDead(_22); // scope 2 at $DIR/slice_iter.rs:+2:15: +2:16 + StorageDead(_21); // scope 2 at $DIR/slice_iter.rs:+2:15: +2:16 + StorageDead(_17); // scope 1 at $DIR/slice_iter.rs:+3:5: +3:6 + goto -> bb4; // scope 1 at $DIR/slice_iter.rs:+1:5: +3:6 + } + + bb10: { + unreachable; // scope 1 at $DIR/slice_iter.rs:+1:19: +1:43 + } + + bb11 (cleanup): { + drop(_2) -> [return: bb12, unwind terminate]; // scope 0 at $DIR/slice_iter.rs:+4:1: +4:2 + } + + bb12 (cleanup): { + resume; // scope 0 at $DIR/slice_iter.rs:+0:1: +4:2 + } +} diff --git a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.mir index 0cf1d68d18a..0c18fb84bcd 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.mir @@ -39,21 +39,20 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { scope 13 (inlined NonNull::<T>::new_unchecked) { // at $SRC_DIR/core/src/slice/iter.rs:LL:COL debug ptr => _9; // in scope 13 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL let mut _10: *const T; // in scope 13 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL - let mut _22: *mut T; // in scope 13 at $SRC_DIR/core/src/intrinsics.rs:LL:COL scope 14 { scope 15 (inlined NonNull::<T>::new_unchecked::runtime::<T>) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL - debug ptr => _22; // in scope 15 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + debug ptr => _9; // in scope 15 at $SRC_DIR/core/src/intrinsics.rs:LL:COL scope 16 (inlined ptr::mut_ptr::<impl *mut T>::is_null) { // at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL - debug self => _22; // in scope 16 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - let mut _23: *mut u8; // in scope 16 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug self => _9; // in scope 16 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + let mut _22: *mut u8; // in scope 16 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL scope 17 { scope 18 (inlined ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - debug ptr => _23; // in scope 18 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug ptr => _22; // in scope 18 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL scope 19 (inlined ptr::mut_ptr::<impl *mut u8>::addr) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - debug self => _23; // in scope 19 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug self => _22; // in scope 19 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL scope 20 { scope 21 (inlined ptr::mut_ptr::<impl *mut u8>::cast::<()>) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - debug self => _23; // in scope 21 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug self => _22; // in scope 21 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL } } } @@ -122,10 +121,8 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { _9 = _4 as *mut T (PtrToPtr); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL StorageLive(_10); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL StorageLive(_22); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL - StorageLive(_23); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL _10 = _9 as *const T (Pointer(MutToConstPointer)); // scope 14 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL _11 = NonNull::<T> { pointer: _10 }; // scope 14 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL - StorageDead(_23); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL StorageDead(_22); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL StorageDead(_10); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL StorageDead(_9); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL diff --git a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.mir new file mode 100644 index 00000000000..870496f14ea --- /dev/null +++ b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.mir @@ -0,0 +1,161 @@ +// MIR for `range_loop` after PreCodegen + +fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { + debug slice => _1; // in scope 0 at $DIR/slice_iter.rs:+0:26: +0:31 + debug f => _2; // in scope 0 at $DIR/slice_iter.rs:+0:42: +0:43 + let mut _0: (); // return place in scope 0 at $DIR/slice_iter.rs:+0:65: +0:65 + let mut _3: usize; // in scope 0 at $DIR/slice_iter.rs:+1:17: +1:28 + let mut _4: std::ops::Range<usize>; // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:28 + let mut _5: std::ops::Range<usize>; // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:28 + let mut _6: &mut std::ops::Range<usize>; // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:28 + let mut _12: std::option::Option<usize>; // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:28 + let mut _15: isize; // in scope 0 at $DIR/slice_iter.rs:+1:5: +4:6 + let mut _17: usize; // in scope 0 at $DIR/slice_iter.rs:+2:18: +2:26 + let mut _18: bool; // in scope 0 at $DIR/slice_iter.rs:+2:18: +2:26 + let mut _20: &impl Fn(usize, &T); // in scope 0 at $DIR/slice_iter.rs:+3:9: +3:10 + let mut _21: (usize, &T); // in scope 0 at $DIR/slice_iter.rs:+3:9: +3:16 + let _22: (); // in scope 0 at $DIR/slice_iter.rs:+1:14: +1:28 + scope 1 { + debug iter => _5; // in scope 1 at $DIR/slice_iter.rs:+1:14: +1:28 + let _16: usize; // in scope 1 at $DIR/slice_iter.rs:+1:9: +1:10 + scope 2 { + debug i => _16; // in scope 2 at $DIR/slice_iter.rs:+1:9: +1:10 + let _19: &T; // in scope 2 at $DIR/slice_iter.rs:+2:13: +2:14 + scope 3 { + debug x => _19; // in scope 3 at $DIR/slice_iter.rs:+2:13: +2:14 + } + } + scope 5 (inlined iter::range::<impl Iterator for std::ops::Range<usize>>::next) { // at $DIR/slice_iter.rs:49:14: 49:28 + debug self => _6; // in scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + scope 6 (inlined <std::ops::Range<usize> as iter::range::RangeIteratorImpl>::spec_next) { // at $SRC_DIR/core/src/iter/range.rs:LL:COL + debug self => _6; // in scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + let mut _7: &usize; // in scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + let mut _8: &usize; // in scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + let mut _11: bool; // in scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + let _13: usize; // in scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + let mut _14: usize; // in scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + scope 7 { + debug old => _13; // in scope 7 at $SRC_DIR/core/src/iter/range.rs:LL:COL + scope 8 { + } + } + scope 9 (inlined cmp::impls::<impl PartialOrd for usize>::lt) { // at $SRC_DIR/core/src/iter/range.rs:LL:COL + debug self => _7; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + debug other => _8; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _9: usize; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + let mut _10: usize; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + } + } + } + } + scope 4 (inlined <std::ops::Range<usize> as IntoIterator>::into_iter) { // at $DIR/slice_iter.rs:49:14: 49:28 + debug self => _4; // in scope 4 at $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL + } + + bb0: { + StorageLive(_3); // scope 0 at $DIR/slice_iter.rs:+1:17: +1:28 + _3 = Len((*_1)); // scope 0 at $DIR/slice_iter.rs:+1:17: +1:28 + _4 = std::ops::Range::<usize> { start: const 0_usize, end: move _3 }; // scope 0 at $DIR/slice_iter.rs:+1:14: +1:28 + StorageDead(_3); // scope 0 at $DIR/slice_iter.rs:+1:27: +1:28 + StorageLive(_5); // scope 0 at $DIR/slice_iter.rs:+1:14: +1:28 + _5 = move _4; // scope 0 at $DIR/slice_iter.rs:+1:14: +1:28 + goto -> bb1; // scope 1 at $DIR/slice_iter.rs:+1:5: +4:6 + } + + bb1: { + StorageLive(_12); // scope 1 at $DIR/slice_iter.rs:+1:14: +1:28 + _6 = &mut _5; // scope 1 at $DIR/slice_iter.rs:+1:14: +1:28 + StorageLive(_13); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageLive(_11); // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageLive(_7); // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + _7 = &((*_6).0: usize); // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageLive(_8); // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + _8 = &((*_6).1: usize); // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageLive(_9); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + _9 = (*_7); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageLive(_10); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + _10 = (*_8); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + _11 = Lt(move _9, move _10); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_10); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_9); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL + StorageDead(_8); // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageDead(_7); // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + switchInt(move _11) -> [0: bb2, otherwise: bb3]; // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + } + + bb2: { + _12 = Option::<usize>::None; // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + goto -> bb5; // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + } + + bb3: { + _13 = ((*_6).0: usize); // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageLive(_14); // scope 7 at $SRC_DIR/core/src/iter/range.rs:LL:COL + _14 = <usize as Step>::forward_unchecked(_13, const 1_usize) -> [return: bb4, unwind: bb12]; // scope 8 at $SRC_DIR/core/src/iter/range.rs:LL:COL + // mir::Constant + // + span: $SRC_DIR/core/src/iter/range.rs:LL:COL + // + literal: Const { ty: unsafe fn(usize, usize) -> usize {<usize as Step>::forward_unchecked}, val: Value(<ZST>) } + } + + bb4: { + ((*_6).0: usize) = move _14; // scope 7 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageDead(_14); // scope 7 at $SRC_DIR/core/src/iter/range.rs:LL:COL + _12 = Option::<usize>::Some(_13); // scope 7 at $SRC_DIR/core/src/iter/range.rs:LL:COL + goto -> bb5; // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + } + + bb5: { + StorageDead(_11); // scope 6 at $SRC_DIR/core/src/iter/range.rs:LL:COL + StorageDead(_13); // scope 5 at $SRC_DIR/core/src/iter/range.rs:LL:COL + _15 = discriminant(_12); // scope 1 at $DIR/slice_iter.rs:+1:14: +1:28 + switchInt(move _15) -> [0: bb6, 1: bb8, otherwise: bb11]; // scope 1 at $DIR/slice_iter.rs:+1:14: +1:28 + } + + bb6: { + StorageDead(_12); // scope 1 at $DIR/slice_iter.rs:+4:5: +4:6 + StorageDead(_5); // scope 0 at $DIR/slice_iter.rs:+4:5: +4:6 + drop(_2) -> bb7; // scope 0 at $DIR/slice_iter.rs:+5:1: +5:2 + } + + bb7: { + return; // scope 0 at $DIR/slice_iter.rs:+5:2: +5:2 + } + + bb8: { + _16 = ((_12 as Some).0: usize); // scope 1 at $DIR/slice_iter.rs:+1:9: +1:10 + _17 = Len((*_1)); // scope 2 at $DIR/slice_iter.rs:+2:18: +2:26 + _18 = Lt(_16, _17); // scope 2 at $DIR/slice_iter.rs:+2:18: +2:26 + assert(move _18, "index out of bounds: the length is {} but the index is {}", move _17, _16) -> [success: bb9, unwind: bb12]; // scope 2 at $DIR/slice_iter.rs:+2:18: +2:26 + } + + bb9: { + _19 = &(*_1)[_16]; // scope 2 at $DIR/slice_iter.rs:+2:17: +2:26 + StorageLive(_20); // scope 3 at $DIR/slice_iter.rs:+3:9: +3:10 + _20 = &_2; // scope 3 at $DIR/slice_iter.rs:+3:9: +3:10 + StorageLive(_21); // scope 3 at $DIR/slice_iter.rs:+3:9: +3:16 + _21 = (_16, _19); // scope 3 at $DIR/slice_iter.rs:+3:9: +3:16 + _22 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _20, move _21) -> [return: bb10, unwind: bb12]; // scope 3 at $DIR/slice_iter.rs:+3:9: +3:16 + // mir::Constant + // + span: $DIR/slice_iter.rs:51:9: 51:10 + // + literal: Const { ty: for<'a> extern "rust-call" fn(&'a impl Fn(usize, &T), (usize, &T)) -> <impl Fn(usize, &T) as FnOnce<(usize, &T)>>::Output {<impl Fn(usize, &T) as Fn<(usize, &T)>>::call}, val: Value(<ZST>) } + } + + bb10: { + StorageDead(_21); // scope 3 at $DIR/slice_iter.rs:+3:15: +3:16 + StorageDead(_20); // scope 3 at $DIR/slice_iter.rs:+3:15: +3:16 + StorageDead(_12); // scope 1 at $DIR/slice_iter.rs:+4:5: +4:6 + goto -> bb1; // scope 1 at $DIR/slice_iter.rs:+1:5: +4:6 + } + + bb11: { + unreachable; // scope 1 at $DIR/slice_iter.rs:+1:14: +1:28 + } + + bb12 (cleanup): { + drop(_2) -> [return: bb13, unwind terminate]; // scope 0 at $DIR/slice_iter.rs:+5:1: +5:2 + } + + bb13 (cleanup): { + resume; // scope 0 at $DIR/slice_iter.rs:+0:1: +5:2 + } +} diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.mir index 4fde50c6fe4..1aa05cbeb97 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.mir @@ -44,21 +44,20 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { scope 13 (inlined NonNull::<T>::new_unchecked) { // at $SRC_DIR/core/src/slice/iter.rs:LL:COL debug ptr => _9; // in scope 13 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL let mut _10: *const T; // in scope 13 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL - let mut _24: *mut T; // in scope 13 at $SRC_DIR/core/src/intrinsics.rs:LL:COL scope 14 { scope 15 (inlined NonNull::<T>::new_unchecked::runtime::<T>) { // at $SRC_DIR/core/src/intrinsics.rs:LL:COL - debug ptr => _24; // in scope 15 at $SRC_DIR/core/src/intrinsics.rs:LL:COL + debug ptr => _9; // in scope 15 at $SRC_DIR/core/src/intrinsics.rs:LL:COL scope 16 (inlined ptr::mut_ptr::<impl *mut T>::is_null) { // at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL - debug self => _24; // in scope 16 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - let mut _25: *mut u8; // in scope 16 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug self => _9; // in scope 16 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + let mut _24: *mut u8; // in scope 16 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL scope 17 { scope 18 (inlined ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - debug ptr => _25; // in scope 18 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug ptr => _24; // in scope 18 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL scope 19 (inlined ptr::mut_ptr::<impl *mut u8>::addr) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - debug self => _25; // in scope 19 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug self => _24; // in scope 19 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL scope 20 { scope 21 (inlined ptr::mut_ptr::<impl *mut u8>::cast::<()>) { // at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL - debug self => _25; // in scope 21 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL + debug self => _24; // in scope 21 at $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL } } } @@ -134,10 +133,8 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { _9 = _4 as *mut T (PtrToPtr); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL StorageLive(_10); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL StorageLive(_24); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL - StorageLive(_25); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL _10 = _9 as *const T (Pointer(MutToConstPointer)); // scope 14 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL _11 = NonNull::<T> { pointer: _10 }; // scope 14 at $SRC_DIR/core/src/ptr/non_null.rs:LL:COL - StorageDead(_25); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL StorageDead(_24); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL StorageDead(_10); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL StorageDead(_9); // scope 7 at $SRC_DIR/core/src/slice/iter.rs:LL:COL diff --git a/tests/mir-opt/pre-codegen/slice_iter.rs b/tests/mir-opt/pre-codegen/slice_iter.rs index ca423ca55e6..a1cd85e753f 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.rs +++ b/tests/mir-opt/pre-codegen/slice_iter.rs @@ -36,3 +36,18 @@ pub fn reverse_loop<'a, T>(slice: &'a [T], f: impl Fn(&T)) { f(x) } } + +// EMIT_MIR slice_iter.enumerated_loop.PreCodegen.after.mir +pub fn enumerated_loop<'a, T>(slice: &'a [T], f: impl Fn(usize, &T)) { + for (i, x) in slice.iter().enumerate() { + f(i, x) + } +} + +// EMIT_MIR slice_iter.range_loop.PreCodegen.after.mir +pub fn range_loop<'a, T>(slice: &'a [T], f: impl Fn(usize, &T)) { + for i in 0..slice.len() { + let x = &slice[i]; + f(i, x) + } +} diff --git a/tests/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff b/tests/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff index bdf1de468b3..7f0e50a23f9 100644 --- a/tests/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff +++ b/tests/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff @@ -9,70 +9,61 @@ let mut _4: std::result::Result<i32, i32>; // in scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:9 let mut _5: isize; // in scope 0 at $DIR/separate_const_switch.rs:+1:9: +1:10 let _6: std::result::Result<std::convert::Infallible, i32>; // in scope 0 at $DIR/separate_const_switch.rs:+1:9: +1:10 - let mut _7: !; // in scope 0 at $DIR/separate_const_switch.rs:+1:9: +1:10 - let mut _8: std::result::Result<std::convert::Infallible, i32>; // in scope 0 at $DIR/separate_const_switch.rs:+1:9: +1:10 - let _9: i32; // in scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10 + let mut _7: std::result::Result<std::convert::Infallible, i32>; // in scope 0 at $DIR/separate_const_switch.rs:+1:9: +1:10 + let _8: i32; // in scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10 scope 1 { debug residual => _6; // in scope 1 at $DIR/separate_const_switch.rs:+1:9: +1:10 scope 2 { scope 8 (inlined #[track_caller] <Result<i32, i32> as FromResidual<Result<Infallible, i32>>>::from_residual) { // at $DIR/separate_const_switch.rs:25:8: 25:10 - debug residual => _8; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL - let _14: i32; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL - let mut _15: i32; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + debug residual => _6; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + let _13: i32; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + let mut _14: i32; // in scope 8 at $SRC_DIR/core/src/result.rs:LL:COL scope 9 { - debug e => _14; // in scope 9 at $SRC_DIR/core/src/result.rs:LL:COL + debug e => _13; // in scope 9 at $SRC_DIR/core/src/result.rs:LL:COL scope 10 (inlined <i32 as From<i32>>::from) { // at $SRC_DIR/core/src/result.rs:LL:COL - debug t => _14; // in scope 10 at $SRC_DIR/core/src/convert/mod.rs:LL:COL + debug t => _13; // in scope 10 at $SRC_DIR/core/src/convert/mod.rs:LL:COL } } } } } scope 3 { - debug val => _9; // in scope 3 at $DIR/separate_const_switch.rs:+1:8: +1:10 + debug val => _8; // in scope 3 at $DIR/separate_const_switch.rs:+1:8: +1:10 scope 4 { } } scope 5 (inlined <Result<i32, i32> as Try>::branch) { // at $DIR/separate_const_switch.rs:25:8: 25:10 - debug self => _4; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL - let mut _10: isize; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + debug self => _1; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + let mut _9: isize; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + let _10: i32; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL let _11: i32; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL - let _12: i32; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL - let mut _13: std::result::Result<std::convert::Infallible, i32>; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + let mut _12: std::result::Result<std::convert::Infallible, i32>; // in scope 5 at $SRC_DIR/core/src/result.rs:LL:COL scope 6 { - debug v => _11; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL + debug v => _10; // in scope 6 at $SRC_DIR/core/src/result.rs:LL:COL } scope 7 { - debug e => _12; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + debug e => _11; // in scope 7 at $SRC_DIR/core/src/result.rs:LL:COL } } bb0: { - StorageLive(_2); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10 StorageLive(_3); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10 - StorageLive(_4); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:9 - _4 = _1; // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:9 + StorageLive(_10); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10 StorageLive(_11); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10 - StorageLive(_12); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10 - _10 = discriminant(_4); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL - switchInt(move _10) -> [0: bb7, 1: bb5, otherwise: bb6]; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + _9 = discriminant(_1); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + switchInt(move _9) -> [0: bb7, 1: bb5, otherwise: bb6]; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL } bb1: { - StorageDead(_12); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10 StorageDead(_11); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10 - StorageDead(_4); // scope 0 at $DIR/separate_const_switch.rs:+1:9: +1:10 + StorageDead(_10); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10 _5 = discriminant(_3); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10 switchInt(move _5) -> [0: bb2, 1: bb4, otherwise: bb3]; // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10 } bb2: { - StorageLive(_9); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10 - _9 = ((_3 as Continue).0: i32); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10 - _2 = _9; // scope 4 at $DIR/separate_const_switch.rs:+1:8: +1:10 - StorageDead(_9); // scope 0 at $DIR/separate_const_switch.rs:+1:9: +1:10 - _0 = Result::<i32, i32>::Ok(move _2); // scope 0 at $DIR/separate_const_switch.rs:+1:5: +1:11 - StorageDead(_2); // scope 0 at $DIR/separate_const_switch.rs:+1:10: +1:11 + _8 = ((_3 as Continue).0: i32); // scope 0 at $DIR/separate_const_switch.rs:+1:8: +1:10 + _0 = Result::<i32, i32>::Ok(_8); // scope 0 at $DIR/separate_const_switch.rs:+1:5: +1:11 StorageDead(_3); // scope 0 at $DIR/separate_const_switch.rs:+2:1: +2:2 return; // scope 0 at $DIR/separate_const_switch.rs:+2:2: +2:2 } @@ -82,30 +73,19 @@ } bb4: { - StorageLive(_6); // scope 0 at $DIR/separate_const_switch.rs:+1:9: +1:10 _6 = ((_3 as Break).0: std::result::Result<std::convert::Infallible, i32>); // scope 0 at $DIR/separate_const_switch.rs:+1:9: +1:10 - StorageLive(_8); // scope 2 at $DIR/separate_const_switch.rs:+1:9: +1:10 - _8 = _6; // scope 2 at $DIR/separate_const_switch.rs:+1:9: +1:10 - StorageLive(_14); // scope 2 at $DIR/separate_const_switch.rs:+1:8: +1:10 - _14 = move ((_8 as Err).0: i32); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL - StorageLive(_15); // scope 9 at $SRC_DIR/core/src/result.rs:LL:COL - _15 = move _14; // scope 10 at $SRC_DIR/core/src/convert/mod.rs:LL:COL - _0 = Result::<i32, i32>::Err(move _15); // scope 9 at $SRC_DIR/core/src/result.rs:LL:COL - StorageDead(_15); // scope 9 at $SRC_DIR/core/src/result.rs:LL:COL - StorageDead(_14); // scope 2 at $DIR/separate_const_switch.rs:+1:8: +1:10 - StorageDead(_8); // scope 2 at $DIR/separate_const_switch.rs:+1:9: +1:10 - StorageDead(_6); // scope 0 at $DIR/separate_const_switch.rs:+1:9: +1:10 - StorageDead(_2); // scope 0 at $DIR/separate_const_switch.rs:+1:10: +1:11 + _13 = ((_6 as Err).0: i32); // scope 8 at $SRC_DIR/core/src/result.rs:LL:COL + _0 = Result::<i32, i32>::Err(move _13); // scope 9 at $SRC_DIR/core/src/result.rs:LL:COL StorageDead(_3); // scope 0 at $DIR/separate_const_switch.rs:+2:1: +2:2 return; // scope 0 at $DIR/separate_const_switch.rs:+2:2: +2:2 } bb5: { - _12 = move ((_4 as Err).0: i32); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL - StorageLive(_13); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - _13 = Result::<Infallible, i32>::Err(move _12); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - _3 = ControlFlow::<Result<Infallible, i32>, i32>::Break(move _13); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL - StorageDead(_13); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + _11 = ((_1 as Err).0: i32); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + StorageLive(_12); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + _12 = Result::<Infallible, i32>::Err(move _11); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + _3 = ControlFlow::<Result<Infallible, i32>, i32>::Break(move _12); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL + StorageDead(_12); // scope 7 at $SRC_DIR/core/src/result.rs:LL:COL goto -> bb1; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL } @@ -114,8 +94,8 @@ } bb7: { - _11 = move ((_4 as Ok).0: i32); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL - _3 = ControlFlow::<Result<Infallible, i32>, i32>::Continue(move _11); // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL + _10 = ((_1 as Ok).0: i32); // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL + _3 = ControlFlow::<Result<Infallible, i32>, i32>::Continue(move _10); // scope 6 at $SRC_DIR/core/src/result.rs:LL:COL goto -> bb1; // scope 5 at $SRC_DIR/core/src/result.rs:LL:COL } } diff --git a/tests/mir-opt/separate_const_switch.too_complex.SeparateConstSwitch.diff b/tests/mir-opt/separate_const_switch.too_complex.SeparateConstSwitch.diff index b5e0a66d83f..f86a96dec41 100644 --- a/tests/mir-opt/separate_const_switch.too_complex.SeparateConstSwitch.diff +++ b/tests/mir-opt/separate_const_switch.too_complex.SeparateConstSwitch.diff @@ -34,13 +34,8 @@ } bb1: { - StorageLive(_6); // scope 0 at $DIR/separate_const_switch.rs:+8:17: +8:18 _6 = ((_1 as Err).0: usize); // scope 0 at $DIR/separate_const_switch.rs:+8:17: +8:18 - StorageLive(_7); // scope 2 at $DIR/separate_const_switch.rs:+8:42: +8:43 - _7 = _6; // scope 2 at $DIR/separate_const_switch.rs:+8:42: +8:43 - _2 = ControlFlow::<usize, i32>::Break(move _7); // scope 2 at $DIR/separate_const_switch.rs:+8:23: +8:44 - StorageDead(_7); // scope 2 at $DIR/separate_const_switch.rs:+8:43: +8:44 - StorageDead(_6); // scope 0 at $DIR/separate_const_switch.rs:+8:43: +8:44 + _2 = ControlFlow::<usize, i32>::Break(_6); // scope 2 at $DIR/separate_const_switch.rs:+8:23: +8:44 goto -> bb4; // scope 0 at $DIR/separate_const_switch.rs:+8:43: +8:44 } @@ -49,13 +44,8 @@ } bb3: { - StorageLive(_4); // scope 0 at $DIR/separate_const_switch.rs:+7:16: +7:17 _4 = ((_1 as Ok).0: i32); // scope 0 at $DIR/separate_const_switch.rs:+7:16: +7:17 - StorageLive(_5); // scope 1 at $DIR/separate_const_switch.rs:+7:44: +7:45 - _5 = _4; // scope 1 at $DIR/separate_const_switch.rs:+7:44: +7:45 - _2 = ControlFlow::<usize, i32>::Continue(move _5); // scope 1 at $DIR/separate_const_switch.rs:+7:22: +7:46 - StorageDead(_5); // scope 1 at $DIR/separate_const_switch.rs:+7:45: +7:46 - StorageDead(_4); // scope 0 at $DIR/separate_const_switch.rs:+7:45: +7:46 + _2 = ControlFlow::<usize, i32>::Continue(_4); // scope 1 at $DIR/separate_const_switch.rs:+7:22: +7:46 goto -> bb4; // scope 0 at $DIR/separate_const_switch.rs:+7:45: +7:46 } @@ -73,13 +63,8 @@ } bb6: { - StorageLive(_9); // scope 0 at $DIR/separate_const_switch.rs:+11:31: +11:32 _9 = ((_2 as Continue).0: i32); // scope 0 at $DIR/separate_const_switch.rs:+11:31: +11:32 - StorageLive(_10); // scope 3 at $DIR/separate_const_switch.rs:+11:42: +11:43 - _10 = _9; // scope 3 at $DIR/separate_const_switch.rs:+11:42: +11:43 - _0 = Option::<i32>::Some(move _10); // scope 3 at $DIR/separate_const_switch.rs:+11:37: +11:44 - StorageDead(_10); // scope 3 at $DIR/separate_const_switch.rs:+11:43: +11:44 - StorageDead(_9); // scope 0 at $DIR/separate_const_switch.rs:+11:43: +11:44 + _0 = Option::<i32>::Some(_9); // scope 3 at $DIR/separate_const_switch.rs:+11:37: +11:44 goto -> bb7; // scope 0 at $DIR/separate_const_switch.rs:+11:43: +11:44 } diff --git a/tests/mir-opt/slice_filter.rs b/tests/mir-opt/slice_filter.rs deleted file mode 100644 index be32f40f132..00000000000 --- a/tests/mir-opt/slice_filter.rs +++ /dev/null @@ -1,20 +0,0 @@ -fn main() { - let input = vec![]; - let _variant_a_result = variant_a(&input); - let _variant_b_result = variant_b(&input); -} - -pub fn variant_a(input: &[(usize, usize, usize, usize)]) -> usize { - input.iter().filter(|(a, b, c, d)| a <= c && d <= b || c <= a && b <= d).count() -} - -pub fn variant_b(input: &[(usize, usize, usize, usize)]) -> usize { - input.iter().filter(|&&(a, b, c, d)| a <= c && d <= b || c <= a && b <= d).count() -} - -// EMIT_MIR slice_filter.variant_a-{closure#0}.ReferencePropagation.diff -// EMIT_MIR slice_filter.variant_a-{closure#0}.CopyProp.diff -// EMIT_MIR slice_filter.variant_a-{closure#0}.DestinationPropagation.diff -// EMIT_MIR slice_filter.variant_b-{closure#0}.CopyProp.diff -// EMIT_MIR slice_filter.variant_b-{closure#0}.ReferencePropagation.diff -// EMIT_MIR slice_filter.variant_b-{closure#0}.DestinationPropagation.diff diff --git a/tests/mir-opt/slice_filter.variant_a-{closure#0}.CopyProp.diff b/tests/mir-opt/slice_filter.variant_a-{closure#0}.CopyProp.diff deleted file mode 100644 index 60e5056c7a9..00000000000 --- a/tests/mir-opt/slice_filter.variant_a-{closure#0}.CopyProp.diff +++ /dev/null @@ -1,279 +0,0 @@ -- // MIR for `variant_a::{closure#0}` before CopyProp -+ // MIR for `variant_a::{closure#0}` after CopyProp - - fn variant_a::{closure#0}(_1: &mut [closure@$DIR/slice_filter.rs:8:25: 8:39], _2: &&(usize, usize, usize, usize)) -> bool { - let mut _0: bool; // return place in scope 0 at $DIR/slice_filter.rs:+0:40: +0:40 - let _3: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:27: +0:28 - let _4: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:30: +0:31 - let _5: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:33: +0:34 - let _6: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:36: +0:37 - let mut _7: bool; // in scope 0 at $DIR/slice_filter.rs:+0:40: +0:56 - let mut _8: bool; // in scope 0 at $DIR/slice_filter.rs:+0:40: +0:46 - let mut _9: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:40: +0:41 - let mut _10: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:45: +0:46 - let _11: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:45: +0:46 - let mut _12: bool; // in scope 0 at $DIR/slice_filter.rs:+0:50: +0:56 - let mut _13: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:50: +0:51 - let mut _14: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:55: +0:56 - let _15: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:55: +0:56 - let mut _16: bool; // in scope 0 at $DIR/slice_filter.rs:+0:60: +0:76 - let mut _17: bool; // in scope 0 at $DIR/slice_filter.rs:+0:60: +0:66 - let mut _18: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:60: +0:61 - let mut _19: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:65: +0:66 - let _20: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:65: +0:66 - let mut _21: bool; // in scope 0 at $DIR/slice_filter.rs:+0:70: +0:76 - let mut _22: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:70: +0:71 - let mut _23: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 - let _24: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 - let mut _25: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 - let mut _26: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 - let mut _27: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 - let mut _28: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 - let mut _31: &usize; // in scope 0 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _32: &usize; // in scope 0 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _37: &usize; // in scope 0 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _38: &usize; // in scope 0 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _43: &usize; // in scope 0 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _44: &usize; // in scope 0 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _49: &usize; // in scope 0 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _50: &usize; // in scope 0 at $SRC_DIR/core/src/cmp.rs:LL:COL - scope 1 { - debug a => _3; // in scope 1 at $DIR/slice_filter.rs:+0:27: +0:28 - debug b => _4; // in scope 1 at $DIR/slice_filter.rs:+0:30: +0:31 - debug c => _5; // in scope 1 at $DIR/slice_filter.rs:+0:33: +0:34 - debug d => _6; // in scope 1 at $DIR/slice_filter.rs:+0:36: +0:37 - scope 2 (inlined cmp::impls::<impl PartialOrd for &usize>::le) { // at $DIR/slice_filter.rs:8:40: 8:46 - debug self => _9; // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL - debug other => _10; // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _29: &usize; // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _30: &usize; // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL - scope 3 (inlined cmp::impls::<impl PartialOrd for usize>::le) { // at $SRC_DIR/core/src/cmp.rs:LL:COL -- debug self => _31; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL -- debug other => _32; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ debug self => _29; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ debug other => _30; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _33: usize; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _34: usize; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL - } - } - scope 4 (inlined cmp::impls::<impl PartialOrd for &usize>::le) { // at $DIR/slice_filter.rs:8:60: 8:66 - debug self => _18; // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL - debug other => _19; // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _35: &usize; // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _36: &usize; // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL - scope 5 (inlined cmp::impls::<impl PartialOrd for usize>::le) { // at $SRC_DIR/core/src/cmp.rs:LL:COL -- debug self => _37; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL -- debug other => _38; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ debug self => _35; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ debug other => _36; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _39: usize; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _40: usize; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL - } - } - scope 6 (inlined cmp::impls::<impl PartialOrd for &usize>::le) { // at $DIR/slice_filter.rs:8:50: 8:56 - debug self => _13; // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL - debug other => _14; // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _41: &usize; // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _42: &usize; // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL - scope 7 (inlined cmp::impls::<impl PartialOrd for usize>::le) { // at $SRC_DIR/core/src/cmp.rs:LL:COL -- debug self => _43; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL -- debug other => _44; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ debug self => _41; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ debug other => _42; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _45: usize; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _46: usize; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL - } - } - scope 8 (inlined cmp::impls::<impl PartialOrd for &usize>::le) { // at $DIR/slice_filter.rs:8:70: 8:76 - debug self => _22; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL - debug other => _23; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _47: &usize; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _48: &usize; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL - scope 9 (inlined cmp::impls::<impl PartialOrd for usize>::le) { // at $SRC_DIR/core/src/cmp.rs:LL:COL -- debug self => _49; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL -- debug other => _50; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ debug self => _47; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ debug other => _48; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _51: usize; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _52: usize; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL - } - } - } - - bb0: { - StorageLive(_3); // scope 0 at $DIR/slice_filter.rs:+0:27: +0:28 - _25 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:27: +0:28 - _3 = &((*_25).0: usize); // scope 0 at $DIR/slice_filter.rs:+0:27: +0:28 - StorageLive(_4); // scope 0 at $DIR/slice_filter.rs:+0:30: +0:31 - _26 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:30: +0:31 - _4 = &((*_26).1: usize); // scope 0 at $DIR/slice_filter.rs:+0:30: +0:31 - StorageLive(_5); // scope 0 at $DIR/slice_filter.rs:+0:33: +0:34 - _27 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:33: +0:34 - _5 = &((*_27).2: usize); // scope 0 at $DIR/slice_filter.rs:+0:33: +0:34 - StorageLive(_6); // scope 0 at $DIR/slice_filter.rs:+0:36: +0:37 - _28 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:36: +0:37 - _6 = &((*_28).3: usize); // scope 0 at $DIR/slice_filter.rs:+0:36: +0:37 - StorageLive(_7); // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 - StorageLive(_8); // scope 1 at $DIR/slice_filter.rs:+0:40: +0:46 - StorageLive(_9); // scope 1 at $DIR/slice_filter.rs:+0:40: +0:41 - _9 = &_3; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:41 - StorageLive(_10); // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 - StorageLive(_11); // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 - _11 = _5; // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 - _10 = &_11; // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 - _29 = deref_copy (*_9); // scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL - _30 = deref_copy (*_10); // scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL -- StorageLive(_31); // scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL -- _31 = _29; // scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL -- StorageLive(_32); // scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL -- _32 = _30; // scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageLive(_33); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL -- _33 = (*_31); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ _33 = (*_29); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageLive(_34); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL -- _34 = (*_32); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ _34 = (*_30); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL - _8 = Le(move _33, move _34); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_34); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_33); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL -- StorageDead(_32); // scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL -- StorageDead(_31); // scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_11); // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 - StorageDead(_10); // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 - StorageDead(_9); // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 - switchInt(move _8) -> [0: bb4, otherwise: bb5]; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 - } - - bb1: { - _0 = const true; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 - goto -> bb3; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 - } - - bb2: { - StorageLive(_16); // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 - StorageLive(_17); // scope 1 at $DIR/slice_filter.rs:+0:60: +0:66 - StorageLive(_18); // scope 1 at $DIR/slice_filter.rs:+0:60: +0:61 - _18 = &_5; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:61 - StorageLive(_19); // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 - StorageLive(_20); // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 - _20 = _3; // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 - _19 = &_20; // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 - _35 = deref_copy (*_18); // scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL - _36 = deref_copy (*_19); // scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL -- StorageLive(_37); // scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL -- _37 = _35; // scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL -- StorageLive(_38); // scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL -- _38 = _36; // scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageLive(_39); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL -- _39 = (*_37); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ _39 = (*_35); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageLive(_40); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL -- _40 = (*_38); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ _40 = (*_36); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL - _17 = Le(move _39, move _40); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_40); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_39); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL -- StorageDead(_38); // scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL -- StorageDead(_37); // scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_20); // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 - StorageDead(_19); // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 - StorageDead(_18); // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 - switchInt(move _17) -> [0: bb6, otherwise: bb7]; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 - } - - bb3: { - StorageDead(_16); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 - StorageDead(_7); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 - StorageDead(_6); // scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 - StorageDead(_5); // scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 - StorageDead(_4); // scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 - StorageDead(_3); // scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 - return; // scope 0 at $DIR/slice_filter.rs:+0:76: +0:76 - } - - bb4: { - _7 = const false; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 - StorageDead(_12); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 - StorageDead(_8); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 - goto -> bb2; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 - } - - bb5: { - StorageLive(_12); // scope 1 at $DIR/slice_filter.rs:+0:50: +0:56 - StorageLive(_13); // scope 1 at $DIR/slice_filter.rs:+0:50: +0:51 - _13 = &_6; // scope 1 at $DIR/slice_filter.rs:+0:50: +0:51 - StorageLive(_14); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 - StorageLive(_15); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 - _15 = _4; // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 - _14 = &_15; // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 - _41 = deref_copy (*_13); // scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL - _42 = deref_copy (*_14); // scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL -- StorageLive(_43); // scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL -- _43 = _41; // scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL -- StorageLive(_44); // scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL -- _44 = _42; // scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageLive(_45); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL -- _45 = (*_43); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ _45 = (*_41); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageLive(_46); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL -- _46 = (*_44); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ _46 = (*_42); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL - _12 = Le(move _45, move _46); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_46); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_45); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL -- StorageDead(_44); // scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL -- StorageDead(_43); // scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_15); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 - StorageDead(_14); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 - StorageDead(_13); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 - _7 = move _12; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 - StorageDead(_12); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 - StorageDead(_8); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 - switchInt(move _7) -> [0: bb2, otherwise: bb1]; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 - } - - bb6: { - _16 = const false; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 - goto -> bb8; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 - } - - bb7: { - StorageLive(_21); // scope 1 at $DIR/slice_filter.rs:+0:70: +0:76 - StorageLive(_22); // scope 1 at $DIR/slice_filter.rs:+0:70: +0:71 - _22 = &_4; // scope 1 at $DIR/slice_filter.rs:+0:70: +0:71 - StorageLive(_23); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 - StorageLive(_24); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 - _24 = _6; // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 - _23 = &_24; // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 - _47 = deref_copy (*_22); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL - _48 = deref_copy (*_23); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL -- StorageLive(_49); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL -- _49 = _47; // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL -- StorageLive(_50); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL -- _50 = _48; // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageLive(_51); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL -- _51 = (*_49); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ _51 = (*_47); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageLive(_52); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL -- _52 = (*_50); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ _52 = (*_48); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL - _21 = Le(move _51, move _52); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_52); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_51); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL -- StorageDead(_50); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL -- StorageDead(_49); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_24); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 - StorageDead(_23); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 - StorageDead(_22); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 - _16 = move _21; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 - goto -> bb8; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 - } - - bb8: { - StorageDead(_21); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 - StorageDead(_17); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 - _0 = move _16; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 - goto -> bb3; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 - } - } - diff --git a/tests/mir-opt/slice_filter.variant_a-{closure#0}.DestinationPropagation.diff b/tests/mir-opt/slice_filter.variant_a-{closure#0}.DestinationPropagation.diff deleted file mode 100644 index afdcf57815f..00000000000 --- a/tests/mir-opt/slice_filter.variant_a-{closure#0}.DestinationPropagation.diff +++ /dev/null @@ -1,165 +0,0 @@ -- // MIR for `variant_a::{closure#0}` before DestinationPropagation -+ // MIR for `variant_a::{closure#0}` after DestinationPropagation - - fn variant_a::{closure#0}(_1: &mut [closure@$DIR/slice_filter.rs:8:25: 8:39], _2: &&(usize, usize, usize, usize)) -> bool { - let mut _0: bool; // return place in scope 0 at $DIR/slice_filter.rs:+0:40: +0:40 - let mut _3: bool; // in scope 0 at $DIR/slice_filter.rs:+0:40: +0:56 - let mut _4: bool; // in scope 0 at $DIR/slice_filter.rs:+0:40: +0:46 - let mut _5: bool; // in scope 0 at $DIR/slice_filter.rs:+0:50: +0:56 - let mut _6: bool; // in scope 0 at $DIR/slice_filter.rs:+0:60: +0:76 - let mut _7: bool; // in scope 0 at $DIR/slice_filter.rs:+0:60: +0:66 - let mut _8: bool; // in scope 0 at $DIR/slice_filter.rs:+0:70: +0:76 - let mut _9: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 - let mut _10: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 - let mut _11: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 - let mut _12: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 - scope 1 { - debug a => &((*_9).0: usize); // in scope 1 at $DIR/slice_filter.rs:+0:27: +0:28 - debug b => &((*_10).1: usize); // in scope 1 at $DIR/slice_filter.rs:+0:30: +0:31 - debug c => &((*_11).2: usize); // in scope 1 at $DIR/slice_filter.rs:+0:33: +0:34 - debug d => &((*_12).3: usize); // in scope 1 at $DIR/slice_filter.rs:+0:36: +0:37 - scope 2 (inlined cmp::impls::<impl PartialOrd for &usize>::le) { // at $DIR/slice_filter.rs:8:40: 8:46 - debug self => &&((*_9).0: usize); // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL - debug other => &&((*_11).2: usize); // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL - scope 3 (inlined cmp::impls::<impl PartialOrd for usize>::le) { // at $SRC_DIR/core/src/cmp.rs:LL:COL - debug self => &((*_9).0: usize); // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL - debug other => &((*_11).2: usize); // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _13: usize; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _14: usize; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL - } - } - scope 4 (inlined cmp::impls::<impl PartialOrd for &usize>::le) { // at $DIR/slice_filter.rs:8:60: 8:66 - debug self => &&((*_11).2: usize); // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL - debug other => &&((*_9).0: usize); // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL - scope 5 (inlined cmp::impls::<impl PartialOrd for usize>::le) { // at $SRC_DIR/core/src/cmp.rs:LL:COL - debug self => &((*_11).2: usize); // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL - debug other => &((*_9).0: usize); // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _15: usize; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _16: usize; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL - } - } - scope 6 (inlined cmp::impls::<impl PartialOrd for &usize>::le) { // at $DIR/slice_filter.rs:8:50: 8:56 - debug self => &&((*_12).3: usize); // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL - debug other => &&((*_10).1: usize); // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL - scope 7 (inlined cmp::impls::<impl PartialOrd for usize>::le) { // at $SRC_DIR/core/src/cmp.rs:LL:COL - debug self => &((*_12).3: usize); // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL - debug other => &((*_10).1: usize); // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _17: usize; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _18: usize; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL - } - } - scope 8 (inlined cmp::impls::<impl PartialOrd for &usize>::le) { // at $DIR/slice_filter.rs:8:70: 8:76 - debug self => &&((*_10).1: usize); // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL - debug other => &&((*_12).3: usize); // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL - scope 9 (inlined cmp::impls::<impl PartialOrd for usize>::le) { // at $SRC_DIR/core/src/cmp.rs:LL:COL - debug self => &((*_10).1: usize); // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL - debug other => &((*_12).3: usize); // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _19: usize; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _20: usize; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL - } - } - } - - bb0: { - _9 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:27: +0:28 - _10 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:30: +0:31 - _11 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:33: +0:34 - _12 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:36: +0:37 -- StorageLive(_3); // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 -+ nop; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 - StorageLive(_4); // scope 1 at $DIR/slice_filter.rs:+0:40: +0:46 - StorageLive(_13); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL - _13 = ((*_9).0: usize); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageLive(_14); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL - _14 = ((*_11).2: usize); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL - _4 = Le(move _13, move _14); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_14); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_13); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL - switchInt(move _4) -> [0: bb4, otherwise: bb5]; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 - } - - bb1: { - _0 = const true; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 - goto -> bb3; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 - } - - bb2: { -- StorageLive(_6); // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 -+ nop; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 - StorageLive(_7); // scope 1 at $DIR/slice_filter.rs:+0:60: +0:66 - StorageLive(_15); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL - _15 = ((*_11).2: usize); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageLive(_16); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL - _16 = ((*_9).0: usize); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL - _7 = Le(move _15, move _16); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_16); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_15); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL - switchInt(move _7) -> [0: bb6, otherwise: bb7]; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 - } - - bb3: { -- StorageDead(_6); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 -- StorageDead(_3); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 -+ nop; // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 -+ nop; // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 - return; // scope 0 at $DIR/slice_filter.rs:+0:76: +0:76 - } - - bb4: { -- StorageDead(_5); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 -+ nop; // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 - StorageDead(_4); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 - goto -> bb2; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 - } - - bb5: { -- StorageLive(_5); // scope 1 at $DIR/slice_filter.rs:+0:50: +0:56 -+ nop; // scope 1 at $DIR/slice_filter.rs:+0:50: +0:56 - StorageLive(_17); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL - _17 = ((*_12).3: usize); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageLive(_18); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL - _18 = ((*_10).1: usize); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL - _5 = Le(move _17, move _18); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_18); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_17); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL -- _3 = move _5; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 -- StorageDead(_5); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 -+ nop; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 -+ nop; // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 - StorageDead(_4); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 -- switchInt(move _3) -> [0: bb2, otherwise: bb1]; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 -+ switchInt(move _5) -> [0: bb2, otherwise: bb1]; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 - } - - bb6: { -- _6 = const false; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 -+ _0 = const false; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 - goto -> bb8; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 - } - - bb7: { -- StorageLive(_8); // scope 1 at $DIR/slice_filter.rs:+0:70: +0:76 -+ nop; // scope 1 at $DIR/slice_filter.rs:+0:70: +0:76 - StorageLive(_19); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL - _19 = ((*_10).1: usize); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageLive(_20); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL - _20 = ((*_12).3: usize); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL -- _8 = Le(move _19, move _20); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ _0 = Le(move _19, move _20); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_20); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_19); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL -- _6 = move _8; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 -+ nop; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 - goto -> bb8; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 - } - - bb8: { -- StorageDead(_8); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 -+ nop; // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 - StorageDead(_7); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 -- _0 = move _6; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 -+ nop; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 - goto -> bb3; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 - } - } - diff --git a/tests/mir-opt/slice_filter.variant_a-{closure#0}.ReferencePropagation.diff b/tests/mir-opt/slice_filter.variant_a-{closure#0}.ReferencePropagation.diff deleted file mode 100644 index 2534eeef432..00000000000 --- a/tests/mir-opt/slice_filter.variant_a-{closure#0}.ReferencePropagation.diff +++ /dev/null @@ -1,267 +0,0 @@ -- // MIR for `variant_a::{closure#0}` before ReferencePropagation -+ // MIR for `variant_a::{closure#0}` after ReferencePropagation - - fn variant_a::{closure#0}(_1: &mut [closure@$DIR/slice_filter.rs:8:25: 8:39], _2: &&(usize, usize, usize, usize)) -> bool { - let mut _0: bool; // return place in scope 0 at $DIR/slice_filter.rs:+0:40: +0:40 - let _3: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:27: +0:28 - let _4: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:30: +0:31 - let _5: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:33: +0:34 - let _6: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:36: +0:37 - let mut _7: bool; // in scope 0 at $DIR/slice_filter.rs:+0:40: +0:56 - let mut _8: bool; // in scope 0 at $DIR/slice_filter.rs:+0:40: +0:46 - let mut _9: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:40: +0:41 - let mut _10: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:45: +0:46 - let _11: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:45: +0:46 - let mut _12: bool; // in scope 0 at $DIR/slice_filter.rs:+0:50: +0:56 - let mut _13: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:50: +0:51 - let mut _14: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:55: +0:56 - let _15: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:55: +0:56 - let mut _16: bool; // in scope 0 at $DIR/slice_filter.rs:+0:60: +0:76 - let mut _17: bool; // in scope 0 at $DIR/slice_filter.rs:+0:60: +0:66 - let mut _18: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:60: +0:61 - let mut _19: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:65: +0:66 - let _20: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:65: +0:66 - let mut _21: bool; // in scope 0 at $DIR/slice_filter.rs:+0:70: +0:76 - let mut _22: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:70: +0:71 - let mut _23: &&usize; // in scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 - let _24: &usize; // in scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 - let mut _25: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 - let mut _26: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 - let mut _27: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 - let mut _28: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:38 - let mut _31: &usize; // in scope 0 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _32: &usize; // in scope 0 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _37: &usize; // in scope 0 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _38: &usize; // in scope 0 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _43: &usize; // in scope 0 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _44: &usize; // in scope 0 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _49: &usize; // in scope 0 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _50: &usize; // in scope 0 at $SRC_DIR/core/src/cmp.rs:LL:COL - scope 1 { -- debug a => _3; // in scope 1 at $DIR/slice_filter.rs:+0:27: +0:28 -- debug b => _4; // in scope 1 at $DIR/slice_filter.rs:+0:30: +0:31 -- debug c => _5; // in scope 1 at $DIR/slice_filter.rs:+0:33: +0:34 -- debug d => _6; // in scope 1 at $DIR/slice_filter.rs:+0:36: +0:37 -+ debug a => &((*_25).0: usize); // in scope 1 at $DIR/slice_filter.rs:+0:27: +0:28 -+ debug b => &((*_26).1: usize); // in scope 1 at $DIR/slice_filter.rs:+0:30: +0:31 -+ debug c => &((*_27).2: usize); // in scope 1 at $DIR/slice_filter.rs:+0:33: +0:34 -+ debug d => &((*_28).3: usize); // in scope 1 at $DIR/slice_filter.rs:+0:36: +0:37 - scope 2 (inlined cmp::impls::<impl PartialOrd for &usize>::le) { // at $DIR/slice_filter.rs:8:40: 8:46 -- debug self => _9; // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL -- debug other => _10; // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ debug self => &&((*_25).0: usize); // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ debug other => &&((*_27).2: usize); // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _29: &usize; // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _30: &usize; // in scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL - scope 3 (inlined cmp::impls::<impl PartialOrd for usize>::le) { // at $SRC_DIR/core/src/cmp.rs:LL:COL -- debug self => _29; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL -- debug other => _30; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ debug self => &((*_25).0: usize); // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ debug other => &((*_27).2: usize); // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _33: usize; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _34: usize; // in scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL - } - } - scope 4 (inlined cmp::impls::<impl PartialOrd for &usize>::le) { // at $DIR/slice_filter.rs:8:60: 8:66 -- debug self => _18; // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL -- debug other => _19; // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ debug self => &&((*_27).2: usize); // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ debug other => &&((*_25).0: usize); // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _35: &usize; // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _36: &usize; // in scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL - scope 5 (inlined cmp::impls::<impl PartialOrd for usize>::le) { // at $SRC_DIR/core/src/cmp.rs:LL:COL -- debug self => _35; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL -- debug other => _36; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ debug self => &((*_27).2: usize); // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ debug other => &((*_25).0: usize); // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _39: usize; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _40: usize; // in scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL - } - } - scope 6 (inlined cmp::impls::<impl PartialOrd for &usize>::le) { // at $DIR/slice_filter.rs:8:50: 8:56 -- debug self => _13; // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL -- debug other => _14; // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ debug self => &&((*_28).3: usize); // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ debug other => &&((*_26).1: usize); // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _41: &usize; // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _42: &usize; // in scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL - scope 7 (inlined cmp::impls::<impl PartialOrd for usize>::le) { // at $SRC_DIR/core/src/cmp.rs:LL:COL -- debug self => _41; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL -- debug other => _42; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ debug self => &((*_28).3: usize); // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ debug other => &((*_26).1: usize); // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _45: usize; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _46: usize; // in scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL - } - } - scope 8 (inlined cmp::impls::<impl PartialOrd for &usize>::le) { // at $DIR/slice_filter.rs:8:70: 8:76 -- debug self => _22; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL -- debug other => _23; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ debug self => &&((*_26).1: usize); // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ debug other => &&((*_28).3: usize); // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _47: &usize; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _48: &usize; // in scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL - scope 9 (inlined cmp::impls::<impl PartialOrd for usize>::le) { // at $SRC_DIR/core/src/cmp.rs:LL:COL -- debug self => _47; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL -- debug other => _48; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ debug self => &((*_26).1: usize); // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ debug other => &((*_28).3: usize); // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _51: usize; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL - let mut _52: usize; // in scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL - } - } - } - - bb0: { -- StorageLive(_3); // scope 0 at $DIR/slice_filter.rs:+0:27: +0:28 - _25 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:27: +0:28 -- _3 = &((*_25).0: usize); // scope 0 at $DIR/slice_filter.rs:+0:27: +0:28 -- StorageLive(_4); // scope 0 at $DIR/slice_filter.rs:+0:30: +0:31 - _26 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:30: +0:31 -- _4 = &((*_26).1: usize); // scope 0 at $DIR/slice_filter.rs:+0:30: +0:31 -- StorageLive(_5); // scope 0 at $DIR/slice_filter.rs:+0:33: +0:34 - _27 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:33: +0:34 -- _5 = &((*_27).2: usize); // scope 0 at $DIR/slice_filter.rs:+0:33: +0:34 -- StorageLive(_6); // scope 0 at $DIR/slice_filter.rs:+0:36: +0:37 - _28 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:36: +0:37 -- _6 = &((*_28).3: usize); // scope 0 at $DIR/slice_filter.rs:+0:36: +0:37 - StorageLive(_7); // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 - StorageLive(_8); // scope 1 at $DIR/slice_filter.rs:+0:40: +0:46 -- StorageLive(_9); // scope 1 at $DIR/slice_filter.rs:+0:40: +0:41 -- _9 = &_3; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:41 -- StorageLive(_10); // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 -- StorageLive(_11); // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 -- _11 = _5; // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 -- _10 = &_11; // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 -- _29 = deref_copy (*_9); // scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL -- _30 = deref_copy (*_10); // scope 2 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageLive(_33); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL -- _33 = (*_29); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ _33 = ((*_25).0: usize); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageLive(_34); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL -- _34 = (*_30); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ _34 = ((*_27).2: usize); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL - _8 = Le(move _33, move _34); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_34); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_33); // scope 3 at $SRC_DIR/core/src/cmp.rs:LL:COL -- StorageDead(_11); // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 -- StorageDead(_10); // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 -- StorageDead(_9); // scope 1 at $DIR/slice_filter.rs:+0:45: +0:46 - switchInt(move _8) -> [0: bb4, otherwise: bb5]; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 - } - - bb1: { - _0 = const true; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 - goto -> bb3; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 - } - - bb2: { - StorageLive(_16); // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 - StorageLive(_17); // scope 1 at $DIR/slice_filter.rs:+0:60: +0:66 -- StorageLive(_18); // scope 1 at $DIR/slice_filter.rs:+0:60: +0:61 -- _18 = &_5; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:61 -- StorageLive(_19); // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 -- StorageLive(_20); // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 -- _20 = _3; // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 -- _19 = &_20; // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 -- _35 = deref_copy (*_18); // scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL -- _36 = deref_copy (*_19); // scope 4 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageLive(_39); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL -- _39 = (*_35); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ _39 = ((*_27).2: usize); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageLive(_40); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL -- _40 = (*_36); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ _40 = ((*_25).0: usize); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL - _17 = Le(move _39, move _40); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_40); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_39); // scope 5 at $SRC_DIR/core/src/cmp.rs:LL:COL -- StorageDead(_20); // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 -- StorageDead(_19); // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 -- StorageDead(_18); // scope 1 at $DIR/slice_filter.rs:+0:65: +0:66 - switchInt(move _17) -> [0: bb6, otherwise: bb7]; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 - } - - bb3: { - StorageDead(_16); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 - StorageDead(_7); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 -- StorageDead(_6); // scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 -- StorageDead(_5); // scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 -- StorageDead(_4); // scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 -- StorageDead(_3); // scope 0 at $DIR/slice_filter.rs:+0:75: +0:76 - return; // scope 0 at $DIR/slice_filter.rs:+0:76: +0:76 - } - - bb4: { - _7 = const false; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 - StorageDead(_12); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 - StorageDead(_8); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 - goto -> bb2; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 - } - - bb5: { - StorageLive(_12); // scope 1 at $DIR/slice_filter.rs:+0:50: +0:56 -- StorageLive(_13); // scope 1 at $DIR/slice_filter.rs:+0:50: +0:51 -- _13 = &_6; // scope 1 at $DIR/slice_filter.rs:+0:50: +0:51 -- StorageLive(_14); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 -- StorageLive(_15); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 -- _15 = _4; // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 -- _14 = &_15; // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 -- _41 = deref_copy (*_13); // scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL -- _42 = deref_copy (*_14); // scope 6 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageLive(_45); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL -- _45 = (*_41); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ _45 = ((*_28).3: usize); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageLive(_46); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL -- _46 = (*_42); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ _46 = ((*_26).1: usize); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL - _12 = Le(move _45, move _46); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_46); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_45); // scope 7 at $SRC_DIR/core/src/cmp.rs:LL:COL -- StorageDead(_15); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 -- StorageDead(_14); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 -- StorageDead(_13); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 - _7 = move _12; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:56 - StorageDead(_12); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 - StorageDead(_8); // scope 1 at $DIR/slice_filter.rs:+0:55: +0:56 - switchInt(move _7) -> [0: bb2, otherwise: bb1]; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 - } - - bb6: { - _16 = const false; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 - goto -> bb8; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 - } - - bb7: { - StorageLive(_21); // scope 1 at $DIR/slice_filter.rs:+0:70: +0:76 -- StorageLive(_22); // scope 1 at $DIR/slice_filter.rs:+0:70: +0:71 -- _22 = &_4; // scope 1 at $DIR/slice_filter.rs:+0:70: +0:71 -- StorageLive(_23); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 -- StorageLive(_24); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 -- _24 = _6; // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 -- _23 = &_24; // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 -- _47 = deref_copy (*_22); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL -- _48 = deref_copy (*_23); // scope 8 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageLive(_51); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL -- _51 = (*_47); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ _51 = ((*_26).1: usize); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageLive(_52); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL -- _52 = (*_48); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL -+ _52 = ((*_28).3: usize); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL - _21 = Le(move _51, move _52); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_52); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL - StorageDead(_51); // scope 9 at $SRC_DIR/core/src/cmp.rs:LL:COL -- StorageDead(_24); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 -- StorageDead(_23); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 -- StorageDead(_22); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 - _16 = move _21; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 - goto -> bb8; // scope 1 at $DIR/slice_filter.rs:+0:60: +0:76 - } - - bb8: { - StorageDead(_21); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 - StorageDead(_17); // scope 1 at $DIR/slice_filter.rs:+0:75: +0:76 - _0 = move _16; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 - goto -> bb3; // scope 1 at $DIR/slice_filter.rs:+0:40: +0:76 - } - } - diff --git a/tests/mir-opt/slice_filter.variant_b-{closure#0}.CopyProp.diff b/tests/mir-opt/slice_filter.variant_b-{closure#0}.CopyProp.diff deleted file mode 100644 index 5e4bdbdfa2e..00000000000 --- a/tests/mir-opt/slice_filter.variant_b-{closure#0}.CopyProp.diff +++ /dev/null @@ -1,139 +0,0 @@ -- // MIR for `variant_b::{closure#0}` before CopyProp -+ // MIR for `variant_b::{closure#0}` after CopyProp - - fn variant_b::{closure#0}(_1: &mut [closure@$DIR/slice_filter.rs:12:25: 12:41], _2: &&(usize, usize, usize, usize)) -> bool { - let mut _0: bool; // return place in scope 0 at $DIR/slice_filter.rs:+0:42: +0:42 - let _3: usize; // in scope 0 at $DIR/slice_filter.rs:+0:29: +0:30 - let _4: usize; // in scope 0 at $DIR/slice_filter.rs:+0:32: +0:33 - let _5: usize; // in scope 0 at $DIR/slice_filter.rs:+0:35: +0:36 - let _6: usize; // in scope 0 at $DIR/slice_filter.rs:+0:38: +0:39 - let mut _7: bool; // in scope 0 at $DIR/slice_filter.rs:+0:42: +0:58 - let mut _8: bool; // in scope 0 at $DIR/slice_filter.rs:+0:42: +0:48 - let mut _9: usize; // in scope 0 at $DIR/slice_filter.rs:+0:42: +0:43 - let mut _10: usize; // in scope 0 at $DIR/slice_filter.rs:+0:47: +0:48 - let mut _11: bool; // in scope 0 at $DIR/slice_filter.rs:+0:52: +0:58 - let mut _12: usize; // in scope 0 at $DIR/slice_filter.rs:+0:52: +0:53 - let mut _13: usize; // in scope 0 at $DIR/slice_filter.rs:+0:57: +0:58 - let mut _14: bool; // in scope 0 at $DIR/slice_filter.rs:+0:62: +0:78 - let mut _15: bool; // in scope 0 at $DIR/slice_filter.rs:+0:62: +0:68 - let mut _16: usize; // in scope 0 at $DIR/slice_filter.rs:+0:62: +0:63 - let mut _17: usize; // in scope 0 at $DIR/slice_filter.rs:+0:67: +0:68 - let mut _18: bool; // in scope 0 at $DIR/slice_filter.rs:+0:72: +0:78 - let mut _19: usize; // in scope 0 at $DIR/slice_filter.rs:+0:72: +0:73 - let mut _20: usize; // in scope 0 at $DIR/slice_filter.rs:+0:77: +0:78 - let mut _21: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:40 - let mut _22: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:40 - let mut _23: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:40 - let mut _24: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:40 - scope 1 { - debug a => _3; // in scope 1 at $DIR/slice_filter.rs:+0:29: +0:30 - debug b => _4; // in scope 1 at $DIR/slice_filter.rs:+0:32: +0:33 - debug c => _5; // in scope 1 at $DIR/slice_filter.rs:+0:35: +0:36 - debug d => _6; // in scope 1 at $DIR/slice_filter.rs:+0:38: +0:39 - } - - bb0: { -- StorageLive(_3); // scope 0 at $DIR/slice_filter.rs:+0:29: +0:30 - _21 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:29: +0:30 - _3 = ((*_21).0: usize); // scope 0 at $DIR/slice_filter.rs:+0:29: +0:30 -- StorageLive(_4); // scope 0 at $DIR/slice_filter.rs:+0:32: +0:33 - _22 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:32: +0:33 - _4 = ((*_22).1: usize); // scope 0 at $DIR/slice_filter.rs:+0:32: +0:33 -- StorageLive(_5); // scope 0 at $DIR/slice_filter.rs:+0:35: +0:36 - _23 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:35: +0:36 - _5 = ((*_23).2: usize); // scope 0 at $DIR/slice_filter.rs:+0:35: +0:36 -- StorageLive(_6); // scope 0 at $DIR/slice_filter.rs:+0:38: +0:39 - _24 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:38: +0:39 - _6 = ((*_24).3: usize); // scope 0 at $DIR/slice_filter.rs:+0:38: +0:39 - StorageLive(_7); // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 - StorageLive(_8); // scope 1 at $DIR/slice_filter.rs:+0:42: +0:48 -- StorageLive(_9); // scope 1 at $DIR/slice_filter.rs:+0:42: +0:43 -- _9 = _3; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:43 -- StorageLive(_10); // scope 1 at $DIR/slice_filter.rs:+0:47: +0:48 -- _10 = _5; // scope 1 at $DIR/slice_filter.rs:+0:47: +0:48 -- _8 = Le(move _9, move _10); // scope 1 at $DIR/slice_filter.rs:+0:42: +0:48 -- StorageDead(_10); // scope 1 at $DIR/slice_filter.rs:+0:47: +0:48 -- StorageDead(_9); // scope 1 at $DIR/slice_filter.rs:+0:47: +0:48 -+ _8 = Le(_3, _5); // scope 1 at $DIR/slice_filter.rs:+0:42: +0:48 - switchInt(move _8) -> [0: bb4, otherwise: bb5]; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 - } - - bb1: { - _0 = const true; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 - goto -> bb3; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 - } - - bb2: { - StorageLive(_14); // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 - StorageLive(_15); // scope 1 at $DIR/slice_filter.rs:+0:62: +0:68 -- StorageLive(_16); // scope 1 at $DIR/slice_filter.rs:+0:62: +0:63 -- _16 = _5; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:63 -- StorageLive(_17); // scope 1 at $DIR/slice_filter.rs:+0:67: +0:68 -- _17 = _3; // scope 1 at $DIR/slice_filter.rs:+0:67: +0:68 -- _15 = Le(move _16, move _17); // scope 1 at $DIR/slice_filter.rs:+0:62: +0:68 -- StorageDead(_17); // scope 1 at $DIR/slice_filter.rs:+0:67: +0:68 -- StorageDead(_16); // scope 1 at $DIR/slice_filter.rs:+0:67: +0:68 -+ _15 = Le(_5, _3); // scope 1 at $DIR/slice_filter.rs:+0:62: +0:68 - switchInt(move _15) -> [0: bb6, otherwise: bb7]; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 - } - - bb3: { - StorageDead(_14); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 - StorageDead(_7); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 -- StorageDead(_6); // scope 0 at $DIR/slice_filter.rs:+0:77: +0:78 -- StorageDead(_5); // scope 0 at $DIR/slice_filter.rs:+0:77: +0:78 -- StorageDead(_4); // scope 0 at $DIR/slice_filter.rs:+0:77: +0:78 -- StorageDead(_3); // scope 0 at $DIR/slice_filter.rs:+0:77: +0:78 - return; // scope 0 at $DIR/slice_filter.rs:+0:78: +0:78 - } - - bb4: { - _7 = const false; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 - StorageDead(_11); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 - StorageDead(_8); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 - goto -> bb2; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 - } - - bb5: { - StorageLive(_11); // scope 1 at $DIR/slice_filter.rs:+0:52: +0:58 -- StorageLive(_12); // scope 1 at $DIR/slice_filter.rs:+0:52: +0:53 -- _12 = _6; // scope 1 at $DIR/slice_filter.rs:+0:52: +0:53 -- StorageLive(_13); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 -- _13 = _4; // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 -- _11 = Le(move _12, move _13); // scope 1 at $DIR/slice_filter.rs:+0:52: +0:58 -- StorageDead(_13); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 -- StorageDead(_12); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 -+ _11 = Le(_6, _4); // scope 1 at $DIR/slice_filter.rs:+0:52: +0:58 - _7 = move _11; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 - StorageDead(_11); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 - StorageDead(_8); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 - switchInt(move _7) -> [0: bb2, otherwise: bb1]; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 - } - - bb6: { - _14 = const false; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 - goto -> bb8; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 - } - - bb7: { - StorageLive(_18); // scope 1 at $DIR/slice_filter.rs:+0:72: +0:78 -- StorageLive(_19); // scope 1 at $DIR/slice_filter.rs:+0:72: +0:73 -- _19 = _4; // scope 1 at $DIR/slice_filter.rs:+0:72: +0:73 -- StorageLive(_20); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 -- _20 = _6; // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 -- _18 = Le(move _19, move _20); // scope 1 at $DIR/slice_filter.rs:+0:72: +0:78 -- StorageDead(_20); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 -- StorageDead(_19); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 -+ _18 = Le(_4, _6); // scope 1 at $DIR/slice_filter.rs:+0:72: +0:78 - _14 = move _18; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 - goto -> bb8; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 - } - - bb8: { - StorageDead(_18); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 - StorageDead(_15); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 - _0 = move _14; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 - goto -> bb3; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 - } - } - diff --git a/tests/mir-opt/slice_filter.variant_b-{closure#0}.DestinationPropagation.diff b/tests/mir-opt/slice_filter.variant_b-{closure#0}.DestinationPropagation.diff deleted file mode 100644 index 45af6600cd4..00000000000 --- a/tests/mir-opt/slice_filter.variant_b-{closure#0}.DestinationPropagation.diff +++ /dev/null @@ -1,109 +0,0 @@ -- // MIR for `variant_b::{closure#0}` before DestinationPropagation -+ // MIR for `variant_b::{closure#0}` after DestinationPropagation - - fn variant_b::{closure#0}(_1: &mut [closure@$DIR/slice_filter.rs:12:25: 12:41], _2: &&(usize, usize, usize, usize)) -> bool { - let mut _0: bool; // return place in scope 0 at $DIR/slice_filter.rs:+0:42: +0:42 - let _3: usize; // in scope 0 at $DIR/slice_filter.rs:+0:29: +0:30 - let _4: usize; // in scope 0 at $DIR/slice_filter.rs:+0:32: +0:33 - let _5: usize; // in scope 0 at $DIR/slice_filter.rs:+0:35: +0:36 - let _6: usize; // in scope 0 at $DIR/slice_filter.rs:+0:38: +0:39 - let mut _7: bool; // in scope 0 at $DIR/slice_filter.rs:+0:42: +0:58 - let mut _8: bool; // in scope 0 at $DIR/slice_filter.rs:+0:42: +0:48 - let mut _9: bool; // in scope 0 at $DIR/slice_filter.rs:+0:52: +0:58 - let mut _10: bool; // in scope 0 at $DIR/slice_filter.rs:+0:62: +0:78 - let mut _11: bool; // in scope 0 at $DIR/slice_filter.rs:+0:62: +0:68 - let mut _12: bool; // in scope 0 at $DIR/slice_filter.rs:+0:72: +0:78 - let mut _13: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:40 - let mut _14: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:40 - let mut _15: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:40 - let mut _16: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:40 - scope 1 { - debug a => _3; // in scope 1 at $DIR/slice_filter.rs:+0:29: +0:30 - debug b => _4; // in scope 1 at $DIR/slice_filter.rs:+0:32: +0:33 - debug c => _5; // in scope 1 at $DIR/slice_filter.rs:+0:35: +0:36 - debug d => _6; // in scope 1 at $DIR/slice_filter.rs:+0:38: +0:39 - } - - bb0: { - _13 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:29: +0:30 - _3 = ((*_13).0: usize); // scope 0 at $DIR/slice_filter.rs:+0:29: +0:30 - _14 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:32: +0:33 - _4 = ((*_14).1: usize); // scope 0 at $DIR/slice_filter.rs:+0:32: +0:33 - _15 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:35: +0:36 - _5 = ((*_15).2: usize); // scope 0 at $DIR/slice_filter.rs:+0:35: +0:36 - _16 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:38: +0:39 - _6 = ((*_16).3: usize); // scope 0 at $DIR/slice_filter.rs:+0:38: +0:39 -- StorageLive(_7); // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 -+ nop; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 - StorageLive(_8); // scope 1 at $DIR/slice_filter.rs:+0:42: +0:48 - _8 = Le(_3, _5); // scope 1 at $DIR/slice_filter.rs:+0:42: +0:48 - switchInt(move _8) -> [0: bb4, otherwise: bb5]; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 - } - - bb1: { - _0 = const true; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 - goto -> bb3; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 - } - - bb2: { -- StorageLive(_10); // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 -+ nop; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 - StorageLive(_11); // scope 1 at $DIR/slice_filter.rs:+0:62: +0:68 - _11 = Le(_5, _3); // scope 1 at $DIR/slice_filter.rs:+0:62: +0:68 - switchInt(move _11) -> [0: bb6, otherwise: bb7]; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 - } - - bb3: { -- StorageDead(_10); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 -- StorageDead(_7); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 -+ nop; // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 -+ nop; // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 - return; // scope 0 at $DIR/slice_filter.rs:+0:78: +0:78 - } - - bb4: { -- StorageDead(_9); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 -+ nop; // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 - StorageDead(_8); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 - goto -> bb2; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 - } - - bb5: { -- StorageLive(_9); // scope 1 at $DIR/slice_filter.rs:+0:52: +0:58 -+ nop; // scope 1 at $DIR/slice_filter.rs:+0:52: +0:58 - _9 = Le(_6, _4); // scope 1 at $DIR/slice_filter.rs:+0:52: +0:58 -- _7 = move _9; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 -- StorageDead(_9); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 -+ nop; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 -+ nop; // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 - StorageDead(_8); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 -- switchInt(move _7) -> [0: bb2, otherwise: bb1]; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 -+ switchInt(move _9) -> [0: bb2, otherwise: bb1]; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 - } - - bb6: { -- _10 = const false; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 -+ _0 = const false; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 - goto -> bb8; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 - } - - bb7: { -- StorageLive(_12); // scope 1 at $DIR/slice_filter.rs:+0:72: +0:78 -- _12 = Le(_4, _6); // scope 1 at $DIR/slice_filter.rs:+0:72: +0:78 -- _10 = move _12; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 -+ nop; // scope 1 at $DIR/slice_filter.rs:+0:72: +0:78 -+ _0 = Le(_4, _6); // scope 1 at $DIR/slice_filter.rs:+0:72: +0:78 -+ nop; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 - goto -> bb8; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 - } - - bb8: { -- StorageDead(_12); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 -+ nop; // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 - StorageDead(_11); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 -- _0 = move _10; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 -+ nop; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 - goto -> bb3; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 - } - } - diff --git a/tests/mir-opt/slice_filter.variant_b-{closure#0}.ReferencePropagation.diff b/tests/mir-opt/slice_filter.variant_b-{closure#0}.ReferencePropagation.diff deleted file mode 100644 index d1241c6b024..00000000000 --- a/tests/mir-opt/slice_filter.variant_b-{closure#0}.ReferencePropagation.diff +++ /dev/null @@ -1,103 +0,0 @@ -- // MIR for `variant_b::{closure#0}` before ReferencePropagation -+ // MIR for `variant_b::{closure#0}` after ReferencePropagation - - fn variant_b::{closure#0}(_1: &mut [closure@$DIR/slice_filter.rs:12:25: 12:41], _2: &&(usize, usize, usize, usize)) -> bool { - let mut _0: bool; // return place in scope 0 at $DIR/slice_filter.rs:+0:42: +0:42 - let _3: usize; // in scope 0 at $DIR/slice_filter.rs:+0:29: +0:30 - let _4: usize; // in scope 0 at $DIR/slice_filter.rs:+0:32: +0:33 - let _5: usize; // in scope 0 at $DIR/slice_filter.rs:+0:35: +0:36 - let _6: usize; // in scope 0 at $DIR/slice_filter.rs:+0:38: +0:39 - let mut _7: bool; // in scope 0 at $DIR/slice_filter.rs:+0:42: +0:58 - let mut _8: bool; // in scope 0 at $DIR/slice_filter.rs:+0:42: +0:48 - let mut _9: usize; // in scope 0 at $DIR/slice_filter.rs:+0:42: +0:43 - let mut _10: usize; // in scope 0 at $DIR/slice_filter.rs:+0:47: +0:48 - let mut _11: bool; // in scope 0 at $DIR/slice_filter.rs:+0:52: +0:58 - let mut _12: usize; // in scope 0 at $DIR/slice_filter.rs:+0:52: +0:53 - let mut _13: usize; // in scope 0 at $DIR/slice_filter.rs:+0:57: +0:58 - let mut _14: bool; // in scope 0 at $DIR/slice_filter.rs:+0:62: +0:78 - let mut _15: bool; // in scope 0 at $DIR/slice_filter.rs:+0:62: +0:68 - let mut _16: usize; // in scope 0 at $DIR/slice_filter.rs:+0:62: +0:63 - let mut _17: usize; // in scope 0 at $DIR/slice_filter.rs:+0:67: +0:68 - let mut _18: bool; // in scope 0 at $DIR/slice_filter.rs:+0:72: +0:78 - let mut _19: usize; // in scope 0 at $DIR/slice_filter.rs:+0:72: +0:73 - let mut _20: usize; // in scope 0 at $DIR/slice_filter.rs:+0:77: +0:78 - let mut _21: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:40 - let mut _22: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:40 - let mut _23: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:40 - let mut _24: &(usize, usize, usize, usize); // in scope 0 at $DIR/slice_filter.rs:+0:26: +0:40 - scope 1 { - debug a => _3; // in scope 1 at $DIR/slice_filter.rs:+0:29: +0:30 - debug b => _4; // in scope 1 at $DIR/slice_filter.rs:+0:32: +0:33 - debug c => _5; // in scope 1 at $DIR/slice_filter.rs:+0:35: +0:36 - debug d => _6; // in scope 1 at $DIR/slice_filter.rs:+0:38: +0:39 - } - - bb0: { - _21 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:29: +0:30 - _3 = ((*_21).0: usize); // scope 0 at $DIR/slice_filter.rs:+0:29: +0:30 - _22 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:32: +0:33 - _4 = ((*_22).1: usize); // scope 0 at $DIR/slice_filter.rs:+0:32: +0:33 - _23 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:35: +0:36 - _5 = ((*_23).2: usize); // scope 0 at $DIR/slice_filter.rs:+0:35: +0:36 - _24 = deref_copy (*_2); // scope 0 at $DIR/slice_filter.rs:+0:38: +0:39 - _6 = ((*_24).3: usize); // scope 0 at $DIR/slice_filter.rs:+0:38: +0:39 - StorageLive(_7); // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 - StorageLive(_8); // scope 1 at $DIR/slice_filter.rs:+0:42: +0:48 - _8 = Le(_3, _5); // scope 1 at $DIR/slice_filter.rs:+0:42: +0:48 - switchInt(move _8) -> [0: bb4, otherwise: bb5]; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 - } - - bb1: { - _0 = const true; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 - goto -> bb3; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 - } - - bb2: { - StorageLive(_14); // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 - StorageLive(_15); // scope 1 at $DIR/slice_filter.rs:+0:62: +0:68 - _15 = Le(_5, _3); // scope 1 at $DIR/slice_filter.rs:+0:62: +0:68 - switchInt(move _15) -> [0: bb6, otherwise: bb7]; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 - } - - bb3: { - StorageDead(_14); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 - StorageDead(_7); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 - return; // scope 0 at $DIR/slice_filter.rs:+0:78: +0:78 - } - - bb4: { - _7 = const false; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 - StorageDead(_11); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 - StorageDead(_8); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 - goto -> bb2; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 - } - - bb5: { - StorageLive(_11); // scope 1 at $DIR/slice_filter.rs:+0:52: +0:58 - _11 = Le(_6, _4); // scope 1 at $DIR/slice_filter.rs:+0:52: +0:58 - _7 = move _11; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:58 - StorageDead(_11); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 - StorageDead(_8); // scope 1 at $DIR/slice_filter.rs:+0:57: +0:58 - switchInt(move _7) -> [0: bb2, otherwise: bb1]; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 - } - - bb6: { - _14 = const false; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 - goto -> bb8; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 - } - - bb7: { - StorageLive(_18); // scope 1 at $DIR/slice_filter.rs:+0:72: +0:78 - _18 = Le(_4, _6); // scope 1 at $DIR/slice_filter.rs:+0:72: +0:78 - _14 = move _18; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 - goto -> bb8; // scope 1 at $DIR/slice_filter.rs:+0:62: +0:78 - } - - bb8: { - StorageDead(_18); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 - StorageDead(_15); // scope 1 at $DIR/slice_filter.rs:+0:77: +0:78 - _0 = move _14; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 - goto -> bb3; // scope 1 at $DIR/slice_filter.rs:+0:42: +0:78 - } - } - diff --git a/tests/rustdoc-gui/theme-in-history.goml b/tests/rustdoc-gui/theme-in-history.goml index 8fcd0ecd309..42c5b5e6e69 100644 --- a/tests/rustdoc-gui/theme-in-history.goml +++ b/tests/rustdoc-gui/theme-in-history.goml @@ -7,7 +7,7 @@ set-local-storage: { } // We reload the page so the local storage settings are being used. reload: -assert-css: ("body", { "background-color": "rgb(53, 53, 53)" }) +assert-css: ("body", { "background-color": "#353535" }) assert-local-storage: { "rustdoc-theme": "dark" } // Now we go to the settings page. @@ -15,7 +15,7 @@ go-to: "file://" + |DOC_PATH| + "/settings.html" wait-for: "#settings" // We change the theme to "light". click: "#theme-light" -wait-for-css: ("body", { "background-color": "rgb(255, 255, 255)" }) +wait-for-css: ("body", { "background-color": "white" }) assert-local-storage: { "rustdoc-theme": "light" } // We go back in history. @@ -23,5 +23,5 @@ history-go-back: // Confirm that we're not on the settings page. assert-false: "#settings" // Check that the current theme is still "light". -assert-css: ("body", { "background-color": "rgb(255, 255, 255)" }) +assert-css: ("body", { "background-color": "white" }) assert-local-storage: { "rustdoc-theme": "light" } diff --git a/tests/rustdoc/double-hyphen-to-dash.rs b/tests/rustdoc/double-hyphen-to-dash.rs new file mode 100644 index 00000000000..66905f90cfc --- /dev/null +++ b/tests/rustdoc/double-hyphen-to-dash.rs @@ -0,0 +1,9 @@ +// This test ensures that `--` (double-hyphen) is correctly converted into `–` (dash). + +#![crate_name = "foo"] + +// @has 'foo/index.html' '//*[@class="desc docblock-short"]' '–' +// @has 'foo/struct.Bar.html' '//*[@class="docblock"]' '–' + +/// -- +pub struct Bar; diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs index 39e34d73f9a..ffbefce48d3 100644 --- a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs @@ -538,7 +538,7 @@ struct LabelWithTrailingPath { #[diag(no_crate_example, code = "E0123")] struct LabelWithTrailingNameValue { #[label(no_crate_label, foo = "...")] - //~^ ERROR invalid nested attribute + //~^ ERROR only `no_span` is a valid nested attribute span: Span, } @@ -546,7 +546,7 @@ struct LabelWithTrailingNameValue { #[diag(no_crate_example, code = "E0123")] struct LabelWithTrailingList { #[label(no_crate_label, foo("..."))] - //~^ ERROR invalid nested attribute + //~^ ERROR only `no_span` is a valid nested attribute span: Span, } diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr index 801e4b5793c..1398f9c96bf 100644 --- a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr @@ -243,7 +243,7 @@ error: invalid nested attribute LL | #[suggestion(nonsense = "bar")] | ^^^^^^^^ | - = help: only `style`, `code` and `applicability` are valid nested attributes + = help: only `no_span`, `style`, `code` and `applicability` are valid nested attributes error: suggestion without `code = "..."` --> $DIR/diagnostic-derive.rs:234:5 @@ -257,7 +257,7 @@ error: invalid nested attribute LL | #[suggestion(msg = "bar")] | ^^^ | - = help: only `style`, `code` and `applicability` are valid nested attributes + = help: only `no_span`, `style`, `code` and `applicability` are valid nested attributes error: suggestion without `code = "..."` --> $DIR/diagnostic-derive.rs:243:5 @@ -335,13 +335,13 @@ error: a diagnostic slug must be the first argument to the attribute LL | #[label(no_crate_label, foo)] | ^ -error: invalid nested attribute +error: only `no_span` is a valid nested attribute --> $DIR/diagnostic-derive.rs:540:29 | LL | #[label(no_crate_label, foo = "...")] | ^^^ -error: invalid nested attribute +error: only `no_span` is a valid nested attribute --> $DIR/diagnostic-derive.rs:548:29 | LL | #[label(no_crate_label, foo("..."))] diff --git a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs index 1bfbb60015d..38af5b0f9fb 100644 --- a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs +++ b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.rs @@ -85,7 +85,7 @@ struct F { #[derive(Subdiagnostic)] #[label(bug = "...")] -//~^ ERROR invalid nested attribute +//~^ ERROR only `no_span` is a valid nested attribute //~| ERROR diagnostic slug must be first argument struct G { #[primary_span] @@ -104,7 +104,7 @@ struct H { #[derive(Subdiagnostic)] #[label(slug = 4)] -//~^ ERROR invalid nested attribute +//~^ ERROR only `no_span` is a valid nested attribute //~| ERROR diagnostic slug must be first argument struct J { #[primary_span] @@ -114,7 +114,7 @@ struct J { #[derive(Subdiagnostic)] #[label(slug("..."))] -//~^ ERROR invalid nested attribute +//~^ ERROR only `no_span` is a valid nested attribute //~| ERROR diagnostic slug must be first argument struct K { #[primary_span] @@ -143,7 +143,7 @@ struct M { #[derive(Subdiagnostic)] #[label(no_crate_example, code = "...")] -//~^ ERROR invalid nested attribute +//~^ ERROR only `no_span` is a valid nested attribute struct N { #[primary_span] span: Span, @@ -152,7 +152,7 @@ struct N { #[derive(Subdiagnostic)] #[label(no_crate_example, applicability = "machine-applicable")] -//~^ ERROR invalid nested attribute +//~^ ERROR only `no_span` is a valid nested attribute struct O { #[primary_span] span: Span, @@ -224,7 +224,7 @@ enum T { enum U { #[label(code = "...")] //~^ ERROR diagnostic slug must be first argument of a `#[label(...)]` attribute - //~| ERROR invalid nested attribute + //~| ERROR only `no_span` is a valid nested attribute A { #[primary_span] span: Span, diff --git a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr index fca4f506890..5ddc8edd745 100644 --- a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr +++ b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr @@ -26,7 +26,7 @@ error: `#[label = ...]` is not a valid attribute LL | #[label = "..."] | ^^^^^^^^^^^^^^^^ -error: invalid nested attribute +error: only `no_span` is a valid nested attribute --> $DIR/subdiagnostic-derive.rs:87:9 | LL | #[label(bug = "...")] @@ -44,7 +44,7 @@ error: unexpected literal in nested attribute, expected ident LL | #[label("...")] | ^^^^^ -error: invalid nested attribute +error: only `no_span` is a valid nested attribute --> $DIR/subdiagnostic-derive.rs:106:9 | LL | #[label(slug = 4)] @@ -56,7 +56,7 @@ error: diagnostic slug must be first argument of a `#[label(...)]` attribute LL | #[label(slug = 4)] | ^^^^^^^^^^^^^^^^^^ -error: invalid nested attribute +error: only `no_span` is a valid nested attribute --> $DIR/subdiagnostic-derive.rs:116:9 | LL | #[label(slug("..."))] @@ -74,13 +74,13 @@ error: unexpected end of input, unexpected token in nested attribute, expected i LL | #[label()] | ^ -error: invalid nested attribute +error: only `no_span` is a valid nested attribute --> $DIR/subdiagnostic-derive.rs:145:27 | LL | #[label(no_crate_example, code = "...")] | ^^^^ -error: invalid nested attribute +error: only `no_span` is a valid nested attribute --> $DIR/subdiagnostic-derive.rs:154:27 | LL | #[label(no_crate_example, applicability = "machine-applicable")] @@ -116,7 +116,7 @@ error: `#[bar(...)]` is not a valid attribute LL | #[bar("...")] | ^^^^^^^^^^^^^ -error: invalid nested attribute +error: only `no_span` is a valid nested attribute --> $DIR/subdiagnostic-derive.rs:225:13 | LL | #[label(code = "...")] @@ -312,7 +312,7 @@ error: invalid nested attribute LL | #[multipart_suggestion(no_crate_example, code = "...", applicability = "machine-applicable")] | ^^^^ | - = help: only `style` and `applicability` are valid nested attributes + = help: only `no_span`, `style` and `applicability` are valid nested attributes error: multipart suggestion without any `#[suggestion_part(...)]` fields --> $DIR/subdiagnostic-derive.rs:540:1 diff --git a/tests/ui/auto-traits/issue-23080-2.stderr b/tests/ui/auto-traits/issue-23080-2.current.stderr index fed485612da..a57c6d9b0cb 100644 --- a/tests/ui/auto-traits/issue-23080-2.stderr +++ b/tests/ui/auto-traits/issue-23080-2.current.stderr @@ -1,5 +1,5 @@ error[E0380]: auto traits cannot have associated items - --> $DIR/issue-23080-2.rs:5:10 + --> $DIR/issue-23080-2.rs:8:10 | LL | unsafe auto trait Trait { | ----- auto traits cannot have associated items diff --git a/tests/ui/auto-traits/issue-23080-2.next.stderr b/tests/ui/auto-traits/issue-23080-2.next.stderr new file mode 100644 index 00000000000..a57c6d9b0cb --- /dev/null +++ b/tests/ui/auto-traits/issue-23080-2.next.stderr @@ -0,0 +1,11 @@ +error[E0380]: auto traits cannot have associated items + --> $DIR/issue-23080-2.rs:8:10 + | +LL | unsafe auto trait Trait { + | ----- auto traits cannot have associated items +LL | type Output; + | -----^^^^^^- help: remove these associated items + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0380`. diff --git a/tests/ui/auto-traits/issue-23080-2.rs b/tests/ui/auto-traits/issue-23080-2.rs index cb4cf6de1ef..882b8f39384 100644 --- a/tests/ui/auto-traits/issue-23080-2.rs +++ b/tests/ui/auto-traits/issue-23080-2.rs @@ -1,3 +1,6 @@ +// revisions: current next +//[next] compile-flags: -Ztrait-solver=next + #![feature(auto_traits)] #![feature(negative_impls)] diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_bad.stderr b/tests/ui/const-generics/adt_const_params/const_param_ty_bad.stderr index de5704ee429..48910b82a10 100644 --- a/tests/ui/const-generics/adt_const_params/const_param_ty_bad.stderr +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_bad.stderr @@ -11,6 +11,10 @@ note: required by a bound in `check` | LL | fn check(_: impl std::marker::ConstParamTy) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check` +help: use parentheses to call this function + | +LL | check(main()); + | ++ error[E0277]: `[closure@$DIR/const_param_ty_bad.rs:8:11: 8:13]` can't be used as a const parameter type --> $DIR/const_param_ty_bad.rs:8:11 @@ -25,6 +29,10 @@ note: required by a bound in `check` | LL | fn check(_: impl std::marker::ConstParamTy) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check` +help: use parentheses to call this closure + | +LL | check(|| {}()); + | ++ error[E0277]: `fn()` can't be used as a const parameter type --> $DIR/const_param_ty_bad.rs:9:11 @@ -39,6 +47,10 @@ note: required by a bound in `check` | LL | fn check(_: impl std::marker::ConstParamTy) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check` +help: use parentheses to call this function pointer + | +LL | check(main as fn()()); + | ++ error[E0277]: `&mut ()` can't be used as a const parameter type --> $DIR/const_param_ty_bad.rs:10:11 @@ -48,11 +60,17 @@ LL | check(&mut ()); | | | required by a bound introduced by this call | + = note: `ConstParamTy` is implemented for `&()`, but not for `&mut ()` note: required by a bound in `check` --> $DIR/const_param_ty_bad.rs:4:18 | LL | fn check(_: impl std::marker::ConstParamTy) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check` +help: consider removing the leading `&`-reference + | +LL - check(&mut ()); +LL + check(()); + | error[E0277]: `*mut ()` can't be used as a const parameter type --> $DIR/const_param_ty_bad.rs:11:11 @@ -62,6 +80,7 @@ LL | check(&mut () as *mut ()); | | | required by a bound introduced by this call | + = help: the trait `ConstParamTy` is implemented for `()` note: required by a bound in `check` --> $DIR/const_param_ty_bad.rs:4:18 | @@ -76,6 +95,7 @@ LL | check(&() as *const ()); | | | required by a bound introduced by this call | + = help: the trait `ConstParamTy` is implemented for `()` note: required by a bound in `check` --> $DIR/const_param_ty_bad.rs:4:18 | diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_good.rs b/tests/ui/const-generics/adt_const_params/const_param_ty_good.rs index 87ae83dd966..100ab332a40 100644 --- a/tests/ui/const-generics/adt_const_params/const_param_ty_good.rs +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_good.rs @@ -49,5 +49,7 @@ fn main() { check::<D<u8>>(); check::<D<[&[bool]; 8]>>(); - // FIXME: test tuples + check::<()>(); + check::<(i32,)>(); + check::<(D<u8>, D<i32>)>(); } 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 37986de481f..08f7c5cb542 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 @@ -9,9 +9,11 @@ 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)]` #[derive(std::marker::ConstParamTy)] //~^ error: the type `CantParamDerive` does not `#[derive(Eq)]` +//~| error: the type `CantParamDerive` does not `#[derive(PartialEq)]` 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 52701d55914..43c5b96dc7c 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,12 @@ +error[E0277]: the type `CantParam` does not `#[derive(PartialEq)]` + --> $DIR/const_param_ty_impl_no_structural_eq.rs:10:36 + | +LL | impl std::marker::ConstParamTy for CantParam {} + | ^^^^^^^^^ the trait `StructuralPartialEq` is not implemented for `CantParam` + | +note: required by a bound in `ConstParamTy` + --> $SRC_DIR/core/src/marker.rs:LL:COL + error[E0277]: the type `CantParam` does not `#[derive(Eq)]` --> $DIR/const_param_ty_impl_no_structural_eq.rs:10:36 | @@ -7,8 +16,18 @@ 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 type `CantParamDerive` does not `#[derive(PartialEq)]` + --> $DIR/const_param_ty_impl_no_structural_eq.rs:14:10 + | +LL | #[derive(std::marker::ConstParamTy)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `StructuralPartialEq` 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) + error[E0277]: the type `CantParamDerive` does not `#[derive(Eq)]` - --> $DIR/const_param_ty_impl_no_structural_eq.rs:13:10 + --> $DIR/const_param_ty_impl_no_structural_eq.rs:14:10 | LL | #[derive(std::marker::ConstParamTy)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `StructuralEq` is not implemented for `CantParamDerive` @@ -17,6 +36,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 2 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_union.rs b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_union.rs index d70377a20c1..c04e96c569b 100644 --- a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_union.rs +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_union.rs @@ -14,6 +14,7 @@ impl Eq for Union {} impl std::marker::StructuralEq for Union {} impl std::marker::ConstParamTy for Union {} +//~^ ERROR the type `Union` does not `#[derive(PartialEq)]` #[derive(std::marker::ConstParamTy)] //~^ ERROR this trait cannot be derived for unions diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_union.stderr b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_union.stderr index 29370304605..985b933c40c 100644 --- a/tests/ui/const-generics/adt_const_params/const_param_ty_impl_union.stderr +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_impl_union.stderr @@ -1,8 +1,18 @@ error: this trait cannot be derived for unions - --> $DIR/const_param_ty_impl_union.rs:18:10 + --> $DIR/const_param_ty_impl_union.rs:19:10 | LL | #[derive(std::marker::ConstParamTy)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +error[E0277]: the type `Union` does not `#[derive(PartialEq)]` + --> $DIR/const_param_ty_impl_union.rs:16:36 + | +LL | impl std::marker::ConstParamTy for Union {} + | ^^^^^ the trait `StructuralPartialEq` is not implemented for `Union` + | +note: required by a bound in `ConstParamTy` + --> $SRC_DIR/core/src/marker.rs:LL:COL + +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/const-generics/const-param-with-additional-obligations.rs b/tests/ui/const-generics/const-param-with-additional-obligations.rs new file mode 100644 index 00000000000..f53cf85cdd3 --- /dev/null +++ b/tests/ui/const-generics/const-param-with-additional-obligations.rs @@ -0,0 +1,17 @@ +#![feature(adt_const_params)] +#![allow(incomplete_features)] + +use std::marker::ConstParamTy; + +#[derive(Eq, PartialEq)] +struct Foo<T>(T); + +trait Other {} + +impl<T> ConstParamTy for Foo<T> where T: Other + ConstParamTy {} + +fn foo<const N: Foo<u8>>() {} +//~^ ERROR `Foo<u8>` must implement `ConstParamTy` to be used as the type of a const generic parameter +//~| NOTE `u8` must implement `Other`, but it does not + +fn main() {} diff --git a/tests/ui/const-generics/const-param-with-additional-obligations.stderr b/tests/ui/const-generics/const-param-with-additional-obligations.stderr new file mode 100644 index 00000000000..f7ec4d57401 --- /dev/null +++ b/tests/ui/const-generics/const-param-with-additional-obligations.stderr @@ -0,0 +1,11 @@ +error[E0741]: `Foo<u8>` must implement `ConstParamTy` to be used as the type of a const generic parameter + --> $DIR/const-param-with-additional-obligations.rs:13:17 + | +LL | fn foo<const N: Foo<u8>>() {} + | ^^^^^^^ + | + = note: `u8` must implement `Other`, but it does not + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0741`. diff --git a/tests/ui/const-generics/float-generic.adt_const_params.stderr b/tests/ui/const-generics/float-generic.adt_const_params.stderr index fef5ef0d1fa..6fe5390471d 100644 --- a/tests/ui/const-generics/float-generic.adt_const_params.stderr +++ b/tests/ui/const-generics/float-generic.adt_const_params.stderr @@ -3,8 +3,6 @@ error[E0741]: `f32` is forbidden as the type of a const generic parameter | LL | fn foo<const F: f32>() {} | ^^^ - | - = note: floats do not derive `Eq` or `Ord`, which are required for const parameters error: aborting due to previous error diff --git a/tests/ui/const-generics/forbid-non-structural_match-types.rs b/tests/ui/const-generics/forbid-non-structural_match-types.rs index 6ae9d5cfbb5..4fec2a9f32f 100644 --- a/tests/ui/const-generics/forbid-non-structural_match-types.rs +++ b/tests/ui/const-generics/forbid-non-structural_match-types.rs @@ -1,13 +1,15 @@ #![feature(adt_const_params)] #![allow(incomplete_features)] -#[derive(PartialEq, Eq)] +use std::marker::ConstParamTy; + +#[derive(PartialEq, Eq, ConstParamTy)] struct A; struct B<const X: A>; // ok struct C; -struct D<const X: C>; //~ ERROR `C` must be annotated with `#[derive(PartialEq, Eq)]` +struct D<const X: C>; //~ ERROR `C` must implement `ConstParamTy` to be used as the type of a const generic parameter fn main() {} diff --git a/tests/ui/const-generics/forbid-non-structural_match-types.stderr b/tests/ui/const-generics/forbid-non-structural_match-types.stderr index 81b9bdfbd60..0efb9e9d3c2 100644 --- a/tests/ui/const-generics/forbid-non-structural_match-types.stderr +++ b/tests/ui/const-generics/forbid-non-structural_match-types.stderr @@ -1,8 +1,14 @@ -error[E0741]: `C` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter - --> $DIR/forbid-non-structural_match-types.rs:11:19 +error[E0741]: `C` must implement `ConstParamTy` to be used as the type of a const generic parameter + --> $DIR/forbid-non-structural_match-types.rs:13:19 | LL | struct D<const X: C>; - | ^ `C` doesn't derive both `PartialEq` and `Eq` + | ^ + | +help: add `#[derive(ConstParamTy, PartialEq, Eq)]` to the struct + | +LL + #[derive(ConstParamTy, PartialEq, Eq)] +LL | struct C; + | error: aborting due to previous error diff --git a/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.full.stderr b/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.full.stderr index 1d10dfdf10c..c478718b4cc 100644 --- a/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.full.stderr +++ b/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.full.stderr @@ -7,7 +7,7 @@ LL | struct ArithArrayLen<const N: usize>([u32; 0 + N]); = help: try adding a `where` bound using this expression: `where [(); 0 + N]:` error: overly complex generic constant - --> $DIR/array-size-in-generic-struct-param.rs:19:15 + --> $DIR/array-size-in-generic-struct-param.rs:23:15 | LL | arr: [u8; CFG.arr_size], | ^^^^^^^^^^^^ field access is not supported in generic constants 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 18e9135d072..956e9c9c988 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 @@ -8,7 +8,7 @@ LL | struct ArithArrayLen<const N: usize>([u32; 0 + N]); = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions error: generic parameters may not be used in const operations - --> $DIR/array-size-in-generic-struct-param.rs:19:15 + --> $DIR/array-size-in-generic-struct-param.rs:23:15 | LL | arr: [u8; CFG.arr_size], | ^^^ cannot perform const operation using `CFG` @@ -17,7 +17,7 @@ LL | arr: [u8; CFG.arr_size], = help: use `#![feature(generic_const_exprs)]` to allow generic const expressions error: `Config` is forbidden as the type of a const generic parameter - --> $DIR/array-size-in-generic-struct-param.rs:17:21 + --> $DIR/array-size-in-generic-struct-param.rs:21:21 | LL | struct B<const CFG: Config> { | ^^^^^^ diff --git a/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.rs b/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.rs index 7d3fe413c17..33ca6dcb304 100644 --- a/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.rs +++ b/tests/ui/const-generics/generic_const_exprs/array-size-in-generic-struct-param.rs @@ -9,7 +9,11 @@ struct ArithArrayLen<const N: usize>([u32; 0 + N]); //[full]~^ ERROR unconstrained generic constant //[min]~^^ ERROR generic parameters may not be used in const operations +#[cfg(full)] +use std::marker::ConstParamTy; + #[derive(PartialEq, Eq)] +#[cfg_attr(full, derive(ConstParamTy))] struct Config { arr_size: usize, } diff --git a/tests/ui/const-generics/generic_const_exprs/issue-80742.stderr b/tests/ui/const-generics/generic_const_exprs/issue-80742.stderr index 6aa8ee13b79..dc3a400cbaa 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-80742.stderr +++ b/tests/ui/const-generics/generic_const_exprs/issue-80742.stderr @@ -1,4 +1,4 @@ -error[E0080]: evaluation of `Inline::<dyn std::fmt::Debug>::{constant#0}` failed +error[E0080]: evaluation of `Inline::<dyn Debug>::{constant#0}` failed --> $SRC_DIR/core/src/mem/mod.rs:LL:COL | = note: size_of called on unsized type `dyn Debug` @@ -35,7 +35,7 @@ help: consider relaxing the type parameter's implicit `Sized` bound LL | impl<T: ?Sized> Inline<T> | ++++++++ -error[E0080]: evaluation of `Inline::<dyn std::fmt::Debug>::{constant#0}` failed +error[E0080]: evaluation of `Inline::<dyn Debug>::{constant#0}` failed --> $SRC_DIR/core/src/mem/mod.rs:LL:COL | = note: size_of called on unsized type `dyn Debug` diff --git a/tests/ui/const-generics/invalid-enum.rs b/tests/ui/const-generics/invalid-enum.rs index cb6d05349db..fcfad300c44 100644 --- a/tests/ui/const-generics/invalid-enum.rs +++ b/tests/ui/const-generics/invalid-enum.rs @@ -1,7 +1,9 @@ #![feature(adt_const_params)] #![allow(incomplete_features)] -#[derive(PartialEq, Eq)] +use std::marker::ConstParamTy; + +#[derive(PartialEq, Eq, ConstParamTy)] enum CompileFlag { A, B, diff --git a/tests/ui/const-generics/invalid-enum.stderr b/tests/ui/const-generics/invalid-enum.stderr index 0d3643f6f89..7e8a632b34f 100644 --- a/tests/ui/const-generics/invalid-enum.stderr +++ b/tests/ui/const-generics/invalid-enum.stderr @@ -1,5 +1,5 @@ error[E0573]: expected type, found variant `CompileFlag::A` - --> $DIR/invalid-enum.rs:21:12 + --> $DIR/invalid-enum.rs:23:12 | LL | test_1::<CompileFlag::A>(); | ^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | test_1::<CompileFlag::A>(); | help: try using the variant's enum: `CompileFlag` error[E0573]: expected type, found variant `CompileFlag::A` - --> $DIR/invalid-enum.rs:25:15 + --> $DIR/invalid-enum.rs:27:15 | LL | test_2::<_, CompileFlag::A>(0); | ^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | test_2::<_, CompileFlag::A>(0); | help: try using the variant's enum: `CompileFlag` error[E0573]: expected type, found variant `CompileFlag::A` - --> $DIR/invalid-enum.rs:29:18 + --> $DIR/invalid-enum.rs:31:18 | LL | let _: Example<CompileFlag::A, _> = Example { x: 0 }; | ^^^^^^^^^^^^^^ @@ -26,7 +26,7 @@ LL | let _: Example<CompileFlag::A, _> = Example { x: 0 }; | help: try using the variant's enum: `CompileFlag` error[E0747]: unresolved item provided when a constant was expected - --> $DIR/invalid-enum.rs:29:18 + --> $DIR/invalid-enum.rs:31:18 | LL | let _: Example<CompileFlag::A, _> = Example { x: 0 }; | ^^^^^^^^^^^^^^ @@ -37,7 +37,7 @@ LL | let _: Example<{ CompileFlag::A }, _> = Example { x: 0 }; | + + error[E0747]: type provided when a constant was expected - --> $DIR/invalid-enum.rs:33:18 + --> $DIR/invalid-enum.rs:35:18 | LL | let _: Example<Example::ASSOC_FLAG, _> = Example { x: 0 }; | ^^^^^^^^^^^^^^^^^^^ @@ -48,7 +48,7 @@ LL | let _: Example<{ Example::ASSOC_FLAG }, _> = Example { x: 0 }; | + + error[E0747]: unresolved item provided when a constant was expected - --> $DIR/invalid-enum.rs:21:12 + --> $DIR/invalid-enum.rs:23:12 | LL | test_1::<CompileFlag::A>(); | ^^^^^^^^^^^^^^ @@ -59,7 +59,7 @@ LL | test_1::<{ CompileFlag::A }>(); | + + error[E0747]: unresolved item provided when a constant was expected - --> $DIR/invalid-enum.rs:25:15 + --> $DIR/invalid-enum.rs:27:15 | LL | test_2::<_, CompileFlag::A>(0); | ^^^^^^^^^^^^^^ diff --git a/tests/ui/const-generics/issue-66451.rs b/tests/ui/const-generics/issue-66451.rs index 3335f7d5984..c8d5515e987 100644 --- a/tests/ui/const-generics/issue-66451.rs +++ b/tests/ui/const-generics/issue-66451.rs @@ -1,13 +1,15 @@ #![feature(adt_const_params)] #![allow(incomplete_features)] -#[derive(Debug, PartialEq, Eq)] +use std::marker::ConstParamTy; + +#[derive(Debug, PartialEq, Eq, ConstParamTy)] struct Foo { value: i32, nested: &'static Bar<i32>, } -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, PartialEq, Eq, ConstParamTy)] struct Bar<T>(T); struct Test<const F: Foo>; diff --git a/tests/ui/const-generics/issue-66451.stderr b/tests/ui/const-generics/issue-66451.stderr index e0cb0b661ff..946d5148667 100644 --- a/tests/ui/const-generics/issue-66451.stderr +++ b/tests/ui/const-generics/issue-66451.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-66451.rs:27:10 + --> $DIR/issue-66451.rs:29:10 | LL | let y: Test<{ | ____________- diff --git a/tests/ui/const-generics/issue-80471.rs b/tests/ui/const-generics/issue-80471.rs index d0af8a5eaa8..fa6f1fde435 100644 --- a/tests/ui/const-generics/issue-80471.rs +++ b/tests/ui/const-generics/issue-80471.rs @@ -8,6 +8,6 @@ enum Nat { } fn foo<const N: Nat>() {} -//~^ ERROR `Box<Nat>` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter +//~^ ERROR `Nat` must implement `ConstParamTy` to be used as the type of a const generic parameter fn main() {} diff --git a/tests/ui/const-generics/issue-80471.stderr b/tests/ui/const-generics/issue-80471.stderr index b89706710bc..3b7143de543 100644 --- a/tests/ui/const-generics/issue-80471.stderr +++ b/tests/ui/const-generics/issue-80471.stderr @@ -7,11 +7,17 @@ LL | #![feature(adt_const_params)] = note: see issue #95174 <https://github.com/rust-lang/rust/issues/95174> for more information = note: `#[warn(incomplete_features)]` on by default -error[E0741]: `Box<Nat>` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter +error[E0741]: `Nat` must implement `ConstParamTy` to be used as the type of a const generic parameter --> $DIR/issue-80471.rs:10:17 | LL | fn foo<const N: Nat>() {} | ^^^ + | +help: add `#[derive(ConstParamTy)]` to the struct + | +LL + #[derive(ConstParamTy)] +LL | enum Nat { + | error: aborting due to previous error; 1 warning emitted diff --git a/tests/ui/const-generics/issues/issue-63322-forbid-dyn.full.stderr b/tests/ui/const-generics/issues/issue-63322-forbid-dyn.full.stderr index 16fabd1e88f..e2d8c5ca0e1 100644 --- a/tests/ui/const-generics/issues/issue-63322-forbid-dyn.full.stderr +++ b/tests/ui/const-generics/issues/issue-63322-forbid-dyn.full.stderr @@ -1,8 +1,10 @@ -error[E0741]: `(dyn A + 'static)` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter +error[E0741]: `&'static (dyn A + 'static)` can't be used as a const parameter type --> $DIR/issue-63322-forbid-dyn.rs:9:18 | LL | fn test<const T: &'static dyn A>() { | ^^^^^^^^^^^^^^ + | + = note: `(dyn A + 'static)` must implement `ConstParamTy`, but it does not error: aborting due to previous error diff --git a/tests/ui/const-generics/issues/issue-63322-forbid-dyn.rs b/tests/ui/const-generics/issues/issue-63322-forbid-dyn.rs index 116c3fcfb21..8bc35ab3d37 100644 --- a/tests/ui/const-generics/issues/issue-63322-forbid-dyn.rs +++ b/tests/ui/const-generics/issues/issue-63322-forbid-dyn.rs @@ -7,7 +7,7 @@ struct B; impl A for B {} fn test<const T: &'static dyn A>() { - //[full]~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` to be used + //[full]~^ ERROR `&'static (dyn A + 'static)` can't be used as a const parameter type //[min]~^^ ERROR `&'static (dyn A + 'static)` is forbidden unimplemented!() } diff --git a/tests/ui/const-generics/issues/issue-71381.full.stderr b/tests/ui/const-generics/issues/issue-71381.full.stderr index 962eaf75b98..b6460e0017f 100644 --- a/tests/ui/const-generics/issues/issue-71381.full.stderr +++ b/tests/ui/const-generics/issues/issue-71381.full.stderr @@ -14,19 +14,6 @@ LL | const FN: unsafe extern "C" fn(Args), | = note: type parameters may not be used in the type of const parameters -error[E0741]: using function pointers as const generic parameters is forbidden - --> $DIR/issue-71381.rs:14:61 - | -LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&self) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0741]: using function pointers as const generic parameters is forbidden - --> $DIR/issue-71381.rs:23:19 - | -LL | const FN: unsafe extern "C" fn(Args), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0741, E0770. -For more information about an error, try `rustc --explain E0741`. +For more information about this error, try `rustc --explain E0770`. diff --git a/tests/ui/const-generics/issues/issue-71381.rs b/tests/ui/const-generics/issues/issue-71381.rs index 66f819dbe06..8a878efb42a 100644 --- a/tests/ui/const-generics/issues/issue-71381.rs +++ b/tests/ui/const-generics/issues/issue-71381.rs @@ -12,8 +12,8 @@ unsafe extern "C" fn pass(args: PassArg) { impl Test { pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&self) { - //~^ ERROR: using function pointers as const generic parameters is forbidden - //~| ERROR: the type of const parameters must not depend on other generic parameters + //[min]~^ ERROR: using function pointers as const generic parameters is forbidden + //~^^ ERROR: the type of const parameters must not depend on other generic parameters self.0 = Self::trampiline::<Args, IDX, FN> as _ } @@ -21,8 +21,8 @@ impl Test { Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args), - //~^ ERROR: using function pointers as const generic parameters is forbidden - //~| ERROR: the type of const parameters must not depend on other generic parameters + //[min]~^ ERROR: using function pointers as const generic parameters is forbidden + //~^^ ERROR: the type of const parameters must not depend on other generic parameters >( args: Args, ) { @@ -31,6 +31,6 @@ impl Test { } fn main() { - let x = Test(); + let x = Test(std::ptr::null()); x.call_me::<PassArg, 30, pass>() } diff --git a/tests/ui/const-generics/issues/issue-71611.full.stderr b/tests/ui/const-generics/issues/issue-71611.full.stderr index e109459f2be..b55f410a023 100644 --- a/tests/ui/const-generics/issues/issue-71611.full.stderr +++ b/tests/ui/const-generics/issues/issue-71611.full.stderr @@ -6,13 +6,6 @@ LL | fn func<A, const F: fn(inner: A)>(outer: A) { | = note: type parameters may not be used in the type of const parameters -error[E0741]: using function pointers as const generic parameters is forbidden - --> $DIR/issue-71611.rs:5:21 - | -LL | fn func<A, const F: fn(inner: A)>(outer: A) { - | ^^^^^^^^^^^^ - -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0741, E0770. -For more information about an error, try `rustc --explain E0741`. +For more information about this error, try `rustc --explain E0770`. diff --git a/tests/ui/const-generics/issues/issue-71611.rs b/tests/ui/const-generics/issues/issue-71611.rs index fbb91ca18aa..c917f66818b 100644 --- a/tests/ui/const-generics/issues/issue-71611.rs +++ b/tests/ui/const-generics/issues/issue-71611.rs @@ -3,8 +3,8 @@ #![cfg_attr(full, allow(incomplete_features))] fn func<A, const F: fn(inner: A)>(outer: A) { - //~^ ERROR: using function pointers as const generic parameters is forbidden - //~| ERROR: the type of const parameters must not depend on other generic parameters + //[min]~^ ERROR: using function pointers as const generic parameters is forbidden + //~^^ ERROR: the type of const parameters must not depend on other generic parameters F(outer); } diff --git a/tests/ui/const-generics/issues/issue-74255.min.stderr b/tests/ui/const-generics/issues/issue-74255.min.stderr index b462d84487e..bbcf8682b71 100644 --- a/tests/ui/const-generics/issues/issue-74255.min.stderr +++ b/tests/ui/const-generics/issues/issue-74255.min.stderr @@ -1,5 +1,5 @@ error: `IceEnum` is forbidden as the type of a const generic parameter - --> $DIR/issue-74255.rs:14:31 + --> $DIR/issue-74255.rs:18:31 | LL | fn ice_struct_fn<const I: IceEnum>() {} | ^^^^^^^ diff --git a/tests/ui/const-generics/issues/issue-74255.rs b/tests/ui/const-generics/issues/issue-74255.rs index 0e523926fb0..60b2fd37c44 100644 --- a/tests/ui/const-generics/issues/issue-74255.rs +++ b/tests/ui/const-generics/issues/issue-74255.rs @@ -3,7 +3,11 @@ #![cfg_attr(full, feature(adt_const_params))] #![cfg_attr(full, allow(incomplete_features))] +#[cfg(full)] +use std::marker::ConstParamTy; + #[derive(PartialEq, Eq)] +#[cfg_attr(full, derive(ConstParamTy))] enum IceEnum { Variant } diff --git a/tests/ui/const-generics/issues/issue-74950.min.stderr b/tests/ui/const-generics/issues/issue-74950.min.stderr index 729ecc2022c..c37ee93d420 100644 --- a/tests/ui/const-generics/issues/issue-74950.min.stderr +++ b/tests/ui/const-generics/issues/issue-74950.min.stderr @@ -1,5 +1,5 @@ error: `Inner` is forbidden as the type of a const generic parameter - --> $DIR/issue-74950.rs:17:23 + --> $DIR/issue-74950.rs:20:23 | LL | struct Outer<const I: Inner>; | ^^^^^ @@ -8,7 +8,7 @@ LL | struct Outer<const I: Inner>; = help: more complex types are supported with `#![feature(adt_const_params)]` error: `Inner` is forbidden as the type of a const generic parameter - --> $DIR/issue-74950.rs:17:23 + --> $DIR/issue-74950.rs:20:23 | LL | struct Outer<const I: Inner>; | ^^^^^ @@ -17,7 +17,7 @@ LL | struct Outer<const I: Inner>; = help: more complex types are supported with `#![feature(adt_const_params)]` error: `Inner` is forbidden as the type of a const generic parameter - --> $DIR/issue-74950.rs:17:23 + --> $DIR/issue-74950.rs:20:23 | LL | struct Outer<const I: Inner>; | ^^^^^ @@ -26,7 +26,7 @@ LL | struct Outer<const I: Inner>; = help: more complex types are supported with `#![feature(adt_const_params)]` error: `Inner` is forbidden as the type of a const generic parameter - --> $DIR/issue-74950.rs:17:23 + --> $DIR/issue-74950.rs:20:23 | LL | struct Outer<const I: Inner>; | ^^^^^ @@ -35,7 +35,7 @@ LL | struct Outer<const I: Inner>; = help: more complex types are supported with `#![feature(adt_const_params)]` error: `Inner` is forbidden as the type of a const generic parameter - --> $DIR/issue-74950.rs:17:23 + --> $DIR/issue-74950.rs:20:23 | LL | struct Outer<const I: Inner>; | ^^^^^ diff --git a/tests/ui/const-generics/issues/issue-74950.rs b/tests/ui/const-generics/issues/issue-74950.rs index 3e1ca4735db..43bb322656b 100644 --- a/tests/ui/const-generics/issues/issue-74950.rs +++ b/tests/ui/const-generics/issues/issue-74950.rs @@ -3,8 +3,11 @@ #![cfg_attr(full, feature(adt_const_params))] #![cfg_attr(full, allow(incomplete_features))] +#[cfg(full)] +use std::marker::ConstParamTy; #[derive(PartialEq, Eq)] +#[cfg_attr(full, derive(ConstParamTy))] struct Inner; // Note: We emit the error 5 times if we don't deduplicate: diff --git a/tests/ui/const-generics/issues/issue-87076.rs b/tests/ui/const-generics/issues/issue-87076.rs index 8a567678b82..a32c1f965f8 100644 --- a/tests/ui/const-generics/issues/issue-87076.rs +++ b/tests/ui/const-generics/issues/issue-87076.rs @@ -3,7 +3,9 @@ #![feature(adt_const_params)] #![allow(incomplete_features)] -#[derive(PartialEq, Eq)] +use std::marker::ConstParamTy; + +#[derive(PartialEq, Eq, ConstParamTy)] pub struct UnitDims { pub time: u8, pub length: u8, diff --git a/tests/ui/const-generics/issues/issue-97278.rs b/tests/ui/const-generics/issues/issue-97278.rs index da0a9776fd4..8e7a1fcd995 100644 --- a/tests/ui/const-generics/issues/issue-97278.rs +++ b/tests/ui/const-generics/issues/issue-97278.rs @@ -9,6 +9,6 @@ enum Bar { } fn test<const BAR: Bar>() {} -//~^ ERROR `Arc<i32>` must be annotated with `#[derive(PartialEq, Eq)]` +//~^ ERROR `Bar` must implement `ConstParamTy` to be used as the type of a const generic parameter fn main() {} diff --git a/tests/ui/const-generics/issues/issue-97278.stderr b/tests/ui/const-generics/issues/issue-97278.stderr index ff13cb505ab..31e92f840e1 100644 --- a/tests/ui/const-generics/issues/issue-97278.stderr +++ b/tests/ui/const-generics/issues/issue-97278.stderr @@ -1,8 +1,14 @@ -error[E0741]: `Arc<i32>` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter +error[E0741]: `Bar` must implement `ConstParamTy` to be used as the type of a const generic parameter --> $DIR/issue-97278.rs:11:20 | LL | fn test<const BAR: Bar>() {} | ^^^ + | +help: add `#[derive(ConstParamTy)]` to the struct + | +LL + #[derive(ConstParamTy)] +LL | enum Bar { + | error: aborting due to previous error diff --git a/tests/ui/const-generics/issues/issue-99641.rs b/tests/ui/const-generics/issues/issue-99641.rs index fae6d3fc41f..dd075a6ad05 100644 --- a/tests/ui/const-generics/issues/issue-99641.rs +++ b/tests/ui/const-generics/issues/issue-99641.rs @@ -3,10 +3,10 @@ fn main() { pub struct Color<const WHITE: (fn(),)>; - //~^ ERROR using function pointers + //~^ ERROR `(fn(),)` can't be used as a const parameter type impl<const WHITE: (fn(),)> Color<WHITE> { - //~^ ERROR using function pointers + //~^ ERROR `(fn(),)` can't be used as a const parameter type pub fn new() -> Self { Color::<WHITE> } diff --git a/tests/ui/const-generics/issues/issue-99641.stderr b/tests/ui/const-generics/issues/issue-99641.stderr index 349ebba08d5..800aec3ef2c 100644 --- a/tests/ui/const-generics/issues/issue-99641.stderr +++ b/tests/ui/const-generics/issues/issue-99641.stderr @@ -1,14 +1,18 @@ -error[E0741]: using function pointers as const generic parameters is forbidden +error[E0741]: `(fn(),)` can't be used as a const parameter type --> $DIR/issue-99641.rs:5:35 | LL | pub struct Color<const WHITE: (fn(),)>; | ^^^^^^^ + | + = note: `fn()` must implement `ConstParamTy`, but it does not -error[E0741]: using function pointers as const generic parameters is forbidden +error[E0741]: `(fn(),)` can't be used as a const parameter type --> $DIR/issue-99641.rs:8:23 | LL | impl<const WHITE: (fn(),)> Color<WHITE> { | ^^^^^^^ + | + = note: `fn()` must implement `ConstParamTy`, but it does not error: aborting due to 2 previous errors diff --git a/tests/ui/const-generics/overlapping_impls.rs b/tests/ui/const-generics/overlapping_impls.rs index e599eadd8cf..2ce6c4a823c 100644 --- a/tests/ui/const-generics/overlapping_impls.rs +++ b/tests/ui/const-generics/overlapping_impls.rs @@ -2,7 +2,8 @@ #![allow(incomplete_features)] #![feature(adt_const_params)] #![feature(generic_const_exprs)] -use std::marker::PhantomData; + +use std::marker::{ConstParamTy, PhantomData}; struct Foo<const I: i32, const J: i32> {} @@ -22,7 +23,7 @@ pub struct Foo2<const P: Protocol, T> { _marker: PhantomData<T>, } -#[derive(PartialEq, Eq)] +#[derive(PartialEq, Eq, ConstParamTy)] pub enum Protocol { Variant1, Variant2, diff --git a/tests/ui/const-generics/std/const-generics-range.full.stderr b/tests/ui/const-generics/std/const-generics-range.full.stderr new file mode 100644 index 00000000000..5bf48ad7385 --- /dev/null +++ b/tests/ui/const-generics/std/const-generics-range.full.stderr @@ -0,0 +1,39 @@ +error[E0741]: `std::ops::Range<usize>` must implement `ConstParamTy` to be used as the type of a const generic parameter + --> $DIR/const-generics-range.rs:8:24 + | +LL | struct _Range<const R: std::ops::Range<usize>>; + | ^^^^^^^^^^^^^^^^^^^^^^ + +error[E0741]: `RangeFrom<usize>` must implement `ConstParamTy` to be used as the type of a const generic parameter + --> $DIR/const-generics-range.rs:13:28 + | +LL | struct _RangeFrom<const R: std::ops::RangeFrom<usize>>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0741]: `RangeFull` must implement `ConstParamTy` to be used as the type of a const generic parameter + --> $DIR/const-generics-range.rs:18:28 + | +LL | struct _RangeFull<const R: std::ops::RangeFull>; + | ^^^^^^^^^^^^^^^^^^^ + +error[E0741]: `RangeInclusive<usize>` must implement `ConstParamTy` to be used as the type of a const generic parameter + --> $DIR/const-generics-range.rs:24:33 + | +LL | struct _RangeInclusive<const R: std::ops::RangeInclusive<usize>>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0741]: `RangeTo<usize>` must implement `ConstParamTy` to be used as the type of a const generic parameter + --> $DIR/const-generics-range.rs:29:26 + | +LL | struct _RangeTo<const R: std::ops::RangeTo<usize>>; + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0741]: `RangeToInclusive<usize>` must implement `ConstParamTy` to be used as the type of a const generic parameter + --> $DIR/const-generics-range.rs:34:35 + | +LL | struct _RangeToInclusive<const R: std::ops::RangeToInclusive<usize>>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0741`. 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 d4b2ad6fd0c..53fca6e884a 100644 --- a/tests/ui/const-generics/std/const-generics-range.min.stderr +++ b/tests/ui/const-generics/std/const-generics-range.min.stderr @@ -1,5 +1,5 @@ error: `std::ops::Range<usize>` is forbidden as the type of a const generic parameter - --> $DIR/const-generics-range.rs:7:24 + --> $DIR/const-generics-range.rs:8:24 | LL | struct _Range<const R: std::ops::Range<usize>>; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | struct _Range<const R: std::ops::Range<usize>>; = help: more complex types are supported with `#![feature(adt_const_params)]` error: `RangeFrom<usize>` is forbidden as the type of a const generic parameter - --> $DIR/const-generics-range.rs:12:28 + --> $DIR/const-generics-range.rs:13:28 | LL | struct _RangeFrom<const R: std::ops::RangeFrom<usize>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ LL | struct _RangeFrom<const R: std::ops::RangeFrom<usize>>; = help: more complex types are supported with `#![feature(adt_const_params)]` error: `RangeFull` is forbidden as the type of a const generic parameter - --> $DIR/const-generics-range.rs:17:28 + --> $DIR/const-generics-range.rs:18:28 | LL | struct _RangeFull<const R: std::ops::RangeFull>; | ^^^^^^^^^^^^^^^^^^^ @@ -26,7 +26,7 @@ LL | struct _RangeFull<const R: std::ops::RangeFull>; = help: more complex types are supported with `#![feature(adt_const_params)]` error: `RangeInclusive<usize>` is forbidden as the type of a const generic parameter - --> $DIR/const-generics-range.rs:23:33 + --> $DIR/const-generics-range.rs:24:33 | LL | struct _RangeInclusive<const R: std::ops::RangeInclusive<usize>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -35,7 +35,7 @@ LL | struct _RangeInclusive<const R: std::ops::RangeInclusive<usize>>; = help: more complex types are supported with `#![feature(adt_const_params)]` error: `RangeTo<usize>` is forbidden as the type of a const generic parameter - --> $DIR/const-generics-range.rs:28:26 + --> $DIR/const-generics-range.rs:29:26 | LL | struct _RangeTo<const R: std::ops::RangeTo<usize>>; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -44,7 +44,7 @@ LL | struct _RangeTo<const R: std::ops::RangeTo<usize>>; = help: more complex types are supported with `#![feature(adt_const_params)]` error: `RangeToInclusive<usize>` is forbidden as the type of a const generic parameter - --> $DIR/const-generics-range.rs:33:35 + --> $DIR/const-generics-range.rs:34:35 | LL | struct _RangeToInclusive<const R: std::ops::RangeToInclusive<usize>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/const-generics/std/const-generics-range.rs b/tests/ui/const-generics/std/const-generics-range.rs index 46c06f312b9..bda59f3ec45 100644 --- a/tests/ui/const-generics/std/const-generics-range.rs +++ b/tests/ui/const-generics/std/const-generics-range.rs @@ -1,4 +1,5 @@ -// [full] check-pass +// [full] known-bug: unknown + // revisions: full min #![cfg_attr(full, feature(adt_const_params))] #![cfg_attr(full, allow(incomplete_features))] diff --git a/tests/ui/const-ptr/forbidden_slices.stderr b/tests/ui/const-ptr/forbidden_slices.stderr index 817cfb0acf9..22c3dfa64fe 100644 --- a/tests/ui/const-ptr/forbidden_slices.stderr +++ b/tests/ui/const-ptr/forbidden_slices.stderr @@ -54,11 +54,11 @@ error[E0080]: it is undefined behavior to use this value LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, size_of::<&u32>()) }; | ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: it is undefined behavior to use this value --> $DIR/forbidden_slices.rs:30:1 @@ -98,7 +98,7 @@ LL | from_raw_parts(ptr, 1) error[E0080]: could not evaluate static initializer --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - = note: out-of-bounds offset_from: null pointer is a dangling pointer (it has no provenance) + = note: out-of-bounds `offset_from`: null pointer is a dangling pointer (it has no provenance) | note: inside `ptr::const_ptr::<impl *const u32>::sub_ptr` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -156,11 +156,11 @@ error[E0080]: it is undefined behavior to use this value LL | pub static R5: &[u8] = unsafe { | ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: it is undefined behavior to use this value --> $DIR/forbidden_slices.rs:63:1 diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr b/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr index 8f3b3d5f700..23ba2c2f535 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/alloc_intrinsic_errors.rs:9:17 | LL | let _ = intrinsics::const_allocate(4, 3) as *mut i32; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ align has to be a power of 2, `3` is not a power of 2 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid align passed to `const_allocate`: 3 is not a power of 2 | note: inside `foo` --> $DIR/alloc_intrinsic_errors.rs:9:17 diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.rs b/tests/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.rs index f746f27000f..9ae906bbb73 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.rs +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.rs @@ -4,11 +4,11 @@ use std::intrinsics; const FOO: *const i32 = foo(); -//~^ ERROR untyped pointers are not allowed in constant +//~^ ERROR unsupported untyped pointer in constant const fn foo() -> &'static i32 { let t = unsafe { - let i = intrinsics::const_allocate(4, 4) as * mut i32; + let i = intrinsics::const_allocate(4, 4) as *mut i32; *i = 20; i }; diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.stderr b/tests/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.stderr index 00ab0dfc557..2103f842bd5 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.stderr +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_nontransient_fail.stderr @@ -1,8 +1,10 @@ -error: untyped pointers are not allowed in constant +error: unsupported untyped pointer in constant --> $DIR/alloc_intrinsic_nontransient_fail.rs:6:1 | LL | const FOO: *const i32 = foo(); | ^^^^^^^^^^^^^^^^^^^^^ + | + = note: memory only reachable via raw pointers is not supported error: aborting due to previous error diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.rs b/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.rs index 77871c394b7..1354b3c33b3 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.rs +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.rs @@ -3,7 +3,7 @@ #![feature(const_mut_refs)] use std::intrinsics; -const BAR: *mut i32 = unsafe { intrinsics::const_allocate(4, 4) as *mut i32}; -//~^ error: untyped pointers are not allowed in constant +const BAR: *mut i32 = unsafe { intrinsics::const_allocate(4, 4) as *mut i32 }; +//~^ error: unsupported untyped pointer in constant fn main() {} diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.stderr b/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.stderr index 36002b850b7..b6276647350 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.stderr +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_untyped.stderr @@ -1,8 +1,10 @@ -error: untyped pointers are not allowed in constant +error: unsupported untyped pointer in constant --> $DIR/alloc_intrinsic_untyped.rs:6:1 | -LL | const BAR: *mut i32 = unsafe { intrinsics::const_allocate(4, 4) as *mut i32}; +LL | const BAR: *mut i32 = unsafe { intrinsics::const_allocate(4, 4) as *mut i32 }; | ^^^^^^^^^^^^^^^^^^^ + | + = note: memory only reachable via raw pointers is not supported error: aborting due to previous error diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr index 650b409b190..4c23957a1f8 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_incorrect_layout.stderr @@ -20,7 +20,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/dealloc_intrinsic_incorrect_layout.rs:25:5 | LL | intrinsics::const_deallocate(ptr, 4, 3); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ align has to be a power of 2, `3` is not a power of 2 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid align passed to `const_deallocate`: 3 is not a power of 2 error: aborting due to 4 previous errors diff --git a/tests/ui/consts/const-eval/raw-bytes.32bit.stderr b/tests/ui/consts/const-eval/raw-bytes.32bit.stderr index a93b561e5be..c0ddaceea4c 100644 --- a/tests/ui/consts/const-eval/raw-bytes.32bit.stderr +++ b/tests/ui/consts/const-eval/raw-bytes.32bit.stderr @@ -35,7 +35,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:44:1 | LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(D)>.0: encountered a value of uninhabited type Never + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(D)>.0: encountered a value of uninhabited type `Never` | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { @@ -290,11 +290,11 @@ error[E0080]: it is undefined behavior to use this value LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 01 00 00 00 │ ╾──╼.... } + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:152:1 @@ -529,11 +529,11 @@ error[E0080]: it is undefined behavior to use this value LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem::size_of::<&u32>()) }; | ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 04 00 00 00 │ ╾──╼.... } + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:221:1 @@ -574,11 +574,11 @@ error[E0080]: it is undefined behavior to use this value LL | pub static R5: &[u8] = unsafe { | ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported = note: the raw bytes of the constant (size: 8, align: 4) { ╾ALLOC_ID╼ 04 00 00 00 │ ╾──╼.... } + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:242:1 diff --git a/tests/ui/consts/const-eval/raw-bytes.64bit.stderr b/tests/ui/consts/const-eval/raw-bytes.64bit.stderr index a32d4863a38..20c905878e0 100644 --- a/tests/ui/consts/const-eval/raw-bytes.64bit.stderr +++ b/tests/ui/consts/const-eval/raw-bytes.64bit.stderr @@ -35,7 +35,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:44:1 | LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(D)>.0: encountered a value of uninhabited type Never + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(D)>.0: encountered a value of uninhabited type `Never` | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 1, align: 1) { @@ -290,11 +290,11 @@ error[E0080]: it is undefined behavior to use this value LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........ } + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:152:1 @@ -529,11 +529,11 @@ error[E0080]: it is undefined behavior to use this value LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem::size_of::<&u32>()) }; | ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 08 00 00 00 00 00 00 00 │ ╾──────╼........ } + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:221:1 @@ -574,11 +574,11 @@ error[E0080]: it is undefined behavior to use this value LL | pub static R5: &[u8] = unsafe { | ^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported = note: the raw bytes of the constant (size: 16, align: 8) { ╾ALLOC_ID╼ 08 00 00 00 00 00 00 00 │ ╾──────╼........ } + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error[E0080]: it is undefined behavior to use this value --> $DIR/raw-bytes.rs:242:1 diff --git a/tests/ui/consts/const-eval/ub-enum.32bit.stderr b/tests/ui/consts/const-eval/ub-enum.32bit.stderr index 3ad1ac974c8..1810600b785 100644 --- a/tests/ui/consts/const-eval/ub-enum.32bit.stderr +++ b/tests/ui/consts/const-eval/ub-enum.32bit.stderr @@ -86,7 +86,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/ub-enum.rs:83:1 | LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(D)>.0: encountered a value of uninhabited type Never + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(D)>.0: encountered a value of uninhabited type `Never` | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { @@ -108,7 +108,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/ub-enum.rs:96:77 | LL | const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(0u64) }; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Ok)>.0.1: encountered a value of uninhabited type Never + | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Ok)>.0.1: encountered a value of uninhabited type `Never` error[E0080]: evaluation of constant value failed --> $DIR/ub-enum.rs:98:77 diff --git a/tests/ui/consts/const-eval/ub-enum.64bit.stderr b/tests/ui/consts/const-eval/ub-enum.64bit.stderr index a66706d1af9..fb40babb0b9 100644 --- a/tests/ui/consts/const-eval/ub-enum.64bit.stderr +++ b/tests/ui/consts/const-eval/ub-enum.64bit.stderr @@ -86,7 +86,7 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/ub-enum.rs:83:1 | LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(D)>.0: encountered a value of uninhabited type Never + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(D)>.0: encountered a value of uninhabited type `Never` | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { @@ -108,7 +108,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/ub-enum.rs:96:77 | LL | const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(0u64) }; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Ok)>.0.1: encountered a value of uninhabited type Never + | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Ok)>.0.1: encountered a value of uninhabited type `Never` error[E0080]: evaluation of constant value failed --> $DIR/ub-enum.rs:98:77 diff --git a/tests/ui/consts/const-eval/ub-uninhabit.stderr b/tests/ui/consts/const-eval/ub-uninhabit.stderr index 733975fc0e9..f1ad0f04d3d 100644 --- a/tests/ui/consts/const-eval/ub-uninhabit.stderr +++ b/tests/ui/consts/const-eval/ub-uninhabit.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/ub-uninhabit.rs:16:35 | LL | const BAD_BAD_BAD: Bar = unsafe { MaybeUninit { uninit: () }.init }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of uninhabited type Bar + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of uninhabited type `Bar` error[E0080]: it is undefined behavior to use this value --> $DIR/ub-uninhabit.rs:19:1 @@ -19,7 +19,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/ub-uninhabit.rs:22:42 | LL | const BAD_BAD_ARRAY: [Bar; 1] = unsafe { MaybeUninit { uninit: () }.init }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered a value of uninhabited type Bar + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered a value of uninhabited type `Bar` error: aborting due to 3 previous errors diff --git a/tests/ui/consts/const-eval/validate_uninhabited_zsts.32bit.stderr b/tests/ui/consts/const-eval/validate_uninhabited_zsts.32bit.stderr index 74bc6317c80..b423edbdcec 100644 --- a/tests/ui/consts/const-eval/validate_uninhabited_zsts.32bit.stderr +++ b/tests/ui/consts/const-eval/validate_uninhabited_zsts.32bit.stderr @@ -28,7 +28,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/validate_uninhabited_zsts.rs:21:42 | LL | const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered a value of uninhabited type empty::Void + | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered a value of uninhabited type `Void` warning: the type `empty::Empty` does not permit zero-initialization --> $DIR/validate_uninhabited_zsts.rs:21:42 diff --git a/tests/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr b/tests/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr index 74bc6317c80..b423edbdcec 100644 --- a/tests/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr +++ b/tests/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr @@ -28,7 +28,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/validate_uninhabited_zsts.rs:21:42 | LL | const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered a value of uninhabited type empty::Void + | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered a value of uninhabited type `Void` warning: the type `empty::Empty` does not permit zero-initialization --> $DIR/validate_uninhabited_zsts.rs:21:42 diff --git a/tests/ui/consts/issue-64506.stderr b/tests/ui/consts/issue-64506.stderr index 31a5b1df837..2fe84245b3e 100644 --- a/tests/ui/consts/issue-64506.stderr +++ b/tests/ui/consts/issue-64506.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/issue-64506.rs:16:22 | LL | let x = unsafe { Foo { b: () }.a }; - | ^^^^^^^^^^^^^^^ constructing invalid value at .inner: encountered a value of uninhabited type AnonPipe + | ^^^^^^^^^^^^^^^ constructing invalid value at .inner: encountered a value of uninhabited type `AnonPipe` error: aborting due to previous error diff --git a/tests/ui/consts/issue-83182.stderr b/tests/ui/consts/issue-83182.stderr index 1d578f910c0..ca4e0f7aa02 100644 --- a/tests/ui/consts/issue-83182.stderr +++ b/tests/ui/consts/issue-83182.stderr @@ -4,11 +4,11 @@ error[E0080]: it is undefined behavior to use this value LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[&()]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes | - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { HEX_DUMP } + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error: aborting due to previous error diff --git a/tests/ui/consts/issue-miri-1910.stderr b/tests/ui/consts/issue-miri-1910.stderr index fb758d406b5..67797e6fb5a 100644 --- a/tests/ui/consts/issue-miri-1910.stderr +++ b/tests/ui/consts/issue-miri-1910.stderr @@ -3,8 +3,6 @@ error[E0080]: evaluation of constant value failed | = note: unable to turn pointer into raw bytes | - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported note: inside `std::ptr::read::<u8>` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL note: inside `ptr::const_ptr::<impl *const u8>::read` @@ -14,6 +12,8 @@ note: inside `C` | LL | (&foo as *const _ as *const u8).add(one_and_a_half_pointers).read(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error: aborting due to previous error diff --git a/tests/ui/consts/miri_unleashed/assoc_const.stderr b/tests/ui/consts/miri_unleashed/assoc_const.stderr index 8e22cb74bf5..d97097d352a 100644 --- a/tests/ui/consts/miri_unleashed/assoc_const.stderr +++ b/tests/ui/consts/miri_unleashed/assoc_const.stderr @@ -1,4 +1,4 @@ -error[E0080]: evaluation of `<std::string::String as Bar<std::vec::Vec<u32>, std::string::String>>::F` failed +error[E0080]: evaluation of `<String as Bar<Vec<u32>, String>>::F` failed --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL | = note: calling non-const function `<Vec<u32> as Drop>::drop` diff --git a/tests/ui/consts/miri_unleashed/raw_mutable_const.rs b/tests/ui/consts/miri_unleashed/raw_mutable_const.rs index 5f8ec4e6e29..adb1f8bf3ec 100644 --- a/tests/ui/consts/miri_unleashed/raw_mutable_const.rs +++ b/tests/ui/consts/miri_unleashed/raw_mutable_const.rs @@ -3,6 +3,6 @@ use std::cell::UnsafeCell; const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _; -//~^ ERROR: untyped pointers are not allowed in constant +//~^ ERROR: unsupported untyped pointer in constant fn main() {} diff --git a/tests/ui/consts/miri_unleashed/raw_mutable_const.stderr b/tests/ui/consts/miri_unleashed/raw_mutable_const.stderr index f8dc11d695f..5acdcdd95e8 100644 --- a/tests/ui/consts/miri_unleashed/raw_mutable_const.stderr +++ b/tests/ui/consts/miri_unleashed/raw_mutable_const.stderr @@ -1,8 +1,10 @@ -error: untyped pointers are not allowed in constant +error: unsupported untyped pointer in constant --> $DIR/raw_mutable_const.rs:5:1 | LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: memory only reachable via raw pointers is not supported warning: skipping const checks | diff --git a/tests/ui/consts/missing_span_in_backtrace.stderr b/tests/ui/consts/missing_span_in_backtrace.stderr index e6d3d51990d..fcfb9fbb3f8 100644 --- a/tests/ui/consts/missing_span_in_backtrace.stderr +++ b/tests/ui/consts/missing_span_in_backtrace.stderr @@ -3,8 +3,6 @@ error[E0080]: evaluation of constant value failed | = note: unable to copy parts of a pointer from memory at ALLOC_ID | - = help: this code performed an operation that depends on the underlying bytes representing a pointer - = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported note: inside `std::ptr::read::<MaybeUninit<MaybeUninit<u8>>>` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL note: inside `mem::swap_simple::<MaybeUninit<MaybeUninit<u8>>>` @@ -22,6 +20,8 @@ note: inside `X` 20 | | mem::size_of::<&i32>(), 21 | | ); | |_________^ + = help: this code performed an operation that depends on the underlying bytes representing a pointer + = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported error: aborting due to previous error diff --git a/tests/ui/consts/offset_from_ub.stderr b/tests/ui/consts/offset_from_ub.stderr index 6530084a585..97ff6efdd79 100644 --- a/tests/ui/consts/offset_from_ub.stderr +++ b/tests/ui/consts/offset_from_ub.stderr @@ -27,31 +27,31 @@ error[E0080]: evaluation of constant value failed --> $DIR/offset_from_ub.rs:37:14 | LL | unsafe { ptr_offset_from(ptr, ptr) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: null pointer is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from`: null pointer is a dangling pointer (it has no provenance) error[E0080]: evaluation of constant value failed --> $DIR/offset_from_ub.rs:44:14 | LL | unsafe { ptr_offset_from(ptr2, ptr1) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: 0x8[noalloc] is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from`: 0x8[noalloc] is a dangling pointer (it has no provenance) error[E0080]: evaluation of constant value failed --> $DIR/offset_from_ub.rs:53:14 | LL | unsafe { ptr_offset_from(end_ptr, start_ptr) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc17 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from`: alloc17 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds error[E0080]: evaluation of constant value failed --> $DIR/offset_from_ub.rs:62:14 | LL | unsafe { ptr_offset_from(start_ptr, end_ptr) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc20 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from`: alloc20 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds error[E0080]: evaluation of constant value failed --> $DIR/offset_from_ub.rs:70:14 | LL | unsafe { ptr_offset_from(end_ptr, end_ptr) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc23 has size 4, so pointer at offset 10 is out-of-bounds + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from`: alloc23 has size 4, so pointer at offset 10 is out-of-bounds error[E0080]: evaluation of constant value failed --> $DIR/offset_from_ub.rs:79:14 @@ -86,7 +86,7 @@ LL | unsafe { ptr_offset_from_unsigned(ptr2, ptr1) } error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - = note: out-of-bounds offset_from: null pointer is a dangling pointer (it has no provenance) + = note: out-of-bounds `offset_from`: null pointer is a dangling pointer (it has no provenance) | note: inside `ptr::const_ptr::<impl *const u8>::offset_from` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -99,7 +99,7 @@ LL | unsafe { ptr2.offset_from(ptr1) } error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - = note: out-of-bounds offset_from: null pointer is a dangling pointer (it has no provenance) + = note: out-of-bounds `offset_from`: null pointer is a dangling pointer (it has no provenance) | note: inside `ptr::const_ptr::<impl *const u8>::offset_from` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL diff --git a/tests/ui/consts/raw-ptr-const.rs b/tests/ui/consts/raw-ptr-const.rs index b9c542d03d5..fc774be54df 100644 --- a/tests/ui/consts/raw-ptr-const.rs +++ b/tests/ui/consts/raw-ptr-const.rs @@ -3,6 +3,6 @@ // could also be allowed. const CONST_RAW: *const Vec<i32> = &Vec::new() as *const _; -//~^ ERROR untyped pointers are not allowed in constant +//~^ ERROR unsupported untyped pointer in constant fn main() {} diff --git a/tests/ui/consts/raw-ptr-const.stderr b/tests/ui/consts/raw-ptr-const.stderr index f7b53433b69..82f782fab7f 100644 --- a/tests/ui/consts/raw-ptr-const.stderr +++ b/tests/ui/consts/raw-ptr-const.stderr @@ -1,8 +1,10 @@ -error: untyped pointers are not allowed in constant +error: unsupported untyped pointer in constant --> $DIR/raw-ptr-const.rs:5:1 | LL | const CONST_RAW: *const Vec<i32> = &Vec::new() as *const _; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: memory only reachable via raw pointers is not supported error: aborting due to previous error diff --git a/tests/ui/consts/refs_check_const_eq-issue-88384.rs b/tests/ui/consts/refs_check_const_eq-issue-88384.rs index 1496b28bd3e..fb0405b651c 100644 --- a/tests/ui/consts/refs_check_const_eq-issue-88384.rs +++ b/tests/ui/consts/refs_check_const_eq-issue-88384.rs @@ -8,10 +8,10 @@ struct CompileTimeSettings{ } struct Foo<const T: CompileTimeSettings>; -//~^ ERROR using function pointers as const generic parameters is forbidden +//~^ ERROR `CompileTimeSettings` must implement `ConstParamTy` to be used as the type of a const generic parameter impl<const T: CompileTimeSettings> Foo<T> { - //~^ ERROR using function pointers as const generic parameters is forbidden + //~^ ERROR `CompileTimeSettings` must implement `ConstParamTy` to be used as the type of a const generic parameter fn call_hooks(){ } } diff --git a/tests/ui/consts/refs_check_const_eq-issue-88384.stderr b/tests/ui/consts/refs_check_const_eq-issue-88384.stderr index 3855b5f2a68..c490cd053e7 100644 --- a/tests/ui/consts/refs_check_const_eq-issue-88384.stderr +++ b/tests/ui/consts/refs_check_const_eq-issue-88384.stderr @@ -7,17 +7,29 @@ LL | #![feature(adt_const_params)] = note: see issue #95174 <https://github.com/rust-lang/rust/issues/95174> for more information = note: `#[warn(incomplete_features)]` on by default -error[E0741]: using function pointers as const generic parameters is forbidden +error[E0741]: `CompileTimeSettings` must implement `ConstParamTy` to be used as the type of a const generic parameter --> $DIR/refs_check_const_eq-issue-88384.rs:10:21 | LL | struct Foo<const T: CompileTimeSettings>; | ^^^^^^^^^^^^^^^^^^^ + | +help: add `#[derive(ConstParamTy)]` to the struct + | +LL + #[derive(ConstParamTy)] +LL | struct CompileTimeSettings{ + | -error[E0741]: using function pointers as const generic parameters is forbidden +error[E0741]: `CompileTimeSettings` must implement `ConstParamTy` to be used as the type of a const generic parameter --> $DIR/refs_check_const_eq-issue-88384.rs:13:15 | LL | impl<const T: CompileTimeSettings> Foo<T> { | ^^^^^^^^^^^^^^^^^^^ + | +help: add `#[derive(ConstParamTy)]` to the struct + | +LL + #[derive(ConstParamTy)] +LL | struct CompileTimeSettings{ + | error: aborting due to 2 previous errors; 1 warning emitted diff --git a/tests/ui/inline-const/elided-lifetime-being-infer-vars.rs b/tests/ui/inline-const/elided-lifetime-being-infer-vars.rs new file mode 100644 index 00000000000..5661db4a253 --- /dev/null +++ b/tests/ui/inline-const/elided-lifetime-being-infer-vars.rs @@ -0,0 +1,11 @@ +// check-pass + +#![feature(inline_const)] + +fn main() { + let _my_usize = const { + let a = 10_usize; + let b: &'_ usize = &a; + *b + }; +} diff --git a/tests/ui/issues/issue-62375.stderr b/tests/ui/issues/issue-62375.stderr index cd632e64fe5..f6d7968c0c4 100644 --- a/tests/ui/issues/issue-62375.stderr +++ b/tests/ui/issues/issue-62375.stderr @@ -11,8 +11,11 @@ note: an implementation of `PartialEq<fn(()) -> A {A::Value}>` might be missing | LL | enum A { | ^^^^^^ must implement `PartialEq<fn(()) -> A {A::Value}>` -note: the trait `PartialEq` must be implemented - --> $SRC_DIR/core/src/cmp.rs:LL:COL +help: consider annotating `A` with `#[derive(PartialEq)]` + | +LL + #[derive(PartialEq)] +LL | enum A { + | help: use parentheses to construct this tuple variant | LL | a == A::Value(/* () */); diff --git a/tests/ui/lint/trivial-casts-featuring-type-ascription.stderr b/tests/ui/lint/trivial-casts-featuring-type-ascription.stderr index 5087807b6c7..159a54873cc 100644 --- a/tests/ui/lint/trivial-casts-featuring-type-ascription.stderr +++ b/tests/ui/lint/trivial-casts-featuring-type-ascription.stderr @@ -4,7 +4,7 @@ error: trivial numeric cast: `i32` as `i32` LL | let lugubrious = 12i32 as i32; | ^^^^^^^^^^^^ | - = help: cast can be replaced by coercion; this might require type ascription or a temporary variable + = help: cast can be replaced by coercion; this might require a temporary variable note: the lint level is defined here --> $DIR/trivial-casts-featuring-type-ascription.rs:1:24 | @@ -17,7 +17,7 @@ error: trivial cast: `&u32` as `*const u32` LL | let _ = haunted as *const u32; | ^^^^^^^^^^^^^^^^^^^^^ | - = help: cast can be replaced by coercion; this might require type ascription or a temporary variable + = help: cast can be replaced by coercion; this might require a temporary variable note: the lint level is defined here --> $DIR/trivial-casts-featuring-type-ascription.rs:1:9 | diff --git a/tests/ui/mir/thir-constparam-temp.rs b/tests/ui/mir/thir-constparam-temp.rs index cdc5910b36c..7eedc325d60 100644 --- a/tests/ui/mir/thir-constparam-temp.rs +++ b/tests/ui/mir/thir-constparam-temp.rs @@ -3,7 +3,9 @@ #![feature(adt_const_params)] #![allow(incomplete_features)] -#[derive(PartialEq, Eq)] +use std::marker::ConstParamTy; + +#[derive(PartialEq, Eq, ConstParamTy)] struct Yikes; impl Yikes { diff --git a/tests/ui/mir/thir-constparam-temp.stderr b/tests/ui/mir/thir-constparam-temp.stderr index b77d67e084f..d50747e5434 100644 --- a/tests/ui/mir/thir-constparam-temp.stderr +++ b/tests/ui/mir/thir-constparam-temp.stderr @@ -1,5 +1,5 @@ warning: taking a mutable reference to a `const` item - --> $DIR/thir-constparam-temp.rs:14:5 + --> $DIR/thir-constparam-temp.rs:16:5 | LL | YIKES.mut_self() | ^^^^^^^^^^^^^^^^ @@ -7,12 +7,12 @@ LL | YIKES.mut_self() = note: each usage of a `const` item creates a new temporary = note: the mutable reference will refer to this temporary, not the original `const` item note: mutable reference created due to call to this method - --> $DIR/thir-constparam-temp.rs:10:5 + --> $DIR/thir-constparam-temp.rs:12:5 | LL | fn mut_self(&mut self) {} | ^^^^^^^^^^^^^^^^^^^^^^ note: `const` item defined here - --> $DIR/thir-constparam-temp.rs:13:8 + --> $DIR/thir-constparam-temp.rs:15:8 | LL | fn foo<const YIKES: Yikes>() { | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/mismatched_types/suggest-option-asderef-unfixable.rs b/tests/ui/mismatched_types/suggest-option-asderef-unfixable.rs new file mode 100644 index 00000000000..cc9ba5514fe --- /dev/null +++ b/tests/ui/mismatched_types/suggest-option-asderef-unfixable.rs @@ -0,0 +1,40 @@ +fn produces_string() -> Option<String> { + Some("my cool string".to_owned()) +} + +fn takes_str_but_too_many_refs(_: &&str) -> Option<()> { + Some(()) +} + +fn no_args() -> Option<()> { + Some(()) +} + +fn generic_ref<T>(_: &T) -> Option<()> { + Some(()) +} + +extern "C" fn takes_str_but_wrong_abi(_: &str) -> Option<()> { + Some(()) +} + +unsafe fn takes_str_but_unsafe(_: &str) -> Option<()> { + Some(()) +} + +struct TypeWithoutDeref; + +fn main() { + let _ = produces_string().and_then(takes_str_but_too_many_refs); + //~^ ERROR type mismatch in function arguments + let _ = produces_string().and_then(takes_str_but_wrong_abi); + //~^ ERROR expected a `FnOnce<(String,)>` closure, found `for<'a> extern "C" fn(&'a str) -> Option<()> {takes_str_but_wrong_abi}` + let _ = produces_string().and_then(takes_str_but_unsafe); + //~^ ERROR expected a `FnOnce<(String,)>` closure, found `for<'a> unsafe fn(&'a str) -> Option<()> {takes_str_but_unsafe}` + let _ = produces_string().and_then(no_args); + //~^ ERROR function is expected to take 1 argument, but it takes 0 arguments + let _ = produces_string().and_then(generic_ref); + //~^ ERROR type mismatch in function arguments + let _ = Some(TypeWithoutDeref).and_then(takes_str_but_too_many_refs); + //~^ ERROR type mismatch in function arguments +} diff --git a/tests/ui/mismatched_types/suggest-option-asderef-unfixable.stderr b/tests/ui/mismatched_types/suggest-option-asderef-unfixable.stderr new file mode 100644 index 00000000000..079909eb48d --- /dev/null +++ b/tests/ui/mismatched_types/suggest-option-asderef-unfixable.stderr @@ -0,0 +1,96 @@ +error[E0631]: type mismatch in function arguments + --> $DIR/suggest-option-asderef-unfixable.rs:28:40 + | +LL | fn takes_str_but_too_many_refs(_: &&str) -> Option<()> { + | ------------------------------------------------------ found signature defined here +... +LL | let _ = produces_string().and_then(takes_str_but_too_many_refs); + | -------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected due to this + | | + | required by a bound introduced by this call + | + = note: expected function signature `fn(String) -> _` + found function signature `for<'a, 'b> fn(&'a &'b str) -> _` +note: required by a bound in `Option::<T>::and_then` + --> $SRC_DIR/core/src/option.rs:LL:COL + +error[E0277]: expected a `FnOnce<(String,)>` closure, found `for<'a> extern "C" fn(&'a str) -> Option<()> {takes_str_but_wrong_abi}` + --> $DIR/suggest-option-asderef-unfixable.rs:30:40 + | +LL | let _ = produces_string().and_then(takes_str_but_wrong_abi); + | -------- ^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnOnce<(String,)>` closure, found `for<'a> extern "C" fn(&'a str) -> Option<()> {takes_str_but_wrong_abi}` + | | + | required by a bound introduced by this call + | + = help: the trait `FnOnce<(String,)>` is not implemented for fn item `for<'a> extern "C" fn(&'a str) -> Option<()> {takes_str_but_wrong_abi}` +note: required by a bound in `Option::<T>::and_then` + --> $SRC_DIR/core/src/option.rs:LL:COL + +error[E0277]: expected a `FnOnce<(String,)>` closure, found `for<'a> unsafe fn(&'a str) -> Option<()> {takes_str_but_unsafe}` + --> $DIR/suggest-option-asderef-unfixable.rs:32:40 + | +LL | let _ = produces_string().and_then(takes_str_but_unsafe); + | -------- ^^^^^^^^^^^^^^^^^^^^ call the function in a closure: `|| unsafe { /* code */ }` + | | + | required by a bound introduced by this call + | + = help: the trait `FnOnce<(String,)>` is not implemented for fn item `for<'a> unsafe fn(&'a str) -> Option<()> {takes_str_but_unsafe}` + = note: unsafe function cannot be called generically without an unsafe block +note: required by a bound in `Option::<T>::and_then` + --> $SRC_DIR/core/src/option.rs:LL:COL + +error[E0593]: function is expected to take 1 argument, but it takes 0 arguments + --> $DIR/suggest-option-asderef-unfixable.rs:34:40 + | +LL | fn no_args() -> Option<()> { + | -------------------------- takes 0 arguments +... +LL | let _ = produces_string().and_then(no_args); + | -------- ^^^^^^^ expected function that takes 1 argument + | | + | required by a bound introduced by this call + | +note: required by a bound in `Option::<T>::and_then` + --> $SRC_DIR/core/src/option.rs:LL:COL + +error[E0631]: type mismatch in function arguments + --> $DIR/suggest-option-asderef-unfixable.rs:36:40 + | +LL | fn generic_ref<T>(_: &T) -> Option<()> { + | -------------------------------------- found signature defined here +... +LL | let _ = produces_string().and_then(generic_ref); + | -------- ^^^^^^^^^^^ expected due to this + | | + | required by a bound introduced by this call + | + = note: expected function signature `fn(String) -> _` + found function signature `for<'a> fn(&'a _) -> _` +note: required by a bound in `Option::<T>::and_then` + --> $SRC_DIR/core/src/option.rs:LL:COL +help: do not borrow the argument + | +LL - fn generic_ref<T>(_: &T) -> Option<()> { +LL + fn generic_ref<T>(_: T) -> Option<()> { + | + +error[E0631]: type mismatch in function arguments + --> $DIR/suggest-option-asderef-unfixable.rs:38:45 + | +LL | fn takes_str_but_too_many_refs(_: &&str) -> Option<()> { + | ------------------------------------------------------ found signature defined here +... +LL | let _ = Some(TypeWithoutDeref).and_then(takes_str_but_too_many_refs); + | -------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected due to this + | | + | required by a bound introduced by this call + | + = note: expected function signature `fn(TypeWithoutDeref) -> _` + found function signature `for<'a, 'b> fn(&'a &'b str) -> _` +note: required by a bound in `Option::<T>::and_then` + --> $SRC_DIR/core/src/option.rs:LL:COL + +error: aborting due to 6 previous errors + +Some errors have detailed explanations: E0277, E0593, E0631. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/mismatched_types/suggest-option-asderef.fixed b/tests/ui/mismatched_types/suggest-option-asderef.fixed new file mode 100644 index 00000000000..08805999341 --- /dev/null +++ b/tests/ui/mismatched_types/suggest-option-asderef.fixed @@ -0,0 +1,30 @@ +// run-rustfix + +fn produces_string() -> Option<String> { + Some("my cool string".to_owned()) +} + +fn takes_str(_: &str) -> Option<()> { + Some(()) +} + +fn takes_str_mut(_: &mut str) -> Option<()> { + Some(()) +} + +fn generic<T>(_: T) -> Option<()> { + Some(()) +} + +fn main() { + let _: Option<()> = produces_string().as_deref().and_then(takes_str); + //~^ ERROR type mismatch in function arguments + //~| HELP call `Option::as_deref()` first + let _: Option<Option<()>> = produces_string().as_deref().map(takes_str); + //~^ ERROR type mismatch in function arguments + //~| HELP call `Option::as_deref()` first + let _: Option<Option<()>> = produces_string().as_deref_mut().map(takes_str_mut); + //~^ ERROR type mismatch in function arguments + //~| HELP call `Option::as_deref_mut()` first + let _ = produces_string().and_then(generic); +} diff --git a/tests/ui/mismatched_types/suggest-option-asderef.rs b/tests/ui/mismatched_types/suggest-option-asderef.rs new file mode 100644 index 00000000000..3cfb2ffa828 --- /dev/null +++ b/tests/ui/mismatched_types/suggest-option-asderef.rs @@ -0,0 +1,30 @@ +// run-rustfix + +fn produces_string() -> Option<String> { + Some("my cool string".to_owned()) +} + +fn takes_str(_: &str) -> Option<()> { + Some(()) +} + +fn takes_str_mut(_: &mut str) -> Option<()> { + Some(()) +} + +fn generic<T>(_: T) -> Option<()> { + Some(()) +} + +fn main() { + let _: Option<()> = produces_string().and_then(takes_str); + //~^ ERROR type mismatch in function arguments + //~| HELP call `Option::as_deref()` first + let _: Option<Option<()>> = produces_string().map(takes_str); + //~^ ERROR type mismatch in function arguments + //~| HELP call `Option::as_deref()` first + let _: Option<Option<()>> = produces_string().map(takes_str_mut); + //~^ ERROR type mismatch in function arguments + //~| HELP call `Option::as_deref_mut()` first + let _ = produces_string().and_then(generic); +} diff --git a/tests/ui/mismatched_types/suggest-option-asderef.stderr b/tests/ui/mismatched_types/suggest-option-asderef.stderr new file mode 100644 index 00000000000..46da19d2bf4 --- /dev/null +++ b/tests/ui/mismatched_types/suggest-option-asderef.stderr @@ -0,0 +1,63 @@ +error[E0631]: type mismatch in function arguments + --> $DIR/suggest-option-asderef.rs:20:52 + | +LL | fn takes_str(_: &str) -> Option<()> { + | ----------------------------------- found signature defined here +... +LL | let _: Option<()> = produces_string().and_then(takes_str); + | -------- ^^^^^^^^^ expected due to this + | | + | required by a bound introduced by this call + | + = note: expected function signature `fn(String) -> _` + found function signature `for<'a> fn(&'a str) -> _` +note: required by a bound in `Option::<T>::and_then` + --> $SRC_DIR/core/src/option.rs:LL:COL +help: call `Option::as_deref()` first + | +LL | let _: Option<()> = produces_string().as_deref().and_then(takes_str); + | +++++++++++ + +error[E0631]: type mismatch in function arguments + --> $DIR/suggest-option-asderef.rs:23:55 + | +LL | fn takes_str(_: &str) -> Option<()> { + | ----------------------------------- found signature defined here +... +LL | let _: Option<Option<()>> = produces_string().map(takes_str); + | --- ^^^^^^^^^ expected due to this + | | + | required by a bound introduced by this call + | + = note: expected function signature `fn(String) -> _` + found function signature `for<'a> fn(&'a str) -> _` +note: required by a bound in `Option::<T>::map` + --> $SRC_DIR/core/src/option.rs:LL:COL +help: call `Option::as_deref()` first + | +LL | let _: Option<Option<()>> = produces_string().as_deref().map(takes_str); + | +++++++++++ + +error[E0631]: type mismatch in function arguments + --> $DIR/suggest-option-asderef.rs:26:55 + | +LL | fn takes_str_mut(_: &mut str) -> Option<()> { + | ------------------------------------------- found signature defined here +... +LL | let _: Option<Option<()>> = produces_string().map(takes_str_mut); + | --- ^^^^^^^^^^^^^ expected due to this + | | + | required by a bound introduced by this call + | + = note: expected function signature `fn(String) -> _` + found function signature `for<'a> fn(&'a mut str) -> _` +note: required by a bound in `Option::<T>::map` + --> $SRC_DIR/core/src/option.rs:LL:COL +help: call `Option::as_deref_mut()` first + | +LL | let _: Option<Option<()>> = produces_string().as_deref_mut().map(takes_str_mut); + | +++++++++++++++ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0631`. diff --git a/tests/ui/numbers-arithmetic/issue-8460-const.noopt.stderr b/tests/ui/numbers-arithmetic/issue-8460-const.noopt.stderr index c4abcb78411..2fba94d0740 100644 --- a/tests/ui/numbers-arithmetic/issue-8460-const.noopt.stderr +++ b/tests/ui/numbers-arithmetic/issue-8460-const.noopt.stderr @@ -76,37 +76,37 @@ error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:35:36 | LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^^^ attempt to compute the remainder of `isize::MIN % -1_isize`, which would overflow + | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN % -1_isize`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:37:36 | LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^ attempt to compute the remainder of `i8::MIN % -1_i8`, which would overflow + | ^^^^^^^^^^^^ attempt to compute `i8::MIN % -1_i8`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:39:36 | LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute the remainder of `i16::MIN % -1_i16`, which would overflow + | ^^^^^^^^^^^^^ attempt to compute `i16::MIN % -1_i16`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:41:36 | LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute the remainder of `i32::MIN % -1_i32`, which would overflow + | ^^^^^^^^^^^^^ attempt to compute `i32::MIN % -1_i32`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:43:36 | LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute the remainder of `i64::MIN % -1_i64`, which would overflow + | ^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:45:36 | LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^^ attempt to compute the remainder of `i128::MIN % -1_i128`, which would overflow + | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN % -1_i128`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:47:36 diff --git a/tests/ui/numbers-arithmetic/issue-8460-const.opt.stderr b/tests/ui/numbers-arithmetic/issue-8460-const.opt.stderr index c4abcb78411..2fba94d0740 100644 --- a/tests/ui/numbers-arithmetic/issue-8460-const.opt.stderr +++ b/tests/ui/numbers-arithmetic/issue-8460-const.opt.stderr @@ -76,37 +76,37 @@ error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:35:36 | LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^^^ attempt to compute the remainder of `isize::MIN % -1_isize`, which would overflow + | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN % -1_isize`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:37:36 | LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^ attempt to compute the remainder of `i8::MIN % -1_i8`, which would overflow + | ^^^^^^^^^^^^ attempt to compute `i8::MIN % -1_i8`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:39:36 | LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute the remainder of `i16::MIN % -1_i16`, which would overflow + | ^^^^^^^^^^^^^ attempt to compute `i16::MIN % -1_i16`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:41:36 | LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute the remainder of `i32::MIN % -1_i32`, which would overflow + | ^^^^^^^^^^^^^ attempt to compute `i32::MIN % -1_i32`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:43:36 | LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute the remainder of `i64::MIN % -1_i64`, which would overflow + | ^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:45:36 | LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^^ attempt to compute the remainder of `i128::MIN % -1_i128`, which would overflow + | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN % -1_i128`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:47:36 diff --git a/tests/ui/numbers-arithmetic/issue-8460-const.opt_with_overflow_checks.stderr b/tests/ui/numbers-arithmetic/issue-8460-const.opt_with_overflow_checks.stderr index c4abcb78411..2fba94d0740 100644 --- a/tests/ui/numbers-arithmetic/issue-8460-const.opt_with_overflow_checks.stderr +++ b/tests/ui/numbers-arithmetic/issue-8460-const.opt_with_overflow_checks.stderr @@ -76,37 +76,37 @@ error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:35:36 | LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^^^ attempt to compute the remainder of `isize::MIN % -1_isize`, which would overflow + | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN % -1_isize`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:37:36 | LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^ attempt to compute the remainder of `i8::MIN % -1_i8`, which would overflow + | ^^^^^^^^^^^^ attempt to compute `i8::MIN % -1_i8`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:39:36 | LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute the remainder of `i16::MIN % -1_i16`, which would overflow + | ^^^^^^^^^^^^^ attempt to compute `i16::MIN % -1_i16`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:41:36 | LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute the remainder of `i32::MIN % -1_i32`, which would overflow + | ^^^^^^^^^^^^^ attempt to compute `i32::MIN % -1_i32`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:43:36 | LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^ attempt to compute the remainder of `i64::MIN % -1_i64`, which would overflow + | ^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:45:36 | LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err()); - | ^^^^^^^^^^^^^^ attempt to compute the remainder of `i128::MIN % -1_i128`, which would overflow + | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN % -1_i128`, which would overflow error: this operation will panic at runtime --> $DIR/issue-8460-const.rs:47:36 diff --git a/tests/ui/offset-of/offset-of-dst-field.rs b/tests/ui/offset-of/offset-of-dst-field.rs index 3b8dc0b84a4..e393b159e64 100644 --- a/tests/ui/offset-of/offset-of-dst-field.rs +++ b/tests/ui/offset-of/offset-of-dst-field.rs @@ -36,6 +36,8 @@ fn main() { offset_of!(Alpha, z); //~ ERROR the size for values of type offset_of!(Beta, z); //~ ERROR the size for values of type offset_of!(Gamma, z); //~ ERROR the size for values of type + offset_of!((u8, dyn Trait), 0); // ok + offset_of!((u8, dyn Trait), 1); //~ ERROR the size for values of type } fn delta() { diff --git a/tests/ui/offset-of/offset-of-dst-field.stderr b/tests/ui/offset-of/offset-of-dst-field.stderr index 128c783d5dd..4eaceaa9358 100644 --- a/tests/ui/offset-of/offset-of-dst-field.stderr +++ b/tests/ui/offset-of/offset-of-dst-field.stderr @@ -25,8 +25,17 @@ LL | offset_of!(Gamma, z); = help: the trait `Sized` is not implemented for `Extern` = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) +error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time + --> $DIR/offset-of-dst-field.rs:40:5 + | +LL | offset_of!((u8, dyn Trait), 1); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `dyn Trait` + = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) + error[E0277]: the size for values of type `Extern` cannot be known at compilation time - --> $DIR/offset-of-dst-field.rs:43:5 + --> $DIR/offset-of-dst-field.rs:45:5 | LL | offset_of!(Delta<Extern>, z); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -35,7 +44,7 @@ LL | offset_of!(Delta<Extern>, z); = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time - --> $DIR/offset-of-dst-field.rs:44:5 + --> $DIR/offset-of-dst-field.rs:46:5 | LL | offset_of!(Delta<dyn Trait>, z); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -44,7 +53,7 @@ LL | offset_of!(Delta<dyn Trait>, z); = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/offset-of-dst-field.rs:42:5 + --> $DIR/offset-of-dst-field.rs:44:5 | LL | offset_of!(Delta<Alpha>, z); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -58,7 +67,7 @@ LL | struct Alpha { = note: this error originates in the macro `offset_of` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the size for values of type `T` cannot be known at compilation time - --> $DIR/offset-of-dst-field.rs:48:5 + --> $DIR/offset-of-dst-field.rs:50:5 | LL | fn generic_with_maybe_sized<T: ?Sized>() -> usize { | - this type parameter needs to be `std::marker::Sized` @@ -72,6 +81,6 @@ LL - fn generic_with_maybe_sized<T: ?Sized>() -> usize { LL + fn generic_with_maybe_sized<T>() -> usize { | -error: aborting due to 7 previous errors +error: aborting due to 8 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/offset-of/offset-of-tuple.rs b/tests/ui/offset-of/offset-of-tuple.rs new file mode 100644 index 00000000000..4077538b77f --- /dev/null +++ b/tests/ui/offset-of/offset-of-tuple.rs @@ -0,0 +1,10 @@ +#![feature(offset_of)] +#![feature(builtin_syntax)] + +fn main() { + core::mem::offset_of!((u8, u8), _0); //~ ERROR no field `_0` + core::mem::offset_of!((u8, u8), +1); //~ ERROR no rules expected + core::mem::offset_of!((u8, u8), -1); //~ ERROR no rules expected + builtin # offset_of((u8, u8), _0); //~ ERROR no field `_0` + builtin # offset_of((u8, u8), +1); //~ ERROR expected identifier +} diff --git a/tests/ui/offset-of/offset-of-tuple.stderr b/tests/ui/offset-of/offset-of-tuple.stderr new file mode 100644 index 00000000000..cc9ce0f3455 --- /dev/null +++ b/tests/ui/offset-of/offset-of-tuple.stderr @@ -0,0 +1,37 @@ +error: expected identifier, found `+` + --> $DIR/offset-of-tuple.rs:9:35 + | +LL | builtin # offset_of((u8, u8), +1); + | ^ expected identifier + +error: no rules expected the token `1` + --> $DIR/offset-of-tuple.rs:6:38 + | +LL | core::mem::offset_of!((u8, u8), +1); + | ^ no rules expected this token in macro call + | + = note: while trying to match sequence start + +error: no rules expected the token `1` + --> $DIR/offset-of-tuple.rs:7:38 + | +LL | core::mem::offset_of!((u8, u8), -1); + | ^ no rules expected this token in macro call + | + = note: while trying to match sequence start + +error[E0609]: no field `_0` on type `(u8, u8)` + --> $DIR/offset-of-tuple.rs:5:37 + | +LL | core::mem::offset_of!((u8, u8), _0); + | ^^ + +error[E0609]: no field `_0` on type `(u8, u8)` + --> $DIR/offset-of-tuple.rs:8:35 + | +LL | builtin # offset_of((u8, u8), _0); + | ^^ + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0609`. diff --git a/tests/ui/offset-of/offset-of-unsized.rs b/tests/ui/offset-of/offset-of-unsized.rs index 666387e615e..49c8328da5c 100644 --- a/tests/ui/offset-of/offset-of-unsized.rs +++ b/tests/ui/offset-of/offset-of-unsized.rs @@ -1,5 +1,6 @@ // build-pass -// regression test for #112051 +// regression test for #112051, not in `offset-of-dst` as the issue is in codegen, +// and isn't triggered in the presence of typeck errors #![feature(offset_of)] diff --git a/tests/ui/sanitize/issue-111184-generator-witness.rs b/tests/ui/sanitize/issue-111184-generator-witness.rs new file mode 100644 index 00000000000..8f4118057ce --- /dev/null +++ b/tests/ui/sanitize/issue-111184-generator-witness.rs @@ -0,0 +1,17 @@ +// Regression test for issue 111184, where ty::GeneratorWitness were not expected to occur in +// encode_ty and caused the compiler to ICE. +// +// needs-sanitizer-cfi +// compile-flags: -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi --edition=2021 +// no-prefer-dynamic +// only-x86_64-unknown-linux-gnu +// run-pass + +use std::future::Future; + +async fn foo() {} +fn bar<T>(_: impl Future<Output = T>) {} + +fn main() { + bar(foo()); +} diff --git a/tests/ui/statics/uninhabited-static.stderr b/tests/ui/statics/uninhabited-static.stderr index 35fdcae6a59..9260930473f 100644 --- a/tests/ui/statics/uninhabited-static.stderr +++ b/tests/ui/statics/uninhabited-static.stderr @@ -47,7 +47,7 @@ error[E0080]: could not evaluate static initializer --> $DIR/uninhabited-static.rs:12:31 | LL | static VOID2: Void = unsafe { std::mem::transmute(()) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of uninhabited type Void + | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of uninhabited type `Void` warning: the type `Void` does not permit zero-initialization --> $DIR/uninhabited-static.rs:12:31 @@ -66,7 +66,7 @@ error[E0080]: could not evaluate static initializer --> $DIR/uninhabited-static.rs:16:32 | LL | static NEVER2: Void = unsafe { std::mem::transmute(()) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of uninhabited type Void + | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of uninhabited type `Void` warning: the type `Void` does not permit zero-initialization --> $DIR/uninhabited-static.rs:16:32 diff --git a/tests/ui/symbol-names/const-generics-structural-demangling.rs b/tests/ui/symbol-names/const-generics-structural-demangling.rs index df09ba494a7..947fddf3f31 100644 --- a/tests/ui/symbol-names/const-generics-structural-demangling.rs +++ b/tests/ui/symbol-names/const-generics-structural-demangling.rs @@ -1,14 +1,13 @@ // build-fail // compile-flags: -C symbol-mangling-version=v0 --crate-name=c -// NOTE(eddyb) we need `core` for `core::option::Option`, normalize away its -// disambiguator hash, which can/should change (including between stage{1,2}). -// normalize-stderr-test: "core\[[0-9a-f]+\]" -> "core[HASH]" // normalize-stderr-test: "c\[[0-9a-f]+\]" -> "c[HASH]" #![feature(adt_const_params, decl_macro, rustc_attrs)] #![allow(incomplete_features)] +use std::marker::ConstParamTy; + pub struct RefByte<const RB: &'static u8>; #[rustc_symbol_name] @@ -43,25 +42,31 @@ pub struct TupleByteBool<const TBB: (u8, bool)>; //~| ERROR demangling-alt(<c::TupleByteBool<{(1, false)}>>) impl TupleByteBool<{(1, false)}> {} -pub struct OptionUsize<const OU: Option<usize>>; +#[derive(PartialEq, Eq, ConstParamTy)] +pub enum MyOption<T> { + Some(T), + None, +} + +pub struct OptionUsize<const OU: MyOption<usize>>; // HACK(eddyb) the full mangling is only in `.stderr` because we can normalize // the `core` disambiguator hash away there, but not here. #[rustc_symbol_name] //~^ ERROR symbol-name //~| ERROR demangling -//~| ERROR demangling-alt(<c::OptionUsize<{core::option::Option::<usize>::None}>>) -impl OptionUsize<{None}> {} +//~| ERROR demangling-alt(<c::OptionUsize<{c::MyOption::<usize>::None}>>) +impl OptionUsize<{MyOption::None}> {} // HACK(eddyb) the full mangling is only in `.stderr` because we can normalize // the `core` disambiguator hash away there, but not here. #[rustc_symbol_name] //~^ ERROR symbol-name //~| ERROR demangling -//~| ERROR demangling-alt(<c::OptionUsize<{core::option::Option::<usize>::Some(0)}>>) -impl OptionUsize<{Some(0)}> {} +//~| ERROR demangling-alt(<c::OptionUsize<{c::MyOption::<usize>::Some(0)}>>) +impl OptionUsize<{MyOption::Some(0)}> {} -#[derive(PartialEq, Eq)] +#[derive(PartialEq, Eq, ConstParamTy)] pub struct Foo { s: &'static str, ch: char, @@ -78,7 +83,7 @@ impl Foo_<{Foo { s: "abc", ch: 'x', slice: &[1, 2, 3] }}> {} // NOTE(eddyb) this tests specifically the use of disambiguators in field names, // using macros 2.0 hygiene to create a `struct` with conflicting field names. macro duplicate_field_name_test($x:ident) { - #[derive(PartialEq, Eq)] + #[derive(PartialEq, Eq, ConstParamTy)] pub struct Bar { $x: u8, x: u16, diff --git a/tests/ui/symbol-names/const-generics-structural-demangling.stderr b/tests/ui/symbol-names/const-generics-structural-demangling.stderr index a4c997477ee..96dea154d05 100644 --- a/tests/ui/symbol-names/const-generics-structural-demangling.stderr +++ b/tests/ui/symbol-names/const-generics-structural-demangling.stderr @@ -1,131 +1,131 @@ error: symbol-name(_RMCsCRATE_HASH_1cINtB<REF>_7RefByteKRh7b_E) - --> $DIR/const-generics-structural-demangling.rs:14:1 + --> $DIR/const-generics-structural-demangling.rs:13:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: demangling(<c[HASH]::RefByte<{&123u8}>>) - --> $DIR/const-generics-structural-demangling.rs:14:1 + --> $DIR/const-generics-structural-demangling.rs:13:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: demangling-alt(<c::RefByte<{&123}>>) - --> $DIR/const-generics-structural-demangling.rs:14:1 + --> $DIR/const-generics-structural-demangling.rs:13:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: symbol-name(_RMs_CsCRATE_HASH_1cINtB<REF>_6RefZstKRAEE) - --> $DIR/const-generics-structural-demangling.rs:24:1 + --> $DIR/const-generics-structural-demangling.rs:23:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: demangling(<c[HASH]::RefZst<{&[]}>>) - --> $DIR/const-generics-structural-demangling.rs:24:1 + --> $DIR/const-generics-structural-demangling.rs:23:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: demangling-alt(<c::RefZst<{&[]}>>) - --> $DIR/const-generics-structural-demangling.rs:24:1 + --> $DIR/const-generics-structural-demangling.rs:23:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: symbol-name(_RMs0_CsCRATE_HASH_1cINtB<REF>_11Array3BytesKAh1_h2_h3_EE) - --> $DIR/const-generics-structural-demangling.rs:32:1 + --> $DIR/const-generics-structural-demangling.rs:31:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: demangling(<c[HASH]::Array3Bytes<{[1u8, 2u8, 3u8]}>>) - --> $DIR/const-generics-structural-demangling.rs:32:1 + --> $DIR/const-generics-structural-demangling.rs:31:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: demangling-alt(<c::Array3Bytes<{[1, 2, 3]}>>) - --> $DIR/const-generics-structural-demangling.rs:32:1 + --> $DIR/const-generics-structural-demangling.rs:31:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: symbol-name(_RMs1_CsCRATE_HASH_1cINtB<REF>_13TupleByteBoolKTh1_b0_EE) - --> $DIR/const-generics-structural-demangling.rs:40:1 + --> $DIR/const-generics-structural-demangling.rs:39:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: demangling(<c[HASH]::TupleByteBool<{(1u8, false)}>>) - --> $DIR/const-generics-structural-demangling.rs:40:1 + --> $DIR/const-generics-structural-demangling.rs:39:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: demangling-alt(<c::TupleByteBool<{(1, false)}>>) - --> $DIR/const-generics-structural-demangling.rs:40:1 + --> $DIR/const-generics-structural-demangling.rs:39:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: symbol-name(_RMs2_CsCRATE_HASH_1cINtB<REF>_11OptionUsizeKVNtINtNtCsCRATE_HASH_4core6option6OptionjE4NoneUE) - --> $DIR/const-generics-structural-demangling.rs:50:1 +error: symbol-name(_RMs2_CsCRATE_HASH_1cINtB<REF>_11OptionUsizeKVNtINtB<REF>_8MyOptionjE4NoneUE) + --> $DIR/const-generics-structural-demangling.rs:55:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling(<c[HASH]::OptionUsize<{core[HASH]::option::Option::<usize>::None}>>) - --> $DIR/const-generics-structural-demangling.rs:50:1 +error: demangling(<c[HASH]::OptionUsize<{c[HASH]::MyOption::<usize>::None}>>) + --> $DIR/const-generics-structural-demangling.rs:55:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling-alt(<c::OptionUsize<{core::option::Option::<usize>::None}>>) - --> $DIR/const-generics-structural-demangling.rs:50:1 +error: demangling-alt(<c::OptionUsize<{c::MyOption::<usize>::None}>>) + --> $DIR/const-generics-structural-demangling.rs:55:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: symbol-name(_RMs3_CsCRATE_HASH_1cINtB<REF>_11OptionUsizeKVNtINtNtCsCRATE_HASH_4core6option6OptionjE4SomeTj0_EE) - --> $DIR/const-generics-structural-demangling.rs:58:1 +error: symbol-name(_RMs3_CsCRATE_HASH_1cINtB<REF>_11OptionUsizeKVNtINtB<REF>_8MyOptionjE4SomeTj0_EE) + --> $DIR/const-generics-structural-demangling.rs:63:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling(<c[HASH]::OptionUsize<{core[HASH]::option::Option::<usize>::Some(0usize)}>>) - --> $DIR/const-generics-structural-demangling.rs:58:1 +error: demangling(<c[HASH]::OptionUsize<{c[HASH]::MyOption::<usize>::Some(0usize)}>>) + --> $DIR/const-generics-structural-demangling.rs:63:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling-alt(<c::OptionUsize<{core::option::Option::<usize>::Some(0)}>>) - --> $DIR/const-generics-structural-demangling.rs:58:1 +error: demangling-alt(<c::OptionUsize<{c::MyOption::<usize>::Some(0)}>>) + --> $DIR/const-generics-structural-demangling.rs:63:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: symbol-name(_RMs4_CsCRATE_HASH_1cINtB<REF>_4Foo_KVNtB<REF>_3FooS1sRe616263_2chc78_5sliceRAh1_h2_h3_EEE) - --> $DIR/const-generics-structural-demangling.rs:72:1 + --> $DIR/const-generics-structural-demangling.rs:77:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: demangling(<c[HASH]::Foo_<{c[HASH]::Foo { s: "abc", ch: 'x', slice: &[1u8, 2u8, 3u8] }}>>) - --> $DIR/const-generics-structural-demangling.rs:72:1 + --> $DIR/const-generics-structural-demangling.rs:77:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ error: demangling-alt(<c::Foo_<{c::Foo { s: "abc", ch: 'x', slice: &[1, 2, 3] }}>>) - --> $DIR/const-generics-structural-demangling.rs:72:1 + --> $DIR/const-generics-structural-demangling.rs:77:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: symbol-name(_RMs9_CsCRATE_HASH_1cINtB<REF>_4Bar_KVNtB<REF>_3BarS1xh7b_s_1xt1000_EE) - --> $DIR/const-generics-structural-demangling.rs:88:5 +error: symbol-name(_RMsf_CsCRATE_HASH_1cINtB<REF>_4Bar_KVNtB<REF>_3BarS1xh7b_s_1xt1000_EE) + --> $DIR/const-generics-structural-demangling.rs:93:5 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ @@ -136,7 +136,7 @@ LL | duplicate_field_name_test!(x); = note: this error originates in the macro `duplicate_field_name_test` (in Nightly builds, run with -Z macro-backtrace for more info) error: demangling(<c[HASH]::Bar_<{c[HASH]::Bar { x: 123u8, x: 4096u16 }}>>) - --> $DIR/const-generics-structural-demangling.rs:88:5 + --> $DIR/const-generics-structural-demangling.rs:93:5 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ @@ -147,7 +147,7 @@ LL | duplicate_field_name_test!(x); = note: this error originates in the macro `duplicate_field_name_test` (in Nightly builds, run with -Z macro-backtrace for more info) error: demangling-alt(<c::Bar_<{c::Bar { x: 123, x: 4096 }}>>) - --> $DIR/const-generics-structural-demangling.rs:88:5 + --> $DIR/const-generics-structural-demangling.rs:93:5 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/traits/new-solver/array-default.rs b/tests/ui/traits/new-solver/array-default.rs new file mode 100644 index 00000000000..5077137b09b --- /dev/null +++ b/tests/ui/traits/new-solver/array-default.rs @@ -0,0 +1,8 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +fn has_default<const N: usize>() where [(); N]: Default {} + +fn main() { + has_default::<1>(); +} diff --git a/tests/ui/traits/new-solver/structural-resolve-field.rs b/tests/ui/traits/new-solver/structural-resolve-field.rs index c492d927696..01899c9ad64 100644 --- a/tests/ui/traits/new-solver/structural-resolve-field.rs +++ b/tests/ui/traits/new-solver/structural-resolve-field.rs @@ -1,35 +1,13 @@ // compile-flags: -Ztrait-solver=next // check-pass +#[derive(Default)] struct Foo { x: i32, } -impl MyDefault for Foo { - fn my_default() -> Self { - Self { - x: 0, - } - } -} - -trait MyDefault { - fn my_default() -> Self; -} - -impl MyDefault for [Foo; 0] { - fn my_default() -> Self { - [] - } -} -impl MyDefault for [Foo; 1] { - fn my_default() -> Self { - [Foo::my_default(); 1] - } -} - fn main() { - let mut xs = <[Foo; 1]>::my_default(); + let mut xs = <[Foo; 1]>::default(); xs[0].x = 1; (&mut xs[0]).x = 2; } diff --git a/tests/ui/traits/new-solver/unevaluated-const-impl-trait-ref.fails.stderr b/tests/ui/traits/new-solver/unevaluated-const-impl-trait-ref.fails.stderr new file mode 100644 index 00000000000..072ac32a5de --- /dev/null +++ b/tests/ui/traits/new-solver/unevaluated-const-impl-trait-ref.fails.stderr @@ -0,0 +1,18 @@ +error[E0277]: the trait bound `(): Trait<1>` is not satisfied + --> $DIR/unevaluated-const-impl-trait-ref.rs:20:13 + | +LL | needs::<1>(); + | ^ the trait `Trait<1>` is not implemented for `()` + | + = help: the following other types implement trait `Trait<N>`: + <() as Trait<0>> + <() as Trait<2>> +note: required by a bound in `needs` + --> $DIR/unevaluated-const-impl-trait-ref.rs:10:38 + | +LL | fn needs<const N: usize>() where (): Trait<N> {} + | ^^^^^^^^ required by this bound in `needs` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/new-solver/unevaluated-const-impl-trait-ref.rs b/tests/ui/traits/new-solver/unevaluated-const-impl-trait-ref.rs new file mode 100644 index 00000000000..26c595bc974 --- /dev/null +++ b/tests/ui/traits/new-solver/unevaluated-const-impl-trait-ref.rs @@ -0,0 +1,22 @@ +// compile-flags: -Ztrait-solver=next +// revisions: works fails +//[works] check-pass + +trait Trait<const N: usize> {} + +impl Trait<{ 1 - 1 }> for () {} +impl Trait<{ 1 + 1 }> for () {} + +fn needs<const N: usize>() where (): Trait<N> {} + +#[cfg(works)] +fn main() { + needs::<0>(); + needs::<2>(); +} + +#[cfg(fails)] +fn main() { + needs::<1>(); + //[fails]~^ ERROR the trait bound `(): Trait<1>` is not satisfied +} diff --git a/tests/ui/typeck/derive-sugg-arg-arity.rs b/tests/ui/typeck/derive-sugg-arg-arity.rs new file mode 100644 index 00000000000..094c93a8535 --- /dev/null +++ b/tests/ui/typeck/derive-sugg-arg-arity.rs @@ -0,0 +1,8 @@ +pub struct A; + +fn main() { + match () { + _ => match A::partial_cmp() {}, + //~^ ERROR the function or associated item `partial_cmp` exists for struct `A`, but its trait bounds were not satisfied + } +} diff --git a/tests/ui/typeck/derive-sugg-arg-arity.stderr b/tests/ui/typeck/derive-sugg-arg-arity.stderr new file mode 100644 index 00000000000..5b4c4817198 --- /dev/null +++ b/tests/ui/typeck/derive-sugg-arg-arity.stderr @@ -0,0 +1,31 @@ +error[E0599]: the function or associated item `partial_cmp` exists for struct `A`, but its trait bounds were not satisfied + --> $DIR/derive-sugg-arg-arity.rs:5:23 + | +LL | pub struct A; + | ------------ + | | + | function or associated item `partial_cmp` not found for this struct + | doesn't satisfy `A: Iterator` + | doesn't satisfy `A: PartialOrd<_>` +... +LL | _ => match A::partial_cmp() {}, + | ^^^^^^^^^^^ function or associated item cannot be called on `A` due to unsatisfied trait bounds + | + = note: the following trait bounds were not satisfied: + `A: PartialOrd<_>` + which is required by `&A: PartialOrd<&_>` + `A: PartialOrd<_>` + which is required by `&mut A: PartialOrd<&mut _>` + `A: Iterator` + which is required by `&mut A: Iterator` +note: the trait `Iterator` must be implemented + --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL +help: consider annotating `A` with `#[derive(PartialEq, PartialOrd)]` + | +LL + #[derive(PartialEq, PartialOrd)] +LL | pub struct A; + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/typeck/return-dyn-type-mismatch-2.rs b/tests/ui/typeck/return-dyn-type-mismatch-2.rs new file mode 100644 index 00000000000..328f154dcbc --- /dev/null +++ b/tests/ui/typeck/return-dyn-type-mismatch-2.rs @@ -0,0 +1,11 @@ +trait Trait<T> {} + +fn foo<T>() -> dyn Trait<T> +where + dyn Trait<T>: Sized, // pesky sized predicate +{ + 42 + //~^ ERROR mismatched types +} + +fn main() {} diff --git a/tests/ui/typeck/return-dyn-type-mismatch-2.stderr b/tests/ui/typeck/return-dyn-type-mismatch-2.stderr new file mode 100644 index 00000000000..9c368e83834 --- /dev/null +++ b/tests/ui/typeck/return-dyn-type-mismatch-2.stderr @@ -0,0 +1,15 @@ +error[E0308]: mismatched types + --> $DIR/return-dyn-type-mismatch-2.rs:7:5 + | +LL | fn foo<T>() -> dyn Trait<T> + | ------------ expected `(dyn Trait<T> + 'static)` because of return type +... +LL | 42 + | ^^ expected `dyn Trait`, found integer + | + = note: expected trait object `(dyn Trait<T> + 'static)` + found type `{integer}` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/typeck/return-dyn-type-mismatch.rs b/tests/ui/typeck/return-dyn-type-mismatch.rs new file mode 100644 index 00000000000..93718f70f41 --- /dev/null +++ b/tests/ui/typeck/return-dyn-type-mismatch.rs @@ -0,0 +1,21 @@ +pub trait TestTrait { + type MyType; + + fn func() -> Option<Self> + where + Self: Sized; +} + +impl<T> dyn TestTrait<MyType = T> +where + Self: Sized, // pesky sized predicate +{ + fn other_func() -> dyn TestTrait<MyType = T> { + match Self::func() { + None => None, + //~^ ERROR mismatched types + } + } +} + +fn main() {} diff --git a/tests/ui/typeck/return-dyn-type-mismatch.stderr b/tests/ui/typeck/return-dyn-type-mismatch.stderr new file mode 100644 index 00000000000..9d0a609d87f --- /dev/null +++ b/tests/ui/typeck/return-dyn-type-mismatch.stderr @@ -0,0 +1,15 @@ +error[E0308]: mismatched types + --> $DIR/return-dyn-type-mismatch.rs:15:21 + | +LL | fn other_func() -> dyn TestTrait<MyType = T> { + | ------------------------- expected `(dyn TestTrait<MyType = T> + 'static)` because of return type +LL | match Self::func() { +LL | None => None, + | ^^^^ expected `dyn TestTrait`, found `Option<_>` + | + = note: expected trait object `(dyn TestTrait<MyType = T> + 'static)` + found enum `Option<_>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. |
