diff options
Diffstat (limited to 'src/test')
466 files changed, 11725 insertions, 4653 deletions
diff --git a/src/test/codegen-units/partitioning/compiler-builtins.rs b/src/test/codegen-units/partitioning/compiler-builtins.rs new file mode 100644 index 00000000000..25195743b04 --- /dev/null +++ b/src/test/codegen-units/partitioning/compiler-builtins.rs @@ -0,0 +1,40 @@ +// Verifies that during compiler_builtins compilation the codegen units are kept +// unmerged. Even when only a single codegen unit is requested with -Ccodegen-units=1. +// +// compile-flags: -Zprint-mono-items=eager -Ccodegen-units=1 + +#![compiler_builtins] +#![crate_type="lib"] +#![feature(compiler_builtins)] + +mod atomics { + //~ MONO_ITEM fn compiler_builtins::atomics[0]::sync_1[0] @@ compiler_builtins-cgu.0[External] + #[no_mangle] + pub extern "C" fn sync_1() {} + + //~ MONO_ITEM fn compiler_builtins::atomics[0]::sync_2[0] @@ compiler_builtins-cgu.0[External] + #[no_mangle] + pub extern "C" fn sync_2() {} + + //~ MONO_ITEM fn compiler_builtins::atomics[0]::sync_3[0] @@ compiler_builtins-cgu.0[External] + #[no_mangle] + pub extern "C" fn sync_3() {} +} + +mod x { + //~ MONO_ITEM fn compiler_builtins::x[0]::x[0] @@ compiler_builtins-cgu.1[External] + #[no_mangle] + pub extern "C" fn x() {} +} + +mod y { + //~ MONO_ITEM fn compiler_builtins::y[0]::y[0] @@ compiler_builtins-cgu.2[External] + #[no_mangle] + pub extern "C" fn y() {} +} + +mod z { + //~ MONO_ITEM fn compiler_builtins::z[0]::z[0] @@ compiler_builtins-cgu.3[External] + #[no_mangle] + pub extern "C" fn z() {} +} diff --git a/src/test/mir-opt/README.md b/src/test/mir-opt/README.md index a6f86d4e384..a0550466cf0 100644 --- a/src/test/mir-opt/README.md +++ b/src/test/mir-opt/README.md @@ -1,9 +1,7 @@ This folder contains tests for MIR optimizations. -There are two test formats. One allows specifying a pattern to look for in the MIR, which also -permits leaving placeholders, but requires you to manually change the pattern if anything changes. -The other emits MIR to extra files that you can automatically update by specifying `--bless` on -the command line (just like `ui` tests updating `.stderr` files). +The `mir-opt` test format emits MIR to extra files that you can automatically update by specifying +`--bless` on the command line (just like `ui` tests updating `.stderr` files). # `--bless`able test format @@ -39,79 +37,3 @@ This exists mainly for completeness and is rarely useful. ``` // EMIT_MIR $file_name_of_some_mir_dump.before.mir ``` - -# Inline test format - -``` -(arbitrary rust code) -// END RUST SOURCE -// START $file_name_of_some_mir_dump_0 -// $expected_line_0 -// (lines or elision) -// $expected_line_N -// END $file_name_of_some_mir_dump_0 -// (lines or elision) -// START $file_name_of_some_mir_dump_N -// $expected_line_0 -// (lines or elision) -// $expected_line_N -// END $file_name_of_some_mir_dump_N -``` - -All the test information is in comments so the test is runnable. - -For each $file_name, compiletest expects [$expected_line_0, ..., -$expected_line_N] to appear in the dumped MIR in order. Currently it allows -other non-matched lines before and after, but not between $expected_lines, -should you want to skip lines, you must include an elision comment, of the form -(as a regex) `//\s*...\s*`. The lines will be skipped lazily, that is, if there -are two identical lines in the output that match the line after the elision -comment, the first one will be matched. - -Examples: - -The following blocks will not match the one after it. - -``` -bb0: { - StorageLive(_1); - _1 = const true; - StorageDead(_1); -} -``` - -``` -bb0: { - StorageLive(_1); - _1 = const true; - goto -> bb1 -} -bb1: { - StorageDead(_1); - return; -} -``` - -But this will match the one above, - -``` -bb0: { - StorageLive(_1); - _1 = const true; - ... - StorageDead(_1); - ... -} -``` - -Lines match ignoring whitespace, and the prefix "//" is removed. - -It also currently strips trailing comments -- partly because the full file path -in "scope comments" is unpredictable and partly because tidy complains about -the lines being too long. - -compiletest handles dumping the MIR before and after every pass for you. The -test writer only has to specify the file names of the dumped files (not the -full path to the file) and what lines to expect. There is an option to rustc -that tells it to dump the mir into some directly (rather then always dumping to -the current directory). diff --git a/src/test/mir-opt/address-of.rs b/src/test/mir-opt/address-of.rs index bbd1ca68a86..6cd14ccf434 100644 --- a/src/test/mir-opt/address-of.rs +++ b/src/test/mir-opt/address-of.rs @@ -1,3 +1,5 @@ +// EMIT_MIR rustc.address_of_reborrow.SimplifyCfg-initial.after.mir + fn address_of_reborrow() { let y = &[0; 10]; let mut z = &mut [0; 10]; @@ -35,6 +37,7 @@ fn address_of_reborrow() { } // The normal borrows here should be preserved +// EMIT_MIR rustc.borrow_and_cast.SimplifyCfg-initial.after.mir fn borrow_and_cast(mut x: i32) { let p = &x as *const i32; let q = &mut x as *const i32; @@ -42,71 +45,3 @@ fn borrow_and_cast(mut x: i32) { } fn main() {} - -// START rustc.address_of_reborrow.SimplifyCfg-initial.after.mir -// bb0: { -// ... -// _5 = &raw const (*_1); // & to *const casts -// ... -// _7 = &raw const (*_1); -// ... -// _11 = &raw const (*_1); -// ... -// _14 = &raw const (*_1); -// ... -// _16 = &raw const (*_1); -// ... -// _17 = &raw const (*_1); // & to *const coercions -// ... -// _18 = &raw const (*_1); -// ... -// _20 = &raw const (*_1); -// ... -// _22 = &raw const (*_1); -// ... -// _24 = &raw const (*_2); // &mut to *const casts -// ... -// _26 = &raw const (*_2); -// ... -// _30 = &raw const (*_2); -// ... -// _33 = &raw const (*_2); -// ... -// _34 = &raw const (*_2); // &mut to *const coercions -// ... -// _35 = &raw const (*_2); -// ... -// _37 = &raw const (*_2); -// ... -// _39 = &raw const (*_2); -// ... -// _41 = &raw mut (*_2); // &mut to *mut casts -// ... -// _43 = &raw mut (*_2); -// ... -// _47 = &raw mut (*_2); -// ... -// _50 = &raw mut (*_2); -// ... -// _51 = &raw mut (*_2); // &mut to *mut coercions -// ... -// _52 = &raw mut (*_2); -// ... -// _54 = &raw mut (*_2); -// ... -// _56 = &raw mut (*_2); -// ... -// } -// END rustc.address_of_reborrow.SimplifyCfg-initial.after.mir - -// START rustc.borrow_and_cast.EraseRegions.after.mir -// bb0: { -// ... -// _4 = &_1; -// ... -// _7 = &mut _1; -// ... -// _10 = &mut _1; -// ... -// } -// END rustc.borrow_and_cast.EraseRegions.after.mir diff --git a/src/test/mir-opt/address-of/rustc.address_of_reborrow.SimplifyCfg-initial.after.mir b/src/test/mir-opt/address-of/rustc.address_of_reborrow.SimplifyCfg-initial.after.mir new file mode 100644 index 00000000000..af07da4cfe0 --- /dev/null +++ b/src/test/mir-opt/address-of/rustc.address_of_reborrow.SimplifyCfg-initial.after.mir @@ -0,0 +1,320 @@ +// MIR for `address_of_reborrow` after SimplifyCfg-initial + +| User Type Annotations +| 0: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) } at $DIR/address-of.rs:7:5: 7:18 +| 1: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) } at $DIR/address-of.rs:9:5: 9:25 +| 2: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) } at $DIR/address-of.rs:13:12: 13:20 +| 3: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) } at $DIR/address-of.rs:13:12: 13:20 +| 4: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32; 10]) } at $DIR/address-of.rs:14:12: 14:28 +| 5: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32; 10]) } at $DIR/address-of.rs:14:12: 14:28 +| 6: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) } at $DIR/address-of.rs:15:12: 15:27 +| 7: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) } at $DIR/address-of.rs:15:12: 15:27 +| 8: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32]) } at $DIR/address-of.rs:16:12: 16:24 +| 9: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32]) } at $DIR/address-of.rs:16:12: 16:24 +| 10: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) } at $DIR/address-of.rs:18:5: 18:18 +| 11: Canonical { max_universe: U3, variables: [CanonicalVarInfo { kind: Region(U3) }], value: Ty(*const dyn std::marker::Send) } at $DIR/address-of.rs:20:5: 20:25 +| 12: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) } at $DIR/address-of.rs:23:12: 23:20 +| 13: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*const ^0) } at $DIR/address-of.rs:23:12: 23:20 +| 14: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32; 10]) } at $DIR/address-of.rs:24:12: 24:28 +| 15: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32; 10]) } at $DIR/address-of.rs:24:12: 24:28 +| 16: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) } at $DIR/address-of.rs:25:12: 25:27 +| 17: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*const dyn std::marker::Send) } at $DIR/address-of.rs:25:12: 25:27 +| 18: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32]) } at $DIR/address-of.rs:26:12: 26:24 +| 19: Canonical { max_universe: U0, variables: [], value: Ty(*const [i32]) } at $DIR/address-of.rs:26:12: 26:24 +| 20: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*mut ^0) } at $DIR/address-of.rs:28:5: 28:16 +| 21: Canonical { max_universe: U6, variables: [CanonicalVarInfo { kind: Region(U6) }], value: Ty(*mut dyn std::marker::Send) } at $DIR/address-of.rs:30:5: 30:23 +| 22: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*mut ^0) } at $DIR/address-of.rs:33:12: 33:18 +| 23: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }], value: Ty(*mut ^0) } at $DIR/address-of.rs:33:12: 33:18 +| 24: Canonical { max_universe: U0, variables: [], value: Ty(*mut [i32; 10]) } at $DIR/address-of.rs:34:12: 34:26 +| 25: Canonical { max_universe: U0, variables: [], value: Ty(*mut [i32; 10]) } at $DIR/address-of.rs:34:12: 34:26 +| 26: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*mut dyn std::marker::Send) } at $DIR/address-of.rs:35:12: 35:25 +| 27: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }], value: Ty(*mut dyn std::marker::Send) } at $DIR/address-of.rs:35:12: 35:25 +| 28: Canonical { max_universe: U0, variables: [], value: Ty(*mut [i32]) } at $DIR/address-of.rs:36:12: 36:22 +| 29: Canonical { max_universe: U0, variables: [], value: Ty(*mut [i32]) } at $DIR/address-of.rs:36:12: 36:22 +| +fn address_of_reborrow() -> () { + let mut _0: (); // return place in scope 0 at $DIR/address-of.rs:3:26: 3:26 + let _1: &[i32; 10]; // in scope 0 at $DIR/address-of.rs:4:9: 4:10 + let _2: [i32; 10]; // in scope 0 at $DIR/address-of.rs:4:14: 4:21 + let mut _4: [i32; 10]; // in scope 0 at $DIR/address-of.rs:5:22: 5:29 + let _5: *const [i32; 10]; // in scope 0 at $DIR/address-of.rs:7:5: 7:18 + let mut _6: *const [i32; 10]; // in scope 0 at $DIR/address-of.rs:7:5: 7:18 + let _7: *const [i32; 10]; // in scope 0 at $DIR/address-of.rs:8:5: 8:26 + let _8: *const dyn std::marker::Send; // in scope 0 at $DIR/address-of.rs:9:5: 9:25 + let mut _9: *const dyn std::marker::Send; // in scope 0 at $DIR/address-of.rs:9:5: 9:25 + let mut _10: *const [i32; 10]; // in scope 0 at $DIR/address-of.rs:9:5: 9:6 + let _11: *const [i32]; // in scope 0 at $DIR/address-of.rs:10:5: 10:22 + let mut _12: *const [i32; 10]; // in scope 0 at $DIR/address-of.rs:10:5: 10:6 + let _13: *const i32; // in scope 0 at $DIR/address-of.rs:11:5: 11:20 + let mut _14: *const [i32; 10]; // in scope 0 at $DIR/address-of.rs:11:5: 11:6 + let mut _18: *const [i32; 10]; // in scope 0 at $DIR/address-of.rs:15:30: 15:31 + let mut _20: *const [i32; 10]; // in scope 0 at $DIR/address-of.rs:16:27: 16:28 + let _21: *const [i32; 10]; // in scope 0 at $DIR/address-of.rs:18:5: 18:18 + let mut _22: *const [i32; 10]; // in scope 0 at $DIR/address-of.rs:18:5: 18:18 + let _23: *const [i32; 10]; // in scope 0 at $DIR/address-of.rs:19:5: 19:26 + let _24: *const dyn std::marker::Send; // in scope 0 at $DIR/address-of.rs:20:5: 20:25 + let mut _25: *const dyn std::marker::Send; // in scope 0 at $DIR/address-of.rs:20:5: 20:25 + let mut _26: *const [i32; 10]; // in scope 0 at $DIR/address-of.rs:20:5: 20:6 + let _27: *const [i32]; // in scope 0 at $DIR/address-of.rs:21:5: 21:22 + let mut _28: *const [i32; 10]; // in scope 0 at $DIR/address-of.rs:21:5: 21:6 + let mut _32: *const [i32; 10]; // in scope 0 at $DIR/address-of.rs:25:30: 25:31 + let mut _34: *const [i32; 10]; // in scope 0 at $DIR/address-of.rs:26:27: 26:28 + let _35: *mut [i32; 10]; // in scope 0 at $DIR/address-of.rs:28:5: 28:16 + let mut _36: *mut [i32; 10]; // in scope 0 at $DIR/address-of.rs:28:5: 28:16 + let _37: *mut [i32; 10]; // in scope 0 at $DIR/address-of.rs:29:5: 29:24 + let _38: *mut dyn std::marker::Send; // in scope 0 at $DIR/address-of.rs:30:5: 30:23 + let mut _39: *mut dyn std::marker::Send; // in scope 0 at $DIR/address-of.rs:30:5: 30:23 + let mut _40: *mut [i32; 10]; // in scope 0 at $DIR/address-of.rs:30:5: 30:6 + let _41: *mut [i32]; // in scope 0 at $DIR/address-of.rs:31:5: 31:20 + let mut _42: *mut [i32; 10]; // in scope 0 at $DIR/address-of.rs:31:5: 31:6 + let mut _46: *mut [i32; 10]; // in scope 0 at $DIR/address-of.rs:35:28: 35:29 + let mut _48: *mut [i32; 10]; // in scope 0 at $DIR/address-of.rs:36:25: 36:26 + scope 1 { + debug y => _1; // in scope 1 at $DIR/address-of.rs:4:9: 4:10 + let mut _3: &mut [i32; 10]; // in scope 1 at $DIR/address-of.rs:5:9: 5:14 + scope 2 { + debug z => _3; // in scope 2 at $DIR/address-of.rs:5:9: 5:14 + let _15: *const [i32; 10] as UserTypeProjection { base: UserType(2), projs: [] }; // in scope 2 at $DIR/address-of.rs:13:9: 13:10 + scope 3 { + debug p => _15; // in scope 3 at $DIR/address-of.rs:13:9: 13:10 + let _16: *const [i32; 10] as UserTypeProjection { base: UserType(4), projs: [] }; // in scope 3 at $DIR/address-of.rs:14:9: 14:10 + scope 4 { + debug p => _16; // in scope 4 at $DIR/address-of.rs:14:9: 14:10 + let _17: *const dyn std::marker::Send as UserTypeProjection { base: UserType(6), projs: [] }; // in scope 4 at $DIR/address-of.rs:15:9: 15:10 + scope 5 { + debug p => _17; // in scope 5 at $DIR/address-of.rs:15:9: 15:10 + let _19: *const [i32] as UserTypeProjection { base: UserType(8), projs: [] }; // in scope 5 at $DIR/address-of.rs:16:9: 16:10 + scope 6 { + debug p => _19; // in scope 6 at $DIR/address-of.rs:16:9: 16:10 + let _29: *const [i32; 10] as UserTypeProjection { base: UserType(12), projs: [] }; // in scope 6 at $DIR/address-of.rs:23:9: 23:10 + scope 7 { + debug p => _29; // in scope 7 at $DIR/address-of.rs:23:9: 23:10 + let _30: *const [i32; 10] as UserTypeProjection { base: UserType(14), projs: [] }; // in scope 7 at $DIR/address-of.rs:24:9: 24:10 + scope 8 { + debug p => _30; // in scope 8 at $DIR/address-of.rs:24:9: 24:10 + let _31: *const dyn std::marker::Send as UserTypeProjection { base: UserType(16), projs: [] }; // in scope 8 at $DIR/address-of.rs:25:9: 25:10 + scope 9 { + debug p => _31; // in scope 9 at $DIR/address-of.rs:25:9: 25:10 + let _33: *const [i32] as UserTypeProjection { base: UserType(18), projs: [] }; // in scope 9 at $DIR/address-of.rs:26:9: 26:10 + scope 10 { + debug p => _33; // in scope 10 at $DIR/address-of.rs:26:9: 26:10 + let _43: *mut [i32; 10] as UserTypeProjection { base: UserType(22), projs: [] }; // in scope 10 at $DIR/address-of.rs:33:9: 33:10 + scope 11 { + debug p => _43; // in scope 11 at $DIR/address-of.rs:33:9: 33:10 + let _44: *mut [i32; 10] as UserTypeProjection { base: UserType(24), projs: [] }; // in scope 11 at $DIR/address-of.rs:34:9: 34:10 + scope 12 { + debug p => _44; // in scope 12 at $DIR/address-of.rs:34:9: 34:10 + let _45: *mut dyn std::marker::Send as UserTypeProjection { base: UserType(26), projs: [] }; // in scope 12 at $DIR/address-of.rs:35:9: 35:10 + scope 13 { + debug p => _45; // in scope 13 at $DIR/address-of.rs:35:9: 35:10 + let _47: *mut [i32] as UserTypeProjection { base: UserType(28), projs: [] }; // in scope 13 at $DIR/address-of.rs:36:9: 36:10 + scope 14 { + debug p => _47; // in scope 14 at $DIR/address-of.rs:36:9: 36:10 + } + } + } + } + } + } + } + } + } + } + } + } + } + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/address-of.rs:4:9: 4:10 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/address-of.rs:4:14: 4:21 + _2 = [const 0i32; 10]; // bb0[2]: scope 0 at $DIR/address-of.rs:4:14: 4:21 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/address-of.rs:4:15: 4:16 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } + _1 = &_2; // bb0[3]: scope 0 at $DIR/address-of.rs:4:13: 4:21 + FakeRead(ForLet, _1); // bb0[4]: scope 0 at $DIR/address-of.rs:4:9: 4:10 + StorageLive(_3); // bb0[5]: scope 1 at $DIR/address-of.rs:5:9: 5:14 + StorageLive(_4); // bb0[6]: scope 1 at $DIR/address-of.rs:5:22: 5:29 + _4 = [const 0i32; 10]; // bb0[7]: scope 1 at $DIR/address-of.rs:5:22: 5:29 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/address-of.rs:5:23: 5:24 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } + _3 = &mut _4; // bb0[8]: scope 1 at $DIR/address-of.rs:5:17: 5:29 + FakeRead(ForLet, _3); // bb0[9]: scope 1 at $DIR/address-of.rs:5:9: 5:14 + StorageLive(_5); // bb0[10]: scope 2 at $DIR/address-of.rs:7:5: 7:18 + StorageLive(_6); // bb0[11]: scope 2 at $DIR/address-of.rs:7:5: 7:18 + _6 = &raw const (*_1); // bb0[12]: scope 2 at $DIR/address-of.rs:7:5: 7:6 + AscribeUserType(_6, o, UserTypeProjection { base: UserType(0), projs: [] }); // bb0[13]: scope 2 at $DIR/address-of.rs:7:5: 7:18 + _5 = _6; // bb0[14]: scope 2 at $DIR/address-of.rs:7:5: 7:18 + StorageDead(_6); // bb0[15]: scope 2 at $DIR/address-of.rs:7:18: 7:19 + StorageDead(_5); // bb0[16]: scope 2 at $DIR/address-of.rs:7:18: 7:19 + StorageLive(_7); // bb0[17]: scope 2 at $DIR/address-of.rs:8:5: 8:26 + _7 = &raw const (*_1); // bb0[18]: scope 2 at $DIR/address-of.rs:8:5: 8:6 + StorageDead(_7); // bb0[19]: scope 2 at $DIR/address-of.rs:8:26: 8:27 + StorageLive(_8); // bb0[20]: scope 2 at $DIR/address-of.rs:9:5: 9:25 + StorageLive(_9); // bb0[21]: scope 2 at $DIR/address-of.rs:9:5: 9:25 + StorageLive(_10); // bb0[22]: scope 2 at $DIR/address-of.rs:9:5: 9:6 + _10 = &raw const (*_1); // bb0[23]: scope 2 at $DIR/address-of.rs:9:5: 9:6 + _9 = move _10 as *const dyn std::marker::Send (Pointer(Unsize)); // bb0[24]: scope 2 at $DIR/address-of.rs:9:5: 9:6 + StorageDead(_10); // bb0[25]: scope 2 at $DIR/address-of.rs:9:5: 9:6 + AscribeUserType(_9, o, UserTypeProjection { base: UserType(1), projs: [] }); // bb0[26]: scope 2 at $DIR/address-of.rs:9:5: 9:25 + _8 = _9; // bb0[27]: scope 2 at $DIR/address-of.rs:9:5: 9:25 + StorageDead(_9); // bb0[28]: scope 2 at $DIR/address-of.rs:9:25: 9:26 + StorageDead(_8); // bb0[29]: scope 2 at $DIR/address-of.rs:9:25: 9:26 + StorageLive(_11); // bb0[30]: scope 2 at $DIR/address-of.rs:10:5: 10:22 + StorageLive(_12); // bb0[31]: scope 2 at $DIR/address-of.rs:10:5: 10:6 + _12 = &raw const (*_1); // bb0[32]: scope 2 at $DIR/address-of.rs:10:5: 10:6 + _11 = move _12 as *const [i32] (Pointer(Unsize)); // bb0[33]: scope 2 at $DIR/address-of.rs:10:5: 10:6 + StorageDead(_12); // bb0[34]: scope 2 at $DIR/address-of.rs:10:5: 10:6 + StorageDead(_11); // bb0[35]: scope 2 at $DIR/address-of.rs:10:22: 10:23 + StorageLive(_13); // bb0[36]: scope 2 at $DIR/address-of.rs:11:5: 11:20 + StorageLive(_14); // bb0[37]: scope 2 at $DIR/address-of.rs:11:5: 11:6 + _14 = &raw const (*_1); // bb0[38]: scope 2 at $DIR/address-of.rs:11:5: 11:6 + _13 = move _14 as *const i32 (Pointer(ArrayToPointer)); // bb0[39]: scope 2 at $DIR/address-of.rs:11:5: 11:20 + StorageDead(_14); // bb0[40]: scope 2 at $DIR/address-of.rs:11:19: 11:20 + StorageDead(_13); // bb0[41]: scope 2 at $DIR/address-of.rs:11:20: 11:21 + StorageLive(_15); // bb0[42]: scope 2 at $DIR/address-of.rs:13:9: 13:10 + _15 = &raw const (*_1); // bb0[43]: scope 2 at $DIR/address-of.rs:13:23: 13:24 + FakeRead(ForLet, _15); // bb0[44]: scope 2 at $DIR/address-of.rs:13:9: 13:10 + AscribeUserType(_15, o, UserTypeProjection { base: UserType(3), projs: [] }); // bb0[45]: scope 2 at $DIR/address-of.rs:13:12: 13:20 + StorageLive(_16); // bb0[46]: scope 3 at $DIR/address-of.rs:14:9: 14:10 + _16 = &raw const (*_1); // bb0[47]: scope 3 at $DIR/address-of.rs:14:31: 14:32 + FakeRead(ForLet, _16); // bb0[48]: scope 3 at $DIR/address-of.rs:14:9: 14:10 + AscribeUserType(_16, o, UserTypeProjection { base: UserType(5), projs: [] }); // bb0[49]: scope 3 at $DIR/address-of.rs:14:12: 14:28 + StorageLive(_17); // bb0[50]: scope 4 at $DIR/address-of.rs:15:9: 15:10 + StorageLive(_18); // bb0[51]: scope 4 at $DIR/address-of.rs:15:30: 15:31 + _18 = &raw const (*_1); // bb0[52]: scope 4 at $DIR/address-of.rs:15:30: 15:31 + _17 = move _18 as *const dyn std::marker::Send (Pointer(Unsize)); // bb0[53]: scope 4 at $DIR/address-of.rs:15:30: 15:31 + StorageDead(_18); // bb0[54]: scope 4 at $DIR/address-of.rs:15:30: 15:31 + FakeRead(ForLet, _17); // bb0[55]: scope 4 at $DIR/address-of.rs:15:9: 15:10 + AscribeUserType(_17, o, UserTypeProjection { base: UserType(7), projs: [] }); // bb0[56]: scope 4 at $DIR/address-of.rs:15:12: 15:27 + StorageLive(_19); // bb0[57]: scope 5 at $DIR/address-of.rs:16:9: 16:10 + StorageLive(_20); // bb0[58]: scope 5 at $DIR/address-of.rs:16:27: 16:28 + _20 = &raw const (*_1); // bb0[59]: scope 5 at $DIR/address-of.rs:16:27: 16:28 + _19 = move _20 as *const [i32] (Pointer(Unsize)); // bb0[60]: scope 5 at $DIR/address-of.rs:16:27: 16:28 + StorageDead(_20); // bb0[61]: scope 5 at $DIR/address-of.rs:16:27: 16:28 + FakeRead(ForLet, _19); // bb0[62]: scope 5 at $DIR/address-of.rs:16:9: 16:10 + AscribeUserType(_19, o, UserTypeProjection { base: UserType(9), projs: [] }); // bb0[63]: scope 5 at $DIR/address-of.rs:16:12: 16:24 + StorageLive(_21); // bb0[64]: scope 6 at $DIR/address-of.rs:18:5: 18:18 + StorageLive(_22); // bb0[65]: scope 6 at $DIR/address-of.rs:18:5: 18:18 + _22 = &raw const (*_3); // bb0[66]: scope 6 at $DIR/address-of.rs:18:5: 18:6 + AscribeUserType(_22, o, UserTypeProjection { base: UserType(10), projs: [] }); // bb0[67]: scope 6 at $DIR/address-of.rs:18:5: 18:18 + _21 = _22; // bb0[68]: scope 6 at $DIR/address-of.rs:18:5: 18:18 + StorageDead(_22); // bb0[69]: scope 6 at $DIR/address-of.rs:18:18: 18:19 + StorageDead(_21); // bb0[70]: scope 6 at $DIR/address-of.rs:18:18: 18:19 + StorageLive(_23); // bb0[71]: scope 6 at $DIR/address-of.rs:19:5: 19:26 + _23 = &raw const (*_3); // bb0[72]: scope 6 at $DIR/address-of.rs:19:5: 19:6 + StorageDead(_23); // bb0[73]: scope 6 at $DIR/address-of.rs:19:26: 19:27 + StorageLive(_24); // bb0[74]: scope 6 at $DIR/address-of.rs:20:5: 20:25 + StorageLive(_25); // bb0[75]: scope 6 at $DIR/address-of.rs:20:5: 20:25 + StorageLive(_26); // bb0[76]: scope 6 at $DIR/address-of.rs:20:5: 20:6 + _26 = &raw const (*_3); // bb0[77]: scope 6 at $DIR/address-of.rs:20:5: 20:6 + _25 = move _26 as *const dyn std::marker::Send (Pointer(Unsize)); // bb0[78]: scope 6 at $DIR/address-of.rs:20:5: 20:6 + StorageDead(_26); // bb0[79]: scope 6 at $DIR/address-of.rs:20:5: 20:6 + AscribeUserType(_25, o, UserTypeProjection { base: UserType(11), projs: [] }); // bb0[80]: scope 6 at $DIR/address-of.rs:20:5: 20:25 + _24 = _25; // bb0[81]: scope 6 at $DIR/address-of.rs:20:5: 20:25 + StorageDead(_25); // bb0[82]: scope 6 at $DIR/address-of.rs:20:25: 20:26 + StorageDead(_24); // bb0[83]: scope 6 at $DIR/address-of.rs:20:25: 20:26 + StorageLive(_27); // bb0[84]: scope 6 at $DIR/address-of.rs:21:5: 21:22 + StorageLive(_28); // bb0[85]: scope 6 at $DIR/address-of.rs:21:5: 21:6 + _28 = &raw const (*_3); // bb0[86]: scope 6 at $DIR/address-of.rs:21:5: 21:6 + _27 = move _28 as *const [i32] (Pointer(Unsize)); // bb0[87]: scope 6 at $DIR/address-of.rs:21:5: 21:6 + StorageDead(_28); // bb0[88]: scope 6 at $DIR/address-of.rs:21:5: 21:6 + StorageDead(_27); // bb0[89]: scope 6 at $DIR/address-of.rs:21:22: 21:23 + StorageLive(_29); // bb0[90]: scope 6 at $DIR/address-of.rs:23:9: 23:10 + _29 = &raw const (*_3); // bb0[91]: scope 6 at $DIR/address-of.rs:23:23: 23:24 + FakeRead(ForLet, _29); // bb0[92]: scope 6 at $DIR/address-of.rs:23:9: 23:10 + AscribeUserType(_29, o, UserTypeProjection { base: UserType(13), projs: [] }); // bb0[93]: scope 6 at $DIR/address-of.rs:23:12: 23:20 + StorageLive(_30); // bb0[94]: scope 7 at $DIR/address-of.rs:24:9: 24:10 + _30 = &raw const (*_3); // bb0[95]: scope 7 at $DIR/address-of.rs:24:31: 24:32 + FakeRead(ForLet, _30); // bb0[96]: scope 7 at $DIR/address-of.rs:24:9: 24:10 + AscribeUserType(_30, o, UserTypeProjection { base: UserType(15), projs: [] }); // bb0[97]: scope 7 at $DIR/address-of.rs:24:12: 24:28 + StorageLive(_31); // bb0[98]: scope 8 at $DIR/address-of.rs:25:9: 25:10 + StorageLive(_32); // bb0[99]: scope 8 at $DIR/address-of.rs:25:30: 25:31 + _32 = &raw const (*_3); // bb0[100]: scope 8 at $DIR/address-of.rs:25:30: 25:31 + _31 = move _32 as *const dyn std::marker::Send (Pointer(Unsize)); // bb0[101]: scope 8 at $DIR/address-of.rs:25:30: 25:31 + StorageDead(_32); // bb0[102]: scope 8 at $DIR/address-of.rs:25:30: 25:31 + FakeRead(ForLet, _31); // bb0[103]: scope 8 at $DIR/address-of.rs:25:9: 25:10 + AscribeUserType(_31, o, UserTypeProjection { base: UserType(17), projs: [] }); // bb0[104]: scope 8 at $DIR/address-of.rs:25:12: 25:27 + StorageLive(_33); // bb0[105]: scope 9 at $DIR/address-of.rs:26:9: 26:10 + StorageLive(_34); // bb0[106]: scope 9 at $DIR/address-of.rs:26:27: 26:28 + _34 = &raw const (*_3); // bb0[107]: scope 9 at $DIR/address-of.rs:26:27: 26:28 + _33 = move _34 as *const [i32] (Pointer(Unsize)); // bb0[108]: scope 9 at $DIR/address-of.rs:26:27: 26:28 + StorageDead(_34); // bb0[109]: scope 9 at $DIR/address-of.rs:26:27: 26:28 + FakeRead(ForLet, _33); // bb0[110]: scope 9 at $DIR/address-of.rs:26:9: 26:10 + AscribeUserType(_33, o, UserTypeProjection { base: UserType(19), projs: [] }); // bb0[111]: scope 9 at $DIR/address-of.rs:26:12: 26:24 + StorageLive(_35); // bb0[112]: scope 10 at $DIR/address-of.rs:28:5: 28:16 + StorageLive(_36); // bb0[113]: scope 10 at $DIR/address-of.rs:28:5: 28:16 + _36 = &raw mut (*_3); // bb0[114]: scope 10 at $DIR/address-of.rs:28:5: 28:6 + AscribeUserType(_36, o, UserTypeProjection { base: UserType(20), projs: [] }); // bb0[115]: scope 10 at $DIR/address-of.rs:28:5: 28:16 + _35 = _36; // bb0[116]: scope 10 at $DIR/address-of.rs:28:5: 28:16 + StorageDead(_36); // bb0[117]: scope 10 at $DIR/address-of.rs:28:16: 28:17 + StorageDead(_35); // bb0[118]: scope 10 at $DIR/address-of.rs:28:16: 28:17 + StorageLive(_37); // bb0[119]: scope 10 at $DIR/address-of.rs:29:5: 29:24 + _37 = &raw mut (*_3); // bb0[120]: scope 10 at $DIR/address-of.rs:29:5: 29:6 + StorageDead(_37); // bb0[121]: scope 10 at $DIR/address-of.rs:29:24: 29:25 + StorageLive(_38); // bb0[122]: scope 10 at $DIR/address-of.rs:30:5: 30:23 + StorageLive(_39); // bb0[123]: scope 10 at $DIR/address-of.rs:30:5: 30:23 + StorageLive(_40); // bb0[124]: scope 10 at $DIR/address-of.rs:30:5: 30:6 + _40 = &raw mut (*_3); // bb0[125]: scope 10 at $DIR/address-of.rs:30:5: 30:6 + _39 = move _40 as *mut dyn std::marker::Send (Pointer(Unsize)); // bb0[126]: scope 10 at $DIR/address-of.rs:30:5: 30:6 + StorageDead(_40); // bb0[127]: scope 10 at $DIR/address-of.rs:30:5: 30:6 + AscribeUserType(_39, o, UserTypeProjection { base: UserType(21), projs: [] }); // bb0[128]: scope 10 at $DIR/address-of.rs:30:5: 30:23 + _38 = _39; // bb0[129]: scope 10 at $DIR/address-of.rs:30:5: 30:23 + StorageDead(_39); // bb0[130]: scope 10 at $DIR/address-of.rs:30:23: 30:24 + StorageDead(_38); // bb0[131]: scope 10 at $DIR/address-of.rs:30:23: 30:24 + StorageLive(_41); // bb0[132]: scope 10 at $DIR/address-of.rs:31:5: 31:20 + StorageLive(_42); // bb0[133]: scope 10 at $DIR/address-of.rs:31:5: 31:6 + _42 = &raw mut (*_3); // bb0[134]: scope 10 at $DIR/address-of.rs:31:5: 31:6 + _41 = move _42 as *mut [i32] (Pointer(Unsize)); // bb0[135]: scope 10 at $DIR/address-of.rs:31:5: 31:6 + StorageDead(_42); // bb0[136]: scope 10 at $DIR/address-of.rs:31:5: 31:6 + StorageDead(_41); // bb0[137]: scope 10 at $DIR/address-of.rs:31:20: 31:21 + StorageLive(_43); // bb0[138]: scope 10 at $DIR/address-of.rs:33:9: 33:10 + _43 = &raw mut (*_3); // bb0[139]: scope 10 at $DIR/address-of.rs:33:21: 33:22 + FakeRead(ForLet, _43); // bb0[140]: scope 10 at $DIR/address-of.rs:33:9: 33:10 + AscribeUserType(_43, o, UserTypeProjection { base: UserType(23), projs: [] }); // bb0[141]: scope 10 at $DIR/address-of.rs:33:12: 33:18 + StorageLive(_44); // bb0[142]: scope 11 at $DIR/address-of.rs:34:9: 34:10 + _44 = &raw mut (*_3); // bb0[143]: scope 11 at $DIR/address-of.rs:34:29: 34:30 + FakeRead(ForLet, _44); // bb0[144]: scope 11 at $DIR/address-of.rs:34:9: 34:10 + AscribeUserType(_44, o, UserTypeProjection { base: UserType(25), projs: [] }); // bb0[145]: scope 11 at $DIR/address-of.rs:34:12: 34:26 + StorageLive(_45); // bb0[146]: scope 12 at $DIR/address-of.rs:35:9: 35:10 + StorageLive(_46); // bb0[147]: scope 12 at $DIR/address-of.rs:35:28: 35:29 + _46 = &raw mut (*_3); // bb0[148]: scope 12 at $DIR/address-of.rs:35:28: 35:29 + _45 = move _46 as *mut dyn std::marker::Send (Pointer(Unsize)); // bb0[149]: scope 12 at $DIR/address-of.rs:35:28: 35:29 + StorageDead(_46); // bb0[150]: scope 12 at $DIR/address-of.rs:35:28: 35:29 + FakeRead(ForLet, _45); // bb0[151]: scope 12 at $DIR/address-of.rs:35:9: 35:10 + AscribeUserType(_45, o, UserTypeProjection { base: UserType(27), projs: [] }); // bb0[152]: scope 12 at $DIR/address-of.rs:35:12: 35:25 + StorageLive(_47); // bb0[153]: scope 13 at $DIR/address-of.rs:36:9: 36:10 + StorageLive(_48); // bb0[154]: scope 13 at $DIR/address-of.rs:36:25: 36:26 + _48 = &raw mut (*_3); // bb0[155]: scope 13 at $DIR/address-of.rs:36:25: 36:26 + _47 = move _48 as *mut [i32] (Pointer(Unsize)); // bb0[156]: scope 13 at $DIR/address-of.rs:36:25: 36:26 + StorageDead(_48); // bb0[157]: scope 13 at $DIR/address-of.rs:36:25: 36:26 + FakeRead(ForLet, _47); // bb0[158]: scope 13 at $DIR/address-of.rs:36:9: 36:10 + AscribeUserType(_47, o, UserTypeProjection { base: UserType(29), projs: [] }); // bb0[159]: scope 13 at $DIR/address-of.rs:36:12: 36:22 + _0 = (); // bb0[160]: scope 0 at $DIR/address-of.rs:3:26: 37:2 + StorageDead(_47); // bb0[161]: scope 13 at $DIR/address-of.rs:37:1: 37:2 + StorageDead(_45); // bb0[162]: scope 12 at $DIR/address-of.rs:37:1: 37:2 + StorageDead(_44); // bb0[163]: scope 11 at $DIR/address-of.rs:37:1: 37:2 + StorageDead(_43); // bb0[164]: scope 10 at $DIR/address-of.rs:37:1: 37:2 + StorageDead(_33); // bb0[165]: scope 9 at $DIR/address-of.rs:37:1: 37:2 + StorageDead(_31); // bb0[166]: scope 8 at $DIR/address-of.rs:37:1: 37:2 + StorageDead(_30); // bb0[167]: scope 7 at $DIR/address-of.rs:37:1: 37:2 + StorageDead(_29); // bb0[168]: scope 6 at $DIR/address-of.rs:37:1: 37:2 + StorageDead(_19); // bb0[169]: scope 5 at $DIR/address-of.rs:37:1: 37:2 + StorageDead(_17); // bb0[170]: scope 4 at $DIR/address-of.rs:37:1: 37:2 + StorageDead(_16); // bb0[171]: scope 3 at $DIR/address-of.rs:37:1: 37:2 + StorageDead(_15); // bb0[172]: scope 2 at $DIR/address-of.rs:37:1: 37:2 + StorageDead(_4); // bb0[173]: scope 1 at $DIR/address-of.rs:37:1: 37:2 + StorageDead(_3); // bb0[174]: scope 1 at $DIR/address-of.rs:37:1: 37:2 + StorageDead(_2); // bb0[175]: scope 0 at $DIR/address-of.rs:37:1: 37:2 + StorageDead(_1); // bb0[176]: scope 0 at $DIR/address-of.rs:37:1: 37:2 + return; // bb0[177]: scope 0 at $DIR/address-of.rs:37:2: 37:2 + } +} diff --git a/src/test/mir-opt/address-of/rustc.borrow_and_cast.SimplifyCfg-initial.after.mir b/src/test/mir-opt/address-of/rustc.borrow_and_cast.SimplifyCfg-initial.after.mir new file mode 100644 index 00000000000..29ccff49202 --- /dev/null +++ b/src/test/mir-opt/address-of/rustc.borrow_and_cast.SimplifyCfg-initial.after.mir @@ -0,0 +1,47 @@ +// MIR for `borrow_and_cast` after SimplifyCfg-initial + +fn borrow_and_cast(_1: i32) -> () { + debug x => _1; // in scope 0 at $DIR/address-of.rs:41:20: 41:25 + let mut _0: (); // return place in scope 0 at $DIR/address-of.rs:41:32: 41:32 + let _2: *const i32; // in scope 0 at $DIR/address-of.rs:42:9: 42:10 + let _3: &i32; // in scope 0 at $DIR/address-of.rs:42:13: 42:15 + let _5: &mut i32; // in scope 0 at $DIR/address-of.rs:43:13: 43:19 + let mut _7: &mut i32; // in scope 0 at $DIR/address-of.rs:44:13: 44:19 + scope 1 { + debug p => _2; // in scope 1 at $DIR/address-of.rs:42:9: 42:10 + let _4: *const i32; // in scope 1 at $DIR/address-of.rs:43:9: 43:10 + scope 2 { + debug q => _4; // in scope 2 at $DIR/address-of.rs:43:9: 43:10 + let _6: *mut i32; // in scope 2 at $DIR/address-of.rs:44:9: 44:10 + scope 3 { + debug r => _6; // in scope 3 at $DIR/address-of.rs:44:9: 44:10 + } + } + } + + bb0: { + StorageLive(_2); // bb0[0]: scope 0 at $DIR/address-of.rs:42:9: 42:10 + StorageLive(_3); // bb0[1]: scope 0 at $DIR/address-of.rs:42:13: 42:15 + _3 = &_1; // bb0[2]: scope 0 at $DIR/address-of.rs:42:13: 42:15 + _2 = &raw const (*_3); // bb0[3]: scope 0 at $DIR/address-of.rs:42:13: 42:15 + FakeRead(ForLet, _2); // bb0[4]: scope 0 at $DIR/address-of.rs:42:9: 42:10 + StorageDead(_3); // bb0[5]: scope 0 at $DIR/address-of.rs:42:29: 42:30 + StorageLive(_4); // bb0[6]: scope 1 at $DIR/address-of.rs:43:9: 43:10 + StorageLive(_5); // bb0[7]: scope 1 at $DIR/address-of.rs:43:13: 43:19 + _5 = &mut _1; // bb0[8]: scope 1 at $DIR/address-of.rs:43:13: 43:19 + _4 = &raw const (*_5); // bb0[9]: scope 1 at $DIR/address-of.rs:43:13: 43:19 + FakeRead(ForLet, _4); // bb0[10]: scope 1 at $DIR/address-of.rs:43:9: 43:10 + StorageDead(_5); // bb0[11]: scope 1 at $DIR/address-of.rs:43:33: 43:34 + StorageLive(_6); // bb0[12]: scope 2 at $DIR/address-of.rs:44:9: 44:10 + StorageLive(_7); // bb0[13]: scope 2 at $DIR/address-of.rs:44:13: 44:19 + _7 = &mut _1; // bb0[14]: scope 2 at $DIR/address-of.rs:44:13: 44:19 + _6 = &raw mut (*_7); // bb0[15]: scope 2 at $DIR/address-of.rs:44:13: 44:19 + FakeRead(ForLet, _6); // bb0[16]: scope 2 at $DIR/address-of.rs:44:9: 44:10 + StorageDead(_7); // bb0[17]: scope 2 at $DIR/address-of.rs:44:31: 44:32 + _0 = (); // bb0[18]: scope 0 at $DIR/address-of.rs:41:32: 45:2 + StorageDead(_6); // bb0[19]: scope 2 at $DIR/address-of.rs:45:1: 45:2 + StorageDead(_4); // bb0[20]: scope 1 at $DIR/address-of.rs:45:1: 45:2 + StorageDead(_2); // bb0[21]: scope 0 at $DIR/address-of.rs:45:1: 45:2 + return; // bb0[22]: scope 0 at $DIR/address-of.rs:45:2: 45:2 + } +} diff --git a/src/test/mir-opt/array-index-is-temporary.rs b/src/test/mir-opt/array-index-is-temporary.rs index 57f30acb3a6..4667c4f66b2 100644 --- a/src/test/mir-opt/array-index-is-temporary.rs +++ b/src/test/mir-opt/array-index-is-temporary.rs @@ -7,35 +7,11 @@ unsafe fn foo(z: *mut usize) -> u32 { 99 } +// EMIT_MIR_FOR_EACH_BIT_WIDTH +// EMIT_MIR rustc.main.SimplifyCfg-elaborate-drops.after.mir fn main() { let mut x = [42, 43, 44]; let mut y = 1; let z: *mut usize = &mut y; x[y] = unsafe { foo(z) }; } - -// END RUST SOURCE -// START rustc.main.SimplifyCfg-elaborate-drops.after.mir -// bb0: { -// ... -// _4 = &mut _2; -// _3 = &raw mut (*_4); -// ... -// _6 = _3; -// _5 = const foo(move _6) -> bb1; -// } -// -// bb1: { -// ... -// _7 = _2; -// _8 = Len(_1); -// _9 = Lt(_7, _8); -// assert(move _9, "index out of bounds: the len is move _8 but the index is _7") -> bb2; -// } -// -// bb2: { -// _1[_7] = move _5; -// ... -// return; -// } -// END rustc.main.SimplifyCfg-elaborate-drops.after.mir diff --git a/src/test/mir-opt/array-index-is-temporary/32bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/array-index-is-temporary/32bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir new file mode 100644 index 00000000000..052a335d00b --- /dev/null +++ b/src/test/mir-opt/array-index-is-temporary/32bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir @@ -0,0 +1,91 @@ +// MIR for `main` after SimplifyCfg-elaborate-drops + +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/array-index-is-temporary.rs:12:11: 12:11 + let mut _1: [u32; 3]; // in scope 0 at $DIR/array-index-is-temporary.rs:13:9: 13:14 + let mut _4: &mut usize; // in scope 0 at $DIR/array-index-is-temporary.rs:15:25: 15:31 + let mut _5: u32; // in scope 0 at $DIR/array-index-is-temporary.rs:16:12: 16:29 + let mut _6: *mut usize; // in scope 0 at $DIR/array-index-is-temporary.rs:16:25: 16:26 + let _7: usize; // in scope 0 at $DIR/array-index-is-temporary.rs:16:7: 16:8 + let mut _8: usize; // in scope 0 at $DIR/array-index-is-temporary.rs:16:5: 16:9 + let mut _9: bool; // in scope 0 at $DIR/array-index-is-temporary.rs:16:5: 16:9 + scope 1 { + debug x => _1; // in scope 1 at $DIR/array-index-is-temporary.rs:13:9: 13:14 + let mut _2: usize; // in scope 1 at $DIR/array-index-is-temporary.rs:14:9: 14:14 + scope 2 { + debug y => _2; // in scope 2 at $DIR/array-index-is-temporary.rs:14:9: 14:14 + let _3: *mut usize as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 2 at $DIR/array-index-is-temporary.rs:15:9: 15:10 + scope 3 { + debug z => _3; // in scope 3 at $DIR/array-index-is-temporary.rs:15:9: 15:10 + scope 4 { + } + } + } + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/array-index-is-temporary.rs:13:9: 13:14 + _1 = [const 42u32, const 43u32, const 44u32]; // bb0[1]: scope 0 at $DIR/array-index-is-temporary.rs:13:17: 13:29 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x0000002a)) + // mir::Constant + // + span: $DIR/array-index-is-temporary.rs:13:18: 13:20 + // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x0000002b)) + // mir::Constant + // + span: $DIR/array-index-is-temporary.rs:13:22: 13:24 + // + literal: Const { ty: u32, val: Value(Scalar(0x0000002b)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x0000002c)) + // mir::Constant + // + span: $DIR/array-index-is-temporary.rs:13:26: 13:28 + // + literal: Const { ty: u32, val: Value(Scalar(0x0000002c)) } + StorageLive(_2); // bb0[2]: scope 1 at $DIR/array-index-is-temporary.rs:14:9: 14:14 + _2 = const 1usize; // bb0[3]: scope 1 at $DIR/array-index-is-temporary.rs:14:17: 14:18 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/array-index-is-temporary.rs:14:17: 14:18 + // + literal: Const { ty: usize, val: Value(Scalar(0x00000001)) } + StorageLive(_3); // bb0[4]: scope 2 at $DIR/array-index-is-temporary.rs:15:9: 15:10 + StorageLive(_4); // bb0[5]: scope 2 at $DIR/array-index-is-temporary.rs:15:25: 15:31 + _4 = &mut _2; // bb0[6]: scope 2 at $DIR/array-index-is-temporary.rs:15:25: 15:31 + _3 = &raw mut (*_4); // bb0[7]: scope 2 at $DIR/array-index-is-temporary.rs:15:25: 15:31 + StorageDead(_4); // bb0[8]: scope 2 at $DIR/array-index-is-temporary.rs:15:31: 15:32 + StorageLive(_5); // bb0[9]: scope 3 at $DIR/array-index-is-temporary.rs:16:12: 16:29 + StorageLive(_6); // bb0[10]: scope 4 at $DIR/array-index-is-temporary.rs:16:25: 16:26 + _6 = _3; // bb0[11]: scope 4 at $DIR/array-index-is-temporary.rs:16:25: 16:26 + _5 = const foo(move _6) -> bb1; // bb0[12]: scope 4 at $DIR/array-index-is-temporary.rs:16:21: 16:27 + // ty::Const + // + ty: unsafe fn(*mut usize) -> u32 {foo} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/array-index-is-temporary.rs:16:21: 16:24 + // + literal: Const { ty: unsafe fn(*mut usize) -> u32 {foo}, val: Value(Scalar(<ZST>)) } + } + + bb1: { + StorageDead(_6); // bb1[0]: scope 4 at $DIR/array-index-is-temporary.rs:16:26: 16:27 + StorageLive(_7); // bb1[1]: scope 3 at $DIR/array-index-is-temporary.rs:16:7: 16:8 + _7 = _2; // bb1[2]: scope 3 at $DIR/array-index-is-temporary.rs:16:7: 16:8 + _8 = Len(_1); // bb1[3]: scope 3 at $DIR/array-index-is-temporary.rs:16:5: 16:9 + _9 = Lt(_7, _8); // bb1[4]: scope 3 at $DIR/array-index-is-temporary.rs:16:5: 16:9 + assert(move _9, "index out of bounds: the len is move _8 but the index is _7") -> bb2; // bb1[5]: scope 3 at $DIR/array-index-is-temporary.rs:16:5: 16:9 + } + + bb2: { + _1[_7] = move _5; // bb2[0]: scope 3 at $DIR/array-index-is-temporary.rs:16:5: 16:29 + StorageDead(_5); // bb2[1]: scope 3 at $DIR/array-index-is-temporary.rs:16:28: 16:29 + StorageDead(_7); // bb2[2]: scope 3 at $DIR/array-index-is-temporary.rs:16:29: 16:30 + _0 = (); // bb2[3]: scope 0 at $DIR/array-index-is-temporary.rs:12:11: 17:2 + StorageDead(_3); // bb2[4]: scope 2 at $DIR/array-index-is-temporary.rs:17:1: 17:2 + StorageDead(_2); // bb2[5]: scope 1 at $DIR/array-index-is-temporary.rs:17:1: 17:2 + StorageDead(_1); // bb2[6]: scope 0 at $DIR/array-index-is-temporary.rs:17:1: 17:2 + return; // bb2[7]: scope 0 at $DIR/array-index-is-temporary.rs:17:2: 17:2 + } +} diff --git a/src/test/mir-opt/array-index-is-temporary/64bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/array-index-is-temporary/64bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir new file mode 100644 index 00000000000..e180f449695 --- /dev/null +++ b/src/test/mir-opt/array-index-is-temporary/64bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir @@ -0,0 +1,91 @@ +// MIR for `main` after SimplifyCfg-elaborate-drops + +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/array-index-is-temporary.rs:12:11: 12:11 + let mut _1: [u32; 3]; // in scope 0 at $DIR/array-index-is-temporary.rs:13:9: 13:14 + let mut _4: &mut usize; // in scope 0 at $DIR/array-index-is-temporary.rs:15:25: 15:31 + let mut _5: u32; // in scope 0 at $DIR/array-index-is-temporary.rs:16:12: 16:29 + let mut _6: *mut usize; // in scope 0 at $DIR/array-index-is-temporary.rs:16:25: 16:26 + let _7: usize; // in scope 0 at $DIR/array-index-is-temporary.rs:16:7: 16:8 + let mut _8: usize; // in scope 0 at $DIR/array-index-is-temporary.rs:16:5: 16:9 + let mut _9: bool; // in scope 0 at $DIR/array-index-is-temporary.rs:16:5: 16:9 + scope 1 { + debug x => _1; // in scope 1 at $DIR/array-index-is-temporary.rs:13:9: 13:14 + let mut _2: usize; // in scope 1 at $DIR/array-index-is-temporary.rs:14:9: 14:14 + scope 2 { + debug y => _2; // in scope 2 at $DIR/array-index-is-temporary.rs:14:9: 14:14 + let _3: *mut usize as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 2 at $DIR/array-index-is-temporary.rs:15:9: 15:10 + scope 3 { + debug z => _3; // in scope 3 at $DIR/array-index-is-temporary.rs:15:9: 15:10 + scope 4 { + } + } + } + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/array-index-is-temporary.rs:13:9: 13:14 + _1 = [const 42u32, const 43u32, const 44u32]; // bb0[1]: scope 0 at $DIR/array-index-is-temporary.rs:13:17: 13:29 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x0000002a)) + // mir::Constant + // + span: $DIR/array-index-is-temporary.rs:13:18: 13:20 + // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x0000002b)) + // mir::Constant + // + span: $DIR/array-index-is-temporary.rs:13:22: 13:24 + // + literal: Const { ty: u32, val: Value(Scalar(0x0000002b)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x0000002c)) + // mir::Constant + // + span: $DIR/array-index-is-temporary.rs:13:26: 13:28 + // + literal: Const { ty: u32, val: Value(Scalar(0x0000002c)) } + StorageLive(_2); // bb0[2]: scope 1 at $DIR/array-index-is-temporary.rs:14:9: 14:14 + _2 = const 1usize; // bb0[3]: scope 1 at $DIR/array-index-is-temporary.rs:14:17: 14:18 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000001)) + // mir::Constant + // + span: $DIR/array-index-is-temporary.rs:14:17: 14:18 + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000001)) } + StorageLive(_3); // bb0[4]: scope 2 at $DIR/array-index-is-temporary.rs:15:9: 15:10 + StorageLive(_4); // bb0[5]: scope 2 at $DIR/array-index-is-temporary.rs:15:25: 15:31 + _4 = &mut _2; // bb0[6]: scope 2 at $DIR/array-index-is-temporary.rs:15:25: 15:31 + _3 = &raw mut (*_4); // bb0[7]: scope 2 at $DIR/array-index-is-temporary.rs:15:25: 15:31 + StorageDead(_4); // bb0[8]: scope 2 at $DIR/array-index-is-temporary.rs:15:31: 15:32 + StorageLive(_5); // bb0[9]: scope 3 at $DIR/array-index-is-temporary.rs:16:12: 16:29 + StorageLive(_6); // bb0[10]: scope 4 at $DIR/array-index-is-temporary.rs:16:25: 16:26 + _6 = _3; // bb0[11]: scope 4 at $DIR/array-index-is-temporary.rs:16:25: 16:26 + _5 = const foo(move _6) -> bb1; // bb0[12]: scope 4 at $DIR/array-index-is-temporary.rs:16:21: 16:27 + // ty::Const + // + ty: unsafe fn(*mut usize) -> u32 {foo} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/array-index-is-temporary.rs:16:21: 16:24 + // + literal: Const { ty: unsafe fn(*mut usize) -> u32 {foo}, val: Value(Scalar(<ZST>)) } + } + + bb1: { + StorageDead(_6); // bb1[0]: scope 4 at $DIR/array-index-is-temporary.rs:16:26: 16:27 + StorageLive(_7); // bb1[1]: scope 3 at $DIR/array-index-is-temporary.rs:16:7: 16:8 + _7 = _2; // bb1[2]: scope 3 at $DIR/array-index-is-temporary.rs:16:7: 16:8 + _8 = Len(_1); // bb1[3]: scope 3 at $DIR/array-index-is-temporary.rs:16:5: 16:9 + _9 = Lt(_7, _8); // bb1[4]: scope 3 at $DIR/array-index-is-temporary.rs:16:5: 16:9 + assert(move _9, "index out of bounds: the len is move _8 but the index is _7") -> bb2; // bb1[5]: scope 3 at $DIR/array-index-is-temporary.rs:16:5: 16:9 + } + + bb2: { + _1[_7] = move _5; // bb2[0]: scope 3 at $DIR/array-index-is-temporary.rs:16:5: 16:29 + StorageDead(_5); // bb2[1]: scope 3 at $DIR/array-index-is-temporary.rs:16:28: 16:29 + StorageDead(_7); // bb2[2]: scope 3 at $DIR/array-index-is-temporary.rs:16:29: 16:30 + _0 = (); // bb2[3]: scope 0 at $DIR/array-index-is-temporary.rs:12:11: 17:2 + StorageDead(_3); // bb2[4]: scope 2 at $DIR/array-index-is-temporary.rs:17:1: 17:2 + StorageDead(_2); // bb2[5]: scope 1 at $DIR/array-index-is-temporary.rs:17:1: 17:2 + StorageDead(_1); // bb2[6]: scope 0 at $DIR/array-index-is-temporary.rs:17:1: 17:2 + return; // bb2[7]: scope 0 at $DIR/array-index-is-temporary.rs:17:2: 17:2 + } +} diff --git a/src/test/mir-opt/box_expr.rs b/src/test/mir-opt/box_expr.rs index fa1a291858b..beaf0baf12c 100644 --- a/src/test/mir-opt/box_expr.rs +++ b/src/test/mir-opt/box_expr.rs @@ -2,6 +2,7 @@ #![feature(box_syntax)] +// EMIT_MIR rustc.main.ElaborateDrops.before.mir fn main() { let x = box S::new(); drop(x); @@ -18,60 +19,3 @@ impl Drop for S { println!("splat!"); } } - -// END RUST SOURCE -// START rustc.main.ElaborateDrops.before.mir -// let mut _0: (); -// let _1: std::boxed::Box<S>; -// let mut _2: std::boxed::Box<S>; -// let _3: (); -// let mut _4: std::boxed::Box<S>; -// scope 1 { -// debug x => _1; -// } -// bb0: { -// StorageLive(_1); -// StorageLive(_2); -// _2 = Box(S); -// (*_2) = const S::new() -> [return: bb2, unwind: bb3]; -// } -// -// bb1 (cleanup): { -// resume; -// } -// -// bb2: { -// _1 = move _2; -// drop(_2) -> bb4; -// } -// -// bb3 (cleanup): { -// drop(_2) -> bb1; -// } -// -// bb4: { -// StorageDead(_2); -// StorageLive(_3); -// StorageLive(_4); -// _4 = move _1; -// _3 = const std::mem::drop::<std::boxed::Box<S>>(move _4) -> [return: bb5, unwind: bb7]; -// } -// -// bb5: { -// StorageDead(_4); -// StorageDead(_3); -// _0 = (); -// drop(_1) -> bb8; -// } -// bb6 (cleanup): { -// drop(_1) -> bb1; -// } -// bb7 (cleanup): { -// drop(_4) -> bb6; -// } -// bb8: { -// StorageDead(_1); -// return; -// } -// } -// END rustc.main.ElaborateDrops.before.mir diff --git a/src/test/mir-opt/box_expr/rustc.main.ElaborateDrops.before.mir b/src/test/mir-opt/box_expr/rustc.main.ElaborateDrops.before.mir new file mode 100644 index 00000000000..61986535dd3 --- /dev/null +++ b/src/test/mir-opt/box_expr/rustc.main.ElaborateDrops.before.mir @@ -0,0 +1,72 @@ +// MIR for `main` before ElaborateDrops + +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/box_expr.rs:6:11: 6:11 + let _1: std::boxed::Box<S>; // in scope 0 at $DIR/box_expr.rs:7:9: 7:10 + let mut _2: std::boxed::Box<S>; // in scope 0 at $DIR/box_expr.rs:7:13: 7:25 + let _3: (); // in scope 0 at $DIR/box_expr.rs:8:5: 8:12 + let mut _4: std::boxed::Box<S>; // in scope 0 at $DIR/box_expr.rs:8:10: 8:11 + scope 1 { + debug x => _1; // in scope 1 at $DIR/box_expr.rs:7:9: 7:10 + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/box_expr.rs:7:9: 7:10 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/box_expr.rs:7:13: 7:25 + _2 = Box(S); // bb0[2]: scope 0 at $DIR/box_expr.rs:7:13: 7:25 + (*_2) = const S::new() -> [return: bb2, unwind: bb3]; // bb0[3]: scope 0 at $DIR/box_expr.rs:7:17: 7:25 + // ty::Const + // + ty: fn() -> S {S::new} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/box_expr.rs:7:17: 7:23 + // + literal: Const { ty: fn() -> S {S::new}, val: Value(Scalar(<ZST>)) } + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/box_expr.rs:6:1: 9:2 + } + + bb2: { + _1 = move _2; // bb2[0]: scope 0 at $DIR/box_expr.rs:7:13: 7:25 + drop(_2) -> bb4; // bb2[1]: scope 0 at $DIR/box_expr.rs:7:24: 7:25 + } + + bb3 (cleanup): { + drop(_2) -> bb1; // bb3[0]: scope 0 at $DIR/box_expr.rs:7:24: 7:25 + } + + bb4: { + StorageDead(_2); // bb4[0]: scope 0 at $DIR/box_expr.rs:7:24: 7:25 + StorageLive(_3); // bb4[1]: scope 1 at $DIR/box_expr.rs:8:5: 8:12 + StorageLive(_4); // bb4[2]: scope 1 at $DIR/box_expr.rs:8:10: 8:11 + _4 = move _1; // bb4[3]: scope 1 at $DIR/box_expr.rs:8:10: 8:11 + _3 = const std::mem::drop::<std::boxed::Box<S>>(move _4) -> [return: bb5, unwind: bb7]; // bb4[4]: scope 1 at $DIR/box_expr.rs:8:5: 8:12 + // ty::Const + // + ty: fn(std::boxed::Box<S>) {std::mem::drop::<std::boxed::Box<S>>} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/box_expr.rs:8:5: 8:9 + // + literal: Const { ty: fn(std::boxed::Box<S>) {std::mem::drop::<std::boxed::Box<S>>}, val: Value(Scalar(<ZST>)) } + } + + bb5: { + StorageDead(_4); // bb5[0]: scope 1 at $DIR/box_expr.rs:8:11: 8:12 + StorageDead(_3); // bb5[1]: scope 1 at $DIR/box_expr.rs:8:12: 8:13 + _0 = (); // bb5[2]: scope 0 at $DIR/box_expr.rs:6:11: 9:2 + drop(_1) -> bb8; // bb5[3]: scope 0 at $DIR/box_expr.rs:9:1: 9:2 + } + + bb6 (cleanup): { + drop(_1) -> bb1; // bb6[0]: scope 0 at $DIR/box_expr.rs:9:1: 9:2 + } + + bb7 (cleanup): { + drop(_4) -> bb6; // bb7[0]: scope 1 at $DIR/box_expr.rs:8:11: 8:12 + } + + bb8: { + StorageDead(_1); // bb8[0]: scope 0 at $DIR/box_expr.rs:9:1: 9:2 + return; // bb8[1]: scope 0 at $DIR/box_expr.rs:9:2: 9:2 + } +} diff --git a/src/test/mir-opt/byte_slice.rs b/src/test/mir-opt/byte_slice.rs index 0fb685c3c4e..317e96d6f52 100644 --- a/src/test/mir-opt/byte_slice.rs +++ b/src/test/mir-opt/byte_slice.rs @@ -1,15 +1,7 @@ // compile-flags: -Z mir-opt-level=0 +// EMIT_MIR rustc.main.SimplifyCfg-elaborate-drops.after.mir fn main() { let x = b"foo"; let y = [5u8, b'x']; } - -// END RUST SOURCE -// START rustc.main.SimplifyCfg-elaborate-drops.after.mir -// ... -// _1 = const b"foo"; -// ... -// _2 = [const 5u8, const 120u8]; -// ... -// END rustc.main.SimplifyCfg-elaborate-drops.after.mir diff --git a/src/test/mir-opt/byte_slice/rustc.main.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/byte_slice/rustc.main.SimplifyCfg-elaborate-drops.after.mir new file mode 100644 index 00000000000..14be9c990bd --- /dev/null +++ b/src/test/mir-opt/byte_slice/rustc.main.SimplifyCfg-elaborate-drops.after.mir @@ -0,0 +1,46 @@ +// MIR for `main` after SimplifyCfg-elaborate-drops + +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/byte_slice.rs:4:11: 4:11 + let _1: &[u8; 3]; // in scope 0 at $DIR/byte_slice.rs:5:9: 5:10 + scope 1 { + debug x => _1; // in scope 1 at $DIR/byte_slice.rs:5:9: 5:10 + let _2: [u8; 2]; // in scope 1 at $DIR/byte_slice.rs:6:9: 6:10 + scope 2 { + debug y => _2; // in scope 2 at $DIR/byte_slice.rs:6:9: 6:10 + } + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/byte_slice.rs:5:9: 5:10 + _1 = const b"foo"; // bb0[1]: scope 0 at $DIR/byte_slice.rs:5:13: 5:19 + // ty::Const + // + ty: &[u8; 3] + // + val: Value(Scalar(alloc0+0)) + // mir::Constant + // + span: $DIR/byte_slice.rs:5:13: 5:19 + // + literal: Const { ty: &[u8; 3], val: Value(Scalar(alloc0+0)) } + StorageLive(_2); // bb0[2]: scope 1 at $DIR/byte_slice.rs:6:9: 6:10 + _2 = [const 5u8, const 120u8]; // bb0[3]: scope 1 at $DIR/byte_slice.rs:6:13: 6:24 + // ty::Const + // + ty: u8 + // + val: Value(Scalar(0x05)) + // mir::Constant + // + span: $DIR/byte_slice.rs:6:14: 6:17 + // + literal: Const { ty: u8, val: Value(Scalar(0x05)) } + // ty::Const + // + ty: u8 + // + val: Value(Scalar(0x78)) + // mir::Constant + // + span: $DIR/byte_slice.rs:6:19: 6:23 + // + literal: Const { ty: u8, val: Value(Scalar(0x78)) } + _0 = (); // bb0[4]: scope 0 at $DIR/byte_slice.rs:4:11: 7:2 + StorageDead(_2); // bb0[5]: scope 1 at $DIR/byte_slice.rs:7:1: 7:2 + StorageDead(_1); // bb0[6]: scope 0 at $DIR/byte_slice.rs:7:1: 7:2 + return; // bb0[7]: scope 0 at $DIR/byte_slice.rs:7:2: 7:2 + } +} + +alloc0 (size: 3, align: 1) { + 66 6f 6f │ foo +} diff --git a/src/test/mir-opt/combine_array_len.rs b/src/test/mir-opt/combine_array_len.rs index 9a046202cd0..aa1c7459ea1 100644 --- a/src/test/mir-opt/combine_array_len.rs +++ b/src/test/mir-opt/combine_array_len.rs @@ -1,3 +1,6 @@ +// EMIT_MIR_FOR_EACH_BIT_WIDTH +// EMIT_MIR rustc.norm2.InstCombine.diff + fn norm2(x: [f32; 2]) -> f32 { let a = x[0]; let b = x[1]; @@ -7,17 +10,3 @@ fn norm2(x: [f32; 2]) -> f32 { fn main() { assert_eq!(norm2([3.0, 4.0]), 5.0*5.0); } - -// END RUST SOURCE - -// START rustc.norm2.InstCombine.before.mir -// _4 = Len(_1); -// ... -// _8 = Len(_1); -// END rustc.norm2.InstCombine.before.mir - -// START rustc.norm2.InstCombine.after.mir -// _4 = const 2usize; -// ... -// _8 = const 2usize; -// END rustc.norm2.InstCombine.after.mir diff --git a/src/test/mir-opt/combine_array_len/32bit/rustc.norm2.InstCombine.diff b/src/test/mir-opt/combine_array_len/32bit/rustc.norm2.InstCombine.diff new file mode 100644 index 00000000000..7ec1c9ac637 --- /dev/null +++ b/src/test/mir-opt/combine_array_len/32bit/rustc.norm2.InstCombine.diff @@ -0,0 +1,101 @@ +- // MIR for `norm2` before InstCombine ++ // MIR for `norm2` after InstCombine + + fn norm2(_1: [f32; 2]) -> f32 { + debug x => _1; // in scope 0 at $DIR/combine_array_len.rs:4:10: 4:11 + let mut _0: f32; // return place in scope 0 at $DIR/combine_array_len.rs:4:26: 4:29 + let _2: f32; // in scope 0 at $DIR/combine_array_len.rs:5:9: 5:10 + let _3: usize; // in scope 0 at $DIR/combine_array_len.rs:5:15: 5:16 + let mut _4: usize; // in scope 0 at $DIR/combine_array_len.rs:5:13: 5:17 + let mut _5: bool; // in scope 0 at $DIR/combine_array_len.rs:5:13: 5:17 + let _7: usize; // in scope 0 at $DIR/combine_array_len.rs:6:15: 6:16 + let mut _8: usize; // in scope 0 at $DIR/combine_array_len.rs:6:13: 6:17 + let mut _9: bool; // in scope 0 at $DIR/combine_array_len.rs:6:13: 6:17 + let mut _10: f32; // in scope 0 at $DIR/combine_array_len.rs:7:5: 7:8 + let mut _11: f32; // in scope 0 at $DIR/combine_array_len.rs:7:5: 7:6 + let mut _12: f32; // in scope 0 at $DIR/combine_array_len.rs:7:7: 7:8 + let mut _13: f32; // in scope 0 at $DIR/combine_array_len.rs:7:11: 7:14 + let mut _14: f32; // in scope 0 at $DIR/combine_array_len.rs:7:11: 7:12 + let mut _15: f32; // in scope 0 at $DIR/combine_array_len.rs:7:13: 7:14 + scope 1 { + debug a => _2; // in scope 1 at $DIR/combine_array_len.rs:5:9: 5:10 + let _6: f32; // in scope 1 at $DIR/combine_array_len.rs:6:9: 6:10 + scope 2 { + debug b => _6; // in scope 2 at $DIR/combine_array_len.rs:6:9: 6:10 + } + } + + bb0: { + StorageLive(_2); // bb0[0]: scope 0 at $DIR/combine_array_len.rs:5:9: 5:10 + StorageLive(_3); // bb0[1]: scope 0 at $DIR/combine_array_len.rs:5:15: 5:16 + _3 = const 0usize; // bb0[2]: scope 0 at $DIR/combine_array_len.rs:5:15: 5:16 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/combine_array_len.rs:5:15: 5:16 + // + literal: Const { ty: usize, val: Value(Scalar(0x00000000)) } +- _4 = Len(_1); // bb0[3]: scope 0 at $DIR/combine_array_len.rs:5:13: 5:17 ++ _4 = const 2usize; // bb0[3]: scope 0 at $DIR/combine_array_len.rs:5:13: 5:17 ++ // ty::Const ++ // + ty: usize ++ // + val: Value(Scalar(0x00000002)) ++ // mir::Constant ++ // + span: $DIR/combine_array_len.rs:5:13: 5:17 ++ // + literal: Const { ty: usize, val: Value(Scalar(0x00000002)) } + _5 = Lt(_3, _4); // bb0[4]: scope 0 at $DIR/combine_array_len.rs:5:13: 5:17 + assert(move _5, "index out of bounds: the len is move _4 but the index is _3") -> bb1; // bb0[5]: scope 0 at $DIR/combine_array_len.rs:5:13: 5:17 + } + + bb1: { + _2 = _1[_3]; // bb1[0]: scope 0 at $DIR/combine_array_len.rs:5:13: 5:17 + StorageDead(_3); // bb1[1]: scope 0 at $DIR/combine_array_len.rs:5:17: 5:18 + StorageLive(_6); // bb1[2]: scope 1 at $DIR/combine_array_len.rs:6:9: 6:10 + StorageLive(_7); // bb1[3]: scope 1 at $DIR/combine_array_len.rs:6:15: 6:16 + _7 = const 1usize; // bb1[4]: scope 1 at $DIR/combine_array_len.rs:6:15: 6:16 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/combine_array_len.rs:6:15: 6:16 + // + literal: Const { ty: usize, val: Value(Scalar(0x00000001)) } +- _8 = Len(_1); // bb1[5]: scope 1 at $DIR/combine_array_len.rs:6:13: 6:17 ++ _8 = const 2usize; // bb1[5]: scope 1 at $DIR/combine_array_len.rs:6:13: 6:17 ++ // ty::Const ++ // + ty: usize ++ // + val: Value(Scalar(0x00000002)) ++ // mir::Constant ++ // + span: $DIR/combine_array_len.rs:6:13: 6:17 ++ // + literal: Const { ty: usize, val: Value(Scalar(0x00000002)) } + _9 = Lt(_7, _8); // bb1[6]: scope 1 at $DIR/combine_array_len.rs:6:13: 6:17 + assert(move _9, "index out of bounds: the len is move _8 but the index is _7") -> bb2; // bb1[7]: scope 1 at $DIR/combine_array_len.rs:6:13: 6:17 + } + + bb2: { + _6 = _1[_7]; // bb2[0]: scope 1 at $DIR/combine_array_len.rs:6:13: 6:17 + StorageDead(_7); // bb2[1]: scope 1 at $DIR/combine_array_len.rs:6:17: 6:18 + StorageLive(_10); // bb2[2]: scope 2 at $DIR/combine_array_len.rs:7:5: 7:8 + StorageLive(_11); // bb2[3]: scope 2 at $DIR/combine_array_len.rs:7:5: 7:6 + _11 = _2; // bb2[4]: scope 2 at $DIR/combine_array_len.rs:7:5: 7:6 + StorageLive(_12); // bb2[5]: scope 2 at $DIR/combine_array_len.rs:7:7: 7:8 + _12 = _2; // bb2[6]: scope 2 at $DIR/combine_array_len.rs:7:7: 7:8 + _10 = Mul(move _11, move _12); // bb2[7]: scope 2 at $DIR/combine_array_len.rs:7:5: 7:8 + StorageDead(_12); // bb2[8]: scope 2 at $DIR/combine_array_len.rs:7:7: 7:8 + StorageDead(_11); // bb2[9]: scope 2 at $DIR/combine_array_len.rs:7:7: 7:8 + StorageLive(_13); // bb2[10]: scope 2 at $DIR/combine_array_len.rs:7:11: 7:14 + StorageLive(_14); // bb2[11]: scope 2 at $DIR/combine_array_len.rs:7:11: 7:12 + _14 = _6; // bb2[12]: scope 2 at $DIR/combine_array_len.rs:7:11: 7:12 + StorageLive(_15); // bb2[13]: scope 2 at $DIR/combine_array_len.rs:7:13: 7:14 + _15 = _6; // bb2[14]: scope 2 at $DIR/combine_array_len.rs:7:13: 7:14 + _13 = Mul(move _14, move _15); // bb2[15]: scope 2 at $DIR/combine_array_len.rs:7:11: 7:14 + StorageDead(_15); // bb2[16]: scope 2 at $DIR/combine_array_len.rs:7:13: 7:14 + StorageDead(_14); // bb2[17]: scope 2 at $DIR/combine_array_len.rs:7:13: 7:14 + _0 = Add(move _10, move _13); // bb2[18]: scope 2 at $DIR/combine_array_len.rs:7:5: 7:14 + StorageDead(_13); // bb2[19]: scope 2 at $DIR/combine_array_len.rs:7:13: 7:14 + StorageDead(_10); // bb2[20]: scope 2 at $DIR/combine_array_len.rs:7:13: 7:14 + StorageDead(_6); // bb2[21]: scope 1 at $DIR/combine_array_len.rs:8:1: 8:2 + StorageDead(_2); // bb2[22]: scope 0 at $DIR/combine_array_len.rs:8:1: 8:2 + return; // bb2[23]: scope 0 at $DIR/combine_array_len.rs:8:2: 8:2 + } + } + diff --git a/src/test/mir-opt/combine_array_len/64bit/rustc.norm2.InstCombine.diff b/src/test/mir-opt/combine_array_len/64bit/rustc.norm2.InstCombine.diff new file mode 100644 index 00000000000..0bab28738d8 --- /dev/null +++ b/src/test/mir-opt/combine_array_len/64bit/rustc.norm2.InstCombine.diff @@ -0,0 +1,101 @@ +- // MIR for `norm2` before InstCombine ++ // MIR for `norm2` after InstCombine + + fn norm2(_1: [f32; 2]) -> f32 { + debug x => _1; // in scope 0 at $DIR/combine_array_len.rs:4:10: 4:11 + let mut _0: f32; // return place in scope 0 at $DIR/combine_array_len.rs:4:26: 4:29 + let _2: f32; // in scope 0 at $DIR/combine_array_len.rs:5:9: 5:10 + let _3: usize; // in scope 0 at $DIR/combine_array_len.rs:5:15: 5:16 + let mut _4: usize; // in scope 0 at $DIR/combine_array_len.rs:5:13: 5:17 + let mut _5: bool; // in scope 0 at $DIR/combine_array_len.rs:5:13: 5:17 + let _7: usize; // in scope 0 at $DIR/combine_array_len.rs:6:15: 6:16 + let mut _8: usize; // in scope 0 at $DIR/combine_array_len.rs:6:13: 6:17 + let mut _9: bool; // in scope 0 at $DIR/combine_array_len.rs:6:13: 6:17 + let mut _10: f32; // in scope 0 at $DIR/combine_array_len.rs:7:5: 7:8 + let mut _11: f32; // in scope 0 at $DIR/combine_array_len.rs:7:5: 7:6 + let mut _12: f32; // in scope 0 at $DIR/combine_array_len.rs:7:7: 7:8 + let mut _13: f32; // in scope 0 at $DIR/combine_array_len.rs:7:11: 7:14 + let mut _14: f32; // in scope 0 at $DIR/combine_array_len.rs:7:11: 7:12 + let mut _15: f32; // in scope 0 at $DIR/combine_array_len.rs:7:13: 7:14 + scope 1 { + debug a => _2; // in scope 1 at $DIR/combine_array_len.rs:5:9: 5:10 + let _6: f32; // in scope 1 at $DIR/combine_array_len.rs:6:9: 6:10 + scope 2 { + debug b => _6; // in scope 2 at $DIR/combine_array_len.rs:6:9: 6:10 + } + } + + bb0: { + StorageLive(_2); // bb0[0]: scope 0 at $DIR/combine_array_len.rs:5:9: 5:10 + StorageLive(_3); // bb0[1]: scope 0 at $DIR/combine_array_len.rs:5:15: 5:16 + _3 = const 0usize; // bb0[2]: scope 0 at $DIR/combine_array_len.rs:5:15: 5:16 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000000)) + // mir::Constant + // + span: $DIR/combine_array_len.rs:5:15: 5:16 + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000000)) } +- _4 = Len(_1); // bb0[3]: scope 0 at $DIR/combine_array_len.rs:5:13: 5:17 ++ _4 = const 2usize; // bb0[3]: scope 0 at $DIR/combine_array_len.rs:5:13: 5:17 ++ // ty::Const ++ // + ty: usize ++ // + val: Value(Scalar(0x0000000000000002)) ++ // mir::Constant ++ // + span: $DIR/combine_array_len.rs:5:13: 5:17 ++ // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000002)) } + _5 = Lt(_3, _4); // bb0[4]: scope 0 at $DIR/combine_array_len.rs:5:13: 5:17 + assert(move _5, "index out of bounds: the len is move _4 but the index is _3") -> bb1; // bb0[5]: scope 0 at $DIR/combine_array_len.rs:5:13: 5:17 + } + + bb1: { + _2 = _1[_3]; // bb1[0]: scope 0 at $DIR/combine_array_len.rs:5:13: 5:17 + StorageDead(_3); // bb1[1]: scope 0 at $DIR/combine_array_len.rs:5:17: 5:18 + StorageLive(_6); // bb1[2]: scope 1 at $DIR/combine_array_len.rs:6:9: 6:10 + StorageLive(_7); // bb1[3]: scope 1 at $DIR/combine_array_len.rs:6:15: 6:16 + _7 = const 1usize; // bb1[4]: scope 1 at $DIR/combine_array_len.rs:6:15: 6:16 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000001)) + // mir::Constant + // + span: $DIR/combine_array_len.rs:6:15: 6:16 + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000001)) } +- _8 = Len(_1); // bb1[5]: scope 1 at $DIR/combine_array_len.rs:6:13: 6:17 ++ _8 = const 2usize; // bb1[5]: scope 1 at $DIR/combine_array_len.rs:6:13: 6:17 ++ // ty::Const ++ // + ty: usize ++ // + val: Value(Scalar(0x0000000000000002)) ++ // mir::Constant ++ // + span: $DIR/combine_array_len.rs:6:13: 6:17 ++ // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000002)) } + _9 = Lt(_7, _8); // bb1[6]: scope 1 at $DIR/combine_array_len.rs:6:13: 6:17 + assert(move _9, "index out of bounds: the len is move _8 but the index is _7") -> bb2; // bb1[7]: scope 1 at $DIR/combine_array_len.rs:6:13: 6:17 + } + + bb2: { + _6 = _1[_7]; // bb2[0]: scope 1 at $DIR/combine_array_len.rs:6:13: 6:17 + StorageDead(_7); // bb2[1]: scope 1 at $DIR/combine_array_len.rs:6:17: 6:18 + StorageLive(_10); // bb2[2]: scope 2 at $DIR/combine_array_len.rs:7:5: 7:8 + StorageLive(_11); // bb2[3]: scope 2 at $DIR/combine_array_len.rs:7:5: 7:6 + _11 = _2; // bb2[4]: scope 2 at $DIR/combine_array_len.rs:7:5: 7:6 + StorageLive(_12); // bb2[5]: scope 2 at $DIR/combine_array_len.rs:7:7: 7:8 + _12 = _2; // bb2[6]: scope 2 at $DIR/combine_array_len.rs:7:7: 7:8 + _10 = Mul(move _11, move _12); // bb2[7]: scope 2 at $DIR/combine_array_len.rs:7:5: 7:8 + StorageDead(_12); // bb2[8]: scope 2 at $DIR/combine_array_len.rs:7:7: 7:8 + StorageDead(_11); // bb2[9]: scope 2 at $DIR/combine_array_len.rs:7:7: 7:8 + StorageLive(_13); // bb2[10]: scope 2 at $DIR/combine_array_len.rs:7:11: 7:14 + StorageLive(_14); // bb2[11]: scope 2 at $DIR/combine_array_len.rs:7:11: 7:12 + _14 = _6; // bb2[12]: scope 2 at $DIR/combine_array_len.rs:7:11: 7:12 + StorageLive(_15); // bb2[13]: scope 2 at $DIR/combine_array_len.rs:7:13: 7:14 + _15 = _6; // bb2[14]: scope 2 at $DIR/combine_array_len.rs:7:13: 7:14 + _13 = Mul(move _14, move _15); // bb2[15]: scope 2 at $DIR/combine_array_len.rs:7:11: 7:14 + StorageDead(_15); // bb2[16]: scope 2 at $DIR/combine_array_len.rs:7:13: 7:14 + StorageDead(_14); // bb2[17]: scope 2 at $DIR/combine_array_len.rs:7:13: 7:14 + _0 = Add(move _10, move _13); // bb2[18]: scope 2 at $DIR/combine_array_len.rs:7:5: 7:14 + StorageDead(_13); // bb2[19]: scope 2 at $DIR/combine_array_len.rs:7:13: 7:14 + StorageDead(_10); // bb2[20]: scope 2 at $DIR/combine_array_len.rs:7:13: 7:14 + StorageDead(_6); // bb2[21]: scope 1 at $DIR/combine_array_len.rs:8:1: 8:2 + StorageDead(_2); // bb2[22]: scope 0 at $DIR/combine_array_len.rs:8:1: 8:2 + return; // bb2[23]: scope 0 at $DIR/combine_array_len.rs:8:2: 8:2 + } + } + diff --git a/src/test/mir-opt/const_prop/aggregate.rs b/src/test/mir-opt/const_prop/aggregate.rs index d04dcc6a05c..928ed8265d3 100644 --- a/src/test/mir-opt/const_prop/aggregate.rs +++ b/src/test/mir-opt/const_prop/aggregate.rs @@ -1,25 +1,6 @@ // compile-flags: -O +// EMIT_MIR rustc.main.ConstProp.diff fn main() { let x = (0, 1, 2).1 + 0; } - -// END RUST SOURCE -// START rustc.main.ConstProp.before.mir -// bb0: { -// ... -// _3 = (const 0i32, const 1i32, const 2i32); -// _2 = (_3.1: i32); -// _1 = Add(move _2, const 0i32); -// ... -// } -// END rustc.main.ConstProp.before.mir -// START rustc.main.ConstProp.after.mir -// bb0: { -// ... -// _3 = (const 0i32, const 1i32, const 2i32); -// _2 = const 1i32; -// _1 = const 1i32; -// ... -// } -// END rustc.main.ConstProp.after.mir diff --git a/src/test/mir-opt/const_prop/aggregate/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/aggregate/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..d20019287b0 --- /dev/null +++ b/src/test/mir-opt/const_prop/aggregate/rustc.main.ConstProp.diff @@ -0,0 +1,62 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/aggregate.rs:4:11: 4:11 + let _1: i32; // in scope 0 at $DIR/aggregate.rs:5:9: 5:10 + let mut _2: i32; // in scope 0 at $DIR/aggregate.rs:5:13: 5:24 + let mut _3: (i32, i32, i32); // in scope 0 at $DIR/aggregate.rs:5:13: 5:22 + scope 1 { + debug x => _1; // in scope 1 at $DIR/aggregate.rs:5:9: 5:10 + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/aggregate.rs:5:9: 5:10 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/aggregate.rs:5:13: 5:24 + StorageLive(_3); // bb0[2]: scope 0 at $DIR/aggregate.rs:5:13: 5:22 + _3 = (const 0i32, const 1i32, const 2i32); // bb0[3]: scope 0 at $DIR/aggregate.rs:5:13: 5:22 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/aggregate.rs:5:14: 5:15 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/aggregate.rs:5:17: 5:18 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/aggregate.rs:5:20: 5:21 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } +- _2 = (_3.1: i32); // bb0[4]: scope 0 at $DIR/aggregate.rs:5:13: 5:24 +- _1 = Add(move _2, const 0i32); // bb0[5]: scope 0 at $DIR/aggregate.rs:5:13: 5:28 ++ _2 = const 1i32; // bb0[4]: scope 0 at $DIR/aggregate.rs:5:13: 5:24 + // ty::Const + // + ty: i32 +- // + val: Value(Scalar(0x00000000)) ++ // + val: Value(Scalar(0x00000001)) + // mir::Constant +- // + span: $DIR/aggregate.rs:5:27: 5:28 +- // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } ++ // + span: $DIR/aggregate.rs:5:13: 5:24 ++ // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } ++ _1 = const 1i32; // bb0[5]: scope 0 at $DIR/aggregate.rs:5:13: 5:28 ++ // ty::Const ++ // + ty: i32 ++ // + val: Value(Scalar(0x00000001)) ++ // mir::Constant ++ // + span: $DIR/aggregate.rs:5:13: 5:28 ++ // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } + StorageDead(_2); // bb0[6]: scope 0 at $DIR/aggregate.rs:5:27: 5:28 + StorageDead(_3); // bb0[7]: scope 0 at $DIR/aggregate.rs:5:28: 5:29 + _0 = (); // bb0[8]: scope 0 at $DIR/aggregate.rs:4:11: 6:2 + StorageDead(_1); // bb0[9]: scope 0 at $DIR/aggregate.rs:6:1: 6:2 + return; // bb0[10]: scope 0 at $DIR/aggregate.rs:6:2: 6:2 + } + } + diff --git a/src/test/mir-opt/const_prop/array_index.rs b/src/test/mir-opt/const_prop/array_index.rs index 406585b5cab..9301e6f5d03 100644 --- a/src/test/mir-opt/const_prop/array_index.rs +++ b/src/test/mir-opt/const_prop/array_index.rs @@ -1,33 +1,6 @@ +// EMIT_MIR_FOR_EACH_BIT_WIDTH + +// EMIT_MIR rustc.main.ConstProp.diff fn main() { let x: u32 = [0, 1, 2, 3][2]; } - -// END RUST SOURCE -// START rustc.main.ConstProp.before.mir -// bb0: { -// ... -// _2 = [const 0u32, const 1u32, const 2u32, const 3u32]; -// ... -// _3 = const 2usize; -// _4 = const 4usize; -// _5 = Lt(_3, _4); -// assert(move _5, "index out of bounds: the len is move _4 but the index is _3") -> bb1; -// } -// bb1: { -// _1 = _2[_3]; -// ... -// return; -// } -// END rustc.main.ConstProp.before.mir -// START rustc.main.ConstProp.after.mir -// bb0: { -// ... -// _5 = const true; -// assert(const true, "index out of bounds: the len is move _4 but the index is _3") -> bb1; -// } -// bb1: { -// _1 = const 2u32; -// ... -// return; -// } -// END rustc.main.ConstProp.after.mir diff --git a/src/test/mir-opt/const_prop/array_index/32bit/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/array_index/32bit/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..f956ef82707 --- /dev/null +++ b/src/test/mir-opt/const_prop/array_index/32bit/rustc.main.ConstProp.diff @@ -0,0 +1,92 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/array_index.rs:4:11: 4:11 + let _1: u32 as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/array_index.rs:5:9: 5:10 + let mut _2: [u32; 4]; // in scope 0 at $DIR/array_index.rs:5:18: 5:30 + let _3: usize; // in scope 0 at $DIR/array_index.rs:5:31: 5:32 + let mut _4: usize; // in scope 0 at $DIR/array_index.rs:5:18: 5:33 + let mut _5: bool; // in scope 0 at $DIR/array_index.rs:5:18: 5:33 + scope 1 { + debug x => _1; // in scope 1 at $DIR/array_index.rs:5:9: 5:10 + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/array_index.rs:5:9: 5:10 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/array_index.rs:5:18: 5:30 + _2 = [const 0u32, const 1u32, const 2u32, const 3u32]; // bb0[2]: scope 0 at $DIR/array_index.rs:5:18: 5:30 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/array_index.rs:5:19: 5:20 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/array_index.rs:5:22: 5:23 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/array_index.rs:5:25: 5:26 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/array_index.rs:5:28: 5:29 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000003)) } + StorageLive(_3); // bb0[3]: scope 0 at $DIR/array_index.rs:5:31: 5:32 + _3 = const 2usize; // bb0[4]: scope 0 at $DIR/array_index.rs:5:31: 5:32 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/array_index.rs:5:31: 5:32 + // + literal: Const { ty: usize, val: Value(Scalar(0x00000002)) } + _4 = const 4usize; // bb0[5]: scope 0 at $DIR/array_index.rs:5:18: 5:33 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x00000004)) + // mir::Constant + // + span: $DIR/array_index.rs:5:18: 5:33 + // + literal: Const { ty: usize, val: Value(Scalar(0x00000004)) } +- _5 = Lt(_3, _4); // bb0[6]: scope 0 at $DIR/array_index.rs:5:18: 5:33 +- assert(move _5, "index out of bounds: the len is move _4 but the index is _3") -> bb1; // bb0[7]: scope 0 at $DIR/array_index.rs:5:18: 5:33 ++ _5 = const true; // bb0[6]: scope 0 at $DIR/array_index.rs:5:18: 5:33 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x01)) ++ // mir::Constant ++ // + span: $DIR/array_index.rs:5:18: 5:33 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } ++ assert(const true, "index out of bounds: the len is move _4 but the index is _3") -> bb1; // bb0[7]: scope 0 at $DIR/array_index.rs:5:18: 5:33 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x01)) ++ // mir::Constant ++ // + span: $DIR/array_index.rs:5:18: 5:33 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + } + + bb1: { +- _1 = _2[_3]; // bb1[0]: scope 0 at $DIR/array_index.rs:5:18: 5:33 ++ _1 = const 2u32; // bb1[0]: scope 0 at $DIR/array_index.rs:5:18: 5:33 ++ // ty::Const ++ // + ty: u32 ++ // + val: Value(Scalar(0x00000002)) ++ // mir::Constant ++ // + span: $DIR/array_index.rs:5:18: 5:33 ++ // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } + StorageDead(_3); // bb1[1]: scope 0 at $DIR/array_index.rs:5:33: 5:34 + StorageDead(_2); // bb1[2]: scope 0 at $DIR/array_index.rs:5:33: 5:34 + _0 = (); // bb1[3]: scope 0 at $DIR/array_index.rs:4:11: 6:2 + StorageDead(_1); // bb1[4]: scope 0 at $DIR/array_index.rs:6:1: 6:2 + return; // bb1[5]: scope 0 at $DIR/array_index.rs:6:2: 6:2 + } + } + diff --git a/src/test/mir-opt/const_prop/array_index/64bit/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/array_index/64bit/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..c336d6e66ae --- /dev/null +++ b/src/test/mir-opt/const_prop/array_index/64bit/rustc.main.ConstProp.diff @@ -0,0 +1,92 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/array_index.rs:4:11: 4:11 + let _1: u32 as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/array_index.rs:5:9: 5:10 + let mut _2: [u32; 4]; // in scope 0 at $DIR/array_index.rs:5:18: 5:30 + let _3: usize; // in scope 0 at $DIR/array_index.rs:5:31: 5:32 + let mut _4: usize; // in scope 0 at $DIR/array_index.rs:5:18: 5:33 + let mut _5: bool; // in scope 0 at $DIR/array_index.rs:5:18: 5:33 + scope 1 { + debug x => _1; // in scope 1 at $DIR/array_index.rs:5:9: 5:10 + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/array_index.rs:5:9: 5:10 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/array_index.rs:5:18: 5:30 + _2 = [const 0u32, const 1u32, const 2u32, const 3u32]; // bb0[2]: scope 0 at $DIR/array_index.rs:5:18: 5:30 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/array_index.rs:5:19: 5:20 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/array_index.rs:5:22: 5:23 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/array_index.rs:5:25: 5:26 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/array_index.rs:5:28: 5:29 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000003)) } + StorageLive(_3); // bb0[3]: scope 0 at $DIR/array_index.rs:5:31: 5:32 + _3 = const 2usize; // bb0[4]: scope 0 at $DIR/array_index.rs:5:31: 5:32 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000002)) + // mir::Constant + // + span: $DIR/array_index.rs:5:31: 5:32 + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000002)) } + _4 = const 4usize; // bb0[5]: scope 0 at $DIR/array_index.rs:5:18: 5:33 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000004)) + // mir::Constant + // + span: $DIR/array_index.rs:5:18: 5:33 + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000004)) } +- _5 = Lt(_3, _4); // bb0[6]: scope 0 at $DIR/array_index.rs:5:18: 5:33 +- assert(move _5, "index out of bounds: the len is move _4 but the index is _3") -> bb1; // bb0[7]: scope 0 at $DIR/array_index.rs:5:18: 5:33 ++ _5 = const true; // bb0[6]: scope 0 at $DIR/array_index.rs:5:18: 5:33 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x01)) ++ // mir::Constant ++ // + span: $DIR/array_index.rs:5:18: 5:33 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } ++ assert(const true, "index out of bounds: the len is move _4 but the index is _3") -> bb1; // bb0[7]: scope 0 at $DIR/array_index.rs:5:18: 5:33 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x01)) ++ // mir::Constant ++ // + span: $DIR/array_index.rs:5:18: 5:33 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + } + + bb1: { +- _1 = _2[_3]; // bb1[0]: scope 0 at $DIR/array_index.rs:5:18: 5:33 ++ _1 = const 2u32; // bb1[0]: scope 0 at $DIR/array_index.rs:5:18: 5:33 ++ // ty::Const ++ // + ty: u32 ++ // + val: Value(Scalar(0x00000002)) ++ // mir::Constant ++ // + span: $DIR/array_index.rs:5:18: 5:33 ++ // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } + StorageDead(_3); // bb1[1]: scope 0 at $DIR/array_index.rs:5:33: 5:34 + StorageDead(_2); // bb1[2]: scope 0 at $DIR/array_index.rs:5:33: 5:34 + _0 = (); // bb1[3]: scope 0 at $DIR/array_index.rs:4:11: 6:2 + StorageDead(_1); // bb1[4]: scope 0 at $DIR/array_index.rs:6:1: 6:2 + return; // bb1[5]: scope 0 at $DIR/array_index.rs:6:2: 6:2 + } + } + diff --git a/src/test/mir-opt/const_prop/boxes.rs b/src/test/mir-opt/const_prop/boxes.rs index cf134dadf27..d45804ebb6c 100644 --- a/src/test/mir-opt/const_prop/boxes.rs +++ b/src/test/mir-opt/const_prop/boxes.rs @@ -7,50 +7,7 @@ // Note: this test verifies that we, in fact, do not const prop `box` +// EMIT_MIR rustc.main.ConstProp.diff fn main() { let x = *(box 42) + 0; } - -// END RUST SOURCE -// START rustc.main.ConstProp.before.mir -// bb0: { -// ... -// _4 = Box(i32); -// (*_4) = const 42i32; -// _3 = move _4; -// ... -// _2 = (*_3); -// _1 = Add(move _2, const 0i32); -// ... -// drop(_3) -> [return: bb2, unwind: bb1]; -// } -// bb1 (cleanup): { -// resume; -// } -// bb2: { -// ... -// _0 = (); -// ... -// } -// END rustc.main.ConstProp.before.mir -// START rustc.main.ConstProp.after.mir -// bb0: { -// ... -// _4 = Box(i32); -// (*_4) = const 42i32; -// _3 = move _4; -// ... -// _2 = (*_3); -// _1 = Add(move _2, const 0i32); -// ... -// drop(_3) -> [return: bb2, unwind: bb1]; -// } -// bb1 (cleanup): { -// resume; -// } -// bb2: { -// ... -// _0 = (); -// ... -// } -// END rustc.main.ConstProp.after.mir diff --git a/src/test/mir-opt/const_prop/boxes/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/boxes/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..50ee2abecfe --- /dev/null +++ b/src/test/mir-opt/const_prop/boxes/rustc.main.ConstProp.diff @@ -0,0 +1,52 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/boxes.rs:11:11: 11:11 + let _1: i32; // in scope 0 at $DIR/boxes.rs:12:9: 12:10 + let mut _2: i32; // in scope 0 at $DIR/boxes.rs:12:13: 12:22 + let mut _3: std::boxed::Box<i32>; // in scope 0 at $DIR/boxes.rs:12:14: 12:22 + let mut _4: std::boxed::Box<i32>; // in scope 0 at $DIR/boxes.rs:12:14: 12:22 + scope 1 { + debug x => _1; // in scope 1 at $DIR/boxes.rs:12:9: 12:10 + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/boxes.rs:12:9: 12:10 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/boxes.rs:12:13: 12:22 + StorageLive(_3); // bb0[2]: scope 0 at $DIR/boxes.rs:12:14: 12:22 + StorageLive(_4); // bb0[3]: scope 0 at $DIR/boxes.rs:12:14: 12:22 + _4 = Box(i32); // bb0[4]: scope 0 at $DIR/boxes.rs:12:14: 12:22 + (*_4) = const 42i32; // bb0[5]: scope 0 at $DIR/boxes.rs:12:19: 12:21 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x0000002a)) + // mir::Constant + // + span: $DIR/boxes.rs:12:19: 12:21 + // + literal: Const { ty: i32, val: Value(Scalar(0x0000002a)) } + _3 = move _4; // bb0[6]: scope 0 at $DIR/boxes.rs:12:14: 12:22 + StorageDead(_4); // bb0[7]: scope 0 at $DIR/boxes.rs:12:21: 12:22 + _2 = (*_3); // bb0[8]: scope 0 at $DIR/boxes.rs:12:13: 12:22 + _1 = Add(move _2, const 0i32); // bb0[9]: scope 0 at $DIR/boxes.rs:12:13: 12:26 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/boxes.rs:12:25: 12:26 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } + StorageDead(_2); // bb0[10]: scope 0 at $DIR/boxes.rs:12:25: 12:26 + drop(_3) -> [return: bb2, unwind: bb1]; // bb0[11]: scope 0 at $DIR/boxes.rs:12:26: 12:27 + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/boxes.rs:11:1: 13:2 + } + + bb2: { + StorageDead(_3); // bb2[0]: scope 0 at $DIR/boxes.rs:12:26: 12:27 + _0 = (); // bb2[1]: scope 0 at $DIR/boxes.rs:11:11: 13:2 + StorageDead(_1); // bb2[2]: scope 0 at $DIR/boxes.rs:13:1: 13:2 + return; // bb2[3]: scope 0 at $DIR/boxes.rs:13:2: 13:2 + } + } + diff --git a/src/test/mir-opt/const_prop/checked_add.rs b/src/test/mir-opt/const_prop/checked_add.rs index fe98cf24eec..439bd2df91f 100644 --- a/src/test/mir-opt/const_prop/checked_add.rs +++ b/src/test/mir-opt/const_prop/checked_add.rs @@ -1,21 +1,6 @@ // compile-flags: -C overflow-checks=on +// EMIT_MIR rustc.main.ConstProp.diff fn main() { let x: u32 = 1 + 1; } - -// END RUST SOURCE -// START rustc.main.ConstProp.before.mir -// bb0: { -// ... -// _2 = CheckedAdd(const 1u32, const 1u32); -// assert(!move (_2.1: bool), "attempt to add with overflow") -> bb1; -// } -// END rustc.main.ConstProp.before.mir -// START rustc.main.ConstProp.after.mir -// bb0: { -// ... -// _2 = (const 2u32, const false); -// assert(!const false, "attempt to add with overflow") -> bb1; -// } -// END rustc.main.ConstProp.after.mir diff --git a/src/test/mir-opt/const_prop/checked_add/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/checked_add/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..0a0a4ff852f --- /dev/null +++ b/src/test/mir-opt/const_prop/checked_add/rustc.main.ConstProp.diff @@ -0,0 +1,59 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/checked_add.rs:4:11: 4:11 + let _1: u32 as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/checked_add.rs:5:9: 5:10 + let mut _2: (u32, bool); // in scope 0 at $DIR/checked_add.rs:5:18: 5:23 + scope 1 { + debug x => _1; // in scope 1 at $DIR/checked_add.rs:5:9: 5:10 + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/checked_add.rs:5:9: 5:10 +- _2 = CheckedAdd(const 1u32, const 1u32); // bb0[1]: scope 0 at $DIR/checked_add.rs:5:18: 5:23 ++ _2 = (const 2u32, const false); // bb0[1]: scope 0 at $DIR/checked_add.rs:5:18: 5:23 + // ty::Const + // + ty: u32 +- // + val: Value(Scalar(0x00000001)) ++ // + val: Value(Scalar(0x00000002)) + // mir::Constant +- // + span: $DIR/checked_add.rs:5:18: 5:19 +- // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) } ++ // + span: $DIR/checked_add.rs:5:18: 5:23 ++ // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } + // ty::Const +- // + ty: u32 +- // + val: Value(Scalar(0x00000001)) ++ // + ty: bool ++ // + val: Value(Scalar(0x00)) + // mir::Constant +- // + span: $DIR/checked_add.rs:5:22: 5:23 +- // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) } +- assert(!move (_2.1: bool), "attempt to add with overflow") -> bb1; // bb0[2]: scope 0 at $DIR/checked_add.rs:5:18: 5:23 ++ // + span: $DIR/checked_add.rs:5:18: 5:23 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } ++ assert(!const false, "attempt to add with overflow") -> bb1; // bb0[2]: scope 0 at $DIR/checked_add.rs:5:18: 5:23 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x00)) ++ // mir::Constant ++ // + span: $DIR/checked_add.rs:5:18: 5:23 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } + } + + bb1: { +- _1 = move (_2.0: u32); // bb1[0]: scope 0 at $DIR/checked_add.rs:5:18: 5:23 ++ _1 = const 2u32; // bb1[0]: scope 0 at $DIR/checked_add.rs:5:18: 5:23 ++ // ty::Const ++ // + ty: u32 ++ // + val: Value(Scalar(0x00000002)) ++ // mir::Constant ++ // + span: $DIR/checked_add.rs:5:18: 5:23 ++ // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } + _0 = (); // bb1[1]: scope 0 at $DIR/checked_add.rs:4:11: 6:2 + StorageDead(_1); // bb1[2]: scope 0 at $DIR/checked_add.rs:6:1: 6:2 + return; // bb1[3]: scope 0 at $DIR/checked_add.rs:6:2: 6:2 + } + } + diff --git a/src/test/mir-opt/const_prop/const_prop_fails_gracefully.rs b/src/test/mir-opt/const_prop/const_prop_fails_gracefully.rs index 3c8c0ff4493..c6c006c0809 100644 --- a/src/test/mir-opt/const_prop/const_prop_fails_gracefully.rs +++ b/src/test/mir-opt/const_prop/const_prop_fails_gracefully.rs @@ -1,31 +1,9 @@ #[inline(never)] fn read(_: usize) { } +// EMIT_MIR rustc.main.ConstProp.diff fn main() { const FOO: &i32 = &1; let x = FOO as *const i32 as usize; read(x); } - -// END RUST SOURCE -// START rustc.main.ConstProp.before.mir -// bb0: { -// ... -// _2 = &raw const (*_3); -// _1 = move _2 as usize (Misc); -// ... -// _5 = _1; -// _4 = const read(move _5) -> bb1; -// } -// END rustc.main.ConstProp.before.mir -// START rustc.main.ConstProp.after.mir -// bb0: { -// ... -// _3 = const main::FOO; -// _2 = &raw const (*_3); -// _1 = move _2 as usize (Misc); -// ... -// _5 = _1; -// _4 = const read(move _5) -> bb1; -// } -// END rustc.main.ConstProp.after.mir diff --git a/src/test/mir-opt/const_prop/const_prop_fails_gracefully/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/const_prop_fails_gracefully/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..f4a5b64f0d9 --- /dev/null +++ b/src/test/mir-opt/const_prop/const_prop_fails_gracefully/rustc.main.ConstProp.diff @@ -0,0 +1,50 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/const_prop_fails_gracefully.rs:5:11: 5:11 + let _1: usize; // in scope 0 at $DIR/const_prop_fails_gracefully.rs:7:9: 7:10 + let mut _2: *const i32; // in scope 0 at $DIR/const_prop_fails_gracefully.rs:7:13: 7:30 + let _3: &i32; // in scope 0 at $DIR/const_prop_fails_gracefully.rs:7:13: 7:16 + let _4: (); // in scope 0 at $DIR/const_prop_fails_gracefully.rs:8:5: 8:12 + let mut _5: usize; // in scope 0 at $DIR/const_prop_fails_gracefully.rs:8:10: 8:11 + scope 1 { + debug x => _1; // in scope 1 at $DIR/const_prop_fails_gracefully.rs:7:9: 7:10 + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/const_prop_fails_gracefully.rs:7:9: 7:10 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/const_prop_fails_gracefully.rs:7:13: 7:30 + StorageLive(_3); // bb0[2]: scope 0 at $DIR/const_prop_fails_gracefully.rs:7:13: 7:16 + _3 = const main::FOO; // bb0[3]: scope 0 at $DIR/const_prop_fails_gracefully.rs:7:13: 7:16 + // ty::Const + // + ty: &i32 + // + val: Unevaluated(DefId(0:5 ~ const_prop_fails_gracefully[317d]::main[0]::FOO[0]), [], None) + // mir::Constant + // + span: $DIR/const_prop_fails_gracefully.rs:7:13: 7:16 + // + literal: Const { ty: &i32, val: Unevaluated(DefId(0:5 ~ const_prop_fails_gracefully[317d]::main[0]::FOO[0]), [], None) } + _2 = &raw const (*_3); // bb0[4]: scope 0 at $DIR/const_prop_fails_gracefully.rs:7:13: 7:16 + _1 = move _2 as usize (Misc); // bb0[5]: scope 0 at $DIR/const_prop_fails_gracefully.rs:7:13: 7:39 + StorageDead(_2); // bb0[6]: scope 0 at $DIR/const_prop_fails_gracefully.rs:7:38: 7:39 + StorageDead(_3); // bb0[7]: scope 0 at $DIR/const_prop_fails_gracefully.rs:7:39: 7:40 + StorageLive(_4); // bb0[8]: scope 1 at $DIR/const_prop_fails_gracefully.rs:8:5: 8:12 + StorageLive(_5); // bb0[9]: scope 1 at $DIR/const_prop_fails_gracefully.rs:8:10: 8:11 + _5 = _1; // bb0[10]: scope 1 at $DIR/const_prop_fails_gracefully.rs:8:10: 8:11 + _4 = const read(move _5) -> bb1; // bb0[11]: scope 1 at $DIR/const_prop_fails_gracefully.rs:8:5: 8:12 + // ty::Const + // + ty: fn(usize) {read} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/const_prop_fails_gracefully.rs:8:5: 8:9 + // + literal: Const { ty: fn(usize) {read}, val: Value(Scalar(<ZST>)) } + } + + bb1: { + StorageDead(_5); // bb1[0]: scope 1 at $DIR/const_prop_fails_gracefully.rs:8:11: 8:12 + StorageDead(_4); // bb1[1]: scope 1 at $DIR/const_prop_fails_gracefully.rs:8:12: 8:13 + _0 = (); // bb1[2]: scope 0 at $DIR/const_prop_fails_gracefully.rs:5:11: 9:2 + StorageDead(_1); // bb1[3]: scope 0 at $DIR/const_prop_fails_gracefully.rs:9:1: 9:2 + return; // bb1[4]: scope 0 at $DIR/const_prop_fails_gracefully.rs:9:2: 9:2 + } + } + diff --git a/src/test/mir-opt/const_prop/control-flow-simplification.rs b/src/test/mir-opt/const_prop/control-flow-simplification.rs index 0e9f33b15e2..1071590dd9e 100644 --- a/src/test/mir-opt/const_prop/control-flow-simplification.rs +++ b/src/test/mir-opt/const_prop/control-flow-simplification.rs @@ -6,6 +6,8 @@ trait NeedsDrop:Sized{ impl<This> NeedsDrop for This{} +// EMIT_MIR rustc.hello.ConstProp.diff +// EMIT_MIR rustc.hello.PreCodegen.before.mir fn hello<T>(){ if <bool>::NEEDS { panic!() @@ -16,49 +18,3 @@ pub fn main() { hello::<()>(); hello::<Vec<()>>(); } - -// END RUST SOURCE -// START rustc.hello.ConstProp.before.mir -// let mut _0: (); -// let mut _1: bool; -// let mut _2: !; -// bb0: { -// StorageLive(_1); -// _1 = const <bool as NeedsDrop>::NEEDS; -// switchInt(_1) -> [false: bb1, otherwise: bb2]; -// } -// bb1: { -// _0 = (); -// StorageDead(_1); -// return; -// } -// bb2: { -// StorageLive(_2); -// const std::rt::begin_panic::<&str>(const "explicit panic"); -// } -// END rustc.hello.ConstProp.before.mir -// START rustc.hello.ConstProp.after.mir -// let mut _0: (); -// let mut _1: bool; -// let mut _2: !; -// bb0: { -// StorageLive(_1); -// _1 = const false; -// switchInt(const false) -> [false: bb1, otherwise: bb2]; -// } -// bb1: { -// _0 = (); -// StorageDead(_1); -// return; -// } -// bb2: { -// StorageLive(_2); -// const std::rt::begin_panic::<&str>(const "explicit panic"); -// } -// END rustc.hello.ConstProp.after.mir -// START rustc.hello.PreCodegen.before.mir -// let mut _0: (); -// bb0: { -// return; -// } -// END rustc.hello.PreCodegen.before.mir diff --git a/src/test/mir-opt/const_prop/control-flow-simplification/rustc.hello.ConstProp.diff b/src/test/mir-opt/const_prop/control-flow-simplification/rustc.hello.ConstProp.diff new file mode 100644 index 00000000000..c551bd77d40 --- /dev/null +++ b/src/test/mir-opt/const_prop/control-flow-simplification/rustc.hello.ConstProp.diff @@ -0,0 +1,54 @@ +- // MIR for `hello` before ConstProp ++ // MIR for `hello` after ConstProp + + fn hello() -> () { + let mut _0: (); // return place in scope 0 at $DIR/control-flow-simplification.rs:11:14: 11:14 + let mut _1: bool; // in scope 0 at $DIR/control-flow-simplification.rs:12:8: 12:21 + let mut _2: !; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/control-flow-simplification.rs:12:8: 12:21 +- _1 = const <bool as NeedsDrop>::NEEDS; // bb0[1]: scope 0 at $DIR/control-flow-simplification.rs:12:8: 12:21 ++ _1 = const false; // bb0[1]: scope 0 at $DIR/control-flow-simplification.rs:12:8: 12:21 + // ty::Const + // + ty: bool +- // + val: Unevaluated(DefId(0:4 ~ control_flow_simplification[317d]::NeedsDrop[0]::NEEDS[0]), [bool], None) ++ // + val: Value(Scalar(0x00)) + // mir::Constant + // + span: $DIR/control-flow-simplification.rs:12:8: 12:21 +- // + literal: Const { ty: bool, val: Unevaluated(DefId(0:4 ~ control_flow_simplification[317d]::NeedsDrop[0]::NEEDS[0]), [bool], None) } +- switchInt(_1) -> [false: bb1, otherwise: bb2]; // bb0[2]: scope 0 at $DIR/control-flow-simplification.rs:12:5: 14:6 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } ++ switchInt(const false) -> [false: bb1, otherwise: bb2]; // bb0[2]: scope 0 at $DIR/control-flow-simplification.rs:12:5: 14:6 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x00)) ++ // mir::Constant ++ // + span: $DIR/control-flow-simplification.rs:12:5: 14:6 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } + } + + bb1: { + _0 = (); // bb1[0]: scope 0 at $DIR/control-flow-simplification.rs:12:5: 14:6 + StorageDead(_1); // bb1[1]: scope 0 at $DIR/control-flow-simplification.rs:15:1: 15:2 + return; // bb1[2]: scope 0 at $DIR/control-flow-simplification.rs:15:2: 15:2 + } + + bb2: { + StorageLive(_2); // bb2[0]: scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + const std::rt::begin_panic::<&str>(const "explicit panic"); // bb2[1]: scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + // ty::Const + // + ty: fn(&str) -> ! {std::rt::begin_panic::<&str>} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $SRC_DIR/libstd/macros.rs:LL:COL + // + literal: Const { ty: fn(&str) -> ! {std::rt::begin_panic::<&str>}, val: Value(Scalar(<ZST>)) } + // ty::Const + // + ty: &str + // + val: Value(Slice { data: Allocation { bytes: [101, 120, 112, 108, 105, 99, 105, 116, 32, 112, 97, 110, 105, 99], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [16383], len: Size { raw: 14 } }, size: Size { raw: 14 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 14 }) + // mir::Constant + // + span: $SRC_DIR/libstd/macros.rs:LL:COL + // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [101, 120, 112, 108, 105, 99, 105, 116, 32, 112, 97, 110, 105, 99], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [16383], len: Size { raw: 14 } }, size: Size { raw: 14 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 14 }) } + } + } + diff --git a/src/test/mir-opt/const_prop/control-flow-simplification/rustc.hello.PreCodegen.before.mir b/src/test/mir-opt/const_prop/control-flow-simplification/rustc.hello.PreCodegen.before.mir new file mode 100644 index 00000000000..53296f8714b --- /dev/null +++ b/src/test/mir-opt/const_prop/control-flow-simplification/rustc.hello.PreCodegen.before.mir @@ -0,0 +1,9 @@ +// MIR for `hello` before PreCodegen + +fn hello() -> () { + let mut _0: (); // return place in scope 0 at $DIR/control-flow-simplification.rs:11:14: 11:14 + + bb0: { + return; // bb0[0]: scope 0 at $DIR/control-flow-simplification.rs:15:2: 15:2 + } +} diff --git a/src/test/mir-opt/const_prop/discriminant.rs b/src/test/mir-opt/const_prop/discriminant.rs index 636aa1af653..04541b94ad7 100644 --- a/src/test/mir-opt/const_prop/discriminant.rs +++ b/src/test/mir-opt/const_prop/discriminant.rs @@ -1,53 +1,7 @@ // compile-flags: -O +// EMIT_MIR_FOR_EACH_BIT_WIDTH +// EMIT_MIR rustc.main.ConstProp.diff fn main() { let x = (if let Some(true) = Some(true) { 42 } else { 10 }) + 0; } - -// END RUST SOURCE -// START rustc.main.ConstProp.before.mir -// bb0: { -// ... -// _3 = std::option::Option::<bool>::Some(const true,); -// _4 = discriminant(_3); -// switchInt(move _4) -> [1isize: bb2, otherwise: bb1]; -// } -// bb1: { -// _2 = const 10i32; -// goto -> bb4; -// } -// bb2: { -// switchInt(((_3 as Some).0: bool)) -> [false: bb1, otherwise: bb3]; -// } -// bb3: { -// _2 = const 42i32; -// goto -> bb4; -// } -// bb4: { -// _1 = Add(move _2, const 0i32); -// ... -// } -// END rustc.main.ConstProp.before.mir -// START rustc.main.ConstProp.after.mir -// bb0: { -// ... -// _3 = const {transmute(0x01): std::option::Option<bool>}; -// _4 = const 1isize; -// switchInt(const 1isize) -> [1isize: bb2, otherwise: bb1]; -// } -// bb1: { -// _2 = const 10i32; -// goto -> bb4; -// } -// bb2: { -// switchInt(const true) -> [false: bb1, otherwise: bb3]; -// } -// bb3: { -// _2 = const 42i32; -// goto -> bb4; -// } -// bb4: { -// _1 = Add(move _2, const 0i32); -// ... -// } -// END rustc.main.ConstProp.after.mir diff --git a/src/test/mir-opt/const_prop/discriminant/32bit/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/discriminant/32bit/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..7423a3cd38d --- /dev/null +++ b/src/test/mir-opt/const_prop/discriminant/32bit/rustc.main.ConstProp.diff @@ -0,0 +1,95 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/discriminant.rs:5:11: 5:11 + let _1: i32; // in scope 0 at $DIR/discriminant.rs:6:9: 6:10 + let mut _2: i32; // in scope 0 at $DIR/discriminant.rs:6:13: 6:64 + let mut _3: std::option::Option<bool>; // in scope 0 at $DIR/discriminant.rs:6:34: 6:44 + let mut _4: isize; // in scope 0 at $DIR/discriminant.rs:6:21: 6:31 + scope 1 { + debug x => _1; // in scope 1 at $DIR/discriminant.rs:6:9: 6:10 + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/discriminant.rs:6:9: 6:10 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/discriminant.rs:6:13: 6:64 + StorageLive(_3); // bb0[2]: scope 0 at $DIR/discriminant.rs:6:34: 6:44 +- _3 = std::option::Option::<bool>::Some(const true,); // bb0[3]: scope 0 at $DIR/discriminant.rs:6:34: 6:44 ++ _3 = const {transmute(0x01): std::option::Option<bool>}; // bb0[3]: scope 0 at $DIR/discriminant.rs:6:34: 6:44 + // ty::Const +- // + ty: bool ++ // + ty: std::option::Option<bool> + // + val: Value(Scalar(0x01)) + // mir::Constant +- // + span: $DIR/discriminant.rs:6:39: 6:43 +- // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } +- _4 = discriminant(_3); // bb0[4]: scope 0 at $DIR/discriminant.rs:6:21: 6:31 +- switchInt(move _4) -> [1isize: bb2, otherwise: bb1]; // bb0[5]: scope 0 at $DIR/discriminant.rs:6:21: 6:31 ++ // + span: $DIR/discriminant.rs:6:34: 6:44 ++ // + literal: Const { ty: std::option::Option<bool>, val: Value(Scalar(0x01)) } ++ _4 = const 1isize; // bb0[4]: scope 0 at $DIR/discriminant.rs:6:21: 6:31 ++ // ty::Const ++ // + ty: isize ++ // + val: Value(Scalar(0x00000001)) ++ // mir::Constant ++ // + span: $DIR/discriminant.rs:6:21: 6:31 ++ // + literal: Const { ty: isize, val: Value(Scalar(0x00000001)) } ++ switchInt(const 1isize) -> [1isize: bb2, otherwise: bb1]; // bb0[5]: scope 0 at $DIR/discriminant.rs:6:21: 6:31 ++ // ty::Const ++ // + ty: isize ++ // + val: Value(Scalar(0x00000001)) ++ // mir::Constant ++ // + span: $DIR/discriminant.rs:6:21: 6:31 ++ // + literal: Const { ty: isize, val: Value(Scalar(0x00000001)) } + } + + bb1: { + _2 = const 10i32; // bb1[0]: scope 0 at $DIR/discriminant.rs:6:59: 6:61 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x0000000a)) + // mir::Constant + // + span: $DIR/discriminant.rs:6:59: 6:61 + // + literal: Const { ty: i32, val: Value(Scalar(0x0000000a)) } + goto -> bb4; // bb1[1]: scope 0 at $DIR/discriminant.rs:6:13: 6:64 + } + + bb2: { +- switchInt(((_3 as Some).0: bool)) -> [false: bb1, otherwise: bb3]; // bb2[0]: scope 0 at $DIR/discriminant.rs:6:26: 6:30 ++ switchInt(const true) -> [false: bb1, otherwise: bb3]; // bb2[0]: scope 0 at $DIR/discriminant.rs:6:26: 6:30 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x01)) ++ // mir::Constant ++ // + span: $DIR/discriminant.rs:6:26: 6:30 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + } + + bb3: { + _2 = const 42i32; // bb3[0]: scope 0 at $DIR/discriminant.rs:6:47: 6:49 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x0000002a)) + // mir::Constant + // + span: $DIR/discriminant.rs:6:47: 6:49 + // + literal: Const { ty: i32, val: Value(Scalar(0x0000002a)) } + goto -> bb4; // bb3[1]: scope 0 at $DIR/discriminant.rs:6:13: 6:64 + } + + bb4: { + _1 = Add(move _2, const 0i32); // bb4[0]: scope 0 at $DIR/discriminant.rs:6:13: 6:68 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/discriminant.rs:6:67: 6:68 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } + StorageDead(_2); // bb4[1]: scope 0 at $DIR/discriminant.rs:6:67: 6:68 + StorageDead(_3); // bb4[2]: scope 0 at $DIR/discriminant.rs:6:68: 6:69 + _0 = (); // bb4[3]: scope 0 at $DIR/discriminant.rs:5:11: 7:2 + StorageDead(_1); // bb4[4]: scope 0 at $DIR/discriminant.rs:7:1: 7:2 + return; // bb4[5]: scope 0 at $DIR/discriminant.rs:7:2: 7:2 + } + } + diff --git a/src/test/mir-opt/const_prop/discriminant/64bit/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/discriminant/64bit/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..60d18cdc942 --- /dev/null +++ b/src/test/mir-opt/const_prop/discriminant/64bit/rustc.main.ConstProp.diff @@ -0,0 +1,95 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/discriminant.rs:5:11: 5:11 + let _1: i32; // in scope 0 at $DIR/discriminant.rs:6:9: 6:10 + let mut _2: i32; // in scope 0 at $DIR/discriminant.rs:6:13: 6:64 + let mut _3: std::option::Option<bool>; // in scope 0 at $DIR/discriminant.rs:6:34: 6:44 + let mut _4: isize; // in scope 0 at $DIR/discriminant.rs:6:21: 6:31 + scope 1 { + debug x => _1; // in scope 1 at $DIR/discriminant.rs:6:9: 6:10 + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/discriminant.rs:6:9: 6:10 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/discriminant.rs:6:13: 6:64 + StorageLive(_3); // bb0[2]: scope 0 at $DIR/discriminant.rs:6:34: 6:44 +- _3 = std::option::Option::<bool>::Some(const true,); // bb0[3]: scope 0 at $DIR/discriminant.rs:6:34: 6:44 ++ _3 = const {transmute(0x01): std::option::Option<bool>}; // bb0[3]: scope 0 at $DIR/discriminant.rs:6:34: 6:44 + // ty::Const +- // + ty: bool ++ // + ty: std::option::Option<bool> + // + val: Value(Scalar(0x01)) + // mir::Constant +- // + span: $DIR/discriminant.rs:6:39: 6:43 +- // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } +- _4 = discriminant(_3); // bb0[4]: scope 0 at $DIR/discriminant.rs:6:21: 6:31 +- switchInt(move _4) -> [1isize: bb2, otherwise: bb1]; // bb0[5]: scope 0 at $DIR/discriminant.rs:6:21: 6:31 ++ // + span: $DIR/discriminant.rs:6:34: 6:44 ++ // + literal: Const { ty: std::option::Option<bool>, val: Value(Scalar(0x01)) } ++ _4 = const 1isize; // bb0[4]: scope 0 at $DIR/discriminant.rs:6:21: 6:31 ++ // ty::Const ++ // + ty: isize ++ // + val: Value(Scalar(0x0000000000000001)) ++ // mir::Constant ++ // + span: $DIR/discriminant.rs:6:21: 6:31 ++ // + literal: Const { ty: isize, val: Value(Scalar(0x0000000000000001)) } ++ switchInt(const 1isize) -> [1isize: bb2, otherwise: bb1]; // bb0[5]: scope 0 at $DIR/discriminant.rs:6:21: 6:31 ++ // ty::Const ++ // + ty: isize ++ // + val: Value(Scalar(0x0000000000000001)) ++ // mir::Constant ++ // + span: $DIR/discriminant.rs:6:21: 6:31 ++ // + literal: Const { ty: isize, val: Value(Scalar(0x0000000000000001)) } + } + + bb1: { + _2 = const 10i32; // bb1[0]: scope 0 at $DIR/discriminant.rs:6:59: 6:61 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x0000000a)) + // mir::Constant + // + span: $DIR/discriminant.rs:6:59: 6:61 + // + literal: Const { ty: i32, val: Value(Scalar(0x0000000a)) } + goto -> bb4; // bb1[1]: scope 0 at $DIR/discriminant.rs:6:13: 6:64 + } + + bb2: { +- switchInt(((_3 as Some).0: bool)) -> [false: bb1, otherwise: bb3]; // bb2[0]: scope 0 at $DIR/discriminant.rs:6:26: 6:30 ++ switchInt(const true) -> [false: bb1, otherwise: bb3]; // bb2[0]: scope 0 at $DIR/discriminant.rs:6:26: 6:30 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x01)) ++ // mir::Constant ++ // + span: $DIR/discriminant.rs:6:26: 6:30 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + } + + bb3: { + _2 = const 42i32; // bb3[0]: scope 0 at $DIR/discriminant.rs:6:47: 6:49 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x0000002a)) + // mir::Constant + // + span: $DIR/discriminant.rs:6:47: 6:49 + // + literal: Const { ty: i32, val: Value(Scalar(0x0000002a)) } + goto -> bb4; // bb3[1]: scope 0 at $DIR/discriminant.rs:6:13: 6:64 + } + + bb4: { + _1 = Add(move _2, const 0i32); // bb4[0]: scope 0 at $DIR/discriminant.rs:6:13: 6:68 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/discriminant.rs:6:67: 6:68 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } + StorageDead(_2); // bb4[1]: scope 0 at $DIR/discriminant.rs:6:67: 6:68 + StorageDead(_3); // bb4[2]: scope 0 at $DIR/discriminant.rs:6:68: 6:69 + _0 = (); // bb4[3]: scope 0 at $DIR/discriminant.rs:5:11: 7:2 + StorageDead(_1); // bb4[4]: scope 0 at $DIR/discriminant.rs:7:1: 7:2 + return; // bb4[5]: scope 0 at $DIR/discriminant.rs:7:2: 7:2 + } + } + diff --git a/src/test/mir-opt/const_prop/indirect.rs b/src/test/mir-opt/const_prop/indirect.rs index b4ee18ed1b5..961e4447d8b 100644 --- a/src/test/mir-opt/const_prop/indirect.rs +++ b/src/test/mir-opt/const_prop/indirect.rs @@ -1,23 +1,6 @@ // compile-flags: -C overflow-checks=on +// EMIT_MIR rustc.main.ConstProp.diff fn main() { let x = (2u32 as u8) + 1; } - -// END RUST SOURCE -// START rustc.main.ConstProp.before.mir -// bb0: { -// ... -// _2 = const 2u32 as u8 (Misc); -// _3 = CheckedAdd(move _2, const 1u8); -// assert(!move (_3.1: bool), "attempt to add with overflow") -> bb1; -//} -// END rustc.main.ConstProp.before.mir -// START rustc.main.ConstProp.after.mir -// bb0: { -// ... -// _2 = const 2u8; -// _3 = (const 3u8, const false); -// assert(!const false, "attempt to add with overflow") -> bb1; -// } -// END rustc.main.ConstProp.after.mir diff --git a/src/test/mir-opt/const_prop/indirect/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/indirect/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..ca3e3bb5d2d --- /dev/null +++ b/src/test/mir-opt/const_prop/indirect/rustc.main.ConstProp.diff @@ -0,0 +1,70 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/indirect.rs:4:11: 4:11 + let _1: u8; // in scope 0 at $DIR/indirect.rs:5:9: 5:10 + let mut _2: u8; // in scope 0 at $DIR/indirect.rs:5:13: 5:25 + let mut _3: (u8, bool); // in scope 0 at $DIR/indirect.rs:5:13: 5:29 + scope 1 { + debug x => _1; // in scope 1 at $DIR/indirect.rs:5:9: 5:10 + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/indirect.rs:5:9: 5:10 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/indirect.rs:5:13: 5:25 +- _2 = const 2u32 as u8 (Misc); // bb0[2]: scope 0 at $DIR/indirect.rs:5:13: 5:25 ++ _2 = const 2u8; // bb0[2]: scope 0 at $DIR/indirect.rs:5:13: 5:25 + // ty::Const +- // + ty: u32 +- // + val: Value(Scalar(0x00000002)) ++ // + ty: u8 ++ // + val: Value(Scalar(0x02)) + // mir::Constant +- // + span: $DIR/indirect.rs:5:14: 5:18 +- // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } +- _3 = CheckedAdd(move _2, const 1u8); // bb0[3]: scope 0 at $DIR/indirect.rs:5:13: 5:29 ++ // + span: $DIR/indirect.rs:5:13: 5:25 ++ // + literal: Const { ty: u8, val: Value(Scalar(0x02)) } ++ _3 = (const 3u8, const false); // bb0[3]: scope 0 at $DIR/indirect.rs:5:13: 5:29 + // ty::Const + // + ty: u8 +- // + val: Value(Scalar(0x01)) ++ // + val: Value(Scalar(0x03)) + // mir::Constant +- // + span: $DIR/indirect.rs:5:28: 5:29 +- // + literal: Const { ty: u8, val: Value(Scalar(0x01)) } +- assert(!move (_3.1: bool), "attempt to add with overflow") -> bb1; // bb0[4]: scope 0 at $DIR/indirect.rs:5:13: 5:29 ++ // + span: $DIR/indirect.rs:5:13: 5:29 ++ // + literal: Const { ty: u8, val: Value(Scalar(0x03)) } ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x00)) ++ // mir::Constant ++ // + span: $DIR/indirect.rs:5:13: 5:29 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } ++ assert(!const false, "attempt to add with overflow") -> bb1; // bb0[4]: scope 0 at $DIR/indirect.rs:5:13: 5:29 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x00)) ++ // mir::Constant ++ // + span: $DIR/indirect.rs:5:13: 5:29 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } + } + + bb1: { +- _1 = move (_3.0: u8); // bb1[0]: scope 0 at $DIR/indirect.rs:5:13: 5:29 ++ _1 = const 3u8; // bb1[0]: scope 0 at $DIR/indirect.rs:5:13: 5:29 ++ // ty::Const ++ // + ty: u8 ++ // + val: Value(Scalar(0x03)) ++ // mir::Constant ++ // + span: $DIR/indirect.rs:5:13: 5:29 ++ // + literal: Const { ty: u8, val: Value(Scalar(0x03)) } + StorageDead(_2); // bb1[1]: scope 0 at $DIR/indirect.rs:5:28: 5:29 + _0 = (); // bb1[2]: scope 0 at $DIR/indirect.rs:4:11: 6:2 + StorageDead(_1); // bb1[3]: scope 0 at $DIR/indirect.rs:6:1: 6:2 + return; // bb1[4]: scope 0 at $DIR/indirect.rs:6:2: 6:2 + } + } + diff --git a/src/test/mir-opt/const_prop/issue-66971.rs b/src/test/mir-opt/const_prop/issue-66971.rs index f332bb89509..50a1405b77b 100644 --- a/src/test/mir-opt/const_prop/issue-66971.rs +++ b/src/test/mir-opt/const_prop/issue-66971.rs @@ -11,28 +11,7 @@ fn encode(this: ((), u8, u8)) { assert!(this.2 == 0); } +// EMIT_MIR rustc.main.ConstProp.diff fn main() { encode(((), 0, 0)); } - -// END RUST SOURCE -// START rustc.main.ConstProp.before.mir -// bb0: { -// ... -// _3 = (); -// _2 = (move _3, const 0u8, const 0u8); -// ... -// _1 = const encode(move _2) -> bb1; -// ... -// } -// END rustc.main.ConstProp.before.mir -// START rustc.main.ConstProp.after.mir -// bb0: { -// ... -// _3 = const (); -// _2 = (move _3, const 0u8, const 0u8); -// ... -// _1 = const encode(move _2) -> bb1; -// ... -// } -// END rustc.main.ConstProp.after.mir diff --git a/src/test/mir-opt/const_prop/issue-66971/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/issue-66971/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..d3ebaa0a632 --- /dev/null +++ b/src/test/mir-opt/const_prop/issue-66971/rustc.main.ConstProp.diff @@ -0,0 +1,52 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/issue-66971.rs:15:11: 15:11 + let _1: (); // in scope 0 at $DIR/issue-66971.rs:16:5: 16:23 + let mut _2: ((), u8, u8); // in scope 0 at $DIR/issue-66971.rs:16:12: 16:22 + let mut _3: (); // in scope 0 at $DIR/issue-66971.rs:16:13: 16:15 + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/issue-66971.rs:16:5: 16:23 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/issue-66971.rs:16:12: 16:22 + StorageLive(_3); // bb0[2]: scope 0 at $DIR/issue-66971.rs:16:13: 16:15 +- _3 = (); // bb0[3]: scope 0 at $DIR/issue-66971.rs:16:13: 16:15 ++ _3 = const (); // bb0[3]: scope 0 at $DIR/issue-66971.rs:16:13: 16:15 ++ // ty::Const ++ // + ty: () ++ // + val: Value(Scalar(<ZST>)) ++ // mir::Constant ++ // + span: $DIR/issue-66971.rs:16:13: 16:15 ++ // + literal: Const { ty: (), val: Value(Scalar(<ZST>)) } + _2 = (move _3, const 0u8, const 0u8); // bb0[4]: scope 0 at $DIR/issue-66971.rs:16:12: 16:22 + // ty::Const + // + ty: u8 + // + val: Value(Scalar(0x00)) + // mir::Constant + // + span: $DIR/issue-66971.rs:16:17: 16:18 + // + literal: Const { ty: u8, val: Value(Scalar(0x00)) } + // ty::Const + // + ty: u8 + // + val: Value(Scalar(0x00)) + // mir::Constant + // + span: $DIR/issue-66971.rs:16:20: 16:21 + // + literal: Const { ty: u8, val: Value(Scalar(0x00)) } + StorageDead(_3); // bb0[5]: scope 0 at $DIR/issue-66971.rs:16:21: 16:22 + _1 = const encode(move _2) -> bb1; // bb0[6]: scope 0 at $DIR/issue-66971.rs:16:5: 16:23 + // ty::Const + // + ty: fn(((), u8, u8)) {encode} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/issue-66971.rs:16:5: 16:11 + // + literal: Const { ty: fn(((), u8, u8)) {encode}, val: Value(Scalar(<ZST>)) } + } + + bb1: { + StorageDead(_2); // bb1[0]: scope 0 at $DIR/issue-66971.rs:16:22: 16:23 + StorageDead(_1); // bb1[1]: scope 0 at $DIR/issue-66971.rs:16:23: 16:24 + _0 = (); // bb1[2]: scope 0 at $DIR/issue-66971.rs:15:11: 17:2 + return; // bb1[3]: scope 0 at $DIR/issue-66971.rs:17:2: 17:2 + } + } + diff --git a/src/test/mir-opt/const_prop/issue-67019.rs b/src/test/mir-opt/const_prop/issue-67019.rs index c6d753a1209..3c832eb1344 100644 --- a/src/test/mir-opt/const_prop/issue-67019.rs +++ b/src/test/mir-opt/const_prop/issue-67019.rs @@ -6,29 +6,7 @@ fn test(this: ((u8, u8),)) { assert!((this.0).0 == 1); } +// EMIT_MIR rustc.main.ConstProp.diff fn main() { test(((1, 2),)); } - -// Important bit is parameter passing so we only check that below -// END RUST SOURCE -// START rustc.main.ConstProp.before.mir -// bb0: { -// ... -// _3 = (const 1u8, const 2u8); -// _2 = (move _3,); -// ... -// _1 = const test(move _2) -> bb1; -// ... -// } -// END rustc.main.ConstProp.before.mir -// START rustc.main.ConstProp.after.mir -// bb0: { -// ... -// _3 = (const 1u8, const 2u8); -// _2 = (move _3,); -// ... -// _1 = const test(move _2) -> bb1; -// ... -// } -// END rustc.main.ConstProp.after.mir diff --git a/src/test/mir-opt/const_prop/issue-67019/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/issue-67019/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..96a20edd91a --- /dev/null +++ b/src/test/mir-opt/const_prop/issue-67019/rustc.main.ConstProp.diff @@ -0,0 +1,47 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/issue-67019.rs:10:11: 10:11 + let _1: (); // in scope 0 at $DIR/issue-67019.rs:11:5: 11:20 + let mut _2: ((u8, u8),); // in scope 0 at $DIR/issue-67019.rs:11:10: 11:19 + let mut _3: (u8, u8); // in scope 0 at $DIR/issue-67019.rs:11:11: 11:17 + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/issue-67019.rs:11:5: 11:20 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/issue-67019.rs:11:10: 11:19 + StorageLive(_3); // bb0[2]: scope 0 at $DIR/issue-67019.rs:11:11: 11:17 + _3 = (const 1u8, const 2u8); // bb0[3]: scope 0 at $DIR/issue-67019.rs:11:11: 11:17 + // ty::Const + // + ty: u8 + // + val: Value(Scalar(0x01)) + // mir::Constant +- // + span: $DIR/issue-67019.rs:11:12: 11:13 ++ // + span: $DIR/issue-67019.rs:11:11: 11:17 + // + literal: Const { ty: u8, val: Value(Scalar(0x01)) } + // ty::Const + // + ty: u8 + // + val: Value(Scalar(0x02)) + // mir::Constant +- // + span: $DIR/issue-67019.rs:11:15: 11:16 ++ // + span: $DIR/issue-67019.rs:11:11: 11:17 + // + literal: Const { ty: u8, val: Value(Scalar(0x02)) } + _2 = (move _3,); // bb0[4]: scope 0 at $DIR/issue-67019.rs:11:10: 11:19 + StorageDead(_3); // bb0[5]: scope 0 at $DIR/issue-67019.rs:11:18: 11:19 + _1 = const test(move _2) -> bb1; // bb0[6]: scope 0 at $DIR/issue-67019.rs:11:5: 11:20 + // ty::Const + // + ty: fn(((u8, u8),)) {test} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/issue-67019.rs:11:5: 11:9 + // + literal: Const { ty: fn(((u8, u8),)) {test}, val: Value(Scalar(<ZST>)) } + } + + bb1: { + StorageDead(_2); // bb1[0]: scope 0 at $DIR/issue-67019.rs:11:19: 11:20 + StorageDead(_1); // bb1[1]: scope 0 at $DIR/issue-67019.rs:11:20: 11:21 + _0 = (); // bb1[2]: scope 0 at $DIR/issue-67019.rs:10:11: 12:2 + return; // bb1[3]: scope 0 at $DIR/issue-67019.rs:12:2: 12:2 + } + } + diff --git a/src/test/mir-opt/const_prop/optimizes_into_variable.rs b/src/test/mir-opt/const_prop/optimizes_into_variable.rs index 93a53db9093..0ae172e777b 100644 --- a/src/test/mir-opt/const_prop/optimizes_into_variable.rs +++ b/src/test/mir-opt/const_prop/optimizes_into_variable.rs @@ -5,145 +5,11 @@ struct Point { y: u32, } +// EMIT_MIR_FOR_EACH_BIT_WIDTH +// EMIT_MIR rustc.main.ConstProp.diff +// EMIT_MIR rustc.main.SimplifyLocals.after.mir fn main() { let x = 2 + 2; let y = [0, 1, 2, 3, 4, 5][3]; let z = (Point { x: 12, y: 42}).y; } - -// END RUST SOURCE -// START rustc.main.ConstProp.before.mir -// let mut _0: (); -// let _1: i32; -// let mut _2: (i32, bool); -// let mut _4: [i32; 6]; -// let _5: usize; -// let mut _6: usize; -// let mut _7: bool; -// let mut _9: Point; -// scope 1 { -// debug x => _1; -// let _3: i32; -// scope 2 { -// debug y => _3; -// let _8: u32; -// scope 3 { -// debug z => _8; -// } -// } -// } -// bb0: { -// StorageLive(_1); -// _2 = CheckedAdd(const 2i32, const 2i32); -// assert(!move (_2.1: bool), "attempt to add with overflow") -> bb1; -// } -// bb1: { -// _1 = move (_2.0: i32); -// StorageLive(_3); -// StorageLive(_4); -// _4 = [const 0i32, const 1i32, const 2i32, const 3i32, const 4i32, const 5i32]; -// StorageLive(_5); -// _5 = const 3usize; -// _6 = const 6usize; -// _7 = Lt(_5, _6); -// assert(move _7, "index out of bounds: the len is move _6 but the index is _5") -> bb2; -// } -// bb2: { -// _3 = _4[_5]; -// StorageDead(_5); -// StorageDead(_4); -// StorageLive(_8); -// StorageLive(_9); -// _9 = Point { x: const 12u32, y: const 42u32 }; -// _8 = (_9.1: u32); -// StorageDead(_9); -// _0 = (); -// StorageDead(_8); -// StorageDead(_3); -// StorageDead(_1); -// return; -// } -// END rustc.main.ConstProp.before.mir -// START rustc.main.ConstProp.after.mir -// let mut _0: (); -// let _1: i32; -// let mut _2: (i32, bool); -// let mut _4: [i32; 6]; -// let _5: usize; -// let mut _6: usize; -// let mut _7: bool; -// let mut _9: Point; -// scope 1 { -// debug x => _1; -// let _3: i32; -// scope 2 { -// debug y => _3; -// let _8: u32; -// scope 3 { -// debug z => _8; -// } -// } -// } -// bb0: { -// StorageLive(_1); -// _2 = (const 4i32, const false); -// assert(!const false, "attempt to add with overflow") -> bb1; -// } -// bb1: { -// _1 = const 4i32; -// StorageLive(_3); -// StorageLive(_4); -// _4 = [const 0i32, const 1i32, const 2i32, const 3i32, const 4i32, const 5i32]; -// StorageLive(_5); -// _5 = const 3usize; -// _6 = const 6usize; -// _7 = const true; -// assert(const true, "index out of bounds: the len is move _6 but the index is _5") -> bb2; -// } -// bb2: { -// _3 = const 3i32; -// StorageDead(_5); -// StorageDead(_4); -// StorageLive(_8); -// StorageLive(_9); -// _9 = Point { x: const 12u32, y: const 42u32 }; -// _8 = const 42u32; -// StorageDead(_9); -// _0 = (); -// StorageDead(_8); -// StorageDead(_3); -// StorageDead(_1); -// return; -// } -// END rustc.main.ConstProp.after.mir -// START rustc.main.SimplifyLocals.after.mir -// let mut _0: (); -// let _1: i32; -// let mut _3: [i32; 6]; -// scope 1 { -// debug x => _1; -// let _2: i32; -// scope 2 { -// debug y => _2; -// let _4: u32; -// scope 3 { -// debug z => _4; -// } -// } -// } -// bb0: { -// StorageLive(_1); -// _1 = const 4i32; -// StorageLive(_2); -// StorageLive(_3); -// _3 = [const 0i32, const 1i32, const 2i32, const 3i32, const 4i32, const 5i32]; -// _2 = const 3i32; -// StorageDead(_3); -// StorageLive(_4); -// _4 = const 42u32; -// StorageDead(_4); -// StorageDead(_2); -// StorageDead(_1); -// return; -// } -// END rustc.main.SimplifyLocals.after.mir diff --git a/src/test/mir-opt/const_prop/optimizes_into_variable/32bit/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/optimizes_into_variable/32bit/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..d8bd397d74a --- /dev/null +++ b/src/test/mir-opt/const_prop/optimizes_into_variable/32bit/rustc.main.ConstProp.diff @@ -0,0 +1,181 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:11:11: 11:11 + let _1: i32; // in scope 0 at $DIR/optimizes_into_variable.rs:12:9: 12:10 + let mut _2: (i32, bool); // in scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18 + let mut _4: [i32; 6]; // in scope 0 at $DIR/optimizes_into_variable.rs:13:13: 13:31 + let _5: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:13:32: 13:33 + let mut _6: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:13:13: 13:34 + let mut _7: bool; // in scope 0 at $DIR/optimizes_into_variable.rs:13:13: 13:34 + let mut _9: Point; // in scope 0 at $DIR/optimizes_into_variable.rs:14:13: 14:36 + scope 1 { + debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:12:9: 12:10 + let _3: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:13:9: 13:10 + scope 2 { + debug y => _3; // in scope 2 at $DIR/optimizes_into_variable.rs:13:9: 13:10 + let _8: u32; // in scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10 + scope 3 { + debug z => _8; // in scope 3 at $DIR/optimizes_into_variable.rs:14:9: 14:10 + } + } + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/optimizes_into_variable.rs:12:9: 12:10 +- _2 = CheckedAdd(const 2i32, const 2i32); // bb0[1]: scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18 ++ _2 = (const 4i32, const false); // bb0[1]: scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18 + // ty::Const + // + ty: i32 +- // + val: Value(Scalar(0x00000002)) ++ // + val: Value(Scalar(0x00000004)) + // mir::Constant +- // + span: $DIR/optimizes_into_variable.rs:12:13: 12:14 +- // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } ++ // + span: $DIR/optimizes_into_variable.rs:12:13: 12:18 ++ // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) } + // ty::Const +- // + ty: i32 +- // + val: Value(Scalar(0x00000002)) ++ // + ty: bool ++ // + val: Value(Scalar(0x00)) + // mir::Constant +- // + span: $DIR/optimizes_into_variable.rs:12:17: 12:18 +- // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } +- assert(!move (_2.1: bool), "attempt to add with overflow") -> bb1; // bb0[2]: scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18 ++ // + span: $DIR/optimizes_into_variable.rs:12:13: 12:18 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } ++ assert(!const false, "attempt to add with overflow") -> bb1; // bb0[2]: scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x00)) ++ // mir::Constant ++ // + span: $DIR/optimizes_into_variable.rs:12:13: 12:18 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } + } + + bb1: { +- _1 = move (_2.0: i32); // bb1[0]: scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18 ++ _1 = const 4i32; // bb1[0]: scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18 ++ // ty::Const ++ // + ty: i32 ++ // + val: Value(Scalar(0x00000004)) ++ // mir::Constant ++ // + span: $DIR/optimizes_into_variable.rs:12:13: 12:18 ++ // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) } + StorageLive(_3); // bb1[1]: scope 1 at $DIR/optimizes_into_variable.rs:13:9: 13:10 + StorageLive(_4); // bb1[2]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:31 + _4 = [const 0i32, const 1i32, const 2i32, const 3i32, const 4i32, const 5i32]; // bb1[3]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:31 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:13:14: 13:15 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:13:17: 13:18 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:13:20: 13:21 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:13:23: 13:24 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000004)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:13:26: 13:27 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000005)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:13:29: 13:30 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000005)) } + StorageLive(_5); // bb1[4]: scope 1 at $DIR/optimizes_into_variable.rs:13:32: 13:33 + _5 = const 3usize; // bb1[5]: scope 1 at $DIR/optimizes_into_variable.rs:13:32: 13:33 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:13:32: 13:33 + // + literal: Const { ty: usize, val: Value(Scalar(0x00000003)) } + _6 = const 6usize; // bb1[6]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x00000006)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:13:13: 13:34 + // + literal: Const { ty: usize, val: Value(Scalar(0x00000006)) } +- _7 = Lt(_5, _6); // bb1[7]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34 +- assert(move _7, "index out of bounds: the len is move _6 but the index is _5") -> bb2; // bb1[8]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34 ++ _7 = const true; // bb1[7]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x01)) ++ // mir::Constant ++ // + span: $DIR/optimizes_into_variable.rs:13:13: 13:34 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } ++ assert(const true, "index out of bounds: the len is move _6 but the index is _5") -> bb2; // bb1[8]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x01)) ++ // mir::Constant ++ // + span: $DIR/optimizes_into_variable.rs:13:13: 13:34 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + } + + bb2: { +- _3 = _4[_5]; // bb2[0]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34 ++ _3 = const 3i32; // bb2[0]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34 ++ // ty::Const ++ // + ty: i32 ++ // + val: Value(Scalar(0x00000003)) ++ // mir::Constant ++ // + span: $DIR/optimizes_into_variable.rs:13:13: 13:34 ++ // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } + StorageDead(_5); // bb2[1]: scope 1 at $DIR/optimizes_into_variable.rs:13:34: 13:35 + StorageDead(_4); // bb2[2]: scope 1 at $DIR/optimizes_into_variable.rs:13:34: 13:35 + StorageLive(_8); // bb2[3]: scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10 + StorageLive(_9); // bb2[4]: scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:36 + _9 = Point { x: const 12u32, y: const 42u32 }; // bb2[5]: scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:36 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x0000000c)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:14:25: 14:27 + // + literal: Const { ty: u32, val: Value(Scalar(0x0000000c)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x0000002a)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:14:32: 14:34 + // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) } +- _8 = (_9.1: u32); // bb2[6]: scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:38 ++ _8 = const 42u32; // bb2[6]: scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:38 ++ // ty::Const ++ // + ty: u32 ++ // + val: Value(Scalar(0x0000002a)) ++ // mir::Constant ++ // + span: $DIR/optimizes_into_variable.rs:14:13: 14:38 ++ // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) } + StorageDead(_9); // bb2[7]: scope 2 at $DIR/optimizes_into_variable.rs:14:38: 14:39 + _0 = (); // bb2[8]: scope 0 at $DIR/optimizes_into_variable.rs:11:11: 15:2 + StorageDead(_8); // bb2[9]: scope 2 at $DIR/optimizes_into_variable.rs:15:1: 15:2 + StorageDead(_3); // bb2[10]: scope 1 at $DIR/optimizes_into_variable.rs:15:1: 15:2 + StorageDead(_1); // bb2[11]: scope 0 at $DIR/optimizes_into_variable.rs:15:1: 15:2 + return; // bb2[12]: scope 0 at $DIR/optimizes_into_variable.rs:15:2: 15:2 + } + } + diff --git a/src/test/mir-opt/const_prop/optimizes_into_variable/32bit/rustc.main.SimplifyLocals.after.mir b/src/test/mir-opt/const_prop/optimizes_into_variable/32bit/rustc.main.SimplifyLocals.after.mir new file mode 100644 index 00000000000..db4d2d13792 --- /dev/null +++ b/src/test/mir-opt/const_prop/optimizes_into_variable/32bit/rustc.main.SimplifyLocals.after.mir @@ -0,0 +1,88 @@ +// MIR for `main` after SimplifyLocals + +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:11:11: 11:11 + let _1: i32; // in scope 0 at $DIR/optimizes_into_variable.rs:12:9: 12:10 + let mut _3: [i32; 6]; // in scope 0 at $DIR/optimizes_into_variable.rs:13:13: 13:31 + scope 1 { + debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:12:9: 12:10 + let _2: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:13:9: 13:10 + scope 2 { + debug y => _2; // in scope 2 at $DIR/optimizes_into_variable.rs:13:9: 13:10 + let _4: u32; // in scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10 + scope 3 { + debug z => _4; // in scope 3 at $DIR/optimizes_into_variable.rs:14:9: 14:10 + } + } + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/optimizes_into_variable.rs:12:9: 12:10 + _1 = const 4i32; // bb0[1]: scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000004)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:12:13: 12:18 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) } + StorageLive(_2); // bb0[2]: scope 1 at $DIR/optimizes_into_variable.rs:13:9: 13:10 + StorageLive(_3); // bb0[3]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:31 + _3 = [const 0i32, const 1i32, const 2i32, const 3i32, const 4i32, const 5i32]; // bb0[4]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:31 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:13:14: 13:15 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:13:17: 13:18 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:13:20: 13:21 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:13:23: 13:24 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000004)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:13:26: 13:27 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000005)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:13:29: 13:30 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000005)) } + _2 = const 3i32; // bb0[5]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:13:13: 13:34 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } + StorageDead(_3); // bb0[6]: scope 1 at $DIR/optimizes_into_variable.rs:13:34: 13:35 + StorageLive(_4); // bb0[7]: scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10 + _4 = const 42u32; // bb0[8]: scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:38 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x0000002a)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:14:13: 14:38 + // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) } + StorageDead(_4); // bb0[9]: scope 2 at $DIR/optimizes_into_variable.rs:15:1: 15:2 + StorageDead(_2); // bb0[10]: scope 1 at $DIR/optimizes_into_variable.rs:15:1: 15:2 + StorageDead(_1); // bb0[11]: scope 0 at $DIR/optimizes_into_variable.rs:15:1: 15:2 + return; // bb0[12]: scope 0 at $DIR/optimizes_into_variable.rs:15:2: 15:2 + } +} diff --git a/src/test/mir-opt/const_prop/optimizes_into_variable/64bit/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/optimizes_into_variable/64bit/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..9e646e7336d --- /dev/null +++ b/src/test/mir-opt/const_prop/optimizes_into_variable/64bit/rustc.main.ConstProp.diff @@ -0,0 +1,181 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:11:11: 11:11 + let _1: i32; // in scope 0 at $DIR/optimizes_into_variable.rs:12:9: 12:10 + let mut _2: (i32, bool); // in scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18 + let mut _4: [i32; 6]; // in scope 0 at $DIR/optimizes_into_variable.rs:13:13: 13:31 + let _5: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:13:32: 13:33 + let mut _6: usize; // in scope 0 at $DIR/optimizes_into_variable.rs:13:13: 13:34 + let mut _7: bool; // in scope 0 at $DIR/optimizes_into_variable.rs:13:13: 13:34 + let mut _9: Point; // in scope 0 at $DIR/optimizes_into_variable.rs:14:13: 14:36 + scope 1 { + debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:12:9: 12:10 + let _3: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:13:9: 13:10 + scope 2 { + debug y => _3; // in scope 2 at $DIR/optimizes_into_variable.rs:13:9: 13:10 + let _8: u32; // in scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10 + scope 3 { + debug z => _8; // in scope 3 at $DIR/optimizes_into_variable.rs:14:9: 14:10 + } + } + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/optimizes_into_variable.rs:12:9: 12:10 +- _2 = CheckedAdd(const 2i32, const 2i32); // bb0[1]: scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18 ++ _2 = (const 4i32, const false); // bb0[1]: scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18 + // ty::Const + // + ty: i32 +- // + val: Value(Scalar(0x00000002)) ++ // + val: Value(Scalar(0x00000004)) + // mir::Constant +- // + span: $DIR/optimizes_into_variable.rs:12:13: 12:14 +- // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } ++ // + span: $DIR/optimizes_into_variable.rs:12:13: 12:18 ++ // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) } + // ty::Const +- // + ty: i32 +- // + val: Value(Scalar(0x00000002)) ++ // + ty: bool ++ // + val: Value(Scalar(0x00)) + // mir::Constant +- // + span: $DIR/optimizes_into_variable.rs:12:17: 12:18 +- // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } +- assert(!move (_2.1: bool), "attempt to add with overflow") -> bb1; // bb0[2]: scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18 ++ // + span: $DIR/optimizes_into_variable.rs:12:13: 12:18 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } ++ assert(!const false, "attempt to add with overflow") -> bb1; // bb0[2]: scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x00)) ++ // mir::Constant ++ // + span: $DIR/optimizes_into_variable.rs:12:13: 12:18 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } + } + + bb1: { +- _1 = move (_2.0: i32); // bb1[0]: scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18 ++ _1 = const 4i32; // bb1[0]: scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18 ++ // ty::Const ++ // + ty: i32 ++ // + val: Value(Scalar(0x00000004)) ++ // mir::Constant ++ // + span: $DIR/optimizes_into_variable.rs:12:13: 12:18 ++ // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) } + StorageLive(_3); // bb1[1]: scope 1 at $DIR/optimizes_into_variable.rs:13:9: 13:10 + StorageLive(_4); // bb1[2]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:31 + _4 = [const 0i32, const 1i32, const 2i32, const 3i32, const 4i32, const 5i32]; // bb1[3]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:31 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:13:14: 13:15 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:13:17: 13:18 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:13:20: 13:21 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:13:23: 13:24 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000004)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:13:26: 13:27 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000005)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:13:29: 13:30 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000005)) } + StorageLive(_5); // bb1[4]: scope 1 at $DIR/optimizes_into_variable.rs:13:32: 13:33 + _5 = const 3usize; // bb1[5]: scope 1 at $DIR/optimizes_into_variable.rs:13:32: 13:33 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000003)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:13:32: 13:33 + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000003)) } + _6 = const 6usize; // bb1[6]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000006)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:13:13: 13:34 + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000006)) } +- _7 = Lt(_5, _6); // bb1[7]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34 +- assert(move _7, "index out of bounds: the len is move _6 but the index is _5") -> bb2; // bb1[8]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34 ++ _7 = const true; // bb1[7]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x01)) ++ // mir::Constant ++ // + span: $DIR/optimizes_into_variable.rs:13:13: 13:34 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } ++ assert(const true, "index out of bounds: the len is move _6 but the index is _5") -> bb2; // bb1[8]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x01)) ++ // mir::Constant ++ // + span: $DIR/optimizes_into_variable.rs:13:13: 13:34 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + } + + bb2: { +- _3 = _4[_5]; // bb2[0]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34 ++ _3 = const 3i32; // bb2[0]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34 ++ // ty::Const ++ // + ty: i32 ++ // + val: Value(Scalar(0x00000003)) ++ // mir::Constant ++ // + span: $DIR/optimizes_into_variable.rs:13:13: 13:34 ++ // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } + StorageDead(_5); // bb2[1]: scope 1 at $DIR/optimizes_into_variable.rs:13:34: 13:35 + StorageDead(_4); // bb2[2]: scope 1 at $DIR/optimizes_into_variable.rs:13:34: 13:35 + StorageLive(_8); // bb2[3]: scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10 + StorageLive(_9); // bb2[4]: scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:36 + _9 = Point { x: const 12u32, y: const 42u32 }; // bb2[5]: scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:36 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x0000000c)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:14:25: 14:27 + // + literal: Const { ty: u32, val: Value(Scalar(0x0000000c)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x0000002a)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:14:32: 14:34 + // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) } +- _8 = (_9.1: u32); // bb2[6]: scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:38 ++ _8 = const 42u32; // bb2[6]: scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:38 ++ // ty::Const ++ // + ty: u32 ++ // + val: Value(Scalar(0x0000002a)) ++ // mir::Constant ++ // + span: $DIR/optimizes_into_variable.rs:14:13: 14:38 ++ // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) } + StorageDead(_9); // bb2[7]: scope 2 at $DIR/optimizes_into_variable.rs:14:38: 14:39 + _0 = (); // bb2[8]: scope 0 at $DIR/optimizes_into_variable.rs:11:11: 15:2 + StorageDead(_8); // bb2[9]: scope 2 at $DIR/optimizes_into_variable.rs:15:1: 15:2 + StorageDead(_3); // bb2[10]: scope 1 at $DIR/optimizes_into_variable.rs:15:1: 15:2 + StorageDead(_1); // bb2[11]: scope 0 at $DIR/optimizes_into_variable.rs:15:1: 15:2 + return; // bb2[12]: scope 0 at $DIR/optimizes_into_variable.rs:15:2: 15:2 + } + } + diff --git a/src/test/mir-opt/const_prop/optimizes_into_variable/64bit/rustc.main.SimplifyLocals.after.mir b/src/test/mir-opt/const_prop/optimizes_into_variable/64bit/rustc.main.SimplifyLocals.after.mir new file mode 100644 index 00000000000..db4d2d13792 --- /dev/null +++ b/src/test/mir-opt/const_prop/optimizes_into_variable/64bit/rustc.main.SimplifyLocals.after.mir @@ -0,0 +1,88 @@ +// MIR for `main` after SimplifyLocals + +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:11:11: 11:11 + let _1: i32; // in scope 0 at $DIR/optimizes_into_variable.rs:12:9: 12:10 + let mut _3: [i32; 6]; // in scope 0 at $DIR/optimizes_into_variable.rs:13:13: 13:31 + scope 1 { + debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:12:9: 12:10 + let _2: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:13:9: 13:10 + scope 2 { + debug y => _2; // in scope 2 at $DIR/optimizes_into_variable.rs:13:9: 13:10 + let _4: u32; // in scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10 + scope 3 { + debug z => _4; // in scope 3 at $DIR/optimizes_into_variable.rs:14:9: 14:10 + } + } + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/optimizes_into_variable.rs:12:9: 12:10 + _1 = const 4i32; // bb0[1]: scope 0 at $DIR/optimizes_into_variable.rs:12:13: 12:18 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000004)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:12:13: 12:18 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) } + StorageLive(_2); // bb0[2]: scope 1 at $DIR/optimizes_into_variable.rs:13:9: 13:10 + StorageLive(_3); // bb0[3]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:31 + _3 = [const 0i32, const 1i32, const 2i32, const 3i32, const 4i32, const 5i32]; // bb0[4]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:31 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:13:14: 13:15 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:13:17: 13:18 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:13:20: 13:21 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:13:23: 13:24 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000004)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:13:26: 13:27 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000005)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:13:29: 13:30 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000005)) } + _2 = const 3i32; // bb0[5]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:13:13: 13:34 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } + StorageDead(_3); // bb0[6]: scope 1 at $DIR/optimizes_into_variable.rs:13:34: 13:35 + StorageLive(_4); // bb0[7]: scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10 + _4 = const 42u32; // bb0[8]: scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:38 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x0000002a)) + // mir::Constant + // + span: $DIR/optimizes_into_variable.rs:14:13: 14:38 + // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) } + StorageDead(_4); // bb0[9]: scope 2 at $DIR/optimizes_into_variable.rs:15:1: 15:2 + StorageDead(_2); // bb0[10]: scope 1 at $DIR/optimizes_into_variable.rs:15:1: 15:2 + StorageDead(_1); // bb0[11]: scope 0 at $DIR/optimizes_into_variable.rs:15:1: 15:2 + return; // bb0[12]: scope 0 at $DIR/optimizes_into_variable.rs:15:2: 15:2 + } +} diff --git a/src/test/mir-opt/const_prop/read_immutable_static.rs b/src/test/mir-opt/const_prop/read_immutable_static.rs index d307cebd715..9635f7050a6 100644 --- a/src/test/mir-opt/const_prop/read_immutable_static.rs +++ b/src/test/mir-opt/const_prop/read_immutable_static.rs @@ -2,30 +2,7 @@ static FOO: u8 = 2; +// EMIT_MIR rustc.main.ConstProp.diff fn main() { let x = FOO + FOO; } - -// END RUST SOURCE -// START rustc.main.ConstProp.before.mir -// bb0: { -// ... -// _3 = const {alloc0+0: &u8}; -// _2 = (*_3); -// ... -// _5 = const {alloc0+0: &u8}; -// _4 = (*_5); -// _1 = Add(move _2, move _4); -// ... -// } -// END rustc.main.ConstProp.before.mir -// START rustc.main.ConstProp.after.mir -// bb0: { -// ... -// _2 = const 2u8; -// ... -// _4 = const 2u8; -// _1 = const 4u8; -// ... -// } -// END rustc.main.ConstProp.after.mir diff --git a/src/test/mir-opt/const_prop/read_immutable_static/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/read_immutable_static/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..6183b22a95f --- /dev/null +++ b/src/test/mir-opt/const_prop/read_immutable_static/rustc.main.ConstProp.diff @@ -0,0 +1,72 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/read_immutable_static.rs:6:11: 6:11 + let _1: u8; // in scope 0 at $DIR/read_immutable_static.rs:7:9: 7:10 + let mut _2: u8; // in scope 0 at $DIR/read_immutable_static.rs:7:13: 7:16 + let mut _3: &u8; // in scope 0 at $DIR/read_immutable_static.rs:7:13: 7:16 + let mut _4: u8; // in scope 0 at $DIR/read_immutable_static.rs:7:19: 7:22 + let mut _5: &u8; // in scope 0 at $DIR/read_immutable_static.rs:7:19: 7:22 + scope 1 { + debug x => _1; // in scope 1 at $DIR/read_immutable_static.rs:7:9: 7:10 + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/read_immutable_static.rs:7:9: 7:10 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/read_immutable_static.rs:7:13: 7:16 + StorageLive(_3); // bb0[2]: scope 0 at $DIR/read_immutable_static.rs:7:13: 7:16 + _3 = const {alloc0+0: &u8}; // bb0[3]: scope 0 at $DIR/read_immutable_static.rs:7:13: 7:16 + // ty::Const + // + ty: &u8 + // + val: Value(Scalar(alloc0+0)) + // mir::Constant + // + span: $DIR/read_immutable_static.rs:7:13: 7:16 + // + literal: Const { ty: &u8, val: Value(Scalar(alloc0+0)) } +- _2 = (*_3); // bb0[4]: scope 0 at $DIR/read_immutable_static.rs:7:13: 7:16 ++ _2 = const 2u8; // bb0[4]: scope 0 at $DIR/read_immutable_static.rs:7:13: 7:16 ++ // ty::Const ++ // + ty: u8 ++ // + val: Value(Scalar(0x02)) ++ // mir::Constant ++ // + span: $DIR/read_immutable_static.rs:7:13: 7:16 ++ // + literal: Const { ty: u8, val: Value(Scalar(0x02)) } + StorageLive(_4); // bb0[5]: scope 0 at $DIR/read_immutable_static.rs:7:19: 7:22 + StorageLive(_5); // bb0[6]: scope 0 at $DIR/read_immutable_static.rs:7:19: 7:22 + _5 = const {alloc0+0: &u8}; // bb0[7]: scope 0 at $DIR/read_immutable_static.rs:7:19: 7:22 + // ty::Const + // + ty: &u8 + // + val: Value(Scalar(alloc0+0)) + // mir::Constant + // + span: $DIR/read_immutable_static.rs:7:19: 7:22 + // + literal: Const { ty: &u8, val: Value(Scalar(alloc0+0)) } +- _4 = (*_5); // bb0[8]: scope 0 at $DIR/read_immutable_static.rs:7:19: 7:22 +- _1 = Add(move _2, move _4); // bb0[9]: scope 0 at $DIR/read_immutable_static.rs:7:13: 7:22 ++ _4 = const 2u8; // bb0[8]: scope 0 at $DIR/read_immutable_static.rs:7:19: 7:22 ++ // ty::Const ++ // + ty: u8 ++ // + val: Value(Scalar(0x02)) ++ // mir::Constant ++ // + span: $DIR/read_immutable_static.rs:7:19: 7:22 ++ // + literal: Const { ty: u8, val: Value(Scalar(0x02)) } ++ _1 = const 4u8; // bb0[9]: scope 0 at $DIR/read_immutable_static.rs:7:13: 7:22 ++ // ty::Const ++ // + ty: u8 ++ // + val: Value(Scalar(0x04)) ++ // mir::Constant ++ // + span: $DIR/read_immutable_static.rs:7:13: 7:22 ++ // + literal: Const { ty: u8, val: Value(Scalar(0x04)) } + StorageDead(_4); // bb0[10]: scope 0 at $DIR/read_immutable_static.rs:7:21: 7:22 + StorageDead(_2); // bb0[11]: scope 0 at $DIR/read_immutable_static.rs:7:21: 7:22 + StorageDead(_5); // bb0[12]: scope 0 at $DIR/read_immutable_static.rs:7:22: 7:23 + StorageDead(_3); // bb0[13]: scope 0 at $DIR/read_immutable_static.rs:7:22: 7:23 + _0 = (); // bb0[14]: scope 0 at $DIR/read_immutable_static.rs:6:11: 8:2 + StorageDead(_1); // bb0[15]: scope 0 at $DIR/read_immutable_static.rs:8:1: 8:2 + return; // bb0[16]: scope 0 at $DIR/read_immutable_static.rs:8:2: 8:2 + } + } + + alloc0 (static: FOO, size: 1, align: 1) { + 02 │ . + } + diff --git a/src/test/mir-opt/const_prop/ref_deref.rs b/src/test/mir-opt/const_prop/ref_deref.rs index 8b48296a5d9..fc33e0e1f3b 100644 --- a/src/test/mir-opt/const_prop/ref_deref.rs +++ b/src/test/mir-opt/const_prop/ref_deref.rs @@ -1,41 +1,6 @@ +// EMIT_MIR rustc.main.PromoteTemps.diff +// EMIT_MIR rustc.main.ConstProp.diff + fn main() { *(&4); } - -// END RUST SOURCE -// START rustc.main.PromoteTemps.before.mir -// bb0: { -// ... -// _3 = const 4i32; -// _2 = &_3; -// _1 = (*_2); -// ... -//} -// END rustc.main.PromoteTemps.before.mir -// START rustc.main.PromoteTemps.after.mir -// bb0: { -// ... -// _4 = const main::promoted[0]; -// _2 = &(*_4); -// _1 = (*_2); -// ... -//} -// END rustc.main.PromoteTemps.after.mir -// START rustc.main.ConstProp.before.mir -// bb0: { -// ... -// _4 = const main::promoted[0]; -// _2 = _4; -// _1 = (*_2); -// ... -//} -// END rustc.main.ConstProp.before.mir -// START rustc.main.ConstProp.after.mir -// bb0: { -// ... -// _4 = const main::promoted[0]; -// _2 = _4; -// _1 = const 4i32; -// ... -// } -// END rustc.main.ConstProp.after.mir diff --git a/src/test/mir-opt/const_prop/ref_deref/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/ref_deref/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..0f8563daba5 --- /dev/null +++ b/src/test/mir-opt/const_prop/ref_deref/rustc.main.ConstProp.diff @@ -0,0 +1,36 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/ref_deref.rs:4:11: 4:11 + let _1: i32; // in scope 0 at $DIR/ref_deref.rs:5:5: 5:10 + let mut _2: &i32; // in scope 0 at $DIR/ref_deref.rs:5:6: 5:10 + let _3: i32; // in scope 0 at $DIR/ref_deref.rs:5:8: 5:9 + let mut _4: &i32; // in scope 0 at $DIR/ref_deref.rs:5:6: 5:10 + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/ref_deref.rs:5:5: 5:10 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/ref_deref.rs:5:6: 5:10 + _4 = const main::promoted[0]; // bb0[2]: scope 0 at $DIR/ref_deref.rs:5:6: 5:10 + // ty::Const + // + ty: &i32 + // + val: Unevaluated(DefId(0:3 ~ ref_deref[317d]::main[0]), [], Some(promoted[0])) + // mir::Constant + // + span: $DIR/ref_deref.rs:5:6: 5:10 + // + literal: Const { ty: &i32, val: Unevaluated(DefId(0:3 ~ ref_deref[317d]::main[0]), [], Some(promoted[0])) } + _2 = _4; // bb0[3]: scope 0 at $DIR/ref_deref.rs:5:6: 5:10 +- _1 = (*_2); // bb0[4]: scope 0 at $DIR/ref_deref.rs:5:5: 5:10 ++ _1 = const 4i32; // bb0[4]: scope 0 at $DIR/ref_deref.rs:5:5: 5:10 ++ // ty::Const ++ // + ty: i32 ++ // + val: Value(Scalar(0x00000004)) ++ // mir::Constant ++ // + span: $DIR/ref_deref.rs:5:5: 5:10 ++ // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) } + StorageDead(_2); // bb0[5]: scope 0 at $DIR/ref_deref.rs:5:10: 5:11 + StorageDead(_1); // bb0[6]: scope 0 at $DIR/ref_deref.rs:5:10: 5:11 + _0 = (); // bb0[7]: scope 0 at $DIR/ref_deref.rs:4:11: 6:2 + return; // bb0[8]: scope 0 at $DIR/ref_deref.rs:6:2: 6:2 + } + } + diff --git a/src/test/mir-opt/const_prop/ref_deref/rustc.main.PromoteTemps.diff b/src/test/mir-opt/const_prop/ref_deref/rustc.main.PromoteTemps.diff new file mode 100644 index 00000000000..ea1baa40f7e --- /dev/null +++ b/src/test/mir-opt/const_prop/ref_deref/rustc.main.PromoteTemps.diff @@ -0,0 +1,42 @@ +- // MIR for `main` before PromoteTemps ++ // MIR for `main` after PromoteTemps + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/ref_deref.rs:4:11: 4:11 + let _1: i32; // in scope 0 at $DIR/ref_deref.rs:5:5: 5:10 + let mut _2: &i32; // in scope 0 at $DIR/ref_deref.rs:5:6: 5:10 + let _3: i32; // in scope 0 at $DIR/ref_deref.rs:5:8: 5:9 ++ let mut _4: &i32; // in scope 0 at $DIR/ref_deref.rs:5:6: 5:10 + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/ref_deref.rs:5:5: 5:10 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/ref_deref.rs:5:6: 5:10 +- StorageLive(_3); // bb0[2]: scope 0 at $DIR/ref_deref.rs:5:8: 5:9 +- _3 = const 4i32; // bb0[3]: scope 0 at $DIR/ref_deref.rs:5:8: 5:9 ++ _4 = const main::promoted[0]; // bb0[2]: scope 0 at $DIR/ref_deref.rs:5:6: 5:10 + // ty::Const +- // + ty: i32 +- // + val: Value(Scalar(0x00000004)) ++ // + ty: &i32 ++ // + val: Unevaluated(DefId(0:3 ~ ref_deref[317d]::main[0]), [], Some(promoted[0])) + // mir::Constant +- // + span: $DIR/ref_deref.rs:5:8: 5:9 +- // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) } +- _2 = &_3; // bb0[4]: scope 0 at $DIR/ref_deref.rs:5:6: 5:10 +- _1 = (*_2); // bb0[5]: scope 0 at $DIR/ref_deref.rs:5:5: 5:10 +- StorageDead(_3); // bb0[6]: scope 0 at $DIR/ref_deref.rs:5:10: 5:11 +- StorageDead(_2); // bb0[7]: scope 0 at $DIR/ref_deref.rs:5:10: 5:11 +- StorageDead(_1); // bb0[8]: scope 0 at $DIR/ref_deref.rs:5:10: 5:11 +- _0 = (); // bb0[9]: scope 0 at $DIR/ref_deref.rs:4:11: 6:2 +- return; // bb0[10]: scope 0 at $DIR/ref_deref.rs:6:2: 6:2 ++ // + span: $DIR/ref_deref.rs:5:6: 5:10 ++ // + literal: Const { ty: &i32, val: Unevaluated(DefId(0:3 ~ ref_deref[317d]::main[0]), [], Some(promoted[0])) } ++ _2 = &(*_4); // bb0[3]: scope 0 at $DIR/ref_deref.rs:5:6: 5:10 ++ _1 = (*_2); // bb0[4]: scope 0 at $DIR/ref_deref.rs:5:5: 5:10 ++ StorageDead(_2); // bb0[5]: scope 0 at $DIR/ref_deref.rs:5:10: 5:11 ++ StorageDead(_1); // bb0[6]: scope 0 at $DIR/ref_deref.rs:5:10: 5:11 ++ _0 = (); // bb0[7]: scope 0 at $DIR/ref_deref.rs:4:11: 6:2 ++ return; // bb0[8]: scope 0 at $DIR/ref_deref.rs:6:2: 6:2 + } + } + diff --git a/src/test/mir-opt/const_prop/ref_deref_project.rs b/src/test/mir-opt/const_prop/ref_deref_project.rs index ca539fb7462..0322e300643 100644 --- a/src/test/mir-opt/const_prop/ref_deref_project.rs +++ b/src/test/mir-opt/const_prop/ref_deref_project.rs @@ -1,41 +1,6 @@ +// EMIT_MIR rustc.main.PromoteTemps.diff +// EMIT_MIR rustc.main.ConstProp.diff + fn main() { *(&(4, 5).1); // This does not currently propagate (#67862) } - -// END RUST SOURCE -// START rustc.main.PromoteTemps.before.mir -// bb0: { -// ... -// _3 = (const 4i32, const 5i32); -// _2 = &(_3.1: i32); -// _1 = (*_2); -// ... -//} -// END rustc.main.PromoteTemps.before.mir -// START rustc.main.PromoteTemps.after.mir -// bb0: { -// ... -// _4 = const main::promoted[0]; -// _2 = &((*_4).1: i32); -// _1 = (*_2); -// ... -//} -// END rustc.main.PromoteTemps.after.mir -// START rustc.main.ConstProp.before.mir -// bb0: { -// ... -// _4 = const main::promoted[0]; -// _2 = &((*_4).1: i32); -// _1 = (*_2); -// ... -//} -// END rustc.main.ConstProp.before.mir -// START rustc.main.ConstProp.after.mir -// bb0: { -// ... -// _4 = const main::promoted[0]; -// _2 = &((*_4).1: i32); -// _1 = (*_2); -// ... -// } -// END rustc.main.ConstProp.after.mir diff --git a/src/test/mir-opt/const_prop/ref_deref_project/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/ref_deref_project/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..c4b3d6b6c27 --- /dev/null +++ b/src/test/mir-opt/const_prop/ref_deref_project/rustc.main.ConstProp.diff @@ -0,0 +1,29 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/ref_deref_project.rs:4:11: 4:11 + let _1: i32; // in scope 0 at $DIR/ref_deref_project.rs:5:5: 5:17 + let mut _2: &i32; // in scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17 + let _3: (i32, i32); // in scope 0 at $DIR/ref_deref_project.rs:5:8: 5:14 + let mut _4: &(i32, i32); // in scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17 + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/ref_deref_project.rs:5:5: 5:17 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17 + _4 = const main::promoted[0]; // bb0[2]: scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17 + // ty::Const + // + ty: &(i32, i32) + // + val: Unevaluated(DefId(0:3 ~ ref_deref_project[317d]::main[0]), [], Some(promoted[0])) + // mir::Constant + // + span: $DIR/ref_deref_project.rs:5:6: 5:17 + // + literal: Const { ty: &(i32, i32), val: Unevaluated(DefId(0:3 ~ ref_deref_project[317d]::main[0]), [], Some(promoted[0])) } + _2 = &((*_4).1: i32); // bb0[3]: scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17 + _1 = (*_2); // bb0[4]: scope 0 at $DIR/ref_deref_project.rs:5:5: 5:17 + StorageDead(_2); // bb0[5]: scope 0 at $DIR/ref_deref_project.rs:5:17: 5:18 + StorageDead(_1); // bb0[6]: scope 0 at $DIR/ref_deref_project.rs:5:17: 5:18 + _0 = (); // bb0[7]: scope 0 at $DIR/ref_deref_project.rs:4:11: 6:2 + return; // bb0[8]: scope 0 at $DIR/ref_deref_project.rs:6:2: 6:2 + } + } + diff --git a/src/test/mir-opt/const_prop/ref_deref_project/rustc.main.PromoteTemps.diff b/src/test/mir-opt/const_prop/ref_deref_project/rustc.main.PromoteTemps.diff new file mode 100644 index 00000000000..852436e13b6 --- /dev/null +++ b/src/test/mir-opt/const_prop/ref_deref_project/rustc.main.PromoteTemps.diff @@ -0,0 +1,48 @@ +- // MIR for `main` before PromoteTemps ++ // MIR for `main` after PromoteTemps + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/ref_deref_project.rs:4:11: 4:11 + let _1: i32; // in scope 0 at $DIR/ref_deref_project.rs:5:5: 5:17 + let mut _2: &i32; // in scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17 + let _3: (i32, i32); // in scope 0 at $DIR/ref_deref_project.rs:5:8: 5:14 ++ let mut _4: &(i32, i32); // in scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17 + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/ref_deref_project.rs:5:5: 5:17 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17 +- StorageLive(_3); // bb0[2]: scope 0 at $DIR/ref_deref_project.rs:5:8: 5:14 +- _3 = (const 4i32, const 5i32); // bb0[3]: scope 0 at $DIR/ref_deref_project.rs:5:8: 5:14 ++ _4 = const main::promoted[0]; // bb0[2]: scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17 + // ty::Const +- // + ty: i32 +- // + val: Value(Scalar(0x00000004)) ++ // + ty: &(i32, i32) ++ // + val: Unevaluated(DefId(0:3 ~ ref_deref_project[317d]::main[0]), [], Some(promoted[0])) + // mir::Constant +- // + span: $DIR/ref_deref_project.rs:5:9: 5:10 +- // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) } +- // ty::Const +- // + ty: i32 +- // + val: Value(Scalar(0x00000005)) +- // mir::Constant +- // + span: $DIR/ref_deref_project.rs:5:12: 5:13 +- // + literal: Const { ty: i32, val: Value(Scalar(0x00000005)) } +- _2 = &(_3.1: i32); // bb0[4]: scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17 +- _1 = (*_2); // bb0[5]: scope 0 at $DIR/ref_deref_project.rs:5:5: 5:17 +- StorageDead(_3); // bb0[6]: scope 0 at $DIR/ref_deref_project.rs:5:17: 5:18 +- StorageDead(_2); // bb0[7]: scope 0 at $DIR/ref_deref_project.rs:5:17: 5:18 +- StorageDead(_1); // bb0[8]: scope 0 at $DIR/ref_deref_project.rs:5:17: 5:18 +- _0 = (); // bb0[9]: scope 0 at $DIR/ref_deref_project.rs:4:11: 6:2 +- return; // bb0[10]: scope 0 at $DIR/ref_deref_project.rs:6:2: 6:2 ++ // + span: $DIR/ref_deref_project.rs:5:6: 5:17 ++ // + literal: Const { ty: &(i32, i32), val: Unevaluated(DefId(0:3 ~ ref_deref_project[317d]::main[0]), [], Some(promoted[0])) } ++ _2 = &((*_4).1: i32); // bb0[3]: scope 0 at $DIR/ref_deref_project.rs:5:6: 5:17 ++ _1 = (*_2); // bb0[4]: scope 0 at $DIR/ref_deref_project.rs:5:5: 5:17 ++ StorageDead(_2); // bb0[5]: scope 0 at $DIR/ref_deref_project.rs:5:17: 5:18 ++ StorageDead(_1); // bb0[6]: scope 0 at $DIR/ref_deref_project.rs:5:17: 5:18 ++ _0 = (); // bb0[7]: scope 0 at $DIR/ref_deref_project.rs:4:11: 6:2 ++ return; // bb0[8]: scope 0 at $DIR/ref_deref_project.rs:6:2: 6:2 + } + } + diff --git a/src/test/mir-opt/const_prop/reify_fn_ptr.rs b/src/test/mir-opt/const_prop/reify_fn_ptr.rs index 4d6fe905b0c..834eb0cb1e9 100644 --- a/src/test/mir-opt/const_prop/reify_fn_ptr.rs +++ b/src/test/mir-opt/const_prop/reify_fn_ptr.rs @@ -1,25 +1,5 @@ +// EMIT_MIR rustc.main.ConstProp.diff + fn main() { let _ = main as usize as *const fn(); } - -// END RUST SOURCE -// START rustc.main.ConstProp.before.mir -// bb0: { -// ... -// _3 = const main as fn() (Pointer(ReifyFnPointer)); -// _2 = move _3 as usize (Misc); -// ... -// _1 = move _2 as *const fn() (Misc); -// ... -// } -// END rustc.main.ConstProp.before.mir -// START rustc.main.ConstProp.after.mir -// bb0: { -// ... -// _3 = const main as fn() (Pointer(ReifyFnPointer)); -// _2 = move _3 as usize (Misc); -// ... -// _1 = move _2 as *const fn() (Misc); -// ... -// } -// END rustc.main.ConstProp.after.mir diff --git a/src/test/mir-opt/const_prop/reify_fn_ptr/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/reify_fn_ptr/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..7a41a8ad74e --- /dev/null +++ b/src/test/mir-opt/const_prop/reify_fn_ptr/rustc.main.ConstProp.diff @@ -0,0 +1,32 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/reify_fn_ptr.rs:3:11: 3:11 + let mut _1: *const fn(); // in scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:41 + let mut _2: usize; // in scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:26 + let mut _3: fn(); // in scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:17 + scope 1 { + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:41 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:26 + StorageLive(_3); // bb0[2]: scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:17 + _3 = const main as fn() (Pointer(ReifyFnPointer)); // bb0[3]: scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:17 + // ty::Const + // + ty: fn() {main} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/reify_fn_ptr.rs:4:13: 4:17 + // + literal: Const { ty: fn() {main}, val: Value(Scalar(<ZST>)) } + _2 = move _3 as usize (Misc); // bb0[4]: scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:26 + StorageDead(_3); // bb0[5]: scope 0 at $DIR/reify_fn_ptr.rs:4:25: 4:26 + _1 = move _2 as *const fn() (Misc); // bb0[6]: scope 0 at $DIR/reify_fn_ptr.rs:4:13: 4:41 + StorageDead(_2); // bb0[7]: scope 0 at $DIR/reify_fn_ptr.rs:4:40: 4:41 + StorageDead(_1); // bb0[8]: scope 0 at $DIR/reify_fn_ptr.rs:4:41: 4:42 + _0 = (); // bb0[9]: scope 0 at $DIR/reify_fn_ptr.rs:3:11: 5:2 + return; // bb0[10]: scope 0 at $DIR/reify_fn_ptr.rs:5:2: 5:2 + } + } + diff --git a/src/test/mir-opt/const_prop/repeat.rs b/src/test/mir-opt/const_prop/repeat.rs index 48c06290cec..cdbfc46d6ca 100644 --- a/src/test/mir-opt/const_prop/repeat.rs +++ b/src/test/mir-opt/const_prop/repeat.rs @@ -1,37 +1,7 @@ // compile-flags: -O +// EMIT_MIR_FOR_EACH_BIT_WIDTH +// EMIT_MIR rustc.main.ConstProp.diff fn main() { let x: u32 = [42; 8][2] + 0; } - -// END RUST SOURCE -// START rustc.main.ConstProp.before.mir -// bb0: { -// ... -// _3 = [const 42u32; 8]; -// ... -// _4 = const 2usize; -// _5 = const 8usize; -// _6 = Lt(_4, _5); -// assert(move _6, "index out of bounds: the len is move _5 but the index is _4") -> bb1; -// } -// bb1: { -// _2 = _3[_4]; -// _1 = Add(move _2, const 0u32); -// ... -// return; -// } -// END rustc.main.ConstProp.before.mir -// START rustc.main.ConstProp.after.mir -// bb0: { -// ... -// _6 = const true; -// assert(const true, "index out of bounds: the len is move _5 but the index is _4") -> bb1; -// } -// bb1: { -// _2 = const 42u32; -// _1 = const 42u32; -// ... -// return; -// } -// END rustc.main.ConstProp.after.mir diff --git a/src/test/mir-opt/const_prop/repeat/32bit/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/repeat/32bit/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..dce98d88e3d --- /dev/null +++ b/src/test/mir-opt/const_prop/repeat/32bit/rustc.main.ConstProp.diff @@ -0,0 +1,88 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/repeat.rs:5:11: 5:11 + let _1: u32 as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/repeat.rs:6:9: 6:10 + let mut _2: u32; // in scope 0 at $DIR/repeat.rs:6:18: 6:28 + let mut _3: [u32; 8]; // in scope 0 at $DIR/repeat.rs:6:18: 6:25 + let _4: usize; // in scope 0 at $DIR/repeat.rs:6:26: 6:27 + let mut _5: usize; // in scope 0 at $DIR/repeat.rs:6:18: 6:28 + let mut _6: bool; // in scope 0 at $DIR/repeat.rs:6:18: 6:28 + scope 1 { + debug x => _1; // in scope 1 at $DIR/repeat.rs:6:9: 6:10 + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/repeat.rs:6:9: 6:10 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/repeat.rs:6:18: 6:28 + StorageLive(_3); // bb0[2]: scope 0 at $DIR/repeat.rs:6:18: 6:25 + _3 = [const 42u32; 8]; // bb0[3]: scope 0 at $DIR/repeat.rs:6:18: 6:25 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x0000002a)) + // mir::Constant + // + span: $DIR/repeat.rs:6:19: 6:21 + // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) } + StorageLive(_4); // bb0[4]: scope 0 at $DIR/repeat.rs:6:26: 6:27 + _4 = const 2usize; // bb0[5]: scope 0 at $DIR/repeat.rs:6:26: 6:27 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/repeat.rs:6:26: 6:27 + // + literal: Const { ty: usize, val: Value(Scalar(0x00000002)) } + _5 = const 8usize; // bb0[6]: scope 0 at $DIR/repeat.rs:6:18: 6:28 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x00000008)) + // mir::Constant + // + span: $DIR/repeat.rs:6:18: 6:28 + // + literal: Const { ty: usize, val: Value(Scalar(0x00000008)) } +- _6 = Lt(_4, _5); // bb0[7]: scope 0 at $DIR/repeat.rs:6:18: 6:28 +- assert(move _6, "index out of bounds: the len is move _5 but the index is _4") -> bb1; // bb0[8]: scope 0 at $DIR/repeat.rs:6:18: 6:28 ++ _6 = const true; // bb0[7]: scope 0 at $DIR/repeat.rs:6:18: 6:28 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x01)) ++ // mir::Constant ++ // + span: $DIR/repeat.rs:6:18: 6:28 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } ++ assert(const true, "index out of bounds: the len is move _5 but the index is _4") -> bb1; // bb0[8]: scope 0 at $DIR/repeat.rs:6:18: 6:28 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x01)) ++ // mir::Constant ++ // + span: $DIR/repeat.rs:6:18: 6:28 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + } + + bb1: { +- _2 = _3[_4]; // bb1[0]: scope 0 at $DIR/repeat.rs:6:18: 6:28 +- _1 = Add(move _2, const 0u32); // bb1[1]: scope 0 at $DIR/repeat.rs:6:18: 6:32 ++ _2 = const 42u32; // bb1[0]: scope 0 at $DIR/repeat.rs:6:18: 6:28 + // ty::Const + // + ty: u32 +- // + val: Value(Scalar(0x00000000)) ++ // + val: Value(Scalar(0x0000002a)) + // mir::Constant +- // + span: $DIR/repeat.rs:6:31: 6:32 +- // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } ++ // + span: $DIR/repeat.rs:6:18: 6:28 ++ // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) } ++ _1 = const 42u32; // bb1[1]: scope 0 at $DIR/repeat.rs:6:18: 6:32 ++ // ty::Const ++ // + ty: u32 ++ // + val: Value(Scalar(0x0000002a)) ++ // mir::Constant ++ // + span: $DIR/repeat.rs:6:18: 6:32 ++ // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) } + StorageDead(_2); // bb1[2]: scope 0 at $DIR/repeat.rs:6:31: 6:32 + StorageDead(_4); // bb1[3]: scope 0 at $DIR/repeat.rs:6:32: 6:33 + StorageDead(_3); // bb1[4]: scope 0 at $DIR/repeat.rs:6:32: 6:33 + _0 = (); // bb1[5]: scope 0 at $DIR/repeat.rs:5:11: 7:2 + StorageDead(_1); // bb1[6]: scope 0 at $DIR/repeat.rs:7:1: 7:2 + return; // bb1[7]: scope 0 at $DIR/repeat.rs:7:2: 7:2 + } + } + diff --git a/src/test/mir-opt/const_prop/repeat/64bit/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/repeat/64bit/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..c9e640291f2 --- /dev/null +++ b/src/test/mir-opt/const_prop/repeat/64bit/rustc.main.ConstProp.diff @@ -0,0 +1,88 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/repeat.rs:5:11: 5:11 + let _1: u32 as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/repeat.rs:6:9: 6:10 + let mut _2: u32; // in scope 0 at $DIR/repeat.rs:6:18: 6:28 + let mut _3: [u32; 8]; // in scope 0 at $DIR/repeat.rs:6:18: 6:25 + let _4: usize; // in scope 0 at $DIR/repeat.rs:6:26: 6:27 + let mut _5: usize; // in scope 0 at $DIR/repeat.rs:6:18: 6:28 + let mut _6: bool; // in scope 0 at $DIR/repeat.rs:6:18: 6:28 + scope 1 { + debug x => _1; // in scope 1 at $DIR/repeat.rs:6:9: 6:10 + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/repeat.rs:6:9: 6:10 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/repeat.rs:6:18: 6:28 + StorageLive(_3); // bb0[2]: scope 0 at $DIR/repeat.rs:6:18: 6:25 + _3 = [const 42u32; 8]; // bb0[3]: scope 0 at $DIR/repeat.rs:6:18: 6:25 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x0000002a)) + // mir::Constant + // + span: $DIR/repeat.rs:6:19: 6:21 + // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) } + StorageLive(_4); // bb0[4]: scope 0 at $DIR/repeat.rs:6:26: 6:27 + _4 = const 2usize; // bb0[5]: scope 0 at $DIR/repeat.rs:6:26: 6:27 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000002)) + // mir::Constant + // + span: $DIR/repeat.rs:6:26: 6:27 + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000002)) } + _5 = const 8usize; // bb0[6]: scope 0 at $DIR/repeat.rs:6:18: 6:28 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000008)) + // mir::Constant + // + span: $DIR/repeat.rs:6:18: 6:28 + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000008)) } +- _6 = Lt(_4, _5); // bb0[7]: scope 0 at $DIR/repeat.rs:6:18: 6:28 +- assert(move _6, "index out of bounds: the len is move _5 but the index is _4") -> bb1; // bb0[8]: scope 0 at $DIR/repeat.rs:6:18: 6:28 ++ _6 = const true; // bb0[7]: scope 0 at $DIR/repeat.rs:6:18: 6:28 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x01)) ++ // mir::Constant ++ // + span: $DIR/repeat.rs:6:18: 6:28 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } ++ assert(const true, "index out of bounds: the len is move _5 but the index is _4") -> bb1; // bb0[8]: scope 0 at $DIR/repeat.rs:6:18: 6:28 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x01)) ++ // mir::Constant ++ // + span: $DIR/repeat.rs:6:18: 6:28 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + } + + bb1: { +- _2 = _3[_4]; // bb1[0]: scope 0 at $DIR/repeat.rs:6:18: 6:28 +- _1 = Add(move _2, const 0u32); // bb1[1]: scope 0 at $DIR/repeat.rs:6:18: 6:32 ++ _2 = const 42u32; // bb1[0]: scope 0 at $DIR/repeat.rs:6:18: 6:28 + // ty::Const + // + ty: u32 +- // + val: Value(Scalar(0x00000000)) ++ // + val: Value(Scalar(0x0000002a)) + // mir::Constant +- // + span: $DIR/repeat.rs:6:31: 6:32 +- // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } ++ // + span: $DIR/repeat.rs:6:18: 6:28 ++ // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) } ++ _1 = const 42u32; // bb1[1]: scope 0 at $DIR/repeat.rs:6:18: 6:32 ++ // ty::Const ++ // + ty: u32 ++ // + val: Value(Scalar(0x0000002a)) ++ // mir::Constant ++ // + span: $DIR/repeat.rs:6:18: 6:32 ++ // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) } + StorageDead(_2); // bb1[2]: scope 0 at $DIR/repeat.rs:6:31: 6:32 + StorageDead(_4); // bb1[3]: scope 0 at $DIR/repeat.rs:6:32: 6:33 + StorageDead(_3); // bb1[4]: scope 0 at $DIR/repeat.rs:6:32: 6:33 + _0 = (); // bb1[5]: scope 0 at $DIR/repeat.rs:5:11: 7:2 + StorageDead(_1); // bb1[6]: scope 0 at $DIR/repeat.rs:7:1: 7:2 + return; // bb1[7]: scope 0 at $DIR/repeat.rs:7:2: 7:2 + } + } + diff --git a/src/test/mir-opt/const_prop/return_place.rs b/src/test/mir-opt/const_prop/return_place.rs index ea7c1e7ccd0..8d5b63b9afd 100644 --- a/src/test/mir-opt/const_prop/return_place.rs +++ b/src/test/mir-opt/const_prop/return_place.rs @@ -1,5 +1,7 @@ // compile-flags: -C overflow-checks=on +// EMIT_MIR rustc.add.ConstProp.diff +// EMIT_MIR rustc.add.PreCodegen.before.mir fn add() -> u32 { 2 + 2 } @@ -7,42 +9,3 @@ fn add() -> u32 { fn main() { add(); } - -// END RUST SOURCE -// START rustc.add.ConstProp.before.mir -// fn add() -> u32 { -// let mut _0: u32; -// let mut _1: (u32, bool); -// bb0: { -// _1 = CheckedAdd(const 2u32, const 2u32); -// assert(!move (_1.1: bool), "attempt to add with overflow") -> bb1; -// } -// bb1: { -// _0 = move (_1.0: u32); -// return; -// } -// } -// END rustc.add.ConstProp.before.mir -// START rustc.add.ConstProp.after.mir -// fn add() -> u32 { -// let mut _0: u32; -// let mut _1: (u32, bool); -// bb0: { -// _1 = (const 4u32, const false); -// assert(!const false, "attempt to add with overflow") -> bb1; -// } -// bb1: { -// _0 = const 4u32; -// return; -// } -// } -// END rustc.add.ConstProp.after.mir -// START rustc.add.PreCodegen.before.mir -// fn add() -> u32 { -// let mut _0: u32; -// bb0: { -// _0 = const 4u32; -// return; -// } -// } -// END rustc.add.PreCodegen.before.mir diff --git a/src/test/mir-opt/const_prop/return_place/rustc.add.ConstProp.diff b/src/test/mir-opt/const_prop/return_place/rustc.add.ConstProp.diff new file mode 100644 index 00000000000..3453c424a36 --- /dev/null +++ b/src/test/mir-opt/const_prop/return_place/rustc.add.ConstProp.diff @@ -0,0 +1,52 @@ +- // MIR for `add` before ConstProp ++ // MIR for `add` after ConstProp + + fn add() -> u32 { + let mut _0: u32; // return place in scope 0 at $DIR/return_place.rs:5:13: 5:16 + let mut _1: (u32, bool); // in scope 0 at $DIR/return_place.rs:6:5: 6:10 + + bb0: { +- _1 = CheckedAdd(const 2u32, const 2u32); // bb0[0]: scope 0 at $DIR/return_place.rs:6:5: 6:10 ++ _1 = (const 4u32, const false); // bb0[0]: scope 0 at $DIR/return_place.rs:6:5: 6:10 + // ty::Const + // + ty: u32 +- // + val: Value(Scalar(0x00000002)) ++ // + val: Value(Scalar(0x00000004)) + // mir::Constant +- // + span: $DIR/return_place.rs:6:5: 6:6 +- // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } ++ // + span: $DIR/return_place.rs:6:5: 6:10 ++ // + literal: Const { ty: u32, val: Value(Scalar(0x00000004)) } + // ty::Const +- // + ty: u32 +- // + val: Value(Scalar(0x00000002)) ++ // + ty: bool ++ // + val: Value(Scalar(0x00)) + // mir::Constant +- // + span: $DIR/return_place.rs:6:9: 6:10 +- // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } +- assert(!move (_1.1: bool), "attempt to add with overflow") -> bb1; // bb0[1]: scope 0 at $DIR/return_place.rs:6:5: 6:10 ++ // + span: $DIR/return_place.rs:6:5: 6:10 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } ++ assert(!const false, "attempt to add with overflow") -> bb1; // bb0[1]: scope 0 at $DIR/return_place.rs:6:5: 6:10 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x00)) ++ // mir::Constant ++ // + span: $DIR/return_place.rs:6:5: 6:10 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } + } + + bb1: { +- _0 = move (_1.0: u32); // bb1[0]: scope 0 at $DIR/return_place.rs:6:5: 6:10 ++ _0 = const 4u32; // bb1[0]: scope 0 at $DIR/return_place.rs:6:5: 6:10 ++ // ty::Const ++ // + ty: u32 ++ // + val: Value(Scalar(0x00000004)) ++ // mir::Constant ++ // + span: $DIR/return_place.rs:6:5: 6:10 ++ // + literal: Const { ty: u32, val: Value(Scalar(0x00000004)) } + return; // bb1[1]: scope 0 at $DIR/return_place.rs:7:2: 7:2 + } + } + diff --git a/src/test/mir-opt/const_prop/return_place/rustc.add.PreCodegen.before.mir b/src/test/mir-opt/const_prop/return_place/rustc.add.PreCodegen.before.mir new file mode 100644 index 00000000000..9af6be771ed --- /dev/null +++ b/src/test/mir-opt/const_prop/return_place/rustc.add.PreCodegen.before.mir @@ -0,0 +1,16 @@ +// MIR for `add` before PreCodegen + +fn add() -> u32 { + let mut _0: u32; // return place in scope 0 at $DIR/return_place.rs:5:13: 5:16 + + bb0: { + _0 = const 4u32; // bb0[0]: scope 0 at $DIR/return_place.rs:6:5: 6:10 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000004)) + // mir::Constant + // + span: $DIR/return_place.rs:6:5: 6:10 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000004)) } + return; // bb0[1]: scope 0 at $DIR/return_place.rs:7:2: 7:2 + } +} diff --git a/src/test/mir-opt/const_prop/slice_len.rs b/src/test/mir-opt/const_prop/slice_len.rs index 43813e43d36..0312f5e8e3a 100644 --- a/src/test/mir-opt/const_prop/slice_len.rs +++ b/src/test/mir-opt/const_prop/slice_len.rs @@ -1,43 +1,6 @@ +// EMIT_MIR_FOR_EACH_BIT_WIDTH + +// EMIT_MIR rustc.main.ConstProp.diff fn main() { (&[1u32, 2, 3] as &[u32])[1]; } - -// END RUST SOURCE -// START rustc.main.ConstProp.before.mir -// bb0: { -// ... -// _9 = const main::promoted[0]; -// _4 = _9; -// _3 = _4; -// _2 = move _3 as &[u32] (Pointer(Unsize)); -// ... -// _6 = const 1usize; -// _7 = Len((*_2)); -// _8 = Lt(_6, _7); -// assert(move _8, "index out of bounds: the len is move _7 but the index is _6") -> bb1; -// } -// bb1: { -// _1 = (*_2)[_6]; -// ... -// return; -// } -// END rustc.main.ConstProp.before.mir -// START rustc.main.ConstProp.after.mir -// bb0: { -// ... -// _9 = const main::promoted[0]; -// _4 = _9; -// _3 = _4; -// _2 = move _3 as &[u32] (Pointer(Unsize)); -// ... -// _6 = const 1usize; -// _7 = const 3usize; -// _8 = const true; -// assert(const true, "index out of bounds: the len is move _7 but the index is _6") -> bb1; -// } -// bb1: { -// _1 = const 2u32; -// ... -// return; -// } -// END rustc.main.ConstProp.after.mir diff --git a/src/test/mir-opt/const_prop/slice_len/32bit/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/slice_len/32bit/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..5f821078b75 --- /dev/null +++ b/src/test/mir-opt/const_prop/slice_len/32bit/rustc.main.ConstProp.diff @@ -0,0 +1,83 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/slice_len.rs:4:11: 4:11 + let _1: u32; // in scope 0 at $DIR/slice_len.rs:5:5: 5:33 + let mut _2: &[u32]; // in scope 0 at $DIR/slice_len.rs:5:5: 5:30 + let mut _3: &[u32; 3]; // in scope 0 at $DIR/slice_len.rs:5:6: 5:19 + let _4: &[u32; 3]; // in scope 0 at $DIR/slice_len.rs:5:6: 5:19 + let _5: [u32; 3]; // in scope 0 at $DIR/slice_len.rs:5:7: 5:19 + let _6: usize; // in scope 0 at $DIR/slice_len.rs:5:31: 5:32 + let mut _7: usize; // in scope 0 at $DIR/slice_len.rs:5:5: 5:33 + let mut _8: bool; // in scope 0 at $DIR/slice_len.rs:5:5: 5:33 + let mut _9: &[u32; 3]; // in scope 0 at $DIR/slice_len.rs:5:6: 5:19 + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/slice_len.rs:5:5: 5:33 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/slice_len.rs:5:5: 5:30 + StorageLive(_3); // bb0[2]: scope 0 at $DIR/slice_len.rs:5:6: 5:19 + StorageLive(_4); // bb0[3]: scope 0 at $DIR/slice_len.rs:5:6: 5:19 + _9 = const main::promoted[0]; // bb0[4]: scope 0 at $DIR/slice_len.rs:5:6: 5:19 + // ty::Const + // + ty: &[u32; 3] + // + val: Unevaluated(DefId(0:3 ~ slice_len[317d]::main[0]), [], Some(promoted[0])) + // mir::Constant + // + span: $DIR/slice_len.rs:5:6: 5:19 + // + literal: Const { ty: &[u32; 3], val: Unevaluated(DefId(0:3 ~ slice_len[317d]::main[0]), [], Some(promoted[0])) } + _4 = _9; // bb0[5]: scope 0 at $DIR/slice_len.rs:5:6: 5:19 + _3 = _4; // bb0[6]: scope 0 at $DIR/slice_len.rs:5:6: 5:19 + _2 = move _3 as &[u32] (Pointer(Unsize)); // bb0[7]: scope 0 at $DIR/slice_len.rs:5:6: 5:19 + StorageDead(_3); // bb0[8]: scope 0 at $DIR/slice_len.rs:5:18: 5:19 + StorageLive(_6); // bb0[9]: scope 0 at $DIR/slice_len.rs:5:31: 5:32 + _6 = const 1usize; // bb0[10]: scope 0 at $DIR/slice_len.rs:5:31: 5:32 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/slice_len.rs:5:31: 5:32 + // + literal: Const { ty: usize, val: Value(Scalar(0x00000001)) } +- _7 = Len((*_2)); // bb0[11]: scope 0 at $DIR/slice_len.rs:5:5: 5:33 +- _8 = Lt(_6, _7); // bb0[12]: scope 0 at $DIR/slice_len.rs:5:5: 5:33 +- assert(move _8, "index out of bounds: the len is move _7 but the index is _6") -> bb1; // bb0[13]: scope 0 at $DIR/slice_len.rs:5:5: 5:33 ++ _7 = const 3usize; // bb0[11]: scope 0 at $DIR/slice_len.rs:5:5: 5:33 ++ // ty::Const ++ // + ty: usize ++ // + val: Value(Scalar(0x00000003)) ++ // mir::Constant ++ // + span: $DIR/slice_len.rs:5:5: 5:33 ++ // + literal: Const { ty: usize, val: Value(Scalar(0x00000003)) } ++ _8 = const true; // bb0[12]: scope 0 at $DIR/slice_len.rs:5:5: 5:33 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x01)) ++ // mir::Constant ++ // + span: $DIR/slice_len.rs:5:5: 5:33 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } ++ assert(const true, "index out of bounds: the len is move _7 but the index is _6") -> bb1; // bb0[13]: scope 0 at $DIR/slice_len.rs:5:5: 5:33 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x01)) ++ // mir::Constant ++ // + span: $DIR/slice_len.rs:5:5: 5:33 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + } + + bb1: { +- _1 = (*_2)[_6]; // bb1[0]: scope 0 at $DIR/slice_len.rs:5:5: 5:33 ++ _1 = const 2u32; // bb1[0]: scope 0 at $DIR/slice_len.rs:5:5: 5:33 ++ // ty::Const ++ // + ty: u32 ++ // + val: Value(Scalar(0x00000002)) ++ // mir::Constant ++ // + span: $DIR/slice_len.rs:5:5: 5:33 ++ // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } + StorageDead(_6); // bb1[1]: scope 0 at $DIR/slice_len.rs:5:33: 5:34 + StorageDead(_4); // bb1[2]: scope 0 at $DIR/slice_len.rs:5:33: 5:34 + StorageDead(_2); // bb1[3]: scope 0 at $DIR/slice_len.rs:5:33: 5:34 + StorageDead(_1); // bb1[4]: scope 0 at $DIR/slice_len.rs:5:33: 5:34 + _0 = (); // bb1[5]: scope 0 at $DIR/slice_len.rs:4:11: 6:2 + return; // bb1[6]: scope 0 at $DIR/slice_len.rs:6:2: 6:2 + } + } + diff --git a/src/test/mir-opt/const_prop/slice_len/64bit/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/slice_len/64bit/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..46f98b7f0ae --- /dev/null +++ b/src/test/mir-opt/const_prop/slice_len/64bit/rustc.main.ConstProp.diff @@ -0,0 +1,83 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/slice_len.rs:4:11: 4:11 + let _1: u32; // in scope 0 at $DIR/slice_len.rs:5:5: 5:33 + let mut _2: &[u32]; // in scope 0 at $DIR/slice_len.rs:5:5: 5:30 + let mut _3: &[u32; 3]; // in scope 0 at $DIR/slice_len.rs:5:6: 5:19 + let _4: &[u32; 3]; // in scope 0 at $DIR/slice_len.rs:5:6: 5:19 + let _5: [u32; 3]; // in scope 0 at $DIR/slice_len.rs:5:7: 5:19 + let _6: usize; // in scope 0 at $DIR/slice_len.rs:5:31: 5:32 + let mut _7: usize; // in scope 0 at $DIR/slice_len.rs:5:5: 5:33 + let mut _8: bool; // in scope 0 at $DIR/slice_len.rs:5:5: 5:33 + let mut _9: &[u32; 3]; // in scope 0 at $DIR/slice_len.rs:5:6: 5:19 + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/slice_len.rs:5:5: 5:33 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/slice_len.rs:5:5: 5:30 + StorageLive(_3); // bb0[2]: scope 0 at $DIR/slice_len.rs:5:6: 5:19 + StorageLive(_4); // bb0[3]: scope 0 at $DIR/slice_len.rs:5:6: 5:19 + _9 = const main::promoted[0]; // bb0[4]: scope 0 at $DIR/slice_len.rs:5:6: 5:19 + // ty::Const + // + ty: &[u32; 3] + // + val: Unevaluated(DefId(0:3 ~ slice_len[317d]::main[0]), [], Some(promoted[0])) + // mir::Constant + // + span: $DIR/slice_len.rs:5:6: 5:19 + // + literal: Const { ty: &[u32; 3], val: Unevaluated(DefId(0:3 ~ slice_len[317d]::main[0]), [], Some(promoted[0])) } + _4 = _9; // bb0[5]: scope 0 at $DIR/slice_len.rs:5:6: 5:19 + _3 = _4; // bb0[6]: scope 0 at $DIR/slice_len.rs:5:6: 5:19 + _2 = move _3 as &[u32] (Pointer(Unsize)); // bb0[7]: scope 0 at $DIR/slice_len.rs:5:6: 5:19 + StorageDead(_3); // bb0[8]: scope 0 at $DIR/slice_len.rs:5:18: 5:19 + StorageLive(_6); // bb0[9]: scope 0 at $DIR/slice_len.rs:5:31: 5:32 + _6 = const 1usize; // bb0[10]: scope 0 at $DIR/slice_len.rs:5:31: 5:32 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000001)) + // mir::Constant + // + span: $DIR/slice_len.rs:5:31: 5:32 + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000001)) } +- _7 = Len((*_2)); // bb0[11]: scope 0 at $DIR/slice_len.rs:5:5: 5:33 +- _8 = Lt(_6, _7); // bb0[12]: scope 0 at $DIR/slice_len.rs:5:5: 5:33 +- assert(move _8, "index out of bounds: the len is move _7 but the index is _6") -> bb1; // bb0[13]: scope 0 at $DIR/slice_len.rs:5:5: 5:33 ++ _7 = const 3usize; // bb0[11]: scope 0 at $DIR/slice_len.rs:5:5: 5:33 ++ // ty::Const ++ // + ty: usize ++ // + val: Value(Scalar(0x0000000000000003)) ++ // mir::Constant ++ // + span: $DIR/slice_len.rs:5:5: 5:33 ++ // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000003)) } ++ _8 = const true; // bb0[12]: scope 0 at $DIR/slice_len.rs:5:5: 5:33 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x01)) ++ // mir::Constant ++ // + span: $DIR/slice_len.rs:5:5: 5:33 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } ++ assert(const true, "index out of bounds: the len is move _7 but the index is _6") -> bb1; // bb0[13]: scope 0 at $DIR/slice_len.rs:5:5: 5:33 ++ // ty::Const ++ // + ty: bool ++ // + val: Value(Scalar(0x01)) ++ // mir::Constant ++ // + span: $DIR/slice_len.rs:5:5: 5:33 ++ // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + } + + bb1: { +- _1 = (*_2)[_6]; // bb1[0]: scope 0 at $DIR/slice_len.rs:5:5: 5:33 ++ _1 = const 2u32; // bb1[0]: scope 0 at $DIR/slice_len.rs:5:5: 5:33 ++ // ty::Const ++ // + ty: u32 ++ // + val: Value(Scalar(0x00000002)) ++ // mir::Constant ++ // + span: $DIR/slice_len.rs:5:5: 5:33 ++ // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } + StorageDead(_6); // bb1[1]: scope 0 at $DIR/slice_len.rs:5:33: 5:34 + StorageDead(_4); // bb1[2]: scope 0 at $DIR/slice_len.rs:5:33: 5:34 + StorageDead(_2); // bb1[3]: scope 0 at $DIR/slice_len.rs:5:33: 5:34 + StorageDead(_1); // bb1[4]: scope 0 at $DIR/slice_len.rs:5:33: 5:34 + _0 = (); // bb1[5]: scope 0 at $DIR/slice_len.rs:4:11: 6:2 + return; // bb1[6]: scope 0 at $DIR/slice_len.rs:6:2: 6:2 + } + } + diff --git a/src/test/mir-opt/const_prop/switch_int.rs b/src/test/mir-opt/const_prop/switch_int.rs index 904d303d87e..46e6efb8180 100644 --- a/src/test/mir-opt/const_prop/switch_int.rs +++ b/src/test/mir-opt/const_prop/switch_int.rs @@ -1,38 +1,11 @@ #[inline(never)] fn foo(_: i32) { } +// EMIT_MIR rustc.main.ConstProp.diff +// EMIT_MIR rustc.main.SimplifyBranches-after-const-prop.diff fn main() { match 1 { 1 => foo(0), _ => foo(-1), } } - -// END RUST SOURCE -// START rustc.main.ConstProp.before.mir -// bb0: { -// ... -// _1 = const 1i32; -// switchInt(_1) -> [1i32: bb2, otherwise: bb1]; -// } -// END rustc.main.ConstProp.before.mir -// START rustc.main.ConstProp.after.mir -// bb0: { -// ... -// switchInt(const 1i32) -> [1i32: bb2, otherwise: bb1]; -// } -// END rustc.main.ConstProp.after.mir -// START rustc.main.SimplifyBranches-after-const-prop.before.mir -// bb0: { -// ... -// _1 = const 1i32; -// switchInt(const 1i32) -> [1i32: bb2, otherwise: bb1]; -// } -// END rustc.main.SimplifyBranches-after-const-prop.before.mir -// START rustc.main.SimplifyBranches-after-const-prop.after.mir -// bb0: { -// ... -// _1 = const 1i32; -// goto -> bb2; -// } -// END rustc.main.SimplifyBranches-after-const-prop.after.mir diff --git a/src/test/mir-opt/const_prop/switch_int/rustc.main.ConstProp.diff b/src/test/mir-opt/const_prop/switch_int/rustc.main.ConstProp.diff new file mode 100644 index 00000000000..92b14309bf2 --- /dev/null +++ b/src/test/mir-opt/const_prop/switch_int/rustc.main.ConstProp.diff @@ -0,0 +1,64 @@ +- // MIR for `main` before ConstProp ++ // MIR for `main` after ConstProp + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/switch_int.rs:6:11: 6:11 + let mut _1: i32; // in scope 0 at $DIR/switch_int.rs:7:11: 7:12 + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/switch_int.rs:7:11: 7:12 + _1 = const 1i32; // bb0[1]: scope 0 at $DIR/switch_int.rs:7:11: 7:12 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/switch_int.rs:7:11: 7:12 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } +- switchInt(_1) -> [1i32: bb2, otherwise: bb1]; // bb0[2]: scope 0 at $DIR/switch_int.rs:8:9: 8:10 ++ switchInt(const 1i32) -> [1i32: bb2, otherwise: bb1]; // bb0[2]: scope 0 at $DIR/switch_int.rs:8:9: 8:10 ++ // ty::Const ++ // + ty: i32 ++ // + val: Value(Scalar(0x00000001)) ++ // mir::Constant ++ // + span: $DIR/switch_int.rs:8:9: 8:10 ++ // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } + } + + bb1: { + _0 = const foo(const -1i32) -> bb3; // bb1[0]: scope 0 at $DIR/switch_int.rs:9:14: 9:21 + // ty::Const + // + ty: fn(i32) {foo} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/switch_int.rs:9:14: 9:17 + // + literal: Const { ty: fn(i32) {foo}, val: Value(Scalar(<ZST>)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0xffffffff)) + // mir::Constant + // + span: $DIR/switch_int.rs:9:18: 9:20 + // + literal: Const { ty: i32, val: Value(Scalar(0xffffffff)) } + } + + bb2: { + _0 = const foo(const 0i32) -> bb3; // bb2[0]: scope 0 at $DIR/switch_int.rs:8:14: 8:20 + // ty::Const + // + ty: fn(i32) {foo} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/switch_int.rs:8:14: 8:17 + // + literal: Const { ty: fn(i32) {foo}, val: Value(Scalar(<ZST>)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/switch_int.rs:8:18: 8:19 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } + } + + bb3: { + StorageDead(_1); // bb3[0]: scope 0 at $DIR/switch_int.rs:11:1: 11:2 + return; // bb3[1]: scope 0 at $DIR/switch_int.rs:11:2: 11:2 + } + } + diff --git a/src/test/mir-opt/const_prop/switch_int/rustc.main.SimplifyBranches-after-const-prop.diff b/src/test/mir-opt/const_prop/switch_int/rustc.main.SimplifyBranches-after-const-prop.diff new file mode 100644 index 00000000000..e1805cc5731 --- /dev/null +++ b/src/test/mir-opt/const_prop/switch_int/rustc.main.SimplifyBranches-after-const-prop.diff @@ -0,0 +1,64 @@ +- // MIR for `main` before SimplifyBranches-after-const-prop ++ // MIR for `main` after SimplifyBranches-after-const-prop + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/switch_int.rs:6:11: 6:11 + let mut _1: i32; // in scope 0 at $DIR/switch_int.rs:7:11: 7:12 + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/switch_int.rs:7:11: 7:12 + _1 = const 1i32; // bb0[1]: scope 0 at $DIR/switch_int.rs:7:11: 7:12 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/switch_int.rs:7:11: 7:12 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } +- switchInt(const 1i32) -> [1i32: bb2, otherwise: bb1]; // bb0[2]: scope 0 at $DIR/switch_int.rs:8:9: 8:10 +- // ty::Const +- // + ty: i32 +- // + val: Value(Scalar(0x00000001)) +- // mir::Constant +- // + span: $DIR/switch_int.rs:8:9: 8:10 +- // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } ++ goto -> bb2; // bb0[2]: scope 0 at $DIR/switch_int.rs:8:9: 8:10 + } + + bb1: { + _0 = const foo(const -1i32) -> bb3; // bb1[0]: scope 0 at $DIR/switch_int.rs:9:14: 9:21 + // ty::Const + // + ty: fn(i32) {foo} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/switch_int.rs:9:14: 9:17 + // + literal: Const { ty: fn(i32) {foo}, val: Value(Scalar(<ZST>)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0xffffffff)) + // mir::Constant + // + span: $DIR/switch_int.rs:9:18: 9:20 + // + literal: Const { ty: i32, val: Value(Scalar(0xffffffff)) } + } + + bb2: { + _0 = const foo(const 0i32) -> bb3; // bb2[0]: scope 0 at $DIR/switch_int.rs:8:14: 8:20 + // ty::Const + // + ty: fn(i32) {foo} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/switch_int.rs:8:14: 8:17 + // + literal: Const { ty: fn(i32) {foo}, val: Value(Scalar(<ZST>)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/switch_int.rs:8:18: 8:19 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } + } + + bb3: { + StorageDead(_1); // bb3[0]: scope 0 at $DIR/switch_int.rs:11:1: 11:2 + return; // bb3[1]: scope 0 at $DIR/switch_int.rs:11:2: 11:2 + } + } + diff --git a/src/test/mir-opt/copy_propagation.rs b/src/test/mir-opt/copy_propagation.rs index a86caf04b04..b5db5497d48 100644 --- a/src/test/mir-opt/copy_propagation.rs +++ b/src/test/mir-opt/copy_propagation.rs @@ -1,3 +1,5 @@ +// EMIT_MIR rustc.test.CopyPropagation.diff + fn test(x: u32) -> u32 { let y = x; y @@ -7,23 +9,3 @@ fn main() { // Make sure the function actually gets instantiated. test(0); } - -// END RUST SOURCE -// START rustc.test.CopyPropagation.before.mir -// bb0: { -// ... -// _2 = _1; -// ... -// _0 = _2; -// ... -// return; -// } -// END rustc.test.CopyPropagation.before.mir -// START rustc.test.CopyPropagation.after.mir -// bb0: { -// ... -// _0 = _1; -// ... -// return; -// } -// END rustc.test.CopyPropagation.after.mir diff --git a/src/test/mir-opt/copy_propagation/rustc.test.CopyPropagation.diff b/src/test/mir-opt/copy_propagation/rustc.test.CopyPropagation.diff new file mode 100644 index 00000000000..4e9d4c56cd6 --- /dev/null +++ b/src/test/mir-opt/copy_propagation/rustc.test.CopyPropagation.diff @@ -0,0 +1,25 @@ +- // MIR for `test` before CopyPropagation ++ // MIR for `test` after CopyPropagation + + fn test(_1: u32) -> u32 { + debug x => _1; // in scope 0 at $DIR/copy_propagation.rs:3:9: 3:10 + let mut _0: u32; // return place in scope 0 at $DIR/copy_propagation.rs:3:20: 3:23 + let _2: u32; // in scope 0 at $DIR/copy_propagation.rs:4:9: 4:10 + scope 1 { +- debug y => _2; // in scope 1 at $DIR/copy_propagation.rs:4:9: 4:10 ++ debug y => _1; // in scope 1 at $DIR/copy_propagation.rs:4:9: 4:10 + } + + bb0: { +- StorageLive(_2); // bb0[0]: scope 0 at $DIR/copy_propagation.rs:4:9: 4:10 +- _2 = _1; // bb0[1]: scope 0 at $DIR/copy_propagation.rs:4:13: 4:14 +- _0 = _2; // bb0[2]: scope 1 at $DIR/copy_propagation.rs:5:5: 5:6 +- StorageDead(_2); // bb0[3]: scope 0 at $DIR/copy_propagation.rs:6:1: 6:2 ++ nop; // bb0[0]: scope 0 at $DIR/copy_propagation.rs:4:9: 4:10 ++ nop; // bb0[1]: scope 0 at $DIR/copy_propagation.rs:4:13: 4:14 ++ _0 = _1; // bb0[2]: scope 1 at $DIR/copy_propagation.rs:5:5: 5:6 ++ nop; // bb0[3]: scope 0 at $DIR/copy_propagation.rs:6:1: 6:2 + return; // bb0[4]: scope 0 at $DIR/copy_propagation.rs:6:2: 6:2 + } + } + diff --git a/src/test/mir-opt/copy_propagation_arg.rs b/src/test/mir-opt/copy_propagation_arg.rs index 5e5fed12fb5..c4858be7f2b 100644 --- a/src/test/mir-opt/copy_propagation_arg.rs +++ b/src/test/mir-opt/copy_propagation_arg.rs @@ -5,21 +5,25 @@ fn dummy(x: u8) -> u8 { x } +// EMIT_MIR rustc.foo.CopyPropagation.diff fn foo(mut x: u8) { // calling `dummy` to make an use of `x` that copyprop cannot eliminate x = dummy(x); // this will assign a local to `x` } +// EMIT_MIR rustc.bar.CopyPropagation.diff fn bar(mut x: u8) { dummy(x); x = 5; } +// EMIT_MIR rustc.baz.CopyPropagation.diff fn baz(mut x: i32) { // self-assignment to a function argument should be eliminated x = x; } +// EMIT_MIR rustc.arg_src.CopyPropagation.diff fn arg_src(mut x: i32) -> i32 { let y = x; x = 123; // Don't propagate this assignment to `y` @@ -33,100 +37,3 @@ fn main() { baz(0); arg_src(0); } - -// END RUST SOURCE -// START rustc.foo.CopyPropagation.before.mir -// bb0: { -// ... -// _3 = _1; -// _2 = const dummy(move _3) -> bb1; -// } -// bb1: { -// ... -// _1 = move _2; -// ... -// } -// END rustc.foo.CopyPropagation.before.mir -// START rustc.foo.CopyPropagation.after.mir -// bb0: { -// ... -// _3 = _1; -// _2 = const dummy(move _3) -> bb1; -// } -// bb1: { -// ... -// _1 = move _2; -// ... -// } -// END rustc.foo.CopyPropagation.after.mir -// START rustc.bar.CopyPropagation.before.mir -// bb0: { -// StorageLive(_2); -// StorageLive(_3); -// _3 = _1; -// _2 = const dummy(move _3) -> bb1; -// } -// bb1: { -// StorageDead(_3); -// StorageDead(_2); -// _1 = const 5u8; -// ... -// return; -// } -// END rustc.bar.CopyPropagation.before.mir -// START rustc.bar.CopyPropagation.after.mir -// bb0: { -// ... -// _3 = _1; -// _2 = const dummy(move _3) -> bb1; -// } -// bb1: { -// ... -// _1 = const 5u8; -// ... -// return; -// } -// END rustc.bar.CopyPropagation.after.mir -// START rustc.baz.CopyPropagation.before.mir -// bb0: { -// StorageLive(_2); -// _2 = _1; -// _1 = move _2; -// StorageDead(_2); -// ... -// return; -// } -// END rustc.baz.CopyPropagation.before.mir -// START rustc.baz.CopyPropagation.after.mir -// bb0: { -// ... -// _2 = _1; -// _1 = move _2; -// ... -// return; -// } -// END rustc.baz.CopyPropagation.after.mir -// START rustc.arg_src.CopyPropagation.before.mir -// bb0: { -// ... -// _2 = _1; -// ... -// _1 = const 123i32; -// ... -// _0 = _2; -// ... -// return; -// } -// END rustc.arg_src.CopyPropagation.before.mir -// START rustc.arg_src.CopyPropagation.after.mir -// bb0: { -// ... -// _2 = _1; -// ... -// _1 = const 123i32; -// ... -// _0 = _2; -// ... -// return; -// } -// END rustc.arg_src.CopyPropagation.after.mir diff --git a/src/test/mir-opt/copy_propagation_arg/rustc.arg_src.CopyPropagation.diff b/src/test/mir-opt/copy_propagation_arg/rustc.arg_src.CopyPropagation.diff new file mode 100644 index 00000000000..db3f588d999 --- /dev/null +++ b/src/test/mir-opt/copy_propagation_arg/rustc.arg_src.CopyPropagation.diff @@ -0,0 +1,27 @@ +- // MIR for `arg_src` before CopyPropagation ++ // MIR for `arg_src` after CopyPropagation + + fn arg_src(_1: i32) -> i32 { + debug x => _1; // in scope 0 at $DIR/copy_propagation_arg.rs:27:12: 27:17 + let mut _0: i32; // return place in scope 0 at $DIR/copy_propagation_arg.rs:27:27: 27:30 + let _2: i32; // in scope 0 at $DIR/copy_propagation_arg.rs:28:9: 28:10 + scope 1 { + debug y => _2; // in scope 1 at $DIR/copy_propagation_arg.rs:28:9: 28:10 + } + + bb0: { + StorageLive(_2); // bb0[0]: scope 0 at $DIR/copy_propagation_arg.rs:28:9: 28:10 + _2 = _1; // bb0[1]: scope 0 at $DIR/copy_propagation_arg.rs:28:13: 28:14 + _1 = const 123i32; // bb0[2]: scope 1 at $DIR/copy_propagation_arg.rs:29:5: 29:12 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x0000007b)) + // mir::Constant + // + span: $DIR/copy_propagation_arg.rs:29:5: 29:12 + // + literal: Const { ty: i32, val: Value(Scalar(0x0000007b)) } + _0 = _2; // bb0[3]: scope 1 at $DIR/copy_propagation_arg.rs:30:5: 30:6 + StorageDead(_2); // bb0[4]: scope 0 at $DIR/copy_propagation_arg.rs:31:1: 31:2 + return; // bb0[5]: scope 0 at $DIR/copy_propagation_arg.rs:31:2: 31:2 + } + } + diff --git a/src/test/mir-opt/copy_propagation_arg/rustc.bar.CopyPropagation.diff b/src/test/mir-opt/copy_propagation_arg/rustc.bar.CopyPropagation.diff new file mode 100644 index 00000000000..8bdc91109b3 --- /dev/null +++ b/src/test/mir-opt/copy_propagation_arg/rustc.bar.CopyPropagation.diff @@ -0,0 +1,37 @@ +- // MIR for `bar` before CopyPropagation ++ // MIR for `bar` after CopyPropagation + + fn bar(_1: u8) -> () { + debug x => _1; // in scope 0 at $DIR/copy_propagation_arg.rs:15:8: 15:13 + let mut _0: (); // return place in scope 0 at $DIR/copy_propagation_arg.rs:15:19: 15:19 + let _2: u8; // in scope 0 at $DIR/copy_propagation_arg.rs:16:5: 16:13 + let mut _3: u8; // in scope 0 at $DIR/copy_propagation_arg.rs:16:11: 16:12 + + bb0: { + StorageLive(_2); // bb0[0]: scope 0 at $DIR/copy_propagation_arg.rs:16:5: 16:13 + StorageLive(_3); // bb0[1]: scope 0 at $DIR/copy_propagation_arg.rs:16:11: 16:12 + _3 = _1; // bb0[2]: scope 0 at $DIR/copy_propagation_arg.rs:16:11: 16:12 + _2 = const dummy(move _3) -> bb1; // bb0[3]: scope 0 at $DIR/copy_propagation_arg.rs:16:5: 16:13 + // ty::Const + // + ty: fn(u8) -> u8 {dummy} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/copy_propagation_arg.rs:16:5: 16:10 + // + literal: Const { ty: fn(u8) -> u8 {dummy}, val: Value(Scalar(<ZST>)) } + } + + bb1: { + StorageDead(_3); // bb1[0]: scope 0 at $DIR/copy_propagation_arg.rs:16:12: 16:13 + StorageDead(_2); // bb1[1]: scope 0 at $DIR/copy_propagation_arg.rs:16:13: 16:14 + _1 = const 5u8; // bb1[2]: scope 0 at $DIR/copy_propagation_arg.rs:17:5: 17:10 + // ty::Const + // + ty: u8 + // + val: Value(Scalar(0x05)) + // mir::Constant + // + span: $DIR/copy_propagation_arg.rs:17:5: 17:10 + // + literal: Const { ty: u8, val: Value(Scalar(0x05)) } + nop; // bb1[3]: scope 0 at $DIR/copy_propagation_arg.rs:15:19: 18:2 + return; // bb1[4]: scope 0 at $DIR/copy_propagation_arg.rs:18:2: 18:2 + } + } + diff --git a/src/test/mir-opt/copy_propagation_arg/rustc.baz.CopyPropagation.diff b/src/test/mir-opt/copy_propagation_arg/rustc.baz.CopyPropagation.diff new file mode 100644 index 00000000000..10f2a98b206 --- /dev/null +++ b/src/test/mir-opt/copy_propagation_arg/rustc.baz.CopyPropagation.diff @@ -0,0 +1,18 @@ +- // MIR for `baz` before CopyPropagation ++ // MIR for `baz` after CopyPropagation + + fn baz(_1: i32) -> () { + debug x => _1; // in scope 0 at $DIR/copy_propagation_arg.rs:21:8: 21:13 + let mut _0: (); // return place in scope 0 at $DIR/copy_propagation_arg.rs:21:20: 21:20 + let mut _2: i32; // in scope 0 at $DIR/copy_propagation_arg.rs:23:9: 23:10 + + bb0: { + StorageLive(_2); // bb0[0]: scope 0 at $DIR/copy_propagation_arg.rs:23:9: 23:10 + _2 = _1; // bb0[1]: scope 0 at $DIR/copy_propagation_arg.rs:23:9: 23:10 + _1 = move _2; // bb0[2]: scope 0 at $DIR/copy_propagation_arg.rs:23:5: 23:10 + StorageDead(_2); // bb0[3]: scope 0 at $DIR/copy_propagation_arg.rs:23:9: 23:10 + nop; // bb0[4]: scope 0 at $DIR/copy_propagation_arg.rs:21:20: 24:2 + return; // bb0[5]: scope 0 at $DIR/copy_propagation_arg.rs:24:2: 24:2 + } + } + diff --git a/src/test/mir-opt/copy_propagation_arg/rustc.foo.CopyPropagation.diff b/src/test/mir-opt/copy_propagation_arg/rustc.foo.CopyPropagation.diff new file mode 100644 index 00000000000..a47880c540e --- /dev/null +++ b/src/test/mir-opt/copy_propagation_arg/rustc.foo.CopyPropagation.diff @@ -0,0 +1,31 @@ +- // MIR for `foo` before CopyPropagation ++ // MIR for `foo` after CopyPropagation + + fn foo(_1: u8) -> () { + debug x => _1; // in scope 0 at $DIR/copy_propagation_arg.rs:9:8: 9:13 + let mut _0: (); // return place in scope 0 at $DIR/copy_propagation_arg.rs:9:19: 9:19 + let mut _2: u8; // in scope 0 at $DIR/copy_propagation_arg.rs:11:9: 11:17 + let mut _3: u8; // in scope 0 at $DIR/copy_propagation_arg.rs:11:15: 11:16 + + bb0: { + StorageLive(_2); // bb0[0]: scope 0 at $DIR/copy_propagation_arg.rs:11:9: 11:17 + StorageLive(_3); // bb0[1]: scope 0 at $DIR/copy_propagation_arg.rs:11:15: 11:16 + _3 = _1; // bb0[2]: scope 0 at $DIR/copy_propagation_arg.rs:11:15: 11:16 + _2 = const dummy(move _3) -> bb1; // bb0[3]: scope 0 at $DIR/copy_propagation_arg.rs:11:9: 11:17 + // ty::Const + // + ty: fn(u8) -> u8 {dummy} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/copy_propagation_arg.rs:11:9: 11:14 + // + literal: Const { ty: fn(u8) -> u8 {dummy}, val: Value(Scalar(<ZST>)) } + } + + bb1: { + StorageDead(_3); // bb1[0]: scope 0 at $DIR/copy_propagation_arg.rs:11:16: 11:17 + _1 = move _2; // bb1[1]: scope 0 at $DIR/copy_propagation_arg.rs:11:5: 11:17 + StorageDead(_2); // bb1[2]: scope 0 at $DIR/copy_propagation_arg.rs:11:16: 11:17 + nop; // bb1[3]: scope 0 at $DIR/copy_propagation_arg.rs:9:19: 12:2 + return; // bb1[4]: scope 0 at $DIR/copy_propagation_arg.rs:12:2: 12:2 + } + } + diff --git a/src/test/mir-opt/deaggregator_test.rs b/src/test/mir-opt/deaggregator_test.rs index 44c2319bc7e..9004a631291 100644 --- a/src/test/mir-opt/deaggregator_test.rs +++ b/src/test/mir-opt/deaggregator_test.rs @@ -4,6 +4,7 @@ struct Baz { z: bool, } +// EMIT_MIR rustc.bar.Deaggregator.diff fn bar(a: usize) -> Baz { Baz { x: a, y: 0.0, z: false } } @@ -12,27 +13,3 @@ fn main() { // Make sure the function actually gets instantiated. bar(0); } - -// END RUST SOURCE -// START rustc.bar.Deaggregator.before.mir -// bb0: { -// ... -// _2 = _1; -// ... -// _0 = Baz { x: move _2, y: const 0f32, z: const false }; -// ... -// return; -// } -// END rustc.bar.Deaggregator.before.mir -// START rustc.bar.Deaggregator.after.mir -// bb0: { -// ... -// _2 = _1; -// ... -// (_0.0: usize) = move _2; -// (_0.1: f32) = const 0f32; -// (_0.2: bool) = const false; -// ... -// return; -// } -// END rustc.bar.Deaggregator.after.mir diff --git a/src/test/mir-opt/deaggregator_test/rustc.bar.Deaggregator.diff b/src/test/mir-opt/deaggregator_test/rustc.bar.Deaggregator.diff new file mode 100644 index 00000000000..082f05a50c1 --- /dev/null +++ b/src/test/mir-opt/deaggregator_test/rustc.bar.Deaggregator.diff @@ -0,0 +1,34 @@ +- // MIR for `bar` before Deaggregator ++ // MIR for `bar` after Deaggregator + + fn bar(_1: usize) -> Baz { + debug a => _1; // in scope 0 at $DIR/deaggregator_test.rs:8:8: 8:9 + let mut _0: Baz; // return place in scope 0 at $DIR/deaggregator_test.rs:8:21: 8:24 + let mut _2: usize; // in scope 0 at $DIR/deaggregator_test.rs:9:14: 9:15 + + bb0: { + StorageLive(_2); // bb0[0]: scope 0 at $DIR/deaggregator_test.rs:9:14: 9:15 + _2 = _1; // bb0[1]: scope 0 at $DIR/deaggregator_test.rs:9:14: 9:15 +- _0 = Baz { x: move _2, y: const 0f32, z: const false }; // bb0[2]: scope 0 at $DIR/deaggregator_test.rs:9:5: 9:35 ++ (_0.0: usize) = move _2; // bb0[2]: scope 0 at $DIR/deaggregator_test.rs:9:5: 9:35 ++ (_0.1: f32) = const 0f32; // bb0[3]: scope 0 at $DIR/deaggregator_test.rs:9:5: 9:35 + // ty::Const + // + ty: f32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/deaggregator_test.rs:9:20: 9:23 + // + literal: Const { ty: f32, val: Value(Scalar(0x00000000)) } ++ (_0.2: bool) = const false; // bb0[4]: scope 0 at $DIR/deaggregator_test.rs:9:5: 9:35 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x00)) + // mir::Constant + // + span: $DIR/deaggregator_test.rs:9:28: 9:33 + // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } +- StorageDead(_2); // bb0[3]: scope 0 at $DIR/deaggregator_test.rs:9:34: 9:35 +- return; // bb0[4]: scope 0 at $DIR/deaggregator_test.rs:10:2: 10:2 ++ StorageDead(_2); // bb0[5]: scope 0 at $DIR/deaggregator_test.rs:9:34: 9:35 ++ return; // bb0[6]: scope 0 at $DIR/deaggregator_test.rs:10:2: 10:2 + } + } + diff --git a/src/test/mir-opt/deaggregator_test_enum.rs b/src/test/mir-opt/deaggregator_test_enum.rs index fed16271590..e74eafd011f 100644 --- a/src/test/mir-opt/deaggregator_test_enum.rs +++ b/src/test/mir-opt/deaggregator_test_enum.rs @@ -3,6 +3,7 @@ enum Baz { Foo { x: usize }, } +// EMIT_MIR rustc.bar.Deaggregator.diff fn bar(a: usize) -> Baz { Baz::Foo { x: a } } @@ -14,24 +15,3 @@ fn main() { Baz::Foo { x } => println!("{}", x), }; } - -// END RUST SOURCE -// START rustc.bar.Deaggregator.before.mir -// bb0: { -// StorageLive(_2); -// _2 = _1; -// _0 = Baz::Foo { x: move _2 }; -// StorageDead(_2); -// return; -// } -// END rustc.bar.Deaggregator.before.mir -// START rustc.bar.Deaggregator.after.mir -// bb0: { -// StorageLive(_2); -// _2 = _1; -// ((_0 as Foo).0: usize) = move _2; -// discriminant(_0) = 1; -// StorageDead(_2); -// return; -// } -// END rustc.bar.Deaggregator.after.mir diff --git a/src/test/mir-opt/deaggregator_test_enum/rustc.bar.Deaggregator.diff b/src/test/mir-opt/deaggregator_test_enum/rustc.bar.Deaggregator.diff new file mode 100644 index 00000000000..b1839ef7e0e --- /dev/null +++ b/src/test/mir-opt/deaggregator_test_enum/rustc.bar.Deaggregator.diff @@ -0,0 +1,21 @@ +- // MIR for `bar` before Deaggregator ++ // MIR for `bar` after Deaggregator + + fn bar(_1: usize) -> Baz { + debug a => _1; // in scope 0 at $DIR/deaggregator_test_enum.rs:7:8: 7:9 + let mut _0: Baz; // return place in scope 0 at $DIR/deaggregator_test_enum.rs:7:21: 7:24 + let mut _2: usize; // in scope 0 at $DIR/deaggregator_test_enum.rs:8:19: 8:20 + + bb0: { + StorageLive(_2); // bb0[0]: scope 0 at $DIR/deaggregator_test_enum.rs:8:19: 8:20 + _2 = _1; // bb0[1]: scope 0 at $DIR/deaggregator_test_enum.rs:8:19: 8:20 +- _0 = Baz::Foo { x: move _2 }; // bb0[2]: scope 0 at $DIR/deaggregator_test_enum.rs:8:5: 8:22 +- StorageDead(_2); // bb0[3]: scope 0 at $DIR/deaggregator_test_enum.rs:8:21: 8:22 +- return; // bb0[4]: scope 0 at $DIR/deaggregator_test_enum.rs:9:2: 9:2 ++ ((_0 as Foo).0: usize) = move _2; // bb0[2]: scope 0 at $DIR/deaggregator_test_enum.rs:8:5: 8:22 ++ discriminant(_0) = 1; // bb0[3]: scope 0 at $DIR/deaggregator_test_enum.rs:8:5: 8:22 ++ StorageDead(_2); // bb0[4]: scope 0 at $DIR/deaggregator_test_enum.rs:8:21: 8:22 ++ return; // bb0[5]: scope 0 at $DIR/deaggregator_test_enum.rs:9:2: 9:2 + } + } + diff --git a/src/test/mir-opt/deaggregator_test_enum_2.rs b/src/test/mir-opt/deaggregator_test_enum_2.rs index b39ad1bef8e..d5201ed72a8 100644 --- a/src/test/mir-opt/deaggregator_test_enum_2.rs +++ b/src/test/mir-opt/deaggregator_test_enum_2.rs @@ -5,6 +5,7 @@ enum Foo { B(i32), } +// EMIT_MIR rustc.test1.Deaggregator.diff fn test1(x: bool, y: i32) -> Foo { if x { Foo::A(y) @@ -17,40 +18,3 @@ fn main() { // Make sure the function actually gets instantiated. test1(false, 0); } - -// END RUST SOURCE -// START rustc.test1.Deaggregator.before.mir -// bb1: { -// StorageLive(_5); -// _5 = _2; -// _0 = Foo::B(move _5,); -// StorageDead(_5); -// goto -> bb3; -// } -// bb2: { -// StorageLive(_4); -// _4 = _2; -// _0 = Foo::A(move _4,); -// StorageDead(_4); -// goto -> bb3; -// } -// END rustc.test1.Deaggregator.before.mir -// START rustc.test1.Deaggregator.after.mir -// bb1: { -// StorageLive(_5); -// _5 = _2; -// ((_0 as B).0: i32) = move _5; -// discriminant(_0) = 1; -// StorageDead(_5); -// goto -> bb3; -// } -// bb2: { -// StorageLive(_4); -// _4 = _2; -// ((_0 as A).0: i32) = move _4; -// discriminant(_0) = 0; -// StorageDead(_4); -// goto -> bb3; -// } -// END rustc.test1.Deaggregator.after.mir -// diff --git a/src/test/mir-opt/deaggregator_test_enum_2/rustc.test1.Deaggregator.diff b/src/test/mir-opt/deaggregator_test_enum_2/rustc.test1.Deaggregator.diff new file mode 100644 index 00000000000..a72a679b209 --- /dev/null +++ b/src/test/mir-opt/deaggregator_test_enum_2/rustc.test1.Deaggregator.diff @@ -0,0 +1,47 @@ +- // MIR for `test1` before Deaggregator ++ // MIR for `test1` after Deaggregator + + fn test1(_1: bool, _2: i32) -> Foo { + debug x => _1; // in scope 0 at $DIR/deaggregator_test_enum_2.rs:9:10: 9:11 + debug y => _2; // in scope 0 at $DIR/deaggregator_test_enum_2.rs:9:19: 9:20 + let mut _0: Foo; // return place in scope 0 at $DIR/deaggregator_test_enum_2.rs:9:30: 9:33 + let mut _3: bool; // in scope 0 at $DIR/deaggregator_test_enum_2.rs:10:8: 10:9 + let mut _4: i32; // in scope 0 at $DIR/deaggregator_test_enum_2.rs:11:16: 11:17 + let mut _5: i32; // in scope 0 at $DIR/deaggregator_test_enum_2.rs:13:16: 13:17 + + bb0: { + StorageLive(_3); // bb0[0]: scope 0 at $DIR/deaggregator_test_enum_2.rs:10:8: 10:9 + _3 = _1; // bb0[1]: scope 0 at $DIR/deaggregator_test_enum_2.rs:10:8: 10:9 + switchInt(_3) -> [false: bb1, otherwise: bb2]; // bb0[2]: scope 0 at $DIR/deaggregator_test_enum_2.rs:10:5: 14:6 + } + + bb1: { + StorageLive(_5); // bb1[0]: scope 0 at $DIR/deaggregator_test_enum_2.rs:13:16: 13:17 + _5 = _2; // bb1[1]: scope 0 at $DIR/deaggregator_test_enum_2.rs:13:16: 13:17 +- _0 = Foo::B(move _5,); // bb1[2]: scope 0 at $DIR/deaggregator_test_enum_2.rs:13:9: 13:18 +- StorageDead(_5); // bb1[3]: scope 0 at $DIR/deaggregator_test_enum_2.rs:13:17: 13:18 +- goto -> bb3; // bb1[4]: scope 0 at $DIR/deaggregator_test_enum_2.rs:10:5: 14:6 ++ ((_0 as B).0: i32) = move _5; // bb1[2]: scope 0 at $DIR/deaggregator_test_enum_2.rs:13:9: 13:18 ++ discriminant(_0) = 1; // bb1[3]: scope 0 at $DIR/deaggregator_test_enum_2.rs:13:9: 13:18 ++ StorageDead(_5); // bb1[4]: scope 0 at $DIR/deaggregator_test_enum_2.rs:13:17: 13:18 ++ goto -> bb3; // bb1[5]: scope 0 at $DIR/deaggregator_test_enum_2.rs:10:5: 14:6 + } + + bb2: { + StorageLive(_4); // bb2[0]: scope 0 at $DIR/deaggregator_test_enum_2.rs:11:16: 11:17 + _4 = _2; // bb2[1]: scope 0 at $DIR/deaggregator_test_enum_2.rs:11:16: 11:17 +- _0 = Foo::A(move _4,); // bb2[2]: scope 0 at $DIR/deaggregator_test_enum_2.rs:11:9: 11:18 +- StorageDead(_4); // bb2[3]: scope 0 at $DIR/deaggregator_test_enum_2.rs:11:17: 11:18 +- goto -> bb3; // bb2[4]: scope 0 at $DIR/deaggregator_test_enum_2.rs:10:5: 14:6 ++ ((_0 as A).0: i32) = move _4; // bb2[2]: scope 0 at $DIR/deaggregator_test_enum_2.rs:11:9: 11:18 ++ discriminant(_0) = 0; // bb2[3]: scope 0 at $DIR/deaggregator_test_enum_2.rs:11:9: 11:18 ++ StorageDead(_4); // bb2[4]: scope 0 at $DIR/deaggregator_test_enum_2.rs:11:17: 11:18 ++ goto -> bb3; // bb2[5]: scope 0 at $DIR/deaggregator_test_enum_2.rs:10:5: 14:6 + } + + bb3: { + StorageDead(_3); // bb3[0]: scope 0 at $DIR/deaggregator_test_enum_2.rs:15:1: 15:2 + return; // bb3[1]: scope 0 at $DIR/deaggregator_test_enum_2.rs:15:2: 15:2 + } + } + diff --git a/src/test/mir-opt/deaggregator_test_multiple.rs b/src/test/mir-opt/deaggregator_test_multiple.rs index 34c41af273f..824a970ce2f 100644 --- a/src/test/mir-opt/deaggregator_test_multiple.rs +++ b/src/test/mir-opt/deaggregator_test_multiple.rs @@ -5,6 +5,7 @@ enum Foo { B, } +// EMIT_MIR rustc.test.Deaggregator.diff fn test(x: i32) -> [Foo; 2] { [Foo::A(x), Foo::A(x)] } @@ -13,37 +14,3 @@ fn main() { // Make sure the function actually gets instantiated. test(0); } - -// END RUST SOURCE -// START rustc.test.Deaggregator.before.mir -// bb0: { -// ... -// _3 = _1; -// ... -// _2 = Foo::A(move _3,); -// ... -// _5 = _1; -// _4 = Foo::A(move _5,); -// ... -// _0 = [move _2, move _4]; -// ... -// return; -// } -// END rustc.test.Deaggregator.before.mir -// START rustc.test.Deaggregator.after.mir -// bb0: { -// ... -// _3 = _1; -// ... -// ((_2 as A).0: i32) = move _3; -// discriminant(_2) = 0; -// ... -// _5 = _1; -// ((_4 as A).0: i32) = move _5; -// discriminant(_4) = 0; -// ... -// _0 = [move _2, move _4]; -// ... -// return; -// } -// END rustc.test.Deaggregator.after.mir diff --git a/src/test/mir-opt/deaggregator_test_multiple/rustc.test.Deaggregator.diff b/src/test/mir-opt/deaggregator_test_multiple/rustc.test.Deaggregator.diff new file mode 100644 index 00000000000..126dfc1ac91 --- /dev/null +++ b/src/test/mir-opt/deaggregator_test_multiple/rustc.test.Deaggregator.diff @@ -0,0 +1,42 @@ +- // MIR for `test` before Deaggregator ++ // MIR for `test` after Deaggregator + + fn test(_1: i32) -> [Foo; 2] { + debug x => _1; // in scope 0 at $DIR/deaggregator_test_multiple.rs:9:9: 9:10 + let mut _0: [Foo; 2]; // return place in scope 0 at $DIR/deaggregator_test_multiple.rs:9:20: 9:28 + let mut _2: Foo; // in scope 0 at $DIR/deaggregator_test_multiple.rs:10:6: 10:15 + let mut _3: i32; // in scope 0 at $DIR/deaggregator_test_multiple.rs:10:13: 10:14 + let mut _4: Foo; // in scope 0 at $DIR/deaggregator_test_multiple.rs:10:17: 10:26 + let mut _5: i32; // in scope 0 at $DIR/deaggregator_test_multiple.rs:10:24: 10:25 + + bb0: { + StorageLive(_2); // bb0[0]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:6: 10:15 + StorageLive(_3); // bb0[1]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:13: 10:14 + _3 = _1; // bb0[2]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:13: 10:14 +- _2 = Foo::A(move _3,); // bb0[3]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:6: 10:15 +- StorageDead(_3); // bb0[4]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:14: 10:15 +- StorageLive(_4); // bb0[5]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:17: 10:26 +- StorageLive(_5); // bb0[6]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:24: 10:25 +- _5 = _1; // bb0[7]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:24: 10:25 +- _4 = Foo::A(move _5,); // bb0[8]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:17: 10:26 +- StorageDead(_5); // bb0[9]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:25: 10:26 +- _0 = [move _2, move _4]; // bb0[10]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:5: 10:27 +- StorageDead(_4); // bb0[11]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:26: 10:27 +- StorageDead(_2); // bb0[12]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:26: 10:27 +- return; // bb0[13]: scope 0 at $DIR/deaggregator_test_multiple.rs:11:2: 11:2 ++ ((_2 as A).0: i32) = move _3; // bb0[3]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:6: 10:15 ++ discriminant(_2) = 0; // bb0[4]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:6: 10:15 ++ StorageDead(_3); // bb0[5]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:14: 10:15 ++ StorageLive(_4); // bb0[6]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:17: 10:26 ++ StorageLive(_5); // bb0[7]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:24: 10:25 ++ _5 = _1; // bb0[8]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:24: 10:25 ++ ((_4 as A).0: i32) = move _5; // bb0[9]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:17: 10:26 ++ discriminant(_4) = 0; // bb0[10]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:17: 10:26 ++ StorageDead(_5); // bb0[11]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:25: 10:26 ++ _0 = [move _2, move _4]; // bb0[12]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:5: 10:27 ++ StorageDead(_4); // bb0[13]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:26: 10:27 ++ StorageDead(_2); // bb0[14]: scope 0 at $DIR/deaggregator_test_multiple.rs:10:26: 10:27 ++ return; // bb0[15]: scope 0 at $DIR/deaggregator_test_multiple.rs:11:2: 11:2 + } + } + diff --git a/src/test/mir-opt/exponential-or.rs b/src/test/mir-opt/exponential-or.rs index 4c23582e1f8..9fce7928f6a 100644 --- a/src/test/mir-opt/exponential-or.rs +++ b/src/test/mir-opt/exponential-or.rs @@ -1,9 +1,8 @@ // Test that simple or-patterns don't get expanded to exponentially large CFGs -// ignore-tidy-linelength - #![feature(or_patterns)] +// EMIT_MIR rustc.match_tuple.SimplifyCfg-initial.after.mir fn match_tuple(x: (u32, bool, Option<i32>, u32)) -> u32 { match x { (y @ (1 | 4), true | false, Some(1 | 8) | None, z @ (6..=9 | 13..=16)) => y ^ z, @@ -12,65 +11,3 @@ fn match_tuple(x: (u32, bool, Option<i32>, u32)) -> u32 { } fn main() {} - -// END RUST SOURCE - -// START rustc.match_tuple.SimplifyCfg-initial.after.mir -// scope 1 { -// debug y => _7; -// debug z => _8; -// } -// bb0: { -// FakeRead(ForMatchedPlace, _1); -// switchInt((_1.0: u32)) -> [1u32: bb2, 4u32: bb2, otherwise: bb1]; -// } -// bb1: { -// _0 = const 0u32; -// goto -> bb10; -// } -// bb2: { -// _2 = discriminant((_1.2: std::option::Option<i32>)); -// switchInt(move _2) -> [0isize: bb4, 1isize: bb3, otherwise: bb1]; -// } -// bb3: { -// switchInt((((_1.2: std::option::Option<i32>) as Some).0: i32)) -> [1i32: bb4, 8i32: bb4, otherwise: bb1]; -// } -// bb4: { -// _5 = Le(const 6u32, (_1.3: u32)); -// switchInt(move _5) -> [false: bb6, otherwise: bb5]; -// } -// bb5: { -// _6 = Le((_1.3: u32), const 9u32); -// switchInt(move _6) -> [false: bb6, otherwise: bb8]; -// } -// bb6: { -// _3 = Le(const 13u32, (_1.3: u32)); -// switchInt(move _3) -> [false: bb1, otherwise: bb7]; -// } -// bb7: { -// _4 = Le((_1.3: u32), const 16u32); -// switchInt(move _4) -> [false: bb1, otherwise: bb8]; -// } -// bb8: { -// falseEdges -> [real: bb9, imaginary: bb1]; -// } -// bb9: { -// StorageLive(_7); -// _7 = (_1.0: u32); -// StorageLive(_8); -// _8 = (_1.3: u32); -// StorageLive(_9); -// _9 = _7; -// StorageLive(_10); -// _10 = _8; -// _0 = BitXor(move _9, move _10); -// StorageDead(_10); -// StorageDead(_9); -// StorageDead(_8); -// StorageDead(_7); -// goto -> bb10; -// } -// bb10: { -// return; -// } -// END rustc.match_tuple.SimplifyCfg-initial.after.mir diff --git a/src/test/mir-opt/exponential-or/rustc.match_tuple.SimplifyCfg-initial.after.mir b/src/test/mir-opt/exponential-or/rustc.match_tuple.SimplifyCfg-initial.after.mir new file mode 100644 index 00000000000..192ec1bbe21 --- /dev/null +++ b/src/test/mir-opt/exponential-or/rustc.match_tuple.SimplifyCfg-initial.after.mir @@ -0,0 +1,113 @@ +// MIR for `match_tuple` after SimplifyCfg-initial + +fn match_tuple(_1: (u32, bool, std::option::Option<i32>, u32)) -> u32 { + debug x => _1; // in scope 0 at $DIR/exponential-or.rs:6:16: 6:17 + let mut _0: u32; // return place in scope 0 at $DIR/exponential-or.rs:6:53: 6:56 + let mut _2: isize; // in scope 0 at $DIR/exponential-or.rs:8:37: 8:48 + let mut _3: bool; // in scope 0 at $DIR/exponential-or.rs:8:70: 8:77 + let mut _4: bool; // in scope 0 at $DIR/exponential-or.rs:8:70: 8:77 + let mut _5: bool; // in scope 0 at $DIR/exponential-or.rs:8:62: 8:67 + let mut _6: bool; // in scope 0 at $DIR/exponential-or.rs:8:62: 8:67 + let _7: u32; // in scope 0 at $DIR/exponential-or.rs:8:10: 8:21 + let _8: u32; // in scope 0 at $DIR/exponential-or.rs:8:57: 8:78 + let mut _9: u32; // in scope 0 at $DIR/exponential-or.rs:8:83: 8:84 + let mut _10: u32; // in scope 0 at $DIR/exponential-or.rs:8:87: 8:88 + scope 1 { + debug y => _7; // in scope 1 at $DIR/exponential-or.rs:8:10: 8:21 + debug z => _8; // in scope 1 at $DIR/exponential-or.rs:8:57: 8:78 + } + + bb0: { + FakeRead(ForMatchedPlace, _1); // bb0[0]: scope 0 at $DIR/exponential-or.rs:7:11: 7:12 + switchInt((_1.0: u32)) -> [1u32: bb2, 4u32: bb2, otherwise: bb1]; // bb0[1]: scope 0 at $DIR/exponential-or.rs:8:15: 8:16 + } + + bb1: { + _0 = const 0u32; // bb1[0]: scope 0 at $DIR/exponential-or.rs:9:14: 9:15 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/exponential-or.rs:9:14: 9:15 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + goto -> bb10; // bb1[1]: scope 0 at $DIR/exponential-or.rs:7:5: 10:6 + } + + bb2: { + _2 = discriminant((_1.2: std::option::Option<i32>)); // bb2[0]: scope 0 at $DIR/exponential-or.rs:8:37: 8:48 + switchInt(move _2) -> [0isize: bb4, 1isize: bb3, otherwise: bb1]; // bb2[1]: scope 0 at $DIR/exponential-or.rs:8:37: 8:48 + } + + bb3: { + switchInt((((_1.2: std::option::Option<i32>) as Some).0: i32)) -> [1i32: bb4, 8i32: bb4, otherwise: bb1]; // bb3[0]: scope 0 at $DIR/exponential-or.rs:8:42: 8:43 + } + + bb4: { + _5 = Le(const 6u32, (_1.3: u32)); // bb4[0]: scope 0 at $DIR/exponential-or.rs:8:62: 8:67 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000006)) + // mir::Constant + // + span: $DIR/exponential-or.rs:8:62: 8:67 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000006)) } + switchInt(move _5) -> [false: bb6, otherwise: bb5]; // bb4[1]: scope 0 at $DIR/exponential-or.rs:8:62: 8:67 + } + + bb5: { + _6 = Le((_1.3: u32), const 9u32); // bb5[0]: scope 0 at $DIR/exponential-or.rs:8:62: 8:67 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000009)) + // mir::Constant + // + span: $DIR/exponential-or.rs:8:62: 8:67 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000009)) } + switchInt(move _6) -> [false: bb6, otherwise: bb8]; // bb5[1]: scope 0 at $DIR/exponential-or.rs:8:62: 8:67 + } + + bb6: { + _3 = Le(const 13u32, (_1.3: u32)); // bb6[0]: scope 0 at $DIR/exponential-or.rs:8:70: 8:77 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x0000000d)) + // mir::Constant + // + span: $DIR/exponential-or.rs:8:70: 8:77 + // + literal: Const { ty: u32, val: Value(Scalar(0x0000000d)) } + switchInt(move _3) -> [false: bb1, otherwise: bb7]; // bb6[1]: scope 0 at $DIR/exponential-or.rs:8:70: 8:77 + } + + bb7: { + _4 = Le((_1.3: u32), const 16u32); // bb7[0]: scope 0 at $DIR/exponential-or.rs:8:70: 8:77 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000010)) + // mir::Constant + // + span: $DIR/exponential-or.rs:8:70: 8:77 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000010)) } + switchInt(move _4) -> [false: bb1, otherwise: bb8]; // bb7[1]: scope 0 at $DIR/exponential-or.rs:8:70: 8:77 + } + + bb8: { + falseEdges -> [real: bb9, imaginary: bb1]; // bb8[0]: scope 0 at $DIR/exponential-or.rs:8:9: 8:79 + } + + bb9: { + StorageLive(_7); // bb9[0]: scope 0 at $DIR/exponential-or.rs:8:10: 8:21 + _7 = (_1.0: u32); // bb9[1]: scope 0 at $DIR/exponential-or.rs:8:10: 8:21 + StorageLive(_8); // bb9[2]: scope 0 at $DIR/exponential-or.rs:8:57: 8:78 + _8 = (_1.3: u32); // bb9[3]: scope 0 at $DIR/exponential-or.rs:8:57: 8:78 + StorageLive(_9); // bb9[4]: scope 1 at $DIR/exponential-or.rs:8:83: 8:84 + _9 = _7; // bb9[5]: scope 1 at $DIR/exponential-or.rs:8:83: 8:84 + StorageLive(_10); // bb9[6]: scope 1 at $DIR/exponential-or.rs:8:87: 8:88 + _10 = _8; // bb9[7]: scope 1 at $DIR/exponential-or.rs:8:87: 8:88 + _0 = BitXor(move _9, move _10); // bb9[8]: scope 1 at $DIR/exponential-or.rs:8:83: 8:88 + StorageDead(_10); // bb9[9]: scope 1 at $DIR/exponential-or.rs:8:87: 8:88 + StorageDead(_9); // bb9[10]: scope 1 at $DIR/exponential-or.rs:8:87: 8:88 + StorageDead(_8); // bb9[11]: scope 0 at $DIR/exponential-or.rs:8:88: 8:89 + StorageDead(_7); // bb9[12]: scope 0 at $DIR/exponential-or.rs:8:88: 8:89 + goto -> bb10; // bb9[13]: scope 0 at $DIR/exponential-or.rs:7:5: 10:6 + } + + bb10: { + return; // bb10[0]: scope 0 at $DIR/exponential-or.rs:11:2: 11:2 + } +} diff --git a/src/test/mir-opt/generator-drop-cleanup.rs b/src/test/mir-opt/generator-drop-cleanup.rs index 278dc49c926..1c3025d5e3f 100644 --- a/src/test/mir-opt/generator-drop-cleanup.rs +++ b/src/test/mir-opt/generator-drop-cleanup.rs @@ -3,45 +3,9 @@ // Regression test for #58892, generator drop shims should not have blocks // spuriously marked as cleanup +// EMIT_MIR rustc.main-{{closure}}.generator_drop.0.mir fn main() { let gen = || { yield; }; } - -// END RUST SOURCE - -// START rustc.main-{{closure}}.generator_drop.0.mir -// bb0: { -// _7 = discriminant((*_1)); -// switchInt(move _7) -> [0u32: bb4, 3u32: bb7, otherwise: bb8]; -// } -// bb1: { -// StorageDead(_4); -// StorageDead(_3); -// goto -> bb5; -// } -// bb2: { -// return; -// } -// bb3: { -// return; -// } -// bb4: { -// goto -> bb6; -// } -// bb5: { -// goto -> bb2; -// } -// bb6: { -// goto -> bb3; -// } -// bb7: { -// StorageLive(_3); -// StorageLive(_4); -// goto -> bb1; -// } -// bb8: { -// return; -// } -// END rustc.main-{{closure}}.generator_drop.0.mir diff --git a/src/test/mir-opt/generator-drop-cleanup/rustc.main-{{closure}}.generator_drop.0.mir b/src/test/mir-opt/generator-drop-cleanup/rustc.main-{{closure}}.generator_drop.0.mir new file mode 100644 index 00000000000..05ed0a641af --- /dev/null +++ b/src/test/mir-opt/generator-drop-cleanup/rustc.main-{{closure}}.generator_drop.0.mir @@ -0,0 +1,53 @@ +// MIR for `main::{{closure}}#0` 0 generator_drop +// generator_layout = GeneratorLayout { field_tys: [], variant_fields: [[], [], [], []], storage_conflicts: BitMatrix { num_rows: 0, num_columns: 0, words: [], marker: PhantomData } } + +fn main::{{closure}}#0(_1: *mut [generator@$DIR/generator-drop-cleanup.rs:8:15: 10:6 {()}]) -> () { + let mut _0: (); // return place in scope 0 at $DIR/generator-drop-cleanup.rs:8:15: 10:6 + let mut _2: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:8:15: 10:6 + let _3: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:9:9: 9:14 + let mut _4: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:9:9: 9:14 + let mut _5: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:8:18: 8:18 + let mut _6: (); // in scope 0 at $DIR/generator-drop-cleanup.rs:8:15: 10:6 + let mut _7: isize; // in scope 0 at $DIR/generator-drop-cleanup.rs:8:15: 10:6 + + bb0: { + _7 = discriminant((*_1)); // bb0[0]: scope 0 at $DIR/generator-drop-cleanup.rs:8:15: 10:6 + switchInt(move _7) -> [0u32: bb4, 3u32: bb7, otherwise: bb8]; // bb0[1]: scope 0 at $DIR/generator-drop-cleanup.rs:8:15: 10:6 + } + + bb1: { + StorageDead(_4); // bb1[0]: scope 0 at $DIR/generator-drop-cleanup.rs:9:13: 9:14 + StorageDead(_3); // bb1[1]: scope 0 at $DIR/generator-drop-cleanup.rs:9:14: 9:15 + goto -> bb5; // bb1[2]: scope 0 at $DIR/generator-drop-cleanup.rs:10:5: 10:6 + } + + bb2: { + return; // bb2[0]: scope 0 at $DIR/generator-drop-cleanup.rs:8:15: 10:6 + } + + bb3: { + return; // bb3[0]: scope 0 at $DIR/generator-drop-cleanup.rs:8:15: 10:6 + } + + bb4: { + goto -> bb6; // bb4[0]: scope 0 at $DIR/generator-drop-cleanup.rs:8:15: 10:6 + } + + bb5: { + goto -> bb2; // bb5[0]: scope 0 at $DIR/generator-drop-cleanup.rs:10:5: 10:6 + } + + bb6: { + goto -> bb3; // bb6[0]: scope 0 at $DIR/generator-drop-cleanup.rs:8:15: 10:6 + } + + bb7: { + StorageLive(_3); // bb7[0]: scope 0 at $DIR/generator-drop-cleanup.rs:8:15: 10:6 + StorageLive(_4); // bb7[1]: scope 0 at $DIR/generator-drop-cleanup.rs:8:15: 10:6 + goto -> bb1; // bb7[2]: scope 0 at $DIR/generator-drop-cleanup.rs:8:15: 10:6 + } + + bb8: { + return; // bb8[0]: scope 0 at $DIR/generator-drop-cleanup.rs:8:15: 10:6 + } +} diff --git a/src/test/mir-opt/generator-storage-dead-unwind.rs b/src/test/mir-opt/generator-storage-dead-unwind.rs index 82b216a99cf..abfb39c77d6 100644 --- a/src/test/mir-opt/generator-storage-dead-unwind.rs +++ b/src/test/mir-opt/generator-storage-dead-unwind.rs @@ -17,6 +17,7 @@ struct Bar(i32); fn take<T>(_x: T) {} +// EMIT_MIR rustc.main-{{closure}}.StateTransform.before.mir fn main() { let _gen = || { let a = Foo(5); @@ -26,89 +27,3 @@ fn main() { take(b); }; } - -// END RUST SOURCE - -// START rustc.main-{{closure}}.StateTransform.before.mir -// ... -// let _3: Foo; -// ... -// let mut _8: Foo; -// ... -// let mut _10: Bar; -// scope 1 { -// debug a => _3; -// let _4: Bar; -// scope 2 { -// debug b => _4; -// } -// } -// bb0: { -// StorageLive(_3); -// _3 = Foo(const 5i32,); -// StorageLive(_4); -// _4 = Bar(const 6i32,); -// ... -// _5 = yield(move _6) -> [resume: bb2, drop: bb4]; -// } -// bb1 (cleanup): { -// resume; -// } -// bb2: { -// ... -// StorageLive(_7); -// StorageLive(_8); -// _8 = move _3; -// _7 = const take::<Foo>(move _8) -> [return: bb7, unwind: bb9]; -// } -// bb3 (cleanup): { -// StorageDead(_3); -// drop(_1) -> bb1; -// } -// bb4: { -// ... -// StorageDead(_4); -// drop(_3) -> [return: bb5, unwind: bb3]; -// } -// bb5: { -// StorageDead(_3); -// drop(_1) -> [return: bb6, unwind: bb1]; -// } -// bb6: { -// generator_drop; -// } -// bb7: { -// StorageDead(_8); -// StorageDead(_7); -// StorageLive(_9); -// StorageLive(_10); -// _10 = move _4; -// _9 = const take::<Bar>(move _10) -> [return: bb10, unwind: bb11]; -// } -// bb8 (cleanup): { -// StorageDead(_4); -// StorageDead(_3); -// drop(_1) -> bb1; -// } -// bb9 (cleanup): { -// StorageDead(_8); -// StorageDead(_7); -// goto -> bb8; -// } -// bb10: { -// StorageDead(_10); -// StorageDead(_9); -// ... -// StorageDead(_4); -// StorageDead(_3); -// drop(_1) -> [return: bb12, unwind: bb1]; -// } -// bb11 (cleanup): { -// StorageDead(_10); -// StorageDead(_9); -// goto -> bb8; -// } -// bb12: { -// return; -// } -// END rustc.main-{{closure}}.StateTransform.before.mir diff --git a/src/test/mir-opt/generator-storage-dead-unwind/rustc.main-{{closure}}.StateTransform.before.mir b/src/test/mir-opt/generator-storage-dead-unwind/rustc.main-{{closure}}.StateTransform.before.mir new file mode 100644 index 00000000000..cc22982a515 --- /dev/null +++ b/src/test/mir-opt/generator-storage-dead-unwind/rustc.main-{{closure}}.StateTransform.before.mir @@ -0,0 +1,130 @@ +// MIR for `main::{{closure}}#0` before StateTransform + +fn main::{{closure}}#0(_1: [generator@$DIR/generator-storage-dead-unwind.rs:22:16: 28:6 {Foo, Bar, ()}], _2: ()) -> () +yields () + { + let mut _0: (); // return place in scope 0 at $DIR/generator-storage-dead-unwind.rs:22:19: 22:19 + let _3: Foo; // in scope 0 at $DIR/generator-storage-dead-unwind.rs:23:13: 23:14 + let _5: (); // in scope 0 at $DIR/generator-storage-dead-unwind.rs:25:9: 25:14 + let mut _6: (); // in scope 0 at $DIR/generator-storage-dead-unwind.rs:25:9: 25:14 + let _7: (); // in scope 0 at $DIR/generator-storage-dead-unwind.rs:26:9: 26:16 + let mut _8: Foo; // in scope 0 at $DIR/generator-storage-dead-unwind.rs:26:14: 26:15 + let _9: (); // in scope 0 at $DIR/generator-storage-dead-unwind.rs:27:9: 27:16 + let mut _10: Bar; // in scope 0 at $DIR/generator-storage-dead-unwind.rs:27:14: 27:15 + scope 1 { + debug a => _3; // in scope 1 at $DIR/generator-storage-dead-unwind.rs:23:13: 23:14 + let _4: Bar; // in scope 1 at $DIR/generator-storage-dead-unwind.rs:24:13: 24:14 + scope 2 { + debug b => _4; // in scope 2 at $DIR/generator-storage-dead-unwind.rs:24:13: 24:14 + } + } + + bb0: { + StorageLive(_3); // bb0[0]: scope 0 at $DIR/generator-storage-dead-unwind.rs:23:13: 23:14 + _3 = Foo(const 5i32,); // bb0[1]: scope 0 at $DIR/generator-storage-dead-unwind.rs:23:17: 23:23 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000005)) + // mir::Constant + // + span: $DIR/generator-storage-dead-unwind.rs:23:21: 23:22 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000005)) } + StorageLive(_4); // bb0[2]: scope 1 at $DIR/generator-storage-dead-unwind.rs:24:13: 24:14 + _4 = Bar(const 6i32,); // bb0[3]: scope 1 at $DIR/generator-storage-dead-unwind.rs:24:17: 24:23 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000006)) + // mir::Constant + // + span: $DIR/generator-storage-dead-unwind.rs:24:21: 24:22 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000006)) } + StorageLive(_5); // bb0[4]: scope 2 at $DIR/generator-storage-dead-unwind.rs:25:9: 25:14 + StorageLive(_6); // bb0[5]: scope 2 at $DIR/generator-storage-dead-unwind.rs:25:9: 25:14 + _6 = (); // bb0[6]: scope 2 at $DIR/generator-storage-dead-unwind.rs:25:9: 25:14 + _5 = yield(move _6) -> [resume: bb2, drop: bb4]; // bb0[7]: scope 2 at $DIR/generator-storage-dead-unwind.rs:25:9: 25:14 + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/generator-storage-dead-unwind.rs:22:16: 28:6 + } + + bb2: { + StorageDead(_6); // bb2[0]: scope 2 at $DIR/generator-storage-dead-unwind.rs:25:13: 25:14 + StorageDead(_5); // bb2[1]: scope 2 at $DIR/generator-storage-dead-unwind.rs:25:14: 25:15 + StorageLive(_7); // bb2[2]: scope 2 at $DIR/generator-storage-dead-unwind.rs:26:9: 26:16 + StorageLive(_8); // bb2[3]: scope 2 at $DIR/generator-storage-dead-unwind.rs:26:14: 26:15 + _8 = move _3; // bb2[4]: scope 2 at $DIR/generator-storage-dead-unwind.rs:26:14: 26:15 + _7 = const take::<Foo>(move _8) -> [return: bb7, unwind: bb9]; // bb2[5]: scope 2 at $DIR/generator-storage-dead-unwind.rs:26:9: 26:16 + // ty::Const + // + ty: fn(Foo) {take::<Foo>} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/generator-storage-dead-unwind.rs:26:9: 26:13 + // + literal: Const { ty: fn(Foo) {take::<Foo>}, val: Value(Scalar(<ZST>)) } + } + + bb3 (cleanup): { + StorageDead(_3); // bb3[0]: scope 0 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6 + drop(_1) -> bb1; // bb3[1]: scope 0 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6 + } + + bb4: { + StorageDead(_6); // bb4[0]: scope 2 at $DIR/generator-storage-dead-unwind.rs:25:13: 25:14 + StorageDead(_5); // bb4[1]: scope 2 at $DIR/generator-storage-dead-unwind.rs:25:14: 25:15 + StorageDead(_4); // bb4[2]: scope 1 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6 + drop(_3) -> [return: bb5, unwind: bb3]; // bb4[3]: scope 0 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6 + } + + bb5: { + StorageDead(_3); // bb5[0]: scope 0 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6 + drop(_1) -> [return: bb6, unwind: bb1]; // bb5[1]: scope 0 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6 + } + + bb6: { + generator_drop; // bb6[0]: scope 0 at $DIR/generator-storage-dead-unwind.rs:22:16: 28:6 + } + + bb7: { + StorageDead(_8); // bb7[0]: scope 2 at $DIR/generator-storage-dead-unwind.rs:26:15: 26:16 + StorageDead(_7); // bb7[1]: scope 2 at $DIR/generator-storage-dead-unwind.rs:26:16: 26:17 + StorageLive(_9); // bb7[2]: scope 2 at $DIR/generator-storage-dead-unwind.rs:27:9: 27:16 + StorageLive(_10); // bb7[3]: scope 2 at $DIR/generator-storage-dead-unwind.rs:27:14: 27:15 + _10 = move _4; // bb7[4]: scope 2 at $DIR/generator-storage-dead-unwind.rs:27:14: 27:15 + _9 = const take::<Bar>(move _10) -> [return: bb10, unwind: bb11]; // bb7[5]: scope 2 at $DIR/generator-storage-dead-unwind.rs:27:9: 27:16 + // ty::Const + // + ty: fn(Bar) {take::<Bar>} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/generator-storage-dead-unwind.rs:27:9: 27:13 + // + literal: Const { ty: fn(Bar) {take::<Bar>}, val: Value(Scalar(<ZST>)) } + } + + bb8 (cleanup): { + StorageDead(_4); // bb8[0]: scope 1 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6 + StorageDead(_3); // bb8[1]: scope 0 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6 + drop(_1) -> bb1; // bb8[2]: scope 0 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6 + } + + bb9 (cleanup): { + StorageDead(_8); // bb9[0]: scope 2 at $DIR/generator-storage-dead-unwind.rs:26:15: 26:16 + StorageDead(_7); // bb9[1]: scope 2 at $DIR/generator-storage-dead-unwind.rs:26:16: 26:17 + goto -> bb8; // bb9[2]: scope 2 at $DIR/generator-storage-dead-unwind.rs:1:1: 1:1 + } + + bb10: { + StorageDead(_10); // bb10[0]: scope 2 at $DIR/generator-storage-dead-unwind.rs:27:15: 27:16 + StorageDead(_9); // bb10[1]: scope 2 at $DIR/generator-storage-dead-unwind.rs:27:16: 27:17 + _0 = (); // bb10[2]: scope 0 at $DIR/generator-storage-dead-unwind.rs:22:19: 28:6 + StorageDead(_4); // bb10[3]: scope 1 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6 + StorageDead(_3); // bb10[4]: scope 0 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6 + drop(_1) -> [return: bb12, unwind: bb1]; // bb10[5]: scope 0 at $DIR/generator-storage-dead-unwind.rs:28:5: 28:6 + } + + bb11 (cleanup): { + StorageDead(_10); // bb11[0]: scope 2 at $DIR/generator-storage-dead-unwind.rs:27:15: 27:16 + StorageDead(_9); // bb11[1]: scope 2 at $DIR/generator-storage-dead-unwind.rs:27:16: 27:17 + goto -> bb8; // bb11[2]: scope 2 at $DIR/generator-storage-dead-unwind.rs:1:1: 1:1 + } + + bb12: { + return; // bb12[0]: scope 0 at $DIR/generator-storage-dead-unwind.rs:28:6: 28:6 + } +} diff --git a/src/test/mir-opt/generator-tiny.rs b/src/test/mir-opt/generator-tiny.rs index 09e943bd962..b537263dd1b 100644 --- a/src/test/mir-opt/generator-tiny.rs +++ b/src/test/mir-opt/generator-tiny.rs @@ -13,6 +13,7 @@ impl Drop for HasDrop { fn callee() {} +// EMIT_MIR rustc.main-{{closure}}.generator_resume.0.mir fn main() { let _gen = |_x: u8| { let _d = HasDrop; @@ -22,13 +23,3 @@ fn main() { } }; } - -// END RUST SOURCE - -// START rustc.main-{{closure}}.generator_resume.0.mir -// bb0: { -// ... -// switchInt(move _11) -> [0u32: bb1, 3u32: bb5, otherwise: bb6]; -// } -// ... -// END rustc.main-{{closure}}.generator_resume.0.mir diff --git a/src/test/mir-opt/generator-tiny/rustc.main-{{closure}}.generator_resume.0.mir b/src/test/mir-opt/generator-tiny/rustc.main-{{closure}}.generator_resume.0.mir new file mode 100644 index 00000000000..a79f0d53f3c --- /dev/null +++ b/src/test/mir-opt/generator-tiny/rustc.main-{{closure}}.generator_resume.0.mir @@ -0,0 +1,72 @@ +// MIR for `main::{{closure}}#0` 0 generator_resume +// generator_layout = GeneratorLayout { field_tys: [HasDrop], variant_fields: [[], [], [], [_0]], storage_conflicts: BitMatrix { num_rows: 1, num_columns: 1, words: [1], marker: PhantomData } } + +fn main::{{closure}}#0(_1: std::pin::Pin<&mut [generator@$DIR/generator-tiny.rs:18:16: 24:6 {u8, HasDrop, ()}]>, _2: u8) -> std::ops::GeneratorState<(), ()> { + debug _x => _10; // in scope 0 at $DIR/generator-tiny.rs:18:17: 18:19 + let mut _0: std::ops::GeneratorState<(), ()>; // return place in scope 0 at $DIR/generator-tiny.rs:18:16: 24:6 + let _3: HasDrop; // in scope 0 at $DIR/generator-tiny.rs:19:13: 19:15 + let mut _4: !; // in scope 0 at $DIR/generator-tiny.rs:20:9: 23:10 + let mut _5: (); // in scope 0 at $DIR/generator-tiny.rs:18:16: 24:6 + let _6: u8; // in scope 0 at $DIR/generator-tiny.rs:21:13: 21:18 + let mut _7: (); // in scope 0 at $DIR/generator-tiny.rs:21:13: 21:18 + let _8: (); // in scope 0 at $DIR/generator-tiny.rs:22:13: 22:21 + let mut _9: (); // in scope 0 at $DIR/generator-tiny.rs:18:25: 18:25 + let _10: u8; // in scope 0 at $DIR/generator-tiny.rs:18:17: 18:19 + let mut _11: isize; // in scope 0 at $DIR/generator-tiny.rs:18:16: 24:6 + scope 1 { + debug _d => (((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:18:16: 24:6 {u8, HasDrop, ()}])) as variant#3).0: HasDrop); // in scope 1 at $DIR/generator-tiny.rs:19:13: 19:15 + } + + bb0: { + _11 = discriminant((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:18:16: 24:6 {u8, HasDrop, ()}]))); // bb0[0]: scope 0 at $DIR/generator-tiny.rs:18:16: 24:6 + switchInt(move _11) -> [0u32: bb1, 3u32: bb5, otherwise: bb6]; // bb0[1]: scope 0 at $DIR/generator-tiny.rs:18:16: 24:6 + } + + bb1: { + _10 = move _2; // bb1[0]: scope 0 at $DIR/generator-tiny.rs:18:16: 24:6 + nop; // bb1[1]: scope 0 at $DIR/generator-tiny.rs:19:13: 19:15 + (((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:18:16: 24:6 {u8, HasDrop, ()}])) as variant#3).0: HasDrop) = HasDrop; // bb1[2]: scope 0 at $DIR/generator-tiny.rs:19:18: 19:25 + StorageLive(_4); // bb1[3]: scope 1 at $DIR/generator-tiny.rs:20:9: 23:10 + goto -> bb2; // bb1[4]: scope 1 at $DIR/generator-tiny.rs:20:9: 23:10 + } + + bb2: { + StorageLive(_6); // bb2[0]: scope 1 at $DIR/generator-tiny.rs:21:13: 21:18 + StorageLive(_7); // bb2[1]: scope 1 at $DIR/generator-tiny.rs:21:13: 21:18 + _7 = (); // bb2[2]: scope 1 at $DIR/generator-tiny.rs:21:13: 21:18 + _0 = std::ops::GeneratorState::<(), ()>::Yielded(move _7,); // bb2[3]: scope 1 at $DIR/generator-tiny.rs:21:13: 21:18 + discriminant((*(_1.0: &mut [generator@$DIR/generator-tiny.rs:18:16: 24:6 {u8, HasDrop, ()}]))) = 3; // bb2[4]: scope 1 at $DIR/generator-tiny.rs:21:13: 21:18 + return; // bb2[5]: scope 1 at $DIR/generator-tiny.rs:21:13: 21:18 + } + + bb3: { + StorageDead(_7); // bb3[0]: scope 1 at $DIR/generator-tiny.rs:21:17: 21:18 + StorageDead(_6); // bb3[1]: scope 1 at $DIR/generator-tiny.rs:21:18: 21:19 + StorageLive(_8); // bb3[2]: scope 1 at $DIR/generator-tiny.rs:22:13: 22:21 + _8 = const callee() -> bb4; // bb3[3]: scope 1 at $DIR/generator-tiny.rs:22:13: 22:21 + // ty::Const + // + ty: fn() {callee} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/generator-tiny.rs:22:13: 22:19 + // + literal: Const { ty: fn() {callee}, val: Value(Scalar(<ZST>)) } + } + + bb4: { + StorageDead(_8); // bb4[0]: scope 1 at $DIR/generator-tiny.rs:22:21: 22:22 + _5 = (); // bb4[1]: scope 1 at $DIR/generator-tiny.rs:20:14: 23:10 + goto -> bb2; // bb4[2]: scope 1 at $DIR/generator-tiny.rs:20:9: 23:10 + } + + bb5: { + StorageLive(_4); // bb5[0]: scope 0 at $DIR/generator-tiny.rs:18:16: 24:6 + StorageLive(_6); // bb5[1]: scope 0 at $DIR/generator-tiny.rs:18:16: 24:6 + StorageLive(_7); // bb5[2]: scope 0 at $DIR/generator-tiny.rs:18:16: 24:6 + _6 = move _2; // bb5[3]: scope 0 at $DIR/generator-tiny.rs:18:16: 24:6 + goto -> bb3; // bb5[4]: scope 0 at $DIR/generator-tiny.rs:18:16: 24:6 + } + + bb6: { + unreachable; // bb6[0]: scope 0 at $DIR/generator-tiny.rs:18:16: 24:6 + } +} diff --git a/src/test/mir-opt/graphviz.rs b/src/test/mir-opt/graphviz.rs index fcbb189c111..b1c0f0dd3c8 100644 --- a/src/test/mir-opt/graphviz.rs +++ b/src/test/mir-opt/graphviz.rs @@ -1,20 +1,5 @@ // Test graphviz output // compile-flags: -Z dump-mir-graphviz -// ignore-tidy-linelength - +// EMIT_MIR rustc.main.mir_map.0.dot fn main() {} - -// END RUST SOURCE -// START rustc.main.mir_map.0.dot -// digraph Mir_0_3 { // The name here MUST be an ASCII identifier. -// graph [fontname="monospace"]; -// node [fontname="monospace"]; -// edge [fontname="monospace"]; -// label=<fn main() -> ()<br align="left"/>>; -// bb0__0_3 [shape="none", label=<<table border="0" cellborder="1" cellspacing="0"><tr><td bgcolor="gray" align="center" colspan="1">0</td></tr><tr><td align="left" balign="left">_0 = ()<br/></td></tr><tr><td align="left">goto</td></tr></table>>]; -// bb1__0_3 [shape="none", label=<<table border="0" cellborder="1" cellspacing="0"><tr><td bgcolor="gray" align="center" colspan="1">1</td></tr><tr><td align="left">resume</td></tr></table>>]; -// bb2__0_3 [shape="none", label=<<table border="0" cellborder="1" cellspacing="0"><tr><td bgcolor="gray" align="center" colspan="1">2</td></tr><tr><td align="left">return</td></tr></table>>]; -// bb0__0_3 -> bb2__0_3 [label=""]; -// } -// END rustc.main.mir_map.0.dot diff --git a/src/test/mir-opt/graphviz/rustc.main.mir_map.0.dot b/src/test/mir-opt/graphviz/rustc.main.mir_map.0.dot new file mode 100644 index 00000000000..2caef3459b8 --- /dev/null +++ b/src/test/mir-opt/graphviz/rustc.main.mir_map.0.dot @@ -0,0 +1,10 @@ +digraph Mir_0_3 { + graph [fontname="monospace"]; + node [fontname="monospace"]; + edge [fontname="monospace"]; + label=<fn main() -> ()<br align="left"/>>; + bb0__0_3 [shape="none", label=<<table border="0" cellborder="1" cellspacing="0"><tr><td bgcolor="gray" align="center" colspan="1">0</td></tr><tr><td align="left" balign="left">_0 = ()<br/></td></tr><tr><td align="left">goto</td></tr></table>>]; + bb1__0_3 [shape="none", label=<<table border="0" cellborder="1" cellspacing="0"><tr><td bgcolor="gray" align="center" colspan="1">1</td></tr><tr><td align="left">resume</td></tr></table>>]; + bb2__0_3 [shape="none", label=<<table border="0" cellborder="1" cellspacing="0"><tr><td bgcolor="gray" align="center" colspan="1">2</td></tr><tr><td align="left">return</td></tr></table>>]; + bb0__0_3 -> bb2__0_3 [label=""]; +} diff --git a/src/test/mir-opt/inline/inline-any-operand.rs b/src/test/mir-opt/inline/inline-any-operand.rs index b5455003719..2edde12d72e 100644 --- a/src/test/mir-opt/inline/inline-any-operand.rs +++ b/src/test/mir-opt/inline/inline-any-operand.rs @@ -6,6 +6,7 @@ fn main() { println!("{}", bar()); } +// EMIT_MIR rustc.bar.Inline.after.mir fn bar() -> bool { let f = foo; f(1, -1) @@ -15,15 +16,3 @@ fn bar() -> bool { fn foo(x: i32, y: i32) -> bool { x == y } - -// END RUST SOURCE -// START rustc.bar.Inline.after.mir -// ... -// bb0: { -// ... -// _0 = Eq(move _3, move _4); -// ... -// return; -// } -// ... -// END rustc.bar.Inline.after.mir diff --git a/src/test/mir-opt/inline/inline-any-operand/rustc.bar.Inline.after.mir b/src/test/mir-opt/inline/inline-any-operand/rustc.bar.Inline.after.mir new file mode 100644 index 00000000000..058d9e70d26 --- /dev/null +++ b/src/test/mir-opt/inline/inline-any-operand/rustc.bar.Inline.after.mir @@ -0,0 +1,47 @@ +// MIR for `bar` after Inline + +fn bar() -> bool { + let mut _0: bool; // return place in scope 0 at $DIR/inline-any-operand.rs:10:13: 10:17 + let _1: fn(i32, i32) -> bool {foo}; // in scope 0 at $DIR/inline-any-operand.rs:11:9: 11:10 + let mut _2: fn(i32, i32) -> bool {foo}; // in scope 0 at $DIR/inline-any-operand.rs:12:5: 12:6 + let mut _3: i32; // in scope 0 at $DIR/inline-any-operand.rs:12:5: 12:13 + let mut _4: i32; // in scope 0 at $DIR/inline-any-operand.rs:12:5: 12:13 + scope 1 { + debug f => _1; // in scope 1 at $DIR/inline-any-operand.rs:11:9: 11:10 + scope 2 { + debug x => _3; // in scope 2 at $DIR/inline-any-operand.rs:16:8: 16:9 + debug y => _4; // in scope 2 at $DIR/inline-any-operand.rs:16:16: 16:17 + } + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/inline-any-operand.rs:11:9: 11:10 + _1 = const foo; // bb0[1]: scope 0 at $DIR/inline-any-operand.rs:11:13: 11:16 + // ty::Const + // + ty: fn(i32, i32) -> bool {foo} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/inline-any-operand.rs:11:13: 11:16 + // + literal: Const { ty: fn(i32, i32) -> bool {foo}, val: Value(Scalar(<ZST>)) } + StorageLive(_2); // bb0[2]: scope 1 at $DIR/inline-any-operand.rs:12:5: 12:6 + _2 = _1; // bb0[3]: scope 1 at $DIR/inline-any-operand.rs:12:5: 12:6 + _3 = const 1i32; // bb0[4]: scope 1 at $DIR/inline-any-operand.rs:12:5: 12:13 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/inline-any-operand.rs:12:7: 12:8 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } + _4 = const -1i32; // bb0[5]: scope 1 at $DIR/inline-any-operand.rs:12:5: 12:13 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0xffffffff)) + // mir::Constant + // + span: $DIR/inline-any-operand.rs:12:10: 12:12 + // + literal: Const { ty: i32, val: Value(Scalar(0xffffffff)) } + _0 = Eq(move _3, move _4); // bb0[6]: scope 2 at $DIR/inline-any-operand.rs:17:5: 17:11 + StorageDead(_2); // bb0[7]: scope 1 at $DIR/inline-any-operand.rs:12:12: 12:13 + StorageDead(_1); // bb0[8]: scope 0 at $DIR/inline-any-operand.rs:13:1: 13:2 + return; // bb0[9]: scope 0 at $DIR/inline-any-operand.rs:13:2: 13:2 + } +} diff --git a/src/test/mir-opt/inline/inline-closure-borrows-arg.rs b/src/test/mir-opt/inline/inline-closure-borrows-arg.rs index 768f4953228..a82a91945d8 100644 --- a/src/test/mir-opt/inline/inline-closure-borrows-arg.rs +++ b/src/test/mir-opt/inline/inline-closure-borrows-arg.rs @@ -7,6 +7,7 @@ fn main() { println!("{}", foo(0, &14)); } +// EMIT_MIR rustc.foo.Inline.after.mir fn foo<T: Copy>(_t: T, q: &i32) -> i32 { let x = |r: &i32, _s: &i32| { let variable = &*r; @@ -14,46 +15,3 @@ fn foo<T: Copy>(_t: T, q: &i32) -> i32 { }; x(q, q) } - -// END RUST SOURCE -// START rustc.foo.Inline.after.mir -// fn foo(_1: T, _2: &i32) -> i32{ -// debug _t => _1; -// debug q => _2; -// let mut _0: i32; -// let _3: [closure@foo<T>::{{closure}}#0]; -// let mut _4: &[closure@foo<T>::{{closure}}#0]; -// let mut _5: (&i32, &i32); -// let mut _6: &i32; -// let mut _7: &i32; -// let mut _8: &i32; -// let mut _9: &i32; -// scope 1 { -// debug x => _3; -// scope 2 { -// debug r => _8; -// debug _s => _9; -// } -// } -// scope 3 { -// debug variable => _8; -// } -// bb0: { -// ... -// _3 = [closure@foo::<T>::{{closure}}#0]; -// ... -// _4 = &_3; -// ... -// _6 = &(*_2); -// ... -// _7 = &(*_2); -// _5 = (move _6, move _7); -// _8 = move (_5.0: &i32); -// _9 = move (_5.1: &i32); -// ... -// _0 = (*_8); -// ... -// return; -// } -// } -// END rustc.foo.Inline.after.mir diff --git a/src/test/mir-opt/inline/inline-closure-borrows-arg/rustc.foo.Inline.after.mir b/src/test/mir-opt/inline/inline-closure-borrows-arg/rustc.foo.Inline.after.mir new file mode 100644 index 00000000000..a8e846d1181 --- /dev/null +++ b/src/test/mir-opt/inline/inline-closure-borrows-arg/rustc.foo.Inline.after.mir @@ -0,0 +1,54 @@ +// MIR for `foo` after Inline + +fn foo(_1: T, _2: &i32) -> i32 { + debug _t => _1; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:11:17: 11:19 + debug q => _2; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:11:24: 11:25 + let mut _0: i32; // return place in scope 0 at $DIR/inline-closure-borrows-arg.rs:11:36: 11:39 + let _3: [closure@foo<T>::{{closure}}#0]; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:12:9: 12:10 + let mut _4: &[closure@foo<T>::{{closure}}#0]; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:6 + let mut _5: (&i32, &i32); // in scope 0 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 + let mut _6: &i32; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:16:7: 16:8 + let mut _7: &i32; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:16:10: 16:11 + let mut _8: &i32; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 + let mut _9: &i32; // in scope 0 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 + scope 1 { + debug x => _3; // in scope 1 at $DIR/inline-closure-borrows-arg.rs:12:9: 12:10 + scope 2 { + debug r => _8; // in scope 2 at $DIR/inline-closure-borrows-arg.rs:12:14: 12:15 + debug _s => _9; // in scope 2 at $DIR/inline-closure-borrows-arg.rs:12:23: 12:25 + } + } + scope 3 { + debug variable => _8; // in scope 3 at $DIR/inline-closure-borrows-arg.rs:13:13: 13:21 + } + + bb0: { + StorageLive(_3); // bb0[0]: scope 0 at $DIR/inline-closure-borrows-arg.rs:12:9: 12:10 + _3 = [closure@foo::<T>::{{closure}}#0]; // bb0[1]: scope 0 at $DIR/inline-closure-borrows-arg.rs:12:13: 15:6 + // closure + // + def_id: DefId(0:6 ~ inline_closure_borrows_arg[317d]::foo[0]::{{closure}}[0]) + // + substs: [ + // T, + // i8, + // for<'r, 's> extern "rust-call" fn((&'r i32, &'s i32)) -> i32, + // (), + // ] + StorageLive(_4); // bb0[2]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:6 + _4 = &_3; // bb0[3]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:6 + StorageLive(_5); // bb0[4]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 + StorageLive(_6); // bb0[5]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:7: 16:8 + _6 = &(*_2); // bb0[6]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:7: 16:8 + StorageLive(_7); // bb0[7]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:10: 16:11 + _7 = &(*_2); // bb0[8]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:10: 16:11 + _5 = (move _6, move _7); // bb0[9]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 + _8 = move (_5.0: &i32); // bb0[10]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 + _9 = move (_5.1: &i32); // bb0[11]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:5: 16:12 + _0 = (*_8); // bb0[12]: scope 3 at $DIR/inline-closure-borrows-arg.rs:14:9: 14:18 + StorageDead(_7); // bb0[13]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:11: 16:12 + StorageDead(_6); // bb0[14]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:11: 16:12 + StorageDead(_5); // bb0[15]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:11: 16:12 + StorageDead(_4); // bb0[16]: scope 1 at $DIR/inline-closure-borrows-arg.rs:16:11: 16:12 + StorageDead(_3); // bb0[17]: scope 0 at $DIR/inline-closure-borrows-arg.rs:17:1: 17:2 + return; // bb0[18]: scope 0 at $DIR/inline-closure-borrows-arg.rs:17:2: 17:2 + } +} diff --git a/src/test/mir-opt/inline/inline-closure-captures.rs b/src/test/mir-opt/inline/inline-closure-captures.rs index e000a418d90..4a0aad9b0e6 100644 --- a/src/test/mir-opt/inline/inline-closure-captures.rs +++ b/src/test/mir-opt/inline/inline-closure-captures.rs @@ -6,55 +6,8 @@ fn main() { println!("{:?}", foo(0, 14)); } +// EMIT_MIR rustc.foo.Inline.after.mir fn foo<T: Copy>(t: T, q: i32) -> (i32, T) { let x = |_q| (q, t); x(q) } - -// END RUST SOURCE -// START rustc.foo.Inline.after.mir -// fn foo(_1: T, _2: i32) -> (i32, T){ -// debug t => _1; -// debug q => _2; -// let mut _0: (i32, T); -// let _3: [closure@foo<T>::{{closure}}#0 q:&i32, t:&T]; -// let mut _4: &i32; -// let mut _5: &T; -// let mut _6: &[closure@foo<T>::{{closure}}#0 q:&i32, t:&T]; -// let mut _7: (i32,); -// let mut _8: i32; -// let mut _11: i32; -// scope 1 { -// debug x => _3; -// scope 2 { -// debug _q => _11; -// debug q => (*((*_6).0: &i32)); -// debug t => (*((*_6).1: &T)); -// let mut _9: i32; -// let mut _10: T; -// } -// } -// bb0: { -// ... -// _4 = &_2; -// ... -// _5 = &_1; -// _3 = [closure@foo::<T>::{{closure}}#0] { q: move _4, t: move _5 }; -// ... -// _6 = &_3; -// ... -// ... -// _8 = _2; -// _7 = (move _8,); -// _11 = move (_7.0: i32); -// ... -// _9 = (*((*_6).0: &i32)); -// ... -// _10 = (*((*_6).1: &T)); -// (_0.0: i32) = move _9; -// (_0.1: T) = move _10; -// ... -// return; -// } -// } -// END rustc.foo.Inline.after.mir diff --git a/src/test/mir-opt/inline/inline-closure-captures/rustc.foo.Inline.after.mir b/src/test/mir-opt/inline/inline-closure-captures/rustc.foo.Inline.after.mir new file mode 100644 index 00000000000..8f7c5615662 --- /dev/null +++ b/src/test/mir-opt/inline/inline-closure-captures/rustc.foo.Inline.after.mir @@ -0,0 +1,63 @@ +// MIR for `foo` after Inline + +fn foo(_1: T, _2: i32) -> (i32, T) { + debug t => _1; // in scope 0 at $DIR/inline-closure-captures.rs:10:17: 10:18 + debug q => _2; // in scope 0 at $DIR/inline-closure-captures.rs:10:23: 10:24 + let mut _0: (i32, T); // return place in scope 0 at $DIR/inline-closure-captures.rs:10:34: 10:42 + let _3: [closure@foo<T>::{{closure}}#0 q:&i32, t:&T]; // in scope 0 at $DIR/inline-closure-captures.rs:11:9: 11:10 + let mut _4: &i32; // in scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24 + let mut _5: &T; // in scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24 + let mut _6: &[closure@foo<T>::{{closure}}#0 q:&i32, t:&T]; // in scope 0 at $DIR/inline-closure-captures.rs:12:5: 12:6 + let mut _7: (i32,); // in scope 0 at $DIR/inline-closure-captures.rs:12:5: 12:9 + let mut _8: i32; // in scope 0 at $DIR/inline-closure-captures.rs:12:7: 12:8 + let mut _11: i32; // in scope 0 at $DIR/inline-closure-captures.rs:12:5: 12:9 + scope 1 { + debug x => _3; // in scope 1 at $DIR/inline-closure-captures.rs:11:9: 11:10 + scope 2 { + debug _q => _11; // in scope 2 at $DIR/inline-closure-captures.rs:11:14: 11:16 + debug q => (*((*_6).0: &i32)); // in scope 2 at $DIR/inline-closure-captures.rs:10:23: 10:24 + debug t => (*((*_6).1: &T)); // in scope 2 at $DIR/inline-closure-captures.rs:10:17: 10:18 + let mut _9: i32; // in scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 + let mut _10: T; // in scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9 + } + } + + bb0: { + StorageLive(_3); // bb0[0]: scope 0 at $DIR/inline-closure-captures.rs:11:9: 11:10 + StorageLive(_4); // bb0[1]: scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24 + _4 = &_2; // bb0[2]: scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24 + StorageLive(_5); // bb0[3]: scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24 + _5 = &_1; // bb0[4]: scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24 + _3 = [closure@foo::<T>::{{closure}}#0] { q: move _4, t: move _5 }; // bb0[5]: scope 0 at $DIR/inline-closure-captures.rs:11:13: 11:24 + // closure + // + def_id: DefId(0:6 ~ inline_closure_captures[317d]::foo[0]::{{closure}}[0]) + // + substs: [ + // T, + // i8, + // extern "rust-call" fn((i32,)) -> (i32, T), + // (&i32, &T), + // ] + StorageDead(_5); // bb0[6]: scope 0 at $DIR/inline-closure-captures.rs:11:23: 11:24 + StorageDead(_4); // bb0[7]: scope 0 at $DIR/inline-closure-captures.rs:11:23: 11:24 + StorageLive(_6); // bb0[8]: scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:6 + _6 = &_3; // bb0[9]: scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:6 + StorageLive(_7); // bb0[10]: scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9 + StorageLive(_8); // bb0[11]: scope 1 at $DIR/inline-closure-captures.rs:12:7: 12:8 + _8 = _2; // bb0[12]: scope 1 at $DIR/inline-closure-captures.rs:12:7: 12:8 + _7 = (move _8,); // bb0[13]: scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9 + _11 = move (_7.0: i32); // bb0[14]: scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9 + StorageLive(_9); // bb0[15]: scope 2 at $DIR/inline-closure-captures.rs:11:19: 11:20 + _9 = (*((*_6).0: &i32)); // bb0[16]: scope 2 at $DIR/inline-closure-captures.rs:11:19: 11:20 + StorageLive(_10); // bb0[17]: scope 2 at $DIR/inline-closure-captures.rs:11:22: 11:23 + _10 = (*((*_6).1: &T)); // bb0[18]: scope 2 at $DIR/inline-closure-captures.rs:11:22: 11:23 + (_0.0: i32) = move _9; // bb0[19]: scope 2 at $DIR/inline-closure-captures.rs:11:18: 11:24 + (_0.1: T) = move _10; // bb0[20]: scope 2 at $DIR/inline-closure-captures.rs:11:18: 11:24 + StorageDead(_10); // bb0[21]: scope 2 at $DIR/inline-closure-captures.rs:11:23: 11:24 + StorageDead(_9); // bb0[22]: scope 2 at $DIR/inline-closure-captures.rs:11:23: 11:24 + StorageDead(_8); // bb0[23]: scope 1 at $DIR/inline-closure-captures.rs:12:8: 12:9 + StorageDead(_7); // bb0[24]: scope 1 at $DIR/inline-closure-captures.rs:12:8: 12:9 + StorageDead(_6); // bb0[25]: scope 1 at $DIR/inline-closure-captures.rs:12:8: 12:9 + StorageDead(_3); // bb0[26]: scope 0 at $DIR/inline-closure-captures.rs:13:1: 13:2 + return; // bb0[27]: scope 0 at $DIR/inline-closure-captures.rs:13:2: 13:2 + } +} diff --git a/src/test/mir-opt/inline/inline-closure.rs b/src/test/mir-opt/inline/inline-closure.rs index bd36e77818e..77e424a2bb3 100644 --- a/src/test/mir-opt/inline/inline-closure.rs +++ b/src/test/mir-opt/inline/inline-closure.rs @@ -6,45 +6,8 @@ fn main() { println!("{}", foo(0, 14)); } +// EMIT_MIR rustc.foo.Inline.after.mir fn foo<T: Copy>(_t: T, q: i32) -> i32 { let x = |_t, _q| _t; x(q, q) } - -// END RUST SOURCE -// START rustc.foo.Inline.after.mir -// fn foo(_1: T, _2: i32) -> i32{ -// debug _t => _1; -// debug q => _2; -// let mut _0: i32; -// let _3: [closure@foo<T>::{{closure}}#0]; -// let mut _4: &[closure@foo<T>::{{closure}}#0]; -// let mut _5: (i32, i32); -// let mut _6: i32; -// let mut _7: i32; -// let mut _8: i32; -// let mut _9: i32; -// scope 1 { -// debug x => _3; -// scope 2 { -// debug _t => _8; -// debug _q => _9; -// } -// } -// bb0: { -// ... -// _3 = [closure@foo::<T>::{{closure}}#0]; -// ... -// _4 = &_3; -// ... -// _6 = _2; -// ... -// _7 = _2; -// _5 = (move _6, move _7); -// _8 = move (_5.0: i32); -// _9 = move (_5.1: i32); -// _0 = _8; -// ... -// return; -// } -// END rustc.foo.Inline.after.mir diff --git a/src/test/mir-opt/inline/inline-closure/rustc.foo.Inline.after.mir b/src/test/mir-opt/inline/inline-closure/rustc.foo.Inline.after.mir new file mode 100644 index 00000000000..e31032e8c69 --- /dev/null +++ b/src/test/mir-opt/inline/inline-closure/rustc.foo.Inline.after.mir @@ -0,0 +1,51 @@ +// MIR for `foo` after Inline + +fn foo(_1: T, _2: i32) -> i32 { + debug _t => _1; // in scope 0 at $DIR/inline-closure.rs:10:17: 10:19 + debug q => _2; // in scope 0 at $DIR/inline-closure.rs:10:24: 10:25 + let mut _0: i32; // return place in scope 0 at $DIR/inline-closure.rs:10:35: 10:38 + let _3: [closure@foo<T>::{{closure}}#0]; // in scope 0 at $DIR/inline-closure.rs:11:9: 11:10 + let mut _4: &[closure@foo<T>::{{closure}}#0]; // in scope 0 at $DIR/inline-closure.rs:12:5: 12:6 + let mut _5: (i32, i32); // in scope 0 at $DIR/inline-closure.rs:12:5: 12:12 + let mut _6: i32; // in scope 0 at $DIR/inline-closure.rs:12:7: 12:8 + let mut _7: i32; // in scope 0 at $DIR/inline-closure.rs:12:10: 12:11 + let mut _8: i32; // in scope 0 at $DIR/inline-closure.rs:12:5: 12:12 + let mut _9: i32; // in scope 0 at $DIR/inline-closure.rs:12:5: 12:12 + scope 1 { + debug x => _3; // in scope 1 at $DIR/inline-closure.rs:11:9: 11:10 + scope 2 { + debug _t => _8; // in scope 2 at $DIR/inline-closure.rs:11:14: 11:16 + debug _q => _9; // in scope 2 at $DIR/inline-closure.rs:11:18: 11:20 + } + } + + bb0: { + StorageLive(_3); // bb0[0]: scope 0 at $DIR/inline-closure.rs:11:9: 11:10 + _3 = [closure@foo::<T>::{{closure}}#0]; // bb0[1]: scope 0 at $DIR/inline-closure.rs:11:13: 11:24 + // closure + // + def_id: DefId(0:6 ~ inline_closure[317d]::foo[0]::{{closure}}[0]) + // + substs: [ + // T, + // i8, + // extern "rust-call" fn((i32, i32)) -> i32, + // (), + // ] + StorageLive(_4); // bb0[2]: scope 1 at $DIR/inline-closure.rs:12:5: 12:6 + _4 = &_3; // bb0[3]: scope 1 at $DIR/inline-closure.rs:12:5: 12:6 + StorageLive(_5); // bb0[4]: scope 1 at $DIR/inline-closure.rs:12:5: 12:12 + StorageLive(_6); // bb0[5]: scope 1 at $DIR/inline-closure.rs:12:7: 12:8 + _6 = _2; // bb0[6]: scope 1 at $DIR/inline-closure.rs:12:7: 12:8 + StorageLive(_7); // bb0[7]: scope 1 at $DIR/inline-closure.rs:12:10: 12:11 + _7 = _2; // bb0[8]: scope 1 at $DIR/inline-closure.rs:12:10: 12:11 + _5 = (move _6, move _7); // bb0[9]: scope 1 at $DIR/inline-closure.rs:12:5: 12:12 + _8 = move (_5.0: i32); // bb0[10]: scope 1 at $DIR/inline-closure.rs:12:5: 12:12 + _9 = move (_5.1: i32); // bb0[11]: scope 1 at $DIR/inline-closure.rs:12:5: 12:12 + _0 = _8; // bb0[12]: scope 2 at $DIR/inline-closure.rs:11:22: 11:24 + StorageDead(_7); // bb0[13]: scope 1 at $DIR/inline-closure.rs:12:11: 12:12 + StorageDead(_6); // bb0[14]: scope 1 at $DIR/inline-closure.rs:12:11: 12:12 + StorageDead(_5); // bb0[15]: scope 1 at $DIR/inline-closure.rs:12:11: 12:12 + StorageDead(_4); // bb0[16]: scope 1 at $DIR/inline-closure.rs:12:11: 12:12 + StorageDead(_3); // bb0[17]: scope 0 at $DIR/inline-closure.rs:13:1: 13:2 + return; // bb0[18]: scope 0 at $DIR/inline-closure.rs:13:2: 13:2 + } +} diff --git a/src/test/mir-opt/inline/inline-into-box-place.rs b/src/test/mir-opt/inline/inline-into-box-place.rs index fcb7b4c4fe6..d36d93cd01c 100644 --- a/src/test/mir-opt/inline/inline-into-box-place.rs +++ b/src/test/mir-opt/inline/inline-into-box-place.rs @@ -1,73 +1,9 @@ -// ignore-tidy-linelength // ignore-wasm32-bare compiled with panic=abort by default // compile-flags: -Z mir-opt-level=3 // only-64bit FIXME: the mir representation of RawVec depends on ptr size #![feature(box_syntax)] +// EMIT_MIR rustc.main.Inline.diff fn main() { let _x: Box<Vec<u32>> = box Vec::new(); } - -// END RUST SOURCE -// START rustc.main.Inline.before.mir -// let mut _0: (); -// let _1: std::boxed::Box<std::vec::Vec<u32>> as UserTypeProjection { base: UserType(0), projs: [] }; -// let mut _2: std::boxed::Box<std::vec::Vec<u32>>; -// let mut _3: (); -// scope 1 { -// debug _x => _1; -// } -// bb0: { -// StorageLive(_1); -// StorageLive(_2); -// _2 = Box(std::vec::Vec<u32>); -// (*_2) = const std::vec::Vec::<u32>::new() -> [return: bb2, unwind: bb4]; -// } -// bb1 (cleanup): { -// resume; -// } -// bb2: { -// _1 = move _2; -// StorageDead(_2); -// _0 = (); -// drop(_1) -> [return: bb3, unwind: bb1]; -// } -// bb3: { -// StorageDead(_1); -// return; -// } -// bb4 (cleanup): { -// _3 = const alloc::alloc::box_free::<std::vec::Vec<u32>>(move (_2.0: std::ptr::Unique<std::vec::Vec<u32>>)) -> bb1; -// } -// END rustc.main.Inline.before.mir -// START rustc.main.Inline.after.mir -// let mut _0: (); -// let _1: std::boxed::Box<std::vec::Vec<u32>> as UserTypeProjection { base: UserType(0), projs: [] }; -// let mut _2: std::boxed::Box<std::vec::Vec<u32>>; -// let mut _3: (); -// let mut _4: &mut std::vec::Vec<u32>; -// scope 1 { -// debug _x => _1; -// } -// scope 2 { -// } -// bb0: { -// StorageLive(_1); -// StorageLive(_2); -// _2 = Box(std::vec::Vec<u32>); -// _4 = &mut (*_2); -// ((*_4).0: alloc::raw_vec::RawVec<u32>) = const ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [65535], len: Size { raw: 16 } }, size: Size { raw: 16 }, align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }: alloc::raw_vec::RawVec::<u32>; -// ((*_4).1: usize) = const 0usize; -// _1 = move _2; -// StorageDead(_2); -// _0 = (); -// drop(_1) -> [return: bb2, unwind: bb1]; -// } -// bb1 (cleanup): { -// resume; -// } -// bb2: { -// StorageDead(_1); -// return; -// } -// END rustc.main.Inline.after.mir diff --git a/src/test/mir-opt/inline/inline-into-box-place/rustc.main.Inline.diff b/src/test/mir-opt/inline/inline-into-box-place/rustc.main.Inline.diff new file mode 100644 index 00000000000..a0db20cbb74 --- /dev/null +++ b/src/test/mir-opt/inline/inline-into-box-place/rustc.main.Inline.diff @@ -0,0 +1,76 @@ +- // MIR for `main` before Inline ++ // MIR for `main` after Inline + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/inline-into-box-place.rs:7:11: 7:11 + let _1: std::boxed::Box<std::vec::Vec<u32>> as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/inline-into-box-place.rs:8:9: 8:11 + let mut _2: std::boxed::Box<std::vec::Vec<u32>>; // in scope 0 at $DIR/inline-into-box-place.rs:8:29: 8:43 + let mut _3: (); // in scope 0 at $DIR/inline-into-box-place.rs:8:42: 8:43 ++ let mut _4: &mut std::vec::Vec<u32>; // in scope 0 at $DIR/inline-into-box-place.rs:8:33: 8:43 + scope 1 { + debug _x => _1; // in scope 1 at $DIR/inline-into-box-place.rs:8:9: 8:11 + } ++ scope 2 { ++ } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/inline-into-box-place.rs:8:9: 8:11 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/inline-into-box-place.rs:8:29: 8:43 + _2 = Box(std::vec::Vec<u32>); // bb0[2]: scope 0 at $DIR/inline-into-box-place.rs:8:29: 8:43 +- (*_2) = const std::vec::Vec::<u32>::new() -> [return: bb2, unwind: bb4]; // bb0[3]: scope 0 at $DIR/inline-into-box-place.rs:8:33: 8:43 ++ _4 = &mut (*_2); // bb0[3]: scope 0 at $DIR/inline-into-box-place.rs:8:33: 8:43 ++ ((*_4).0: alloc::raw_vec::RawVec<u32>) = const ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [65535], len: Size { raw: 16 } }, size: Size { raw: 16 }, align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }: alloc::raw_vec::RawVec::<u32>; // bb0[4]: scope 2 at $SRC_DIR/liballoc/vec.rs:LL:COL + // ty::Const +- // + ty: fn() -> std::vec::Vec<u32> {std::vec::Vec::<u32>::new} +- // + val: Value(Scalar(<ZST>)) ++ // + ty: alloc::raw_vec::RawVec<u32> ++ // + val: Value(ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [65535], len: Size { raw: 16 } }, size: Size { raw: 16 }, align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) + // mir::Constant +- // + span: $DIR/inline-into-box-place.rs:8:33: 8:41 +- // + user_ty: UserType(1) +- // + literal: Const { ty: fn() -> std::vec::Vec<u32> {std::vec::Vec::<u32>::new}, val: Value(Scalar(<ZST>)) } ++ // + span: $SRC_DIR/liballoc/vec.rs:LL:COL ++ // + user_ty: UserType(0) ++ // + literal: Const { ty: alloc::raw_vec::RawVec<u32>, val: Value(ByRef { alloc: Allocation { bytes: [4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [65535], len: Size { raw: 16 } }, size: Size { raw: 16 }, align: Align { pow2: 3 }, mutability: Not, extra: () }, offset: Size { raw: 0 } }) } ++ ((*_4).1: usize) = const 0usize; // bb0[5]: scope 2 at $SRC_DIR/liballoc/vec.rs:LL:COL ++ // ty::Const ++ // + ty: usize ++ // + val: Value(Scalar(0x0000000000000000)) ++ // mir::Constant ++ // + span: $SRC_DIR/liballoc/vec.rs:LL:COL ++ // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000000)) } ++ _1 = move _2; // bb0[6]: scope 0 at $DIR/inline-into-box-place.rs:8:29: 8:43 ++ StorageDead(_2); // bb0[7]: scope 0 at $DIR/inline-into-box-place.rs:8:42: 8:43 ++ _0 = (); // bb0[8]: scope 0 at $DIR/inline-into-box-place.rs:7:11: 9:2 ++ drop(_1) -> [return: bb2, unwind: bb1]; // bb0[9]: scope 0 at $DIR/inline-into-box-place.rs:9:1: 9:2 + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/inline-into-box-place.rs:7:1: 9:2 + } + + bb2: { +- _1 = move _2; // bb2[0]: scope 0 at $DIR/inline-into-box-place.rs:8:29: 8:43 +- StorageDead(_2); // bb2[1]: scope 0 at $DIR/inline-into-box-place.rs:8:42: 8:43 +- _0 = (); // bb2[2]: scope 0 at $DIR/inline-into-box-place.rs:7:11: 9:2 +- drop(_1) -> [return: bb3, unwind: bb1]; // bb2[3]: scope 0 at $DIR/inline-into-box-place.rs:9:1: 9:2 +- } +- +- bb3: { +- StorageDead(_1); // bb3[0]: scope 0 at $DIR/inline-into-box-place.rs:9:1: 9:2 +- return; // bb3[1]: scope 0 at $DIR/inline-into-box-place.rs:9:2: 9:2 +- } +- +- bb4 (cleanup): { +- _3 = const alloc::alloc::box_free::<std::vec::Vec<u32>>(move (_2.0: std::ptr::Unique<std::vec::Vec<u32>>)) -> bb1; // bb4[0]: scope 0 at $DIR/inline-into-box-place.rs:8:42: 8:43 +- // ty::Const +- // + ty: unsafe fn(std::ptr::Unique<std::vec::Vec<u32>>) {alloc::alloc::box_free::<std::vec::Vec<u32>>} +- // + val: Value(Scalar(<ZST>)) +- // mir::Constant +- // + span: $DIR/inline-into-box-place.rs:8:42: 8:43 +- // + literal: Const { ty: unsafe fn(std::ptr::Unique<std::vec::Vec<u32>>) {alloc::alloc::box_free::<std::vec::Vec<u32>>}, val: Value(Scalar(<ZST>)) } ++ StorageDead(_1); // bb2[0]: scope 0 at $DIR/inline-into-box-place.rs:9:1: 9:2 ++ return; // bb2[1]: scope 0 at $DIR/inline-into-box-place.rs:9:2: 9:2 + } + } + diff --git a/src/test/mir-opt/inline/inline-retag.rs b/src/test/mir-opt/inline/inline-retag.rs index 7b78fc339f2..d7e425ec658 100644 --- a/src/test/mir-opt/inline/inline-retag.rs +++ b/src/test/mir-opt/inline/inline-retag.rs @@ -6,6 +6,7 @@ fn main() { println!("{}", bar()); } +// EMIT_MIR rustc.bar.Inline.after.mir fn bar() -> bool { let f = foo; f(&1, &-1) @@ -15,23 +16,3 @@ fn bar() -> bool { fn foo(x: &i32, y: &i32) -> bool { *x == *y } - -// END RUST SOURCE -// START rustc.bar.Inline.after.mir -// ... -// bb0: { -// ... -// Retag(_3); -// ... -// Retag(_3); -// Retag(_6); -// StorageLive(_11); -// _11 = (*_3); -// StorageLive(_12); -// _12 = (*_6); -// _0 = Eq(move _11, move _12); -// ... -// return; -// } -// ... -// END rustc.bar.Inline.after.mir diff --git a/src/test/mir-opt/inline/inline-retag/rustc.bar.Inline.after.mir b/src/test/mir-opt/inline/inline-retag/rustc.bar.Inline.after.mir new file mode 100644 index 00000000000..ae2226bd183 --- /dev/null +++ b/src/test/mir-opt/inline/inline-retag/rustc.bar.Inline.after.mir @@ -0,0 +1,81 @@ +// MIR for `bar` after Inline + +fn bar() -> bool { + let mut _0: bool; // return place in scope 0 at $DIR/inline-retag.rs:10:13: 10:17 + let _1: for<'r, 's> fn(&'r i32, &'s i32) -> bool {foo}; // in scope 0 at $DIR/inline-retag.rs:11:9: 11:10 + let mut _2: for<'r, 's> fn(&'r i32, &'s i32) -> bool {foo}; // in scope 0 at $DIR/inline-retag.rs:12:5: 12:6 + let mut _3: &i32; // in scope 0 at $DIR/inline-retag.rs:12:7: 12:9 + let _4: &i32; // in scope 0 at $DIR/inline-retag.rs:12:7: 12:9 + let _5: i32; // in scope 0 at $DIR/inline-retag.rs:12:8: 12:9 + let mut _6: &i32; // in scope 0 at $DIR/inline-retag.rs:12:11: 12:14 + let _7: &i32; // in scope 0 at $DIR/inline-retag.rs:12:11: 12:14 + let _8: i32; // in scope 0 at $DIR/inline-retag.rs:12:12: 12:14 + scope 1 { + debug f => _1; // in scope 1 at $DIR/inline-retag.rs:11:9: 11:10 + let mut _9: &i32; // in scope 1 at $DIR/inline-retag.rs:12:11: 12:14 + let mut _10: &i32; // in scope 1 at $DIR/inline-retag.rs:12:7: 12:9 + scope 2 { + debug x => _3; // in scope 2 at $DIR/inline-retag.rs:16:8: 16:9 + debug y => _6; // in scope 2 at $DIR/inline-retag.rs:16:17: 16:18 + let mut _11: i32; // in scope 2 at $DIR/inline-retag.rs:12:5: 12:15 + let mut _12: i32; // in scope 2 at $DIR/inline-retag.rs:12:5: 12:15 + } + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/inline-retag.rs:11:9: 11:10 + _1 = const foo; // bb0[1]: scope 0 at $DIR/inline-retag.rs:11:13: 11:16 + // ty::Const + // + ty: for<'r, 's> fn(&'r i32, &'s i32) -> bool {foo} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/inline-retag.rs:11:13: 11:16 + // + literal: Const { ty: for<'r, 's> fn(&'r i32, &'s i32) -> bool {foo}, val: Value(Scalar(<ZST>)) } + StorageLive(_2); // bb0[2]: scope 1 at $DIR/inline-retag.rs:12:5: 12:6 + _2 = _1; // bb0[3]: scope 1 at $DIR/inline-retag.rs:12:5: 12:6 + StorageLive(_3); // bb0[4]: scope 1 at $DIR/inline-retag.rs:12:7: 12:9 + StorageLive(_4); // bb0[5]: scope 1 at $DIR/inline-retag.rs:12:7: 12:9 + _10 = const bar::promoted[1]; // bb0[6]: scope 1 at $DIR/inline-retag.rs:12:7: 12:9 + // ty::Const + // + ty: &i32 + // + val: Unevaluated(DefId(0:4 ~ inline_retag[317d]::bar[0]), [], Some(promoted[1])) + // mir::Constant + // + span: $DIR/inline-retag.rs:12:7: 12:9 + // + literal: Const { ty: &i32, val: Unevaluated(DefId(0:4 ~ inline_retag[317d]::bar[0]), [], Some(promoted[1])) } + Retag(_10); // bb0[7]: scope 1 at $DIR/inline-retag.rs:12:7: 12:9 + _4 = &(*_10); // bb0[8]: scope 1 at $DIR/inline-retag.rs:12:7: 12:9 + Retag(_4); // bb0[9]: scope 1 at $DIR/inline-retag.rs:12:7: 12:9 + _3 = &(*_4); // bb0[10]: scope 1 at $DIR/inline-retag.rs:12:7: 12:9 + Retag(_3); // bb0[11]: scope 1 at $DIR/inline-retag.rs:12:7: 12:9 + StorageLive(_6); // bb0[12]: scope 1 at $DIR/inline-retag.rs:12:11: 12:14 + StorageLive(_7); // bb0[13]: scope 1 at $DIR/inline-retag.rs:12:11: 12:14 + _9 = const bar::promoted[0]; // bb0[14]: scope 1 at $DIR/inline-retag.rs:12:11: 12:14 + // ty::Const + // + ty: &i32 + // + val: Unevaluated(DefId(0:4 ~ inline_retag[317d]::bar[0]), [], Some(promoted[0])) + // mir::Constant + // + span: $DIR/inline-retag.rs:12:11: 12:14 + // + literal: Const { ty: &i32, val: Unevaluated(DefId(0:4 ~ inline_retag[317d]::bar[0]), [], Some(promoted[0])) } + Retag(_9); // bb0[15]: scope 1 at $DIR/inline-retag.rs:12:11: 12:14 + _7 = &(*_9); // bb0[16]: scope 1 at $DIR/inline-retag.rs:12:11: 12:14 + Retag(_7); // bb0[17]: scope 1 at $DIR/inline-retag.rs:12:11: 12:14 + _6 = &(*_7); // bb0[18]: scope 1 at $DIR/inline-retag.rs:12:11: 12:14 + Retag(_6); // bb0[19]: scope 1 at $DIR/inline-retag.rs:12:11: 12:14 + Retag(_3); // bb0[20]: scope 2 at $DIR/inline-retag.rs:16:1: 18:2 + Retag(_6); // bb0[21]: scope 2 at $DIR/inline-retag.rs:16:1: 18:2 + StorageLive(_11); // bb0[22]: scope 2 at $DIR/inline-retag.rs:17:5: 17:7 + _11 = (*_3); // bb0[23]: scope 2 at $DIR/inline-retag.rs:17:5: 17:7 + StorageLive(_12); // bb0[24]: scope 2 at $DIR/inline-retag.rs:17:11: 17:13 + _12 = (*_6); // bb0[25]: scope 2 at $DIR/inline-retag.rs:17:11: 17:13 + _0 = Eq(move _11, move _12); // bb0[26]: scope 2 at $DIR/inline-retag.rs:17:5: 17:13 + StorageDead(_12); // bb0[27]: scope 2 at $DIR/inline-retag.rs:17:12: 17:13 + StorageDead(_11); // bb0[28]: scope 2 at $DIR/inline-retag.rs:17:12: 17:13 + StorageDead(_6); // bb0[29]: scope 1 at $DIR/inline-retag.rs:12:14: 12:15 + StorageDead(_3); // bb0[30]: scope 1 at $DIR/inline-retag.rs:12:14: 12:15 + StorageDead(_2); // bb0[31]: scope 1 at $DIR/inline-retag.rs:12:14: 12:15 + StorageDead(_1); // bb0[32]: scope 0 at $DIR/inline-retag.rs:13:1: 13:2 + StorageDead(_7); // bb0[33]: scope 0 at $DIR/inline-retag.rs:13:1: 13:2 + StorageDead(_4); // bb0[34]: scope 0 at $DIR/inline-retag.rs:13:1: 13:2 + return; // bb0[35]: scope 0 at $DIR/inline-retag.rs:13:2: 13:2 + } +} diff --git a/src/test/mir-opt/inline/inline-specialization.rs b/src/test/mir-opt/inline/inline-specialization.rs index 9591019bb4f..fcdaca460a9 100644 --- a/src/test/mir-opt/inline/inline-specialization.rs +++ b/src/test/mir-opt/inline/inline-specialization.rs @@ -1,5 +1,6 @@ #![feature(specialization)] +// EMIT_MIR rustc.main.Inline.diff fn main() { let x = <Vec::<()> as Foo>::bar(); } @@ -12,37 +13,3 @@ impl<T> Foo for Vec<T> { #[inline(always)] default fn bar() -> u32 { 123 } } - -// END RUST SOURCE -// START rustc.main.Inline.before.mir -// let mut _0: (); -// let _1: u32; -// scope 1 { -// debug x => _1; -// } -// bb0: { -// StorageLive(_1); -// _1 = const <std::vec::Vec<()> as Foo>::bar() -> bb1; -// } -// bb1: { -// _0 = (); -// StorageDead(_1); -// return; -// } -// END rustc.main.Inline.before.mir -// START rustc.main.Inline.after.mir -// let mut _0: (); -// let _1: u32; -// scope 1 { -// debug x => _1; -// } -// scope 2 { -// } -// bb0: { -// StorageLive(_1); -// _1 = const 123u32; -// _0 = (); -// StorageDead(_1); -// return; -// } -// END rustc.main.Inline.after.mir diff --git a/src/test/mir-opt/inline/inline-specialization/rustc.main.Inline.diff b/src/test/mir-opt/inline/inline-specialization/rustc.main.Inline.diff new file mode 100644 index 00000000000..98d03b19977 --- /dev/null +++ b/src/test/mir-opt/inline/inline-specialization/rustc.main.Inline.diff @@ -0,0 +1,38 @@ +- // MIR for `main` before Inline ++ // MIR for `main` after Inline + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/inline-specialization.rs:4:11: 4:11 + let _1: u32; // in scope 0 at $DIR/inline-specialization.rs:5:9: 5:10 + scope 1 { + debug x => _1; // in scope 1 at $DIR/inline-specialization.rs:5:9: 5:10 + } ++ scope 2 { ++ } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/inline-specialization.rs:5:9: 5:10 +- _1 = const <std::vec::Vec<()> as Foo>::bar() -> bb1; // bb0[1]: scope 0 at $DIR/inline-specialization.rs:5:13: 5:38 ++ _1 = const 123u32; // bb0[1]: scope 2 at $DIR/inline-specialization.rs:14:31: 14:34 + // ty::Const +- // + ty: fn() -> u32 {<std::vec::Vec<()> as Foo>::bar} +- // + val: Value(Scalar(<ZST>)) ++ // + ty: u32 ++ // + val: Value(Scalar(0x0000007b)) + // mir::Constant +- // + span: $DIR/inline-specialization.rs:5:13: 5:36 +- // + literal: Const { ty: fn() -> u32 {<std::vec::Vec<()> as Foo>::bar}, val: Value(Scalar(<ZST>)) } +- } +- +- bb1: { +- _0 = (); // bb1[0]: scope 0 at $DIR/inline-specialization.rs:4:11: 6:2 +- StorageDead(_1); // bb1[1]: scope 0 at $DIR/inline-specialization.rs:6:1: 6:2 +- return; // bb1[2]: scope 0 at $DIR/inline-specialization.rs:6:2: 6:2 ++ // + span: $DIR/inline-specialization.rs:14:31: 14:34 ++ // + literal: Const { ty: u32, val: Value(Scalar(0x0000007b)) } ++ _0 = (); // bb0[2]: scope 0 at $DIR/inline-specialization.rs:4:11: 6:2 ++ StorageDead(_1); // bb0[3]: scope 0 at $DIR/inline-specialization.rs:6:1: 6:2 ++ return; // bb0[4]: scope 0 at $DIR/inline-specialization.rs:6:2: 6:2 + } + } + diff --git a/src/test/mir-opt/inline/inline-trait-method.rs b/src/test/mir-opt/inline/inline-trait-method.rs index a2c5fb920cd..cb3db9b5592 100644 --- a/src/test/mir-opt/inline/inline-trait-method.rs +++ b/src/test/mir-opt/inline/inline-trait-method.rs @@ -4,6 +4,7 @@ fn main() { println!("{}", test(&())); } +// EMIT_MIR rustc.test.Inline.after.mir fn test(x: &dyn X) -> u32 { x.y() } @@ -19,13 +20,3 @@ impl X for () { 2 } } - -// END RUST SOURCE -// START rustc.test.Inline.after.mir -// ... -// bb0: { -// ... -// _0 = const <dyn X as X>::y(move _2) -> bb1; -// } -// ... -// END rustc.test.Inline.after.mir diff --git a/src/test/mir-opt/inline/inline-trait-method/rustc.test.Inline.after.mir b/src/test/mir-opt/inline/inline-trait-method/rustc.test.Inline.after.mir new file mode 100644 index 00000000000..488303e09ef --- /dev/null +++ b/src/test/mir-opt/inline/inline-trait-method/rustc.test.Inline.after.mir @@ -0,0 +1,24 @@ +// MIR for `test` after Inline + +fn test(_1: &dyn X) -> u32 { + debug x => _1; // in scope 0 at $DIR/inline-trait-method.rs:8:9: 8:10 + let mut _0: u32; // return place in scope 0 at $DIR/inline-trait-method.rs:8:23: 8:26 + let mut _2: &dyn X; // in scope 0 at $DIR/inline-trait-method.rs:9:5: 9:6 + + bb0: { + StorageLive(_2); // bb0[0]: scope 0 at $DIR/inline-trait-method.rs:9:5: 9:6 + _2 = &(*_1); // bb0[1]: scope 0 at $DIR/inline-trait-method.rs:9:5: 9:6 + _0 = const <dyn X as X>::y(move _2) -> bb1; // bb0[2]: scope 0 at $DIR/inline-trait-method.rs:9:5: 9:10 + // ty::Const + // + ty: for<'r> fn(&'r dyn X) -> u32 {<dyn X as X>::y} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/inline-trait-method.rs:9:7: 9:8 + // + literal: Const { ty: for<'r> fn(&'r dyn X) -> u32 {<dyn X as X>::y}, val: Value(Scalar(<ZST>)) } + } + + bb1: { + StorageDead(_2); // bb1[0]: scope 0 at $DIR/inline-trait-method.rs:9:9: 9:10 + return; // bb1[1]: scope 0 at $DIR/inline-trait-method.rs:10:2: 10:2 + } +} diff --git a/src/test/mir-opt/inline/inline-trait-method_2.rs b/src/test/mir-opt/inline/inline-trait-method_2.rs index 4ad4311113a..e37f091c5cd 100644 --- a/src/test/mir-opt/inline/inline-trait-method_2.rs +++ b/src/test/mir-opt/inline/inline-trait-method_2.rs @@ -1,5 +1,6 @@ // compile-flags: -Z span_free_formats -Z mir-opt-level=3 +// EMIT_MIR rustc.test2.Inline.after.mir fn test2(x: &dyn X) -> bool { test(x) } @@ -24,13 +25,3 @@ impl X for () { fn main() { println!("Should be true: {}", test2(&())); } - -// END RUST SOURCE -// START rustc.test2.Inline.after.mir -// ... -// bb0: { -// ... -// _0 = const <dyn X as X>::y(move _2) -> bb1; -// } -// ... -// END rustc.test2.Inline.after.mir diff --git a/src/test/mir-opt/inline/inline-trait-method_2/rustc.test2.Inline.after.mir b/src/test/mir-opt/inline/inline-trait-method_2/rustc.test2.Inline.after.mir new file mode 100644 index 00000000000..aca47198aa9 --- /dev/null +++ b/src/test/mir-opt/inline/inline-trait-method_2/rustc.test2.Inline.after.mir @@ -0,0 +1,31 @@ +// MIR for `test2` after Inline + +fn test2(_1: &dyn X) -> bool { + debug x => _1; // in scope 0 at $DIR/inline-trait-method_2.rs:4:10: 4:11 + let mut _0: bool; // return place in scope 0 at $DIR/inline-trait-method_2.rs:4:24: 4:28 + let mut _2: &dyn X; // in scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11 + let mut _3: &dyn X; // in scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11 + scope 1 { + debug x => _2; // in scope 1 at $DIR/inline-trait-method_2.rs:9:9: 9:10 + } + + bb0: { + StorageLive(_2); // bb0[0]: scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11 + StorageLive(_3); // bb0[1]: scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11 + _3 = &(*_1); // bb0[2]: scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11 + _2 = move _3 as &dyn X (Pointer(Unsize)); // bb0[3]: scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11 + StorageDead(_3); // bb0[4]: scope 0 at $DIR/inline-trait-method_2.rs:5:10: 5:11 + _0 = const <dyn X as X>::y(move _2) -> bb1; // bb0[5]: scope 1 at $DIR/inline-trait-method_2.rs:10:5: 10:10 + // ty::Const + // + ty: for<'r> fn(&'r dyn X) -> bool {<dyn X as X>::y} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/inline-trait-method_2.rs:10:7: 10:8 + // + literal: Const { ty: for<'r> fn(&'r dyn X) -> bool {<dyn X as X>::y}, val: Value(Scalar(<ZST>)) } + } + + bb1: { + StorageDead(_2); // bb1[0]: scope 0 at $DIR/inline-trait-method_2.rs:5:11: 5:12 + return; // bb1[1]: scope 0 at $DIR/inline-trait-method_2.rs:6:2: 6:2 + } +} diff --git a/src/test/mir-opt/issue-38669.rs b/src/test/mir-opt/issue-38669.rs index d980cc891dc..f6883ac8086 100644 --- a/src/test/mir-opt/issue-38669.rs +++ b/src/test/mir-opt/issue-38669.rs @@ -1,5 +1,6 @@ // check that we don't StorageDead booleans before they are used +// EMIT_MIR rustc.main.SimplifyCfg-initial.after.mir fn main() { let mut should_break = false; loop { @@ -9,42 +10,3 @@ fn main() { should_break = true; } } - -// END RUST SOURCE -// START rustc.main.SimplifyCfg-initial.after.mir -// bb0: { -// StorageLive(_1); -// _1 = const false; -// FakeRead(ForLet, _1); -// goto -> bb2; -// } -// bb1 (cleanup): { -// resume; -// } -// bb2: { -// falseUnwind -> [real: bb3, cleanup: bb1]; -// } -// bb3: { -// StorageLive(_3); -// StorageLive(_4); -// _4 = _1; -// FakeRead(ForMatchedPlace, _4); -// switchInt(_4) -> [false: bb5, otherwise: bb4]; -// } -// ... -// bb5: { -// _3 = (); -// StorageDead(_4); -// StorageDead(_3); -// _1 = const true; -// _2 = (); -// goto -> bb2; -// } -// bb6: { -// _0 = (); -// StorageDead(_4); -// StorageDead(_3); -// StorageDead(_1); -// return; -// } -// END rustc.main.SimplifyCfg-initial.after.mir diff --git a/src/test/mir-opt/issue-38669/rustc.main.SimplifyCfg-initial.after.mir b/src/test/mir-opt/issue-38669/rustc.main.SimplifyCfg-initial.after.mir new file mode 100644 index 00000000000..5144cdd3dab --- /dev/null +++ b/src/test/mir-opt/issue-38669/rustc.main.SimplifyCfg-initial.after.mir @@ -0,0 +1,69 @@ +// MIR for `main` after SimplifyCfg-initial + +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/issue-38669.rs:4:11: 4:11 + let mut _1: bool; // in scope 0 at $DIR/issue-38669.rs:5:9: 5:25 + let mut _2: (); // in scope 0 at $DIR/issue-38669.rs:4:1: 12:2 + let _3: (); // in scope 0 at $DIR/issue-38669.rs:7:9: 9:10 + let mut _4: bool; // in scope 0 at $DIR/issue-38669.rs:7:12: 7:24 + let mut _5: !; // in scope 0 at $DIR/issue-38669.rs:7:25: 9:10 + scope 1 { + debug should_break => _1; // in scope 1 at $DIR/issue-38669.rs:5:9: 5:25 + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/issue-38669.rs:5:9: 5:25 + _1 = const false; // bb0[1]: scope 0 at $DIR/issue-38669.rs:5:28: 5:33 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x00)) + // mir::Constant + // + span: $DIR/issue-38669.rs:5:28: 5:33 + // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } + FakeRead(ForLet, _1); // bb0[2]: scope 0 at $DIR/issue-38669.rs:5:9: 5:25 + goto -> bb2; // bb0[3]: scope 1 at $DIR/issue-38669.rs:6:5: 11:6 + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/issue-38669.rs:4:1: 12:2 + } + + bb2: { + falseUnwind -> [real: bb3, cleanup: bb1]; // bb2[0]: scope 1 at $DIR/issue-38669.rs:6:5: 11:6 + } + + bb3: { + StorageLive(_3); // bb3[0]: scope 1 at $DIR/issue-38669.rs:7:9: 9:10 + StorageLive(_4); // bb3[1]: scope 1 at $DIR/issue-38669.rs:7:12: 7:24 + _4 = _1; // bb3[2]: scope 1 at $DIR/issue-38669.rs:7:12: 7:24 + FakeRead(ForMatchedPlace, _4); // bb3[3]: scope 1 at $DIR/issue-38669.rs:7:12: 7:24 + switchInt(_4) -> [false: bb5, otherwise: bb4]; // bb3[4]: scope 1 at $DIR/issue-38669.rs:7:9: 9:10 + } + + bb4: { + falseEdges -> [real: bb6, imaginary: bb5]; // bb4[0]: scope 1 at $DIR/issue-38669.rs:7:9: 9:10 + } + + bb5: { + _3 = (); // bb5[0]: scope 1 at $DIR/issue-38669.rs:7:9: 9:10 + StorageDead(_4); // bb5[1]: scope 1 at $DIR/issue-38669.rs:9:9: 9:10 + StorageDead(_3); // bb5[2]: scope 1 at $DIR/issue-38669.rs:9:9: 9:10 + _1 = const true; // bb5[3]: scope 1 at $DIR/issue-38669.rs:10:9: 10:28 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x01)) + // mir::Constant + // + span: $DIR/issue-38669.rs:10:24: 10:28 + // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + _2 = (); // bb5[4]: scope 1 at $DIR/issue-38669.rs:6:10: 11:6 + goto -> bb2; // bb5[5]: scope 1 at $DIR/issue-38669.rs:6:5: 11:6 + } + + bb6: { + _0 = (); // bb6[0]: scope 1 at $DIR/issue-38669.rs:8:13: 8:18 + StorageDead(_4); // bb6[1]: scope 1 at $DIR/issue-38669.rs:9:9: 9:10 + StorageDead(_3); // bb6[2]: scope 1 at $DIR/issue-38669.rs:9:9: 9:10 + StorageDead(_1); // bb6[3]: scope 0 at $DIR/issue-38669.rs:12:1: 12:2 + return; // bb6[4]: scope 0 at $DIR/issue-38669.rs:12:2: 12:2 + } +} diff --git a/src/test/mir-opt/issue-41110.rs b/src/test/mir-opt/issue-41110.rs index 5ba54f98d00..cc35b8785a7 100644 --- a/src/test/mir-opt/issue-41110.rs +++ b/src/test/mir-opt/issue-41110.rs @@ -2,12 +2,15 @@ // check that we don't emit multiple drop flags when they are not needed. + +// EMIT_MIR rustc.main.ElaborateDrops.after.mir fn main() { let x = S.other(S.id()); } // no_mangle to make sure this gets instantiated even in an executable. #[no_mangle] +// EMIT_MIR rustc.test.ElaborateDrops.after.mir pub fn test() { let u = S; let mut v = S; @@ -25,34 +28,3 @@ impl S { fn id(self) -> Self { self } fn other(self, s: Self) {} } - -// END RUST SOURCE -// START rustc.main.ElaborateDrops.after.mir -// let mut _0: (); -// let _1: (); -// let mut _2: S; -// let mut _3: S; -// let mut _4: S; -// let mut _5: bool; -// scope 1 { -// debug x => _1; -// } -// ... -// bb0: { -// END rustc.main.ElaborateDrops.after.mir -// START rustc.test.ElaborateDrops.after.mir -// let mut _0: (); -// let _1: S; -// let _3: (); -// let mut _4: S; -// let mut _5: S; -// let mut _6: bool; -// ... -// debug u => _1; -// ... -// let mut _2: S; -// ... -// debug v => _2; -// ... -// bb0: { -// END rustc.test.ElaborateDrops.after.mir diff --git a/src/test/mir-opt/issue-41110/rustc.main.ElaborateDrops.after.mir b/src/test/mir-opt/issue-41110/rustc.main.ElaborateDrops.after.mir new file mode 100644 index 00000000000..0499054c329 --- /dev/null +++ b/src/test/mir-opt/issue-41110/rustc.main.ElaborateDrops.after.mir @@ -0,0 +1,111 @@ +// MIR for `main` after ElaborateDrops + +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/issue-41110.rs:7:11: 7:11 + let _1: (); // in scope 0 at $DIR/issue-41110.rs:8:9: 8:10 + let mut _2: S; // in scope 0 at $DIR/issue-41110.rs:8:13: 8:14 + let mut _3: S; // in scope 0 at $DIR/issue-41110.rs:8:21: 8:27 + let mut _4: S; // in scope 0 at $DIR/issue-41110.rs:8:21: 8:22 + let mut _5: bool; // in scope 0 at $DIR/issue-41110.rs:8:27: 8:28 + scope 1 { + debug x => _1; // in scope 1 at $DIR/issue-41110.rs:8:9: 8:10 + } + + bb0: { + _5 = const false; // bb0[0]: scope 0 at $DIR/issue-41110.rs:8:9: 8:10 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x00)) + // mir::Constant + // + span: $DIR/issue-41110.rs:8:9: 8:10 + // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } + StorageLive(_1); // bb0[1]: scope 0 at $DIR/issue-41110.rs:8:9: 8:10 + StorageLive(_2); // bb0[2]: scope 0 at $DIR/issue-41110.rs:8:13: 8:14 + _5 = const true; // bb0[3]: scope 0 at $DIR/issue-41110.rs:8:13: 8:14 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x01)) + // mir::Constant + // + span: $DIR/issue-41110.rs:8:13: 8:14 + // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + _2 = S; // bb0[4]: scope 0 at $DIR/issue-41110.rs:8:13: 8:14 + StorageLive(_3); // bb0[5]: scope 0 at $DIR/issue-41110.rs:8:21: 8:27 + StorageLive(_4); // bb0[6]: scope 0 at $DIR/issue-41110.rs:8:21: 8:22 + _4 = S; // bb0[7]: scope 0 at $DIR/issue-41110.rs:8:21: 8:22 + _3 = const S::id(move _4) -> [return: bb2, unwind: bb4]; // bb0[8]: scope 0 at $DIR/issue-41110.rs:8:21: 8:27 + // ty::Const + // + ty: fn(S) -> S {S::id} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/issue-41110.rs:8:23: 8:25 + // + literal: Const { ty: fn(S) -> S {S::id}, val: Value(Scalar(<ZST>)) } + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/issue-41110.rs:7:1: 9:2 + } + + bb2: { + StorageDead(_4); // bb2[0]: scope 0 at $DIR/issue-41110.rs:8:26: 8:27 + _5 = const false; // bb2[1]: scope 0 at $DIR/issue-41110.rs:8:13: 8:28 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x00)) + // mir::Constant + // + span: $DIR/issue-41110.rs:8:13: 8:28 + // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } + _1 = const S::other(move _2, move _3) -> [return: bb6, unwind: bb5]; // bb2[2]: scope 0 at $DIR/issue-41110.rs:8:13: 8:28 + // ty::Const + // + ty: fn(S, S) {S::other} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/issue-41110.rs:8:15: 8:20 + // + literal: Const { ty: fn(S, S) {S::other}, val: Value(Scalar(<ZST>)) } + } + + bb3 (cleanup): { + goto -> bb9; // bb3[0]: scope 0 at $DIR/issue-41110.rs:8:27: 8:28 + } + + bb4 (cleanup): { + goto -> bb3; // bb4[0]: scope 0 at $DIR/issue-41110.rs:8:26: 8:27 + } + + bb5 (cleanup): { + goto -> bb3; // bb5[0]: scope 0 at $DIR/issue-41110.rs:8:27: 8:28 + } + + bb6: { + StorageDead(_3); // bb6[0]: scope 0 at $DIR/issue-41110.rs:8:27: 8:28 + _5 = const false; // bb6[1]: scope 0 at $DIR/issue-41110.rs:8:27: 8:28 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x00)) + // mir::Constant + // + span: $DIR/issue-41110.rs:8:27: 8:28 + // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } + StorageDead(_2); // bb6[2]: scope 0 at $DIR/issue-41110.rs:8:27: 8:28 + _0 = (); // bb6[3]: scope 0 at $DIR/issue-41110.rs:7:11: 9:2 + StorageDead(_1); // bb6[4]: scope 0 at $DIR/issue-41110.rs:9:1: 9:2 + return; // bb6[5]: scope 0 at $DIR/issue-41110.rs:9:2: 9:2 + } + + bb7 (cleanup): { + drop(_2) -> bb1; // bb7[0]: scope 0 at $DIR/issue-41110.rs:8:27: 8:28 + } + + bb8 (cleanup): { + _5 = const false; // bb8[0]: scope 0 at $DIR/issue-41110.rs:8:27: 8:28 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x00)) + // mir::Constant + // + span: $DIR/issue-41110.rs:8:27: 8:28 + // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } + goto -> bb7; // bb8[1]: scope 0 at $DIR/issue-41110.rs:8:27: 8:28 + } + + bb9 (cleanup): { + switchInt(_5) -> [false: bb1, otherwise: bb8]; // bb9[0]: scope 0 at $DIR/issue-41110.rs:8:27: 8:28 + } +} diff --git a/src/test/mir-opt/issue-41110/rustc.test.ElaborateDrops.after.mir b/src/test/mir-opt/issue-41110/rustc.test.ElaborateDrops.after.mir new file mode 100644 index 00000000000..b6623fcd4d9 --- /dev/null +++ b/src/test/mir-opt/issue-41110/rustc.test.ElaborateDrops.after.mir @@ -0,0 +1,139 @@ +// MIR for `test` after ElaborateDrops + +fn test() -> () { + let mut _0: (); // return place in scope 0 at $DIR/issue-41110.rs:14:15: 14:15 + let _1: S; // in scope 0 at $DIR/issue-41110.rs:15:9: 15:10 + let _3: (); // in scope 0 at $DIR/issue-41110.rs:17:5: 17:12 + let mut _4: S; // in scope 0 at $DIR/issue-41110.rs:17:10: 17:11 + let mut _5: S; // in scope 0 at $DIR/issue-41110.rs:18:9: 18:10 + let mut _6: bool; // in scope 0 at $DIR/issue-41110.rs:19:1: 19:2 + scope 1 { + debug u => _1; // in scope 1 at $DIR/issue-41110.rs:15:9: 15:10 + let mut _2: S; // in scope 1 at $DIR/issue-41110.rs:16:9: 16:14 + scope 2 { + debug v => _2; // in scope 2 at $DIR/issue-41110.rs:16:9: 16:14 + } + } + + bb0: { + _6 = const false; // bb0[0]: scope 0 at $DIR/issue-41110.rs:15:9: 15:10 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x00)) + // mir::Constant + // + span: $DIR/issue-41110.rs:15:9: 15:10 + // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } + StorageLive(_1); // bb0[1]: scope 0 at $DIR/issue-41110.rs:15:9: 15:10 + _6 = const true; // bb0[2]: scope 0 at $DIR/issue-41110.rs:15:13: 15:14 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x01)) + // mir::Constant + // + span: $DIR/issue-41110.rs:15:13: 15:14 + // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + _1 = S; // bb0[3]: scope 0 at $DIR/issue-41110.rs:15:13: 15:14 + StorageLive(_2); // bb0[4]: scope 1 at $DIR/issue-41110.rs:16:9: 16:14 + _2 = S; // bb0[5]: scope 1 at $DIR/issue-41110.rs:16:17: 16:18 + StorageLive(_3); // bb0[6]: scope 2 at $DIR/issue-41110.rs:17:5: 17:12 + StorageLive(_4); // bb0[7]: scope 2 at $DIR/issue-41110.rs:17:10: 17:11 + _4 = move _2; // bb0[8]: scope 2 at $DIR/issue-41110.rs:17:10: 17:11 + _3 = const std::mem::drop::<S>(move _4) -> [return: bb2, unwind: bb5]; // bb0[9]: scope 2 at $DIR/issue-41110.rs:17:5: 17:12 + // ty::Const + // + ty: fn(S) {std::mem::drop::<S>} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/issue-41110.rs:17:5: 17:9 + // + literal: Const { ty: fn(S) {std::mem::drop::<S>}, val: Value(Scalar(<ZST>)) } + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/issue-41110.rs:14:1: 19:2 + } + + bb2: { + StorageDead(_4); // bb2[0]: scope 2 at $DIR/issue-41110.rs:17:11: 17:12 + StorageDead(_3); // bb2[1]: scope 2 at $DIR/issue-41110.rs:17:12: 17:13 + StorageLive(_5); // bb2[2]: scope 2 at $DIR/issue-41110.rs:18:9: 18:10 + _6 = const false; // bb2[3]: scope 2 at $DIR/issue-41110.rs:18:9: 18:10 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x00)) + // mir::Constant + // + span: $DIR/issue-41110.rs:18:9: 18:10 + // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } + _5 = move _1; // bb2[4]: scope 2 at $DIR/issue-41110.rs:18:9: 18:10 + goto -> bb12; // bb2[5]: scope 2 at $DIR/issue-41110.rs:18:5: 18:6 + } + + bb3 (cleanup): { + goto -> bb15; // bb3[0]: scope 0 at $DIR/issue-41110.rs:19:1: 19:2 + } + + bb4 (cleanup): { + goto -> bb3; // bb4[0]: scope 1 at $DIR/issue-41110.rs:19:1: 19:2 + } + + bb5 (cleanup): { + goto -> bb4; // bb5[0]: scope 2 at $DIR/issue-41110.rs:17:11: 17:12 + } + + bb6: { + goto -> bb8; // bb6[0]: scope 2 at $DIR/issue-41110.rs:18:9: 18:10 + } + + bb7 (cleanup): { + goto -> bb4; // bb7[0]: scope 2 at $DIR/issue-41110.rs:18:9: 18:10 + } + + bb8: { + StorageDead(_5); // bb8[0]: scope 2 at $DIR/issue-41110.rs:18:9: 18:10 + _0 = (); // bb8[1]: scope 0 at $DIR/issue-41110.rs:14:15: 19:2 + drop(_2) -> [return: bb9, unwind: bb3]; // bb8[2]: scope 1 at $DIR/issue-41110.rs:19:1: 19:2 + } + + bb9: { + StorageDead(_2); // bb9[0]: scope 1 at $DIR/issue-41110.rs:19:1: 19:2 + goto -> bb10; // bb9[1]: scope 0 at $DIR/issue-41110.rs:19:1: 19:2 + } + + bb10: { + _6 = const false; // bb10[0]: scope 0 at $DIR/issue-41110.rs:19:1: 19:2 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x00)) + // mir::Constant + // + span: $DIR/issue-41110.rs:19:1: 19:2 + // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } + StorageDead(_1); // bb10[1]: scope 0 at $DIR/issue-41110.rs:19:1: 19:2 + return; // bb10[2]: scope 0 at $DIR/issue-41110.rs:19:2: 19:2 + } + + bb11 (cleanup): { + _2 = move _5; // bb11[0]: scope 2 at $DIR/issue-41110.rs:18:5: 18:6 + goto -> bb7; // bb11[1]: scope 2 at $DIR/issue-41110.rs:18:5: 18:6 + } + + bb12: { + _2 = move _5; // bb12[0]: scope 2 at $DIR/issue-41110.rs:18:5: 18:6 + goto -> bb6; // bb12[1]: scope 2 at $DIR/issue-41110.rs:18:5: 18:6 + } + + bb13 (cleanup): { + drop(_1) -> bb1; // bb13[0]: scope 0 at $DIR/issue-41110.rs:19:1: 19:2 + } + + bb14 (cleanup): { + _6 = const false; // bb14[0]: scope 0 at $DIR/issue-41110.rs:19:1: 19:2 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x00)) + // mir::Constant + // + span: $DIR/issue-41110.rs:19:1: 19:2 + // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } + goto -> bb13; // bb14[1]: scope 0 at $DIR/issue-41110.rs:19:1: 19:2 + } + + bb15 (cleanup): { + switchInt(_6) -> [false: bb1, otherwise: bb14]; // bb15[0]: scope 0 at $DIR/issue-41110.rs:19:1: 19:2 + } +} diff --git a/src/test/mir-opt/issue-41697.rs b/src/test/mir-opt/issue-41697.rs index 5a461d61482..07b9d175677 100644 --- a/src/test/mir-opt/issue-41697.rs +++ b/src/test/mir-opt/issue-41697.rs @@ -13,7 +13,9 @@ trait Foo { fn get(&self) -> [u8; 2]; } -impl Foo for [u8; 2] { +// EMIT_MIR_FOR_EACH_BIT_WIDTH +// EMIT_MIR rustc.{{impl}}-{{constant}}.SimplifyCfg-qualify-consts.after.mir +impl Foo for [u8; 1+1] { fn get(&self) -> [u8; 2] { *self } diff --git a/src/test/mir-opt/issue-41697/32bit/rustc.{{impl}}-{{constant}}.SimplifyCfg-qualify-consts.after.mir b/src/test/mir-opt/issue-41697/32bit/rustc.{{impl}}-{{constant}}.SimplifyCfg-qualify-consts.after.mir new file mode 100644 index 00000000000..072ca4cfe47 --- /dev/null +++ b/src/test/mir-opt/issue-41697/32bit/rustc.{{impl}}-{{constant}}.SimplifyCfg-qualify-consts.after.mir @@ -0,0 +1,32 @@ +// MIR for `<impl at $DIR/issue-41697.rs:18:1: 22:2>::{{constant}}#0` after SimplifyCfg-qualify-consts + +<impl at $DIR/issue-41697.rs:18:1: 22:2>::{{constant}}#0: usize = { + let mut _0: usize; // return place in scope 0 at $DIR/issue-41697.rs:18:19: 18:22 + let mut _1: (usize, bool); // in scope 0 at $DIR/issue-41697.rs:18:19: 18:22 + + bb0: { + _1 = CheckedAdd(const 1usize, const 1usize); // bb0[0]: scope 0 at $DIR/issue-41697.rs:18:19: 18:22 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/issue-41697.rs:18:19: 18:20 + // + literal: Const { ty: usize, val: Value(Scalar(0x00000001)) } + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/issue-41697.rs:18:21: 18:22 + // + literal: Const { ty: usize, val: Value(Scalar(0x00000001)) } + assert(!move (_1.1: bool), "attempt to add with overflow") -> [success: bb2, unwind: bb1]; // bb0[1]: scope 0 at $DIR/issue-41697.rs:18:19: 18:22 + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/issue-41697.rs:18:19: 18:22 + } + + bb2: { + _0 = move (_1.0: usize); // bb2[0]: scope 0 at $DIR/issue-41697.rs:18:19: 18:22 + return; // bb2[1]: scope 0 at $DIR/issue-41697.rs:18:19: 18:22 + } +} diff --git a/src/test/mir-opt/issue-41697/64bit/rustc.{{impl}}-{{constant}}.SimplifyCfg-qualify-consts.after.mir b/src/test/mir-opt/issue-41697/64bit/rustc.{{impl}}-{{constant}}.SimplifyCfg-qualify-consts.after.mir new file mode 100644 index 00000000000..5a9d1570b80 --- /dev/null +++ b/src/test/mir-opt/issue-41697/64bit/rustc.{{impl}}-{{constant}}.SimplifyCfg-qualify-consts.after.mir @@ -0,0 +1,32 @@ +// MIR for `<impl at $DIR/issue-41697.rs:18:1: 22:2>::{{constant}}#0` after SimplifyCfg-qualify-consts + +<impl at $DIR/issue-41697.rs:18:1: 22:2>::{{constant}}#0: usize = { + let mut _0: usize; // return place in scope 0 at $DIR/issue-41697.rs:18:19: 18:22 + let mut _1: (usize, bool); // in scope 0 at $DIR/issue-41697.rs:18:19: 18:22 + + bb0: { + _1 = CheckedAdd(const 1usize, const 1usize); // bb0[0]: scope 0 at $DIR/issue-41697.rs:18:19: 18:22 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000001)) + // mir::Constant + // + span: $DIR/issue-41697.rs:18:19: 18:20 + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000001)) } + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000001)) + // mir::Constant + // + span: $DIR/issue-41697.rs:18:21: 18:22 + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000001)) } + assert(!move (_1.1: bool), "attempt to add with overflow") -> [success: bb2, unwind: bb1]; // bb0[1]: scope 0 at $DIR/issue-41697.rs:18:19: 18:22 + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/issue-41697.rs:18:19: 18:22 + } + + bb2: { + _0 = move (_1.0: usize); // bb2[0]: scope 0 at $DIR/issue-41697.rs:18:19: 18:22 + return; // bb2[1]: scope 0 at $DIR/issue-41697.rs:18:19: 18:22 + } +} diff --git a/src/test/mir-opt/issue-41888.rs b/src/test/mir-opt/issue-41888.rs index efe2b249d4a..6caaa59d0af 100644 --- a/src/test/mir-opt/issue-41888.rs +++ b/src/test/mir-opt/issue-41888.rs @@ -1,6 +1,8 @@ +// ignore-wasm32-bare compiled with panic=abort by default // check that we clear the "ADT master drop flag" even when there are // no fields to be dropped. +// EMIT_MIR rustc.main.ElaborateDrops.after.mir fn main() { let e; if cond() { @@ -20,159 +22,3 @@ enum E { F(K), G(Box<E>) } - -// END RUST SOURCE -// fn main() -> () { -// let mut _0: (); -// scope 1 { -// let _1: E; -// debug e => _1; -// scope 2 { -// let _6: K; -// debug _k => _6; -// } -// } -// let mut _2: bool; -// let mut _3: (); -// let mut _4: E; -// let mut _5: K; -// let mut _7: isize; -// let mut _8: bool; // drop flag for `e` -// let mut _9: bool; -// let mut _10: bool; -// let mut _11: isize; -// let mut _12: isize; -// -// bb0: { -// _8 = const false; -// _10 = const false; -// _9 = const false; -// StorageLive(_1); -// StorageLive(_2); -// _2 = const cond() -> [return: bb3, unwind: bb2]; -// } -// -// bb1: { -// resume; -// } -// -// bb2: { -// goto -> bb1; -// } -// -// bb3: { -// switchInt(_2) -> [0u8: bb5, otherwise: bb4]; -// } -// -// bb4: { -// StorageLive(_4); -// StorageLive(_5); -// _5 = K::{{constructor}}; -// _4 = E::F(_5,); -// StorageDead(_5); -// goto -> bb15; -// } -// -// bb5: { -// _0 = (); -// goto -> bb12; -// } -// -// bb6: { -// goto -> bb2; -// } -// -// bb7: { -// goto -> bb8; -// } -// -// bb8: { -// StorageDead(_4); -// _7 = discriminant(_1); -// switchInt(_7) -> [0isize: bb10, otherwise: bb9]; -// } -// -// bb9: { -// _0 = (); -// goto -> bb11; -// } -// -// bb10: { -// StorageLive(_6); -// _10 = const false; -// _6 = ((_1 as F).0: K); -// _0 = (); -// goto -> bb11; -// } -// -// bb11: { -// StorageDead(_6); -// goto -> bb12; -// } -// -// bb12: { -// StorageDead(_2); -// goto -> bb22; -// } -// -// bb13: { -// StorageDead(_1); -// return; -// } -// -// bb14: { -// _8 = const true; -// _9 = const true; -// _10 = const true; -// _1 = _4; -// goto -> bb6; -// } -// -// bb15: { -// _8 = const true; -// _9 = const true; -// _10 = const true; -// _1 = _4; -// goto -> bb7; -// } -// -// bb16: { -// _8 = const false; // clear the drop flag - must always be reached -// goto -> bb13; -// } -// -// bb17: { -// _8 = const false; -// goto -> bb1; -// } -// -// bb18: { -// goto -> bb17; -// } -// -// bb19: { -// drop(_1) -> [return: bb16, unwind: bb17]; -// } -// -// bb20: { -// drop(_1) -> bb17; -// } -// -// bb21: { -// _11 = discriminant(_1); -// switchInt(_11) -> [0isize: bb16, otherwise: bb19]; -// } -// -// bb22: { -// switchInt(_8) -> [0u8: bb16, otherwise: bb21]; -// } -// -// bb23: { -// _12 = discriminant(_1); -// switchInt(_12) -> [0isize: bb18, otherwise: bb20]; -// } -// -// bb24: { -// switchInt(_8) -> [0u8: bb17, otherwise: bb23]; -// } -// } diff --git a/src/test/mir-opt/issue-41888/rustc.main.ElaborateDrops.after.mir b/src/test/mir-opt/issue-41888/rustc.main.ElaborateDrops.after.mir new file mode 100644 index 00000000000..6cd3e2dec83 --- /dev/null +++ b/src/test/mir-opt/issue-41888/rustc.main.ElaborateDrops.after.mir @@ -0,0 +1,250 @@ +// MIR for `main` after ElaborateDrops + +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/issue-41888.rs:6:11: 6:11 + let _1: E; // in scope 0 at $DIR/issue-41888.rs:7:9: 7:10 + let mut _2: bool; // in scope 0 at $DIR/issue-41888.rs:8:8: 8:14 + let mut _3: E; // in scope 0 at $DIR/issue-41888.rs:9:13: 9:20 + let mut _4: K; // in scope 0 at $DIR/issue-41888.rs:9:18: 9:19 + let mut _5: isize; // in scope 0 at $DIR/issue-41888.rs:10:16: 10:24 + let mut _7: bool; // in scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + let mut _8: bool; // in scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + let mut _9: bool; // in scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + let mut _10: isize; // in scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + let mut _11: isize; // in scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + scope 1 { + debug e => _1; // in scope 1 at $DIR/issue-41888.rs:7:9: 7:10 + let _6: K; // in scope 1 at $DIR/issue-41888.rs:10:21: 10:23 + scope 2 { + debug _k => _6; // in scope 2 at $DIR/issue-41888.rs:10:21: 10:23 + } + } + + bb0: { + _9 = const false; // bb0[0]: scope 0 at $DIR/issue-41888.rs:7:9: 7:10 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x00)) + // mir::Constant + // + span: $DIR/issue-41888.rs:7:9: 7:10 + // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } + _7 = const false; // bb0[1]: scope 0 at $DIR/issue-41888.rs:7:9: 7:10 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x00)) + // mir::Constant + // + span: $DIR/issue-41888.rs:7:9: 7:10 + // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } + _8 = const false; // bb0[2]: scope 0 at $DIR/issue-41888.rs:7:9: 7:10 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x00)) + // mir::Constant + // + span: $DIR/issue-41888.rs:7:9: 7:10 + // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } + StorageLive(_1); // bb0[3]: scope 0 at $DIR/issue-41888.rs:7:9: 7:10 + StorageLive(_2); // bb0[4]: scope 1 at $DIR/issue-41888.rs:8:8: 8:14 + _2 = const cond() -> [return: bb2, unwind: bb3]; // bb0[5]: scope 1 at $DIR/issue-41888.rs:8:8: 8:14 + // ty::Const + // + ty: fn() -> bool {cond} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/issue-41888.rs:8:8: 8:12 + // + literal: Const { ty: fn() -> bool {cond}, val: Value(Scalar(<ZST>)) } + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/issue-41888.rs:6:1: 15:2 + } + + bb2: { + switchInt(_2) -> [false: bb4, otherwise: bb5]; // bb2[0]: scope 1 at $DIR/issue-41888.rs:8:5: 14:6 + } + + bb3 (cleanup): { + goto -> bb1; // bb3[0]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + } + + bb4: { + _0 = (); // bb4[0]: scope 1 at $DIR/issue-41888.rs:8:5: 14:6 + goto -> bb11; // bb4[1]: scope 1 at $DIR/issue-41888.rs:8:5: 14:6 + } + + bb5: { + StorageLive(_3); // bb5[0]: scope 1 at $DIR/issue-41888.rs:9:13: 9:20 + StorageLive(_4); // bb5[1]: scope 1 at $DIR/issue-41888.rs:9:18: 9:19 + _4 = K; // bb5[2]: scope 1 at $DIR/issue-41888.rs:9:18: 9:19 + _3 = E::F(move _4,); // bb5[3]: scope 1 at $DIR/issue-41888.rs:9:13: 9:20 + StorageDead(_4); // bb5[4]: scope 1 at $DIR/issue-41888.rs:9:19: 9:20 + goto -> bb14; // bb5[5]: scope 1 at $DIR/issue-41888.rs:9:9: 9:10 + } + + bb6: { + goto -> bb8; // bb6[0]: scope 1 at $DIR/issue-41888.rs:9:19: 9:20 + } + + bb7 (cleanup): { + goto -> bb3; // bb7[0]: scope 1 at $DIR/issue-41888.rs:9:19: 9:20 + } + + bb8: { + StorageDead(_3); // bb8[0]: scope 1 at $DIR/issue-41888.rs:9:19: 9:20 + _5 = discriminant(_1); // bb8[1]: scope 1 at $DIR/issue-41888.rs:10:16: 10:24 + switchInt(move _5) -> [0isize: bb10, otherwise: bb9]; // bb8[2]: scope 1 at $DIR/issue-41888.rs:10:16: 10:24 + } + + bb9: { + _0 = (); // bb9[0]: scope 1 at $DIR/issue-41888.rs:10:9: 13:10 + goto -> bb11; // bb9[1]: scope 1 at $DIR/issue-41888.rs:10:9: 13:10 + } + + bb10: { + StorageLive(_6); // bb10[0]: scope 1 at $DIR/issue-41888.rs:10:21: 10:23 + _9 = const false; // bb10[1]: scope 1 at $DIR/issue-41888.rs:10:21: 10:23 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x00)) + // mir::Constant + // + span: $DIR/issue-41888.rs:10:21: 10:23 + // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } + _6 = move ((_1 as F).0: K); // bb10[2]: scope 1 at $DIR/issue-41888.rs:10:21: 10:23 + _0 = (); // bb10[3]: scope 2 at $DIR/issue-41888.rs:10:29: 13:10 + StorageDead(_6); // bb10[4]: scope 1 at $DIR/issue-41888.rs:13:9: 13:10 + goto -> bb11; // bb10[5]: scope 1 at $DIR/issue-41888.rs:10:9: 13:10 + } + + bb11: { + goto -> bb21; // bb11[0]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + } + + bb12: { + _7 = const false; // bb12[0]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x00)) + // mir::Constant + // + span: $DIR/issue-41888.rs:15:1: 15:2 + // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } + _8 = const false; // bb12[1]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x00)) + // mir::Constant + // + span: $DIR/issue-41888.rs:15:1: 15:2 + // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } + _9 = const false; // bb12[2]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x00)) + // mir::Constant + // + span: $DIR/issue-41888.rs:15:1: 15:2 + // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } + StorageDead(_1); // bb12[3]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + StorageDead(_2); // bb12[4]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + return; // bb12[5]: scope 0 at $DIR/issue-41888.rs:15:2: 15:2 + } + + bb13 (cleanup): { + _7 = const true; // bb13[0]: scope 1 at $DIR/issue-41888.rs:9:9: 9:10 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x01)) + // mir::Constant + // + span: $DIR/issue-41888.rs:9:9: 9:10 + // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + _8 = const true; // bb13[1]: scope 1 at $DIR/issue-41888.rs:9:9: 9:10 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x01)) + // mir::Constant + // + span: $DIR/issue-41888.rs:9:9: 9:10 + // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + _9 = const true; // bb13[2]: scope 1 at $DIR/issue-41888.rs:9:9: 9:10 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x01)) + // mir::Constant + // + span: $DIR/issue-41888.rs:9:9: 9:10 + // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + _1 = move _3; // bb13[3]: scope 1 at $DIR/issue-41888.rs:9:9: 9:10 + goto -> bb7; // bb13[4]: scope 1 at $DIR/issue-41888.rs:9:9: 9:10 + } + + bb14: { + _7 = const true; // bb14[0]: scope 1 at $DIR/issue-41888.rs:9:9: 9:10 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x01)) + // mir::Constant + // + span: $DIR/issue-41888.rs:9:9: 9:10 + // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + _8 = const true; // bb14[1]: scope 1 at $DIR/issue-41888.rs:9:9: 9:10 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x01)) + // mir::Constant + // + span: $DIR/issue-41888.rs:9:9: 9:10 + // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + _9 = const true; // bb14[2]: scope 1 at $DIR/issue-41888.rs:9:9: 9:10 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x01)) + // mir::Constant + // + span: $DIR/issue-41888.rs:9:9: 9:10 + // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + _1 = move _3; // bb14[3]: scope 1 at $DIR/issue-41888.rs:9:9: 9:10 + goto -> bb6; // bb14[4]: scope 1 at $DIR/issue-41888.rs:9:9: 9:10 + } + + bb15: { + _7 = const false; // bb15[0]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x00)) + // mir::Constant + // + span: $DIR/issue-41888.rs:15:1: 15:2 + // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } + goto -> bb12; // bb15[1]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + } + + bb16 (cleanup): { + _7 = const false; // bb16[0]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x00)) + // mir::Constant + // + span: $DIR/issue-41888.rs:15:1: 15:2 + // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } + goto -> bb1; // bb16[1]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + } + + bb17 (cleanup): { + goto -> bb16; // bb17[0]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + } + + bb18: { + drop(_1) -> [return: bb15, unwind: bb16]; // bb18[0]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + } + + bb19 (cleanup): { + drop(_1) -> bb16; // bb19[0]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + } + + bb20: { + _10 = discriminant(_1); // bb20[0]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + switchInt(move _10) -> [0isize: bb15, otherwise: bb18]; // bb20[1]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + } + + bb21: { + switchInt(_7) -> [false: bb15, otherwise: bb20]; // bb21[0]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + } + + bb22 (cleanup): { + _11 = discriminant(_1); // bb22[0]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + switchInt(move _11) -> [0isize: bb17, otherwise: bb19]; // bb22[1]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + } + + bb23 (cleanup): { + switchInt(_7) -> [false: bb16, otherwise: bb22]; // bb23[0]: scope 0 at $DIR/issue-41888.rs:15:1: 15:2 + } +} diff --git a/src/test/mir-opt/issue-49232.rs b/src/test/mir-opt/issue-49232.rs index 54c89b85f42..7d308980b90 100644 --- a/src/test/mir-opt/issue-49232.rs +++ b/src/test/mir-opt/issue-49232.rs @@ -1,6 +1,7 @@ // We must mark a variable whose initialization fails due to an // abort statement as StorageDead. +// EMIT_MIR rustc.main.mir_map.0.mir fn main() { loop { let beacon = { @@ -12,82 +13,3 @@ fn main() { drop(&beacon); } } - -// END RUST SOURCE -// START rustc.main.mir_map.0.mir -// fn main() -> (){ -// let mut _0: (); -// let mut _1: (); -// let _2: i32; -// let mut _3: bool; -// let mut _4: !; -// let _5: (); -// let mut _6: &i32; -// scope 1 { -// debug beacon => _2; -// } -// bb0: { -// goto -> bb1; -// } -// bb1: { -// falseUnwind -> [real: bb3, cleanup: bb4]; -// } -// bb2: { -// goto -> bb14; -// } -// bb3: { -// StorageLive(_2); -// StorageLive(_3); -// _3 = const true; -// FakeRead(ForMatchedPlace, _3); -// switchInt(_3) -> [false: bb5, otherwise: bb6]; -// } -// bb4 (cleanup): { -// resume; -// } -// bb5: { -// falseEdges -> [real: bb7, imaginary: bb6]; -// } -// bb6: { -// _0 = (); -// goto -> bb8; -// } -// bb7: { -// _2 = const 4i32; -// goto -> bb12; -// } -// bb8: { -// StorageDead(_3); -// goto -> bb9; -// } -// bb9: { -// StorageDead(_2); -// goto -> bb2; -// } -// bb10: { -// _4 = (); -// unreachable; -// } -// bb11: { -// goto -> bb12; -// } -// bb12: { -// FakeRead(ForLet, _2); -// StorageDead(_3); -// StorageLive(_5); -// StorageLive(_6); -// _6 = &_2; -// _5 = const std::mem::drop::<&i32>(move _6) -> [return: bb13, unwind: bb4]; -// } -// bb13: { -// StorageDead(_6); -// StorageDead(_5); -// _1 = (); -// StorageDead(_2); -// goto -> bb1; -// } -// bb14: { -// return; -// } -// } -// END rustc.main.mir_map.0.mir diff --git a/src/test/mir-opt/issue-49232/rustc.main.mir_map.0.mir b/src/test/mir-opt/issue-49232/rustc.main.mir_map.0.mir new file mode 100644 index 00000000000..03815d58bbc --- /dev/null +++ b/src/test/mir-opt/issue-49232/rustc.main.mir_map.0.mir @@ -0,0 +1,110 @@ +// MIR for `main` 0 mir_map + +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/issue-49232.rs:5:11: 5:11 + let mut _1: (); // in scope 0 at $DIR/issue-49232.rs:5:1: 15:2 + let _2: i32; // in scope 0 at $DIR/issue-49232.rs:7:13: 7:19 + let mut _3: bool; // in scope 0 at $DIR/issue-49232.rs:8:19: 8:23 + let mut _4: !; // in scope 0 at $DIR/issue-49232.rs:10:25: 10:30 + let _5: (); // in scope 0 at $DIR/issue-49232.rs:13:9: 13:22 + let mut _6: &i32; // in scope 0 at $DIR/issue-49232.rs:13:14: 13:21 + scope 1 { + debug beacon => _2; // in scope 1 at $DIR/issue-49232.rs:7:13: 7:19 + } + + bb0: { + goto -> bb1; // bb0[0]: scope 0 at $DIR/issue-49232.rs:6:5: 14:6 + } + + bb1: { + falseUnwind -> [real: bb3, cleanup: bb4]; // bb1[0]: scope 0 at $DIR/issue-49232.rs:6:5: 14:6 + } + + bb2: { + goto -> bb14; // bb2[0]: scope 0 at $DIR/issue-49232.rs:15:2: 15:2 + } + + bb3: { + StorageLive(_2); // bb3[0]: scope 0 at $DIR/issue-49232.rs:7:13: 7:19 + StorageLive(_3); // bb3[1]: scope 0 at $DIR/issue-49232.rs:8:19: 8:23 + _3 = const true; // bb3[2]: scope 0 at $DIR/issue-49232.rs:8:19: 8:23 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x01)) + // mir::Constant + // + span: $DIR/issue-49232.rs:8:19: 8:23 + // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + FakeRead(ForMatchedPlace, _3); // bb3[3]: scope 0 at $DIR/issue-49232.rs:8:19: 8:23 + switchInt(_3) -> [false: bb5, otherwise: bb6]; // bb3[4]: scope 0 at $DIR/issue-49232.rs:9:17: 9:22 + } + + bb4 (cleanup): { + resume; // bb4[0]: scope 0 at $DIR/issue-49232.rs:5:1: 15:2 + } + + bb5: { + falseEdges -> [real: bb7, imaginary: bb6]; // bb5[0]: scope 0 at $DIR/issue-49232.rs:9:17: 9:22 + } + + bb6: { + _0 = (); // bb6[0]: scope 0 at $DIR/issue-49232.rs:10:25: 10:30 + goto -> bb8; // bb6[1]: scope 0 at $DIR/issue-49232.rs:10:25: 10:30 + } + + bb7: { + _2 = const 4i32; // bb7[0]: scope 0 at $DIR/issue-49232.rs:9:26: 9:27 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000004)) + // mir::Constant + // + span: $DIR/issue-49232.rs:9:26: 9:27 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) } + goto -> bb12; // bb7[1]: scope 0 at $DIR/issue-49232.rs:8:13: 11:14 + } + + bb8: { + StorageDead(_3); // bb8[0]: scope 0 at $DIR/issue-49232.rs:12:10: 12:11 + goto -> bb9; // bb8[1]: scope 0 at $DIR/issue-49232.rs:10:25: 10:30 + } + + bb9: { + StorageDead(_2); // bb9[0]: scope 0 at $DIR/issue-49232.rs:14:5: 14:6 + goto -> bb2; // bb9[1]: scope 0 at $DIR/issue-49232.rs:10:25: 10:30 + } + + bb10: { + _4 = (); // bb10[0]: scope 0 at $DIR/issue-49232.rs:10:25: 10:30 + unreachable; // bb10[1]: scope 0 at $DIR/issue-49232.rs:10:25: 10:30 + } + + bb11: { + goto -> bb12; // bb11[0]: scope 0 at $DIR/issue-49232.rs:8:13: 11:14 + } + + bb12: { + FakeRead(ForLet, _2); // bb12[0]: scope 0 at $DIR/issue-49232.rs:7:13: 7:19 + StorageDead(_3); // bb12[1]: scope 0 at $DIR/issue-49232.rs:12:10: 12:11 + StorageLive(_5); // bb12[2]: scope 1 at $DIR/issue-49232.rs:13:9: 13:22 + StorageLive(_6); // bb12[3]: scope 1 at $DIR/issue-49232.rs:13:14: 13:21 + _6 = &_2; // bb12[4]: scope 1 at $DIR/issue-49232.rs:13:14: 13:21 + _5 = const std::mem::drop::<&i32>(move _6) -> [return: bb13, unwind: bb4]; // bb12[5]: scope 1 at $DIR/issue-49232.rs:13:9: 13:22 + // ty::Const + // + ty: fn(&i32) {std::mem::drop::<&i32>} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/issue-49232.rs:13:9: 13:13 + // + literal: Const { ty: fn(&i32) {std::mem::drop::<&i32>}, val: Value(Scalar(<ZST>)) } + } + + bb13: { + StorageDead(_6); // bb13[0]: scope 1 at $DIR/issue-49232.rs:13:21: 13:22 + StorageDead(_5); // bb13[1]: scope 1 at $DIR/issue-49232.rs:13:22: 13:23 + _1 = (); // bb13[2]: scope 0 at $DIR/issue-49232.rs:6:10: 14:6 + StorageDead(_2); // bb13[3]: scope 0 at $DIR/issue-49232.rs:14:5: 14:6 + goto -> bb1; // bb13[4]: scope 0 at $DIR/issue-49232.rs:6:5: 14:6 + } + + bb14: { + return; // bb14[0]: scope 0 at $DIR/issue-49232.rs:15:2: 15:2 + } +} diff --git a/src/test/mir-opt/issue-62289.rs b/src/test/mir-opt/issue-62289.rs index 8e619ffdf8b..f0d57c572b3 100644 --- a/src/test/mir-opt/issue-62289.rs +++ b/src/test/mir-opt/issue-62289.rs @@ -1,10 +1,10 @@ // check that we don't forget to drop the Box if we early return before // initializing it -// ignore-tidy-linelength // ignore-wasm32-bare compiled with panic=abort by default #![feature(box_syntax)] +// EMIT_MIR rustc.test.ElaborateDrops.before.mir fn test() -> Option<Box<u32>> { Some(box (None?)) } @@ -12,80 +12,3 @@ fn test() -> Option<Box<u32>> { fn main() { test(); } - -// END RUST SOURCE -// START rustc.test.ElaborateDrops.before.mir -// fn test() -> std::option::Option<std::boxed::Box<u32>> { -// ... -// bb0: { -// StorageLive(_1); -// StorageLive(_2); -// _2 = Box(u32); -// StorageLive(_3); -// StorageLive(_4); -// _4 = std::option::Option::<u32>::None; -// _3 = const <std::option::Option<u32> as std::ops::Try>::into_result(move _4) -> [return: bb2, unwind: bb3]; -// } -// bb1 (cleanup): { -// resume; -// } -// bb2: { -// StorageDead(_4); -// _5 = discriminant(_3); -// switchInt(move _5) -> [0isize: bb4, 1isize: bb6, otherwise: bb5]; -// } -// bb3 (cleanup): { -// drop(_2) -> bb1; -// } -// bb4: { -// StorageLive(_10); -// _10 = ((_3 as Ok).0: u32); -// (*_2) = _10; -// StorageDead(_10); -// _1 = move _2; -// drop(_2) -> [return: bb12, unwind: bb11]; -// } -// bb5: { -// unreachable; -// } -// bb6: { -// StorageLive(_6); -// _6 = ((_3 as Err).0: std::option::NoneError); -// StorageLive(_8); -// StorageLive(_9); -// _9 = _6; -// _8 = const <std::option::NoneError as std::convert::From<std::option::NoneError>>::from(move _9) -> [return: bb8, unwind: bb3]; -// } -// bb7: { -// return; -// } -// bb8: { -// StorageDead(_9); -// _0 = const <std::option::Option<std::boxed::Box<u32>> as std::ops::Try>::from_error(move _8) -> [return: bb9, unwind: bb3]; -// } -// bb9: { -// StorageDead(_8); -// StorageDead(_6); -// drop(_2) -> bb10; -// } -// bb10: { -// StorageDead(_2); -// StorageDead(_1); -// StorageDead(_3); -// goto -> bb7; -// } -// bb11 (cleanup): { -// drop(_1) -> bb1; -// } -// bb12: { -// StorageDead(_2); -// _0 = std::option::Option::<std::boxed::Box<u32>>::Some(move _1,); -// drop(_1) -> bb13; -// } -// bb13: { -// StorageDead(_1); -// StorageDead(_3); -// goto -> bb7; -// } -// } -// END rustc.test.ElaborateDrops.before.mir diff --git a/src/test/mir-opt/issue-62289/rustc.test.ElaborateDrops.before.mir b/src/test/mir-opt/issue-62289/rustc.test.ElaborateDrops.before.mir new file mode 100644 index 00000000000..c2f91980021 --- /dev/null +++ b/src/test/mir-opt/issue-62289/rustc.test.ElaborateDrops.before.mir @@ -0,0 +1,127 @@ +// MIR for `test` before ElaborateDrops + +fn test() -> std::option::Option<std::boxed::Box<u32>> { + let mut _0: std::option::Option<std::boxed::Box<u32>>; // return place in scope 0 at $DIR/issue-62289.rs:8:14: 8:30 + let mut _1: std::boxed::Box<u32>; // in scope 0 at $DIR/issue-62289.rs:9:10: 9:21 + let mut _2: std::boxed::Box<u32>; // in scope 0 at $DIR/issue-62289.rs:9:10: 9:21 + let mut _3: std::result::Result<u32, std::option::NoneError>; // in scope 0 at $DIR/issue-62289.rs:9:15: 9:20 + let mut _4: std::option::Option<u32>; // in scope 0 at $DIR/issue-62289.rs:9:15: 9:19 + let mut _5: isize; // in scope 0 at $DIR/issue-62289.rs:9:19: 9:20 + let _6: std::option::NoneError; // in scope 0 at $DIR/issue-62289.rs:9:19: 9:20 + let mut _7: !; // in scope 0 at $DIR/issue-62289.rs:9:19: 9:20 + let mut _8: std::option::NoneError; // in scope 0 at $DIR/issue-62289.rs:9:19: 9:20 + let mut _9: std::option::NoneError; // in scope 0 at $DIR/issue-62289.rs:9:19: 9:20 + let _10: u32; // in scope 0 at $DIR/issue-62289.rs:9:15: 9:20 + scope 1 { + debug err => _6; // in scope 1 at $DIR/issue-62289.rs:9:19: 9:20 + scope 2 { + } + } + scope 3 { + debug val => _10; // in scope 3 at $DIR/issue-62289.rs:9:15: 9:20 + scope 4 { + } + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/issue-62289.rs:9:10: 9:21 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/issue-62289.rs:9:10: 9:21 + _2 = Box(u32); // bb0[2]: scope 0 at $DIR/issue-62289.rs:9:10: 9:21 + StorageLive(_3); // bb0[3]: scope 0 at $DIR/issue-62289.rs:9:15: 9:20 + StorageLive(_4); // bb0[4]: scope 0 at $DIR/issue-62289.rs:9:15: 9:19 + _4 = std::option::Option::<u32>::None; // bb0[5]: scope 0 at $DIR/issue-62289.rs:9:15: 9:19 + _3 = const <std::option::Option<u32> as std::ops::Try>::into_result(move _4) -> [return: bb2, unwind: bb3]; // bb0[6]: scope 0 at $DIR/issue-62289.rs:9:15: 9:20 + // ty::Const + // + ty: fn(std::option::Option<u32>) -> std::result::Result<<std::option::Option<u32> as std::ops::Try>::Ok, <std::option::Option<u32> as std::ops::Try>::Error> {<std::option::Option<u32> as std::ops::Try>::into_result} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/issue-62289.rs:9:15: 9:20 + // + literal: Const { ty: fn(std::option::Option<u32>) -> std::result::Result<<std::option::Option<u32> as std::ops::Try>::Ok, <std::option::Option<u32> as std::ops::Try>::Error> {<std::option::Option<u32> as std::ops::Try>::into_result}, val: Value(Scalar(<ZST>)) } + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/issue-62289.rs:8:1: 10:2 + } + + bb2: { + StorageDead(_4); // bb2[0]: scope 0 at $DIR/issue-62289.rs:9:19: 9:20 + _5 = discriminant(_3); // bb2[1]: scope 0 at $DIR/issue-62289.rs:9:19: 9:20 + switchInt(move _5) -> [0isize: bb4, 1isize: bb6, otherwise: bb5]; // bb2[2]: scope 0 at $DIR/issue-62289.rs:9:19: 9:20 + } + + bb3 (cleanup): { + drop(_2) -> bb1; // bb3[0]: scope 0 at $DIR/issue-62289.rs:9:20: 9:21 + } + + bb4: { + StorageLive(_10); // bb4[0]: scope 0 at $DIR/issue-62289.rs:9:15: 9:20 + _10 = ((_3 as Ok).0: u32); // bb4[1]: scope 0 at $DIR/issue-62289.rs:9:15: 9:20 + (*_2) = _10; // bb4[2]: scope 4 at $DIR/issue-62289.rs:9:15: 9:20 + StorageDead(_10); // bb4[3]: scope 0 at $DIR/issue-62289.rs:9:19: 9:20 + _1 = move _2; // bb4[4]: scope 0 at $DIR/issue-62289.rs:9:10: 9:21 + drop(_2) -> [return: bb12, unwind: bb11]; // bb4[5]: scope 0 at $DIR/issue-62289.rs:9:20: 9:21 + } + + bb5: { + unreachable; // bb5[0]: scope 0 at $DIR/issue-62289.rs:9:15: 9:20 + } + + bb6: { + StorageLive(_6); // bb6[0]: scope 0 at $DIR/issue-62289.rs:9:19: 9:20 + _6 = ((_3 as Err).0: std::option::NoneError); // bb6[1]: scope 0 at $DIR/issue-62289.rs:9:19: 9:20 + StorageLive(_8); // bb6[2]: scope 2 at $DIR/issue-62289.rs:9:19: 9:20 + StorageLive(_9); // bb6[3]: scope 2 at $DIR/issue-62289.rs:9:19: 9:20 + _9 = _6; // bb6[4]: scope 2 at $DIR/issue-62289.rs:9:19: 9:20 + _8 = const <std::option::NoneError as std::convert::From<std::option::NoneError>>::from(move _9) -> [return: bb8, unwind: bb3]; // bb6[5]: scope 2 at $DIR/issue-62289.rs:9:19: 9:20 + // ty::Const + // + ty: fn(std::option::NoneError) -> std::option::NoneError {<std::option::NoneError as std::convert::From<std::option::NoneError>>::from} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/issue-62289.rs:9:19: 9:20 + // + literal: Const { ty: fn(std::option::NoneError) -> std::option::NoneError {<std::option::NoneError as std::convert::From<std::option::NoneError>>::from}, val: Value(Scalar(<ZST>)) } + } + + bb7: { + return; // bb7[0]: scope 0 at $DIR/issue-62289.rs:10:2: 10:2 + } + + bb8: { + StorageDead(_9); // bb8[0]: scope 2 at $DIR/issue-62289.rs:9:19: 9:20 + _0 = const <std::option::Option<std::boxed::Box<u32>> as std::ops::Try>::from_error(move _8) -> [return: bb9, unwind: bb3]; // bb8[1]: scope 2 at $DIR/issue-62289.rs:9:19: 9:20 + // ty::Const + // + ty: fn(<std::option::Option<std::boxed::Box<u32>> as std::ops::Try>::Error) -> std::option::Option<std::boxed::Box<u32>> {<std::option::Option<std::boxed::Box<u32>> as std::ops::Try>::from_error} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/issue-62289.rs:9:15: 9:20 + // + literal: Const { ty: fn(<std::option::Option<std::boxed::Box<u32>> as std::ops::Try>::Error) -> std::option::Option<std::boxed::Box<u32>> {<std::option::Option<std::boxed::Box<u32>> as std::ops::Try>::from_error}, val: Value(Scalar(<ZST>)) } + } + + bb9: { + StorageDead(_8); // bb9[0]: scope 2 at $DIR/issue-62289.rs:9:19: 9:20 + StorageDead(_6); // bb9[1]: scope 0 at $DIR/issue-62289.rs:9:19: 9:20 + drop(_2) -> bb10; // bb9[2]: scope 0 at $DIR/issue-62289.rs:9:20: 9:21 + } + + bb10: { + StorageDead(_2); // bb10[0]: scope 0 at $DIR/issue-62289.rs:9:20: 9:21 + StorageDead(_1); // bb10[1]: scope 0 at $DIR/issue-62289.rs:9:21: 9:22 + StorageDead(_3); // bb10[2]: scope 0 at $DIR/issue-62289.rs:10:1: 10:2 + goto -> bb7; // bb10[3]: scope 0 at $DIR/issue-62289.rs:9:19: 9:20 + } + + bb11 (cleanup): { + drop(_1) -> bb1; // bb11[0]: scope 0 at $DIR/issue-62289.rs:9:21: 9:22 + } + + bb12: { + StorageDead(_2); // bb12[0]: scope 0 at $DIR/issue-62289.rs:9:20: 9:21 + _0 = std::option::Option::<std::boxed::Box<u32>>::Some(move _1,); // bb12[1]: scope 0 at $DIR/issue-62289.rs:9:5: 9:22 + drop(_1) -> bb13; // bb12[2]: scope 0 at $DIR/issue-62289.rs:9:21: 9:22 + } + + bb13: { + StorageDead(_1); // bb13[0]: scope 0 at $DIR/issue-62289.rs:9:21: 9:22 + StorageDead(_3); // bb13[1]: scope 0 at $DIR/issue-62289.rs:10:1: 10:2 + goto -> bb7; // bb13[2]: scope 0 at $DIR/issue-62289.rs:10:2: 10:2 + } +} diff --git a/src/test/mir-opt/loop_test.rs b/src/test/mir-opt/loop_test.rs index 418febbdc01..cb23a4c671b 100644 --- a/src/test/mir-opt/loop_test.rs +++ b/src/test/mir-opt/loop_test.rs @@ -2,6 +2,7 @@ // Tests to make sure we correctly generate falseUnwind edges in loops +// EMIT_MIR rustc.main.SimplifyCfg-qualify-consts.after.mir fn main() { // Exit early at runtime. Since only care about the generated MIR // and not the runtime behavior (which is exercised by other tests) @@ -14,31 +15,3 @@ fn main() { continue; } } - -// END RUST SOURCE -// START rustc.main.SimplifyCfg-qualify-consts.after.mir -// ... -// bb1 (cleanup): { -// resume; -// } -// ... -// bb3: { // Entry into the loop -// _1 = (); -// StorageDead(_2); -// StorageDead(_1); -// StorageLive(_4); -// goto -> bb5; -// } -// ... -// bb5: { // The loop_block -// falseUnwind -> [real: bb6, cleanup: bb1]; -// } -// bb6: { // The loop body (body_block) -// StorageLive(_6); -// _6 = const 1i32; -// FakeRead(ForLet, _6); -// StorageDead(_6); -// goto -> bb5; -// } -// ... -// END rustc.main.SimplifyCfg-qualify-consts.after.mir diff --git a/src/test/mir-opt/loop_test/rustc.main.SimplifyCfg-qualify-consts.after.mir b/src/test/mir-opt/loop_test/rustc.main.SimplifyCfg-qualify-consts.after.mir new file mode 100644 index 00000000000..c458592e920 --- /dev/null +++ b/src/test/mir-opt/loop_test/rustc.main.SimplifyCfg-qualify-consts.after.mir @@ -0,0 +1,69 @@ +// MIR for `main` after SimplifyCfg-qualify-consts + +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/loop_test.rs:6:11: 6:11 + let _1: (); // in scope 0 at $DIR/loop_test.rs:10:5: 12:6 + let mut _2: bool; // in scope 0 at $DIR/loop_test.rs:10:8: 10:12 + let mut _3: !; // in scope 0 at $DIR/loop_test.rs:10:13: 12:6 + let mut _4: !; // in scope 0 at $DIR/loop_test.rs:13:5: 16:6 + let mut _5: (); // in scope 0 at $DIR/loop_test.rs:6:1: 17:2 + let _6: i32; // in scope 0 at $DIR/loop_test.rs:14:13: 14:14 + scope 1 { + debug x => _6; // in scope 1 at $DIR/loop_test.rs:14:13: 14:14 + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/loop_test.rs:10:5: 12:6 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/loop_test.rs:10:8: 10:12 + _2 = const true; // bb0[2]: scope 0 at $DIR/loop_test.rs:10:8: 10:12 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x01)) + // mir::Constant + // + span: $DIR/loop_test.rs:10:8: 10:12 + // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + FakeRead(ForMatchedPlace, _2); // bb0[3]: scope 0 at $DIR/loop_test.rs:10:8: 10:12 + switchInt(_2) -> [false: bb3, otherwise: bb2]; // bb0[4]: scope 0 at $DIR/loop_test.rs:10:5: 12:6 + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/loop_test.rs:6:1: 17:2 + } + + bb2: { + falseEdges -> [real: bb4, imaginary: bb3]; // bb2[0]: scope 0 at $DIR/loop_test.rs:10:5: 12:6 + } + + bb3: { + _1 = (); // bb3[0]: scope 0 at $DIR/loop_test.rs:10:5: 12:6 + StorageDead(_2); // bb3[1]: scope 0 at $DIR/loop_test.rs:12:5: 12:6 + StorageDead(_1); // bb3[2]: scope 0 at $DIR/loop_test.rs:12:5: 12:6 + StorageLive(_4); // bb3[3]: scope 0 at $DIR/loop_test.rs:13:5: 16:6 + goto -> bb5; // bb3[4]: scope 0 at $DIR/loop_test.rs:13:5: 16:6 + } + + bb4: { + _0 = (); // bb4[0]: scope 0 at $DIR/loop_test.rs:11:9: 11:15 + StorageDead(_2); // bb4[1]: scope 0 at $DIR/loop_test.rs:12:5: 12:6 + StorageDead(_1); // bb4[2]: scope 0 at $DIR/loop_test.rs:12:5: 12:6 + return; // bb4[3]: scope 0 at $DIR/loop_test.rs:17:2: 17:2 + } + + bb5: { + falseUnwind -> [real: bb6, cleanup: bb1]; // bb5[0]: scope 0 at $DIR/loop_test.rs:13:5: 16:6 + } + + bb6: { + StorageLive(_6); // bb6[0]: scope 0 at $DIR/loop_test.rs:14:13: 14:14 + _6 = const 1i32; // bb6[1]: scope 0 at $DIR/loop_test.rs:14:17: 14:18 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/loop_test.rs:14:17: 14:18 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } + FakeRead(ForLet, _6); // bb6[2]: scope 0 at $DIR/loop_test.rs:14:13: 14:14 + StorageDead(_6); // bb6[3]: scope 0 at $DIR/loop_test.rs:16:5: 16:6 + goto -> bb5; // bb6[4]: scope 0 at $DIR/loop_test.rs:15:9: 15:17 + } +} diff --git a/src/test/mir-opt/match-arm-scopes.rs b/src/test/mir-opt/match-arm-scopes.rs index 7afc3bbd6fa..0e30a156715 100644 --- a/src/test/mir-opt/match-arm-scopes.rs +++ b/src/test/mir-opt/match-arm-scopes.rs @@ -1,3 +1,4 @@ +// ignore-wasm32-bare compiled with panic=abort by default // Test that StorageDead and Drops are generated properly for bindings in // matches: // * The MIR should only contain a single drop of `s` and `t`: at the end @@ -8,6 +9,8 @@ // all of the bindings for that scope. // * No drop flags are used. +// EMIT_MIR rustc.complicated_match.SimplifyCfg-initial.after.mir +// EMIT_MIR rustc.complicated_match.ElaborateDrops.after.mir fn complicated_match(cond: bool, items: (bool, bool, String)) -> i32 { match items { (false, a, s) | (a, false, s) if if cond { return 3 } else { a } => 1, @@ -31,199 +34,3 @@ fn main() { assert_eq!(complicated_match(cond, (items_1, items_2, String::new())), result,); } } - -// END RUST SOURCE -// START rustc.complicated_match.SimplifyCfg-initial.after.mir -// let mut _0: i32; -// let mut _3: &bool; // Temp for fake borrow of `items.0` -// let mut _4: &bool; // Temp for fake borrow of `items.1` -// let _5: bool; // `a` in arm -// let _6: &bool; // `a` in guard -// let _7: std::string::String; // `s` in arm -// let _8: &std::string::String; // `s` in guard -// let mut _9: bool; // `if cond { return 3 } else { a }` -// let mut _10: bool; // `cond` -// let mut _11: !; // `return 3` -// let mut _12: bool; // `if cond { return 3 } else { a }` -// let mut _13: bool; // `cond` -// let mut _14: !; // `return 3` -// let _15: bool; // `b` -// let _16: std::string::String; // `t` -// scope 1 { -// debug a => _5; -// debug a => _6; -// debug s => _7; -// debug s => _8; -// } -// scope 2 { -// debug b => _15; -// debug t => _16; -// } -// bb0: { -// FakeRead(ForMatchedPlace, _2); -// switchInt((_2.0: bool)) -> [false: bb2, otherwise: bb3]; -// } -// bb1 (cleanup): { -// resume; -// } -// bb2: { // pre-binding for arm 1 first pattern -// falseEdges -> [real: bb9, imaginary: bb4]; -// } -// bb3: { -// switchInt((_2.1: bool)) -> [false: bb4, otherwise: bb5]; -// } -// bb4: { // pre-binding for arm 1 second pattern -// falseEdges -> [real: bb18, imaginary: bb6]; -// } -// bb5: { -// switchInt((_2.0: bool)) -> [false: bb7, otherwise: bb6]; -// } -// bb6: { // pre-binding for arm 2 first pattern -// falseEdges -> [real: bb26, imaginary: bb7]; -// } -// bb7: { // bindings for arm 2 - second pattern -// StorageLive(_15); -// _15 = (_2.1: bool); -// StorageLive(_16); -// _16 = move (_2.2: std::string::String); -// goto -> bb25; -// } -// bb8: { // arm 1 -// _0 = const 1i32; -// drop(_7) -> [return: bb24, unwind: bb14]; -// } -// bb9: { // guard - first time -// StorageLive(_6); -// _6 = &(_2.1: bool); -// StorageLive(_8); -// _8 = &(_2.2: std::string::String); -// _3 = &shallow (_2.0: bool); -// _4 = &shallow (_2.1: bool); -// StorageLive(_9); -// StorageLive(_10); -// _10 = _1; -// FakeRead(ForMatchedPlace, _10); -// switchInt(_10) -> [false: bb11, otherwise: bb10]; -// } -// bb10: { -// falseEdges -> [real: bb12, imaginary: bb11]; -// } -// bb11: { // `else` block - first time -// _9 = (*_6); -// StorageDead(_10); -// switchInt(move _9) -> [false: bb17, otherwise: bb16]; -// } -// bb12: { // `return 3` - first time -// _0 = const 3i32; -// StorageDead(_10); -// StorageDead(_9); -// StorageDead(_8); -// StorageDead(_6); -// goto -> bb15; -// } -// bb13: { -// return; -// } -// bb14 (cleanup): { -// drop(_2) -> bb1; -// } -// bb15: { -// drop(_2) -> [return: bb13, unwind: bb1]; -// } -// bb16: { -// StorageDead(_9); -// FakeRead(ForMatchGuard, _3); -// FakeRead(ForMatchGuard, _4); -// FakeRead(ForGuardBinding, _6); -// FakeRead(ForGuardBinding, _8); -// StorageLive(_5); -// _5 = (_2.1: bool); -// StorageLive(_7); -// _7 = move (_2.2: std::string::String); -// goto -> bb8; -// } -// bb17: { // guard otherwise case - first time -// StorageDead(_9); -// StorageDead(_8); -// StorageDead(_6); -// falseEdges -> [real: bb3, imaginary: bb4]; -// } -// bb18: { // guard - second time -// StorageLive(_6); -// _6 = &(_2.0: bool); -// StorageLive(_8); -// _8 = &(_2.2: std::string::String); -// _3 = &shallow (_2.0: bool); -// _4 = &shallow (_2.1: bool); -// StorageLive(_12); -// StorageLive(_13); -// _13 = _1; -// FakeRead(ForMatchedPlace, _13); -// switchInt(_13) -> [false: bb20, otherwise: bb19]; -// } -// bb19: { -// falseEdges -> [real: bb21, imaginary: bb20]; -// } -// bb20: { // `else` block - second time -// _12 = (*_6); -// StorageDead(_13); -// switchInt(move _12) -> [false: bb23, otherwise: bb22]; -// } -// bb21: { -// _0 = const 3i32; -// StorageDead(_13); -// StorageDead(_12); -// StorageDead(_8); -// StorageDead(_6); -// goto -> bb15; -// } -// bb22: { // bindings for arm 1 -// StorageDead(_12); -// FakeRead(ForMatchGuard, _3); -// FakeRead(ForMatchGuard, _4); -// FakeRead(ForGuardBinding, _6); -// FakeRead(ForGuardBinding, _8); -// StorageLive(_5); -// _5 = (_2.0: bool); -// StorageLive(_7); -// _7 = move (_2.2: std::string::String); -// goto -> bb8; -// } -// bb23: { // Guard otherwise case - second time -// StorageDead(_12); -// StorageDead(_8); -// StorageDead(_6); -// falseEdges -> [real: bb5, imaginary: bb6]; -// } -// bb24: { // rest of arm 1 -// StorageDead(_7); -// StorageDead(_5); -// StorageDead(_8); -// StorageDead(_6); -// goto -> bb28; -// } -// bb25: { // arm 2 -// _0 = const 2i32; -// drop(_16) -> [return: bb27, unwind: bb14]; -// } -// bb26: { // bindings for arm 2 - first pattern -// StorageLive(_15); -// _15 = (_2.1: bool); -// StorageLive(_16); -// _16 = move (_2.2: std::string::String); -// goto -> bb25; -// } - -// bb27: { // rest of arm 2 -// StorageDead(_16); -// StorageDead(_15); -// goto -> bb28; -// } -// bb28: { -// drop(_2) -> [return: bb13, unwind: bb1]; -// } -// END rustc.complicated_match.SimplifyCfg-initial.after.mir -// START rustc.complicated_match.ElaborateDrops.after.mir -// let _16: std::string::String; // No drop flags, which would come after this. -// scope 1 { -// END rustc.complicated_match.ElaborateDrops.after.mir diff --git a/src/test/mir-opt/match-arm-scopes/rustc.complicated_match.ElaborateDrops.after.mir b/src/test/mir-opt/match-arm-scopes/rustc.complicated_match.ElaborateDrops.after.mir new file mode 100644 index 00000000000..0b60f4f3321 --- /dev/null +++ b/src/test/mir-opt/match-arm-scopes/rustc.complicated_match.ElaborateDrops.after.mir @@ -0,0 +1,235 @@ +// MIR for `complicated_match` after ElaborateDrops + +fn complicated_match(_1: bool, _2: (bool, bool, std::string::String)) -> i32 { + debug cond => _1; // in scope 0 at $DIR/match-arm-scopes.rs:14:22: 14:26 + debug items => _2; // in scope 0 at $DIR/match-arm-scopes.rs:14:34: 14:39 + let mut _0: i32; // return place in scope 0 at $DIR/match-arm-scopes.rs:14:66: 14:69 + let mut _3: &bool; // in scope 0 at $DIR/match-arm-scopes.rs:15:11: 15:16 + let mut _4: &bool; // in scope 0 at $DIR/match-arm-scopes.rs:15:11: 15:16 + let _5: bool; // in scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18 + let _6: &bool; // in scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18 + let _7: std::string::String; // in scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21 + let _8: &std::string::String; // in scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21 + let mut _9: bool; // in scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 + let mut _10: bool; // in scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49 + let mut _11: !; // in scope 0 at $DIR/match-arm-scopes.rs:16:52: 16:60 + let mut _12: bool; // in scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 + let mut _13: bool; // in scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49 + let mut _14: !; // in scope 0 at $DIR/match-arm-scopes.rs:16:52: 16:60 + let _15: bool; // in scope 0 at $DIR/match-arm-scopes.rs:17:16: 17:17 + let _16: std::string::String; // in scope 0 at $DIR/match-arm-scopes.rs:17:19: 17:20 + scope 1 { + debug a => _5; // in scope 1 at $DIR/match-arm-scopes.rs:16:17: 16:18 + debug a => _6; // in scope 1 at $DIR/match-arm-scopes.rs:16:17: 16:18 + debug s => _7; // in scope 1 at $DIR/match-arm-scopes.rs:16:20: 16:21 + debug s => _8; // in scope 1 at $DIR/match-arm-scopes.rs:16:20: 16:21 + } + scope 2 { + debug b => _15; // in scope 2 at $DIR/match-arm-scopes.rs:17:16: 17:17 + debug t => _16; // in scope 2 at $DIR/match-arm-scopes.rs:17:19: 17:20 + } + + bb0: { + switchInt((_2.0: bool)) -> [false: bb6, otherwise: bb2]; // bb0[0]: scope 0 at $DIR/match-arm-scopes.rs:16:10: 16:15 + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/match-arm-scopes.rs:14:1: 19:2 + } + + bb2: { + switchInt((_2.1: bool)) -> [false: bb14, otherwise: bb3]; // bb2[0]: scope 0 at $DIR/match-arm-scopes.rs:16:29: 16:34 + } + + bb3: { + switchInt((_2.0: bool)) -> [false: bb4, otherwise: bb21]; // bb3[0]: scope 0 at $DIR/match-arm-scopes.rs:17:10: 17:14 + } + + bb4: { + StorageLive(_15); // bb4[0]: scope 0 at $DIR/match-arm-scopes.rs:17:32: 17:33 + _15 = (_2.1: bool); // bb4[1]: scope 0 at $DIR/match-arm-scopes.rs:17:32: 17:33 + StorageLive(_16); // bb4[2]: scope 0 at $DIR/match-arm-scopes.rs:17:35: 17:36 + _16 = move (_2.2: std::string::String); // bb4[3]: scope 0 at $DIR/match-arm-scopes.rs:17:35: 17:36 + goto -> bb20; // bb4[4]: scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6 + } + + bb5: { + _0 = const 1i32; // bb5[0]: scope 1 at $DIR/match-arm-scopes.rs:16:77: 16:78 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/match-arm-scopes.rs:16:77: 16:78 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } + drop(_7) -> [return: bb19, unwind: bb10]; // bb5[1]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + } + + bb6: { + StorageLive(_6); // bb6[0]: scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18 + _6 = &(_2.1: bool); // bb6[1]: scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18 + StorageLive(_8); // bb6[2]: scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21 + _8 = &(_2.2: std::string::String); // bb6[3]: scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21 + StorageLive(_9); // bb6[4]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 + StorageLive(_10); // bb6[5]: scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49 + _10 = _1; // bb6[6]: scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49 + switchInt(_10) -> [false: bb7, otherwise: bb8]; // bb6[7]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 + } + + bb7: { + _9 = (*_6); // bb7[0]: scope 0 at $DIR/match-arm-scopes.rs:16:70: 16:71 + StorageDead(_10); // bb7[1]: scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 + switchInt(move _9) -> [false: bb13, otherwise: bb12]; // bb7[2]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 + } + + bb8: { + _0 = const 3i32; // bb8[0]: scope 0 at $DIR/match-arm-scopes.rs:16:59: 16:60 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/match-arm-scopes.rs:16:59: 16:60 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } + StorageDead(_10); // bb8[1]: scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 + StorageDead(_9); // bb8[2]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_8); // bb8[3]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_6); // bb8[4]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + goto -> bb11; // bb8[5]: scope 0 at $DIR/match-arm-scopes.rs:16:52: 16:60 + } + + bb9: { + return; // bb9[0]: scope 0 at $DIR/match-arm-scopes.rs:19:2: 19:2 + } + + bb10 (cleanup): { + goto -> bb25; // bb10[0]: scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2 + } + + bb11: { + drop(_2) -> [return: bb9, unwind: bb1]; // bb11[0]: scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2 + } + + bb12: { + StorageDead(_9); // bb12[0]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageLive(_5); // bb12[1]: scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18 + _5 = (_2.1: bool); // bb12[2]: scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18 + StorageLive(_7); // bb12[3]: scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21 + _7 = move (_2.2: std::string::String); // bb12[4]: scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21 + goto -> bb5; // bb12[5]: scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6 + } + + bb13: { + StorageDead(_9); // bb13[0]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_8); // bb13[1]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_6); // bb13[2]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + goto -> bb2; // bb13[3]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 + } + + bb14: { + StorageLive(_6); // bb14[0]: scope 0 at $DIR/match-arm-scopes.rs:16:26: 16:27 + _6 = &(_2.0: bool); // bb14[1]: scope 0 at $DIR/match-arm-scopes.rs:16:26: 16:27 + StorageLive(_8); // bb14[2]: scope 0 at $DIR/match-arm-scopes.rs:16:36: 16:37 + _8 = &(_2.2: std::string::String); // bb14[3]: scope 0 at $DIR/match-arm-scopes.rs:16:36: 16:37 + StorageLive(_12); // bb14[4]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 + StorageLive(_13); // bb14[5]: scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49 + _13 = _1; // bb14[6]: scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49 + switchInt(_13) -> [false: bb15, otherwise: bb16]; // bb14[7]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 + } + + bb15: { + _12 = (*_6); // bb15[0]: scope 0 at $DIR/match-arm-scopes.rs:16:70: 16:71 + StorageDead(_13); // bb15[1]: scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 + switchInt(move _12) -> [false: bb18, otherwise: bb17]; // bb15[2]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 + } + + bb16: { + _0 = const 3i32; // bb16[0]: scope 0 at $DIR/match-arm-scopes.rs:16:59: 16:60 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/match-arm-scopes.rs:16:59: 16:60 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } + StorageDead(_13); // bb16[1]: scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 + StorageDead(_12); // bb16[2]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_8); // bb16[3]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_6); // bb16[4]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + goto -> bb11; // bb16[5]: scope 0 at $DIR/match-arm-scopes.rs:16:52: 16:60 + } + + bb17: { + StorageDead(_12); // bb17[0]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageLive(_5); // bb17[1]: scope 0 at $DIR/match-arm-scopes.rs:16:26: 16:27 + _5 = (_2.0: bool); // bb17[2]: scope 0 at $DIR/match-arm-scopes.rs:16:26: 16:27 + StorageLive(_7); // bb17[3]: scope 0 at $DIR/match-arm-scopes.rs:16:36: 16:37 + _7 = move (_2.2: std::string::String); // bb17[4]: scope 0 at $DIR/match-arm-scopes.rs:16:36: 16:37 + goto -> bb5; // bb17[5]: scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6 + } + + bb18: { + StorageDead(_12); // bb18[0]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_8); // bb18[1]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_6); // bb18[2]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + goto -> bb3; // bb18[3]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 + } + + bb19: { + StorageDead(_7); // bb19[0]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_5); // bb19[1]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_8); // bb19[2]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_6); // bb19[3]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + goto -> bb23; // bb19[4]: scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6 + } + + bb20: { + _0 = const 2i32; // bb20[0]: scope 2 at $DIR/match-arm-scopes.rs:17:41: 17:42 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/match-arm-scopes.rs:17:41: 17:42 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } + drop(_16) -> [return: bb22, unwind: bb10]; // bb20[1]: scope 0 at $DIR/match-arm-scopes.rs:17:42: 17:43 + } + + bb21: { + StorageLive(_15); // bb21[0]: scope 0 at $DIR/match-arm-scopes.rs:17:16: 17:17 + _15 = (_2.1: bool); // bb21[1]: scope 0 at $DIR/match-arm-scopes.rs:17:16: 17:17 + StorageLive(_16); // bb21[2]: scope 0 at $DIR/match-arm-scopes.rs:17:19: 17:20 + _16 = move (_2.2: std::string::String); // bb21[3]: scope 0 at $DIR/match-arm-scopes.rs:17:19: 17:20 + goto -> bb20; // bb21[4]: scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6 + } + + bb22: { + StorageDead(_16); // bb22[0]: scope 0 at $DIR/match-arm-scopes.rs:17:42: 17:43 + StorageDead(_15); // bb22[1]: scope 0 at $DIR/match-arm-scopes.rs:17:42: 17:43 + goto -> bb23; // bb22[2]: scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6 + } + + bb23: { + goto -> bb29; // bb23[0]: scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2 + } + + bb24 (cleanup): { + goto -> bb1; // bb24[0]: scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2 + } + + bb25 (cleanup): { + goto -> bb24; // bb25[0]: scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2 + } + + bb26: { + goto -> bb9; // bb26[0]: scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2 + } + + bb27 (cleanup): { + goto -> bb1; // bb27[0]: scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2 + } + + bb28 (cleanup): { + goto -> bb27; // bb28[0]: scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2 + } + + bb29: { + goto -> bb26; // bb29[0]: scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2 + } +} diff --git a/src/test/mir-opt/match-arm-scopes/rustc.complicated_match.SimplifyCfg-initial.after.mir b/src/test/mir-opt/match-arm-scopes/rustc.complicated_match.SimplifyCfg-initial.after.mir new file mode 100644 index 00000000000..80ce94a7f3c --- /dev/null +++ b/src/test/mir-opt/match-arm-scopes/rustc.complicated_match.SimplifyCfg-initial.after.mir @@ -0,0 +1,246 @@ +// MIR for `complicated_match` after SimplifyCfg-initial + +fn complicated_match(_1: bool, _2: (bool, bool, std::string::String)) -> i32 { + debug cond => _1; // in scope 0 at $DIR/match-arm-scopes.rs:14:22: 14:26 + debug items => _2; // in scope 0 at $DIR/match-arm-scopes.rs:14:34: 14:39 + let mut _0: i32; // return place in scope 0 at $DIR/match-arm-scopes.rs:14:66: 14:69 + let mut _3: &bool; // in scope 0 at $DIR/match-arm-scopes.rs:15:11: 15:16 + let mut _4: &bool; // in scope 0 at $DIR/match-arm-scopes.rs:15:11: 15:16 + let _5: bool; // in scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18 + let _6: &bool; // in scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18 + let _7: std::string::String; // in scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21 + let _8: &std::string::String; // in scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21 + let mut _9: bool; // in scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 + let mut _10: bool; // in scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49 + let mut _11: !; // in scope 0 at $DIR/match-arm-scopes.rs:16:52: 16:60 + let mut _12: bool; // in scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 + let mut _13: bool; // in scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49 + let mut _14: !; // in scope 0 at $DIR/match-arm-scopes.rs:16:52: 16:60 + let _15: bool; // in scope 0 at $DIR/match-arm-scopes.rs:17:16: 17:17 + let _16: std::string::String; // in scope 0 at $DIR/match-arm-scopes.rs:17:19: 17:20 + scope 1 { + debug a => _5; // in scope 1 at $DIR/match-arm-scopes.rs:16:17: 16:18 + debug a => _6; // in scope 1 at $DIR/match-arm-scopes.rs:16:17: 16:18 + debug s => _7; // in scope 1 at $DIR/match-arm-scopes.rs:16:20: 16:21 + debug s => _8; // in scope 1 at $DIR/match-arm-scopes.rs:16:20: 16:21 + } + scope 2 { + debug b => _15; // in scope 2 at $DIR/match-arm-scopes.rs:17:16: 17:17 + debug t => _16; // in scope 2 at $DIR/match-arm-scopes.rs:17:19: 17:20 + } + + bb0: { + FakeRead(ForMatchedPlace, _2); // bb0[0]: scope 0 at $DIR/match-arm-scopes.rs:15:11: 15:16 + switchInt((_2.0: bool)) -> [false: bb2, otherwise: bb3]; // bb0[1]: scope 0 at $DIR/match-arm-scopes.rs:16:10: 16:15 + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/match-arm-scopes.rs:14:1: 19:2 + } + + bb2: { + falseEdges -> [real: bb9, imaginary: bb4]; // bb2[0]: scope 0 at $DIR/match-arm-scopes.rs:16:9: 16:22 + } + + bb3: { + switchInt((_2.1: bool)) -> [false: bb4, otherwise: bb5]; // bb3[0]: scope 0 at $DIR/match-arm-scopes.rs:16:29: 16:34 + } + + bb4: { + falseEdges -> [real: bb18, imaginary: bb6]; // bb4[0]: scope 0 at $DIR/match-arm-scopes.rs:16:25: 16:38 + } + + bb5: { + switchInt((_2.0: bool)) -> [false: bb7, otherwise: bb6]; // bb5[0]: scope 0 at $DIR/match-arm-scopes.rs:17:10: 17:14 + } + + bb6: { + falseEdges -> [real: bb26, imaginary: bb7]; // bb6[0]: scope 0 at $DIR/match-arm-scopes.rs:17:9: 17:21 + } + + bb7: { + StorageLive(_15); // bb7[0]: scope 0 at $DIR/match-arm-scopes.rs:17:32: 17:33 + _15 = (_2.1: bool); // bb7[1]: scope 0 at $DIR/match-arm-scopes.rs:17:32: 17:33 + StorageLive(_16); // bb7[2]: scope 0 at $DIR/match-arm-scopes.rs:17:35: 17:36 + _16 = move (_2.2: std::string::String); // bb7[3]: scope 0 at $DIR/match-arm-scopes.rs:17:35: 17:36 + goto -> bb25; // bb7[4]: scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6 + } + + bb8: { + _0 = const 1i32; // bb8[0]: scope 1 at $DIR/match-arm-scopes.rs:16:77: 16:78 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/match-arm-scopes.rs:16:77: 16:78 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } + drop(_7) -> [return: bb24, unwind: bb14]; // bb8[1]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + } + + bb9: { + StorageLive(_6); // bb9[0]: scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18 + _6 = &(_2.1: bool); // bb9[1]: scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18 + StorageLive(_8); // bb9[2]: scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21 + _8 = &(_2.2: std::string::String); // bb9[3]: scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21 + _3 = &shallow (_2.0: bool); // bb9[4]: scope 0 at $DIR/match-arm-scopes.rs:15:11: 15:16 + _4 = &shallow (_2.1: bool); // bb9[5]: scope 0 at $DIR/match-arm-scopes.rs:15:11: 15:16 + StorageLive(_9); // bb9[6]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 + StorageLive(_10); // bb9[7]: scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49 + _10 = _1; // bb9[8]: scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49 + FakeRead(ForMatchedPlace, _10); // bb9[9]: scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49 + switchInt(_10) -> [false: bb11, otherwise: bb10]; // bb9[10]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 + } + + bb10: { + falseEdges -> [real: bb12, imaginary: bb11]; // bb10[0]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 + } + + bb11: { + _9 = (*_6); // bb11[0]: scope 0 at $DIR/match-arm-scopes.rs:16:70: 16:71 + StorageDead(_10); // bb11[1]: scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 + switchInt(move _9) -> [false: bb17, otherwise: bb16]; // bb11[2]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 + } + + bb12: { + _0 = const 3i32; // bb12[0]: scope 0 at $DIR/match-arm-scopes.rs:16:59: 16:60 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/match-arm-scopes.rs:16:59: 16:60 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } + StorageDead(_10); // bb12[1]: scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 + StorageDead(_9); // bb12[2]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_8); // bb12[3]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_6); // bb12[4]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + goto -> bb15; // bb12[5]: scope 0 at $DIR/match-arm-scopes.rs:16:52: 16:60 + } + + bb13: { + return; // bb13[0]: scope 0 at $DIR/match-arm-scopes.rs:19:2: 19:2 + } + + bb14 (cleanup): { + drop(_2) -> bb1; // bb14[0]: scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2 + } + + bb15: { + drop(_2) -> [return: bb13, unwind: bb1]; // bb15[0]: scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2 + } + + bb16: { + StorageDead(_9); // bb16[0]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + FakeRead(ForMatchGuard, _3); // bb16[1]: scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 + FakeRead(ForMatchGuard, _4); // bb16[2]: scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 + FakeRead(ForGuardBinding, _6); // bb16[3]: scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 + FakeRead(ForGuardBinding, _8); // bb16[4]: scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 + StorageLive(_5); // bb16[5]: scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18 + _5 = (_2.1: bool); // bb16[6]: scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18 + StorageLive(_7); // bb16[7]: scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21 + _7 = move (_2.2: std::string::String); // bb16[8]: scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21 + goto -> bb8; // bb16[9]: scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6 + } + + bb17: { + StorageDead(_9); // bb17[0]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_8); // bb17[1]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_6); // bb17[2]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + falseEdges -> [real: bb3, imaginary: bb4]; // bb17[3]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 + } + + bb18: { + StorageLive(_6); // bb18[0]: scope 0 at $DIR/match-arm-scopes.rs:16:26: 16:27 + _6 = &(_2.0: bool); // bb18[1]: scope 0 at $DIR/match-arm-scopes.rs:16:26: 16:27 + StorageLive(_8); // bb18[2]: scope 0 at $DIR/match-arm-scopes.rs:16:36: 16:37 + _8 = &(_2.2: std::string::String); // bb18[3]: scope 0 at $DIR/match-arm-scopes.rs:16:36: 16:37 + _3 = &shallow (_2.0: bool); // bb18[4]: scope 0 at $DIR/match-arm-scopes.rs:15:11: 15:16 + _4 = &shallow (_2.1: bool); // bb18[5]: scope 0 at $DIR/match-arm-scopes.rs:15:11: 15:16 + StorageLive(_12); // bb18[6]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 + StorageLive(_13); // bb18[7]: scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49 + _13 = _1; // bb18[8]: scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49 + FakeRead(ForMatchedPlace, _13); // bb18[9]: scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49 + switchInt(_13) -> [false: bb20, otherwise: bb19]; // bb18[10]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 + } + + bb19: { + falseEdges -> [real: bb21, imaginary: bb20]; // bb19[0]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 + } + + bb20: { + _12 = (*_6); // bb20[0]: scope 0 at $DIR/match-arm-scopes.rs:16:70: 16:71 + StorageDead(_13); // bb20[1]: scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 + switchInt(move _12) -> [false: bb23, otherwise: bb22]; // bb20[2]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 + } + + bb21: { + _0 = const 3i32; // bb21[0]: scope 0 at $DIR/match-arm-scopes.rs:16:59: 16:60 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/match-arm-scopes.rs:16:59: 16:60 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } + StorageDead(_13); // bb21[1]: scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 + StorageDead(_12); // bb21[2]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_8); // bb21[3]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_6); // bb21[4]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + goto -> bb15; // bb21[5]: scope 0 at $DIR/match-arm-scopes.rs:16:52: 16:60 + } + + bb22: { + StorageDead(_12); // bb22[0]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + FakeRead(ForMatchGuard, _3); // bb22[1]: scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 + FakeRead(ForMatchGuard, _4); // bb22[2]: scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 + FakeRead(ForGuardBinding, _6); // bb22[3]: scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 + FakeRead(ForGuardBinding, _8); // bb22[4]: scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 + StorageLive(_5); // bb22[5]: scope 0 at $DIR/match-arm-scopes.rs:16:26: 16:27 + _5 = (_2.0: bool); // bb22[6]: scope 0 at $DIR/match-arm-scopes.rs:16:26: 16:27 + StorageLive(_7); // bb22[7]: scope 0 at $DIR/match-arm-scopes.rs:16:36: 16:37 + _7 = move (_2.2: std::string::String); // bb22[8]: scope 0 at $DIR/match-arm-scopes.rs:16:36: 16:37 + goto -> bb8; // bb22[9]: scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6 + } + + bb23: { + StorageDead(_12); // bb23[0]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_8); // bb23[1]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_6); // bb23[2]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + falseEdges -> [real: bb5, imaginary: bb6]; // bb23[3]: scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 + } + + bb24: { + StorageDead(_7); // bb24[0]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_5); // bb24[1]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_8); // bb24[2]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + StorageDead(_6); // bb24[3]: scope 0 at $DIR/match-arm-scopes.rs:16:78: 16:79 + goto -> bb28; // bb24[4]: scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6 + } + + bb25: { + _0 = const 2i32; // bb25[0]: scope 2 at $DIR/match-arm-scopes.rs:17:41: 17:42 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/match-arm-scopes.rs:17:41: 17:42 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } + drop(_16) -> [return: bb27, unwind: bb14]; // bb25[1]: scope 0 at $DIR/match-arm-scopes.rs:17:42: 17:43 + } + + bb26: { + StorageLive(_15); // bb26[0]: scope 0 at $DIR/match-arm-scopes.rs:17:16: 17:17 + _15 = (_2.1: bool); // bb26[1]: scope 0 at $DIR/match-arm-scopes.rs:17:16: 17:17 + StorageLive(_16); // bb26[2]: scope 0 at $DIR/match-arm-scopes.rs:17:19: 17:20 + _16 = move (_2.2: std::string::String); // bb26[3]: scope 0 at $DIR/match-arm-scopes.rs:17:19: 17:20 + goto -> bb25; // bb26[4]: scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6 + } + + bb27: { + StorageDead(_16); // bb27[0]: scope 0 at $DIR/match-arm-scopes.rs:17:42: 17:43 + StorageDead(_15); // bb27[1]: scope 0 at $DIR/match-arm-scopes.rs:17:42: 17:43 + goto -> bb28; // bb27[2]: scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6 + } + + bb28: { + drop(_2) -> [return: bb13, unwind: bb1]; // bb28[0]: scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2 + } +} diff --git a/src/test/mir-opt/match_false_edges.rs b/src/test/mir-opt/match_false_edges.rs index 237828d9020..91f4aad165e 100644 --- a/src/test/mir-opt/match_false_edges.rs +++ b/src/test/mir-opt/match_false_edges.rs @@ -10,6 +10,7 @@ fn guard2(_: i32) -> bool { // no_mangle to make sure this gets instantiated even in an executable. #[no_mangle] +// EMIT_MIR rustc.full_tested_match.PromoteTemps.after.mir pub fn full_tested_match() { let _ = match Some(42) { Some(x) if guard() => (1, x), @@ -20,6 +21,7 @@ pub fn full_tested_match() { // no_mangle to make sure this gets instantiated even in an executable. #[no_mangle] +// EMIT_MIR rustc.full_tested_match2.PromoteTemps.before.mir pub fn full_tested_match2() { let _ = match Some(42) { Some(x) if guard() => (1, x), @@ -28,6 +30,7 @@ pub fn full_tested_match2() { }; } +// EMIT_MIR rustc.main.PromoteTemps.before.mir fn main() { let _ = match Some(1) { Some(_w) if guard() => 1, @@ -36,245 +39,3 @@ fn main() { _z => 4, }; } - -// END RUST SOURCE -// -// START rustc.full_tested_match.PromoteTemps.after.mir -// bb0: { -// ... -// _2 = std::option::Option::<i32>::Some(const 42i32,); -// FakeRead(ForMatchedPlace, _2); -// _3 = discriminant(_2); -// switchInt(move _3) -> [0isize: bb2, 1isize: bb3, otherwise: bb5]; -// } -// bb1 (cleanup): { -// resume; -// } -// bb2: { // pre_binding3 and arm3 -// _1 = (const 3i32, const 3i32); -// goto -> bb11; -// } -// bb3: { -// falseEdges -> [real: bb6, imaginary: bb4]; //pre_binding1 -// } -// bb4: { -// falseEdges -> [real: bb10, imaginary: bb2]; //pre_binding2 -// } -// bb5: { -// unreachable; -// } -// bb6: { // binding1 and guard -// StorageLive(_6); -// _11 = const full_tested_match::promoted[0]; -// _6 = &(((*_11) as Some).0: i32); -// _4 = &shallow _2; -// StorageLive(_7); -// _7 = const guard() -> [return: bb7, unwind: bb1]; -// } -// bb7: { // end of guard -// switchInt(move _7) -> [false: bb9, otherwise: bb8]; -// } -// bb8: { // arm1 -// StorageDead(_7); -// FakeRead(ForMatchGuard, _4); -// FakeRead(ForGuardBinding, _6); -// StorageLive(_5); -// _5 = ((_2 as Some).0: i32); -// StorageLive(_8); -// _8 = _5; -// _1 = (const 1i32, move _8); -// StorageDead(_8); -// StorageDead(_5); -// StorageDead(_6); -// goto -> bb11; -// } -// bb9: { // to pre_binding2 -// StorageDead(_7); -// StorageDead(_6); -// goto -> bb4; -// } -// bb10: { // arm2 -// StorageLive(_9); -// _9 = ((_2 as Some).0: i32); -// StorageLive(_10); -// _10 = _9; -// _1 = (const 2i32, move _10); -// StorageDead(_10); -// StorageDead(_9); -// goto -> bb11; -// } -// bb11: { -// StorageDead(_2); -// StorageDead(_1); -// _0 = (); -// return; -// } -// END rustc.full_tested_match.PromoteTemps.after.mir -// -// START rustc.full_tested_match2.PromoteTemps.before.mir -// bb0: { -// ... -// _2 = std::option::Option::<i32>::Some(const 42i32,); -// FakeRead(ForMatchedPlace, _2); -// _3 = discriminant(_2); -// switchInt(move _3) -> [0isize: bb2, 1isize: bb3, otherwise: bb5]; -// } -// bb1 (cleanup): { -// resume; -// } -// bb2: { // pre_binding2 -// falseEdges -> [real: bb10, imaginary: bb4]; -// } -// bb3: { // pre_binding1 -// falseEdges -> [real: bb6, imaginary: bb2]; -// } -// bb4: { // binding3 and arm3 -// StorageLive(_9); -// _9 = ((_2 as Some).0: i32); -// StorageLive(_10); -// _10 = _9; -// _1 = (const 2i32, move _10); -// StorageDead(_10); -// StorageDead(_9); -// goto -> bb11; -// } -// bb5: { -// unreachable; -// } -// bb6: { -// StorageLive(_6); -// _6 = &((_2 as Some).0: i32); -// _4 = &shallow _2; -// StorageLive(_7); -// _7 = const guard() -> [return: bb7, unwind: bb1]; -// } -// bb7: { // end of guard -// switchInt(move _7) -> [false: bb9, otherwise: bb8]; -// } -// bb8: { -// StorageDead(_7); -// FakeRead(ForMatchGuard, _4); -// FakeRead(ForGuardBinding, _6); -// StorageLive(_5); -// _5 = ((_2 as Some).0: i32); -// StorageLive(_8); -// _8 = _5; -// _1 = (const 1i32, move _8); -// StorageDead(_8); -// StorageDead(_5); -// StorageDead(_6); -// goto -> bb11; -// } -// bb9: { // to pre_binding3 (can skip 2 since this is `Some`) -// StorageDead(_7); -// StorageDead(_6); -// falseEdges -> [real: bb4, imaginary: bb2]; -// } -// bb10: { // arm2 -// _1 = (const 3i32, const 3i32); -// goto -> bb11; -// } -// bb11: { -// StorageDead(_2); -// StorageDead(_1); -// _0 = (); -// return; -// } -// END rustc.full_tested_match2.PromoteTemps.before.mir -// -// START rustc.main.PromoteTemps.before.mir -// bb0: { -// ... -// _2 = std::option::Option::<i32>::Some(const 1i32,); -// FakeRead(ForMatchedPlace, _2); -// _4 = discriminant(_2); -// switchInt(move _4) -> [1isize: bb3, otherwise: bb2]; -// } -// bb1 (cleanup): { -// resume; -// } -// bb2: { -// falseEdges -> [real: bb10, imaginary: bb5]; -// } -// bb3: { -// falseEdges -> [real: bb6, imaginary: bb2]; -// } -// bb4: { -// StorageLive(_14); -// _14 = _2; -// _1 = const 4i32; -// StorageDead(_14); -// goto -> bb15; -// } -// bb5: { -// falseEdges -> [real: bb11, imaginary: bb4]; -// } -// bb6: { //end of guard1 -// StorageLive(_7); -// _7 = &((_2 as Some).0: i32); -// _5 = &shallow _2; -// StorageLive(_8); -// _8 = const guard() -> [return: bb7, unwind: bb1]; -// } -// bb7: { -// switchInt(move _8) -> [false: bb9, otherwise: bb8]; -// } -// bb8: { -// StorageDead(_8); -// FakeRead(ForMatchGuard, _5); -// FakeRead(ForGuardBinding, _7); -// StorageLive(_6); -// _6 = ((_2 as Some).0: i32); -// _1 = const 1i32; -// StorageDead(_6); -// StorageDead(_7); -// goto -> bb15; -// } -// bb9: { -// StorageDead(_8); -// StorageDead(_7); -// falseEdges -> [real: bb2, imaginary: bb2]; -// } -// bb10: { // binding2 & arm2 -// StorageLive(_9); -// _9 = _2; -// _1 = const 2i32; -// StorageDead(_9); -// goto -> bb15; -// } -// bb11: { // binding3: Some(y) if guard2(y) -// StorageLive(_11); -// _11 = &((_2 as Some).0: i32); -// _5 = &shallow _2; -// StorageLive(_12); -// StorageLive(_13); -// _13 = (*_11); -// _12 = const guard2(move _13) -> [return: bb12, unwind: bb1]; -// } -// bb12: { // end of guard2 -// StorageDead(_13); -// switchInt(move _12) -> [false: bb14, otherwise: bb13]; -// } -// bb13: { // binding4 & arm4 -// StorageDead(_12); -// FakeRead(ForMatchGuard, _5); -// FakeRead(ForGuardBinding, _11); -// StorageLive(_10); -// _10 = ((_2 as Some).0: i32); -// _1 = const 3i32; -// StorageDead(_10); -// StorageDead(_11); -// goto -> bb15; -// } -// bb14: { -// StorageDead(_12); -// StorageDead(_11); -// falseEdges -> [real: bb4, imaginary: bb4]; -// } -// bb15: { -// StorageDead(_2); -// StorageDead(_1); -// _0 = (); -// return; -// } -// END rustc.main.PromoteTemps.before.mir diff --git a/src/test/mir-opt/match_false_edges/rustc.full_tested_match.PromoteTemps.after.mir b/src/test/mir-opt/match_false_edges/rustc.full_tested_match.PromoteTemps.after.mir new file mode 100644 index 00000000000..acc03cce46e --- /dev/null +++ b/src/test/mir-opt/match_false_edges/rustc.full_tested_match.PromoteTemps.after.mir @@ -0,0 +1,149 @@ +// MIR for `full_tested_match` after PromoteTemps + +fn full_tested_match() -> () { + let mut _0: (); // return place in scope 0 at $DIR/match_false_edges.rs:14:28: 14:28 + let mut _1: (i32, i32); // in scope 0 at $DIR/match_false_edges.rs:15:13: 19:6 + let mut _2: std::option::Option<i32>; // in scope 0 at $DIR/match_false_edges.rs:15:19: 15:27 + let mut _3: isize; // in scope 0 at $DIR/match_false_edges.rs:16:9: 16:16 + let mut _4: &std::option::Option<i32>; // in scope 0 at $DIR/match_false_edges.rs:15:19: 15:27 + let _5: i32; // in scope 0 at $DIR/match_false_edges.rs:16:14: 16:15 + let _6: &i32; // in scope 0 at $DIR/match_false_edges.rs:16:14: 16:15 + let mut _7: bool; // in scope 0 at $DIR/match_false_edges.rs:16:20: 16:27 + let mut _8: i32; // in scope 0 at $DIR/match_false_edges.rs:16:35: 16:36 + let _9: i32; // in scope 0 at $DIR/match_false_edges.rs:17:14: 17:15 + let mut _10: i32; // in scope 0 at $DIR/match_false_edges.rs:17:24: 17:25 + let mut _11: &std::option::Option<i32>; // in scope 0 at $DIR/match_false_edges.rs:16:14: 16:15 + scope 1 { + } + scope 2 { + debug x => _5; // in scope 2 at $DIR/match_false_edges.rs:16:14: 16:15 + debug x => _6; // in scope 2 at $DIR/match_false_edges.rs:16:14: 16:15 + } + scope 3 { + debug y => _9; // in scope 3 at $DIR/match_false_edges.rs:17:14: 17:15 + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/match_false_edges.rs:15:13: 19:6 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/match_false_edges.rs:15:19: 15:27 + _2 = std::option::Option::<i32>::Some(const 42i32,); // bb0[2]: scope 0 at $DIR/match_false_edges.rs:15:19: 15:27 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x0000002a)) + // mir::Constant + // + span: $DIR/match_false_edges.rs:15:24: 15:26 + // + literal: Const { ty: i32, val: Value(Scalar(0x0000002a)) } + FakeRead(ForMatchedPlace, _2); // bb0[3]: scope 0 at $DIR/match_false_edges.rs:15:19: 15:27 + _3 = discriminant(_2); // bb0[4]: scope 0 at $DIR/match_false_edges.rs:16:9: 16:16 + switchInt(move _3) -> [0isize: bb2, 1isize: bb3, otherwise: bb5]; // bb0[5]: scope 0 at $DIR/match_false_edges.rs:16:9: 16:16 + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/match_false_edges.rs:14:1: 20:2 + } + + bb2: { + _1 = (const 3i32, const 3i32); // bb2[0]: scope 0 at $DIR/match_false_edges.rs:18:17: 18:23 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/match_false_edges.rs:18:18: 18:19 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/match_false_edges.rs:18:21: 18:22 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } + goto -> bb11; // bb2[1]: scope 0 at $DIR/match_false_edges.rs:15:13: 19:6 + } + + bb3: { + falseEdges -> [real: bb6, imaginary: bb4]; // bb3[0]: scope 0 at $DIR/match_false_edges.rs:16:9: 16:16 + } + + bb4: { + falseEdges -> [real: bb10, imaginary: bb2]; // bb4[0]: scope 0 at $DIR/match_false_edges.rs:17:9: 17:16 + } + + bb5: { + unreachable; // bb5[0]: scope 0 at $DIR/match_false_edges.rs:15:19: 15:27 + } + + bb6: { + StorageLive(_6); // bb6[0]: scope 0 at $DIR/match_false_edges.rs:16:14: 16:15 + _11 = const full_tested_match::promoted[0]; // bb6[1]: scope 0 at $DIR/match_false_edges.rs:16:14: 16:15 + // ty::Const + // + ty: &std::option::Option<i32> + // + val: Unevaluated(DefId(0:5 ~ match_false_edges[317d]::full_tested_match[0]), [], Some(promoted[0])) + // mir::Constant + // + span: $DIR/match_false_edges.rs:16:14: 16:15 + // + literal: Const { ty: &std::option::Option<i32>, val: Unevaluated(DefId(0:5 ~ match_false_edges[317d]::full_tested_match[0]), [], Some(promoted[0])) } + _6 = &(((*_11) as Some).0: i32); // bb6[2]: scope 0 at $DIR/match_false_edges.rs:16:14: 16:15 + _4 = &shallow _2; // bb6[3]: scope 0 at $DIR/match_false_edges.rs:15:19: 15:27 + StorageLive(_7); // bb6[4]: scope 0 at $DIR/match_false_edges.rs:16:20: 16:27 + _7 = const guard() -> [return: bb7, unwind: bb1]; // bb6[5]: scope 0 at $DIR/match_false_edges.rs:16:20: 16:27 + // ty::Const + // + ty: fn() -> bool {guard} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/match_false_edges.rs:16:20: 16:25 + // + literal: Const { ty: fn() -> bool {guard}, val: Value(Scalar(<ZST>)) } + } + + bb7: { + switchInt(move _7) -> [false: bb9, otherwise: bb8]; // bb7[0]: scope 0 at $DIR/match_false_edges.rs:16:20: 16:27 + } + + bb8: { + StorageDead(_7); // bb8[0]: scope 0 at $DIR/match_false_edges.rs:16:37: 16:38 + FakeRead(ForMatchGuard, _4); // bb8[1]: scope 0 at $DIR/match_false_edges.rs:16:26: 16:27 + FakeRead(ForGuardBinding, _6); // bb8[2]: scope 0 at $DIR/match_false_edges.rs:16:26: 16:27 + StorageLive(_5); // bb8[3]: scope 0 at $DIR/match_false_edges.rs:16:14: 16:15 + _5 = ((_2 as Some).0: i32); // bb8[4]: scope 0 at $DIR/match_false_edges.rs:16:14: 16:15 + StorageLive(_8); // bb8[5]: scope 2 at $DIR/match_false_edges.rs:16:35: 16:36 + _8 = _5; // bb8[6]: scope 2 at $DIR/match_false_edges.rs:16:35: 16:36 + _1 = (const 1i32, move _8); // bb8[7]: scope 2 at $DIR/match_false_edges.rs:16:31: 16:37 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/match_false_edges.rs:16:32: 16:33 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } + StorageDead(_8); // bb8[8]: scope 2 at $DIR/match_false_edges.rs:16:36: 16:37 + StorageDead(_5); // bb8[9]: scope 0 at $DIR/match_false_edges.rs:16:37: 16:38 + StorageDead(_6); // bb8[10]: scope 0 at $DIR/match_false_edges.rs:16:37: 16:38 + goto -> bb11; // bb8[11]: scope 0 at $DIR/match_false_edges.rs:15:13: 19:6 + } + + bb9: { + StorageDead(_7); // bb9[0]: scope 0 at $DIR/match_false_edges.rs:16:37: 16:38 + StorageDead(_6); // bb9[1]: scope 0 at $DIR/match_false_edges.rs:16:37: 16:38 + goto -> bb4; // bb9[2]: scope 0 at $DIR/match_false_edges.rs:16:20: 16:27 + } + + bb10: { + StorageLive(_9); // bb10[0]: scope 0 at $DIR/match_false_edges.rs:17:14: 17:15 + _9 = ((_2 as Some).0: i32); // bb10[1]: scope 0 at $DIR/match_false_edges.rs:17:14: 17:15 + StorageLive(_10); // bb10[2]: scope 3 at $DIR/match_false_edges.rs:17:24: 17:25 + _10 = _9; // bb10[3]: scope 3 at $DIR/match_false_edges.rs:17:24: 17:25 + _1 = (const 2i32, move _10); // bb10[4]: scope 3 at $DIR/match_false_edges.rs:17:20: 17:26 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/match_false_edges.rs:17:21: 17:22 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } + StorageDead(_10); // bb10[5]: scope 3 at $DIR/match_false_edges.rs:17:25: 17:26 + StorageDead(_9); // bb10[6]: scope 0 at $DIR/match_false_edges.rs:17:26: 17:27 + goto -> bb11; // bb10[7]: scope 0 at $DIR/match_false_edges.rs:15:13: 19:6 + } + + bb11: { + StorageDead(_2); // bb11[0]: scope 0 at $DIR/match_false_edges.rs:19:6: 19:7 + StorageDead(_1); // bb11[1]: scope 0 at $DIR/match_false_edges.rs:19:6: 19:7 + _0 = (); // bb11[2]: scope 0 at $DIR/match_false_edges.rs:14:28: 20:2 + return; // bb11[3]: scope 0 at $DIR/match_false_edges.rs:20:2: 20:2 + } +} diff --git a/src/test/mir-opt/match_false_edges/rustc.full_tested_match2.PromoteTemps.before.mir b/src/test/mir-opt/match_false_edges/rustc.full_tested_match2.PromoteTemps.before.mir new file mode 100644 index 00000000000..cc1fa562645 --- /dev/null +++ b/src/test/mir-opt/match_false_edges/rustc.full_tested_match2.PromoteTemps.before.mir @@ -0,0 +1,141 @@ +// MIR for `full_tested_match2` before PromoteTemps + +fn full_tested_match2() -> () { + let mut _0: (); // return place in scope 0 at $DIR/match_false_edges.rs:25:29: 25:29 + let mut _1: (i32, i32); // in scope 0 at $DIR/match_false_edges.rs:26:13: 30:6 + let mut _2: std::option::Option<i32>; // in scope 0 at $DIR/match_false_edges.rs:26:19: 26:27 + let mut _3: isize; // in scope 0 at $DIR/match_false_edges.rs:27:9: 27:16 + let mut _4: &std::option::Option<i32>; // in scope 0 at $DIR/match_false_edges.rs:26:19: 26:27 + let _5: i32; // in scope 0 at $DIR/match_false_edges.rs:27:14: 27:15 + let _6: &i32; // in scope 0 at $DIR/match_false_edges.rs:27:14: 27:15 + let mut _7: bool; // in scope 0 at $DIR/match_false_edges.rs:27:20: 27:27 + let mut _8: i32; // in scope 0 at $DIR/match_false_edges.rs:27:35: 27:36 + let _9: i32; // in scope 0 at $DIR/match_false_edges.rs:29:14: 29:15 + let mut _10: i32; // in scope 0 at $DIR/match_false_edges.rs:29:24: 29:25 + scope 1 { + } + scope 2 { + debug x => _5; // in scope 2 at $DIR/match_false_edges.rs:27:14: 27:15 + debug x => _6; // in scope 2 at $DIR/match_false_edges.rs:27:14: 27:15 + } + scope 3 { + debug y => _9; // in scope 3 at $DIR/match_false_edges.rs:29:14: 29:15 + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/match_false_edges.rs:26:13: 30:6 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/match_false_edges.rs:26:19: 26:27 + _2 = std::option::Option::<i32>::Some(const 42i32,); // bb0[2]: scope 0 at $DIR/match_false_edges.rs:26:19: 26:27 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x0000002a)) + // mir::Constant + // + span: $DIR/match_false_edges.rs:26:24: 26:26 + // + literal: Const { ty: i32, val: Value(Scalar(0x0000002a)) } + FakeRead(ForMatchedPlace, _2); // bb0[3]: scope 0 at $DIR/match_false_edges.rs:26:19: 26:27 + _3 = discriminant(_2); // bb0[4]: scope 0 at $DIR/match_false_edges.rs:27:9: 27:16 + switchInt(move _3) -> [0isize: bb2, 1isize: bb3, otherwise: bb5]; // bb0[5]: scope 0 at $DIR/match_false_edges.rs:27:9: 27:16 + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/match_false_edges.rs:25:1: 31:2 + } + + bb2: { + falseEdges -> [real: bb10, imaginary: bb4]; // bb2[0]: scope 0 at $DIR/match_false_edges.rs:28:9: 28:13 + } + + bb3: { + falseEdges -> [real: bb6, imaginary: bb2]; // bb3[0]: scope 0 at $DIR/match_false_edges.rs:27:9: 27:16 + } + + bb4: { + StorageLive(_9); // bb4[0]: scope 0 at $DIR/match_false_edges.rs:29:14: 29:15 + _9 = ((_2 as Some).0: i32); // bb4[1]: scope 0 at $DIR/match_false_edges.rs:29:14: 29:15 + StorageLive(_10); // bb4[2]: scope 3 at $DIR/match_false_edges.rs:29:24: 29:25 + _10 = _9; // bb4[3]: scope 3 at $DIR/match_false_edges.rs:29:24: 29:25 + _1 = (const 2i32, move _10); // bb4[4]: scope 3 at $DIR/match_false_edges.rs:29:20: 29:26 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/match_false_edges.rs:29:21: 29:22 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } + StorageDead(_10); // bb4[5]: scope 3 at $DIR/match_false_edges.rs:29:25: 29:26 + StorageDead(_9); // bb4[6]: scope 0 at $DIR/match_false_edges.rs:29:26: 29:27 + goto -> bb11; // bb4[7]: scope 0 at $DIR/match_false_edges.rs:26:13: 30:6 + } + + bb5: { + unreachable; // bb5[0]: scope 0 at $DIR/match_false_edges.rs:26:19: 26:27 + } + + bb6: { + StorageLive(_6); // bb6[0]: scope 0 at $DIR/match_false_edges.rs:27:14: 27:15 + _6 = &((_2 as Some).0: i32); // bb6[1]: scope 0 at $DIR/match_false_edges.rs:27:14: 27:15 + _4 = &shallow _2; // bb6[2]: scope 0 at $DIR/match_false_edges.rs:26:19: 26:27 + StorageLive(_7); // bb6[3]: scope 0 at $DIR/match_false_edges.rs:27:20: 27:27 + _7 = const guard() -> [return: bb7, unwind: bb1]; // bb6[4]: scope 0 at $DIR/match_false_edges.rs:27:20: 27:27 + // ty::Const + // + ty: fn() -> bool {guard} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/match_false_edges.rs:27:20: 27:25 + // + literal: Const { ty: fn() -> bool {guard}, val: Value(Scalar(<ZST>)) } + } + + bb7: { + switchInt(move _7) -> [false: bb9, otherwise: bb8]; // bb7[0]: scope 0 at $DIR/match_false_edges.rs:27:20: 27:27 + } + + bb8: { + StorageDead(_7); // bb8[0]: scope 0 at $DIR/match_false_edges.rs:27:37: 27:38 + FakeRead(ForMatchGuard, _4); // bb8[1]: scope 0 at $DIR/match_false_edges.rs:27:26: 27:27 + FakeRead(ForGuardBinding, _6); // bb8[2]: scope 0 at $DIR/match_false_edges.rs:27:26: 27:27 + StorageLive(_5); // bb8[3]: scope 0 at $DIR/match_false_edges.rs:27:14: 27:15 + _5 = ((_2 as Some).0: i32); // bb8[4]: scope 0 at $DIR/match_false_edges.rs:27:14: 27:15 + StorageLive(_8); // bb8[5]: scope 2 at $DIR/match_false_edges.rs:27:35: 27:36 + _8 = _5; // bb8[6]: scope 2 at $DIR/match_false_edges.rs:27:35: 27:36 + _1 = (const 1i32, move _8); // bb8[7]: scope 2 at $DIR/match_false_edges.rs:27:31: 27:37 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/match_false_edges.rs:27:32: 27:33 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } + StorageDead(_8); // bb8[8]: scope 2 at $DIR/match_false_edges.rs:27:36: 27:37 + StorageDead(_5); // bb8[9]: scope 0 at $DIR/match_false_edges.rs:27:37: 27:38 + StorageDead(_6); // bb8[10]: scope 0 at $DIR/match_false_edges.rs:27:37: 27:38 + goto -> bb11; // bb8[11]: scope 0 at $DIR/match_false_edges.rs:26:13: 30:6 + } + + bb9: { + StorageDead(_7); // bb9[0]: scope 0 at $DIR/match_false_edges.rs:27:37: 27:38 + StorageDead(_6); // bb9[1]: scope 0 at $DIR/match_false_edges.rs:27:37: 27:38 + falseEdges -> [real: bb4, imaginary: bb2]; // bb9[2]: scope 0 at $DIR/match_false_edges.rs:27:20: 27:27 + } + + bb10: { + _1 = (const 3i32, const 3i32); // bb10[0]: scope 0 at $DIR/match_false_edges.rs:28:17: 28:23 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/match_false_edges.rs:28:18: 28:19 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/match_false_edges.rs:28:21: 28:22 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } + goto -> bb11; // bb10[1]: scope 0 at $DIR/match_false_edges.rs:26:13: 30:6 + } + + bb11: { + StorageDead(_2); // bb11[0]: scope 0 at $DIR/match_false_edges.rs:30:6: 30:7 + StorageDead(_1); // bb11[1]: scope 0 at $DIR/match_false_edges.rs:30:6: 30:7 + _0 = (); // bb11[2]: scope 0 at $DIR/match_false_edges.rs:25:29: 31:2 + return; // bb11[3]: scope 0 at $DIR/match_false_edges.rs:31:2: 31:2 + } +} diff --git a/src/test/mir-opt/match_false_edges/rustc.main.PromoteTemps.before.mir b/src/test/mir-opt/match_false_edges/rustc.main.PromoteTemps.before.mir new file mode 100644 index 00000000000..fce497df982 --- /dev/null +++ b/src/test/mir-opt/match_false_edges/rustc.main.PromoteTemps.before.mir @@ -0,0 +1,188 @@ +// MIR for `main` before PromoteTemps + +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/match_false_edges.rs:34:11: 34:11 + let mut _1: i32; // in scope 0 at $DIR/match_false_edges.rs:35:13: 40:6 + let mut _2: std::option::Option<i32>; // in scope 0 at $DIR/match_false_edges.rs:35:19: 35:26 + let mut _3: isize; // in scope 0 at $DIR/match_false_edges.rs:38:9: 38:16 + let mut _4: isize; // in scope 0 at $DIR/match_false_edges.rs:36:9: 36:17 + let mut _5: &std::option::Option<i32>; // in scope 0 at $DIR/match_false_edges.rs:35:19: 35:26 + let _6: i32; // in scope 0 at $DIR/match_false_edges.rs:36:14: 36:16 + let _7: &i32; // in scope 0 at $DIR/match_false_edges.rs:36:14: 36:16 + let mut _8: bool; // in scope 0 at $DIR/match_false_edges.rs:36:21: 36:28 + let _9: std::option::Option<i32>; // in scope 0 at $DIR/match_false_edges.rs:37:9: 37:11 + let _10: i32; // in scope 0 at $DIR/match_false_edges.rs:38:14: 38:15 + let _11: &i32; // in scope 0 at $DIR/match_false_edges.rs:38:14: 38:15 + let mut _12: bool; // in scope 0 at $DIR/match_false_edges.rs:38:20: 38:29 + let mut _13: i32; // in scope 0 at $DIR/match_false_edges.rs:38:27: 38:28 + let _14: std::option::Option<i32>; // in scope 0 at $DIR/match_false_edges.rs:39:9: 39:11 + scope 1 { + } + scope 2 { + debug _w => _6; // in scope 2 at $DIR/match_false_edges.rs:36:14: 36:16 + debug _w => _7; // in scope 2 at $DIR/match_false_edges.rs:36:14: 36:16 + } + scope 3 { + debug _x => _9; // in scope 3 at $DIR/match_false_edges.rs:37:9: 37:11 + } + scope 4 { + debug y => _10; // in scope 4 at $DIR/match_false_edges.rs:38:14: 38:15 + debug y => _11; // in scope 4 at $DIR/match_false_edges.rs:38:14: 38:15 + } + scope 5 { + debug _z => _14; // in scope 5 at $DIR/match_false_edges.rs:39:9: 39:11 + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/match_false_edges.rs:35:13: 40:6 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/match_false_edges.rs:35:19: 35:26 + _2 = std::option::Option::<i32>::Some(const 1i32,); // bb0[2]: scope 0 at $DIR/match_false_edges.rs:35:19: 35:26 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/match_false_edges.rs:35:24: 35:25 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } + FakeRead(ForMatchedPlace, _2); // bb0[3]: scope 0 at $DIR/match_false_edges.rs:35:19: 35:26 + _4 = discriminant(_2); // bb0[4]: scope 0 at $DIR/match_false_edges.rs:36:9: 36:17 + switchInt(move _4) -> [1isize: bb3, otherwise: bb2]; // bb0[5]: scope 0 at $DIR/match_false_edges.rs:36:9: 36:17 + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/match_false_edges.rs:34:1: 41:2 + } + + bb2: { + falseEdges -> [real: bb10, imaginary: bb5]; // bb2[0]: scope 0 at $DIR/match_false_edges.rs:37:9: 37:11 + } + + bb3: { + falseEdges -> [real: bb6, imaginary: bb2]; // bb3[0]: scope 0 at $DIR/match_false_edges.rs:36:9: 36:17 + } + + bb4: { + StorageLive(_14); // bb4[0]: scope 0 at $DIR/match_false_edges.rs:39:9: 39:11 + _14 = _2; // bb4[1]: scope 0 at $DIR/match_false_edges.rs:39:9: 39:11 + _1 = const 4i32; // bb4[2]: scope 5 at $DIR/match_false_edges.rs:39:15: 39:16 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000004)) + // mir::Constant + // + span: $DIR/match_false_edges.rs:39:15: 39:16 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) } + StorageDead(_14); // bb4[3]: scope 0 at $DIR/match_false_edges.rs:39:16: 39:17 + goto -> bb15; // bb4[4]: scope 0 at $DIR/match_false_edges.rs:35:13: 40:6 + } + + bb5: { + falseEdges -> [real: bb11, imaginary: bb4]; // bb5[0]: scope 0 at $DIR/match_false_edges.rs:38:9: 38:16 + } + + bb6: { + StorageLive(_7); // bb6[0]: scope 0 at $DIR/match_false_edges.rs:36:14: 36:16 + _7 = &((_2 as Some).0: i32); // bb6[1]: scope 0 at $DIR/match_false_edges.rs:36:14: 36:16 + _5 = &shallow _2; // bb6[2]: scope 0 at $DIR/match_false_edges.rs:35:19: 35:26 + StorageLive(_8); // bb6[3]: scope 0 at $DIR/match_false_edges.rs:36:21: 36:28 + _8 = const guard() -> [return: bb7, unwind: bb1]; // bb6[4]: scope 0 at $DIR/match_false_edges.rs:36:21: 36:28 + // ty::Const + // + ty: fn() -> bool {guard} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/match_false_edges.rs:36:21: 36:26 + // + literal: Const { ty: fn() -> bool {guard}, val: Value(Scalar(<ZST>)) } + } + + bb7: { + switchInt(move _8) -> [false: bb9, otherwise: bb8]; // bb7[0]: scope 0 at $DIR/match_false_edges.rs:36:21: 36:28 + } + + bb8: { + StorageDead(_8); // bb8[0]: scope 0 at $DIR/match_false_edges.rs:36:33: 36:34 + FakeRead(ForMatchGuard, _5); // bb8[1]: scope 0 at $DIR/match_false_edges.rs:36:27: 36:28 + FakeRead(ForGuardBinding, _7); // bb8[2]: scope 0 at $DIR/match_false_edges.rs:36:27: 36:28 + StorageLive(_6); // bb8[3]: scope 0 at $DIR/match_false_edges.rs:36:14: 36:16 + _6 = ((_2 as Some).0: i32); // bb8[4]: scope 0 at $DIR/match_false_edges.rs:36:14: 36:16 + _1 = const 1i32; // bb8[5]: scope 2 at $DIR/match_false_edges.rs:36:32: 36:33 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/match_false_edges.rs:36:32: 36:33 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } + StorageDead(_6); // bb8[6]: scope 0 at $DIR/match_false_edges.rs:36:33: 36:34 + StorageDead(_7); // bb8[7]: scope 0 at $DIR/match_false_edges.rs:36:33: 36:34 + goto -> bb15; // bb8[8]: scope 0 at $DIR/match_false_edges.rs:35:13: 40:6 + } + + bb9: { + StorageDead(_8); // bb9[0]: scope 0 at $DIR/match_false_edges.rs:36:33: 36:34 + StorageDead(_7); // bb9[1]: scope 0 at $DIR/match_false_edges.rs:36:33: 36:34 + falseEdges -> [real: bb2, imaginary: bb2]; // bb9[2]: scope 0 at $DIR/match_false_edges.rs:36:21: 36:28 + } + + bb10: { + StorageLive(_9); // bb10[0]: scope 0 at $DIR/match_false_edges.rs:37:9: 37:11 + _9 = _2; // bb10[1]: scope 0 at $DIR/match_false_edges.rs:37:9: 37:11 + _1 = const 2i32; // bb10[2]: scope 3 at $DIR/match_false_edges.rs:37:15: 37:16 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/match_false_edges.rs:37:15: 37:16 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } + StorageDead(_9); // bb10[3]: scope 0 at $DIR/match_false_edges.rs:37:16: 37:17 + goto -> bb15; // bb10[4]: scope 0 at $DIR/match_false_edges.rs:35:13: 40:6 + } + + bb11: { + StorageLive(_11); // bb11[0]: scope 0 at $DIR/match_false_edges.rs:38:14: 38:15 + _11 = &((_2 as Some).0: i32); // bb11[1]: scope 0 at $DIR/match_false_edges.rs:38:14: 38:15 + _5 = &shallow _2; // bb11[2]: scope 0 at $DIR/match_false_edges.rs:35:19: 35:26 + StorageLive(_12); // bb11[3]: scope 0 at $DIR/match_false_edges.rs:38:20: 38:29 + StorageLive(_13); // bb11[4]: scope 0 at $DIR/match_false_edges.rs:38:27: 38:28 + _13 = (*_11); // bb11[5]: scope 0 at $DIR/match_false_edges.rs:38:27: 38:28 + _12 = const guard2(move _13) -> [return: bb12, unwind: bb1]; // bb11[6]: scope 0 at $DIR/match_false_edges.rs:38:20: 38:29 + // ty::Const + // + ty: fn(i32) -> bool {guard2} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/match_false_edges.rs:38:20: 38:26 + // + literal: Const { ty: fn(i32) -> bool {guard2}, val: Value(Scalar(<ZST>)) } + } + + bb12: { + StorageDead(_13); // bb12[0]: scope 0 at $DIR/match_false_edges.rs:38:28: 38:29 + switchInt(move _12) -> [false: bb14, otherwise: bb13]; // bb12[1]: scope 0 at $DIR/match_false_edges.rs:38:20: 38:29 + } + + bb13: { + StorageDead(_12); // bb13[0]: scope 0 at $DIR/match_false_edges.rs:38:34: 38:35 + FakeRead(ForMatchGuard, _5); // bb13[1]: scope 0 at $DIR/match_false_edges.rs:38:28: 38:29 + FakeRead(ForGuardBinding, _11); // bb13[2]: scope 0 at $DIR/match_false_edges.rs:38:28: 38:29 + StorageLive(_10); // bb13[3]: scope 0 at $DIR/match_false_edges.rs:38:14: 38:15 + _10 = ((_2 as Some).0: i32); // bb13[4]: scope 0 at $DIR/match_false_edges.rs:38:14: 38:15 + _1 = const 3i32; // bb13[5]: scope 4 at $DIR/match_false_edges.rs:38:33: 38:34 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/match_false_edges.rs:38:33: 38:34 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } + StorageDead(_10); // bb13[6]: scope 0 at $DIR/match_false_edges.rs:38:34: 38:35 + StorageDead(_11); // bb13[7]: scope 0 at $DIR/match_false_edges.rs:38:34: 38:35 + goto -> bb15; // bb13[8]: scope 0 at $DIR/match_false_edges.rs:35:13: 40:6 + } + + bb14: { + StorageDead(_12); // bb14[0]: scope 0 at $DIR/match_false_edges.rs:38:34: 38:35 + StorageDead(_11); // bb14[1]: scope 0 at $DIR/match_false_edges.rs:38:34: 38:35 + falseEdges -> [real: bb4, imaginary: bb4]; // bb14[2]: scope 0 at $DIR/match_false_edges.rs:38:20: 38:29 + } + + bb15: { + StorageDead(_2); // bb15[0]: scope 0 at $DIR/match_false_edges.rs:40:6: 40:7 + StorageDead(_1); // bb15[1]: scope 0 at $DIR/match_false_edges.rs:40:6: 40:7 + _0 = (); // bb15[2]: scope 0 at $DIR/match_false_edges.rs:34:11: 41:2 + return; // bb15[3]: scope 0 at $DIR/match_false_edges.rs:41:2: 41:2 + } +} diff --git a/src/test/mir-opt/match_test.rs b/src/test/mir-opt/match_test.rs index 5ee3e1447d8..c3b07d42f5e 100644 --- a/src/test/mir-opt/match_test.rs +++ b/src/test/mir-opt/match_test.rs @@ -2,6 +2,7 @@ #![feature(exclusive_range_pattern)] +// EMIT_MIR rustc.main.SimplifyCfg-initial.after.mir fn main() { let x = 3; let b = true; @@ -15,70 +16,3 @@ fn main() { _ => 3, }; } - -// END RUST SOURCE -// START rustc.main.SimplifyCfg-initial.after.mir -// bb0: { -// ... -// switchInt(move _6) -> [false: bb4, otherwise: bb1]; -// } -// bb1: { -// _7 = Lt(_1, const 10i32); -// switchInt(move _7) -> [false: bb4, otherwise: bb2]; -// } -// bb2: { -// falseEdges -> [real: bb9, imaginary: bb6]; -// } -// bb3: { -// _3 = const 3i32; -// goto -> bb14; -// } -// bb4: { -// _4 = Le(const 10i32, _1); -// switchInt(move _4) -> [false: bb7, otherwise: bb5]; -// } -// bb5: { -// _5 = Le(_1, const 20i32); -// switchInt(move _5) -> [false: bb7, otherwise: bb6]; -// } -// bb6: { -// falseEdges -> [real: bb12, imaginary: bb8]; -// } -// bb7: { -// switchInt(_1) -> [-1i32: bb8, otherwise: bb3]; -// } -// bb8: { -// falseEdges -> [real: bb13, imaginary: bb3]; -// } -// bb9: { -// _8 = &shallow _1; -// StorageLive(_9); -// _9 = _2; -// switchInt(move _9) -> [false: bb11, otherwise: bb10]; -// } -// bb10: { -// StorageDead(_9); -// FakeRead(ForMatchGuard, _8); -// _3 = const 0i32; -// goto -> bb14; -// } -// bb11: { -// StorageDead(_9); -// falseEdges -> [real: bb3, imaginary: bb6]; -// } -// bb12: { -// _3 = const 1i32; -// goto -> bb14; -// } -// bb13: { -// _3 = const 2i32; -// goto -> bb14; -// } -// bb14: { -// StorageDead(_3); -// _0 = (); -// StorageDead(_2); -// StorageDead(_1); -// return; -// } -// END rustc.main.SimplifyCfg-initial.after.mir diff --git a/src/test/mir-opt/match_test/rustc.main.SimplifyCfg-initial.after.mir b/src/test/mir-opt/match_test/rustc.main.SimplifyCfg-initial.after.mir new file mode 100644 index 00000000000..ef5feb79bec --- /dev/null +++ b/src/test/mir-opt/match_test/rustc.main.SimplifyCfg-initial.after.mir @@ -0,0 +1,166 @@ +// MIR for `main` after SimplifyCfg-initial + +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/match_test.rs:6:11: 6:11 + let _1: i32; // in scope 0 at $DIR/match_test.rs:7:9: 7:10 + let _3: i32; // in scope 0 at $DIR/match_test.rs:12:5: 17:6 + let mut _4: bool; // in scope 0 at $DIR/match_test.rs:14:9: 14:16 + let mut _5: bool; // in scope 0 at $DIR/match_test.rs:14:9: 14:16 + let mut _6: bool; // in scope 0 at $DIR/match_test.rs:13:9: 13:14 + let mut _7: bool; // in scope 0 at $DIR/match_test.rs:13:9: 13:14 + let mut _8: &i32; // in scope 0 at $DIR/match_test.rs:12:11: 12:12 + let mut _9: bool; // in scope 0 at $DIR/match_test.rs:13:18: 13:19 + scope 1 { + debug x => _1; // in scope 1 at $DIR/match_test.rs:7:9: 7:10 + let _2: bool; // in scope 1 at $DIR/match_test.rs:8:9: 8:10 + scope 2 { + debug b => _2; // in scope 2 at $DIR/match_test.rs:8:9: 8:10 + } + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/match_test.rs:7:9: 7:10 + _1 = const 3i32; // bb0[1]: scope 0 at $DIR/match_test.rs:7:13: 7:14 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/match_test.rs:7:13: 7:14 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } + FakeRead(ForLet, _1); // bb0[2]: scope 0 at $DIR/match_test.rs:7:9: 7:10 + StorageLive(_2); // bb0[3]: scope 1 at $DIR/match_test.rs:8:9: 8:10 + _2 = const true; // bb0[4]: scope 1 at $DIR/match_test.rs:8:13: 8:17 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x01)) + // mir::Constant + // + span: $DIR/match_test.rs:8:13: 8:17 + // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + FakeRead(ForLet, _2); // bb0[5]: scope 1 at $DIR/match_test.rs:8:9: 8:10 + StorageLive(_3); // bb0[6]: scope 2 at $DIR/match_test.rs:12:5: 17:6 + FakeRead(ForMatchedPlace, _1); // bb0[7]: scope 2 at $DIR/match_test.rs:12:11: 12:12 + _6 = Le(const 0i32, _1); // bb0[8]: scope 2 at $DIR/match_test.rs:13:9: 13:14 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/match_test.rs:13:9: 13:14 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } + switchInt(move _6) -> [false: bb4, otherwise: bb1]; // bb0[9]: scope 2 at $DIR/match_test.rs:13:9: 13:14 + } + + bb1: { + _7 = Lt(_1, const 10i32); // bb1[0]: scope 2 at $DIR/match_test.rs:13:9: 13:14 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x0000000a)) + // mir::Constant + // + span: $DIR/match_test.rs:13:9: 13:14 + // + literal: Const { ty: i32, val: Value(Scalar(0x0000000a)) } + switchInt(move _7) -> [false: bb4, otherwise: bb2]; // bb1[1]: scope 2 at $DIR/match_test.rs:13:9: 13:14 + } + + bb2: { + falseEdges -> [real: bb9, imaginary: bb6]; // bb2[0]: scope 2 at $DIR/match_test.rs:13:9: 13:14 + } + + bb3: { + _3 = const 3i32; // bb3[0]: scope 2 at $DIR/match_test.rs:16:14: 16:15 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/match_test.rs:16:14: 16:15 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } + goto -> bb14; // bb3[1]: scope 2 at $DIR/match_test.rs:12:5: 17:6 + } + + bb4: { + _4 = Le(const 10i32, _1); // bb4[0]: scope 2 at $DIR/match_test.rs:14:9: 14:16 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x0000000a)) + // mir::Constant + // + span: $DIR/match_test.rs:14:9: 14:16 + // + literal: Const { ty: i32, val: Value(Scalar(0x0000000a)) } + switchInt(move _4) -> [false: bb7, otherwise: bb5]; // bb4[1]: scope 2 at $DIR/match_test.rs:14:9: 14:16 + } + + bb5: { + _5 = Le(_1, const 20i32); // bb5[0]: scope 2 at $DIR/match_test.rs:14:9: 14:16 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000014)) + // mir::Constant + // + span: $DIR/match_test.rs:14:9: 14:16 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000014)) } + switchInt(move _5) -> [false: bb7, otherwise: bb6]; // bb5[1]: scope 2 at $DIR/match_test.rs:14:9: 14:16 + } + + bb6: { + falseEdges -> [real: bb12, imaginary: bb8]; // bb6[0]: scope 2 at $DIR/match_test.rs:14:9: 14:16 + } + + bb7: { + switchInt(_1) -> [-1i32: bb8, otherwise: bb3]; // bb7[0]: scope 2 at $DIR/match_test.rs:15:9: 15:11 + } + + bb8: { + falseEdges -> [real: bb13, imaginary: bb3]; // bb8[0]: scope 2 at $DIR/match_test.rs:15:9: 15:11 + } + + bb9: { + _8 = &shallow _1; // bb9[0]: scope 2 at $DIR/match_test.rs:12:11: 12:12 + StorageLive(_9); // bb9[1]: scope 2 at $DIR/match_test.rs:13:18: 13:19 + _9 = _2; // bb9[2]: scope 2 at $DIR/match_test.rs:13:18: 13:19 + switchInt(move _9) -> [false: bb11, otherwise: bb10]; // bb9[3]: scope 2 at $DIR/match_test.rs:13:18: 13:19 + } + + bb10: { + StorageDead(_9); // bb10[0]: scope 2 at $DIR/match_test.rs:13:24: 13:25 + FakeRead(ForMatchGuard, _8); // bb10[1]: scope 2 at $DIR/match_test.rs:13:18: 13:19 + _3 = const 0i32; // bb10[2]: scope 2 at $DIR/match_test.rs:13:23: 13:24 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/match_test.rs:13:23: 13:24 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } + goto -> bb14; // bb10[3]: scope 2 at $DIR/match_test.rs:12:5: 17:6 + } + + bb11: { + StorageDead(_9); // bb11[0]: scope 2 at $DIR/match_test.rs:13:24: 13:25 + falseEdges -> [real: bb3, imaginary: bb6]; // bb11[1]: scope 2 at $DIR/match_test.rs:13:18: 13:19 + } + + bb12: { + _3 = const 1i32; // bb12[0]: scope 2 at $DIR/match_test.rs:14:20: 14:21 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/match_test.rs:14:20: 14:21 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } + goto -> bb14; // bb12[1]: scope 2 at $DIR/match_test.rs:12:5: 17:6 + } + + bb13: { + _3 = const 2i32; // bb13[0]: scope 2 at $DIR/match_test.rs:15:15: 15:16 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/match_test.rs:15:15: 15:16 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } + goto -> bb14; // bb13[1]: scope 2 at $DIR/match_test.rs:12:5: 17:6 + } + + bb14: { + StorageDead(_3); // bb14[0]: scope 2 at $DIR/match_test.rs:17:6: 17:7 + _0 = (); // bb14[1]: scope 0 at $DIR/match_test.rs:6:11: 18:2 + StorageDead(_2); // bb14[2]: scope 1 at $DIR/match_test.rs:18:1: 18:2 + StorageDead(_1); // bb14[3]: scope 0 at $DIR/match_test.rs:18:1: 18:2 + return; // bb14[4]: scope 0 at $DIR/match_test.rs:18:2: 18:2 + } +} diff --git a/src/test/mir-opt/nll/named-lifetimes-basic.rs b/src/test/mir-opt/nll/named-lifetimes-basic.rs index 2a6c2db03be..073ccf7e6c6 100644 --- a/src/test/mir-opt/nll/named-lifetimes-basic.rs +++ b/src/test/mir-opt/nll/named-lifetimes-basic.rs @@ -8,31 +8,8 @@ #![allow(warnings)] +// EMIT_MIR rustc.use_x.nll.0.mir fn use_x<'a, 'b: 'a, 'c>(w: &'a mut i32, x: &'b u32, y: &'a u32, z: &'c u32) -> bool { true } fn main() { } - -// END RUST SOURCE -// START rustc.use_x.nll.0.mir -// | Free Region Mapping -// | '_#0r | Global | ['_#2r, '_#1r, '_#0r, '_#4r, '_#3r] -// | '_#1r | External | ['_#1r, '_#4r] -// | '_#2r | External | ['_#2r, '_#1r, '_#4r] -// | '_#3r | Local | ['_#4r, '_#3r] -// | '_#4r | Local | ['_#4r] -// | -// | Inferred Region Values -// | '_#0r | U0 | {bb0[0..=1], '_#0r, '_#1r, '_#2r, '_#3r, '_#4r} -// | '_#1r | U0 | {bb0[0..=1], '_#1r} -// | '_#2r | U0 | {bb0[0..=1], '_#2r} -// | '_#3r | U0 | {bb0[0..=1], '_#3r} -// | '_#4r | U0 | {bb0[0..=1], '_#4r} -// | '_#5r | U0 | {bb0[0..=1], '_#1r} -// | '_#6r | U0 | {bb0[0..=1], '_#2r} -// | '_#7r | U0 | {bb0[0..=1], '_#1r} -// | '_#8r | U0 | {bb0[0..=1], '_#3r} -// | -// ... -// fn use_x(_1: &'_#5r mut i32, _2: &'_#6r u32, _3: &'_#7r u32, _4: &'_#8r u32) -> bool { -// END rustc.use_x.nll.0.mir diff --git a/src/test/mir-opt/nll/named-lifetimes-basic/rustc.use_x.nll.0.mir b/src/test/mir-opt/nll/named-lifetimes-basic/rustc.use_x.nll.0.mir new file mode 100644 index 00000000000..a486af608ef --- /dev/null +++ b/src/test/mir-opt/nll/named-lifetimes-basic/rustc.use_x.nll.0.mir @@ -0,0 +1,53 @@ +// MIR for `use_x` 0 nll + +| Free Region Mapping +| '_#0r | Global | ['_#2r, '_#1r, '_#0r, '_#4r, '_#3r] +| '_#1r | External | ['_#1r, '_#4r] +| '_#2r | External | ['_#2r, '_#1r, '_#4r] +| '_#3r | Local | ['_#4r, '_#3r] +| '_#4r | Local | ['_#4r] +| +| Inferred Region Values +| '_#0r | U0 | {bb0[0..=1], '_#0r, '_#1r, '_#2r, '_#3r, '_#4r} +| '_#1r | U0 | {bb0[0..=1], '_#1r} +| '_#2r | U0 | {bb0[0..=1], '_#2r} +| '_#3r | U0 | {bb0[0..=1], '_#3r} +| '_#4r | U0 | {bb0[0..=1], '_#4r} +| '_#5r | U0 | {bb0[0..=1], '_#1r} +| '_#6r | U0 | {bb0[0..=1], '_#2r} +| '_#7r | U0 | {bb0[0..=1], '_#1r} +| '_#8r | U0 | {bb0[0..=1], '_#3r} +| +| Inference Constraints +| '_#0r live at {bb0[0..=1]} +| '_#1r live at {bb0[0..=1]} +| '_#2r live at {bb0[0..=1]} +| '_#3r live at {bb0[0..=1]} +| '_#4r live at {bb0[0..=1]} +| '_#1r: '_#5r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:26: 12:27) +| '_#1r: '_#7r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:54: 12:55) +| '_#2r: '_#6r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:42: 12:43) +| '_#3r: '_#8r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:66: 12:67) +| '_#5r: '_#1r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:26: 12:27) +| '_#6r: '_#2r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:42: 12:43) +| '_#7r: '_#1r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:54: 12:55) +| '_#8r: '_#3r due to BoringNoLocation at All($DIR/named-lifetimes-basic.rs:12:66: 12:67) +| +fn use_x(_1: &'_#5r mut i32, _2: &'_#6r u32, _3: &'_#7r u32, _4: &'_#8r u32) -> bool { + debug w => _1; // in scope 0 at $DIR/named-lifetimes-basic.rs:12:26: 12:27 + debug x => _2; // in scope 0 at $DIR/named-lifetimes-basic.rs:12:42: 12:43 + debug y => _3; // in scope 0 at $DIR/named-lifetimes-basic.rs:12:54: 12:55 + debug z => _4; // in scope 0 at $DIR/named-lifetimes-basic.rs:12:66: 12:67 + let mut _0: bool; // return place in scope 0 at $DIR/named-lifetimes-basic.rs:12:81: 12:85 + + bb0: { + _0 = const Const(Value(Scalar(0x01)): bool); // bb0[0]: scope 0 at $DIR/named-lifetimes-basic.rs:12:88: 12:92 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x01)) + // mir::Constant + // + span: $DIR/named-lifetimes-basic.rs:12:88: 12:92 + // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + return; // bb0[1]: scope 0 at $DIR/named-lifetimes-basic.rs:12:94: 12:94 + } +} diff --git a/src/test/mir-opt/nll/region-subtyping-basic.rs b/src/test/mir-opt/nll/region-subtyping-basic.rs index 16e357fc162..740cb1c5e96 100644 --- a/src/test/mir-opt/nll/region-subtyping-basic.rs +++ b/src/test/mir-opt/nll/region-subtyping-basic.rs @@ -9,6 +9,8 @@ fn use_x(_: usize) -> bool { true } +// EMIT_MIR_FOR_EACH_BIT_WIDTH +// EMIT_MIR rustc.main.nll.0.mir fn main() { let mut v = [1, 2, 3]; let p = &v[0]; @@ -19,23 +21,3 @@ fn main() { use_x(22); } } - -// END RUST SOURCE -// START rustc.main.nll.0.mir -// | '_#2r | U0 | {bb2[0..=8], bb3[0], bb5[0..=2]} -// | '_#3r | U0 | {bb2[1..=8], bb3[0], bb5[0..=2]} -// | '_#4r | U0 | {bb2[4..=8], bb3[0], bb5[0..=2]} -// END rustc.main.nll.0.mir -// START rustc.main.nll.0.mir -// let _2: &'_#3r usize; -// ... -// debug p => _2; -// ... -// let _6: &'_#4r usize; -// ... -// debug q => _6; -// ... -// _2 = &'_#2r _1[_3]; -// ... -// _6 = _2; -// END rustc.main.nll.0.mir diff --git a/src/test/mir-opt/nll/region-subtyping-basic/32bit/rustc.main.nll.0.mir b/src/test/mir-opt/nll/region-subtyping-basic/32bit/rustc.main.nll.0.mir new file mode 100644 index 00000000000..f6ec2d92502 --- /dev/null +++ b/src/test/mir-opt/nll/region-subtyping-basic/32bit/rustc.main.nll.0.mir @@ -0,0 +1,158 @@ +// MIR for `main` 0 nll + +| Free Region Mapping +| '_#0r | Global | ['_#0r, '_#1r] +| '_#1r | Local | ['_#1r] +| +| Inferred Region Values +| '_#0r | U0 | {bb0[0..=8], bb1[0], bb2[0..=8], bb3[0], bb4[0..=1], bb5[0..=3], bb6[0..=3], bb7[0..=2], bb8[0..=5], '_#0r, '_#1r} +| '_#1r | U0 | {bb0[0..=8], bb1[0], bb2[0..=8], bb3[0], bb4[0..=1], bb5[0..=3], bb6[0..=3], bb7[0..=2], bb8[0..=5], '_#1r} +| '_#2r | U0 | {bb2[0..=8], bb3[0], bb5[0..=2]} +| '_#3r | U0 | {bb2[1..=8], bb3[0], bb5[0..=2]} +| '_#4r | U0 | {bb2[4..=8], bb3[0], bb5[0..=2]} +| +| Inference Constraints +| '_#0r live at {bb0[0..=8], bb1[0], bb2[0..=8], bb3[0], bb4[0..=1], bb5[0..=3], bb6[0..=3], bb7[0..=2], bb8[0..=5]} +| '_#1r live at {bb0[0..=8], bb1[0], bb2[0..=8], bb3[0], bb4[0..=1], bb5[0..=3], bb6[0..=3], bb7[0..=2], bb8[0..=5]} +| '_#2r live at {bb2[0]} +| '_#3r live at {bb2[1..=3]} +| '_#4r live at {bb2[4..=8], bb3[0], bb5[0..=2]} +| '_#2r: '_#3r due to Assignment at Single(bb2[0]) +| '_#3r: '_#4r due to Assignment at Single(bb2[3]) +| +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/region-subtyping-basic.rs:14:11: 14:11 + let mut _1: [usize; Const { ty: usize, val: Value(Scalar(0x00000003)) }]; // in scope 0 at $DIR/region-subtyping-basic.rs:15:9: 15:14 + let _3: usize; // in scope 0 at $DIR/region-subtyping-basic.rs:16:16: 16:17 + let mut _4: usize; // in scope 0 at $DIR/region-subtyping-basic.rs:16:14: 16:18 + let mut _5: bool; // in scope 0 at $DIR/region-subtyping-basic.rs:16:14: 16:18 + let mut _7: bool; // in scope 0 at $DIR/region-subtyping-basic.rs:18:8: 18:12 + let _8: bool; // in scope 0 at $DIR/region-subtyping-basic.rs:19:9: 19:18 + let mut _9: usize; // in scope 0 at $DIR/region-subtyping-basic.rs:19:15: 19:17 + let _10: bool; // in scope 0 at $DIR/region-subtyping-basic.rs:21:9: 21:18 + scope 1 { + debug v => _1; // in scope 1 at $DIR/region-subtyping-basic.rs:15:9: 15:14 + let _2: &'_#3r usize; // in scope 1 at $DIR/region-subtyping-basic.rs:16:9: 16:10 + scope 2 { + debug p => _2; // in scope 2 at $DIR/region-subtyping-basic.rs:16:9: 16:10 + let _6: &'_#4r usize; // in scope 2 at $DIR/region-subtyping-basic.rs:17:9: 17:10 + scope 3 { + debug q => _6; // in scope 3 at $DIR/region-subtyping-basic.rs:17:9: 17:10 + } + } + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/region-subtyping-basic.rs:15:9: 15:14 + _1 = [const Const(Value(Scalar(0x00000001)): usize), const Const(Value(Scalar(0x00000002)): usize), const Const(Value(Scalar(0x00000003)): usize)]; // bb0[1]: scope 0 at $DIR/region-subtyping-basic.rs:15:17: 15:26 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/region-subtyping-basic.rs:15:18: 15:19 + // + literal: Const { ty: usize, val: Value(Scalar(0x00000001)) } + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/region-subtyping-basic.rs:15:21: 15:22 + // + literal: Const { ty: usize, val: Value(Scalar(0x00000002)) } + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/region-subtyping-basic.rs:15:24: 15:25 + // + literal: Const { ty: usize, val: Value(Scalar(0x00000003)) } + FakeRead(ForLet, _1); // bb0[2]: scope 0 at $DIR/region-subtyping-basic.rs:15:9: 15:14 + StorageLive(_2); // bb0[3]: scope 1 at $DIR/region-subtyping-basic.rs:16:9: 16:10 + StorageLive(_3); // bb0[4]: scope 1 at $DIR/region-subtyping-basic.rs:16:16: 16:17 + _3 = const Const(Value(Scalar(0x00000000)): usize); // bb0[5]: scope 1 at $DIR/region-subtyping-basic.rs:16:16: 16:17 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/region-subtyping-basic.rs:16:16: 16:17 + // + literal: Const { ty: usize, val: Value(Scalar(0x00000000)) } + _4 = Len(_1); // bb0[6]: scope 1 at $DIR/region-subtyping-basic.rs:16:14: 16:18 + _5 = Lt(_3, _4); // bb0[7]: scope 1 at $DIR/region-subtyping-basic.rs:16:14: 16:18 + assert(move _5, "index out of bounds: the len is move _4 but the index is _3") -> [success: bb2, unwind: bb1]; // bb0[8]: scope 1 at $DIR/region-subtyping-basic.rs:16:14: 16:18 + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/region-subtyping-basic.rs:14:1: 23:2 + } + + bb2: { + _2 = &'_#2r _1[_3]; // bb2[0]: scope 1 at $DIR/region-subtyping-basic.rs:16:13: 16:18 + FakeRead(ForLet, _2); // bb2[1]: scope 1 at $DIR/region-subtyping-basic.rs:16:9: 16:10 + StorageLive(_6); // bb2[2]: scope 2 at $DIR/region-subtyping-basic.rs:17:9: 17:10 + _6 = _2; // bb2[3]: scope 2 at $DIR/region-subtyping-basic.rs:17:13: 17:14 + FakeRead(ForLet, _6); // bb2[4]: scope 2 at $DIR/region-subtyping-basic.rs:17:9: 17:10 + StorageLive(_7); // bb2[5]: scope 3 at $DIR/region-subtyping-basic.rs:18:8: 18:12 + _7 = const Const(Value(Scalar(0x01)): bool); // bb2[6]: scope 3 at $DIR/region-subtyping-basic.rs:18:8: 18:12 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x01)) + // mir::Constant + // + span: $DIR/region-subtyping-basic.rs:18:8: 18:12 + // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + FakeRead(ForMatchedPlace, _7); // bb2[7]: scope 3 at $DIR/region-subtyping-basic.rs:18:8: 18:12 + switchInt(_7) -> [Const(Value(Scalar(0x00)): bool): bb4, otherwise: bb3]; // bb2[8]: scope 3 at $DIR/region-subtyping-basic.rs:18:5: 22:6 + } + + bb3: { + falseEdges -> [real: bb5, imaginary: bb4]; // bb3[0]: scope 3 at $DIR/region-subtyping-basic.rs:18:5: 22:6 + } + + bb4: { + StorageLive(_10); // bb4[0]: scope 3 at $DIR/region-subtyping-basic.rs:21:9: 21:18 + _10 = const Const(Value(Scalar(<ZST>)): fn(usize) -> bool {use_x})(const Const(Value(Scalar(0x00000016)): usize)) -> [return: bb7, unwind: bb1]; // bb4[1]: scope 3 at $DIR/region-subtyping-basic.rs:21:9: 21:18 + // ty::Const + // + ty: fn(usize) -> bool {use_x} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/region-subtyping-basic.rs:21:9: 21:14 + // + literal: Const { ty: fn(usize) -> bool {use_x}, val: Value(Scalar(<ZST>)) } + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x00000016)) + // mir::Constant + // + span: $DIR/region-subtyping-basic.rs:21:15: 21:17 + // + literal: Const { ty: usize, val: Value(Scalar(0x00000016)) } + } + + bb5: { + StorageLive(_8); // bb5[0]: scope 3 at $DIR/region-subtyping-basic.rs:19:9: 19:18 + StorageLive(_9); // bb5[1]: scope 3 at $DIR/region-subtyping-basic.rs:19:15: 19:17 + _9 = (*_6); // bb5[2]: scope 3 at $DIR/region-subtyping-basic.rs:19:15: 19:17 + _8 = const Const(Value(Scalar(<ZST>)): fn(usize) -> bool {use_x})(move _9) -> [return: bb6, unwind: bb1]; // bb5[3]: scope 3 at $DIR/region-subtyping-basic.rs:19:9: 19:18 + // ty::Const + // + ty: fn(usize) -> bool {use_x} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/region-subtyping-basic.rs:19:9: 19:14 + // + literal: Const { ty: fn(usize) -> bool {use_x}, val: Value(Scalar(<ZST>)) } + } + + bb6: { + StorageDead(_9); // bb6[0]: scope 3 at $DIR/region-subtyping-basic.rs:19:17: 19:18 + StorageDead(_8); // bb6[1]: scope 3 at $DIR/region-subtyping-basic.rs:19:18: 19:19 + _0 = (); // bb6[2]: scope 3 at $DIR/region-subtyping-basic.rs:18:13: 20:6 + goto -> bb8; // bb6[3]: scope 3 at $DIR/region-subtyping-basic.rs:18:5: 22:6 + } + + bb7: { + StorageDead(_10); // bb7[0]: scope 3 at $DIR/region-subtyping-basic.rs:21:18: 21:19 + _0 = (); // bb7[1]: scope 3 at $DIR/region-subtyping-basic.rs:20:12: 22:6 + goto -> bb8; // bb7[2]: scope 3 at $DIR/region-subtyping-basic.rs:18:5: 22:6 + } + + bb8: { + StorageDead(_6); // bb8[0]: scope 2 at $DIR/region-subtyping-basic.rs:23:1: 23:2 + StorageDead(_3); // bb8[1]: scope 1 at $DIR/region-subtyping-basic.rs:23:1: 23:2 + StorageDead(_2); // bb8[2]: scope 1 at $DIR/region-subtyping-basic.rs:23:1: 23:2 + StorageDead(_1); // bb8[3]: scope 0 at $DIR/region-subtyping-basic.rs:23:1: 23:2 + StorageDead(_7); // bb8[4]: scope 0 at $DIR/region-subtyping-basic.rs:23:1: 23:2 + return; // bb8[5]: scope 0 at $DIR/region-subtyping-basic.rs:23:2: 23:2 + } +} diff --git a/src/test/mir-opt/nll/region-subtyping-basic/64bit/rustc.main.nll.0.mir b/src/test/mir-opt/nll/region-subtyping-basic/64bit/rustc.main.nll.0.mir new file mode 100644 index 00000000000..fa3a9a0e122 --- /dev/null +++ b/src/test/mir-opt/nll/region-subtyping-basic/64bit/rustc.main.nll.0.mir @@ -0,0 +1,158 @@ +// MIR for `main` 0 nll + +| Free Region Mapping +| '_#0r | Global | ['_#0r, '_#1r] +| '_#1r | Local | ['_#1r] +| +| Inferred Region Values +| '_#0r | U0 | {bb0[0..=8], bb1[0], bb2[0..=8], bb3[0], bb4[0..=1], bb5[0..=3], bb6[0..=3], bb7[0..=2], bb8[0..=5], '_#0r, '_#1r} +| '_#1r | U0 | {bb0[0..=8], bb1[0], bb2[0..=8], bb3[0], bb4[0..=1], bb5[0..=3], bb6[0..=3], bb7[0..=2], bb8[0..=5], '_#1r} +| '_#2r | U0 | {bb2[0..=8], bb3[0], bb5[0..=2]} +| '_#3r | U0 | {bb2[1..=8], bb3[0], bb5[0..=2]} +| '_#4r | U0 | {bb2[4..=8], bb3[0], bb5[0..=2]} +| +| Inference Constraints +| '_#0r live at {bb0[0..=8], bb1[0], bb2[0..=8], bb3[0], bb4[0..=1], bb5[0..=3], bb6[0..=3], bb7[0..=2], bb8[0..=5]} +| '_#1r live at {bb0[0..=8], bb1[0], bb2[0..=8], bb3[0], bb4[0..=1], bb5[0..=3], bb6[0..=3], bb7[0..=2], bb8[0..=5]} +| '_#2r live at {bb2[0]} +| '_#3r live at {bb2[1..=3]} +| '_#4r live at {bb2[4..=8], bb3[0], bb5[0..=2]} +| '_#2r: '_#3r due to Assignment at Single(bb2[0]) +| '_#3r: '_#4r due to Assignment at Single(bb2[3]) +| +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/region-subtyping-basic.rs:14:11: 14:11 + let mut _1: [usize; Const { ty: usize, val: Value(Scalar(0x0000000000000003)) }]; // in scope 0 at $DIR/region-subtyping-basic.rs:15:9: 15:14 + let _3: usize; // in scope 0 at $DIR/region-subtyping-basic.rs:16:16: 16:17 + let mut _4: usize; // in scope 0 at $DIR/region-subtyping-basic.rs:16:14: 16:18 + let mut _5: bool; // in scope 0 at $DIR/region-subtyping-basic.rs:16:14: 16:18 + let mut _7: bool; // in scope 0 at $DIR/region-subtyping-basic.rs:18:8: 18:12 + let _8: bool; // in scope 0 at $DIR/region-subtyping-basic.rs:19:9: 19:18 + let mut _9: usize; // in scope 0 at $DIR/region-subtyping-basic.rs:19:15: 19:17 + let _10: bool; // in scope 0 at $DIR/region-subtyping-basic.rs:21:9: 21:18 + scope 1 { + debug v => _1; // in scope 1 at $DIR/region-subtyping-basic.rs:15:9: 15:14 + let _2: &'_#3r usize; // in scope 1 at $DIR/region-subtyping-basic.rs:16:9: 16:10 + scope 2 { + debug p => _2; // in scope 2 at $DIR/region-subtyping-basic.rs:16:9: 16:10 + let _6: &'_#4r usize; // in scope 2 at $DIR/region-subtyping-basic.rs:17:9: 17:10 + scope 3 { + debug q => _6; // in scope 3 at $DIR/region-subtyping-basic.rs:17:9: 17:10 + } + } + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/region-subtyping-basic.rs:15:9: 15:14 + _1 = [const Const(Value(Scalar(0x0000000000000001)): usize), const Const(Value(Scalar(0x0000000000000002)): usize), const Const(Value(Scalar(0x0000000000000003)): usize)]; // bb0[1]: scope 0 at $DIR/region-subtyping-basic.rs:15:17: 15:26 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000001)) + // mir::Constant + // + span: $DIR/region-subtyping-basic.rs:15:18: 15:19 + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000001)) } + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000002)) + // mir::Constant + // + span: $DIR/region-subtyping-basic.rs:15:21: 15:22 + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000002)) } + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000003)) + // mir::Constant + // + span: $DIR/region-subtyping-basic.rs:15:24: 15:25 + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000003)) } + FakeRead(ForLet, _1); // bb0[2]: scope 0 at $DIR/region-subtyping-basic.rs:15:9: 15:14 + StorageLive(_2); // bb0[3]: scope 1 at $DIR/region-subtyping-basic.rs:16:9: 16:10 + StorageLive(_3); // bb0[4]: scope 1 at $DIR/region-subtyping-basic.rs:16:16: 16:17 + _3 = const Const(Value(Scalar(0x0000000000000000)): usize); // bb0[5]: scope 1 at $DIR/region-subtyping-basic.rs:16:16: 16:17 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000000)) + // mir::Constant + // + span: $DIR/region-subtyping-basic.rs:16:16: 16:17 + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000000)) } + _4 = Len(_1); // bb0[6]: scope 1 at $DIR/region-subtyping-basic.rs:16:14: 16:18 + _5 = Lt(_3, _4); // bb0[7]: scope 1 at $DIR/region-subtyping-basic.rs:16:14: 16:18 + assert(move _5, "index out of bounds: the len is move _4 but the index is _3") -> [success: bb2, unwind: bb1]; // bb0[8]: scope 1 at $DIR/region-subtyping-basic.rs:16:14: 16:18 + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/region-subtyping-basic.rs:14:1: 23:2 + } + + bb2: { + _2 = &'_#2r _1[_3]; // bb2[0]: scope 1 at $DIR/region-subtyping-basic.rs:16:13: 16:18 + FakeRead(ForLet, _2); // bb2[1]: scope 1 at $DIR/region-subtyping-basic.rs:16:9: 16:10 + StorageLive(_6); // bb2[2]: scope 2 at $DIR/region-subtyping-basic.rs:17:9: 17:10 + _6 = _2; // bb2[3]: scope 2 at $DIR/region-subtyping-basic.rs:17:13: 17:14 + FakeRead(ForLet, _6); // bb2[4]: scope 2 at $DIR/region-subtyping-basic.rs:17:9: 17:10 + StorageLive(_7); // bb2[5]: scope 3 at $DIR/region-subtyping-basic.rs:18:8: 18:12 + _7 = const Const(Value(Scalar(0x01)): bool); // bb2[6]: scope 3 at $DIR/region-subtyping-basic.rs:18:8: 18:12 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x01)) + // mir::Constant + // + span: $DIR/region-subtyping-basic.rs:18:8: 18:12 + // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + FakeRead(ForMatchedPlace, _7); // bb2[7]: scope 3 at $DIR/region-subtyping-basic.rs:18:8: 18:12 + switchInt(_7) -> [Const(Value(Scalar(0x00)): bool): bb4, otherwise: bb3]; // bb2[8]: scope 3 at $DIR/region-subtyping-basic.rs:18:5: 22:6 + } + + bb3: { + falseEdges -> [real: bb5, imaginary: bb4]; // bb3[0]: scope 3 at $DIR/region-subtyping-basic.rs:18:5: 22:6 + } + + bb4: { + StorageLive(_10); // bb4[0]: scope 3 at $DIR/region-subtyping-basic.rs:21:9: 21:18 + _10 = const Const(Value(Scalar(<ZST>)): fn(usize) -> bool {use_x})(const Const(Value(Scalar(0x0000000000000016)): usize)) -> [return: bb7, unwind: bb1]; // bb4[1]: scope 3 at $DIR/region-subtyping-basic.rs:21:9: 21:18 + // ty::Const + // + ty: fn(usize) -> bool {use_x} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/region-subtyping-basic.rs:21:9: 21:14 + // + literal: Const { ty: fn(usize) -> bool {use_x}, val: Value(Scalar(<ZST>)) } + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000016)) + // mir::Constant + // + span: $DIR/region-subtyping-basic.rs:21:15: 21:17 + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000016)) } + } + + bb5: { + StorageLive(_8); // bb5[0]: scope 3 at $DIR/region-subtyping-basic.rs:19:9: 19:18 + StorageLive(_9); // bb5[1]: scope 3 at $DIR/region-subtyping-basic.rs:19:15: 19:17 + _9 = (*_6); // bb5[2]: scope 3 at $DIR/region-subtyping-basic.rs:19:15: 19:17 + _8 = const Const(Value(Scalar(<ZST>)): fn(usize) -> bool {use_x})(move _9) -> [return: bb6, unwind: bb1]; // bb5[3]: scope 3 at $DIR/region-subtyping-basic.rs:19:9: 19:18 + // ty::Const + // + ty: fn(usize) -> bool {use_x} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/region-subtyping-basic.rs:19:9: 19:14 + // + literal: Const { ty: fn(usize) -> bool {use_x}, val: Value(Scalar(<ZST>)) } + } + + bb6: { + StorageDead(_9); // bb6[0]: scope 3 at $DIR/region-subtyping-basic.rs:19:17: 19:18 + StorageDead(_8); // bb6[1]: scope 3 at $DIR/region-subtyping-basic.rs:19:18: 19:19 + _0 = (); // bb6[2]: scope 3 at $DIR/region-subtyping-basic.rs:18:13: 20:6 + goto -> bb8; // bb6[3]: scope 3 at $DIR/region-subtyping-basic.rs:18:5: 22:6 + } + + bb7: { + StorageDead(_10); // bb7[0]: scope 3 at $DIR/region-subtyping-basic.rs:21:18: 21:19 + _0 = (); // bb7[1]: scope 3 at $DIR/region-subtyping-basic.rs:20:12: 22:6 + goto -> bb8; // bb7[2]: scope 3 at $DIR/region-subtyping-basic.rs:18:5: 22:6 + } + + bb8: { + StorageDead(_6); // bb8[0]: scope 2 at $DIR/region-subtyping-basic.rs:23:1: 23:2 + StorageDead(_3); // bb8[1]: scope 1 at $DIR/region-subtyping-basic.rs:23:1: 23:2 + StorageDead(_2); // bb8[2]: scope 1 at $DIR/region-subtyping-basic.rs:23:1: 23:2 + StorageDead(_1); // bb8[3]: scope 0 at $DIR/region-subtyping-basic.rs:23:1: 23:2 + StorageDead(_7); // bb8[4]: scope 0 at $DIR/region-subtyping-basic.rs:23:1: 23:2 + return; // bb8[5]: scope 0 at $DIR/region-subtyping-basic.rs:23:2: 23:2 + } +} diff --git a/src/test/mir-opt/no-drop-for-inactive-variant.rs b/src/test/mir-opt/no-drop-for-inactive-variant.rs index 74a606af28f..cf6426b878a 100644 --- a/src/test/mir-opt/no-drop-for-inactive-variant.rs +++ b/src/test/mir-opt/no-drop-for-inactive-variant.rs @@ -3,6 +3,7 @@ // Ensure that there are no drop terminators in `unwrap<T>` (except the one along the cleanup // path). +// EMIT_MIR rustc.unwrap.SimplifyCfg-elaborate-drops.after.mir fn unwrap<T>(opt: Option<T>) -> T { match opt { Some(x) => x, @@ -13,31 +14,3 @@ fn unwrap<T>(opt: Option<T>) -> T { fn main() { let _ = unwrap(Some(1i32)); } - -// END RUST SOURCE -// START rustc.unwrap.SimplifyCfg-elaborate-drops.after.mir -// fn unwrap(_1: std::option::Option<T>) -> T { -// ... -// bb0: { -// ... -// switchInt(move _2) -> [0isize: bb2, 1isize: bb4, otherwise: bb3]; -// } -// bb1 (cleanup): { -// resume; -// } -// bb2: { -// ... -// const std::rt::begin_panic::<&str>(const "explicit panic") -> bb5; -// } -// bb3: { -// unreachable; -// } -// bb4: { -// ... -// return; -// } -// bb5 (cleanup): { -// drop(_1) -> bb1; -// } -// } -// END rustc.unwrap.SimplifyCfg-elaborate-drops.after.mir diff --git a/src/test/mir-opt/no-drop-for-inactive-variant/rustc.unwrap.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/no-drop-for-inactive-variant/rustc.unwrap.SimplifyCfg-elaborate-drops.after.mir new file mode 100644 index 00000000000..38302411336 --- /dev/null +++ b/src/test/mir-opt/no-drop-for-inactive-variant/rustc.unwrap.SimplifyCfg-elaborate-drops.after.mir @@ -0,0 +1,57 @@ +// MIR for `unwrap` after SimplifyCfg-elaborate-drops + +fn unwrap(_1: std::option::Option<T>) -> T { + debug opt => _1; // in scope 0 at $DIR/no-drop-for-inactive-variant.rs:7:14: 7:17 + let mut _0: T; // return place in scope 0 at $DIR/no-drop-for-inactive-variant.rs:7:33: 7:34 + let mut _2: isize; // in scope 0 at $DIR/no-drop-for-inactive-variant.rs:9:9: 9:16 + let _3: T; // in scope 0 at $DIR/no-drop-for-inactive-variant.rs:9:14: 9:15 + let mut _4: !; // in scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + let mut _5: isize; // in scope 0 at $DIR/no-drop-for-inactive-variant.rs:12:1: 12:2 + let mut _6: isize; // in scope 0 at $DIR/no-drop-for-inactive-variant.rs:12:1: 12:2 + scope 1 { + debug x => _3; // in scope 1 at $DIR/no-drop-for-inactive-variant.rs:9:14: 9:15 + } + + bb0: { + _2 = discriminant(_1); // bb0[0]: scope 0 at $DIR/no-drop-for-inactive-variant.rs:9:9: 9:16 + switchInt(move _2) -> [0isize: bb2, 1isize: bb4, otherwise: bb3]; // bb0[1]: scope 0 at $DIR/no-drop-for-inactive-variant.rs:9:9: 9:16 + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/no-drop-for-inactive-variant.rs:7:1: 12:2 + } + + bb2: { + StorageLive(_4); // bb2[0]: scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + const std::rt::begin_panic::<&str>(const "explicit panic") -> bb5; // bb2[1]: scope 0 at $SRC_DIR/libstd/macros.rs:LL:COL + // ty::Const + // + ty: fn(&str) -> ! {std::rt::begin_panic::<&str>} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $SRC_DIR/libstd/macros.rs:LL:COL + // + literal: Const { ty: fn(&str) -> ! {std::rt::begin_panic::<&str>}, val: Value(Scalar(<ZST>)) } + // ty::Const + // + ty: &str + // + val: Value(Slice { data: Allocation { bytes: [101, 120, 112, 108, 105, 99, 105, 116, 32, 112, 97, 110, 105, 99], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [16383], len: Size { raw: 14 } }, size: Size { raw: 14 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 14 }) + // mir::Constant + // + span: $SRC_DIR/libstd/macros.rs:LL:COL + // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [101, 120, 112, 108, 105, 99, 105, 116, 32, 112, 97, 110, 105, 99], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [16383], len: Size { raw: 14 } }, size: Size { raw: 14 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 14 }) } + } + + bb3: { + unreachable; // bb3[0]: scope 0 at $DIR/no-drop-for-inactive-variant.rs:8:11: 8:14 + } + + bb4: { + StorageLive(_3); // bb4[0]: scope 0 at $DIR/no-drop-for-inactive-variant.rs:9:14: 9:15 + _3 = move ((_1 as Some).0: T); // bb4[1]: scope 0 at $DIR/no-drop-for-inactive-variant.rs:9:14: 9:15 + _0 = move _3; // bb4[2]: scope 1 at $DIR/no-drop-for-inactive-variant.rs:9:20: 9:21 + StorageDead(_3); // bb4[3]: scope 0 at $DIR/no-drop-for-inactive-variant.rs:9:21: 9:22 + _5 = discriminant(_1); // bb4[4]: scope 0 at $DIR/no-drop-for-inactive-variant.rs:12:1: 12:2 + return; // bb4[5]: scope 0 at $DIR/no-drop-for-inactive-variant.rs:12:2: 12:2 + } + + bb5 (cleanup): { + drop(_1) -> bb1; // bb5[0]: scope 0 at $DIR/no-drop-for-inactive-variant.rs:12:1: 12:2 + } +} diff --git a/src/test/mir-opt/no-spurious-drop-after-call.rs b/src/test/mir-opt/no-spurious-drop-after-call.rs index 782bc31186c..ab58654e07c 100644 --- a/src/test/mir-opt/no-spurious-drop-after-call.rs +++ b/src/test/mir-opt/no-spurious-drop-after-call.rs @@ -4,21 +4,7 @@ // MIR drop of the argument. (We used to have a `DROP(_2)` in the code // below, as part of bb3.) +// EMIT_MIR rustc.main.ElaborateDrops.before.mir fn main() { std::mem::drop("".to_string()); } - -// END RUST SOURCE -// START rustc.main.ElaborateDrops.before.mir -// bb2: { -// StorageDead(_3); -// _1 = const std::mem::drop::<std::string::String>(move _2) -> [return: bb3, unwind: bb4]; -// } -// bb3: { -// StorageDead(_2); -// StorageDead(_4); -// StorageDead(_1); -// _0 = (); -// return; -// } -// END rustc.main.ElaborateDrops.before.mir diff --git a/src/test/mir-opt/no-spurious-drop-after-call/rustc.main.ElaborateDrops.before.mir b/src/test/mir-opt/no-spurious-drop-after-call/rustc.main.ElaborateDrops.before.mir new file mode 100644 index 00000000000..b65bc760330 --- /dev/null +++ b/src/test/mir-opt/no-spurious-drop-after-call/rustc.main.ElaborateDrops.before.mir @@ -0,0 +1,58 @@ +// MIR for `main` before ElaborateDrops + +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/no-spurious-drop-after-call.rs:8:11: 8:11 + let _1: (); // in scope 0 at $DIR/no-spurious-drop-after-call.rs:9:5: 9:35 + let mut _2: std::string::String; // in scope 0 at $DIR/no-spurious-drop-after-call.rs:9:20: 9:34 + let mut _3: &str; // in scope 0 at $DIR/no-spurious-drop-after-call.rs:9:20: 9:22 + let _4: &str; // in scope 0 at $DIR/no-spurious-drop-after-call.rs:9:20: 9:22 + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/no-spurious-drop-after-call.rs:9:5: 9:35 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/no-spurious-drop-after-call.rs:9:20: 9:34 + StorageLive(_3); // bb0[2]: scope 0 at $DIR/no-spurious-drop-after-call.rs:9:20: 9:22 + StorageLive(_4); // bb0[3]: scope 0 at $DIR/no-spurious-drop-after-call.rs:9:20: 9:22 + _4 = const ""; // bb0[4]: scope 0 at $DIR/no-spurious-drop-after-call.rs:9:20: 9:22 + // ty::Const + // + ty: &str + // + val: Value(Slice { data: Allocation { bytes: [], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [], len: Size { raw: 0 } }, size: Size { raw: 0 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 0 }) + // mir::Constant + // + span: $DIR/no-spurious-drop-after-call.rs:9:20: 9:22 + // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [], len: Size { raw: 0 } }, size: Size { raw: 0 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 0 }) } + _3 = &(*_4); // bb0[5]: scope 0 at $DIR/no-spurious-drop-after-call.rs:9:20: 9:22 + _2 = const <str as std::string::ToString>::to_string(move _3) -> bb2; // bb0[6]: scope 0 at $DIR/no-spurious-drop-after-call.rs:9:20: 9:34 + // ty::Const + // + ty: for<'r> fn(&'r str) -> std::string::String {<str as std::string::ToString>::to_string} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/no-spurious-drop-after-call.rs:9:23: 9:32 + // + literal: Const { ty: for<'r> fn(&'r str) -> std::string::String {<str as std::string::ToString>::to_string}, val: Value(Scalar(<ZST>)) } + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/no-spurious-drop-after-call.rs:8:1: 10:2 + } + + bb2: { + StorageDead(_3); // bb2[0]: scope 0 at $DIR/no-spurious-drop-after-call.rs:9:33: 9:34 + _1 = const std::mem::drop::<std::string::String>(move _2) -> [return: bb3, unwind: bb4]; // bb2[1]: scope 0 at $DIR/no-spurious-drop-after-call.rs:9:5: 9:35 + // ty::Const + // + ty: fn(std::string::String) {std::mem::drop::<std::string::String>} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/no-spurious-drop-after-call.rs:9:5: 9:19 + // + literal: Const { ty: fn(std::string::String) {std::mem::drop::<std::string::String>}, val: Value(Scalar(<ZST>)) } + } + + bb3: { + StorageDead(_2); // bb3[0]: scope 0 at $DIR/no-spurious-drop-after-call.rs:9:34: 9:35 + StorageDead(_4); // bb3[1]: scope 0 at $DIR/no-spurious-drop-after-call.rs:9:35: 9:36 + StorageDead(_1); // bb3[2]: scope 0 at $DIR/no-spurious-drop-after-call.rs:9:35: 9:36 + _0 = (); // bb3[3]: scope 0 at $DIR/no-spurious-drop-after-call.rs:8:11: 10:2 + return; // bb3[4]: scope 0 at $DIR/no-spurious-drop-after-call.rs:10:2: 10:2 + } + + bb4 (cleanup): { + drop(_2) -> bb1; // bb4[0]: scope 0 at $DIR/no-spurious-drop-after-call.rs:9:34: 9:35 + } +} diff --git a/src/test/mir-opt/packed-struct-drop-aligned.rs b/src/test/mir-opt/packed-struct-drop-aligned.rs index 39b90060179..daf397c3d9c 100644 --- a/src/test/mir-opt/packed-struct-drop-aligned.rs +++ b/src/test/mir-opt/packed-struct-drop-aligned.rs @@ -1,5 +1,7 @@ // ignore-wasm32-bare compiled with panic=abort by default +// EMIT_MIR_FOR_EACH_BIT_WIDTH +// EMIT_MIR rustc.main.SimplifyCfg-elaborate-drops.after.mir fn main() { let mut x = Packed(Aligned(Droppy(0))); x.0 = Aligned(Droppy(0)); @@ -13,47 +15,3 @@ struct Droppy(usize); impl Drop for Droppy { fn drop(&mut self) {} } - -// END RUST SOURCE -// START rustc.main.SimplifyCfg-elaborate-drops.after.mir -// fn main() -> () { -// let mut _0: (); -// let mut _1: Packed; -// let mut _2: Aligned; -// let mut _3: Droppy; -// let mut _4: Aligned; -// let mut _5: Droppy; -// let mut _6: Aligned; -// scope 1 { -// debug x => _1; -// } -// -// bb0: { -// StorageLive(_1); -// ... -// _1 = Packed(move _2,); -// ... -// StorageLive(_6); -// _6 = move (_1.0: Aligned); -// drop(_6) -> [return: bb4, unwind: bb3]; -// } -// bb1 (cleanup): { -// resume; -// } -// bb2: { -// StorageDead(_1); -// return; -// } -// bb3 (cleanup): { -// (_1.0: Aligned) = move _4; -// drop(_1) -> bb1; -// } -// bb4: { -// StorageDead(_6); -// (_1.0: Aligned) = move _4; -// StorageDead(_4); -// _0 = (); -// drop(_1) -> [return: bb2, unwind: bb1]; -// } -// } -// END rustc.main.SimplifyCfg-elaborate-drops.after.mir diff --git a/src/test/mir-opt/packed-struct-drop-aligned/32bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/packed-struct-drop-aligned/32bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir new file mode 100644 index 00000000000..03265c613bc --- /dev/null +++ b/src/test/mir-opt/packed-struct-drop-aligned/32bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir @@ -0,0 +1,67 @@ +// MIR for `main` after SimplifyCfg-elaborate-drops + +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/packed-struct-drop-aligned.rs:5:11: 5:11 + let mut _1: Packed; // in scope 0 at $DIR/packed-struct-drop-aligned.rs:6:9: 6:14 + let mut _2: Aligned; // in scope 0 at $DIR/packed-struct-drop-aligned.rs:6:24: 6:42 + let mut _3: Droppy; // in scope 0 at $DIR/packed-struct-drop-aligned.rs:6:32: 6:41 + let mut _4: Aligned; // in scope 0 at $DIR/packed-struct-drop-aligned.rs:7:11: 7:29 + let mut _5: Droppy; // in scope 0 at $DIR/packed-struct-drop-aligned.rs:7:19: 7:28 + let mut _6: Aligned; // in scope 0 at $DIR/packed-struct-drop-aligned.rs:7:5: 7:8 + scope 1 { + debug x => _1; // in scope 1 at $DIR/packed-struct-drop-aligned.rs:6:9: 6:14 + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:9: 6:14 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:24: 6:42 + StorageLive(_3); // bb0[2]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:32: 6:41 + _3 = Droppy(const 0usize,); // bb0[3]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:32: 6:41 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/packed-struct-drop-aligned.rs:6:39: 6:40 + // + literal: Const { ty: usize, val: Value(Scalar(0x00000000)) } + _2 = Aligned(move _3,); // bb0[4]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:24: 6:42 + StorageDead(_3); // bb0[5]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:41: 6:42 + _1 = Packed(move _2,); // bb0[6]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:17: 6:43 + StorageDead(_2); // bb0[7]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:42: 6:43 + StorageLive(_4); // bb0[8]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:11: 7:29 + StorageLive(_5); // bb0[9]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:19: 7:28 + _5 = Droppy(const 0usize,); // bb0[10]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:19: 7:28 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/packed-struct-drop-aligned.rs:7:26: 7:27 + // + literal: Const { ty: usize, val: Value(Scalar(0x00000000)) } + _4 = Aligned(move _5,); // bb0[11]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:11: 7:29 + StorageDead(_5); // bb0[12]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:28: 7:29 + StorageLive(_6); // bb0[13]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:5: 7:8 + _6 = move (_1.0: Aligned); // bb0[14]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:5: 7:8 + drop(_6) -> [return: bb4, unwind: bb3]; // bb0[15]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:5: 7:8 + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/packed-struct-drop-aligned.rs:5:1: 8:2 + } + + bb2: { + StorageDead(_1); // bb2[0]: scope 0 at $DIR/packed-struct-drop-aligned.rs:8:1: 8:2 + return; // bb2[1]: scope 0 at $DIR/packed-struct-drop-aligned.rs:8:2: 8:2 + } + + bb3 (cleanup): { + (_1.0: Aligned) = move _4; // bb3[0]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:5: 7:8 + drop(_1) -> bb1; // bb3[1]: scope 0 at $DIR/packed-struct-drop-aligned.rs:8:1: 8:2 + } + + bb4: { + StorageDead(_6); // bb4[0]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:5: 7:8 + (_1.0: Aligned) = move _4; // bb4[1]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:5: 7:8 + StorageDead(_4); // bb4[2]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:28: 7:29 + _0 = (); // bb4[3]: scope 0 at $DIR/packed-struct-drop-aligned.rs:5:11: 8:2 + drop(_1) -> [return: bb2, unwind: bb1]; // bb4[4]: scope 0 at $DIR/packed-struct-drop-aligned.rs:8:1: 8:2 + } +} diff --git a/src/test/mir-opt/packed-struct-drop-aligned/64bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/packed-struct-drop-aligned/64bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir new file mode 100644 index 00000000000..a1424d0bf59 --- /dev/null +++ b/src/test/mir-opt/packed-struct-drop-aligned/64bit/rustc.main.SimplifyCfg-elaborate-drops.after.mir @@ -0,0 +1,67 @@ +// MIR for `main` after SimplifyCfg-elaborate-drops + +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/packed-struct-drop-aligned.rs:5:11: 5:11 + let mut _1: Packed; // in scope 0 at $DIR/packed-struct-drop-aligned.rs:6:9: 6:14 + let mut _2: Aligned; // in scope 0 at $DIR/packed-struct-drop-aligned.rs:6:24: 6:42 + let mut _3: Droppy; // in scope 0 at $DIR/packed-struct-drop-aligned.rs:6:32: 6:41 + let mut _4: Aligned; // in scope 0 at $DIR/packed-struct-drop-aligned.rs:7:11: 7:29 + let mut _5: Droppy; // in scope 0 at $DIR/packed-struct-drop-aligned.rs:7:19: 7:28 + let mut _6: Aligned; // in scope 0 at $DIR/packed-struct-drop-aligned.rs:7:5: 7:8 + scope 1 { + debug x => _1; // in scope 1 at $DIR/packed-struct-drop-aligned.rs:6:9: 6:14 + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:9: 6:14 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:24: 6:42 + StorageLive(_3); // bb0[2]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:32: 6:41 + _3 = Droppy(const 0usize,); // bb0[3]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:32: 6:41 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000000)) + // mir::Constant + // + span: $DIR/packed-struct-drop-aligned.rs:6:39: 6:40 + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000000)) } + _2 = Aligned(move _3,); // bb0[4]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:24: 6:42 + StorageDead(_3); // bb0[5]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:41: 6:42 + _1 = Packed(move _2,); // bb0[6]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:17: 6:43 + StorageDead(_2); // bb0[7]: scope 0 at $DIR/packed-struct-drop-aligned.rs:6:42: 6:43 + StorageLive(_4); // bb0[8]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:11: 7:29 + StorageLive(_5); // bb0[9]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:19: 7:28 + _5 = Droppy(const 0usize,); // bb0[10]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:19: 7:28 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000000)) + // mir::Constant + // + span: $DIR/packed-struct-drop-aligned.rs:7:26: 7:27 + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000000)) } + _4 = Aligned(move _5,); // bb0[11]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:11: 7:29 + StorageDead(_5); // bb0[12]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:28: 7:29 + StorageLive(_6); // bb0[13]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:5: 7:8 + _6 = move (_1.0: Aligned); // bb0[14]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:5: 7:8 + drop(_6) -> [return: bb4, unwind: bb3]; // bb0[15]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:5: 7:8 + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/packed-struct-drop-aligned.rs:5:1: 8:2 + } + + bb2: { + StorageDead(_1); // bb2[0]: scope 0 at $DIR/packed-struct-drop-aligned.rs:8:1: 8:2 + return; // bb2[1]: scope 0 at $DIR/packed-struct-drop-aligned.rs:8:2: 8:2 + } + + bb3 (cleanup): { + (_1.0: Aligned) = move _4; // bb3[0]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:5: 7:8 + drop(_1) -> bb1; // bb3[1]: scope 0 at $DIR/packed-struct-drop-aligned.rs:8:1: 8:2 + } + + bb4: { + StorageDead(_6); // bb4[0]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:5: 7:8 + (_1.0: Aligned) = move _4; // bb4[1]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:5: 7:8 + StorageDead(_4); // bb4[2]: scope 1 at $DIR/packed-struct-drop-aligned.rs:7:28: 7:29 + _0 = (); // bb4[3]: scope 0 at $DIR/packed-struct-drop-aligned.rs:5:11: 8:2 + drop(_1) -> [return: bb2, unwind: bb1]; // bb4[4]: scope 0 at $DIR/packed-struct-drop-aligned.rs:8:1: 8:2 + } +} diff --git a/src/test/mir-opt/remove_fake_borrows.rs b/src/test/mir-opt/remove_fake_borrows.rs index ea106eaf595..fd2f1d0dbff 100644 --- a/src/test/mir-opt/remove_fake_borrows.rs +++ b/src/test/mir-opt/remove_fake_borrows.rs @@ -2,6 +2,7 @@ // ignore-wasm32-bare compiled with panic=abort by default +// EMIT_MIR rustc.match_guard.CleanupNonCodegenStatements.diff fn match_guard(x: Option<&&i32>, c: bool) -> i32 { match x { Some(0) if c => 0, @@ -12,97 +13,3 @@ fn match_guard(x: Option<&&i32>, c: bool) -> i32 { fn main() { match_guard(None, true); } - -// END RUST SOURCE - -// START rustc.match_guard.CleanupNonCodegenStatements.before.mir -// bb0: { -// FakeRead(ForMatchedPlace, _1); -// _3 = discriminant(_1); -// switchInt(move _3) -> [1isize: bb2, otherwise: bb1]; -// } -// bb1: { -// _0 = const 1i32; -// goto -> bb7; -// } -// bb2: { -// switchInt((*(*((_1 as Some).0: &&i32)))) -> [0i32: bb3, otherwise: bb1]; -// } -// bb3: { -// goto -> bb4; -// } -// bb4: { -// _4 = &shallow _1; -// _5 = &shallow ((_1 as Some).0: &&i32); -// _6 = &shallow (*((_1 as Some).0: &&i32)); -// _7 = &shallow (*(*((_1 as Some).0: &&i32))); -// StorageLive(_8); -// _8 = _2; -// switchInt(move _8) -> [false: bb6, otherwise: bb5]; -// } -// bb5: { -// StorageDead(_8); -// FakeRead(ForMatchGuard, _4); -// FakeRead(ForMatchGuard, _5); -// FakeRead(ForMatchGuard, _6); -// FakeRead(ForMatchGuard, _7); -// _0 = const 0i32; -// goto -> bb7; -// } -// bb6: { -// StorageDead(_8); -// goto -> bb1; -// } -// bb7: { -// return; -// } -// bb8 (cleanup): { -// resume; -// } -// END rustc.match_guard.CleanupNonCodegenStatements.before.mir - -// START rustc.match_guard.CleanupNonCodegenStatements.after.mir -// bb0: { -// nop; -// _3 = discriminant(_1); -// switchInt(move _3) -> [1isize: bb2, otherwise: bb1]; -// } -// bb1: { -// _0 = const 1i32; -// goto -> bb7; -// } -// bb2: { -// switchInt((*(*((_1 as Some).0: &&i32)))) -> [0i32: bb3, otherwise: bb1]; -// } -// bb3: { -// goto -> bb4; -// } -// bb4: { -// nop; -// nop; -// nop; -// nop; -// StorageLive(_8); -// _8 = _2; -// switchInt(move _8) -> [false: bb6, otherwise: bb5]; -// } -// bb5: { -// StorageDead(_8); -// nop; -// nop; -// nop; -// nop; -// _0 = const 0i32; -// goto -> bb7; -// } -// bb6: { -// StorageDead(_8); -// goto -> bb1; -// } -// bb7: { -// return; -// } -// bb8 (cleanup): { -// resume; -// } -// END rustc.match_guard.CleanupNonCodegenStatements.after.mir diff --git a/src/test/mir-opt/remove_fake_borrows/rustc.match_guard.CleanupNonCodegenStatements.diff b/src/test/mir-opt/remove_fake_borrows/rustc.match_guard.CleanupNonCodegenStatements.diff new file mode 100644 index 00000000000..c915554a127 --- /dev/null +++ b/src/test/mir-opt/remove_fake_borrows/rustc.match_guard.CleanupNonCodegenStatements.diff @@ -0,0 +1,88 @@ +- // MIR for `match_guard` before CleanupNonCodegenStatements ++ // MIR for `match_guard` after CleanupNonCodegenStatements + + fn match_guard(_1: std::option::Option<&&i32>, _2: bool) -> i32 { + debug x => _1; // in scope 0 at $DIR/remove_fake_borrows.rs:6:16: 6:17 + debug c => _2; // in scope 0 at $DIR/remove_fake_borrows.rs:6:34: 6:35 + let mut _0: i32; // return place in scope 0 at $DIR/remove_fake_borrows.rs:6:46: 6:49 + let mut _3: isize; // in scope 0 at $DIR/remove_fake_borrows.rs:8:9: 8:16 + let mut _4: &std::option::Option<&&i32>; // in scope 0 at $DIR/remove_fake_borrows.rs:7:11: 7:12 + let mut _5: &&&i32; // in scope 0 at $DIR/remove_fake_borrows.rs:7:11: 7:12 + let mut _6: &&i32; // in scope 0 at $DIR/remove_fake_borrows.rs:7:11: 7:12 + let mut _7: &i32; // in scope 0 at $DIR/remove_fake_borrows.rs:7:11: 7:12 + let mut _8: bool; // in scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21 + + bb0: { +- FakeRead(ForMatchedPlace, _1); // bb0[0]: scope 0 at $DIR/remove_fake_borrows.rs:7:11: 7:12 ++ nop; // bb0[0]: scope 0 at $DIR/remove_fake_borrows.rs:7:11: 7:12 + _3 = discriminant(_1); // bb0[1]: scope 0 at $DIR/remove_fake_borrows.rs:8:9: 8:16 + switchInt(move _3) -> [1isize: bb2, otherwise: bb1]; // bb0[2]: scope 0 at $DIR/remove_fake_borrows.rs:8:9: 8:16 + } + + bb1: { + _0 = const 1i32; // bb1[0]: scope 0 at $DIR/remove_fake_borrows.rs:9:14: 9:15 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/remove_fake_borrows.rs:9:14: 9:15 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } + goto -> bb7; // bb1[1]: scope 0 at $DIR/remove_fake_borrows.rs:7:5: 10:6 + } + + bb2: { + switchInt((*(*((_1 as Some).0: &&i32)))) -> [0i32: bb3, otherwise: bb1]; // bb2[0]: scope 0 at $DIR/remove_fake_borrows.rs:8:14: 8:15 + } + + bb3: { + goto -> bb4; // bb3[0]: scope 0 at $DIR/remove_fake_borrows.rs:8:9: 8:16 + } + + bb4: { +- _4 = &shallow _1; // bb4[0]: scope 0 at $DIR/remove_fake_borrows.rs:7:11: 7:12 +- _5 = &shallow ((_1 as Some).0: &&i32); // bb4[1]: scope 0 at $DIR/remove_fake_borrows.rs:7:11: 7:12 +- _6 = &shallow (*((_1 as Some).0: &&i32)); // bb4[2]: scope 0 at $DIR/remove_fake_borrows.rs:7:11: 7:12 +- _7 = &shallow (*(*((_1 as Some).0: &&i32))); // bb4[3]: scope 0 at $DIR/remove_fake_borrows.rs:7:11: 7:12 ++ nop; // bb4[0]: scope 0 at $DIR/remove_fake_borrows.rs:7:11: 7:12 ++ nop; // bb4[1]: scope 0 at $DIR/remove_fake_borrows.rs:7:11: 7:12 ++ nop; // bb4[2]: scope 0 at $DIR/remove_fake_borrows.rs:7:11: 7:12 ++ nop; // bb4[3]: scope 0 at $DIR/remove_fake_borrows.rs:7:11: 7:12 + StorageLive(_8); // bb4[4]: scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21 + _8 = _2; // bb4[5]: scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21 + switchInt(move _8) -> [false: bb6, otherwise: bb5]; // bb4[6]: scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21 + } + + bb5: { + StorageDead(_8); // bb5[0]: scope 0 at $DIR/remove_fake_borrows.rs:8:26: 8:27 +- FakeRead(ForMatchGuard, _4); // bb5[1]: scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21 +- FakeRead(ForMatchGuard, _5); // bb5[2]: scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21 +- FakeRead(ForMatchGuard, _6); // bb5[3]: scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21 +- FakeRead(ForMatchGuard, _7); // bb5[4]: scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21 ++ nop; // bb5[1]: scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21 ++ nop; // bb5[2]: scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21 ++ nop; // bb5[3]: scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21 ++ nop; // bb5[4]: scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21 + _0 = const 0i32; // bb5[5]: scope 0 at $DIR/remove_fake_borrows.rs:8:25: 8:26 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/remove_fake_borrows.rs:8:25: 8:26 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } + goto -> bb7; // bb5[6]: scope 0 at $DIR/remove_fake_borrows.rs:7:5: 10:6 + } + + bb6: { + StorageDead(_8); // bb6[0]: scope 0 at $DIR/remove_fake_borrows.rs:8:26: 8:27 + goto -> bb1; // bb6[1]: scope 0 at $DIR/remove_fake_borrows.rs:8:20: 8:21 + } + + bb7: { + return; // bb7[0]: scope 0 at $DIR/remove_fake_borrows.rs:11:2: 11:2 + } + + bb8 (cleanup): { + resume; // bb8[0]: scope 0 at $DIR/remove_fake_borrows.rs:6:1: 11:2 + } + } + diff --git a/src/test/mir-opt/retag.rs b/src/test/mir-opt/retag.rs index a0a7a760c2d..eba0f567c4a 100644 --- a/src/test/mir-opt/retag.rs +++ b/src/test/mir-opt/retag.rs @@ -6,6 +6,8 @@ struct Test(i32); +// EMIT_MIR rustc.{{impl}}-foo.SimplifyCfg-elaborate-drops.after.mir +// EMIT_MIR rustc.{{impl}}-foo_shr.SimplifyCfg-elaborate-drops.after.mir impl Test { // Make sure we run the pass on a method, not just on bare functions. fn foo<'x>(&self, x: &'x mut i32) -> &'x mut i32 { @@ -16,10 +18,14 @@ impl Test { } } +// EMIT_MIR rustc.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.mir + impl Drop for Test { fn drop(&mut self) {} } +// EMIT_MIR rustc.main.SimplifyCfg-elaborate-drops.after.mir +// EMIT_MIR rustc.main-{{closure}}.SimplifyCfg-elaborate-drops.after.mir fn main() { let mut x = 0; { @@ -43,94 +49,3 @@ fn main() { // escape-to-raw (shr) let _w = _w as *const _; } - -// END RUST SOURCE -// START rustc.{{impl}}-foo.SimplifyCfg-elaborate-drops.after.mir -// bb0: { -// Retag([fn entry] _1); -// Retag([fn entry] _2); -// ... -// _0 = &mut (*_3); -// Retag(_0); -// ... -// return; -// } -// END rustc.{{impl}}-foo.SimplifyCfg-elaborate-drops.after.mir -// START rustc.{{impl}}-foo_shr.SimplifyCfg-elaborate-drops.after.mir -// bb0: { -// Retag([fn entry] _1); -// Retag([fn entry] _2); -// ... -// _0 = _2; -// Retag(_0); -// ... -// return; -// } -// END rustc.{{impl}}-foo_shr.SimplifyCfg-elaborate-drops.after.mir -// START rustc.main.SimplifyCfg-elaborate-drops.after.mir -// fn main() -> () { -// ... -// bb0: { -// ... -// _3 = const Test::foo(move _4, move _6) -> [return: bb2, unwind: bb3]; -// } -// -// ... -// -// bb2: { -// Retag(_3); -// ... -// _9 = move _3; -// Retag(_9); -// _8 = &mut (*_9); -// Retag(_8); -// StorageDead(_9); -// StorageLive(_10); -// _10 = move _8; -// Retag(_10); -// ... -// _12 = &raw mut (*_10); -// Retag([raw] _12); -// ... -// _15 = move _16(move _17) -> bb5; -// } -// -// bb5: { -// Retag(_15); -// ... -// _19 = const Test::foo_shr(move _20, move _22) -> [return: bb6, unwind: bb7]; -// } -// -// ... -// } -// END rustc.main.SimplifyCfg-elaborate-drops.after.mir -// START rustc.main-{{closure}}.SimplifyCfg-elaborate-drops.after.mir -// fn main::{{closure}}#0(_1: &[closure@main::{{closure}}#0], _2: &i32) -> &i32 { -// ... -// bb0: { -// Retag([fn entry] _1); -// Retag([fn entry] _2); -// StorageLive(_3); -// _3 = _2; -// Retag(_3); -// _0 = _2; -// Retag(_0); -// StorageDead(_3); -// return; -// } -// } -// END rustc.main-{{closure}}.SimplifyCfg-elaborate-drops.after.mir -// START rustc.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.mir -// fn std::intrinsics::drop_in_place(_1: *mut Test) -> () { -// ... -// bb0: { -// Retag([raw] _1); -// _2 = &mut (*_1); -// _3 = const <Test as std::ops::Drop>::drop(move _2) -> bb1; -// } -// -// bb1: { -// return; -// } -// } -// END rustc.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.mir diff --git a/src/test/mir-opt/retag/rustc.main-{{closure}}.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/retag/rustc.main-{{closure}}.SimplifyCfg-elaborate-drops.after.mir new file mode 100644 index 00000000000..5aa2510f344 --- /dev/null +++ b/src/test/mir-opt/retag/rustc.main-{{closure}}.SimplifyCfg-elaborate-drops.after.mir @@ -0,0 +1,22 @@ +// MIR for `main::{{closure}}#0` after SimplifyCfg-elaborate-drops + +fn main::{{closure}}#0(_1: &[closure@main::{{closure}}#0], _2: &i32) -> &i32 { + debug x => _2; // in scope 0 at $DIR/retag.rs:40:32: 40:33 + let mut _0: &i32; // return place in scope 0 at $DIR/retag.rs:40:44: 40:48 + let _3: &i32; // in scope 0 at $DIR/retag.rs:41:13: 41:15 + scope 1 { + debug _y => _3; // in scope 1 at $DIR/retag.rs:41:13: 41:15 + } + + bb0: { + Retag([fn entry] _1); // bb0[0]: scope 0 at $DIR/retag.rs:40:31: 43:6 + Retag([fn entry] _2); // bb0[1]: scope 0 at $DIR/retag.rs:40:31: 43:6 + StorageLive(_3); // bb0[2]: scope 0 at $DIR/retag.rs:41:13: 41:15 + _3 = _2; // bb0[3]: scope 0 at $DIR/retag.rs:41:18: 41:19 + Retag(_3); // bb0[4]: scope 0 at $DIR/retag.rs:41:18: 41:19 + _0 = _2; // bb0[5]: scope 1 at $DIR/retag.rs:42:9: 42:10 + Retag(_0); // bb0[6]: scope 1 at $DIR/retag.rs:42:9: 42:10 + StorageDead(_3); // bb0[7]: scope 0 at $DIR/retag.rs:43:5: 43:6 + return; // bb0[8]: scope 0 at $DIR/retag.rs:43:6: 43:6 + } +} diff --git a/src/test/mir-opt/retag/rustc.main.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/retag/rustc.main.SimplifyCfg-elaborate-drops.after.mir new file mode 100644 index 00000000000..780cb9d4ad5 --- /dev/null +++ b/src/test/mir-opt/retag/rustc.main.SimplifyCfg-elaborate-drops.after.mir @@ -0,0 +1,227 @@ +// MIR for `main` after SimplifyCfg-elaborate-drops + +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/retag.rs:29:11: 29:11 + let mut _1: i32; // in scope 0 at $DIR/retag.rs:30:9: 30:14 + let _2: (); // in scope 0 at $DIR/retag.rs:31:5: 37:6 + let mut _4: &Test; // in scope 0 at $DIR/retag.rs:32:17: 32:24 + let _5: Test; // in scope 0 at $DIR/retag.rs:32:17: 32:24 + let mut _6: &mut i32; // in scope 0 at $DIR/retag.rs:32:29: 32:35 + let mut _7: &mut i32; // in scope 0 at $DIR/retag.rs:32:29: 32:35 + let mut _9: &mut i32; // in scope 0 at $DIR/retag.rs:33:19: 33:20 + let mut _12: *mut i32; // in scope 0 at $DIR/retag.rs:36:18: 36:29 + let mut _14: [closure@main::{{closure}}#0]; // in scope 0 at $DIR/retag.rs:40:31: 43:6 + let mut _16: for<'r> fn(&'r i32) -> &'r i32; // in scope 0 at $DIR/retag.rs:44:14: 44:15 + let mut _17: &i32; // in scope 0 at $DIR/retag.rs:44:16: 44:18 + let _18: &i32; // in scope 0 at $DIR/retag.rs:44:16: 44:18 + let _19: &i32; // in scope 0 at $DIR/retag.rs:47:5: 47:24 + let mut _20: &Test; // in scope 0 at $DIR/retag.rs:47:5: 47:12 + let _21: Test; // in scope 0 at $DIR/retag.rs:47:5: 47:12 + let mut _22: &i32; // in scope 0 at $DIR/retag.rs:47:21: 47:23 + let _23: &i32; // in scope 0 at $DIR/retag.rs:47:21: 47:23 + let _24: i32; // in scope 0 at $DIR/retag.rs:47:22: 47:23 + let mut _26: *const i32; // in scope 0 at $DIR/retag.rs:50:14: 50:28 + scope 1 { + debug x => _1; // in scope 1 at $DIR/retag.rs:30:9: 30:14 + let _3: &mut i32; // in scope 1 at $DIR/retag.rs:32:13: 32:14 + let _13: for<'r> fn(&'r i32) -> &'r i32 as UserTypeProjection { base: UserType(1), projs: [] }; // in scope 1 at $DIR/retag.rs:40:9: 40:10 + scope 2 { + debug v => _3; // in scope 2 at $DIR/retag.rs:32:13: 32:14 + let _8: &mut i32; // in scope 2 at $DIR/retag.rs:33:13: 33:14 + scope 3 { + debug w => _8; // in scope 3 at $DIR/retag.rs:33:13: 33:14 + let _10: &mut i32; // in scope 3 at $DIR/retag.rs:34:13: 34:14 + scope 4 { + debug w => _10; // in scope 4 at $DIR/retag.rs:34:13: 34:14 + let _11: *mut i32; // in scope 4 at $DIR/retag.rs:36:13: 36:15 + scope 5 { + debug _w => _11; // in scope 5 at $DIR/retag.rs:36:13: 36:15 + } + } + } + } + scope 6 { + debug c => _13; // in scope 6 at $DIR/retag.rs:40:9: 40:10 + let _15: &i32; // in scope 6 at $DIR/retag.rs:44:9: 44:11 + scope 7 { + debug _w => _15; // in scope 7 at $DIR/retag.rs:44:9: 44:11 + let _25: *const i32; // in scope 7 at $DIR/retag.rs:50:9: 50:11 + let mut _27: &i32; // in scope 7 at $DIR/retag.rs:47:21: 47:23 + scope 8 { + debug _w => _25; // in scope 8 at $DIR/retag.rs:50:9: 50:11 + } + } + } + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/retag.rs:30:9: 30:14 + _1 = const 0i32; // bb0[1]: scope 0 at $DIR/retag.rs:30:17: 30:18 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/retag.rs:30:17: 30:18 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } + StorageLive(_2); // bb0[2]: scope 1 at $DIR/retag.rs:31:5: 37:6 + StorageLive(_3); // bb0[3]: scope 1 at $DIR/retag.rs:32:13: 32:14 + StorageLive(_4); // bb0[4]: scope 1 at $DIR/retag.rs:32:17: 32:24 + StorageLive(_5); // bb0[5]: scope 1 at $DIR/retag.rs:32:17: 32:24 + _5 = Test(const 0i32,); // bb0[6]: scope 1 at $DIR/retag.rs:32:17: 32:24 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/retag.rs:32:22: 32:23 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } + _4 = &_5; // bb0[7]: scope 1 at $DIR/retag.rs:32:17: 32:24 + Retag(_4); // bb0[8]: scope 1 at $DIR/retag.rs:32:17: 32:24 + StorageLive(_6); // bb0[9]: scope 1 at $DIR/retag.rs:32:29: 32:35 + StorageLive(_7); // bb0[10]: scope 1 at $DIR/retag.rs:32:29: 32:35 + _7 = &mut _1; // bb0[11]: scope 1 at $DIR/retag.rs:32:29: 32:35 + Retag(_7); // bb0[12]: scope 1 at $DIR/retag.rs:32:29: 32:35 + _6 = &mut (*_7); // bb0[13]: scope 1 at $DIR/retag.rs:32:29: 32:35 + Retag([2phase] _6); // bb0[14]: scope 1 at $DIR/retag.rs:32:29: 32:35 + _3 = const Test::foo(move _4, move _6) -> [return: bb2, unwind: bb3]; // bb0[15]: scope 1 at $DIR/retag.rs:32:17: 32:36 + // ty::Const + // + ty: for<'r, 'x> fn(&'r Test, &'x mut i32) -> &'x mut i32 {Test::foo} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/retag.rs:32:25: 32:28 + // + literal: Const { ty: for<'r, 'x> fn(&'r Test, &'x mut i32) -> &'x mut i32 {Test::foo}, val: Value(Scalar(<ZST>)) } + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/retag.rs:29:1: 51:2 + } + + bb2: { + Retag(_3); // bb2[0]: scope 1 at $DIR/retag.rs:32:17: 32:36 + StorageDead(_6); // bb2[1]: scope 1 at $DIR/retag.rs:32:35: 32:36 + StorageDead(_4); // bb2[2]: scope 1 at $DIR/retag.rs:32:35: 32:36 + StorageDead(_7); // bb2[3]: scope 1 at $DIR/retag.rs:32:36: 32:37 + drop(_5) -> [return: bb4, unwind: bb1]; // bb2[4]: scope 1 at $DIR/retag.rs:32:36: 32:37 + } + + bb3 (cleanup): { + drop(_5) -> bb1; // bb3[0]: scope 1 at $DIR/retag.rs:32:36: 32:37 + } + + bb4: { + StorageDead(_5); // bb4[0]: scope 1 at $DIR/retag.rs:32:36: 32:37 + StorageLive(_8); // bb4[1]: scope 2 at $DIR/retag.rs:33:13: 33:14 + StorageLive(_9); // bb4[2]: scope 2 at $DIR/retag.rs:33:19: 33:20 + _9 = move _3; // bb4[3]: scope 2 at $DIR/retag.rs:33:19: 33:20 + Retag(_9); // bb4[4]: scope 2 at $DIR/retag.rs:33:19: 33:20 + _8 = &mut (*_9); // bb4[5]: scope 2 at $DIR/retag.rs:33:19: 33:20 + Retag(_8); // bb4[6]: scope 2 at $DIR/retag.rs:33:19: 33:20 + StorageDead(_9); // bb4[7]: scope 2 at $DIR/retag.rs:33:22: 33:23 + StorageLive(_10); // bb4[8]: scope 3 at $DIR/retag.rs:34:13: 34:14 + _10 = move _8; // bb4[9]: scope 3 at $DIR/retag.rs:34:17: 34:18 + Retag(_10); // bb4[10]: scope 3 at $DIR/retag.rs:34:17: 34:18 + StorageLive(_11); // bb4[11]: scope 4 at $DIR/retag.rs:36:13: 36:15 + StorageLive(_12); // bb4[12]: scope 4 at $DIR/retag.rs:36:18: 36:29 + _12 = &raw mut (*_10); // bb4[13]: scope 4 at $DIR/retag.rs:36:18: 36:19 + Retag([raw] _12); // bb4[14]: scope 4 at $DIR/retag.rs:36:18: 36:19 + _11 = _12; // bb4[15]: scope 4 at $DIR/retag.rs:36:18: 36:29 + StorageDead(_12); // bb4[16]: scope 4 at $DIR/retag.rs:36:29: 36:30 + _2 = (); // bb4[17]: scope 1 at $DIR/retag.rs:31:5: 37:6 + StorageDead(_11); // bb4[18]: scope 4 at $DIR/retag.rs:37:5: 37:6 + StorageDead(_10); // bb4[19]: scope 3 at $DIR/retag.rs:37:5: 37:6 + StorageDead(_8); // bb4[20]: scope 2 at $DIR/retag.rs:37:5: 37:6 + StorageDead(_3); // bb4[21]: scope 1 at $DIR/retag.rs:37:5: 37:6 + StorageDead(_2); // bb4[22]: scope 1 at $DIR/retag.rs:37:5: 37:6 + StorageLive(_13); // bb4[23]: scope 1 at $DIR/retag.rs:40:9: 40:10 + StorageLive(_14); // bb4[24]: scope 1 at $DIR/retag.rs:40:31: 43:6 + _14 = [closure@main::{{closure}}#0]; // bb4[25]: scope 1 at $DIR/retag.rs:40:31: 43:6 + // closure + // + def_id: DefId(0:14 ~ retag[317d]::main[0]::{{closure}}[0]) + // + substs: [ + // i8, + // for<'r> extern "rust-call" fn((&'r i32,)) -> &'r i32, + // (), + // ] + Retag(_14); // bb4[26]: scope 1 at $DIR/retag.rs:40:31: 43:6 + _13 = move _14 as for<'r> fn(&'r i32) -> &'r i32 (Pointer(ClosureFnPointer(Normal))); // bb4[27]: scope 1 at $DIR/retag.rs:40:31: 43:6 + StorageDead(_14); // bb4[28]: scope 1 at $DIR/retag.rs:43:5: 43:6 + StorageLive(_15); // bb4[29]: scope 6 at $DIR/retag.rs:44:9: 44:11 + StorageLive(_16); // bb4[30]: scope 6 at $DIR/retag.rs:44:14: 44:15 + _16 = _13; // bb4[31]: scope 6 at $DIR/retag.rs:44:14: 44:15 + StorageLive(_17); // bb4[32]: scope 6 at $DIR/retag.rs:44:16: 44:18 + StorageLive(_18); // bb4[33]: scope 6 at $DIR/retag.rs:44:16: 44:18 + _18 = &_1; // bb4[34]: scope 6 at $DIR/retag.rs:44:16: 44:18 + Retag(_18); // bb4[35]: scope 6 at $DIR/retag.rs:44:16: 44:18 + _17 = &(*_18); // bb4[36]: scope 6 at $DIR/retag.rs:44:16: 44:18 + Retag(_17); // bb4[37]: scope 6 at $DIR/retag.rs:44:16: 44:18 + _15 = move _16(move _17) -> bb5; // bb4[38]: scope 6 at $DIR/retag.rs:44:14: 44:19 + } + + bb5: { + Retag(_15); // bb5[0]: scope 6 at $DIR/retag.rs:44:14: 44:19 + StorageDead(_17); // bb5[1]: scope 6 at $DIR/retag.rs:44:18: 44:19 + StorageDead(_16); // bb5[2]: scope 6 at $DIR/retag.rs:44:18: 44:19 + StorageDead(_18); // bb5[3]: scope 6 at $DIR/retag.rs:44:19: 44:20 + StorageLive(_19); // bb5[4]: scope 7 at $DIR/retag.rs:47:5: 47:24 + StorageLive(_20); // bb5[5]: scope 7 at $DIR/retag.rs:47:5: 47:12 + StorageLive(_21); // bb5[6]: scope 7 at $DIR/retag.rs:47:5: 47:12 + _21 = Test(const 0i32,); // bb5[7]: scope 7 at $DIR/retag.rs:47:5: 47:12 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/retag.rs:47:10: 47:11 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } + _20 = &_21; // bb5[8]: scope 7 at $DIR/retag.rs:47:5: 47:12 + Retag(_20); // bb5[9]: scope 7 at $DIR/retag.rs:47:5: 47:12 + StorageLive(_22); // bb5[10]: scope 7 at $DIR/retag.rs:47:21: 47:23 + StorageLive(_23); // bb5[11]: scope 7 at $DIR/retag.rs:47:21: 47:23 + _27 = const main::promoted[0]; // bb5[12]: scope 7 at $DIR/retag.rs:47:21: 47:23 + // ty::Const + // + ty: &i32 + // + val: Unevaluated(DefId(0:13 ~ retag[317d]::main[0]), [], Some(promoted[0])) + // mir::Constant + // + span: $DIR/retag.rs:47:21: 47:23 + // + literal: Const { ty: &i32, val: Unevaluated(DefId(0:13 ~ retag[317d]::main[0]), [], Some(promoted[0])) } + Retag(_27); // bb5[13]: scope 7 at $DIR/retag.rs:47:21: 47:23 + _23 = &(*_27); // bb5[14]: scope 7 at $DIR/retag.rs:47:21: 47:23 + Retag(_23); // bb5[15]: scope 7 at $DIR/retag.rs:47:21: 47:23 + _22 = &(*_23); // bb5[16]: scope 7 at $DIR/retag.rs:47:21: 47:23 + Retag(_22); // bb5[17]: scope 7 at $DIR/retag.rs:47:21: 47:23 + _19 = const Test::foo_shr(move _20, move _22) -> [return: bb6, unwind: bb7]; // bb5[18]: scope 7 at $DIR/retag.rs:47:5: 47:24 + // ty::Const + // + ty: for<'r, 'x> fn(&'r Test, &'x i32) -> &'x i32 {Test::foo_shr} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/retag.rs:47:13: 47:20 + // + literal: Const { ty: for<'r, 'x> fn(&'r Test, &'x i32) -> &'x i32 {Test::foo_shr}, val: Value(Scalar(<ZST>)) } + } + + bb6: { + Retag(_19); // bb6[0]: scope 7 at $DIR/retag.rs:47:5: 47:24 + StorageDead(_22); // bb6[1]: scope 7 at $DIR/retag.rs:47:23: 47:24 + StorageDead(_20); // bb6[2]: scope 7 at $DIR/retag.rs:47:23: 47:24 + StorageDead(_23); // bb6[3]: scope 7 at $DIR/retag.rs:47:24: 47:25 + drop(_21) -> [return: bb8, unwind: bb1]; // bb6[4]: scope 7 at $DIR/retag.rs:47:24: 47:25 + } + + bb7 (cleanup): { + drop(_21) -> bb1; // bb7[0]: scope 7 at $DIR/retag.rs:47:24: 47:25 + } + + bb8: { + StorageDead(_21); // bb8[0]: scope 7 at $DIR/retag.rs:47:24: 47:25 + StorageDead(_19); // bb8[1]: scope 7 at $DIR/retag.rs:47:24: 47:25 + StorageLive(_25); // bb8[2]: scope 7 at $DIR/retag.rs:50:9: 50:11 + StorageLive(_26); // bb8[3]: scope 7 at $DIR/retag.rs:50:14: 50:28 + _26 = &raw const (*_15); // bb8[4]: scope 7 at $DIR/retag.rs:50:14: 50:16 + Retag([raw] _26); // bb8[5]: scope 7 at $DIR/retag.rs:50:14: 50:16 + _25 = _26; // bb8[6]: scope 7 at $DIR/retag.rs:50:14: 50:28 + StorageDead(_26); // bb8[7]: scope 7 at $DIR/retag.rs:50:28: 50:29 + _0 = (); // bb8[8]: scope 0 at $DIR/retag.rs:29:11: 51:2 + StorageDead(_25); // bb8[9]: scope 7 at $DIR/retag.rs:51:1: 51:2 + StorageDead(_15); // bb8[10]: scope 6 at $DIR/retag.rs:51:1: 51:2 + StorageDead(_13); // bb8[11]: scope 1 at $DIR/retag.rs:51:1: 51:2 + StorageDead(_1); // bb8[12]: scope 0 at $DIR/retag.rs:51:1: 51:2 + return; // bb8[13]: scope 0 at $DIR/retag.rs:51:2: 51:2 + } +} diff --git a/src/test/mir-opt/retag/rustc.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.mir b/src/test/mir-opt/retag/rustc.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.mir new file mode 100644 index 00000000000..306d30587d6 --- /dev/null +++ b/src/test/mir-opt/retag/rustc.ptr-drop_in_place.Test.SimplifyCfg-make_shim.after.mir @@ -0,0 +1,23 @@ +// MIR for `std::intrinsics::drop_in_place` after SimplifyCfg-make_shim + +fn std::intrinsics::drop_in_place(_1: *mut Test) -> () { + let mut _0: (); // return place in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + let mut _2: &mut Test; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + let mut _3: (); // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + + bb0: { + Retag([raw] _1); // bb0[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + _2 = &mut (*_1); // bb0[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + _3 = const <Test as std::ops::Drop>::drop(move _2) -> bb1; // bb0[2]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + // ty::Const + // + ty: for<'r> fn(&'r mut Test) {<Test as std::ops::Drop>::drop} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $SRC_DIR/libcore/ptr/mod.rs:LL:COL + // + literal: Const { ty: for<'r> fn(&'r mut Test) {<Test as std::ops::Drop>::drop}, val: Value(Scalar(<ZST>)) } + } + + bb1: { + return; // bb1[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } +} diff --git a/src/test/mir-opt/retag/rustc.{{impl}}-foo.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/retag/rustc.{{impl}}-foo.SimplifyCfg-elaborate-drops.after.mir new file mode 100644 index 00000000000..265a4bdd822 --- /dev/null +++ b/src/test/mir-opt/retag/rustc.{{impl}}-foo.SimplifyCfg-elaborate-drops.after.mir @@ -0,0 +1,20 @@ +// MIR for `<impl at $DIR/retag.rs:11:1: 19:2>::foo` after SimplifyCfg-elaborate-drops + +fn <impl at $DIR/retag.rs:11:1: 19:2>::foo(_1: &Test, _2: &mut i32) -> &mut i32 { + debug self => _1; // in scope 0 at $DIR/retag.rs:13:16: 13:21 + debug x => _2; // in scope 0 at $DIR/retag.rs:13:23: 13:24 + let mut _0: &mut i32; // return place in scope 0 at $DIR/retag.rs:13:42: 13:53 + let mut _3: &mut i32; // in scope 0 at $DIR/retag.rs:14:9: 14:10 + + bb0: { + Retag([fn entry] _1); // bb0[0]: scope 0 at $DIR/retag.rs:13:5: 15:6 + Retag([fn entry] _2); // bb0[1]: scope 0 at $DIR/retag.rs:13:5: 15:6 + StorageLive(_3); // bb0[2]: scope 0 at $DIR/retag.rs:14:9: 14:10 + _3 = &mut (*_2); // bb0[3]: scope 0 at $DIR/retag.rs:14:9: 14:10 + Retag(_3); // bb0[4]: scope 0 at $DIR/retag.rs:14:9: 14:10 + _0 = &mut (*_3); // bb0[5]: scope 0 at $DIR/retag.rs:14:9: 14:10 + Retag(_0); // bb0[6]: scope 0 at $DIR/retag.rs:14:9: 14:10 + StorageDead(_3); // bb0[7]: scope 0 at $DIR/retag.rs:15:5: 15:6 + return; // bb0[8]: scope 0 at $DIR/retag.rs:15:6: 15:6 + } +} diff --git a/src/test/mir-opt/retag/rustc.{{impl}}-foo_shr.SimplifyCfg-elaborate-drops.after.mir b/src/test/mir-opt/retag/rustc.{{impl}}-foo_shr.SimplifyCfg-elaborate-drops.after.mir new file mode 100644 index 00000000000..edf1058e457 --- /dev/null +++ b/src/test/mir-opt/retag/rustc.{{impl}}-foo_shr.SimplifyCfg-elaborate-drops.after.mir @@ -0,0 +1,15 @@ +// MIR for `<impl at $DIR/retag.rs:11:1: 19:2>::foo_shr` after SimplifyCfg-elaborate-drops + +fn <impl at $DIR/retag.rs:11:1: 19:2>::foo_shr(_1: &Test, _2: &i32) -> &i32 { + debug self => _1; // in scope 0 at $DIR/retag.rs:16:20: 16:25 + debug x => _2; // in scope 0 at $DIR/retag.rs:16:27: 16:28 + let mut _0: &i32; // return place in scope 0 at $DIR/retag.rs:16:42: 16:49 + + bb0: { + Retag([fn entry] _1); // bb0[0]: scope 0 at $DIR/retag.rs:16:5: 18:6 + Retag([fn entry] _2); // bb0[1]: scope 0 at $DIR/retag.rs:16:5: 18:6 + _0 = _2; // bb0[2]: scope 0 at $DIR/retag.rs:17:9: 17:10 + Retag(_0); // bb0[3]: scope 0 at $DIR/retag.rs:17:9: 17:10 + return; // bb0[4]: scope 0 at $DIR/retag.rs:18:6: 18:6 + } +} diff --git a/src/test/mir-opt/retain-never-const.rs b/src/test/mir-opt/retain-never-const.rs index 8e9bae8569f..af1077e6334 100644 --- a/src/test/mir-opt/retain-never-const.rs +++ b/src/test/mir-opt/retain-never-const.rs @@ -14,17 +14,9 @@ impl<T> PrintName<T> { const VOID: ! = panic!(); } +// EMIT_MIR rustc.no_codegen.PreCodegen.after.mir fn no_codegen<T>() { let _ = PrintName::<T>::VOID; } fn main() {} - -// END RUST SOURCE -// START rustc.no_codegen.PreCodegen.after.mir -// bb0: { -// StorageLive(_1); -// _1 = const PrintName::<T>::VOID; -// unreachable; -// } -// END rustc.no_codegen.PreCodegen.after.mir diff --git a/src/test/mir-opt/retain-never-const/rustc.no_codegen.PreCodegen.after.mir b/src/test/mir-opt/retain-never-const/rustc.no_codegen.PreCodegen.after.mir new file mode 100644 index 00000000000..2d7a79ee44c --- /dev/null +++ b/src/test/mir-opt/retain-never-const/rustc.no_codegen.PreCodegen.after.mir @@ -0,0 +1,21 @@ +// MIR for `no_codegen` after PreCodegen + +fn no_codegen() -> () { + let mut _0: (); // return place in scope 0 at $DIR/retain-never-const.rs:18:20: 18:20 + let mut _1: !; // in scope 0 at $DIR/retain-never-const.rs:19:13: 19:33 + scope 1 { + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/retain-never-const.rs:19:13: 19:33 + _1 = const PrintName::<T>::VOID; // bb0[1]: scope 0 at $DIR/retain-never-const.rs:19:13: 19:33 + // ty::Const + // + ty: ! + // + val: Unevaluated(DefId(0:9 ~ retain_never_const[317d]::{{impl}}[0]::VOID[0]), [T], None) + // mir::Constant + // + span: $DIR/retain-never-const.rs:19:13: 19:33 + // + user_ty: UserType(0) + // + literal: Const { ty: !, val: Unevaluated(DefId(0:9 ~ retain_never_const[317d]::{{impl}}[0]::VOID[0]), [T], None) } + unreachable; // bb0[2]: scope 0 at $DIR/retain-never-const.rs:19:13: 19:33 + } +} diff --git a/src/test/mir-opt/simple-match.rs b/src/test/mir-opt/simple-match.rs index fc1a3bb1bf4..c8c7e9188c2 100644 --- a/src/test/mir-opt/simple-match.rs +++ b/src/test/mir-opt/simple-match.rs @@ -1,5 +1,7 @@ // Test that we don't generate unnecessarily large MIR for very simple matches +// EMIT_MIR_FOR_EACH_BIT_WIDTH +// EMIT_MIR rustc.match_bool.mir_map.0.mir fn match_bool(x: bool) -> usize { match x { true => 10, @@ -8,32 +10,3 @@ fn match_bool(x: bool) -> usize { } fn main() {} - - -// END RUST SOURCE -// START rustc.match_bool.mir_map.0.mir -// bb0: { -// FakeRead(ForMatchedPlace, _1); -// switchInt(_1) -> [false: bb3, otherwise: bb2]; -// } -// bb1 (cleanup): { -// resume; -// } -// bb2: { -// falseEdges -> [real: bb4, imaginary: bb3]; -// } -// bb3: { -// _0 = const 20usize; -// goto -> bb5; -// } -// bb4: { -// _0 = const 10usize; -// goto -> bb5; -// } -// bb5: { -// goto -> bb6; -// } -// bb6: { -// return; -// } -// END rustc.match_bool.mir_map.0.mir diff --git a/src/test/mir-opt/simple-match/32bit/rustc.match_bool.mir_map.0.mir b/src/test/mir-opt/simple-match/32bit/rustc.match_bool.mir_map.0.mir new file mode 100644 index 00000000000..b720255893a --- /dev/null +++ b/src/test/mir-opt/simple-match/32bit/rustc.match_bool.mir_map.0.mir @@ -0,0 +1,49 @@ +// MIR for `match_bool` 0 mir_map + +fn match_bool(_1: bool) -> usize { + debug x => _1; // in scope 0 at $DIR/simple-match.rs:5:15: 5:16 + let mut _0: usize; // return place in scope 0 at $DIR/simple-match.rs:5:27: 5:32 + + bb0: { + FakeRead(ForMatchedPlace, _1); // bb0[0]: scope 0 at $DIR/simple-match.rs:6:11: 6:12 + switchInt(_1) -> [false: bb3, otherwise: bb2]; // bb0[1]: scope 0 at $DIR/simple-match.rs:7:9: 7:13 + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/simple-match.rs:5:1: 10:2 + } + + bb2: { + falseEdges -> [real: bb4, imaginary: bb3]; // bb2[0]: scope 0 at $DIR/simple-match.rs:7:9: 7:13 + } + + bb3: { + _0 = const 20usize; // bb3[0]: scope 0 at $DIR/simple-match.rs:8:14: 8:16 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x00000014)) + // mir::Constant + // + span: $DIR/simple-match.rs:8:14: 8:16 + // + literal: Const { ty: usize, val: Value(Scalar(0x00000014)) } + goto -> bb5; // bb3[1]: scope 0 at $DIR/simple-match.rs:6:5: 9:6 + } + + bb4: { + _0 = const 10usize; // bb4[0]: scope 0 at $DIR/simple-match.rs:7:17: 7:19 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000a)) + // mir::Constant + // + span: $DIR/simple-match.rs:7:17: 7:19 + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000a)) } + goto -> bb5; // bb4[1]: scope 0 at $DIR/simple-match.rs:6:5: 9:6 + } + + bb5: { + goto -> bb6; // bb5[0]: scope 0 at $DIR/simple-match.rs:10:2: 10:2 + } + + bb6: { + return; // bb6[0]: scope 0 at $DIR/simple-match.rs:10:2: 10:2 + } +} diff --git a/src/test/mir-opt/simple-match/64bit/rustc.match_bool.mir_map.0.mir b/src/test/mir-opt/simple-match/64bit/rustc.match_bool.mir_map.0.mir new file mode 100644 index 00000000000..f2fe72d0c11 --- /dev/null +++ b/src/test/mir-opt/simple-match/64bit/rustc.match_bool.mir_map.0.mir @@ -0,0 +1,49 @@ +// MIR for `match_bool` 0 mir_map + +fn match_bool(_1: bool) -> usize { + debug x => _1; // in scope 0 at $DIR/simple-match.rs:5:15: 5:16 + let mut _0: usize; // return place in scope 0 at $DIR/simple-match.rs:5:27: 5:32 + + bb0: { + FakeRead(ForMatchedPlace, _1); // bb0[0]: scope 0 at $DIR/simple-match.rs:6:11: 6:12 + switchInt(_1) -> [false: bb3, otherwise: bb2]; // bb0[1]: scope 0 at $DIR/simple-match.rs:7:9: 7:13 + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/simple-match.rs:5:1: 10:2 + } + + bb2: { + falseEdges -> [real: bb4, imaginary: bb3]; // bb2[0]: scope 0 at $DIR/simple-match.rs:7:9: 7:13 + } + + bb3: { + _0 = const 20usize; // bb3[0]: scope 0 at $DIR/simple-match.rs:8:14: 8:16 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000014)) + // mir::Constant + // + span: $DIR/simple-match.rs:8:14: 8:16 + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000014)) } + goto -> bb5; // bb3[1]: scope 0 at $DIR/simple-match.rs:6:5: 9:6 + } + + bb4: { + _0 = const 10usize; // bb4[0]: scope 0 at $DIR/simple-match.rs:7:17: 7:19 + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x000000000000000a)) + // mir::Constant + // + span: $DIR/simple-match.rs:7:17: 7:19 + // + literal: Const { ty: usize, val: Value(Scalar(0x000000000000000a)) } + goto -> bb5; // bb4[1]: scope 0 at $DIR/simple-match.rs:6:5: 9:6 + } + + bb5: { + goto -> bb6; // bb5[0]: scope 0 at $DIR/simple-match.rs:10:2: 10:2 + } + + bb6: { + return; // bb6[0]: scope 0 at $DIR/simple-match.rs:10:2: 10:2 + } +} diff --git a/src/test/mir-opt/simplify-arm-identity.rs b/src/test/mir-opt/simplify-arm-identity.rs index a8fa64255fb..cc6aab7523f 100644 --- a/src/test/mir-opt/simplify-arm-identity.rs +++ b/src/test/mir-opt/simplify-arm-identity.rs @@ -12,6 +12,7 @@ enum Dst { Foo(u8), } +// EMIT_MIR rustc.main.SimplifyArmIdentity.diff fn main() { let e: Src = Src::Foo(0); let _: Dst = match e { @@ -19,57 +20,3 @@ fn main() { Src::Bar => Dst::Foo(0), }; } - -// END RUST SOURCE -// START rustc.main.SimplifyArmIdentity.before.mir -// fn main() -> () { -// ... -// bb0: { -// StorageLive(_1); -// ((_1 as Foo).0: u8) = const 0u8; -// discriminant(_1) = 0; -// StorageLive(_2); -// _3 = discriminant(_1); -// switchInt(move _3) -> [0isize: bb3, 1isize: bb1, otherwise: bb2]; -// } -// bb1: { -// ((_2 as Foo).0: u8) = const 0u8; -// discriminant(_2) = 0; -// goto -> bb4; -// } -// ... -// bb3: { -// _4 = ((_1 as Foo).0: u8); -// ((_2 as Foo).0: u8) = move _4; -// discriminant(_2) = 0; -// goto -> bb4; -// } -// ... -// } -// END rustc.main.SimplifyArmIdentity.before.mir -// START rustc.main.SimplifyArmIdentity.after.mir -// fn main() -> () { -// ... -// bb0: { -// StorageLive(_1); -// ((_1 as Foo).0: u8) = const 0u8; -// discriminant(_1) = 0; -// StorageLive(_2); -// _3 = discriminant(_1); -// switchInt(move _3) -> [0isize: bb3, 1isize: bb1, otherwise: bb2]; -// } -// bb1: { -// ((_2 as Foo).0: u8) = const 0u8; -// discriminant(_2) = 0; -// goto -> bb4; -// } -// ... -// bb3: { -// _4 = ((_1 as Foo).0: u8); -// ((_2 as Foo).0: u8) = move _4; -// discriminant(_2) = 0; -// goto -> bb4; -// } -// ... -// } -// END rustc.main.SimplifyArmIdentity.after.mir diff --git a/src/test/mir-opt/simplify-arm-identity/rustc.main.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify-arm-identity/rustc.main.SimplifyArmIdentity.diff new file mode 100644 index 00000000000..32338127923 --- /dev/null +++ b/src/test/mir-opt/simplify-arm-identity/rustc.main.SimplifyArmIdentity.diff @@ -0,0 +1,64 @@ +- // MIR for `main` before SimplifyArmIdentity ++ // MIR for `main` after SimplifyArmIdentity + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/simplify-arm-identity.rs:16:11: 16:11 + let _1: Src as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/simplify-arm-identity.rs:17:9: 17:10 + let mut _2: Dst; // in scope 0 at $DIR/simplify-arm-identity.rs:18:18: 21:6 + let mut _3: isize; // in scope 0 at $DIR/simplify-arm-identity.rs:19:9: 19:20 + let mut _5: u8; // in scope 0 at $DIR/simplify-arm-identity.rs:19:33: 19:34 + scope 1 { + debug e => _1; // in scope 1 at $DIR/simplify-arm-identity.rs:17:9: 17:10 + let _4: u8; // in scope 1 at $DIR/simplify-arm-identity.rs:19:18: 19:19 + scope 2 { + } + scope 3 { + debug x => _4; // in scope 3 at $DIR/simplify-arm-identity.rs:19:18: 19:19 + } + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/simplify-arm-identity.rs:17:9: 17:10 + ((_1 as Foo).0: u8) = const 0u8; // bb0[1]: scope 0 at $DIR/simplify-arm-identity.rs:17:18: 17:29 + // ty::Const + // + ty: u8 + // + val: Value(Scalar(0x00)) + // mir::Constant + // + span: $DIR/simplify-arm-identity.rs:17:27: 17:28 + // + literal: Const { ty: u8, val: Value(Scalar(0x00)) } + discriminant(_1) = 0; // bb0[2]: scope 0 at $DIR/simplify-arm-identity.rs:17:18: 17:29 + StorageLive(_2); // bb0[3]: scope 1 at $DIR/simplify-arm-identity.rs:18:18: 21:6 + _3 = discriminant(_1); // bb0[4]: scope 1 at $DIR/simplify-arm-identity.rs:19:9: 19:20 + switchInt(move _3) -> [0isize: bb3, 1isize: bb1, otherwise: bb2]; // bb0[5]: scope 1 at $DIR/simplify-arm-identity.rs:19:9: 19:20 + } + + bb1: { + ((_2 as Foo).0: u8) = const 0u8; // bb1[0]: scope 1 at $DIR/simplify-arm-identity.rs:20:21: 20:32 + // ty::Const + // + ty: u8 + // + val: Value(Scalar(0x00)) + // mir::Constant + // + span: $DIR/simplify-arm-identity.rs:20:30: 20:31 + // + literal: Const { ty: u8, val: Value(Scalar(0x00)) } + discriminant(_2) = 0; // bb1[1]: scope 1 at $DIR/simplify-arm-identity.rs:20:21: 20:32 + goto -> bb4; // bb1[2]: scope 1 at $DIR/simplify-arm-identity.rs:18:18: 21:6 + } + + bb2: { + unreachable; // bb2[0]: scope 1 at $DIR/simplify-arm-identity.rs:18:24: 18:25 + } + + bb3: { + _4 = ((_1 as Foo).0: u8); // bb3[0]: scope 1 at $DIR/simplify-arm-identity.rs:19:18: 19:19 + ((_2 as Foo).0: u8) = move _4; // bb3[1]: scope 3 at $DIR/simplify-arm-identity.rs:19:24: 19:35 + discriminant(_2) = 0; // bb3[2]: scope 3 at $DIR/simplify-arm-identity.rs:19:24: 19:35 + goto -> bb4; // bb3[3]: scope 1 at $DIR/simplify-arm-identity.rs:18:18: 21:6 + } + + bb4: { + StorageDead(_2); // bb4[0]: scope 1 at $DIR/simplify-arm-identity.rs:21:6: 21:7 + StorageDead(_1); // bb4[1]: scope 0 at $DIR/simplify-arm-identity.rs:22:1: 22:2 + return; // bb4[2]: scope 0 at $DIR/simplify-arm-identity.rs:22:2: 22:2 + } + } + diff --git a/src/test/mir-opt/simplify-locals-removes-unused-consts.rs b/src/test/mir-opt/simplify-locals-removes-unused-consts.rs index e427fd55ad6..48cee3c30d2 100644 --- a/src/test/mir-opt/simplify-locals-removes-unused-consts.rs +++ b/src/test/mir-opt/simplify-locals-removes-unused-consts.rs @@ -8,82 +8,10 @@ struct Temp { fn use_u8(_: u8) {} +// EMIT_MIR rustc.main.SimplifyLocals.diff fn main() { let ((), ()) = ((), ()); use_zst(((), ())); use_u8((Temp { x: 40 }).x + 2); } - -// END RUST SOURCE - -// START rustc.main.SimplifyLocals.before.mir -// let mut _0: (); -// let mut _1: ((), ()); -// let mut _2: (); -// let mut _3: (); -// let _4: (); -// let mut _5: ((), ()); -// let mut _6: (); -// let mut _7: (); -// let _8: (); -// let mut _9: u8; -// let mut _10: u8; -// let mut _11: Temp; -// scope 1 { -// } -// bb0: { -// StorageLive(_1); -// StorageLive(_2); -// _2 = const (); -// StorageLive(_3); -// _3 = const (); -// _1 = const {transmute(()): ((), ())}; -// StorageDead(_3); -// StorageDead(_2); -// StorageDead(_1); -// StorageLive(_4); -// StorageLive(_6); -// _6 = const (); -// StorageLive(_7); -// _7 = const (); -// StorageDead(_7); -// StorageDead(_6); -// _4 = const use_zst(const {transmute(()): ((), ())}) -> bb1; -// } -// bb1: { -// StorageDead(_4); -// StorageLive(_8); -// StorageLive(_10); -// StorageLive(_11); -// _11 = const {transmute(0x28) : Temp}; -// _10 = const 40u8; -// StorageDead(_10); -// _8 = const use_u8(const 42u8) -> bb2; -// } -// bb2: { -// StorageDead(_11); -// StorageDead(_8); -// return; -// } -// END rustc.main.SimplifyLocals.before.mir -// START rustc.main.SimplifyLocals.after.mir -// let mut _0: (); -// let _1: (); -// let _2: (); -// scope 1 { -// } -// bb0: { -// StorageLive(_1); -// _1 = const use_zst(const {transmute(()): ((), ())}) -> bb1; -// } -// bb1: { -// StorageDead(_1); -// StorageLive(_2); -// _2 = const use_u8(const 42u8) -> bb2; -// } -// bb2: { -// StorageDead(_2); -// return; -// } -// END rustc.main.SimplifyLocals.after.mir diff --git a/src/test/mir-opt/simplify-locals-removes-unused-consts/rustc.main.SimplifyLocals.diff b/src/test/mir-opt/simplify-locals-removes-unused-consts/rustc.main.SimplifyLocals.diff new file mode 100644 index 00000000000..15deb3e31bd --- /dev/null +++ b/src/test/mir-opt/simplify-locals-removes-unused-consts/rustc.main.SimplifyLocals.diff @@ -0,0 +1,132 @@ +- // MIR for `main` before SimplifyLocals ++ // MIR for `main` after SimplifyLocals + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:12:11: 12:11 +- let mut _1: ((), ()); // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:20: 13:28 +- let mut _2: (); // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:21: 13:23 +- let mut _3: (); // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:25: 13:27 +- let _4: (); // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:22 +- let mut _5: ((), ()); // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:14:13: 14:21 +- let mut _6: (); // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:14:14: 14:16 +- let mut _7: (); // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:14:18: 14:20 +- let _8: (); // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:16:5: 16:35 +- let mut _9: u8; // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:34 +- let mut _10: u8; // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:30 +- let mut _11: Temp; // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:28 ++ let _1: (); // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:22 ++ let _2: (); // in scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:16:5: 16:35 + scope 1 { + } + + bb0: { +- StorageLive(_1); // bb0[0]: scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:20: 13:28 +- StorageLive(_2); // bb0[1]: scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:21: 13:23 +- _2 = const (); // bb0[2]: scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:21: 13:23 ++ StorageLive(_1); // bb0[0]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:22 ++ _1 = const use_zst(const {transmute(()): ((), ())}) -> bb1; // bb0[1]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:22 + // ty::Const +- // + ty: () +- // + val: Value(Scalar(<ZST>)) +- // mir::Constant +- // + span: $DIR/simplify-locals-removes-unused-consts.rs:13:21: 13:23 +- // + literal: Const { ty: (), val: Value(Scalar(<ZST>)) } +- StorageLive(_3); // bb0[3]: scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:25: 13:27 +- _3 = const (); // bb0[4]: scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:25: 13:27 +- // ty::Const +- // + ty: () +- // + val: Value(Scalar(<ZST>)) +- // mir::Constant +- // + span: $DIR/simplify-locals-removes-unused-consts.rs:13:25: 13:27 +- // + literal: Const { ty: (), val: Value(Scalar(<ZST>)) } +- _1 = const {transmute(()): ((), ())}; // bb0[5]: scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:20: 13:28 +- // ty::Const +- // + ty: ((), ()) +- // + val: Value(Scalar(<ZST>)) +- // mir::Constant +- // + span: $DIR/simplify-locals-removes-unused-consts.rs:13:20: 13:28 +- // + literal: Const { ty: ((), ()), val: Value(Scalar(<ZST>)) } +- StorageDead(_3); // bb0[6]: scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:27: 13:28 +- StorageDead(_2); // bb0[7]: scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:27: 13:28 +- StorageDead(_1); // bb0[8]: scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:13:28: 13:29 +- StorageLive(_4); // bb0[9]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:22 +- StorageLive(_6); // bb0[10]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:14: 14:16 +- _6 = const (); // bb0[11]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:14: 14:16 +- // ty::Const +- // + ty: () +- // + val: Value(Scalar(<ZST>)) +- // mir::Constant +- // + span: $DIR/simplify-locals-removes-unused-consts.rs:14:14: 14:16 +- // + literal: Const { ty: (), val: Value(Scalar(<ZST>)) } +- StorageLive(_7); // bb0[12]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:18: 14:20 +- _7 = const (); // bb0[13]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:18: 14:20 +- // ty::Const +- // + ty: () +- // + val: Value(Scalar(<ZST>)) +- // mir::Constant +- // + span: $DIR/simplify-locals-removes-unused-consts.rs:14:18: 14:20 +- // + literal: Const { ty: (), val: Value(Scalar(<ZST>)) } +- StorageDead(_7); // bb0[14]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:20: 14:21 +- StorageDead(_6); // bb0[15]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:20: 14:21 +- _4 = const use_zst(const {transmute(()): ((), ())}) -> bb1; // bb0[16]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:22 +- // ty::Const + // + ty: fn(((), ())) {use_zst} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/simplify-locals-removes-unused-consts.rs:14:5: 14:12 + // + literal: Const { ty: fn(((), ())) {use_zst}, val: Value(Scalar(<ZST>)) } + // ty::Const + // + ty: ((), ()) + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/simplify-locals-removes-unused-consts.rs:14:13: 14:21 + // + literal: Const { ty: ((), ()), val: Value(Scalar(<ZST>)) } + } + + bb1: { +- StorageDead(_4); // bb1[0]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:22: 14:23 +- StorageLive(_8); // bb1[1]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:5: 16:35 +- StorageLive(_10); // bb1[2]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:30 +- StorageLive(_11); // bb1[3]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:28 +- _11 = const {transmute(0x28): Temp}; // bb1[4]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:28 ++ StorageDead(_1); // bb1[0]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:14:22: 14:23 ++ StorageLive(_2); // bb1[1]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:5: 16:35 ++ _2 = const use_u8(const 42u8) -> bb2; // bb1[2]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:5: 16:35 + // ty::Const +- // + ty: Temp +- // + val: Value(Scalar(0x28)) +- // mir::Constant +- // + span: $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:28 +- // + literal: Const { ty: Temp, val: Value(Scalar(0x28)) } +- _10 = const 40u8; // bb1[5]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:30 +- // ty::Const +- // + ty: u8 +- // + val: Value(Scalar(0x28)) +- // mir::Constant +- // + span: $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:30 +- // + literal: Const { ty: u8, val: Value(Scalar(0x28)) } +- StorageDead(_10); // bb1[6]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:33: 16:34 +- _8 = const use_u8(const 42u8) -> bb2; // bb1[7]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:5: 16:35 +- // ty::Const + // + ty: fn(u8) {use_u8} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/simplify-locals-removes-unused-consts.rs:16:5: 16:11 + // + literal: Const { ty: fn(u8) {use_u8}, val: Value(Scalar(<ZST>)) } + // ty::Const + // + ty: u8 + // + val: Value(Scalar(0x2a)) + // mir::Constant + // + span: $DIR/simplify-locals-removes-unused-consts.rs:16:12: 16:34 + // + literal: Const { ty: u8, val: Value(Scalar(0x2a)) } + } + + bb2: { +- StorageDead(_11); // bb2[0]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:35: 16:36 +- StorageDead(_8); // bb2[1]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:35: 16:36 +- return; // bb2[2]: scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:17:2: 17:2 ++ StorageDead(_2); // bb2[0]: scope 1 at $DIR/simplify-locals-removes-unused-consts.rs:16:35: 16:36 ++ return; // bb2[1]: scope 0 at $DIR/simplify-locals-removes-unused-consts.rs:17:2: 17:2 + } + } + diff --git a/src/test/mir-opt/simplify_cfg.rs b/src/test/mir-opt/simplify_cfg.rs index ef843f71581..8d588a39d65 100644 --- a/src/test/mir-opt/simplify_cfg.rs +++ b/src/test/mir-opt/simplify_cfg.rs @@ -1,5 +1,7 @@ // Test that the goto chain starting from bb0 is collapsed. +// EMIT_MIR rustc.main.SimplifyCfg-initial.diff +// EMIT_MIR rustc.main.SimplifyCfg-early-opt.diff fn main() { loop { if bar() { @@ -12,43 +14,3 @@ fn main() { fn bar() -> bool { true } - -// END RUST SOURCE -// START rustc.main.SimplifyCfg-initial.before.mir -// bb0: { -// goto -> bb1; -// } -// bb1: { -// falseUnwind -> [real: bb3, cleanup: bb4]; -// } -// ... -// bb11: { -// ... -// goto -> bb1; -// } -// END rustc.main.SimplifyCfg-initial.before.mir -// START rustc.main.SimplifyCfg-initial.after.mir -// bb0: { -// falseUnwind -> [real: bb1, cleanup: bb2]; -// } -// ... -// bb5: { -// ... -// goto -> bb0; -// } -// END rustc.main.SimplifyCfg-initial.after.mir -// START rustc.main.SimplifyCfg-early-opt.before.mir -// bb0: { -// goto -> bb1; -// } -// bb1: { -// StorageLive(_2); -// _2 = const bar() -> bb3; -// } -// END rustc.main.SimplifyCfg-early-opt.before.mir -// START rustc.main.SimplifyCfg-early-opt.after.mir -// bb0: { -// StorageLive(_2); -// _2 = const bar() -> bb1; -// } -// END rustc.main.SimplifyCfg-early-opt.after.mir diff --git a/src/test/mir-opt/simplify_cfg/rustc.main.SimplifyCfg-early-opt.diff b/src/test/mir-opt/simplify_cfg/rustc.main.SimplifyCfg-early-opt.diff new file mode 100644 index 00000000000..9225bcd0b65 --- /dev/null +++ b/src/test/mir-opt/simplify_cfg/rustc.main.SimplifyCfg-early-opt.diff @@ -0,0 +1,62 @@ +- // MIR for `main` before SimplifyCfg-early-opt ++ // MIR for `main` after SimplifyCfg-early-opt + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/simplify_cfg.rs:5:11: 5:11 + let mut _1: (); // in scope 0 at $DIR/simplify_cfg.rs:5:1: 11:2 + let mut _2: bool; // in scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17 + let mut _3: !; // in scope 0 at $DIR/simplify_cfg.rs:7:18: 9:10 + + bb0: { +- goto -> bb1; // bb0[0]: scope 0 at $DIR/simplify_cfg.rs:6:5: 10:6 +- } +- +- bb1: { +- StorageLive(_2); // bb1[0]: scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17 +- _2 = const bar() -> bb3; // bb1[1]: scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17 ++ StorageLive(_2); // bb0[0]: scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17 ++ _2 = const bar() -> bb1; // bb0[1]: scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17 + // ty::Const + // + ty: fn() -> bool {bar} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/simplify_cfg.rs:7:12: 7:15 + // + literal: Const { ty: fn() -> bool {bar}, val: Value(Scalar(<ZST>)) } + } + +- bb2 (cleanup): { +- resume; // bb2[0]: scope 0 at $DIR/simplify_cfg.rs:5:1: 11:2 ++ bb1: { ++ switchInt(_2) -> [false: bb2, otherwise: bb3]; // bb1[0]: scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10 + } + +- bb3: { +- nop; // bb3[0]: scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17 +- switchInt(_2) -> [false: bb5, otherwise: bb4]; // bb3[1]: scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10 ++ bb2: { ++ _1 = (); // bb2[0]: scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10 ++ StorageDead(_2); // bb2[1]: scope 0 at $DIR/simplify_cfg.rs:10:5: 10:6 ++ goto -> bb0; // bb2[2]: scope 0 at $DIR/simplify_cfg.rs:6:5: 10:6 + } + +- bb4: { +- goto -> bb6; // bb4[0]: scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10 +- } +- +- bb5: { +- _1 = (); // bb5[0]: scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10 +- StorageDead(_2); // bb5[1]: scope 0 at $DIR/simplify_cfg.rs:10:5: 10:6 +- goto -> bb0; // bb5[2]: scope 0 at $DIR/simplify_cfg.rs:6:5: 10:6 +- } +- +- bb6: { +- _0 = (); // bb6[0]: scope 0 at $DIR/simplify_cfg.rs:8:13: 8:18 +- StorageDead(_2); // bb6[1]: scope 0 at $DIR/simplify_cfg.rs:10:5: 10:6 +- return; // bb6[2]: scope 0 at $DIR/simplify_cfg.rs:11:2: 11:2 ++ bb3: { ++ _0 = (); // bb3[0]: scope 0 at $DIR/simplify_cfg.rs:8:13: 8:18 ++ StorageDead(_2); // bb3[1]: scope 0 at $DIR/simplify_cfg.rs:10:5: 10:6 ++ return; // bb3[2]: scope 0 at $DIR/simplify_cfg.rs:11:2: 11:2 + } + } + diff --git a/src/test/mir-opt/simplify_cfg/rustc.main.SimplifyCfg-initial.diff b/src/test/mir-opt/simplify_cfg/rustc.main.SimplifyCfg-initial.diff new file mode 100644 index 00000000000..856ee3508cb --- /dev/null +++ b/src/test/mir-opt/simplify_cfg/rustc.main.SimplifyCfg-initial.diff @@ -0,0 +1,96 @@ +- // MIR for `main` before SimplifyCfg-initial ++ // MIR for `main` after SimplifyCfg-initial + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/simplify_cfg.rs:5:11: 5:11 + let mut _1: (); // in scope 0 at $DIR/simplify_cfg.rs:5:1: 11:2 + let mut _2: bool; // in scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17 + let mut _3: !; // in scope 0 at $DIR/simplify_cfg.rs:7:18: 9:10 + + bb0: { +- goto -> bb1; // bb0[0]: scope 0 at $DIR/simplify_cfg.rs:6:5: 10:6 ++ falseUnwind -> [real: bb1, cleanup: bb2]; // bb0[0]: scope 0 at $DIR/simplify_cfg.rs:6:5: 10:6 + } + + bb1: { +- falseUnwind -> [real: bb3, cleanup: bb4]; // bb1[0]: scope 0 at $DIR/simplify_cfg.rs:6:5: 10:6 +- } +- +- bb2: { +- goto -> bb13; // bb2[0]: scope 0 at $DIR/simplify_cfg.rs:11:2: 11:2 +- } +- +- bb3: { +- StorageLive(_2); // bb3[0]: scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17 +- _2 = const bar() -> [return: bb5, unwind: bb4]; // bb3[1]: scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17 ++ StorageLive(_2); // bb1[0]: scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17 ++ _2 = const bar() -> [return: bb3, unwind: bb2]; // bb1[1]: scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17 + // ty::Const + // + ty: fn() -> bool {bar} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/simplify_cfg.rs:7:12: 7:15 + // + literal: Const { ty: fn() -> bool {bar}, val: Value(Scalar(<ZST>)) } + } + +- bb4 (cleanup): { +- resume; // bb4[0]: scope 0 at $DIR/simplify_cfg.rs:5:1: 11:2 ++ bb2 (cleanup): { ++ resume; // bb2[0]: scope 0 at $DIR/simplify_cfg.rs:5:1: 11:2 + } + +- bb5: { +- FakeRead(ForMatchedPlace, _2); // bb5[0]: scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17 +- switchInt(_2) -> [false: bb7, otherwise: bb6]; // bb5[1]: scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10 ++ bb3: { ++ FakeRead(ForMatchedPlace, _2); // bb3[0]: scope 0 at $DIR/simplify_cfg.rs:7:12: 7:17 ++ switchInt(_2) -> [false: bb5, otherwise: bb4]; // bb3[1]: scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10 + } + +- bb6: { +- falseEdges -> [real: bb8, imaginary: bb7]; // bb6[0]: scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10 ++ bb4: { ++ falseEdges -> [real: bb6, imaginary: bb5]; // bb4[0]: scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10 + } + +- bb7: { +- _1 = (); // bb7[0]: scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10 +- goto -> bb12; // bb7[1]: scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10 ++ bb5: { ++ _1 = (); // bb5[0]: scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10 ++ StorageDead(_2); // bb5[1]: scope 0 at $DIR/simplify_cfg.rs:10:5: 10:6 ++ goto -> bb0; // bb5[2]: scope 0 at $DIR/simplify_cfg.rs:6:5: 10:6 + } + +- bb8: { +- _0 = (); // bb8[0]: scope 0 at $DIR/simplify_cfg.rs:8:13: 8:18 +- goto -> bb9; // bb8[1]: scope 0 at $DIR/simplify_cfg.rs:8:13: 8:18 +- } +- +- bb9: { +- StorageDead(_2); // bb9[0]: scope 0 at $DIR/simplify_cfg.rs:10:5: 10:6 +- goto -> bb2; // bb9[1]: scope 0 at $DIR/simplify_cfg.rs:8:13: 8:18 +- } +- +- bb10: { +- unreachable; // bb10[0]: scope 0 at $DIR/simplify_cfg.rs:7:18: 9:10 +- } +- +- bb11: { +- goto -> bb12; // bb11[0]: scope 0 at $DIR/simplify_cfg.rs:7:9: 9:10 +- } +- +- bb12: { +- StorageDead(_2); // bb12[0]: scope 0 at $DIR/simplify_cfg.rs:10:5: 10:6 +- goto -> bb1; // bb12[1]: scope 0 at $DIR/simplify_cfg.rs:6:5: 10:6 +- } +- +- bb13: { +- return; // bb13[0]: scope 0 at $DIR/simplify_cfg.rs:11:2: 11:2 ++ bb6: { ++ _0 = (); // bb6[0]: scope 0 at $DIR/simplify_cfg.rs:8:13: 8:18 ++ StorageDead(_2); // bb6[1]: scope 0 at $DIR/simplify_cfg.rs:10:5: 10:6 ++ return; // bb6[2]: scope 0 at $DIR/simplify_cfg.rs:11:2: 11:2 + } + } + diff --git a/src/test/mir-opt/simplify_if.rs b/src/test/mir-opt/simplify_if.rs index 471c1df3300..e2d3ebe69c4 100644 --- a/src/test/mir-opt/simplify_if.rs +++ b/src/test/mir-opt/simplify_if.rs @@ -1,19 +1,9 @@ +#[inline(never)] +fn noop() {} + +// EMIT_MIR rustc.main.SimplifyBranches-after-const-prop.diff fn main() { if false { - println!("hello world!"); + noop(); } } - -// END RUST SOURCE -// START rustc.main.SimplifyBranches-after-const-prop.before.mir -// bb0: { -// ... -// switchInt(const false) -> [false: bb1, otherwise: bb2]; -// } -// END rustc.main.SimplifyBranches-after-const-prop.before.mir -// START rustc.main.SimplifyBranches-after-const-prop.after.mir -// bb0: { -// ... -// goto -> bb1; -// } -// END rustc.main.SimplifyBranches-after-const-prop.after.mir diff --git a/src/test/mir-opt/simplify_if/rustc.main.SimplifyBranches-after-const-prop.diff b/src/test/mir-opt/simplify_if/rustc.main.SimplifyBranches-after-const-prop.diff new file mode 100644 index 00000000000..9e53a0f18af --- /dev/null +++ b/src/test/mir-opt/simplify_if/rustc.main.SimplifyBranches-after-const-prop.diff @@ -0,0 +1,55 @@ +- // MIR for `main` before SimplifyBranches-after-const-prop ++ // MIR for `main` after SimplifyBranches-after-const-prop + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/simplify_if.rs:5:11: 5:11 + let mut _1: bool; // in scope 0 at $DIR/simplify_if.rs:6:8: 6:13 + let _2: (); // in scope 0 at $DIR/simplify_if.rs:7:9: 7:15 + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/simplify_if.rs:6:8: 6:13 + _1 = const false; // bb0[1]: scope 0 at $DIR/simplify_if.rs:6:8: 6:13 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x00)) + // mir::Constant + // + span: $DIR/simplify_if.rs:6:8: 6:13 + // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } +- switchInt(const false) -> [false: bb1, otherwise: bb2]; // bb0[2]: scope 0 at $DIR/simplify_if.rs:6:5: 8:6 +- // ty::Const +- // + ty: bool +- // + val: Value(Scalar(0x00)) +- // mir::Constant +- // + span: $DIR/simplify_if.rs:6:5: 8:6 +- // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } ++ goto -> bb1; // bb0[2]: scope 0 at $DIR/simplify_if.rs:6:5: 8:6 + } + + bb1: { + _0 = (); // bb1[0]: scope 0 at $DIR/simplify_if.rs:6:5: 8:6 + goto -> bb4; // bb1[1]: scope 0 at $DIR/simplify_if.rs:6:5: 8:6 + } + + bb2: { + StorageLive(_2); // bb2[0]: scope 0 at $DIR/simplify_if.rs:7:9: 7:15 + _2 = const noop() -> bb3; // bb2[1]: scope 0 at $DIR/simplify_if.rs:7:9: 7:15 + // ty::Const + // + ty: fn() {noop} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/simplify_if.rs:7:9: 7:13 + // + literal: Const { ty: fn() {noop}, val: Value(Scalar(<ZST>)) } + } + + bb3: { + StorageDead(_2); // bb3[0]: scope 0 at $DIR/simplify_if.rs:7:15: 7:16 + _0 = (); // bb3[1]: scope 0 at $DIR/simplify_if.rs:6:14: 8:6 + goto -> bb4; // bb3[2]: scope 0 at $DIR/simplify_if.rs:6:5: 8:6 + } + + bb4: { + StorageDead(_1); // bb4[0]: scope 0 at $DIR/simplify_if.rs:9:1: 9:2 + return; // bb4[1]: scope 0 at $DIR/simplify_if.rs:9:2: 9:2 + } + } + diff --git a/src/test/mir-opt/simplify_match.rs b/src/test/mir-opt/simplify_match.rs index 8624899a0ab..233f9ff4c40 100644 --- a/src/test/mir-opt/simplify_match.rs +++ b/src/test/mir-opt/simplify_match.rs @@ -1,22 +1,10 @@ +#[inline(never)] +fn noop() {} + +// EMIT_MIR rustc.main.SimplifyBranches-after-copy-prop.diff fn main() { match { let x = false; x } { - true => println!("hello world!"), + true => noop(), false => {}, } } - -// END RUST SOURCE -// START rustc.main.SimplifyBranches-after-copy-prop.before.mir -// bb0: { -// ... -// switchInt(const false) -> [false: bb1, otherwise: bb2]; -// } -// bb1: { -// END rustc.main.SimplifyBranches-after-copy-prop.before.mir -// START rustc.main.SimplifyBranches-after-copy-prop.after.mir -// bb0: { -// ... -// goto -> bb1; -// } -// bb1: { -// END rustc.main.SimplifyBranches-after-copy-prop.after.mir diff --git a/src/test/mir-opt/simplify_match/rustc.main.SimplifyBranches-after-copy-prop.diff b/src/test/mir-opt/simplify_match/rustc.main.SimplifyBranches-after-copy-prop.diff new file mode 100644 index 00000000000..5429032b099 --- /dev/null +++ b/src/test/mir-opt/simplify_match/rustc.main.SimplifyBranches-after-copy-prop.diff @@ -0,0 +1,48 @@ +- // MIR for `main` before SimplifyBranches-after-copy-prop ++ // MIR for `main` after SimplifyBranches-after-copy-prop + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/simplify_match.rs:5:11: 5:11 + let mut _1: bool; // in scope 0 at $DIR/simplify_match.rs:6:11: 6:31 + let _2: bool; // in scope 0 at $DIR/simplify_match.rs:6:17: 6:18 + scope 1 { + debug x => _2; // in scope 1 at $DIR/simplify_match.rs:6:17: 6:18 + } + + bb0: { + nop; // bb0[0]: scope 0 at $DIR/simplify_match.rs:6:11: 6:31 + nop; // bb0[1]: scope 0 at $DIR/simplify_match.rs:6:17: 6:18 + nop; // bb0[2]: scope 0 at $DIR/simplify_match.rs:6:21: 6:26 + nop; // bb0[3]: scope 1 at $DIR/simplify_match.rs:6:28: 6:29 + nop; // bb0[4]: scope 0 at $DIR/simplify_match.rs:6:30: 6:31 +- switchInt(const false) -> [false: bb1, otherwise: bb2]; // bb0[5]: scope 0 at $DIR/simplify_match.rs:7:9: 7:13 +- // ty::Const +- // + ty: bool +- // + val: Value(Scalar(0x00)) +- // mir::Constant +- // + span: $DIR/simplify_match.rs:6:21: 6:26 +- // + literal: Const { ty: bool, val: Value(Scalar(0x00)) } ++ goto -> bb1; // bb0[5]: scope 0 at $DIR/simplify_match.rs:7:9: 7:13 + } + + bb1: { + nop; // bb1[0]: scope 0 at $DIR/simplify_match.rs:8:18: 8:20 + goto -> bb3; // bb1[1]: scope 0 at $DIR/simplify_match.rs:6:5: 9:6 + } + + bb2: { + _0 = const noop() -> bb3; // bb2[0]: scope 0 at $DIR/simplify_match.rs:7:17: 7:23 + // ty::Const + // + ty: fn() {noop} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/simplify_match.rs:7:17: 7:21 + // + literal: Const { ty: fn() {noop}, val: Value(Scalar(<ZST>)) } + } + + bb3: { + nop; // bb3[0]: scope 0 at $DIR/simplify_match.rs:10:1: 10:2 + return; // bb3[1]: scope 0 at $DIR/simplify_match.rs:10:2: 10:2 + } + } + diff --git a/src/test/mir-opt/simplify_try.rs b/src/test/mir-opt/simplify_try.rs index 78a7f722538..88a0451a76f 100644 --- a/src/test/mir-opt/simplify_try.rs +++ b/src/test/mir-opt/simplify_try.rs @@ -1,3 +1,7 @@ +// EMIT_MIR rustc.try_identity.SimplifyArmIdentity.diff +// EMIT_MIR rustc.try_identity.SimplifyBranchSame.after.mir +// EMIT_MIR rustc.try_identity.SimplifyLocals.after.mir + fn try_identity(x: Result<u32, i32>) -> Result<u32, i32> { let y = x?; Ok(y) @@ -6,210 +10,3 @@ fn try_identity(x: Result<u32, i32>) -> Result<u32, i32> { fn main() { let _ = try_identity(Ok(0)); } - -// END RUST SOURCE -// START rustc.try_identity.SimplifyArmIdentity.before.mir -// fn try_identity(_1: std::result::Result<u32, i32>) -> std::result::Result<u32, i32> { -// debug x => _1; -// let mut _0: std::result::Result<u32, i32>; -// let _2: u32; -// let mut _3: std::result::Result<u32, i32>; -// let mut _4: std::result::Result<u32, i32>; -// let mut _5: isize; -// let _6: i32; -// let mut _7: !; -// let mut _8: i32; -// let mut _9: i32; -// let _10: u32; -// let mut _11: u32; -// scope 1 { -// debug y => _10; -// } -// scope 2 { -// debug err => _6; -// scope 3 { -// scope 7 { -// debug t => _6; -// } -// scope 8 { -// debug v => _6; -// let mut _12: i32; -// } -// } -// } -// scope 4 { -// debug val => _10; -// scope 5 { -// } -// } -// scope 6 { -// debug self => _1; -// } -// bb0: { -// _5 = discriminant(_1); -// switchInt(move _5) -> [0isize: bb1, otherwise: bb2]; -// } -// bb1: { -// _10 = ((_1 as Ok).0: u32); -// ((_0 as Ok).0: u32) = move _10; -// discriminant(_0) = 0; -// goto -> bb3; -// } -// bb2: { -// _6 = ((_1 as Err).0: i32); -// ((_0 as Err).0: i32) = move _6; -// discriminant(_0) = 1; -// goto -> bb3; -// } -// bb3: { -// return; -// } -// } -// END rustc.try_identity.SimplifyArmIdentity.before.mir - -// START rustc.try_identity.SimplifyArmIdentity.after.mir -// fn try_identity(_1: std::result::Result<u32, i32>) -> std::result::Result<u32, i32> { -// debug x => _1; -// let mut _0: std::result::Result<u32, i32>; -// let _2: u32; -// let mut _3: std::result::Result<u32, i32>; -// let mut _4: std::result::Result<u32, i32>; -// let mut _5: isize; -// let _6: i32; -// let mut _7: !; -// let mut _8: i32; -// let mut _9: i32; -// let _10: u32; -// let mut _11: u32; -// scope 1 { -// debug y => _10; -// } -// scope 2 { -// debug err => _6; -// scope 3 { -// scope 7 { -// debug t => _6; -// } -// scope 8 { -// debug v => _6; -// let mut _12: i32; -// } -// } -// } -// scope 4 { -// debug val => _10; -// scope 5 { -// } -// } -// scope 6 { -// debug self => _1; -// } -// bb0: { -// _5 = discriminant(_1); -// switchInt(move _5) -> [0isize: bb1, otherwise: bb2]; -// } -// bb1: { -// _0 = move _1; -// nop; -// nop; -// goto -> bb3; -// } -// bb2: { -// _0 = move _1; -// nop; -// nop; -// goto -> bb3; -// } -// bb3: { -// return; -// } -// } -// END rustc.try_identity.SimplifyArmIdentity.after.mir - -// START rustc.try_identity.SimplifyBranchSame.after.mir -// fn try_identity(_1: std::result::Result<u32, i32>) -> std::result::Result<u32, i32> { -// debug x => _1; -// let mut _0: std::result::Result<u32, i32>; -// let _2: u32; -// let mut _3: std::result::Result<u32, i32>; -// let mut _4: std::result::Result<u32, i32>; -// let mut _5: isize; -// let _6: i32; -// let mut _7: !; -// let mut _8: i32; -// let mut _9: i32; -// let _10: u32; -// let mut _11: u32; -// scope 1 { -// debug y => _10; -// } -// scope 2 { -// debug err => _6; -// scope 3 { -// scope 7 { -// debug t => _6; -// } -// scope 8 { -// debug v => _6; -// let mut _12: i32; -// } -// } -// } -// scope 4 { -// debug val => _10; -// scope 5 { -// } -// } -// scope 6 { -// debug self => _1; -// } -// bb0: { -// _5 = discriminant(_1); -// goto -> bb1; -// } -// bb1: { -// _0 = move _1; -// nop; -// nop; -// goto -> bb2; -// } -// bb2: { -// return; -// } -// } -// END rustc.try_identity.SimplifyBranchSame.after.mir - -// START rustc.try_identity.SimplifyLocals.after.mir -// fn try_identity(_1: std::result::Result<u32, i32>) -> std::result::Result<u32, i32> { -// debug x => _1; -// let mut _0: std::result::Result<u32, i32>; -// let _2: i32; -// let _3: u32; -// scope 1 { -// debug y => _3; -// } -// scope 2 { -// debug err => _2; -// scope 3 { -// scope 7 { -// debug t => _2; -// } -// scope 8 { -// debug v => _2; -// } -// } -// } -// scope 4 { -// debug val => _3; -// scope 5 { -// } -// } -// scope 6 { -// debug self => _1; -// } -// bb0: { -// _0 = move _1; -// return; -// } -// } -// END rustc.try_identity.SimplifyLocals.after.mir diff --git a/src/test/mir-opt/simplify_try/rustc.try_identity.SimplifyArmIdentity.diff b/src/test/mir-opt/simplify_try/rustc.try_identity.SimplifyArmIdentity.diff new file mode 100644 index 00000000000..a4cc6b817ea --- /dev/null +++ b/src/test/mir-opt/simplify_try/rustc.try_identity.SimplifyArmIdentity.diff @@ -0,0 +1,70 @@ +- // MIR for `try_identity` before SimplifyArmIdentity ++ // MIR for `try_identity` after SimplifyArmIdentity + + fn try_identity(_1: std::result::Result<u32, i32>) -> std::result::Result<u32, i32> { + debug x => _1; // in scope 0 at $DIR/simplify_try.rs:5:17: 5:18 + let mut _0: std::result::Result<u32, i32>; // return place in scope 0 at $DIR/simplify_try.rs:5:41: 5:57 + let _2: u32; // in scope 0 at $DIR/simplify_try.rs:6:9: 6:10 + let mut _3: std::result::Result<u32, i32>; // in scope 0 at $DIR/simplify_try.rs:6:13: 6:15 + let mut _4: std::result::Result<u32, i32>; // in scope 0 at $DIR/simplify_try.rs:6:13: 6:14 + let mut _5: isize; // in scope 0 at $DIR/simplify_try.rs:6:14: 6:15 + let _6: i32; // in scope 0 at $DIR/simplify_try.rs:6:14: 6:15 + let mut _7: !; // in scope 0 at $DIR/simplify_try.rs:6:14: 6:15 + let mut _8: i32; // in scope 0 at $DIR/simplify_try.rs:6:14: 6:15 + let mut _9: i32; // in scope 0 at $DIR/simplify_try.rs:6:14: 6:15 + let _10: u32; // in scope 0 at $DIR/simplify_try.rs:6:13: 6:15 + let mut _11: u32; // in scope 0 at $DIR/simplify_try.rs:7:8: 7:9 + scope 1 { + debug y => _10; // in scope 1 at $DIR/simplify_try.rs:6:9: 6:10 + } + scope 2 { + debug err => _6; // in scope 2 at $DIR/simplify_try.rs:6:14: 6:15 + scope 3 { + scope 7 { + debug t => _6; // in scope 7 at $SRC_DIR/libcore/convert/mod.rs:LL:COL + } + scope 8 { + debug v => _6; // in scope 8 at $SRC_DIR/libcore/result.rs:LL:COL + let mut _12: i32; // in scope 8 at $DIR/simplify_try.rs:6:14: 6:15 + } + } + } + scope 4 { + debug val => _10; // in scope 4 at $DIR/simplify_try.rs:6:13: 6:15 + scope 5 { + } + } + scope 6 { + debug self => _1; // in scope 6 at $SRC_DIR/libcore/result.rs:LL:COL + } + + bb0: { + _5 = discriminant(_1); // bb0[0]: scope 0 at $DIR/simplify_try.rs:6:14: 6:15 + switchInt(move _5) -> [0isize: bb1, otherwise: bb2]; // bb0[1]: scope 0 at $DIR/simplify_try.rs:6:14: 6:15 + } + + bb1: { +- _10 = ((_1 as Ok).0: u32); // bb1[0]: scope 0 at $DIR/simplify_try.rs:6:13: 6:15 +- ((_0 as Ok).0: u32) = move _10; // bb1[1]: scope 1 at $DIR/simplify_try.rs:7:5: 7:10 +- discriminant(_0) = 0; // bb1[2]: scope 1 at $DIR/simplify_try.rs:7:5: 7:10 ++ _0 = move _1; // bb1[0]: scope 1 at $DIR/simplify_try.rs:7:5: 7:10 ++ nop; // bb1[1]: scope 1 at $DIR/simplify_try.rs:7:5: 7:10 ++ nop; // bb1[2]: scope 1 at $DIR/simplify_try.rs:7:5: 7:10 + goto -> bb3; // bb1[3]: scope 0 at $DIR/simplify_try.rs:8:2: 8:2 + } + + bb2: { +- _6 = ((_1 as Err).0: i32); // bb2[0]: scope 0 at $DIR/simplify_try.rs:6:14: 6:15 +- ((_0 as Err).0: i32) = move _6; // bb2[1]: scope 8 at $SRC_DIR/libcore/result.rs:LL:COL +- discriminant(_0) = 1; // bb2[2]: scope 8 at $SRC_DIR/libcore/result.rs:LL:COL ++ _0 = move _1; // bb2[0]: scope 8 at $SRC_DIR/libcore/result.rs:LL:COL ++ nop; // bb2[1]: scope 8 at $SRC_DIR/libcore/result.rs:LL:COL ++ nop; // bb2[2]: scope 8 at $SRC_DIR/libcore/result.rs:LL:COL + goto -> bb3; // bb2[3]: scope 0 at $DIR/simplify_try.rs:6:14: 6:15 + } + + bb3: { + return; // bb3[0]: scope 0 at $DIR/simplify_try.rs:8:2: 8:2 + } + } + diff --git a/src/test/mir-opt/simplify_try/rustc.try_identity.SimplifyBranchSame.after.mir b/src/test/mir-opt/simplify_try/rustc.try_identity.SimplifyBranchSame.after.mir new file mode 100644 index 00000000000..a18fb641f94 --- /dev/null +++ b/src/test/mir-opt/simplify_try/rustc.try_identity.SimplifyBranchSame.after.mir @@ -0,0 +1,55 @@ +// MIR for `try_identity` after SimplifyBranchSame + +fn try_identity(_1: std::result::Result<u32, i32>) -> std::result::Result<u32, i32> { + debug x => _1; // in scope 0 at $DIR/simplify_try.rs:5:17: 5:18 + let mut _0: std::result::Result<u32, i32>; // return place in scope 0 at $DIR/simplify_try.rs:5:41: 5:57 + let _2: u32; // in scope 0 at $DIR/simplify_try.rs:6:9: 6:10 + let mut _3: std::result::Result<u32, i32>; // in scope 0 at $DIR/simplify_try.rs:6:13: 6:15 + let mut _4: std::result::Result<u32, i32>; // in scope 0 at $DIR/simplify_try.rs:6:13: 6:14 + let mut _5: isize; // in scope 0 at $DIR/simplify_try.rs:6:14: 6:15 + let _6: i32; // in scope 0 at $DIR/simplify_try.rs:6:14: 6:15 + let mut _7: !; // in scope 0 at $DIR/simplify_try.rs:6:14: 6:15 + let mut _8: i32; // in scope 0 at $DIR/simplify_try.rs:6:14: 6:15 + let mut _9: i32; // in scope 0 at $DIR/simplify_try.rs:6:14: 6:15 + let _10: u32; // in scope 0 at $DIR/simplify_try.rs:6:13: 6:15 + let mut _11: u32; // in scope 0 at $DIR/simplify_try.rs:7:8: 7:9 + scope 1 { + debug y => _10; // in scope 1 at $DIR/simplify_try.rs:6:9: 6:10 + } + scope 2 { + debug err => _6; // in scope 2 at $DIR/simplify_try.rs:6:14: 6:15 + scope 3 { + scope 7 { + debug t => _6; // in scope 7 at $SRC_DIR/libcore/convert/mod.rs:LL:COL + } + scope 8 { + debug v => _6; // in scope 8 at $SRC_DIR/libcore/result.rs:LL:COL + let mut _12: i32; // in scope 8 at $DIR/simplify_try.rs:6:14: 6:15 + } + } + } + scope 4 { + debug val => _10; // in scope 4 at $DIR/simplify_try.rs:6:13: 6:15 + scope 5 { + } + } + scope 6 { + debug self => _1; // in scope 6 at $SRC_DIR/libcore/result.rs:LL:COL + } + + bb0: { + _5 = discriminant(_1); // bb0[0]: scope 0 at $DIR/simplify_try.rs:6:14: 6:15 + goto -> bb1; // bb0[1]: scope 0 at $DIR/simplify_try.rs:6:14: 6:15 + } + + bb1: { + _0 = move _1; // bb1[0]: scope 1 at $DIR/simplify_try.rs:7:5: 7:10 + nop; // bb1[1]: scope 1 at $DIR/simplify_try.rs:7:5: 7:10 + nop; // bb1[2]: scope 1 at $DIR/simplify_try.rs:7:5: 7:10 + goto -> bb2; // bb1[3]: scope 0 at $DIR/simplify_try.rs:8:2: 8:2 + } + + bb2: { + return; // bb2[0]: scope 0 at $DIR/simplify_try.rs:8:2: 8:2 + } +} diff --git a/src/test/mir-opt/simplify_try/rustc.try_identity.SimplifyLocals.after.mir b/src/test/mir-opt/simplify_try/rustc.try_identity.SimplifyLocals.after.mir new file mode 100644 index 00000000000..b7ed760f6d6 --- /dev/null +++ b/src/test/mir-opt/simplify_try/rustc.try_identity.SimplifyLocals.after.mir @@ -0,0 +1,35 @@ +// MIR for `try_identity` after SimplifyLocals + +fn try_identity(_1: std::result::Result<u32, i32>) -> std::result::Result<u32, i32> { + debug x => _1; // in scope 0 at $DIR/simplify_try.rs:5:17: 5:18 + let mut _0: std::result::Result<u32, i32>; // return place in scope 0 at $DIR/simplify_try.rs:5:41: 5:57 + let _2: i32; // in scope 0 at $DIR/simplify_try.rs:6:14: 6:15 + let _3: u32; // in scope 0 at $DIR/simplify_try.rs:6:13: 6:15 + scope 1 { + debug y => _3; // in scope 1 at $DIR/simplify_try.rs:6:9: 6:10 + } + scope 2 { + debug err => _2; // in scope 2 at $DIR/simplify_try.rs:6:14: 6:15 + scope 3 { + scope 7 { + debug t => _2; // in scope 7 at $SRC_DIR/libcore/convert/mod.rs:LL:COL + } + scope 8 { + debug v => _2; // in scope 8 at $SRC_DIR/libcore/result.rs:LL:COL + } + } + } + scope 4 { + debug val => _3; // in scope 4 at $DIR/simplify_try.rs:6:13: 6:15 + scope 5 { + } + } + scope 6 { + debug self => _1; // in scope 6 at $SRC_DIR/libcore/result.rs:LL:COL + } + + bb0: { + _0 = move _1; // bb0[0]: scope 1 at $DIR/simplify_try.rs:7:5: 7:10 + return; // bb0[1]: scope 0 at $DIR/simplify_try.rs:8:2: 8:2 + } +} diff --git a/src/test/mir-opt/slice-drop-shim.rs b/src/test/mir-opt/slice-drop-shim.rs index a25375594d3..5d8d37e0bc5 100644 --- a/src/test/mir-opt/slice-drop-shim.rs +++ b/src/test/mir-opt/slice-drop-shim.rs @@ -1,90 +1,7 @@ // compile-flags: -Zmir-opt-level=0 +// EMIT_MIR_FOR_EACH_BIT_WIDTH +// EMIT_MIR rustc.ptr-drop_in_place.[std__string__String].AddMovesForPackedDrops.before.mir fn main() { let _fn = std::ptr::drop_in_place::<[String]> as unsafe fn(_); } - -// END RUST SOURCE - -// START rustc.ptr-drop_in_place.[std__string__String].AddMovesForPackedDrops.before.mir -// let mut _2: usize; -// let mut _3: usize; -// let mut _4: usize; -// let mut _5: *mut std::string::String; -// let mut _6: bool; -// let mut _7: *mut std::string::String; -// let mut _8: bool; -// let mut _9: *mut std::string::String; -// let mut _10: *mut std::string::String; -// let mut _11: *mut std::string::String; -// let mut _12: bool; -// let mut _13: *mut std::string::String; -// let mut _14: bool; -// let mut _15: *mut [std::string::String]; -// bb0: { -// goto -> bb15; -// } -// bb1: { -// return; -// } -// bb2 (cleanup): { -// resume; -// } -// bb3 (cleanup): { -// _5 = &raw mut (*_1)[_4]; -// _4 = Add(move _4, const 1usize); -// drop((*_5)) -> bb4; -// } -// bb4 (cleanup): { -// _6 = Eq(_4, _3); -// switchInt(move _6) -> [false: bb3, otherwise: bb2]; -// } -// bb5: { -// _7 = &raw mut (*_1)[_4]; -// _4 = Add(move _4, const 1usize); -// drop((*_7)) -> [return: bb6, unwind: bb4]; -// } -// bb6: { -// _8 = Eq(_4, _3); -// switchInt(move _8) -> [false: bb5, otherwise: bb1]; -// } -// bb7: { -// _4 = const 0usize; -// goto -> bb6; -// } -// bb8: { -// goto -> bb7; -// } -// bb9 (cleanup): { -// _11 = _9; -// _9 = Offset(move _9, const 1usize); -// drop((*_11)) -> bb10; -// } -// bb10 (cleanup): { -// _12 = Eq(_9, _10); -// switchInt(move _12) -> [false: bb9, otherwise: bb2]; -// } -// bb11: { -// _13 = _9; -// _9 = Offset(move _9, const 1usize); -// drop((*_13)) -> [return: bb12, unwind: bb10]; -// } -// bb12: { -// _14 = Eq(_9, _10); -// switchInt(move _14) -> [false: bb11, otherwise: bb1]; -// } -// bb13: { -// _15 = &raw mut (*_1); -// _9 = move _15 as *mut std::string::String (Misc); -// _10 = Offset(_9, move _3); -// goto -> bb12; -// } -// bb14: { -// goto -> bb13; -// } -// bb15: { -// _2 = SizeOf(std::string::String); -// _3 = Len((*_1)); -// switchInt(move _2) -> [0usize: bb8, otherwise: bb14]; -// } -// END rustc.ptr-drop_in_place.[std__string__String].AddMovesForPackedDrops.before.mir diff --git a/src/test/mir-opt/slice-drop-shim/32bit/rustc.ptr-drop_in_place.[std__string__String].AddMovesForPackedDrops.before.mir b/src/test/mir-opt/slice-drop-shim/32bit/rustc.ptr-drop_in_place.[std__string__String].AddMovesForPackedDrops.before.mir new file mode 100644 index 00000000000..e397adcc2cc --- /dev/null +++ b/src/test/mir-opt/slice-drop-shim/32bit/rustc.ptr-drop_in_place.[std__string__String].AddMovesForPackedDrops.before.mir @@ -0,0 +1,131 @@ +// MIR for `std::intrinsics::drop_in_place` before AddMovesForPackedDrops + +fn std::intrinsics::drop_in_place(_1: *mut [std::string::String]) -> () { + let mut _0: (); // return place in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + let mut _2: usize; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + let mut _3: usize; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + let mut _4: usize; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + let mut _5: *mut std::string::String; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + let mut _6: bool; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + let mut _7: *mut std::string::String; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + let mut _8: bool; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + let mut _9: *mut std::string::String; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + let mut _10: *mut std::string::String; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + let mut _11: *mut std::string::String; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + let mut _12: bool; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + let mut _13: *mut std::string::String; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + let mut _14: bool; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + let mut _15: *mut [std::string::String]; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + + bb0: { + goto -> bb15; // bb0[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb1: { + return; // bb1[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb2 (cleanup): { + resume; // bb2[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb3 (cleanup): { + _5 = &raw mut (*_1)[_4]; // bb3[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + _4 = Add(move _4, const 1usize); // bb3[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $SRC_DIR/libcore/ptr/mod.rs:LL:COL + // + literal: Const { ty: usize, val: Value(Scalar(0x00000001)) } + drop((*_5)) -> bb4; // bb3[2]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb4 (cleanup): { + _6 = Eq(_4, _3); // bb4[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + switchInt(move _6) -> [false: bb3, otherwise: bb2]; // bb4[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb5: { + _7 = &raw mut (*_1)[_4]; // bb5[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + _4 = Add(move _4, const 1usize); // bb5[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $SRC_DIR/libcore/ptr/mod.rs:LL:COL + // + literal: Const { ty: usize, val: Value(Scalar(0x00000001)) } + drop((*_7)) -> [return: bb6, unwind: bb4]; // bb5[2]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb6: { + _8 = Eq(_4, _3); // bb6[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + switchInt(move _8) -> [false: bb5, otherwise: bb1]; // bb6[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb7: { + _4 = const 0usize; // bb7[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $SRC_DIR/libcore/ptr/mod.rs:LL:COL + // + literal: Const { ty: usize, val: Value(Scalar(0x00000000)) } + goto -> bb6; // bb7[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb8: { + goto -> bb7; // bb8[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb9 (cleanup): { + _11 = _9; // bb9[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + _9 = Offset(move _9, const 1usize); // bb9[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $SRC_DIR/libcore/ptr/mod.rs:LL:COL + // + literal: Const { ty: usize, val: Value(Scalar(0x00000001)) } + drop((*_11)) -> bb10; // bb9[2]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb10 (cleanup): { + _12 = Eq(_9, _10); // bb10[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + switchInt(move _12) -> [false: bb9, otherwise: bb2]; // bb10[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb11: { + _13 = _9; // bb11[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + _9 = Offset(move _9, const 1usize); // bb11[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $SRC_DIR/libcore/ptr/mod.rs:LL:COL + // + literal: Const { ty: usize, val: Value(Scalar(0x00000001)) } + drop((*_13)) -> [return: bb12, unwind: bb10]; // bb11[2]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb12: { + _14 = Eq(_9, _10); // bb12[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + switchInt(move _14) -> [false: bb11, otherwise: bb1]; // bb12[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb13: { + _15 = &raw mut (*_1); // bb13[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + _9 = move _15 as *mut std::string::String (Misc); // bb13[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + _10 = Offset(_9, move _3); // bb13[2]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + goto -> bb12; // bb13[3]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb14: { + goto -> bb13; // bb14[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb15: { + _2 = SizeOf(std::string::String); // bb15[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + _3 = Len((*_1)); // bb15[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + switchInt(move _2) -> [0usize: bb8, otherwise: bb14]; // bb15[2]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } +} diff --git a/src/test/mir-opt/slice-drop-shim/64bit/rustc.ptr-drop_in_place.[std__string__String].AddMovesForPackedDrops.before.mir b/src/test/mir-opt/slice-drop-shim/64bit/rustc.ptr-drop_in_place.[std__string__String].AddMovesForPackedDrops.before.mir new file mode 100644 index 00000000000..fd2bfe46c5a --- /dev/null +++ b/src/test/mir-opt/slice-drop-shim/64bit/rustc.ptr-drop_in_place.[std__string__String].AddMovesForPackedDrops.before.mir @@ -0,0 +1,131 @@ +// MIR for `std::intrinsics::drop_in_place` before AddMovesForPackedDrops + +fn std::intrinsics::drop_in_place(_1: *mut [std::string::String]) -> () { + let mut _0: (); // return place in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + let mut _2: usize; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + let mut _3: usize; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + let mut _4: usize; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + let mut _5: *mut std::string::String; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + let mut _6: bool; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + let mut _7: *mut std::string::String; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + let mut _8: bool; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + let mut _9: *mut std::string::String; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + let mut _10: *mut std::string::String; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + let mut _11: *mut std::string::String; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + let mut _12: bool; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + let mut _13: *mut std::string::String; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + let mut _14: bool; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + let mut _15: *mut [std::string::String]; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + + bb0: { + goto -> bb15; // bb0[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb1: { + return; // bb1[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb2 (cleanup): { + resume; // bb2[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb3 (cleanup): { + _5 = &raw mut (*_1)[_4]; // bb3[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + _4 = Add(move _4, const 1usize); // bb3[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000001)) + // mir::Constant + // + span: $SRC_DIR/libcore/ptr/mod.rs:LL:COL + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000001)) } + drop((*_5)) -> bb4; // bb3[2]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb4 (cleanup): { + _6 = Eq(_4, _3); // bb4[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + switchInt(move _6) -> [false: bb3, otherwise: bb2]; // bb4[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb5: { + _7 = &raw mut (*_1)[_4]; // bb5[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + _4 = Add(move _4, const 1usize); // bb5[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000001)) + // mir::Constant + // + span: $SRC_DIR/libcore/ptr/mod.rs:LL:COL + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000001)) } + drop((*_7)) -> [return: bb6, unwind: bb4]; // bb5[2]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb6: { + _8 = Eq(_4, _3); // bb6[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + switchInt(move _8) -> [false: bb5, otherwise: bb1]; // bb6[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb7: { + _4 = const 0usize; // bb7[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000000)) + // mir::Constant + // + span: $SRC_DIR/libcore/ptr/mod.rs:LL:COL + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000000)) } + goto -> bb6; // bb7[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb8: { + goto -> bb7; // bb8[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb9 (cleanup): { + _11 = _9; // bb9[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + _9 = Offset(move _9, const 1usize); // bb9[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000001)) + // mir::Constant + // + span: $SRC_DIR/libcore/ptr/mod.rs:LL:COL + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000001)) } + drop((*_11)) -> bb10; // bb9[2]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb10 (cleanup): { + _12 = Eq(_9, _10); // bb10[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + switchInt(move _12) -> [false: bb9, otherwise: bb2]; // bb10[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb11: { + _13 = _9; // bb11[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + _9 = Offset(move _9, const 1usize); // bb11[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + // ty::Const + // + ty: usize + // + val: Value(Scalar(0x0000000000000001)) + // mir::Constant + // + span: $SRC_DIR/libcore/ptr/mod.rs:LL:COL + // + literal: Const { ty: usize, val: Value(Scalar(0x0000000000000001)) } + drop((*_13)) -> [return: bb12, unwind: bb10]; // bb11[2]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb12: { + _14 = Eq(_9, _10); // bb12[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + switchInt(move _14) -> [false: bb11, otherwise: bb1]; // bb12[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb13: { + _15 = &raw mut (*_1); // bb13[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + _9 = move _15 as *mut std::string::String (Misc); // bb13[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + _10 = Offset(_9, move _3); // bb13[2]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + goto -> bb12; // bb13[3]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb14: { + goto -> bb13; // bb14[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb15: { + _2 = SizeOf(std::string::String); // bb15[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + _3 = Len((*_1)); // bb15[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + switchInt(move _2) -> [0usize: bb8, otherwise: bb14]; // bb15[2]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } +} diff --git a/src/test/mir-opt/storage_live_dead_in_statics.rs b/src/test/mir-opt/storage_live_dead_in_statics.rs index 1c98766b968..a269914f262 100644 --- a/src/test/mir-opt/storage_live_dead_in_statics.rs +++ b/src/test/mir-opt/storage_live_dead_in_statics.rs @@ -1,8 +1,7 @@ // Check that when we compile the static `XXX` into MIR, we do not // generate `StorageStart` or `StorageEnd` statements. -// ignore-tidy-linelength - +// EMIT_MIR rustc.XXX.mir_map.0.mir static XXX: &'static Foo = &Foo { tup: "hi", data: &[ @@ -32,159 +31,3 @@ struct Foo { fn main() { println!("{:?}", XXX); } - -// END RUST SOURCE -// START rustc.XXX.mir_map.0.mir -// let mut _0: &Foo; -// let _1: &Foo; -// let _2: Foo; -// let mut _3: &[(u32, u32)]; -// let mut _4: &[(u32, u32); 42]; -// let _5: &[(u32, u32); 42]; -// let _6: [(u32, u32); 42]; -// let mut _7: (u32, u32); -// let mut _8: (u32, u32); -// let mut _9: (u32, u32); -// let mut _10: (u32, u32); -// let mut _11: (u32, u32); -// let mut _12: (u32, u32); -// let mut _13: (u32, u32); -// let mut _14: (u32, u32); -// let mut _15: (u32, u32); -// let mut _16: (u32, u32); -// let mut _17: (u32, u32); -// let mut _18: (u32, u32); -// let mut _19: (u32, u32); -// let mut _20: (u32, u32); -// let mut _21: (u32, u32); -// let mut _22: (u32, u32); -// let mut _23: (u32, u32); -// let mut _24: (u32, u32); -// let mut _25: (u32, u32); -// let mut _26: (u32, u32); -// let mut _27: (u32, u32); -// let mut _28: (u32, u32); -// let mut _29: (u32, u32); -// let mut _30: (u32, u32); -// let mut _31: (u32, u32); -// let mut _32: (u32, u32); -// let mut _33: (u32, u32); -// let mut _34: (u32, u32); -// let mut _35: (u32, u32); -// let mut _36: (u32, u32); -// let mut _37: (u32, u32); -// let mut _38: (u32, u32); -// let mut _39: (u32, u32); -// let mut _40: (u32, u32); -// let mut _41: (u32, u32); -// let mut _42: (u32, u32); -// let mut _43: (u32, u32); -// let mut _44: (u32, u32); -// let mut _45: (u32, u32); -// let mut _46: (u32, u32); -// let mut _47: (u32, u32); -// let mut _48: (u32, u32); -// bb0: { -// StorageLive(_1); -// StorageLive(_2); -// StorageLive(_3); -// StorageLive(_4); -// StorageLive(_5); -// StorageLive(_6); -// StorageLive(_7); -// _7 = (const 0u32, const 1u32); -// StorageLive(_8); -// _8 = (const 0u32, const 2u32); -// StorageLive(_9); -// _9 = (const 0u32, const 3u32); -// StorageLive(_10); -// _10 = (const 0u32, const 1u32); -// StorageLive(_11); -// _11 = (const 0u32, const 2u32); -// StorageLive(_12); -// _12 = (const 0u32, const 3u32); -// StorageLive(_13); -// _13 = (const 0u32, const 1u32); -// StorageLive(_14); -// _14 = (const 0u32, const 2u32); -// StorageLive(_15); -// _15 = (const 0u32, const 3u32); -// StorageLive(_16); -// _16 = (const 0u32, const 1u32); -// StorageLive(_17); -// _17 = (const 0u32, const 2u32); -// StorageLive(_18); -// _18 = (const 0u32, const 3u32); -// StorageLive(_19); -// _19 = (const 0u32, const 1u32); -// StorageLive(_20); -// _20 = (const 0u32, const 2u32); -// StorageLive(_21); -// _21 = (const 0u32, const 3u32); -// StorageLive(_22); -// _22 = (const 0u32, const 1u32); -// StorageLive(_23); -// _23 = (const 0u32, const 2u32); -// StorageLive(_24); -// _24 = (const 0u32, const 3u32); -// StorageLive(_25); -// _25 = (const 0u32, const 1u32); -// StorageLive(_26); -// _26 = (const 0u32, const 2u32); -// StorageLive(_27); -// _27 = (const 0u32, const 3u32); -// StorageLive(_28); -// _28 = (const 0u32, const 1u32); -// StorageLive(_29); -// _29 = (const 0u32, const 2u32); -// StorageLive(_30); -// _30 = (const 0u32, const 3u32); -// StorageLive(_31); -// _31 = (const 0u32, const 1u32); -// StorageLive(_32); -// _32 = (const 0u32, const 2u32); -// StorageLive(_33); -// _33 = (const 0u32, const 3u32); -// StorageLive(_34); -// _34 = (const 0u32, const 1u32); -// StorageLive(_35); -// _35 = (const 0u32, const 2u32); -// StorageLive(_36); -// _36 = (const 0u32, const 3u32); -// StorageLive(_37); -// _37 = (const 0u32, const 1u32); -// StorageLive(_38); -// _38 = (const 0u32, const 2u32); -// StorageLive(_39); -// _39 = (const 0u32, const 3u32); -// StorageLive(_40); -// _40 = (const 0u32, const 1u32); -// StorageLive(_41); -// _41 = (const 0u32, const 2u32); -// StorageLive(_42); -// _42 = (const 0u32, const 3u32); -// StorageLive(_43); -// _43 = (const 0u32, const 1u32); -// StorageLive(_44); -// _44 = (const 0u32, const 2u32); -// StorageLive(_45); -// _45 = (const 0u32, const 3u32); -// StorageLive(_46); -// _46 = (const 0u32, const 1u32); -// StorageLive(_47); -// _47 = (const 0u32, const 2u32); -// StorageLive(_48); -// _48 = (const 0u32, const 3u32); -// _6 = [move _7, move _8, move _9, move _10, move _11, move _12, move _13, move _14, move _15, move _16, move _17, move _18, move _19, move _20, move _21, move _22, move _23, move _24, move _25, move _26, move _27, move _28, move _29, move _30, move _31, move _32, move _33, move _34, move _35, move _36, move _37, move _38, move _39, move _40, move _41, move _42, move _43, move _44, move _45, move _46, move _47, move _48]; -// _5 = &_6; -// _4 = &(*_5); -// _3 = move _4 as &[(u32, u32)] (Pointer(Unsize)); -// _2 = Foo { tup: const "hi", data: move _3 }; -// _1 = &_2; -// _0 = &(*_1); -// StorageDead(_5); -// StorageDead(_1); -// return; -// } -//} -// END rustc.XXX.mir_map.0.mir diff --git a/src/test/mir-opt/storage_live_dead_in_statics/rustc.XXX.mir_map.0.mir b/src/test/mir-opt/storage_live_dead_in_statics/rustc.XXX.mir_map.0.mir new file mode 100644 index 00000000000..5ea1e431d19 --- /dev/null +++ b/src/test/mir-opt/storage_live_dead_in_statics/rustc.XXX.mir_map.0.mir @@ -0,0 +1,670 @@ +// MIR for `XXX` 0 mir_map + +static XXX: &Foo = { + let mut _0: &Foo; // return place in scope 0 at $DIR/storage_live_dead_in_statics.rs:5:13: 5:25 + let _1: &Foo; // in scope 0 at $DIR/storage_live_dead_in_statics.rs:5:28: 23:2 + let _2: Foo; // in scope 0 at $DIR/storage_live_dead_in_statics.rs:5:29: 23:2 + let mut _3: &[(u32, u32)]; // in scope 0 at $DIR/storage_live_dead_in_statics.rs:7:11: 22:6 + let mut _4: &[(u32, u32); 42]; // in scope 0 at $DIR/storage_live_dead_in_statics.rs:7:11: 22:6 + let _5: &[(u32, u32); 42]; // in scope 0 at $DIR/storage_live_dead_in_statics.rs:7:11: 22:6 + let _6: [(u32, u32); 42]; // in scope 0 at $DIR/storage_live_dead_in_statics.rs:7:12: 22:6 + let mut _7: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:8:9: 8:15 + let mut _8: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:8:17: 8:23 + let mut _9: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:8:25: 8:31 + let mut _10: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:9:9: 9:15 + let mut _11: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:9:17: 9:23 + let mut _12: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:9:25: 9:31 + let mut _13: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:10:9: 10:15 + let mut _14: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:10:17: 10:23 + let mut _15: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:10:25: 10:31 + let mut _16: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:11:9: 11:15 + let mut _17: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:11:17: 11:23 + let mut _18: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:11:25: 11:31 + let mut _19: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:12:9: 12:15 + let mut _20: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:12:17: 12:23 + let mut _21: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:12:25: 12:31 + let mut _22: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:13:9: 13:15 + let mut _23: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:13:17: 13:23 + let mut _24: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:13:25: 13:31 + let mut _25: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:14:9: 14:15 + let mut _26: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:14:17: 14:23 + let mut _27: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:14:25: 14:31 + let mut _28: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:15:9: 15:15 + let mut _29: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:15:17: 15:23 + let mut _30: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:15:25: 15:31 + let mut _31: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:16:9: 16:15 + let mut _32: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:16:17: 16:23 + let mut _33: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:16:25: 16:31 + let mut _34: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:17:9: 17:15 + let mut _35: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:17:17: 17:23 + let mut _36: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:17:25: 17:31 + let mut _37: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:18:9: 18:15 + let mut _38: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:18:17: 18:23 + let mut _39: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:18:25: 18:31 + let mut _40: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:19:9: 19:15 + let mut _41: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:19:17: 19:23 + let mut _42: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:19:25: 19:31 + let mut _43: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:20:9: 20:15 + let mut _44: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:20:17: 20:23 + let mut _45: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:20:25: 20:31 + let mut _46: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:21:9: 21:15 + let mut _47: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:21:17: 21:23 + let mut _48: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:21:25: 21:31 + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/storage_live_dead_in_statics.rs:5:28: 23:2 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/storage_live_dead_in_statics.rs:5:29: 23:2 + StorageLive(_3); // bb0[2]: scope 0 at $DIR/storage_live_dead_in_statics.rs:7:11: 22:6 + StorageLive(_4); // bb0[3]: scope 0 at $DIR/storage_live_dead_in_statics.rs:7:11: 22:6 + StorageLive(_5); // bb0[4]: scope 0 at $DIR/storage_live_dead_in_statics.rs:7:11: 22:6 + StorageLive(_6); // bb0[5]: scope 0 at $DIR/storage_live_dead_in_statics.rs:7:12: 22:6 + StorageLive(_7); // bb0[6]: scope 0 at $DIR/storage_live_dead_in_statics.rs:8:9: 8:15 + _7 = (const 0u32, const 1u32); // bb0[7]: scope 0 at $DIR/storage_live_dead_in_statics.rs:8:9: 8:15 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:8:10: 8:11 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:8:13: 8:14 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) } + StorageLive(_8); // bb0[8]: scope 0 at $DIR/storage_live_dead_in_statics.rs:8:17: 8:23 + _8 = (const 0u32, const 2u32); // bb0[9]: scope 0 at $DIR/storage_live_dead_in_statics.rs:8:17: 8:23 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:8:18: 8:19 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:8:21: 8:22 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } + StorageLive(_9); // bb0[10]: scope 0 at $DIR/storage_live_dead_in_statics.rs:8:25: 8:31 + _9 = (const 0u32, const 3u32); // bb0[11]: scope 0 at $DIR/storage_live_dead_in_statics.rs:8:25: 8:31 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:8:26: 8:27 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:8:29: 8:30 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000003)) } + StorageLive(_10); // bb0[12]: scope 0 at $DIR/storage_live_dead_in_statics.rs:9:9: 9:15 + _10 = (const 0u32, const 1u32); // bb0[13]: scope 0 at $DIR/storage_live_dead_in_statics.rs:9:9: 9:15 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:9:10: 9:11 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:9:13: 9:14 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) } + StorageLive(_11); // bb0[14]: scope 0 at $DIR/storage_live_dead_in_statics.rs:9:17: 9:23 + _11 = (const 0u32, const 2u32); // bb0[15]: scope 0 at $DIR/storage_live_dead_in_statics.rs:9:17: 9:23 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:9:18: 9:19 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:9:21: 9:22 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } + StorageLive(_12); // bb0[16]: scope 0 at $DIR/storage_live_dead_in_statics.rs:9:25: 9:31 + _12 = (const 0u32, const 3u32); // bb0[17]: scope 0 at $DIR/storage_live_dead_in_statics.rs:9:25: 9:31 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:9:26: 9:27 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:9:29: 9:30 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000003)) } + StorageLive(_13); // bb0[18]: scope 0 at $DIR/storage_live_dead_in_statics.rs:10:9: 10:15 + _13 = (const 0u32, const 1u32); // bb0[19]: scope 0 at $DIR/storage_live_dead_in_statics.rs:10:9: 10:15 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:10:10: 10:11 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:10:13: 10:14 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) } + StorageLive(_14); // bb0[20]: scope 0 at $DIR/storage_live_dead_in_statics.rs:10:17: 10:23 + _14 = (const 0u32, const 2u32); // bb0[21]: scope 0 at $DIR/storage_live_dead_in_statics.rs:10:17: 10:23 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:10:18: 10:19 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:10:21: 10:22 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } + StorageLive(_15); // bb0[22]: scope 0 at $DIR/storage_live_dead_in_statics.rs:10:25: 10:31 + _15 = (const 0u32, const 3u32); // bb0[23]: scope 0 at $DIR/storage_live_dead_in_statics.rs:10:25: 10:31 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:10:26: 10:27 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:10:29: 10:30 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000003)) } + StorageLive(_16); // bb0[24]: scope 0 at $DIR/storage_live_dead_in_statics.rs:11:9: 11:15 + _16 = (const 0u32, const 1u32); // bb0[25]: scope 0 at $DIR/storage_live_dead_in_statics.rs:11:9: 11:15 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:11:10: 11:11 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:11:13: 11:14 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) } + StorageLive(_17); // bb0[26]: scope 0 at $DIR/storage_live_dead_in_statics.rs:11:17: 11:23 + _17 = (const 0u32, const 2u32); // bb0[27]: scope 0 at $DIR/storage_live_dead_in_statics.rs:11:17: 11:23 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:11:18: 11:19 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:11:21: 11:22 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } + StorageLive(_18); // bb0[28]: scope 0 at $DIR/storage_live_dead_in_statics.rs:11:25: 11:31 + _18 = (const 0u32, const 3u32); // bb0[29]: scope 0 at $DIR/storage_live_dead_in_statics.rs:11:25: 11:31 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:11:26: 11:27 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:11:29: 11:30 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000003)) } + StorageLive(_19); // bb0[30]: scope 0 at $DIR/storage_live_dead_in_statics.rs:12:9: 12:15 + _19 = (const 0u32, const 1u32); // bb0[31]: scope 0 at $DIR/storage_live_dead_in_statics.rs:12:9: 12:15 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:12:10: 12:11 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:12:13: 12:14 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) } + StorageLive(_20); // bb0[32]: scope 0 at $DIR/storage_live_dead_in_statics.rs:12:17: 12:23 + _20 = (const 0u32, const 2u32); // bb0[33]: scope 0 at $DIR/storage_live_dead_in_statics.rs:12:17: 12:23 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:12:18: 12:19 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:12:21: 12:22 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } + StorageLive(_21); // bb0[34]: scope 0 at $DIR/storage_live_dead_in_statics.rs:12:25: 12:31 + _21 = (const 0u32, const 3u32); // bb0[35]: scope 0 at $DIR/storage_live_dead_in_statics.rs:12:25: 12:31 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:12:26: 12:27 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:12:29: 12:30 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000003)) } + StorageLive(_22); // bb0[36]: scope 0 at $DIR/storage_live_dead_in_statics.rs:13:9: 13:15 + _22 = (const 0u32, const 1u32); // bb0[37]: scope 0 at $DIR/storage_live_dead_in_statics.rs:13:9: 13:15 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:13:10: 13:11 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:13:13: 13:14 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) } + StorageLive(_23); // bb0[38]: scope 0 at $DIR/storage_live_dead_in_statics.rs:13:17: 13:23 + _23 = (const 0u32, const 2u32); // bb0[39]: scope 0 at $DIR/storage_live_dead_in_statics.rs:13:17: 13:23 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:13:18: 13:19 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:13:21: 13:22 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } + StorageLive(_24); // bb0[40]: scope 0 at $DIR/storage_live_dead_in_statics.rs:13:25: 13:31 + _24 = (const 0u32, const 3u32); // bb0[41]: scope 0 at $DIR/storage_live_dead_in_statics.rs:13:25: 13:31 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:13:26: 13:27 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:13:29: 13:30 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000003)) } + StorageLive(_25); // bb0[42]: scope 0 at $DIR/storage_live_dead_in_statics.rs:14:9: 14:15 + _25 = (const 0u32, const 1u32); // bb0[43]: scope 0 at $DIR/storage_live_dead_in_statics.rs:14:9: 14:15 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:14:10: 14:11 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:14:13: 14:14 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) } + StorageLive(_26); // bb0[44]: scope 0 at $DIR/storage_live_dead_in_statics.rs:14:17: 14:23 + _26 = (const 0u32, const 2u32); // bb0[45]: scope 0 at $DIR/storage_live_dead_in_statics.rs:14:17: 14:23 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:14:18: 14:19 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:14:21: 14:22 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } + StorageLive(_27); // bb0[46]: scope 0 at $DIR/storage_live_dead_in_statics.rs:14:25: 14:31 + _27 = (const 0u32, const 3u32); // bb0[47]: scope 0 at $DIR/storage_live_dead_in_statics.rs:14:25: 14:31 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:14:26: 14:27 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:14:29: 14:30 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000003)) } + StorageLive(_28); // bb0[48]: scope 0 at $DIR/storage_live_dead_in_statics.rs:15:9: 15:15 + _28 = (const 0u32, const 1u32); // bb0[49]: scope 0 at $DIR/storage_live_dead_in_statics.rs:15:9: 15:15 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:15:10: 15:11 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:15:13: 15:14 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) } + StorageLive(_29); // bb0[50]: scope 0 at $DIR/storage_live_dead_in_statics.rs:15:17: 15:23 + _29 = (const 0u32, const 2u32); // bb0[51]: scope 0 at $DIR/storage_live_dead_in_statics.rs:15:17: 15:23 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:15:18: 15:19 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:15:21: 15:22 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } + StorageLive(_30); // bb0[52]: scope 0 at $DIR/storage_live_dead_in_statics.rs:15:25: 15:31 + _30 = (const 0u32, const 3u32); // bb0[53]: scope 0 at $DIR/storage_live_dead_in_statics.rs:15:25: 15:31 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:15:26: 15:27 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:15:29: 15:30 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000003)) } + StorageLive(_31); // bb0[54]: scope 0 at $DIR/storage_live_dead_in_statics.rs:16:9: 16:15 + _31 = (const 0u32, const 1u32); // bb0[55]: scope 0 at $DIR/storage_live_dead_in_statics.rs:16:9: 16:15 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:16:10: 16:11 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:16:13: 16:14 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) } + StorageLive(_32); // bb0[56]: scope 0 at $DIR/storage_live_dead_in_statics.rs:16:17: 16:23 + _32 = (const 0u32, const 2u32); // bb0[57]: scope 0 at $DIR/storage_live_dead_in_statics.rs:16:17: 16:23 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:16:18: 16:19 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:16:21: 16:22 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } + StorageLive(_33); // bb0[58]: scope 0 at $DIR/storage_live_dead_in_statics.rs:16:25: 16:31 + _33 = (const 0u32, const 3u32); // bb0[59]: scope 0 at $DIR/storage_live_dead_in_statics.rs:16:25: 16:31 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:16:26: 16:27 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:16:29: 16:30 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000003)) } + StorageLive(_34); // bb0[60]: scope 0 at $DIR/storage_live_dead_in_statics.rs:17:9: 17:15 + _34 = (const 0u32, const 1u32); // bb0[61]: scope 0 at $DIR/storage_live_dead_in_statics.rs:17:9: 17:15 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:17:10: 17:11 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:17:13: 17:14 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) } + StorageLive(_35); // bb0[62]: scope 0 at $DIR/storage_live_dead_in_statics.rs:17:17: 17:23 + _35 = (const 0u32, const 2u32); // bb0[63]: scope 0 at $DIR/storage_live_dead_in_statics.rs:17:17: 17:23 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:17:18: 17:19 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:17:21: 17:22 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } + StorageLive(_36); // bb0[64]: scope 0 at $DIR/storage_live_dead_in_statics.rs:17:25: 17:31 + _36 = (const 0u32, const 3u32); // bb0[65]: scope 0 at $DIR/storage_live_dead_in_statics.rs:17:25: 17:31 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:17:26: 17:27 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:17:29: 17:30 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000003)) } + StorageLive(_37); // bb0[66]: scope 0 at $DIR/storage_live_dead_in_statics.rs:18:9: 18:15 + _37 = (const 0u32, const 1u32); // bb0[67]: scope 0 at $DIR/storage_live_dead_in_statics.rs:18:9: 18:15 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:18:10: 18:11 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:18:13: 18:14 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) } + StorageLive(_38); // bb0[68]: scope 0 at $DIR/storage_live_dead_in_statics.rs:18:17: 18:23 + _38 = (const 0u32, const 2u32); // bb0[69]: scope 0 at $DIR/storage_live_dead_in_statics.rs:18:17: 18:23 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:18:18: 18:19 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:18:21: 18:22 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } + StorageLive(_39); // bb0[70]: scope 0 at $DIR/storage_live_dead_in_statics.rs:18:25: 18:31 + _39 = (const 0u32, const 3u32); // bb0[71]: scope 0 at $DIR/storage_live_dead_in_statics.rs:18:25: 18:31 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:18:26: 18:27 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:18:29: 18:30 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000003)) } + StorageLive(_40); // bb0[72]: scope 0 at $DIR/storage_live_dead_in_statics.rs:19:9: 19:15 + _40 = (const 0u32, const 1u32); // bb0[73]: scope 0 at $DIR/storage_live_dead_in_statics.rs:19:9: 19:15 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:19:10: 19:11 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:19:13: 19:14 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) } + StorageLive(_41); // bb0[74]: scope 0 at $DIR/storage_live_dead_in_statics.rs:19:17: 19:23 + _41 = (const 0u32, const 2u32); // bb0[75]: scope 0 at $DIR/storage_live_dead_in_statics.rs:19:17: 19:23 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:19:18: 19:19 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:19:21: 19:22 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } + StorageLive(_42); // bb0[76]: scope 0 at $DIR/storage_live_dead_in_statics.rs:19:25: 19:31 + _42 = (const 0u32, const 3u32); // bb0[77]: scope 0 at $DIR/storage_live_dead_in_statics.rs:19:25: 19:31 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:19:26: 19:27 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:19:29: 19:30 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000003)) } + StorageLive(_43); // bb0[78]: scope 0 at $DIR/storage_live_dead_in_statics.rs:20:9: 20:15 + _43 = (const 0u32, const 1u32); // bb0[79]: scope 0 at $DIR/storage_live_dead_in_statics.rs:20:9: 20:15 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:20:10: 20:11 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:20:13: 20:14 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) } + StorageLive(_44); // bb0[80]: scope 0 at $DIR/storage_live_dead_in_statics.rs:20:17: 20:23 + _44 = (const 0u32, const 2u32); // bb0[81]: scope 0 at $DIR/storage_live_dead_in_statics.rs:20:17: 20:23 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:20:18: 20:19 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:20:21: 20:22 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } + StorageLive(_45); // bb0[82]: scope 0 at $DIR/storage_live_dead_in_statics.rs:20:25: 20:31 + _45 = (const 0u32, const 3u32); // bb0[83]: scope 0 at $DIR/storage_live_dead_in_statics.rs:20:25: 20:31 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:20:26: 20:27 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:20:29: 20:30 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000003)) } + StorageLive(_46); // bb0[84]: scope 0 at $DIR/storage_live_dead_in_statics.rs:21:9: 21:15 + _46 = (const 0u32, const 1u32); // bb0[85]: scope 0 at $DIR/storage_live_dead_in_statics.rs:21:9: 21:15 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:21:10: 21:11 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:21:13: 21:14 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000001)) } + StorageLive(_47); // bb0[86]: scope 0 at $DIR/storage_live_dead_in_statics.rs:21:17: 21:23 + _47 = (const 0u32, const 2u32); // bb0[87]: scope 0 at $DIR/storage_live_dead_in_statics.rs:21:17: 21:23 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:21:18: 21:19 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:21:21: 21:22 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000002)) } + StorageLive(_48); // bb0[88]: scope 0 at $DIR/storage_live_dead_in_statics.rs:21:25: 21:31 + _48 = (const 0u32, const 3u32); // bb0[89]: scope 0 at $DIR/storage_live_dead_in_statics.rs:21:25: 21:31 + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:21:26: 21:27 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000000)) } + // ty::Const + // + ty: u32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:21:29: 21:30 + // + literal: Const { ty: u32, val: Value(Scalar(0x00000003)) } + _6 = [move _7, move _8, move _9, move _10, move _11, move _12, move _13, move _14, move _15, move _16, move _17, move _18, move _19, move _20, move _21, move _22, move _23, move _24, move _25, move _26, move _27, move _28, move _29, move _30, move _31, move _32, move _33, move _34, move _35, move _36, move _37, move _38, move _39, move _40, move _41, move _42, move _43, move _44, move _45, move _46, move _47, move _48]; // bb0[90]: scope 0 at $DIR/storage_live_dead_in_statics.rs:7:12: 22:6 + _5 = &_6; // bb0[91]: scope 0 at $DIR/storage_live_dead_in_statics.rs:7:11: 22:6 + _4 = &(*_5); // bb0[92]: scope 0 at $DIR/storage_live_dead_in_statics.rs:7:11: 22:6 + _3 = move _4 as &[(u32, u32)] (Pointer(Unsize)); // bb0[93]: scope 0 at $DIR/storage_live_dead_in_statics.rs:7:11: 22:6 + _2 = Foo { tup: const "hi", data: move _3 }; // bb0[94]: scope 0 at $DIR/storage_live_dead_in_statics.rs:5:29: 23:2 + // ty::Const + // + ty: &str + // + val: Value(Slice { data: Allocation { bytes: [104, 105], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [3], len: Size { raw: 2 } }, size: Size { raw: 2 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 2 }) + // mir::Constant + // + span: $DIR/storage_live_dead_in_statics.rs:6:10: 6:14 + // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [104, 105], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [3], len: Size { raw: 2 } }, size: Size { raw: 2 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 2 }) } + _1 = &_2; // bb0[95]: scope 0 at $DIR/storage_live_dead_in_statics.rs:5:28: 23:2 + _0 = &(*_1); // bb0[96]: scope 0 at $DIR/storage_live_dead_in_statics.rs:5:28: 23:2 + StorageDead(_5); // bb0[97]: scope 0 at $DIR/storage_live_dead_in_statics.rs:23:1: 23:2 + StorageDead(_1); // bb0[98]: scope 0 at $DIR/storage_live_dead_in_statics.rs:23:1: 23:2 + return; // bb0[99]: scope 0 at $DIR/storage_live_dead_in_statics.rs:5:1: 23:3 + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/storage_live_dead_in_statics.rs:5:1: 23:3 + } +} diff --git a/src/test/mir-opt/storage_ranges.rs b/src/test/mir-opt/storage_ranges.rs index 95570ff76a6..7b3c77aca27 100644 --- a/src/test/mir-opt/storage_ranges.rs +++ b/src/test/mir-opt/storage_ranges.rs @@ -1,3 +1,5 @@ +// EMIT_MIR rustc.main.nll.0.mir + fn main() { let a = 0; { @@ -5,32 +7,3 @@ fn main() { } let c = 1; } - -// END RUST SOURCE -// START rustc.main.nll.0.mir -// bb0: { -// StorageLive(_1); -// _1 = const 0i32; -// FakeRead(ForLet, _1); -// StorageLive(_2); -// StorageLive(_3); -// StorageLive(_4); -// StorageLive(_5); -// _5 = _1; -// _4 = std::option::Option::<i32>::Some(move _5,); -// StorageDead(_5); -// _3 = &_4; -// FakeRead(ForLet, _3); -// _2 = (); -// StorageDead(_4); -// StorageDead(_3); -// StorageDead(_2); -// StorageLive(_6); -// _6 = const 1i32; -// FakeRead(ForLet, _6); -// _0 = (); -// StorageDead(_6); -// StorageDead(_1); -// return; -// } -// END rustc.main.nll.0.mir diff --git a/src/test/mir-opt/storage_ranges/rustc.main.nll.0.mir b/src/test/mir-opt/storage_ranges/rustc.main.nll.0.mir new file mode 100644 index 00000000000..57ec47346e8 --- /dev/null +++ b/src/test/mir-opt/storage_ranges/rustc.main.nll.0.mir @@ -0,0 +1,75 @@ +// MIR for `main` 0 nll + +| Free Region Mapping +| '_#0r | Global | ['_#0r, '_#1r] +| '_#1r | Local | ['_#1r] +| +| Inferred Region Values +| '_#0r | U0 | {bb0[0..=22], '_#0r, '_#1r} +| '_#1r | U0 | {bb0[0..=22], '_#1r} +| '_#2r | U0 | {bb0[10..=11]} +| '_#3r | U0 | {bb0[11]} +| +| Inference Constraints +| '_#0r live at {bb0[0..=22]} +| '_#1r live at {bb0[0..=22]} +| '_#2r live at {bb0[10]} +| '_#3r live at {bb0[11]} +| '_#2r: '_#3r due to Assignment at Single(bb0[10]) +| +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/storage_ranges.rs:3:11: 3:11 + let _1: i32; // in scope 0 at $DIR/storage_ranges.rs:4:9: 4:10 + let _2: (); // in scope 0 at $DIR/storage_ranges.rs:5:5: 7:6 + let _4: std::option::Option<i32>; // in scope 0 at $DIR/storage_ranges.rs:6:18: 6:25 + let mut _5: i32; // in scope 0 at $DIR/storage_ranges.rs:6:23: 6:24 + scope 1 { + debug a => _1; // in scope 1 at $DIR/storage_ranges.rs:4:9: 4:10 + let _3: &std::option::Option<i32>; // in scope 1 at $DIR/storage_ranges.rs:6:13: 6:14 + let _6: i32; // in scope 1 at $DIR/storage_ranges.rs:8:9: 8:10 + scope 2 { + debug b => _3; // in scope 2 at $DIR/storage_ranges.rs:6:13: 6:14 + } + scope 3 { + debug c => _6; // in scope 3 at $DIR/storage_ranges.rs:8:9: 8:10 + } + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/storage_ranges.rs:4:9: 4:10 + _1 = const 0i32; // bb0[1]: scope 0 at $DIR/storage_ranges.rs:4:13: 4:14 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000000)) + // mir::Constant + // + span: $DIR/storage_ranges.rs:4:13: 4:14 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } + FakeRead(ForLet, _1); // bb0[2]: scope 0 at $DIR/storage_ranges.rs:4:9: 4:10 + StorageLive(_2); // bb0[3]: scope 1 at $DIR/storage_ranges.rs:5:5: 7:6 + StorageLive(_3); // bb0[4]: scope 1 at $DIR/storage_ranges.rs:6:13: 6:14 + StorageLive(_4); // bb0[5]: scope 1 at $DIR/storage_ranges.rs:6:18: 6:25 + StorageLive(_5); // bb0[6]: scope 1 at $DIR/storage_ranges.rs:6:23: 6:24 + _5 = _1; // bb0[7]: scope 1 at $DIR/storage_ranges.rs:6:23: 6:24 + _4 = std::option::Option::<i32>::Some(move _5,); // bb0[8]: scope 1 at $DIR/storage_ranges.rs:6:18: 6:25 + StorageDead(_5); // bb0[9]: scope 1 at $DIR/storage_ranges.rs:6:24: 6:25 + _3 = &_4; // bb0[10]: scope 1 at $DIR/storage_ranges.rs:6:17: 6:25 + FakeRead(ForLet, _3); // bb0[11]: scope 1 at $DIR/storage_ranges.rs:6:13: 6:14 + _2 = (); // bb0[12]: scope 1 at $DIR/storage_ranges.rs:5:5: 7:6 + StorageDead(_4); // bb0[13]: scope 1 at $DIR/storage_ranges.rs:7:5: 7:6 + StorageDead(_3); // bb0[14]: scope 1 at $DIR/storage_ranges.rs:7:5: 7:6 + StorageDead(_2); // bb0[15]: scope 1 at $DIR/storage_ranges.rs:7:5: 7:6 + StorageLive(_6); // bb0[16]: scope 1 at $DIR/storage_ranges.rs:8:9: 8:10 + _6 = const 1i32; // bb0[17]: scope 1 at $DIR/storage_ranges.rs:8:13: 8:14 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/storage_ranges.rs:8:13: 8:14 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } + FakeRead(ForLet, _6); // bb0[18]: scope 1 at $DIR/storage_ranges.rs:8:9: 8:10 + _0 = (); // bb0[19]: scope 0 at $DIR/storage_ranges.rs:3:11: 9:2 + StorageDead(_6); // bb0[20]: scope 1 at $DIR/storage_ranges.rs:9:1: 9:2 + StorageDead(_1); // bb0[21]: scope 0 at $DIR/storage_ranges.rs:9:1: 9:2 + return; // bb0[22]: scope 0 at $DIR/storage_ranges.rs:9:2: 9:2 + } +} diff --git a/src/test/mir-opt/uniform_array_move_out.rs b/src/test/mir-opt/uniform_array_move_out.rs index d587d237227..c1b7ebdbc3a 100644 --- a/src/test/mir-opt/uniform_array_move_out.rs +++ b/src/test/mir-opt/uniform_array_move_out.rs @@ -1,10 +1,12 @@ #![feature(box_syntax)] +// EMIT_MIR rustc.move_out_from_end.mir_map.0.mir fn move_out_from_end() { let a = [box 1, box 2]; let [.., _y] = a; } +// EMIT_MIR rustc.move_out_by_subslice.mir_map.0.mir fn move_out_by_subslice() { let a = [box 1, box 2]; let [_y @ ..] = a; @@ -14,15 +16,3 @@ fn main() { move_out_by_subslice(); move_out_from_end(); } - -// END RUST SOURCE - -// START rustc.move_out_from_end.mir_map.0.mir -// _6 = move _1[1 of 2]; -// _0 = (); -// END rustc.move_out_from_end.mir_map.0.mir - -// START rustc.move_out_by_subslice.mir_map.0.mir -// _6 = move _1[0..2]; -// _0 = (); -// END rustc.move_out_by_subslice.mir_map.0.mir diff --git a/src/test/mir-opt/uniform_array_move_out/rustc.move_out_by_subslice.mir_map.0.mir b/src/test/mir-opt/uniform_array_move_out/rustc.move_out_by_subslice.mir_map.0.mir new file mode 100644 index 00000000000..5dbee8f7b3d --- /dev/null +++ b/src/test/mir-opt/uniform_array_move_out/rustc.move_out_by_subslice.mir_map.0.mir @@ -0,0 +1,111 @@ +// MIR for `move_out_by_subslice` 0 mir_map + +fn move_out_by_subslice() -> () { + let mut _0: (); // return place in scope 0 at $DIR/uniform_array_move_out.rs:10:27: 10:27 + let _1: [std::boxed::Box<i32>; 2]; // in scope 0 at $DIR/uniform_array_move_out.rs:11:9: 11:10 + let mut _2: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:11:14: 11:19 + let mut _3: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:11:14: 11:19 + let mut _4: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:11:21: 11:26 + let mut _5: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:11:21: 11:26 + scope 1 { + debug a => _1; // in scope 1 at $DIR/uniform_array_move_out.rs:11:9: 11:10 + let _6: [std::boxed::Box<i32>; 2]; // in scope 1 at $DIR/uniform_array_move_out.rs:12:10: 12:17 + scope 2 { + debug _y => _6; // in scope 2 at $DIR/uniform_array_move_out.rs:12:10: 12:17 + } + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/uniform_array_move_out.rs:11:9: 11:10 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/uniform_array_move_out.rs:11:14: 11:19 + StorageLive(_3); // bb0[2]: scope 0 at $DIR/uniform_array_move_out.rs:11:14: 11:19 + _3 = Box(i32); // bb0[3]: scope 0 at $DIR/uniform_array_move_out.rs:11:14: 11:19 + (*_3) = const 1i32; // bb0[4]: scope 0 at $DIR/uniform_array_move_out.rs:11:18: 11:19 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/uniform_array_move_out.rs:11:18: 11:19 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } + _2 = move _3; // bb0[5]: scope 0 at $DIR/uniform_array_move_out.rs:11:14: 11:19 + drop(_3) -> [return: bb4, unwind: bb2]; // bb0[6]: scope 0 at $DIR/uniform_array_move_out.rs:11:18: 11:19 + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/uniform_array_move_out.rs:10:1: 13:2 + } + + bb2 (cleanup): { + drop(_2) -> bb1; // bb2[0]: scope 0 at $DIR/uniform_array_move_out.rs:11:26: 11:27 + } + + bb3 (cleanup): { + drop(_3) -> bb2; // bb3[0]: scope 0 at $DIR/uniform_array_move_out.rs:11:18: 11:19 + } + + bb4: { + StorageDead(_3); // bb4[0]: scope 0 at $DIR/uniform_array_move_out.rs:11:18: 11:19 + StorageLive(_4); // bb4[1]: scope 0 at $DIR/uniform_array_move_out.rs:11:21: 11:26 + StorageLive(_5); // bb4[2]: scope 0 at $DIR/uniform_array_move_out.rs:11:21: 11:26 + _5 = Box(i32); // bb4[3]: scope 0 at $DIR/uniform_array_move_out.rs:11:21: 11:26 + (*_5) = const 2i32; // bb4[4]: scope 0 at $DIR/uniform_array_move_out.rs:11:25: 11:26 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/uniform_array_move_out.rs:11:25: 11:26 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } + _4 = move _5; // bb4[5]: scope 0 at $DIR/uniform_array_move_out.rs:11:21: 11:26 + drop(_5) -> [return: bb7, unwind: bb5]; // bb4[6]: scope 0 at $DIR/uniform_array_move_out.rs:11:25: 11:26 + } + + bb5 (cleanup): { + drop(_4) -> bb2; // bb5[0]: scope 0 at $DIR/uniform_array_move_out.rs:11:26: 11:27 + } + + bb6 (cleanup): { + drop(_5) -> bb5; // bb6[0]: scope 0 at $DIR/uniform_array_move_out.rs:11:25: 11:26 + } + + bb7: { + StorageDead(_5); // bb7[0]: scope 0 at $DIR/uniform_array_move_out.rs:11:25: 11:26 + _1 = [move _2, move _4]; // bb7[1]: scope 0 at $DIR/uniform_array_move_out.rs:11:13: 11:27 + drop(_4) -> [return: bb8, unwind: bb2]; // bb7[2]: scope 0 at $DIR/uniform_array_move_out.rs:11:26: 11:27 + } + + bb8: { + StorageDead(_4); // bb8[0]: scope 0 at $DIR/uniform_array_move_out.rs:11:26: 11:27 + drop(_2) -> [return: bb9, unwind: bb1]; // bb8[1]: scope 0 at $DIR/uniform_array_move_out.rs:11:26: 11:27 + } + + bb9: { + StorageDead(_2); // bb9[0]: scope 0 at $DIR/uniform_array_move_out.rs:11:26: 11:27 + FakeRead(ForLet, _1); // bb9[1]: scope 0 at $DIR/uniform_array_move_out.rs:11:9: 11:10 + StorageLive(_6); // bb9[2]: scope 1 at $DIR/uniform_array_move_out.rs:12:10: 12:17 + _6 = move _1[0..2]; // bb9[3]: scope 1 at $DIR/uniform_array_move_out.rs:12:10: 12:17 + _0 = (); // bb9[4]: scope 0 at $DIR/uniform_array_move_out.rs:10:27: 13:2 + drop(_6) -> [return: bb12, unwind: bb10]; // bb9[5]: scope 1 at $DIR/uniform_array_move_out.rs:13:1: 13:2 + } + + bb10 (cleanup): { + drop(_1) -> bb1; // bb10[0]: scope 0 at $DIR/uniform_array_move_out.rs:13:1: 13:2 + } + + bb11 (cleanup): { + drop(_6) -> bb10; // bb11[0]: scope 1 at $DIR/uniform_array_move_out.rs:13:1: 13:2 + } + + bb12: { + StorageDead(_6); // bb12[0]: scope 1 at $DIR/uniform_array_move_out.rs:13:1: 13:2 + drop(_1) -> [return: bb13, unwind: bb1]; // bb12[1]: scope 0 at $DIR/uniform_array_move_out.rs:13:1: 13:2 + } + + bb13: { + StorageDead(_1); // bb13[0]: scope 0 at $DIR/uniform_array_move_out.rs:13:1: 13:2 + goto -> bb14; // bb13[1]: scope 0 at $DIR/uniform_array_move_out.rs:13:2: 13:2 + } + + bb14: { + return; // bb14[0]: scope 0 at $DIR/uniform_array_move_out.rs:13:2: 13:2 + } +} diff --git a/src/test/mir-opt/uniform_array_move_out/rustc.move_out_from_end.mir_map.0.mir b/src/test/mir-opt/uniform_array_move_out/rustc.move_out_from_end.mir_map.0.mir new file mode 100644 index 00000000000..4a5cd625c9d --- /dev/null +++ b/src/test/mir-opt/uniform_array_move_out/rustc.move_out_from_end.mir_map.0.mir @@ -0,0 +1,111 @@ +// MIR for `move_out_from_end` 0 mir_map + +fn move_out_from_end() -> () { + let mut _0: (); // return place in scope 0 at $DIR/uniform_array_move_out.rs:4:24: 4:24 + let _1: [std::boxed::Box<i32>; 2]; // in scope 0 at $DIR/uniform_array_move_out.rs:5:9: 5:10 + let mut _2: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:5:14: 5:19 + let mut _3: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:5:14: 5:19 + let mut _4: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:5:21: 5:26 + let mut _5: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:5:21: 5:26 + scope 1 { + debug a => _1; // in scope 1 at $DIR/uniform_array_move_out.rs:5:9: 5:10 + let _6: std::boxed::Box<i32>; // in scope 1 at $DIR/uniform_array_move_out.rs:6:14: 6:16 + scope 2 { + debug _y => _6; // in scope 2 at $DIR/uniform_array_move_out.rs:6:14: 6:16 + } + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/uniform_array_move_out.rs:5:9: 5:10 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/uniform_array_move_out.rs:5:14: 5:19 + StorageLive(_3); // bb0[2]: scope 0 at $DIR/uniform_array_move_out.rs:5:14: 5:19 + _3 = Box(i32); // bb0[3]: scope 0 at $DIR/uniform_array_move_out.rs:5:14: 5:19 + (*_3) = const 1i32; // bb0[4]: scope 0 at $DIR/uniform_array_move_out.rs:5:18: 5:19 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/uniform_array_move_out.rs:5:18: 5:19 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } + _2 = move _3; // bb0[5]: scope 0 at $DIR/uniform_array_move_out.rs:5:14: 5:19 + drop(_3) -> [return: bb4, unwind: bb2]; // bb0[6]: scope 0 at $DIR/uniform_array_move_out.rs:5:18: 5:19 + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/uniform_array_move_out.rs:4:1: 7:2 + } + + bb2 (cleanup): { + drop(_2) -> bb1; // bb2[0]: scope 0 at $DIR/uniform_array_move_out.rs:5:26: 5:27 + } + + bb3 (cleanup): { + drop(_3) -> bb2; // bb3[0]: scope 0 at $DIR/uniform_array_move_out.rs:5:18: 5:19 + } + + bb4: { + StorageDead(_3); // bb4[0]: scope 0 at $DIR/uniform_array_move_out.rs:5:18: 5:19 + StorageLive(_4); // bb4[1]: scope 0 at $DIR/uniform_array_move_out.rs:5:21: 5:26 + StorageLive(_5); // bb4[2]: scope 0 at $DIR/uniform_array_move_out.rs:5:21: 5:26 + _5 = Box(i32); // bb4[3]: scope 0 at $DIR/uniform_array_move_out.rs:5:21: 5:26 + (*_5) = const 2i32; // bb4[4]: scope 0 at $DIR/uniform_array_move_out.rs:5:25: 5:26 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/uniform_array_move_out.rs:5:25: 5:26 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } + _4 = move _5; // bb4[5]: scope 0 at $DIR/uniform_array_move_out.rs:5:21: 5:26 + drop(_5) -> [return: bb7, unwind: bb5]; // bb4[6]: scope 0 at $DIR/uniform_array_move_out.rs:5:25: 5:26 + } + + bb5 (cleanup): { + drop(_4) -> bb2; // bb5[0]: scope 0 at $DIR/uniform_array_move_out.rs:5:26: 5:27 + } + + bb6 (cleanup): { + drop(_5) -> bb5; // bb6[0]: scope 0 at $DIR/uniform_array_move_out.rs:5:25: 5:26 + } + + bb7: { + StorageDead(_5); // bb7[0]: scope 0 at $DIR/uniform_array_move_out.rs:5:25: 5:26 + _1 = [move _2, move _4]; // bb7[1]: scope 0 at $DIR/uniform_array_move_out.rs:5:13: 5:27 + drop(_4) -> [return: bb8, unwind: bb2]; // bb7[2]: scope 0 at $DIR/uniform_array_move_out.rs:5:26: 5:27 + } + + bb8: { + StorageDead(_4); // bb8[0]: scope 0 at $DIR/uniform_array_move_out.rs:5:26: 5:27 + drop(_2) -> [return: bb9, unwind: bb1]; // bb8[1]: scope 0 at $DIR/uniform_array_move_out.rs:5:26: 5:27 + } + + bb9: { + StorageDead(_2); // bb9[0]: scope 0 at $DIR/uniform_array_move_out.rs:5:26: 5:27 + FakeRead(ForLet, _1); // bb9[1]: scope 0 at $DIR/uniform_array_move_out.rs:5:9: 5:10 + StorageLive(_6); // bb9[2]: scope 1 at $DIR/uniform_array_move_out.rs:6:14: 6:16 + _6 = move _1[1 of 2]; // bb9[3]: scope 1 at $DIR/uniform_array_move_out.rs:6:14: 6:16 + _0 = (); // bb9[4]: scope 0 at $DIR/uniform_array_move_out.rs:4:24: 7:2 + drop(_6) -> [return: bb12, unwind: bb10]; // bb9[5]: scope 1 at $DIR/uniform_array_move_out.rs:7:1: 7:2 + } + + bb10 (cleanup): { + drop(_1) -> bb1; // bb10[0]: scope 0 at $DIR/uniform_array_move_out.rs:7:1: 7:2 + } + + bb11 (cleanup): { + drop(_6) -> bb10; // bb11[0]: scope 1 at $DIR/uniform_array_move_out.rs:7:1: 7:2 + } + + bb12: { + StorageDead(_6); // bb12[0]: scope 1 at $DIR/uniform_array_move_out.rs:7:1: 7:2 + drop(_1) -> [return: bb13, unwind: bb1]; // bb12[1]: scope 0 at $DIR/uniform_array_move_out.rs:7:1: 7:2 + } + + bb13: { + StorageDead(_1); // bb13[0]: scope 0 at $DIR/uniform_array_move_out.rs:7:1: 7:2 + goto -> bb14; // bb13[1]: scope 0 at $DIR/uniform_array_move_out.rs:7:2: 7:2 + } + + bb14: { + return; // bb14[0]: scope 0 at $DIR/uniform_array_move_out.rs:7:2: 7:2 + } +} diff --git a/src/test/mir-opt/uninhabited-enum.rs b/src/test/mir-opt/uninhabited-enum.rs index 904a9c43c1b..6503e193608 100644 --- a/src/test/mir-opt/uninhabited-enum.rs +++ b/src/test/mir-opt/uninhabited-enum.rs @@ -2,11 +2,13 @@ pub enum Void {} +// EMIT_MIR rustc.process_never.SimplifyLocals.after.mir #[no_mangle] pub fn process_never(input: *const !) { let _input = unsafe { &*input }; } +// EMIT_MIR rustc.process_void.SimplifyLocals.after.mir #[no_mangle] pub fn process_void(input: *const Void) { let _input = unsafe { &*input }; @@ -15,23 +17,3 @@ pub fn process_void(input: *const Void) { } fn main() {} - -// END RUST SOURCE -// -// START rustc.process_never.SimplifyLocals.after.mir -// bb0: { -// StorageLive(_2); -// _2 = &(*_1); -// StorageDead(_2); -// unreachable; -// } -// END rustc.process_never.SimplifyLocals.after.mir -// -// START rustc.process_void.SimplifyLocals.after.mir -// bb0: { -// StorageLive(_2); -// _2 = &(*_1); -// StorageDead(_2); -// return; -// } -// END rustc.process_void.SimplifyLocals.after.mir diff --git a/src/test/mir-opt/uninhabited-enum/rustc.process_never.SimplifyLocals.after.mir b/src/test/mir-opt/uninhabited-enum/rustc.process_never.SimplifyLocals.after.mir new file mode 100644 index 00000000000..f2c87336608 --- /dev/null +++ b/src/test/mir-opt/uninhabited-enum/rustc.process_never.SimplifyLocals.after.mir @@ -0,0 +1,19 @@ +// MIR for `process_never` after SimplifyLocals + +fn process_never(_1: *const !) -> () { + debug input => _1; // in scope 0 at $DIR/uninhabited-enum.rs:7:22: 7:27 + let mut _0: (); // return place in scope 0 at $DIR/uninhabited-enum.rs:7:39: 7:39 + let _2: &!; // in scope 0 at $DIR/uninhabited-enum.rs:8:8: 8:14 + scope 1 { + debug _input => _2; // in scope 1 at $DIR/uninhabited-enum.rs:8:8: 8:14 + } + scope 2 { + } + + bb0: { + StorageLive(_2); // bb0[0]: scope 0 at $DIR/uninhabited-enum.rs:8:8: 8:14 + _2 = &(*_1); // bb0[1]: scope 2 at $DIR/uninhabited-enum.rs:8:26: 8:33 + StorageDead(_2); // bb0[2]: scope 0 at $DIR/uninhabited-enum.rs:9:1: 9:2 + unreachable; // bb0[3]: scope 0 at $DIR/uninhabited-enum.rs:7:39: 9:2 + } +} diff --git a/src/test/mir-opt/uninhabited-enum/rustc.process_void.SimplifyLocals.after.mir b/src/test/mir-opt/uninhabited-enum/rustc.process_void.SimplifyLocals.after.mir new file mode 100644 index 00000000000..2eb820bbdc3 --- /dev/null +++ b/src/test/mir-opt/uninhabited-enum/rustc.process_void.SimplifyLocals.after.mir @@ -0,0 +1,19 @@ +// MIR for `process_void` after SimplifyLocals + +fn process_void(_1: *const Void) -> () { + debug input => _1; // in scope 0 at $DIR/uninhabited-enum.rs:13:21: 13:26 + let mut _0: (); // return place in scope 0 at $DIR/uninhabited-enum.rs:13:41: 13:41 + let _2: &Void; // in scope 0 at $DIR/uninhabited-enum.rs:14:8: 14:14 + scope 1 { + debug _input => _2; // in scope 1 at $DIR/uninhabited-enum.rs:14:8: 14:14 + } + scope 2 { + } + + bb0: { + StorageLive(_2); // bb0[0]: scope 0 at $DIR/uninhabited-enum.rs:14:8: 14:14 + _2 = &(*_1); // bb0[1]: scope 2 at $DIR/uninhabited-enum.rs:14:26: 14:33 + StorageDead(_2); // bb0[2]: scope 0 at $DIR/uninhabited-enum.rs:17:1: 17:2 + return; // bb0[3]: scope 0 at $DIR/uninhabited-enum.rs:17:2: 17:2 + } +} diff --git a/src/test/mir-opt/uninhabited_enum_branching.rs b/src/test/mir-opt/uninhabited_enum_branching.rs index dda5fd4fb75..daf1156d20e 100644 --- a/src/test/mir-opt/uninhabited_enum_branching.rs +++ b/src/test/mir-opt/uninhabited_enum_branching.rs @@ -14,6 +14,8 @@ enum Test2 { E = 5, } +// EMIT_MIR rustc.main.UninhabitedEnumBranching.diff +// EMIT_MIR rustc.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir fn main() { match Test1::C { Test1::A(_) => "A(Empty)", @@ -26,178 +28,3 @@ fn main() { Test2::E => "E", }; } - -// END RUST SOURCE -// -// START rustc.main.UninhabitedEnumBranching.before.mir -// let mut _0: (); -// let _1: &str; -// let mut _2: Test1; -// let mut _3: isize; -// let _4: &str; -// let _5: &str; -// let _6: &str; -// let mut _7: Test2; -// let mut _8: isize; -// let _9: &str; -// bb0: { -// StorageLive(_1); -// StorageLive(_2); -// _2 = Test1::C; -// _3 = discriminant(_2); -// switchInt(move _3) -> [0isize: bb2, 1isize: bb3, otherwise: bb1]; -// } -// bb1: { -// StorageLive(_5); -// _5 = const "C"; -// _1 = &(*_5); -// StorageDead(_5); -// goto -> bb4; -// } -// bb2: { -// _1 = const "A(Empty)"; -// goto -> bb4; -// } -// bb3: { -// StorageLive(_4); -// _4 = const "B(Empty)"; -// _1 = &(*_4); -// StorageDead(_4); -// goto -> bb4; -// } -// bb4: { -// StorageDead(_2); -// StorageDead(_1); -// StorageLive(_6); -// StorageLive(_7); -// _7 = Test2::D; -// _8 = discriminant(_7); -// switchInt(move _8) -> [4isize: bb6, otherwise: bb5]; -// } -// bb5: { -// StorageLive(_9); -// _9 = const "E"; -// _6 = &(*_9); -// StorageDead(_9); -// goto -> bb7; -// } -// bb6: { -// _6 = const "D"; -// goto -> bb7; -// } -// bb7: { -// StorageDead(_7); -// StorageDead(_6); -// _0 = (); -// return; -// } -// END rustc.main.UninhabitedEnumBranching.before.mir -// START rustc.main.UninhabitedEnumBranching.after.mir -// let mut _0: (); -// let _1: &str; -// let mut _2: Test1; -// let mut _3: isize; -// let _4: &str; -// let _5: &str; -// let _6: &str; -// let mut _7: Test2; -// let mut _8: isize; -// let _9: &str; -// bb0: { -// StorageLive(_1); -// StorageLive(_2); -// _2 = Test1::C; -// _3 = discriminant(_2); -// switchInt(move _3) -> bb1; -// } -// bb1: { -// StorageLive(_5); -// _5 = const "C"; -// _1 = &(*_5); -// StorageDead(_5); -// goto -> bb4; -// } -// bb2: { -// _1 = const "A(Empty)"; -// goto -> bb4; -// } -// bb3: { -// StorageLive(_4); -// _4 = const "B(Empty)"; -// _1 = &(*_4); -// StorageDead(_4); -// goto -> bb4; -// } -// bb4: { -// StorageDead(_2); -// StorageDead(_1); -// StorageLive(_6); -// StorageLive(_7); -// _7 = Test2::D; -// _8 = discriminant(_7); -// switchInt(move _8) -> [4isize: bb6, otherwise: bb5]; -// } -// bb5: { -// StorageLive(_9); -// _9 = const "E"; -// _6 = &(*_9); -// StorageDead(_9); -// goto -> bb7; -// } -// bb6: { -// _6 = const "D"; -// goto -> bb7; -// } -// bb7: { -// StorageDead(_7); -// StorageDead(_6); -// _0 = (); -// return; -// } -// END rustc.main.UninhabitedEnumBranching.after.mir -// START rustc.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir -// let mut _0: (); -// let _1: &str; -// let mut _2: Test1; -// let mut _3: isize; -// let _4: &str; -// let _5: &str; -// let _6: &str; -// let mut _7: Test2; -// let mut _8: isize; -// let _9: &str; -// bb0: { -// StorageLive(_1); -// StorageLive(_2); -// _2 = Test1::C; -// _3 = discriminant(_2); -// StorageLive(_5); -// _5 = const "C"; -// _1 = &(*_5); -// StorageDead(_5); -// StorageDead(_2); -// StorageDead(_1); -// StorageLive(_6); -// StorageLive(_7); -// _7 = Test2::D; -// _8 = discriminant(_7); -// switchInt(move _8) -> [4isize: bb2, otherwise: bb1]; -// } -// bb1: { -// StorageLive(_9); -// _9 = const "E"; -// _6 = &(*_9); -// StorageDead(_9); -// goto -> bb3; -// } -// bb2: { -// _6 = const "D"; -// goto -> bb3; -// } -// bb3: { -// StorageDead(_7); -// StorageDead(_6); -// _0 = (); -// return; -// } -// END rustc.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir diff --git a/src/test/mir-opt/uninhabited_enum_branching/rustc.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir b/src/test/mir-opt/uninhabited_enum_branching/rustc.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir new file mode 100644 index 00000000000..c8dde4d360c --- /dev/null +++ b/src/test/mir-opt/uninhabited_enum_branching/rustc.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir @@ -0,0 +1,70 @@ +// MIR for `main` after SimplifyCfg-after-uninhabited-enum-branching + +fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/uninhabited_enum_branching.rs:19:11: 19:11 + let _1: &str; // in scope 0 at $DIR/uninhabited_enum_branching.rs:20:5: 24:6 + let mut _2: Test1; // in scope 0 at $DIR/uninhabited_enum_branching.rs:20:11: 20:19 + let mut _3: isize; // in scope 0 at $DIR/uninhabited_enum_branching.rs:21:9: 21:20 + let _4: &str; // in scope 0 at $DIR/uninhabited_enum_branching.rs:22:24: 22:34 + let _5: &str; // in scope 0 at $DIR/uninhabited_enum_branching.rs:23:21: 23:24 + let _6: &str; // in scope 0 at $DIR/uninhabited_enum_branching.rs:26:5: 29:6 + let mut _7: Test2; // in scope 0 at $DIR/uninhabited_enum_branching.rs:26:11: 26:19 + let mut _8: isize; // in scope 0 at $DIR/uninhabited_enum_branching.rs:27:9: 27:17 + let _9: &str; // in scope 0 at $DIR/uninhabited_enum_branching.rs:28:21: 28:24 + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/uninhabited_enum_branching.rs:20:5: 24:6 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/uninhabited_enum_branching.rs:20:11: 20:19 + _2 = Test1::C; // bb0[2]: scope 0 at $DIR/uninhabited_enum_branching.rs:20:11: 20:19 + _3 = discriminant(_2); // bb0[3]: scope 0 at $DIR/uninhabited_enum_branching.rs:21:9: 21:20 + StorageLive(_5); // bb0[4]: scope 0 at $DIR/uninhabited_enum_branching.rs:23:21: 23:24 + _5 = const "C"; // bb0[5]: scope 0 at $DIR/uninhabited_enum_branching.rs:23:21: 23:24 + // ty::Const + // + ty: &str + // + val: Value(Slice { data: Allocation { bytes: [67], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 }) + // mir::Constant + // + span: $DIR/uninhabited_enum_branching.rs:23:21: 23:24 + // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [67], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 }) } + _1 = &(*_5); // bb0[6]: scope 0 at $DIR/uninhabited_enum_branching.rs:23:21: 23:24 + StorageDead(_5); // bb0[7]: scope 0 at $DIR/uninhabited_enum_branching.rs:23:23: 23:24 + StorageDead(_2); // bb0[8]: scope 0 at $DIR/uninhabited_enum_branching.rs:24:6: 24:7 + StorageDead(_1); // bb0[9]: scope 0 at $DIR/uninhabited_enum_branching.rs:24:6: 24:7 + StorageLive(_6); // bb0[10]: scope 0 at $DIR/uninhabited_enum_branching.rs:26:5: 29:6 + StorageLive(_7); // bb0[11]: scope 0 at $DIR/uninhabited_enum_branching.rs:26:11: 26:19 + _7 = Test2::D; // bb0[12]: scope 0 at $DIR/uninhabited_enum_branching.rs:26:11: 26:19 + _8 = discriminant(_7); // bb0[13]: scope 0 at $DIR/uninhabited_enum_branching.rs:27:9: 27:17 + switchInt(move _8) -> [4isize: bb2, otherwise: bb1]; // bb0[14]: scope 0 at $DIR/uninhabited_enum_branching.rs:27:9: 27:17 + } + + bb1: { + StorageLive(_9); // bb1[0]: scope 0 at $DIR/uninhabited_enum_branching.rs:28:21: 28:24 + _9 = const "E"; // bb1[1]: scope 0 at $DIR/uninhabited_enum_branching.rs:28:21: 28:24 + // ty::Const + // + ty: &str + // + val: Value(Slice { data: Allocation { bytes: [69], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 }) + // mir::Constant + // + span: $DIR/uninhabited_enum_branching.rs:28:21: 28:24 + // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [69], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 }) } + _6 = &(*_9); // bb1[2]: scope 0 at $DIR/uninhabited_enum_branching.rs:28:21: 28:24 + StorageDead(_9); // bb1[3]: scope 0 at $DIR/uninhabited_enum_branching.rs:28:23: 28:24 + goto -> bb3; // bb1[4]: scope 0 at $DIR/uninhabited_enum_branching.rs:26:5: 29:6 + } + + bb2: { + _6 = const "D"; // bb2[0]: scope 0 at $DIR/uninhabited_enum_branching.rs:27:21: 27:24 + // ty::Const + // + ty: &str + // + val: Value(Slice { data: Allocation { bytes: [68], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 }) + // mir::Constant + // + span: $DIR/uninhabited_enum_branching.rs:27:21: 27:24 + // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [68], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 }) } + goto -> bb3; // bb2[1]: scope 0 at $DIR/uninhabited_enum_branching.rs:26:5: 29:6 + } + + bb3: { + StorageDead(_7); // bb3[0]: scope 0 at $DIR/uninhabited_enum_branching.rs:29:6: 29:7 + StorageDead(_6); // bb3[1]: scope 0 at $DIR/uninhabited_enum_branching.rs:29:6: 29:7 + _0 = (); // bb3[2]: scope 0 at $DIR/uninhabited_enum_branching.rs:19:11: 30:2 + return; // bb3[3]: scope 0 at $DIR/uninhabited_enum_branching.rs:30:2: 30:2 + } +} diff --git a/src/test/mir-opt/uninhabited_enum_branching/rustc.main.UninhabitedEnumBranching.diff b/src/test/mir-opt/uninhabited_enum_branching/rustc.main.UninhabitedEnumBranching.diff new file mode 100644 index 00000000000..cccd6aa3230 --- /dev/null +++ b/src/test/mir-opt/uninhabited_enum_branching/rustc.main.UninhabitedEnumBranching.diff @@ -0,0 +1,106 @@ +- // MIR for `main` before UninhabitedEnumBranching ++ // MIR for `main` after UninhabitedEnumBranching + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/uninhabited_enum_branching.rs:19:11: 19:11 + let _1: &str; // in scope 0 at $DIR/uninhabited_enum_branching.rs:20:5: 24:6 + let mut _2: Test1; // in scope 0 at $DIR/uninhabited_enum_branching.rs:20:11: 20:19 + let mut _3: isize; // in scope 0 at $DIR/uninhabited_enum_branching.rs:21:9: 21:20 + let _4: &str; // in scope 0 at $DIR/uninhabited_enum_branching.rs:22:24: 22:34 + let _5: &str; // in scope 0 at $DIR/uninhabited_enum_branching.rs:23:21: 23:24 + let _6: &str; // in scope 0 at $DIR/uninhabited_enum_branching.rs:26:5: 29:6 + let mut _7: Test2; // in scope 0 at $DIR/uninhabited_enum_branching.rs:26:11: 26:19 + let mut _8: isize; // in scope 0 at $DIR/uninhabited_enum_branching.rs:27:9: 27:17 + let _9: &str; // in scope 0 at $DIR/uninhabited_enum_branching.rs:28:21: 28:24 + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/uninhabited_enum_branching.rs:20:5: 24:6 + StorageLive(_2); // bb0[1]: scope 0 at $DIR/uninhabited_enum_branching.rs:20:11: 20:19 + _2 = Test1::C; // bb0[2]: scope 0 at $DIR/uninhabited_enum_branching.rs:20:11: 20:19 + _3 = discriminant(_2); // bb0[3]: scope 0 at $DIR/uninhabited_enum_branching.rs:21:9: 21:20 +- switchInt(move _3) -> [0isize: bb2, 1isize: bb3, otherwise: bb1]; // bb0[4]: scope 0 at $DIR/uninhabited_enum_branching.rs:21:9: 21:20 ++ switchInt(move _3) -> bb1; // bb0[4]: scope 0 at $DIR/uninhabited_enum_branching.rs:21:9: 21:20 + } + + bb1: { + StorageLive(_5); // bb1[0]: scope 0 at $DIR/uninhabited_enum_branching.rs:23:21: 23:24 + _5 = const "C"; // bb1[1]: scope 0 at $DIR/uninhabited_enum_branching.rs:23:21: 23:24 + // ty::Const + // + ty: &str + // + val: Value(Slice { data: Allocation { bytes: [67], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 }) + // mir::Constant + // + span: $DIR/uninhabited_enum_branching.rs:23:21: 23:24 + // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [67], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 }) } + _1 = &(*_5); // bb1[2]: scope 0 at $DIR/uninhabited_enum_branching.rs:23:21: 23:24 + StorageDead(_5); // bb1[3]: scope 0 at $DIR/uninhabited_enum_branching.rs:23:23: 23:24 + goto -> bb4; // bb1[4]: scope 0 at $DIR/uninhabited_enum_branching.rs:20:5: 24:6 + } + + bb2: { + _1 = const "A(Empty)"; // bb2[0]: scope 0 at $DIR/uninhabited_enum_branching.rs:21:24: 21:34 + // ty::Const + // + ty: &str + // + val: Value(Slice { data: Allocation { bytes: [65, 40, 69, 109, 112, 116, 121, 41], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [255], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 8 }) + // mir::Constant + // + span: $DIR/uninhabited_enum_branching.rs:21:24: 21:34 + // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [65, 40, 69, 109, 112, 116, 121, 41], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [255], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 8 }) } + goto -> bb4; // bb2[1]: scope 0 at $DIR/uninhabited_enum_branching.rs:20:5: 24:6 + } + + bb3: { + StorageLive(_4); // bb3[0]: scope 0 at $DIR/uninhabited_enum_branching.rs:22:24: 22:34 + _4 = const "B(Empty)"; // bb3[1]: scope 0 at $DIR/uninhabited_enum_branching.rs:22:24: 22:34 + // ty::Const + // + ty: &str + // + val: Value(Slice { data: Allocation { bytes: [66, 40, 69, 109, 112, 116, 121, 41], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [255], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 8 }) + // mir::Constant + // + span: $DIR/uninhabited_enum_branching.rs:22:24: 22:34 + // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [66, 40, 69, 109, 112, 116, 121, 41], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [255], len: Size { raw: 8 } }, size: Size { raw: 8 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 8 }) } + _1 = &(*_4); // bb3[2]: scope 0 at $DIR/uninhabited_enum_branching.rs:22:24: 22:34 + StorageDead(_4); // bb3[3]: scope 0 at $DIR/uninhabited_enum_branching.rs:22:33: 22:34 + goto -> bb4; // bb3[4]: scope 0 at $DIR/uninhabited_enum_branching.rs:20:5: 24:6 + } + + bb4: { + StorageDead(_2); // bb4[0]: scope 0 at $DIR/uninhabited_enum_branching.rs:24:6: 24:7 + StorageDead(_1); // bb4[1]: scope 0 at $DIR/uninhabited_enum_branching.rs:24:6: 24:7 + StorageLive(_6); // bb4[2]: scope 0 at $DIR/uninhabited_enum_branching.rs:26:5: 29:6 + StorageLive(_7); // bb4[3]: scope 0 at $DIR/uninhabited_enum_branching.rs:26:11: 26:19 + _7 = Test2::D; // bb4[4]: scope 0 at $DIR/uninhabited_enum_branching.rs:26:11: 26:19 + _8 = discriminant(_7); // bb4[5]: scope 0 at $DIR/uninhabited_enum_branching.rs:27:9: 27:17 + switchInt(move _8) -> [4isize: bb6, otherwise: bb5]; // bb4[6]: scope 0 at $DIR/uninhabited_enum_branching.rs:27:9: 27:17 + } + + bb5: { + StorageLive(_9); // bb5[0]: scope 0 at $DIR/uninhabited_enum_branching.rs:28:21: 28:24 + _9 = const "E"; // bb5[1]: scope 0 at $DIR/uninhabited_enum_branching.rs:28:21: 28:24 + // ty::Const + // + ty: &str + // + val: Value(Slice { data: Allocation { bytes: [69], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 }) + // mir::Constant + // + span: $DIR/uninhabited_enum_branching.rs:28:21: 28:24 + // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [69], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 }) } + _6 = &(*_9); // bb5[2]: scope 0 at $DIR/uninhabited_enum_branching.rs:28:21: 28:24 + StorageDead(_9); // bb5[3]: scope 0 at $DIR/uninhabited_enum_branching.rs:28:23: 28:24 + goto -> bb7; // bb5[4]: scope 0 at $DIR/uninhabited_enum_branching.rs:26:5: 29:6 + } + + bb6: { + _6 = const "D"; // bb6[0]: scope 0 at $DIR/uninhabited_enum_branching.rs:27:21: 27:24 + // ty::Const + // + ty: &str + // + val: Value(Slice { data: Allocation { bytes: [68], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 }) + // mir::Constant + // + span: $DIR/uninhabited_enum_branching.rs:27:21: 27:24 + // + literal: Const { ty: &str, val: Value(Slice { data: Allocation { bytes: [68], relocations: Relocations(SortedMap { data: [] }), undef_mask: UndefMask { blocks: [1], len: Size { raw: 1 } }, size: Size { raw: 1 }, align: Align { pow2: 0 }, mutability: Not, extra: () }, start: 0, end: 1 }) } + goto -> bb7; // bb6[1]: scope 0 at $DIR/uninhabited_enum_branching.rs:26:5: 29:6 + } + + bb7: { + StorageDead(_7); // bb7[0]: scope 0 at $DIR/uninhabited_enum_branching.rs:29:6: 29:7 + StorageDead(_6); // bb7[1]: scope 0 at $DIR/uninhabited_enum_branching.rs:29:6: 29:7 + _0 = (); // bb7[2]: scope 0 at $DIR/uninhabited_enum_branching.rs:19:11: 30:2 + return; // bb7[3]: scope 0 at $DIR/uninhabited_enum_branching.rs:30:2: 30:2 + } + } + diff --git a/src/test/mir-opt/unreachable.rs b/src/test/mir-opt/unreachable.rs index fa5c1a074ee..6f0c4ca3cf5 100644 --- a/src/test/mir-opt/unreachable.rs +++ b/src/test/mir-opt/unreachable.rs @@ -4,6 +4,7 @@ fn empty() -> Option<Empty> { None } +// EMIT_MIR rustc.main.UnreachablePropagation.diff fn main() { if let Some(_x) = empty() { let mut _y; @@ -17,62 +18,3 @@ fn main() { match _x { } } } - -// END RUST SOURCE -// START rustc.main.UnreachablePropagation.before.mir -// bb0: { -// StorageLive(_1); -// _1 = const empty() -> bb1; -// } -// bb1: { -// _2 = discriminant(_1); -// switchInt(move _2) -> [1isize: bb3, otherwise: bb2]; -// } -// bb2: { -// _0 = (); -// StorageDead(_1); -// return; -// } -// bb3: { -// StorageLive(_3); -// _3 = move ((_1 as Some).0: Empty); -// StorageLive(_4); -// StorageLive(_5); -// StorageLive(_6); -// _6 = const true; -// switchInt(_6) -> [false: bb4, otherwise: bb5]; -// } -// bb4: { -// _4 = const 42i32; -// _5 = (); -// goto -> bb6; -// } -// bb5: { -// _4 = const 21i32; -// _5 = (); -// goto -> bb6; -// } -// bb6: { -// StorageDead(_6); -// StorageDead(_5); -// StorageLive(_7); -// unreachable; -// } -// } -// END rustc.main.UnreachablePropagation.before.mir -// START rustc.main.UnreachablePropagation.after.mir -// bb0: { -// StorageLive(_1); -// _1 = const empty() -> bb1; -// } -// bb1: { -// _2 = discriminant(_1); -// goto -> bb2; -// } -// bb2: { -// _0 = (); -// StorageDead(_1); -// return; -// } -// } -// END rustc.main.UnreachablePropagation.after.mir diff --git a/src/test/mir-opt/unreachable/rustc.main.UnreachablePropagation.diff b/src/test/mir-opt/unreachable/rustc.main.UnreachablePropagation.diff new file mode 100644 index 00000000000..3a239c6e3b0 --- /dev/null +++ b/src/test/mir-opt/unreachable/rustc.main.UnreachablePropagation.diff @@ -0,0 +1,90 @@ +- // MIR for `main` before UnreachablePropagation ++ // MIR for `main` after UnreachablePropagation + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/unreachable.rs:8:11: 8:11 + let mut _1: std::option::Option<Empty>; // in scope 0 at $DIR/unreachable.rs:9:23: 9:30 + let mut _2: isize; // in scope 0 at $DIR/unreachable.rs:9:12: 9:20 + let _3: Empty; // in scope 0 at $DIR/unreachable.rs:9:17: 9:19 + let _5: (); // in scope 0 at $DIR/unreachable.rs:12:9: 16:10 + let mut _6: bool; // in scope 0 at $DIR/unreachable.rs:12:12: 12:16 + let mut _7: !; // in scope 0 at $DIR/unreachable.rs:18:9: 18:21 + scope 1 { + debug _x => _3; // in scope 1 at $DIR/unreachable.rs:9:17: 9:19 + let mut _4: i32; // in scope 1 at $DIR/unreachable.rs:10:13: 10:19 + scope 2 { + debug _y => _4; // in scope 2 at $DIR/unreachable.rs:10:13: 10:19 + } + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/unreachable.rs:9:23: 9:30 + _1 = const empty() -> bb1; // bb0[1]: scope 0 at $DIR/unreachable.rs:9:23: 9:30 + // ty::Const + // + ty: fn() -> std::option::Option<Empty> {empty} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/unreachable.rs:9:23: 9:28 + // + literal: Const { ty: fn() -> std::option::Option<Empty> {empty}, val: Value(Scalar(<ZST>)) } + } + + bb1: { + _2 = discriminant(_1); // bb1[0]: scope 0 at $DIR/unreachable.rs:9:12: 9:20 +- switchInt(move _2) -> [1isize: bb3, otherwise: bb2]; // bb1[1]: scope 0 at $DIR/unreachable.rs:9:12: 9:20 ++ goto -> bb2; // bb1[1]: scope 0 at $DIR/unreachable.rs:9:12: 9:20 + } + + bb2: { + _0 = (); // bb2[0]: scope 0 at $DIR/unreachable.rs:9:5: 19:6 + StorageDead(_1); // bb2[1]: scope 0 at $DIR/unreachable.rs:20:1: 20:2 + return; // bb2[2]: scope 0 at $DIR/unreachable.rs:20:2: 20:2 +- } +- +- bb3: { +- StorageLive(_3); // bb3[0]: scope 0 at $DIR/unreachable.rs:9:17: 9:19 +- _3 = move ((_1 as Some).0: Empty); // bb3[1]: scope 0 at $DIR/unreachable.rs:9:17: 9:19 +- StorageLive(_4); // bb3[2]: scope 1 at $DIR/unreachable.rs:10:13: 10:19 +- StorageLive(_5); // bb3[3]: scope 2 at $DIR/unreachable.rs:12:9: 16:10 +- StorageLive(_6); // bb3[4]: scope 2 at $DIR/unreachable.rs:12:12: 12:16 +- _6 = const true; // bb3[5]: scope 2 at $DIR/unreachable.rs:12:12: 12:16 +- // ty::Const +- // + ty: bool +- // + val: Value(Scalar(0x01)) +- // mir::Constant +- // + span: $DIR/unreachable.rs:12:12: 12:16 +- // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } +- switchInt(_6) -> [false: bb4, otherwise: bb5]; // bb3[6]: scope 2 at $DIR/unreachable.rs:12:9: 16:10 +- } +- +- bb4: { +- _4 = const 42i32; // bb4[0]: scope 2 at $DIR/unreachable.rs:15:13: 15:20 +- // ty::Const +- // + ty: i32 +- // + val: Value(Scalar(0x0000002a)) +- // mir::Constant +- // + span: $DIR/unreachable.rs:15:18: 15:20 +- // + literal: Const { ty: i32, val: Value(Scalar(0x0000002a)) } +- _5 = (); // bb4[1]: scope 2 at $DIR/unreachable.rs:14:16: 16:10 +- goto -> bb6; // bb4[2]: scope 2 at $DIR/unreachable.rs:12:9: 16:10 +- } +- +- bb5: { +- _4 = const 21i32; // bb5[0]: scope 2 at $DIR/unreachable.rs:13:13: 13:20 +- // ty::Const +- // + ty: i32 +- // + val: Value(Scalar(0x00000015)) +- // mir::Constant +- // + span: $DIR/unreachable.rs:13:18: 13:20 +- // + literal: Const { ty: i32, val: Value(Scalar(0x00000015)) } +- _5 = (); // bb5[1]: scope 2 at $DIR/unreachable.rs:12:17: 14:10 +- goto -> bb6; // bb5[2]: scope 2 at $DIR/unreachable.rs:12:9: 16:10 +- } +- +- bb6: { +- StorageDead(_6); // bb6[0]: scope 2 at $DIR/unreachable.rs:16:9: 16:10 +- StorageDead(_5); // bb6[1]: scope 2 at $DIR/unreachable.rs:16:9: 16:10 +- StorageLive(_7); // bb6[2]: scope 2 at $DIR/unreachable.rs:18:9: 18:21 +- unreachable; // bb6[3]: scope 2 at $DIR/unreachable.rs:18:15: 18:17 + } + } + diff --git a/src/test/mir-opt/unreachable_asm.rs b/src/test/mir-opt/unreachable_asm.rs index 990141657f4..4bbf22b8227 100644 --- a/src/test/mir-opt/unreachable_asm.rs +++ b/src/test/mir-opt/unreachable_asm.rs @@ -1,4 +1,3 @@ -// ignore-tidy-linelength #![feature(llvm_asm)] enum Empty {} @@ -7,6 +6,7 @@ fn empty() -> Option<Empty> { None } +// EMIT_MIR rustc.main.UnreachablePropagation.diff fn main() { if let Some(_x) = empty() { let mut _y; @@ -22,51 +22,3 @@ fn main() { match _x { } } } - -// END RUST SOURCE -// START rustc.main.UnreachablePropagation.before.mir -// bb4: { -// _4 = const 42i32; -// _5 = (); -// goto -> bb6; -// } -// bb5: { -// _4 = const 21i32; -// _5 = (); -// goto -> bb6; -// } -// bb6: { -// StorageDead(_6); -// StorageDead(_5); -// StorageLive(_7); -// llvm_asm!(LlvmInlineAsmInner { asm: "NOP", asm_str_style: Cooked, outputs: [], inputs: [], clobbers: [], volatile: true, alignstack: false, dialect: Att } : [] : []); -// _7 = (); -// StorageDead(_7); -// StorageLive(_8); -// unreachable; -// } -// } -// END rustc.main.UnreachablePropagation.before.mir -// START rustc.main.UnreachablePropagation.after.mir -// bb4: { -// _4 = const 42i32; -// _5 = (); -// goto -> bb6; -// } -// bb5: { -// _4 = const 21i32; -// _5 = (); -// goto -> bb6; -// } -// bb6: { -// StorageDead(_6); -// StorageDead(_5); -// StorageLive(_7); -// llvm_asm!(LlvmInlineAsmInner { asm: "NOP", asm_str_style: Cooked, outputs: [], inputs: [], clobbers: [], volatile: true, alignstack: false, dialect: Att } : [] : []); -// _7 = (); -// StorageDead(_7); -// StorageLive(_8); -// unreachable; -// } -// } -// END rustc.main.UnreachablePropagation.after.mir diff --git a/src/test/mir-opt/unreachable_asm/rustc.main.UnreachablePropagation.diff b/src/test/mir-opt/unreachable_asm/rustc.main.UnreachablePropagation.diff new file mode 100644 index 00000000000..c32165a3893 --- /dev/null +++ b/src/test/mir-opt/unreachable_asm/rustc.main.UnreachablePropagation.diff @@ -0,0 +1,96 @@ +- // MIR for `main` before UnreachablePropagation ++ // MIR for `main` after UnreachablePropagation + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/unreachable_asm.rs:10:11: 10:11 + let mut _1: std::option::Option<Empty>; // in scope 0 at $DIR/unreachable_asm.rs:11:23: 11:30 + let mut _2: isize; // in scope 0 at $DIR/unreachable_asm.rs:11:12: 11:20 + let _3: Empty; // in scope 0 at $DIR/unreachable_asm.rs:11:17: 11:19 + let _5: (); // in scope 0 at $DIR/unreachable_asm.rs:14:9: 18:10 + let mut _6: bool; // in scope 0 at $DIR/unreachable_asm.rs:14:12: 14:16 + let _7: (); // in scope 0 at $DIR/unreachable_asm.rs:21:9: 21:37 + let mut _8: !; // in scope 0 at $DIR/unreachable_asm.rs:22:9: 22:21 + scope 1 { + debug _x => _3; // in scope 1 at $DIR/unreachable_asm.rs:11:17: 11:19 + let mut _4: i32; // in scope 1 at $DIR/unreachable_asm.rs:12:13: 12:19 + scope 2 { + debug _y => _4; // in scope 2 at $DIR/unreachable_asm.rs:12:13: 12:19 + scope 3 { + } + } + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/unreachable_asm.rs:11:23: 11:30 + _1 = const empty() -> bb1; // bb0[1]: scope 0 at $DIR/unreachable_asm.rs:11:23: 11:30 + // ty::Const + // + ty: fn() -> std::option::Option<Empty> {empty} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/unreachable_asm.rs:11:23: 11:28 + // + literal: Const { ty: fn() -> std::option::Option<Empty> {empty}, val: Value(Scalar(<ZST>)) } + } + + bb1: { + _2 = discriminant(_1); // bb1[0]: scope 0 at $DIR/unreachable_asm.rs:11:12: 11:20 + switchInt(move _2) -> [1isize: bb3, otherwise: bb2]; // bb1[1]: scope 0 at $DIR/unreachable_asm.rs:11:12: 11:20 + } + + bb2: { + _0 = (); // bb2[0]: scope 0 at $DIR/unreachable_asm.rs:11:5: 23:6 + StorageDead(_1); // bb2[1]: scope 0 at $DIR/unreachable_asm.rs:24:1: 24:2 + return; // bb2[2]: scope 0 at $DIR/unreachable_asm.rs:24:2: 24:2 + } + + bb3: { + StorageLive(_3); // bb3[0]: scope 0 at $DIR/unreachable_asm.rs:11:17: 11:19 + _3 = move ((_1 as Some).0: Empty); // bb3[1]: scope 0 at $DIR/unreachable_asm.rs:11:17: 11:19 + StorageLive(_4); // bb3[2]: scope 1 at $DIR/unreachable_asm.rs:12:13: 12:19 + StorageLive(_5); // bb3[3]: scope 2 at $DIR/unreachable_asm.rs:14:9: 18:10 + StorageLive(_6); // bb3[4]: scope 2 at $DIR/unreachable_asm.rs:14:12: 14:16 + _6 = const true; // bb3[5]: scope 2 at $DIR/unreachable_asm.rs:14:12: 14:16 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x01)) + // mir::Constant + // + span: $DIR/unreachable_asm.rs:14:12: 14:16 + // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + switchInt(_6) -> [false: bb4, otherwise: bb5]; // bb3[6]: scope 2 at $DIR/unreachable_asm.rs:14:9: 18:10 + } + + bb4: { + _4 = const 42i32; // bb4[0]: scope 2 at $DIR/unreachable_asm.rs:17:13: 17:20 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x0000002a)) + // mir::Constant + // + span: $DIR/unreachable_asm.rs:17:18: 17:20 + // + literal: Const { ty: i32, val: Value(Scalar(0x0000002a)) } + _5 = (); // bb4[1]: scope 2 at $DIR/unreachable_asm.rs:16:16: 18:10 + goto -> bb6; // bb4[2]: scope 2 at $DIR/unreachable_asm.rs:14:9: 18:10 + } + + bb5: { + _4 = const 21i32; // bb5[0]: scope 2 at $DIR/unreachable_asm.rs:15:13: 15:20 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000015)) + // mir::Constant + // + span: $DIR/unreachable_asm.rs:15:18: 15:20 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000015)) } + _5 = (); // bb5[1]: scope 2 at $DIR/unreachable_asm.rs:14:17: 16:10 + goto -> bb6; // bb5[2]: scope 2 at $DIR/unreachable_asm.rs:14:9: 18:10 + } + + bb6: { + StorageDead(_6); // bb6[0]: scope 2 at $DIR/unreachable_asm.rs:18:9: 18:10 + StorageDead(_5); // bb6[1]: scope 2 at $DIR/unreachable_asm.rs:18:9: 18:10 + StorageLive(_7); // bb6[2]: scope 2 at $DIR/unreachable_asm.rs:21:9: 21:37 + llvm_asm!(LlvmInlineAsmInner { asm: "NOP", asm_str_style: Cooked, outputs: [], inputs: [], clobbers: [], volatile: true, alignstack: false, dialect: Att } : [] : []); // bb6[3]: scope 3 at $DIR/unreachable_asm.rs:21:18: 21:35 + _7 = (); // bb6[4]: scope 3 at $DIR/unreachable_asm.rs:21:9: 21:37 + StorageDead(_7); // bb6[5]: scope 2 at $DIR/unreachable_asm.rs:21:36: 21:37 + StorageLive(_8); // bb6[6]: scope 2 at $DIR/unreachable_asm.rs:22:9: 22:21 + unreachable; // bb6[7]: scope 2 at $DIR/unreachable_asm.rs:22:15: 22:17 + } + } + diff --git a/src/test/mir-opt/unreachable_asm_2.rs b/src/test/mir-opt/unreachable_asm_2.rs index 0851e24d410..f1610db999e 100644 --- a/src/test/mir-opt/unreachable_asm_2.rs +++ b/src/test/mir-opt/unreachable_asm_2.rs @@ -1,4 +1,3 @@ -// ignore-tidy-linelength #![feature(llvm_asm)] enum Empty {} @@ -7,6 +6,7 @@ fn empty() -> Option<Empty> { None } +// EMIT_MIR rustc.main.UnreachablePropagation.diff fn main() { if let Some(_x) = empty() { let mut _y; @@ -24,61 +24,3 @@ fn main() { match _x { } } } - -// END RUST SOURCE -// START rustc.main.UnreachablePropagation.before.mir -// bb3: { -// ... -// switchInt(_6) -> [false: bb4, otherwise: bb5]; -// } -// bb4: { -// StorageLive(_8); -// llvm_asm!(LlvmInlineAsmInner { asm: "NOP", asm_str_style: Cooked, outputs: [], inputs: [], clobbers: [], volatile: true, alignstack: false, dialect: Att } : [] : []); -// _8 = (); -// StorageDead(_8); -// _4 = const 42i32; -// _5 = (); -// goto -> bb6; -// } -// bb5: { -// StorageLive(_7); -// llvm_asm!(LlvmInlineAsmInner { asm: "NOP", asm_str_style: Cooked, outputs: [], inputs: [], clobbers: [], volatile: true, alignstack: false, dialect: Att } : [] : []); -// _7 = (); -// StorageDead(_7); -// _4 = const 21i32; -// _5 = (); -// goto -> bb6; -// } -// bb6: { -// StorageDead(_6); -// StorageDead(_5); -// StorageLive(_9); -// unreachable; -// } -// } -// END rustc.main.UnreachablePropagation.before.mir -// START rustc.main.UnreachablePropagation.after.mir -// bb3: { -// ... -// switchInt(_6) -> [false: bb4, otherwise: bb5]; -// } -// bb4: { -// StorageLive(_8); -// llvm_asm!(LlvmInlineAsmInner { asm: "NOP", asm_str_style: Cooked, outputs: [], inputs: [], clobbers: [], volatile: true, alignstack: false, dialect: Att } : [] : []); -// _8 = (); -// StorageDead(_8); -// _4 = const 42i32; -// _5 = (); -// unreachable; -// } -// bb5: { -// StorageLive(_7); -// llvm_asm!(LlvmInlineAsmInner { asm: "NOP", asm_str_style: Cooked, outputs: [], inputs: [], clobbers: [], volatile: true, alignstack: false, dialect: Att } : [] : []); -// _7 = (); -// StorageDead(_7); -// _4 = const 21i32; -// _5 = (); -// unreachable; -// } -// } -// END rustc.main.UnreachablePropagation.after.mir diff --git a/src/test/mir-opt/unreachable_asm_2/rustc.main.UnreachablePropagation.diff b/src/test/mir-opt/unreachable_asm_2/rustc.main.UnreachablePropagation.diff new file mode 100644 index 00000000000..a3741787566 --- /dev/null +++ b/src/test/mir-opt/unreachable_asm_2/rustc.main.UnreachablePropagation.diff @@ -0,0 +1,105 @@ +- // MIR for `main` before UnreachablePropagation ++ // MIR for `main` after UnreachablePropagation + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/unreachable_asm_2.rs:10:11: 10:11 + let mut _1: std::option::Option<Empty>; // in scope 0 at $DIR/unreachable_asm_2.rs:11:23: 11:30 + let mut _2: isize; // in scope 0 at $DIR/unreachable_asm_2.rs:11:12: 11:20 + let _3: Empty; // in scope 0 at $DIR/unreachable_asm_2.rs:11:17: 11:19 + let _5: (); // in scope 0 at $DIR/unreachable_asm_2.rs:14:9: 22:10 + let mut _6: bool; // in scope 0 at $DIR/unreachable_asm_2.rs:14:12: 14:16 + let _7: (); // in scope 0 at $DIR/unreachable_asm_2.rs:16:13: 16:41 + let _8: (); // in scope 0 at $DIR/unreachable_asm_2.rs:20:13: 20:41 + let mut _9: !; // in scope 0 at $DIR/unreachable_asm_2.rs:24:9: 24:21 + scope 1 { + debug _x => _3; // in scope 1 at $DIR/unreachable_asm_2.rs:11:17: 11:19 + let mut _4: i32; // in scope 1 at $DIR/unreachable_asm_2.rs:12:13: 12:19 + scope 2 { + debug _y => _4; // in scope 2 at $DIR/unreachable_asm_2.rs:12:13: 12:19 + scope 3 { + } + scope 4 { + } + } + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/unreachable_asm_2.rs:11:23: 11:30 + _1 = const empty() -> bb1; // bb0[1]: scope 0 at $DIR/unreachable_asm_2.rs:11:23: 11:30 + // ty::Const + // + ty: fn() -> std::option::Option<Empty> {empty} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/unreachable_asm_2.rs:11:23: 11:28 + // + literal: Const { ty: fn() -> std::option::Option<Empty> {empty}, val: Value(Scalar(<ZST>)) } + } + + bb1: { + _2 = discriminant(_1); // bb1[0]: scope 0 at $DIR/unreachable_asm_2.rs:11:12: 11:20 + switchInt(move _2) -> [1isize: bb3, otherwise: bb2]; // bb1[1]: scope 0 at $DIR/unreachable_asm_2.rs:11:12: 11:20 + } + + bb2: { + _0 = (); // bb2[0]: scope 0 at $DIR/unreachable_asm_2.rs:11:5: 25:6 + StorageDead(_1); // bb2[1]: scope 0 at $DIR/unreachable_asm_2.rs:26:1: 26:2 + return; // bb2[2]: scope 0 at $DIR/unreachable_asm_2.rs:26:2: 26:2 + } + + bb3: { + StorageLive(_3); // bb3[0]: scope 0 at $DIR/unreachable_asm_2.rs:11:17: 11:19 + _3 = move ((_1 as Some).0: Empty); // bb3[1]: scope 0 at $DIR/unreachable_asm_2.rs:11:17: 11:19 + StorageLive(_4); // bb3[2]: scope 1 at $DIR/unreachable_asm_2.rs:12:13: 12:19 + StorageLive(_5); // bb3[3]: scope 2 at $DIR/unreachable_asm_2.rs:14:9: 22:10 + StorageLive(_6); // bb3[4]: scope 2 at $DIR/unreachable_asm_2.rs:14:12: 14:16 + _6 = const true; // bb3[5]: scope 2 at $DIR/unreachable_asm_2.rs:14:12: 14:16 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x01)) + // mir::Constant + // + span: $DIR/unreachable_asm_2.rs:14:12: 14:16 + // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + switchInt(_6) -> [false: bb4, otherwise: bb5]; // bb3[6]: scope 2 at $DIR/unreachable_asm_2.rs:14:9: 22:10 + } + + bb4: { + StorageLive(_8); // bb4[0]: scope 2 at $DIR/unreachable_asm_2.rs:20:13: 20:41 + llvm_asm!(LlvmInlineAsmInner { asm: "NOP", asm_str_style: Cooked, outputs: [], inputs: [], clobbers: [], volatile: true, alignstack: false, dialect: Att } : [] : []); // bb4[1]: scope 4 at $DIR/unreachable_asm_2.rs:20:22: 20:39 + _8 = (); // bb4[2]: scope 4 at $DIR/unreachable_asm_2.rs:20:13: 20:41 + StorageDead(_8); // bb4[3]: scope 2 at $DIR/unreachable_asm_2.rs:20:40: 20:41 + _4 = const 42i32; // bb4[4]: scope 2 at $DIR/unreachable_asm_2.rs:21:13: 21:20 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x0000002a)) + // mir::Constant + // + span: $DIR/unreachable_asm_2.rs:21:18: 21:20 + // + literal: Const { ty: i32, val: Value(Scalar(0x0000002a)) } + _5 = (); // bb4[5]: scope 2 at $DIR/unreachable_asm_2.rs:18:16: 22:10 +- goto -> bb6; // bb4[6]: scope 2 at $DIR/unreachable_asm_2.rs:14:9: 22:10 ++ unreachable; // bb4[6]: scope 2 at $DIR/unreachable_asm_2.rs:14:9: 22:10 + } + + bb5: { + StorageLive(_7); // bb5[0]: scope 2 at $DIR/unreachable_asm_2.rs:16:13: 16:41 + llvm_asm!(LlvmInlineAsmInner { asm: "NOP", asm_str_style: Cooked, outputs: [], inputs: [], clobbers: [], volatile: true, alignstack: false, dialect: Att } : [] : []); // bb5[1]: scope 3 at $DIR/unreachable_asm_2.rs:16:22: 16:39 + _7 = (); // bb5[2]: scope 3 at $DIR/unreachable_asm_2.rs:16:13: 16:41 + StorageDead(_7); // bb5[3]: scope 2 at $DIR/unreachable_asm_2.rs:16:40: 16:41 + _4 = const 21i32; // bb5[4]: scope 2 at $DIR/unreachable_asm_2.rs:17:13: 17:20 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000015)) + // mir::Constant + // + span: $DIR/unreachable_asm_2.rs:17:18: 17:20 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000015)) } + _5 = (); // bb5[5]: scope 2 at $DIR/unreachable_asm_2.rs:14:17: 18:10 +- goto -> bb6; // bb5[6]: scope 2 at $DIR/unreachable_asm_2.rs:14:9: 22:10 +- } +- +- bb6: { +- StorageDead(_6); // bb6[0]: scope 2 at $DIR/unreachable_asm_2.rs:22:9: 22:10 +- StorageDead(_5); // bb6[1]: scope 2 at $DIR/unreachable_asm_2.rs:22:9: 22:10 +- StorageLive(_9); // bb6[2]: scope 2 at $DIR/unreachable_asm_2.rs:24:9: 24:21 +- unreachable; // bb6[3]: scope 2 at $DIR/unreachable_asm_2.rs:24:15: 24:17 ++ unreachable; // bb5[6]: scope 2 at $DIR/unreachable_asm_2.rs:14:9: 22:10 + } + } + diff --git a/src/test/mir-opt/unreachable_diverging.rs b/src/test/mir-opt/unreachable_diverging.rs index bf05019d5ce..53c753f717b 100644 --- a/src/test/mir-opt/unreachable_diverging.rs +++ b/src/test/mir-opt/unreachable_diverging.rs @@ -8,6 +8,7 @@ fn loop_forever() { loop {} } +// EMIT_MIR rustc.main.UnreachablePropagation.diff fn main() { let x = true; if let Some(bomb) = empty() { @@ -17,49 +18,3 @@ fn main() { match bomb {} } } - -// END RUST SOURCE -// START rustc.main.UnreachablePropagation.before.mir -// bb3: { -// StorageLive(_4); -// _4 = move ((_2 as Some).0: Empty); -// StorageLive(_5); -// StorageLive(_6); -// _6 = _1; -// switchInt(_6) -> [false: bb4, otherwise: bb5]; -// } -// bb4: { -// _5 = (); -// goto -> bb6; -// } -// bb5: { -// _5 = const loop_forever() -> bb6; -// } -// bb6: { -// StorageDead(_6); -// StorageDead(_5); -// StorageLive(_7); -// unreachable; -// } -// } -// END rustc.main.UnreachablePropagation.before.mir -// START rustc.main.UnreachablePropagation.after.mir -// bb3: { -// StorageLive(_4); -// _4 = move ((_2 as Some).0: Empty); -// StorageLive(_5); -// StorageLive(_6); -// _6 = _1; -// goto -> bb4; -// } -// bb4: { -// _5 = const loop_forever() -> bb5; -// } -// bb5: { -// StorageDead(_6); -// StorageDead(_5); -// StorageLive(_7); -// unreachable; -// } -// } -// END rustc.main.UnreachablePropagation.after.mir diff --git a/src/test/mir-opt/unreachable_diverging/rustc.main.UnreachablePropagation.diff b/src/test/mir-opt/unreachable_diverging/rustc.main.UnreachablePropagation.diff new file mode 100644 index 00000000000..8d1d137f192 --- /dev/null +++ b/src/test/mir-opt/unreachable_diverging/rustc.main.UnreachablePropagation.diff @@ -0,0 +1,89 @@ +- // MIR for `main` before UnreachablePropagation ++ // MIR for `main` after UnreachablePropagation + + fn main() -> () { + let mut _0: (); // return place in scope 0 at $DIR/unreachable_diverging.rs:12:11: 12:11 + let _1: bool; // in scope 0 at $DIR/unreachable_diverging.rs:13:9: 13:10 + let mut _2: std::option::Option<Empty>; // in scope 0 at $DIR/unreachable_diverging.rs:14:25: 14:32 + let mut _3: isize; // in scope 0 at $DIR/unreachable_diverging.rs:14:12: 14:22 + let _5: (); // in scope 0 at $DIR/unreachable_diverging.rs:15:9: 17:10 + let mut _6: bool; // in scope 0 at $DIR/unreachable_diverging.rs:15:12: 15:13 + let mut _7: !; // in scope 0 at $DIR/unreachable_diverging.rs:18:9: 18:22 + scope 1 { + debug x => _1; // in scope 1 at $DIR/unreachable_diverging.rs:13:9: 13:10 + let _4: Empty; // in scope 1 at $DIR/unreachable_diverging.rs:14:17: 14:21 + scope 2 { + debug bomb => _4; // in scope 2 at $DIR/unreachable_diverging.rs:14:17: 14:21 + } + } + + bb0: { + StorageLive(_1); // bb0[0]: scope 0 at $DIR/unreachable_diverging.rs:13:9: 13:10 + _1 = const true; // bb0[1]: scope 0 at $DIR/unreachable_diverging.rs:13:13: 13:17 + // ty::Const + // + ty: bool + // + val: Value(Scalar(0x01)) + // mir::Constant + // + span: $DIR/unreachable_diverging.rs:13:13: 13:17 + // + literal: Const { ty: bool, val: Value(Scalar(0x01)) } + StorageLive(_2); // bb0[2]: scope 1 at $DIR/unreachable_diverging.rs:14:25: 14:32 + _2 = const empty() -> bb1; // bb0[3]: scope 1 at $DIR/unreachable_diverging.rs:14:25: 14:32 + // ty::Const + // + ty: fn() -> std::option::Option<Empty> {empty} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/unreachable_diverging.rs:14:25: 14:30 + // + literal: Const { ty: fn() -> std::option::Option<Empty> {empty}, val: Value(Scalar(<ZST>)) } + } + + bb1: { + _3 = discriminant(_2); // bb1[0]: scope 1 at $DIR/unreachable_diverging.rs:14:12: 14:22 + switchInt(move _3) -> [1isize: bb3, otherwise: bb2]; // bb1[1]: scope 1 at $DIR/unreachable_diverging.rs:14:12: 14:22 + } + + bb2: { + _0 = (); // bb2[0]: scope 1 at $DIR/unreachable_diverging.rs:14:5: 19:6 + StorageDead(_1); // bb2[1]: scope 0 at $DIR/unreachable_diverging.rs:20:1: 20:2 + StorageDead(_2); // bb2[2]: scope 0 at $DIR/unreachable_diverging.rs:20:1: 20:2 + return; // bb2[3]: scope 0 at $DIR/unreachable_diverging.rs:20:2: 20:2 + } + + bb3: { + StorageLive(_4); // bb3[0]: scope 1 at $DIR/unreachable_diverging.rs:14:17: 14:21 + _4 = move ((_2 as Some).0: Empty); // bb3[1]: scope 1 at $DIR/unreachable_diverging.rs:14:17: 14:21 + StorageLive(_5); // bb3[2]: scope 2 at $DIR/unreachable_diverging.rs:15:9: 17:10 + StorageLive(_6); // bb3[3]: scope 2 at $DIR/unreachable_diverging.rs:15:12: 15:13 + _6 = _1; // bb3[4]: scope 2 at $DIR/unreachable_diverging.rs:15:12: 15:13 +- switchInt(_6) -> [false: bb4, otherwise: bb5]; // bb3[5]: scope 2 at $DIR/unreachable_diverging.rs:15:9: 17:10 ++ goto -> bb4; // bb3[5]: scope 2 at $DIR/unreachable_diverging.rs:15:9: 17:10 + } + + bb4: { +- _5 = (); // bb4[0]: scope 2 at $DIR/unreachable_diverging.rs:15:9: 17:10 +- goto -> bb6; // bb4[1]: scope 2 at $DIR/unreachable_diverging.rs:15:9: 17:10 +- } +- +- bb5: { +- _5 = const loop_forever() -> bb6; // bb5[0]: scope 2 at $DIR/unreachable_diverging.rs:16:13: 16:27 ++ _5 = const loop_forever() -> bb5; // bb4[0]: scope 2 at $DIR/unreachable_diverging.rs:16:13: 16:27 + // ty::Const + // + ty: fn() {loop_forever} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/unreachable_diverging.rs:16:13: 16:25 + // + literal: Const { ty: fn() {loop_forever}, val: Value(Scalar(<ZST>)) } + } + +- bb6: { +- StorageDead(_6); // bb6[0]: scope 2 at $DIR/unreachable_diverging.rs:17:9: 17:10 +- StorageDead(_5); // bb6[1]: scope 2 at $DIR/unreachable_diverging.rs:17:9: 17:10 +- StorageLive(_7); // bb6[2]: scope 2 at $DIR/unreachable_diverging.rs:18:9: 18:22 +- unreachable; // bb6[3]: scope 2 at $DIR/unreachable_diverging.rs:18:15: 18:19 ++ bb5: { ++ StorageDead(_6); // bb5[0]: scope 2 at $DIR/unreachable_diverging.rs:17:9: 17:10 ++ StorageDead(_5); // bb5[1]: scope 2 at $DIR/unreachable_diverging.rs:17:9: 17:10 ++ StorageLive(_7); // bb5[2]: scope 2 at $DIR/unreachable_diverging.rs:18:9: 18:22 ++ unreachable; // bb5[3]: scope 2 at $DIR/unreachable_diverging.rs:18:15: 18:19 + } + } + diff --git a/src/test/mir-opt/unusual-item-types.rs b/src/test/mir-opt/unusual-item-types.rs index 88cfb62a0d0..ffe8ca01dfb 100644 --- a/src/test/mir-opt/unusual-item-types.rs +++ b/src/test/mir-opt/unusual-item-types.rs @@ -1,86 +1,29 @@ // Test that we don't ICE when trying to dump MIR for unusual item types and // that we don't create filenames containing `<` and `>` -// ignore-tidy-linelength + +// EMIT_MIR_FOR_EACH_BIT_WIDTH struct A; +// EMIT_MIR rustc.{{impl}}-ASSOCIATED_CONSTANT.mir_map.0.mir impl A { const ASSOCIATED_CONSTANT: i32 = 2; } // See #59021 +// EMIT_MIR rustc.Test-X-{{constructor}}.mir_map.0.mir enum Test { X(usize), Y { a: usize }, } +// EMIT_MIR rustc.E-V-{{constant}}.mir_map.0.mir enum E { V = 5, } fn main() { let f = Test::X as fn(usize) -> Test; +// EMIT_MIR rustc.ptr-drop_in_place.std__vec__Vec_i32_.AddMovesForPackedDrops.before.mir let v = Vec::<i32>::new(); } - -// END RUST SOURCE - -// START rustc.{{impl}}-ASSOCIATED_CONSTANT.mir_map.0.mir -// bb0: { -// _0 = const 2i32; -// return; -// } -// bb1 (cleanup): { -// resume; -// } -// END rustc.{{impl}}-ASSOCIATED_CONSTANT.mir_map.0.mir - -// START rustc.E-V-{{constant}}.mir_map.0.mir -// bb0: { -// _0 = const 5isize; -// return; -// } -// bb1 (cleanup): { -// resume; -// } -// END rustc.E-V-{{constant}}.mir_map.0.mir - -// START rustc.ptr-drop_in_place.std__vec__Vec_i32_.AddMovesForPackedDrops.before.mir -// bb0: { -// goto -> bb7; -// } -// bb1: { -// return; -// } -// bb2 (cleanup): { -// resume; -// } -// bb3: { -// goto -> bb1; -// } -// bb4 (cleanup): { -// goto -> bb2; -// } -// bb5 (cleanup): { -// drop(((*_1).0: alloc::raw_vec::RawVec<i32>)) -> bb4; -// } -// bb6: { -// drop(((*_1).0: alloc::raw_vec::RawVec<i32>)) -> [return: bb3, unwind: bb4]; -// } -// bb7: { -// _2 = &mut (*_1); -// _3 = const <std::vec::Vec<i32> as std::ops::Drop>::drop(move _2) -> [return: bb6, unwind: bb5]; -// } -// END rustc.ptr-drop_in_place.std__vec__Vec_i32_.AddMovesForPackedDrops.before.mir - -// START rustc.Test-X-{{constructor}}.mir_map.0.mir -// fn Test::X(_1: usize) -> Test { -// let mut _0: Test; -// -// bb0: { -// ((_0 as X).0: usize) = move _1; -// discriminant(_0) = 0; -// return; -// } -// } -// END rustc.Test-X-{{constructor}}.mir_map.0.mir diff --git a/src/test/mir-opt/unusual-item-types/32bit/rustc.E-V-{{constant}}.mir_map.0.mir b/src/test/mir-opt/unusual-item-types/32bit/rustc.E-V-{{constant}}.mir_map.0.mir new file mode 100644 index 00000000000..3dc8cea1fe8 --- /dev/null +++ b/src/test/mir-opt/unusual-item-types/32bit/rustc.E-V-{{constant}}.mir_map.0.mir @@ -0,0 +1,20 @@ +// MIR for `E::V::{{constant}}#0` 0 mir_map + +E::V::{{constant}}#0: isize = { + let mut _0: isize; // return place in scope 0 at $DIR/unusual-item-types.rs:22:9: 22:10 + + bb0: { + _0 = const 5isize; // bb0[0]: scope 0 at $DIR/unusual-item-types.rs:22:9: 22:10 + // ty::Const + // + ty: isize + // + val: Value(Scalar(0x00000005)) + // mir::Constant + // + span: $DIR/unusual-item-types.rs:22:9: 22:10 + // + literal: Const { ty: isize, val: Value(Scalar(0x00000005)) } + return; // bb0[1]: scope 0 at $DIR/unusual-item-types.rs:22:9: 22:10 + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/unusual-item-types.rs:22:9: 22:10 + } +} diff --git a/src/test/mir-opt/unusual-item-types/32bit/rustc.Test-X-{{constructor}}.mir_map.0.mir b/src/test/mir-opt/unusual-item-types/32bit/rustc.Test-X-{{constructor}}.mir_map.0.mir new file mode 100644 index 00000000000..d6ce06246a1 --- /dev/null +++ b/src/test/mir-opt/unusual-item-types/32bit/rustc.Test-X-{{constructor}}.mir_map.0.mir @@ -0,0 +1,11 @@ +// MIR for `Test::X` 0 mir_map + +fn Test::X(_1: usize) -> Test { + let mut _0: Test; // return place in scope 0 at $DIR/unusual-item-types.rs:16:5: 16:13 + + bb0: { + ((_0 as X).0: usize) = move _1; // bb0[0]: scope 0 at $DIR/unusual-item-types.rs:16:5: 16:13 + discriminant(_0) = 0; // bb0[1]: scope 0 at $DIR/unusual-item-types.rs:16:5: 16:13 + return; // bb0[2]: scope 0 at $DIR/unusual-item-types.rs:16:5: 16:13 + } +} diff --git a/src/test/mir-opt/unusual-item-types/32bit/rustc.ptr-drop_in_place.std__vec__Vec_i32_.AddMovesForPackedDrops.before.mir b/src/test/mir-opt/unusual-item-types/32bit/rustc.ptr-drop_in_place.std__vec__Vec_i32_.AddMovesForPackedDrops.before.mir new file mode 100644 index 00000000000..b78480e774c --- /dev/null +++ b/src/test/mir-opt/unusual-item-types/32bit/rustc.ptr-drop_in_place.std__vec__Vec_i32_.AddMovesForPackedDrops.before.mir @@ -0,0 +1,46 @@ +// MIR for `std::intrinsics::drop_in_place` before AddMovesForPackedDrops + +fn std::intrinsics::drop_in_place(_1: *mut std::vec::Vec<i32>) -> () { + let mut _0: (); // return place in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + let mut _2: &mut std::vec::Vec<i32>; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + let mut _3: (); // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + + bb0: { + goto -> bb7; // bb0[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb1: { + return; // bb1[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb2 (cleanup): { + resume; // bb2[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb3: { + goto -> bb1; // bb3[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb4 (cleanup): { + goto -> bb2; // bb4[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb5 (cleanup): { + drop(((*_1).0: alloc::raw_vec::RawVec<i32>)) -> bb4; // bb5[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb6: { + drop(((*_1).0: alloc::raw_vec::RawVec<i32>)) -> [return: bb3, unwind: bb4]; // bb6[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb7: { + _2 = &mut (*_1); // bb7[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + _3 = const <std::vec::Vec<i32> as std::ops::Drop>::drop(move _2) -> [return: bb6, unwind: bb5]; // bb7[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + // ty::Const + // + ty: for<'r> fn(&'r mut std::vec::Vec<i32>) {<std::vec::Vec<i32> as std::ops::Drop>::drop} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $SRC_DIR/libcore/ptr/mod.rs:LL:COL + // + literal: Const { ty: for<'r> fn(&'r mut std::vec::Vec<i32>) {<std::vec::Vec<i32> as std::ops::Drop>::drop}, val: Value(Scalar(<ZST>)) } + } +} diff --git a/src/test/mir-opt/unusual-item-types/32bit/rustc.{{impl}}-ASSOCIATED_CONSTANT.mir_map.0.mir b/src/test/mir-opt/unusual-item-types/32bit/rustc.{{impl}}-ASSOCIATED_CONSTANT.mir_map.0.mir new file mode 100644 index 00000000000..9f65819bcf8 --- /dev/null +++ b/src/test/mir-opt/unusual-item-types/32bit/rustc.{{impl}}-ASSOCIATED_CONSTANT.mir_map.0.mir @@ -0,0 +1,20 @@ +// MIR for `<impl at $DIR/unusual-item-types.rs:9:1: 11:2>::ASSOCIATED_CONSTANT` 0 mir_map + +const <impl at $DIR/unusual-item-types.rs:9:1: 11:2>::ASSOCIATED_CONSTANT: i32 = { + let mut _0: i32; // return place in scope 0 at $DIR/unusual-item-types.rs:10:32: 10:35 + + bb0: { + _0 = const 2i32; // bb0[0]: scope 0 at $DIR/unusual-item-types.rs:10:38: 10:39 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/unusual-item-types.rs:10:38: 10:39 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } + return; // bb0[1]: scope 0 at $DIR/unusual-item-types.rs:10:5: 10:40 + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/unusual-item-types.rs:10:5: 10:40 + } +} diff --git a/src/test/mir-opt/unusual-item-types/64bit/rustc.E-V-{{constant}}.mir_map.0.mir b/src/test/mir-opt/unusual-item-types/64bit/rustc.E-V-{{constant}}.mir_map.0.mir new file mode 100644 index 00000000000..8434ff47f1c --- /dev/null +++ b/src/test/mir-opt/unusual-item-types/64bit/rustc.E-V-{{constant}}.mir_map.0.mir @@ -0,0 +1,20 @@ +// MIR for `E::V::{{constant}}#0` 0 mir_map + +E::V::{{constant}}#0: isize = { + let mut _0: isize; // return place in scope 0 at $DIR/unusual-item-types.rs:22:9: 22:10 + + bb0: { + _0 = const 5isize; // bb0[0]: scope 0 at $DIR/unusual-item-types.rs:22:9: 22:10 + // ty::Const + // + ty: isize + // + val: Value(Scalar(0x0000000000000005)) + // mir::Constant + // + span: $DIR/unusual-item-types.rs:22:9: 22:10 + // + literal: Const { ty: isize, val: Value(Scalar(0x0000000000000005)) } + return; // bb0[1]: scope 0 at $DIR/unusual-item-types.rs:22:9: 22:10 + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/unusual-item-types.rs:22:9: 22:10 + } +} diff --git a/src/test/mir-opt/unusual-item-types/64bit/rustc.Test-X-{{constructor}}.mir_map.0.mir b/src/test/mir-opt/unusual-item-types/64bit/rustc.Test-X-{{constructor}}.mir_map.0.mir new file mode 100644 index 00000000000..d6ce06246a1 --- /dev/null +++ b/src/test/mir-opt/unusual-item-types/64bit/rustc.Test-X-{{constructor}}.mir_map.0.mir @@ -0,0 +1,11 @@ +// MIR for `Test::X` 0 mir_map + +fn Test::X(_1: usize) -> Test { + let mut _0: Test; // return place in scope 0 at $DIR/unusual-item-types.rs:16:5: 16:13 + + bb0: { + ((_0 as X).0: usize) = move _1; // bb0[0]: scope 0 at $DIR/unusual-item-types.rs:16:5: 16:13 + discriminant(_0) = 0; // bb0[1]: scope 0 at $DIR/unusual-item-types.rs:16:5: 16:13 + return; // bb0[2]: scope 0 at $DIR/unusual-item-types.rs:16:5: 16:13 + } +} diff --git a/src/test/mir-opt/unusual-item-types/64bit/rustc.ptr-drop_in_place.std__vec__Vec_i32_.AddMovesForPackedDrops.before.mir b/src/test/mir-opt/unusual-item-types/64bit/rustc.ptr-drop_in_place.std__vec__Vec_i32_.AddMovesForPackedDrops.before.mir new file mode 100644 index 00000000000..b78480e774c --- /dev/null +++ b/src/test/mir-opt/unusual-item-types/64bit/rustc.ptr-drop_in_place.std__vec__Vec_i32_.AddMovesForPackedDrops.before.mir @@ -0,0 +1,46 @@ +// MIR for `std::intrinsics::drop_in_place` before AddMovesForPackedDrops + +fn std::intrinsics::drop_in_place(_1: *mut std::vec::Vec<i32>) -> () { + let mut _0: (); // return place in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + let mut _2: &mut std::vec::Vec<i32>; // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + let mut _3: (); // in scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + + bb0: { + goto -> bb7; // bb0[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb1: { + return; // bb1[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb2 (cleanup): { + resume; // bb2[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb3: { + goto -> bb1; // bb3[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb4 (cleanup): { + goto -> bb2; // bb4[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb5 (cleanup): { + drop(((*_1).0: alloc::raw_vec::RawVec<i32>)) -> bb4; // bb5[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb6: { + drop(((*_1).0: alloc::raw_vec::RawVec<i32>)) -> [return: bb3, unwind: bb4]; // bb6[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + } + + bb7: { + _2 = &mut (*_1); // bb7[0]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + _3 = const <std::vec::Vec<i32> as std::ops::Drop>::drop(move _2) -> [return: bb6, unwind: bb5]; // bb7[1]: scope 0 at $SRC_DIR/libcore/ptr/mod.rs:LL:COL + // ty::Const + // + ty: for<'r> fn(&'r mut std::vec::Vec<i32>) {<std::vec::Vec<i32> as std::ops::Drop>::drop} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $SRC_DIR/libcore/ptr/mod.rs:LL:COL + // + literal: Const { ty: for<'r> fn(&'r mut std::vec::Vec<i32>) {<std::vec::Vec<i32> as std::ops::Drop>::drop}, val: Value(Scalar(<ZST>)) } + } +} diff --git a/src/test/mir-opt/unusual-item-types/64bit/rustc.{{impl}}-ASSOCIATED_CONSTANT.mir_map.0.mir b/src/test/mir-opt/unusual-item-types/64bit/rustc.{{impl}}-ASSOCIATED_CONSTANT.mir_map.0.mir new file mode 100644 index 00000000000..9f65819bcf8 --- /dev/null +++ b/src/test/mir-opt/unusual-item-types/64bit/rustc.{{impl}}-ASSOCIATED_CONSTANT.mir_map.0.mir @@ -0,0 +1,20 @@ +// MIR for `<impl at $DIR/unusual-item-types.rs:9:1: 11:2>::ASSOCIATED_CONSTANT` 0 mir_map + +const <impl at $DIR/unusual-item-types.rs:9:1: 11:2>::ASSOCIATED_CONSTANT: i32 = { + let mut _0: i32; // return place in scope 0 at $DIR/unusual-item-types.rs:10:32: 10:35 + + bb0: { + _0 = const 2i32; // bb0[0]: scope 0 at $DIR/unusual-item-types.rs:10:38: 10:39 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/unusual-item-types.rs:10:38: 10:39 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } + return; // bb0[1]: scope 0 at $DIR/unusual-item-types.rs:10:5: 10:40 + } + + bb1 (cleanup): { + resume; // bb1[0]: scope 0 at $DIR/unusual-item-types.rs:10:5: 10:40 + } +} diff --git a/src/test/mir-opt/while-storage.rs b/src/test/mir-opt/while-storage.rs index 86c3f79d3a7..56f6c3380a7 100644 --- a/src/test/mir-opt/while-storage.rs +++ b/src/test/mir-opt/while-storage.rs @@ -5,6 +5,7 @@ fn get_bool(c: bool) -> bool { c } +// EMIT_MIR rustc.while_loop.PreCodegen.after.mir fn while_loop(c: bool) { while get_bool(c) { if get_bool(c) { @@ -16,41 +17,3 @@ fn while_loop(c: bool) { fn main() { while_loop(false); } - -// END RUST SOURCE - -// START rustc.while_loop.PreCodegen.after.mir -// bb0: { -// StorageLive(_2); -// StorageLive(_3); -// _3 = _1; -// _2 = const get_bool(move _3) -> bb1; -// } -// bb1: { -// StorageDead(_3); -// switchInt(_2) -> [false: bb6, otherwise: bb2]; -// } -// bb2: { -// StorageLive(_4); -// StorageLive(_5); -// _5 = _1; -// _4 = const get_bool(move _5) -> bb3; -// } -// bb3: { -// StorageDead(_5); -// switchInt(_4) -> [false: bb4, otherwise: bb5]; -// } -// bb4: { -// StorageDead(_4); -// StorageDead(_2); -// goto -> bb0; -// } -// bb5: { -// StorageDead(_4); -// goto -> bb6; -// } -// bb6: { -// StorageDead(_2); -// return; -// } -// END rustc.while_loop.PreCodegen.after.mir diff --git a/src/test/mir-opt/while-storage/rustc.while_loop.PreCodegen.after.mir b/src/test/mir-opt/while-storage/rustc.while_loop.PreCodegen.after.mir new file mode 100644 index 00000000000..8fadcb8c12f --- /dev/null +++ b/src/test/mir-opt/while-storage/rustc.while_loop.PreCodegen.after.mir @@ -0,0 +1,62 @@ +// MIR for `while_loop` after PreCodegen + +fn while_loop(_1: bool) -> () { + debug c => _1; // in scope 0 at $DIR/while-storage.rs:9:15: 9:16 + let mut _0: (); // return place in scope 0 at $DIR/while-storage.rs:9:24: 9:24 + let mut _2: bool; // in scope 0 at $DIR/while-storage.rs:10:11: 10:22 + let mut _3: bool; // in scope 0 at $DIR/while-storage.rs:10:20: 10:21 + let mut _4: bool; // in scope 0 at $DIR/while-storage.rs:11:12: 11:23 + let mut _5: bool; // in scope 0 at $DIR/while-storage.rs:11:21: 11:22 + + bb0: { + StorageLive(_2); // bb0[0]: scope 0 at $DIR/while-storage.rs:10:11: 10:22 + StorageLive(_3); // bb0[1]: scope 0 at $DIR/while-storage.rs:10:20: 10:21 + _3 = _1; // bb0[2]: scope 0 at $DIR/while-storage.rs:10:20: 10:21 + _2 = const get_bool(move _3) -> bb1; // bb0[3]: scope 0 at $DIR/while-storage.rs:10:11: 10:22 + // ty::Const + // + ty: fn(bool) -> bool {get_bool} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/while-storage.rs:10:11: 10:19 + // + literal: Const { ty: fn(bool) -> bool {get_bool}, val: Value(Scalar(<ZST>)) } + } + + bb1: { + StorageDead(_3); // bb1[0]: scope 0 at $DIR/while-storage.rs:10:21: 10:22 + switchInt(_2) -> [false: bb6, otherwise: bb2]; // bb1[1]: scope 0 at $DIR/while-storage.rs:10:5: 14:6 + } + + bb2: { + StorageLive(_4); // bb2[0]: scope 0 at $DIR/while-storage.rs:11:12: 11:23 + StorageLive(_5); // bb2[1]: scope 0 at $DIR/while-storage.rs:11:21: 11:22 + _5 = _1; // bb2[2]: scope 0 at $DIR/while-storage.rs:11:21: 11:22 + _4 = const get_bool(move _5) -> bb3; // bb2[3]: scope 0 at $DIR/while-storage.rs:11:12: 11:23 + // ty::Const + // + ty: fn(bool) -> bool {get_bool} + // + val: Value(Scalar(<ZST>)) + // mir::Constant + // + span: $DIR/while-storage.rs:11:12: 11:20 + // + literal: Const { ty: fn(bool) -> bool {get_bool}, val: Value(Scalar(<ZST>)) } + } + + bb3: { + StorageDead(_5); // bb3[0]: scope 0 at $DIR/while-storage.rs:11:22: 11:23 + switchInt(_4) -> [false: bb4, otherwise: bb5]; // bb3[1]: scope 0 at $DIR/while-storage.rs:11:9: 13:10 + } + + bb4: { + StorageDead(_4); // bb4[0]: scope 0 at $DIR/while-storage.rs:14:5: 14:6 + StorageDead(_2); // bb4[1]: scope 0 at $DIR/while-storage.rs:10:21: 10:22 + goto -> bb0; // bb4[2]: scope 0 at $DIR/while-storage.rs:10:5: 14:6 + } + + bb5: { + StorageDead(_4); // bb5[0]: scope 0 at $DIR/while-storage.rs:14:5: 14:6 + goto -> bb6; // bb5[1]: scope 0 at $DIR/while-storage.rs:12:13: 12:18 + } + + bb6: { + StorageDead(_2); // bb6[0]: scope 0 at $DIR/while-storage.rs:10:21: 10:22 + return; // bb6[1]: scope 0 at $DIR/while-storage.rs:15:2: 15:2 + } +} diff --git a/src/test/run-make-fulldeps/link-args-order/Makefile b/src/test/run-make-fulldeps/link-args-order/Makefile new file mode 100644 index 00000000000..98c1e0eac3b --- /dev/null +++ b/src/test/run-make-fulldeps/link-args-order/Makefile @@ -0,0 +1,10 @@ +# ignore-msvc + +-include ../tools.mk + +RUSTC_FLAGS = -C linker-flavor=ld -C link-arg=a -C link-args="b c" -C link-args="d e" -C link-arg=f +RUSTC_FLAGS_PRE = -C linker-flavor=ld -Z pre-link-arg=a -Z pre-link-args="b c" -Z pre-link-args="d e" -Z pre-link-arg=f + +all: + $(RUSTC) $(RUSTC_FLAGS) empty.rs 2>&1 | $(CGREP) '"a" "b" "c" "d" "e" "f" "g"' + $(RUSTC) $(RUSTC_FLAGS_PRE) empty.rs 2>&1 | $(CGREP) '"a" "b" "c" "d" "e" "f"' diff --git a/src/test/run-make-fulldeps/link-args-order/empty.rs b/src/test/run-make-fulldeps/link-args-order/empty.rs new file mode 100644 index 00000000000..2439171004b --- /dev/null +++ b/src/test/run-make-fulldeps/link-args-order/empty.rs @@ -0,0 +1,6 @@ +#![feature(link_args)] + +#[link_args = "g"] +extern "C" {} + +fn main() {} diff --git a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile index a35174b3c2a..1e267fb9576 100644 --- a/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile +++ b/src/test/run-make-fulldeps/sysroot-crates-are-unstable/Makefile @@ -1,2 +1,2 @@ all: - python2.7 test.py + '$(PYTHON)' test.py diff --git a/src/test/rustdoc/auxiliary/external-macro-src.rs b/src/test/rustdoc/auxiliary/external-macro-src.rs new file mode 100644 index 00000000000..ce20ca5c91e --- /dev/null +++ b/src/test/rustdoc/auxiliary/external-macro-src.rs @@ -0,0 +1,15 @@ +// compile-flags:--remap-path-prefix={{src-base}}=/does-not-exist + +#![doc(html_root_url = "https://example.com/")] + +#[macro_export] +macro_rules! make_foo { + () => { + pub struct Foo; + impl Foo { + pub fn new() -> Foo { + Foo + } + } + } +} diff --git a/src/test/rustdoc/external-macro-src.rs b/src/test/rustdoc/external-macro-src.rs new file mode 100644 index 00000000000..4394415e5c7 --- /dev/null +++ b/src/test/rustdoc/external-macro-src.rs @@ -0,0 +1,15 @@ +// aux-build:external-macro-src.rs +// ignore-tidy-linelength + +#![crate_name = "foo"] + +#[macro_use] +extern crate external_macro_src; + +// @has foo/index.html '//a[@href="../src/foo/external-macro-src.rs.html#4-15"]' '[src]' + +// @has foo/struct.Foo.html +// @has - '//a[@href="https://example.com/src/external_macro_src/external-macro-src.rs.html#8"]' '[src]' +// @has - '//a[@href="https://example.com/src/external_macro_src/external-macro-src.rs.html#9-13"]' '[src]' +// @has - '//a[@href="https://example.com/src/external_macro_src/external-macro-src.rs.html#10-12"]' '[src]' +make_foo!(); diff --git a/src/test/rustdoc/issue-26606.rs b/src/test/rustdoc/issue-26606.rs index d2aa4bbbd12..c8e9a63ea9f 100644 --- a/src/test/rustdoc/issue-26606.rs +++ b/src/test/rustdoc/issue-26606.rs @@ -7,5 +7,5 @@ extern crate issue_26606_macro; // @has issue_26606/constant.FOO.html -// @has - '//a/@href' '../src/issue_26606/auxiliary/issue-26606-macro.rs.html#3' +// @has - '//a/@href' '../src/issue_26606_macro/issue-26606-macro.rs.html#3' make_item!(FOO); diff --git a/src/test/rustdoc/thread-local-src.rs b/src/test/rustdoc/thread-local-src.rs new file mode 100644 index 00000000000..022d81a4dbf --- /dev/null +++ b/src/test/rustdoc/thread-local-src.rs @@ -0,0 +1,6 @@ +#![crate_name = "foo"] + +// @has foo/index.html '//a[@href="../src/foo/thread-local-src.rs.html#1-6"]' '[src]' + +// @has foo/constant.FOO.html '//a/@href' 'https://doc.rust-lang.org/nightly/src/std/' +thread_local!(pub static FOO: bool = false); diff --git a/src/test/ui-fulldeps/lint-group-forbid-always-trumps-cli.rs b/src/test/ui-fulldeps/lint-group-forbid-always-trumps-cli.rs new file mode 100644 index 00000000000..fc19bc03906 --- /dev/null +++ b/src/test/ui-fulldeps/lint-group-forbid-always-trumps-cli.rs @@ -0,0 +1,7 @@ +// aux-build:lint-group-plugin-test.rs +// compile-flags: -F unused -A unused + +fn main() { + let x = 1; + //~^ ERROR unused variable: `x` +} diff --git a/src/test/ui-fulldeps/lint-group-forbid-always-trumps-cli.stderr b/src/test/ui-fulldeps/lint-group-forbid-always-trumps-cli.stderr new file mode 100644 index 00000000000..6bab367b0d1 --- /dev/null +++ b/src/test/ui-fulldeps/lint-group-forbid-always-trumps-cli.stderr @@ -0,0 +1,10 @@ +error: unused variable: `x` + --> $DIR/lint-group-forbid-always-trumps-cli.rs:5:9 + | +LL | let x = 1; + | ^ help: if this is intentional, prefix it with an underscore: `_x` + | + = note: `-F unused-variables` implied by `-F unused` + +error: aborting due to previous error + diff --git a/src/test/ui/anonymous-higher-ranked-lifetime.stderr b/src/test/ui/anonymous-higher-ranked-lifetime.stderr index c6d9a61bdd9..de478417d06 100644 --- a/src/test/ui/anonymous-higher-ranked-lifetime.stderr +++ b/src/test/ui/anonymous-higher-ranked-lifetime.stderr @@ -7,7 +7,7 @@ LL | f1(|_: (), _: ()| {}); | expected signature of `for<'r, 's> fn(&'r (), &'s ()) -> _` ... LL | fn f1<F>(_: F) where F: Fn(&(), &()) {} - | -- ------------ required by this bound in `f1` + | ------------ required by this bound in `f1` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:3:5 @@ -18,7 +18,7 @@ LL | f2(|_: (), _: ()| {}); | expected signature of `for<'a, 'r> fn(&'a (), &'r ()) -> _` ... LL | fn f2<F>(_: F) where F: for<'a> Fn(&'a (), &()) {} - | -- ----------------------- required by this bound in `f2` + | ----------------------- required by this bound in `f2` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:4:5 @@ -29,7 +29,7 @@ LL | f3(|_: (), _: ()| {}); | expected signature of `for<'r> fn(&(), &'r ()) -> _` ... LL | fn f3<'a, F>(_: F) where F: Fn(&'a (), &()) {} - | -- --------------- required by this bound in `f3` + | --------------- required by this bound in `f3` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:5:5 @@ -40,7 +40,7 @@ LL | f4(|_: (), _: ()| {}); | expected signature of `for<'s, 'r> fn(&'s (), &'r ()) -> _` ... LL | fn f4<F>(_: F) where F: for<'r> Fn(&(), &'r ()) {} - | -- ----------------------- required by this bound in `f4` + | ----------------------- required by this bound in `f4` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:6:5 @@ -51,7 +51,7 @@ LL | f5(|_: (), _: ()| {}); | expected signature of `for<'r> fn(&'r (), &'r ()) -> _` ... LL | fn f5<F>(_: F) where F: for<'r> Fn(&'r (), &'r ()) {} - | -- -------------------------- required by this bound in `f5` + | -------------------------- required by this bound in `f5` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:7:5 @@ -62,7 +62,7 @@ LL | g1(|_: (), _: ()| {}); | expected signature of `for<'r> fn(&'r (), std::boxed::Box<(dyn for<'s> std::ops::Fn(&'s ()) + 'static)>) -> _` ... LL | fn g1<F>(_: F) where F: Fn(&(), Box<dyn Fn(&())>) {} - | -- ------------------------- required by this bound in `g1` + | ------------------------- required by this bound in `g1` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:8:5 @@ -73,7 +73,7 @@ LL | g2(|_: (), _: ()| {}); | expected signature of `for<'r> fn(&'r (), for<'s> fn(&'s ())) -> _` ... LL | fn g2<F>(_: F) where F: Fn(&(), fn(&())) {} - | -- ---------------- required by this bound in `g2` + | ---------------- required by this bound in `g2` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:9:5 @@ -84,7 +84,7 @@ LL | g3(|_: (), _: ()| {}); | expected signature of `for<'s> fn(&'s (), std::boxed::Box<(dyn for<'r> std::ops::Fn(&'r ()) + 'static)>) -> _` ... LL | fn g3<F>(_: F) where F: for<'s> Fn(&'s (), Box<dyn Fn(&())>) {} - | -- ------------------------------------ required by this bound in `g3` + | ------------------------------------ required by this bound in `g3` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:10:5 @@ -95,7 +95,7 @@ LL | g4(|_: (), _: ()| {}); | expected signature of `for<'s> fn(&'s (), for<'r> fn(&'r ())) -> _` ... LL | fn g4<F>(_: F) where F: Fn(&(), for<'r> fn(&'r ())) {} - | -- --------------------------- required by this bound in `g4` + | --------------------------- required by this bound in `g4` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:11:5 @@ -106,7 +106,7 @@ LL | h1(|_: (), _: (), _: (), _: ()| {}); | expected signature of `for<'r, 's> fn(&'r (), std::boxed::Box<(dyn for<'t0> std::ops::Fn(&'t0 ()) + 'static)>, &'s (), for<'t0, 't1> fn(&'t0 (), &'t1 ())) -> _` ... LL | fn h1<F>(_: F) where F: Fn(&(), Box<dyn Fn(&())>, &(), fn(&(), &())) {} - | -- -------------------------------------------- required by this bound in `h1` + | -------------------------------------------- required by this bound in `h1` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:12:5 @@ -117,7 +117,7 @@ LL | h2(|_: (), _: (), _: (), _: ()| {}); | expected signature of `for<'r, 't0> fn(&'r (), std::boxed::Box<(dyn for<'s> std::ops::Fn(&'s ()) + 'static)>, &'t0 (), for<'s, 't1> fn(&'s (), &'t1 ())) -> _` ... LL | fn h2<F>(_: F) where F: for<'t0> Fn(&(), Box<dyn Fn(&())>, &'t0 (), fn(&(), &())) {} - | -- --------------------------------------------------------- required by this bound in `h2` + | --------------------------------------------------------- required by this bound in `h2` error: aborting due to 11 previous errors diff --git a/src/test/ui/associated-const/issue-63496.stderr b/src/test/ui/associated-const/issue-63496.stderr index 3a70e7d43c2..34e947030a0 100644 --- a/src/test/ui/associated-const/issue-63496.stderr +++ b/src/test/ui/associated-const/issue-63496.stderr @@ -10,7 +10,7 @@ LL | fn f() -> ([u8; A::C], [u8; A::C]); | cannot infer type | help: use the fully qualified path to an implementation: `<Type as A>::C` | - = note: cannot resolve `_: A` + = note: cannot satisfy `_: A` = note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl` error[E0283]: type annotations needed @@ -25,7 +25,7 @@ LL | fn f() -> ([u8; A::C], [u8; A::C]); | cannot infer type | help: use the fully qualified path to an implementation: `<Type as A>::C` | - = note: cannot resolve `_: A` + = note: cannot satisfy `_: A` = note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl` error: aborting due to 2 previous errors diff --git a/src/test/ui/associated-item/issue-48027.stderr b/src/test/ui/associated-item/issue-48027.stderr index 62a380732a8..98b545c6e0e 100644 --- a/src/test/ui/associated-item/issue-48027.stderr +++ b/src/test/ui/associated-item/issue-48027.stderr @@ -22,7 +22,7 @@ LL | fn return_n(&self) -> [u8; Bar::X]; | cannot infer type | help: use the fully qualified path to an implementation: `<Type as Bar>::X` | - = note: cannot resolve `_: Bar` + = note: cannot satisfy `_: Bar` = note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl` error: aborting due to 2 previous errors diff --git a/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr b/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr index efd5a92a4fc..d5066e39ebc 100644 --- a/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr +++ b/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.stderr @@ -20,7 +20,10 @@ error[E0277]: `<<T as Case1>::C as std::iter::Iterator>::Item` cannot be sent be --> $DIR/bad-bounds-on-assoc-in-trait.rs:36:20 | LL | trait Case1 { - | ----------- required by `Case1` + | ----- +LL | type C: Clone + Iterator<Item: +LL | Send + Iterator<Item: + | ---- required by this bound in `Case1` ... LL | fn assume_case1<T: Case1>() { | ^^^^^ - help: consider further restricting the associated type: `where <<T as Case1>::C as std::iter::Iterator>::Item: std::marker::Send` @@ -33,7 +36,10 @@ error[E0277]: `<<T as Case1>::C as std::iter::Iterator>::Item` cannot be shared --> $DIR/bad-bounds-on-assoc-in-trait.rs:36:20 | LL | trait Case1 { - | ----------- required by `Case1` + | ----- +... +LL | > + Sync>; + | ---- required by this bound in `Case1` ... LL | fn assume_case1<T: Case1>() { | ^^^^^ - help: consider further restricting the associated type: `where <<T as Case1>::C as std::iter::Iterator>::Item: std::marker::Sync` @@ -46,7 +52,10 @@ error[E0277]: `<_ as Lam<&'a u8>>::App` doesn't implement `std::fmt::Debug` --> $DIR/bad-bounds-on-assoc-in-trait.rs:36:20 | LL | trait Case1 { - | ----------- required by `Case1` + | ----- +... +LL | Debug + | ----- required by this bound in `Case1` ... LL | fn assume_case1<T: Case1>() { | ^^^^^ `<_ as Lam<&'a u8>>::App` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug` diff --git a/src/test/ui/associated-types/associated-types-binding-to-type-defined-in-supertrait.stderr b/src/test/ui/associated-types/associated-types-binding-to-type-defined-in-supertrait.stderr index 86e651b53f0..029c923aa7d 100644 --- a/src/test/ui/associated-types/associated-types-binding-to-type-defined-in-supertrait.stderr +++ b/src/test/ui/associated-types/associated-types-binding-to-type-defined-in-supertrait.stderr @@ -2,7 +2,7 @@ error[E0271]: type mismatch resolving `<ModelT as Vehicle>::Color == Blue` --> $DIR/associated-types-binding-to-type-defined-in-supertrait.rs:31:10 | LL | fn blue_car<C:Car<Color=Blue>>(c: C) { - | -------- ---------- required by this bound in `blue_car` + | ---------- required by this bound in `blue_car` ... LL | fn b() { blue_car(ModelT); } | ^^^^^^^^ expected struct `Blue`, found struct `Black` @@ -11,7 +11,7 @@ error[E0271]: type mismatch resolving `<ModelU as Vehicle>::Color == Black` --> $DIR/associated-types-binding-to-type-defined-in-supertrait.rs:32:10 | LL | fn black_car<C:Car<Color=Black>>(c: C) { - | --------- ----------- required by this bound in `black_car` + | ----------- required by this bound in `black_car` ... LL | fn c() { black_car(ModelU); } | ^^^^^^^^^ expected struct `Black`, found struct `Blue` diff --git a/src/test/ui/associated-types/associated-types-eq-3.stderr b/src/test/ui/associated-types/associated-types-eq-3.stderr index d4e6bed8232..a8608abb4d9 100644 --- a/src/test/ui/associated-types/associated-types-eq-3.stderr +++ b/src/test/ui/associated-types/associated-types-eq-3.stderr @@ -15,7 +15,7 @@ error[E0271]: type mismatch resolving `<isize as Foo>::A == Bar` --> $DIR/associated-types-eq-3.rs:38:5 | LL | fn foo1<I: Foo<A=Bar>>(x: I) { - | ---- ----- required by this bound in `foo1` + | ----- required by this bound in `foo1` ... LL | foo1(a); | ^^^^ expected struct `Bar`, found `usize` diff --git a/src/test/ui/associated-types/associated-types-issue-20346.stderr b/src/test/ui/associated-types/associated-types-issue-20346.stderr index cebcae44fd0..8f2b760840c 100644 --- a/src/test/ui/associated-types/associated-types-issue-20346.stderr +++ b/src/test/ui/associated-types/associated-types-issue-20346.stderr @@ -2,7 +2,7 @@ error[E0271]: type mismatch resolving `<Adapter<I> as Iterator>::Item == std::op --> $DIR/associated-types-issue-20346.rs:34:5 | LL | fn is_iterator_of<A, I: Iterator<Item=A>>(_: &I) {} - | -------------- ------ required by this bound in `is_iterator_of` + | ------ required by this bound in `is_iterator_of` ... LL | fn test_adapter<T, I: Iterator<Item=Option<T>>>(it: I) { | - this type parameter diff --git a/src/test/ui/associated-types/associated-types-multiple-types-one-trait.stderr b/src/test/ui/associated-types/associated-types-multiple-types-one-trait.stderr index d56b45dc251..4e481411b4d 100644 --- a/src/test/ui/associated-types/associated-types-multiple-types-one-trait.stderr +++ b/src/test/ui/associated-types/associated-types-multiple-types-one-trait.stderr @@ -5,7 +5,7 @@ LL | want_y(t); | ^^^^^^ expected `i32`, found associated type ... LL | fn want_y<T:Foo<Y=i32>>(t: &T) { } - | ------ ----- required by this bound in `want_y` + | ----- required by this bound in `want_y` | = note: expected type `i32` found associated type `<T as Foo>::Y` @@ -19,7 +19,7 @@ LL | want_x(t); | ^^^^^^ expected `u32`, found associated type ... LL | fn want_x<T:Foo<X=u32>>(t: &T) { } - | ------ ----- required by this bound in `want_x` + | ----- required by this bound in `want_x` | = note: expected type `u32` found associated type `<T as Foo>::X` diff --git a/src/test/ui/associated-types/associated-types-overridden-binding.stderr b/src/test/ui/associated-types/associated-types-overridden-binding.stderr index 9e10ed7b729..3aed85645ae 100644 --- a/src/test/ui/associated-types/associated-types-overridden-binding.stderr +++ b/src/test/ui/associated-types/associated-types-overridden-binding.stderr @@ -2,21 +2,21 @@ error[E0284]: type annotations needed --> $DIR/associated-types-overridden-binding.rs:4:12 | LL | trait Foo: Iterator<Item = i32> {} - | ------------------------------- required by `Foo` + | ---------- required by this bound in `Foo` LL | trait Bar: Foo<Item = u32> {} | ^^^^^^^^^^^^^^^ cannot infer type for type parameter `Self` | - = note: cannot resolve `<Self as std::iter::Iterator>::Item == i32` + = note: cannot satisfy `<Self as std::iter::Iterator>::Item == i32` error[E0284]: type annotations needed --> $DIR/associated-types-overridden-binding.rs:7:21 | LL | trait I32Iterator = Iterator<Item = i32>; - | ----------------------------------------- required by `I32Iterator` + | ---------- required by this bound in `I32Iterator` LL | trait U32Iterator = I32Iterator<Item = u32>; | ^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `Self` | - = note: cannot resolve `<Self as std::iter::Iterator>::Item == i32` + = note: cannot satisfy `<Self as std::iter::Iterator>::Item == i32` error: aborting due to 2 previous errors diff --git a/src/test/ui/associated-types/associated-types-path-2.stderr b/src/test/ui/associated-types/associated-types-path-2.stderr index ec24260ec75..b2599410f05 100644 --- a/src/test/ui/associated-types/associated-types-path-2.stderr +++ b/src/test/ui/associated-types/associated-types-path-2.stderr @@ -13,7 +13,7 @@ error[E0277]: the trait bound `u32: Foo` is not satisfied --> $DIR/associated-types-path-2.rs:29:5 | LL | pub fn f1<T: Foo>(a: T, x: T::A) {} - | -- --- required by this bound in `f1` + | --- required by this bound in `f1` ... LL | f1(2u32, 4u32); | ^^ the trait `Foo` is not implemented for `u32` @@ -28,7 +28,7 @@ error[E0277]: the trait bound `u32: Foo` is not satisfied --> $DIR/associated-types-path-2.rs:35:5 | LL | pub fn f1<T: Foo>(a: T, x: T::A) {} - | -- --- required by this bound in `f1` + | --- required by this bound in `f1` ... LL | f1(2u32, 4i32); | ^^ the trait `Foo` is not implemented for `u32` diff --git a/src/test/ui/associated-types/associated-types-unconstrained.stderr b/src/test/ui/associated-types/associated-types-unconstrained.stderr index 14ce4836f97..2914a7f868b 100644 --- a/src/test/ui/associated-types/associated-types-unconstrained.stderr +++ b/src/test/ui/associated-types/associated-types-unconstrained.stderr @@ -4,7 +4,7 @@ error[E0284]: type annotations needed LL | let x: isize = Foo::bar(); | ^^^^^^^^ cannot infer type | - = note: cannot resolve `<_ as Foo>::A == _` + = note: cannot satisfy `<_ as Foo>::A == _` error: aborting due to previous error diff --git a/src/test/ui/associated-types/defaults-suitability.stderr b/src/test/ui/associated-types/defaults-suitability.stderr index 54e39c4367d..3f6702da2a4 100644 --- a/src/test/ui/associated-types/defaults-suitability.stderr +++ b/src/test/ui/associated-types/defaults-suitability.stderr @@ -128,10 +128,14 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation | LL | type Ty = Vec<[u8]>; | ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + ::: $SRC_DIR/liballoc/vec.rs:LL:COL + | +LL | pub struct Vec<T> { + | - required by this bound in `std::vec::Vec` | = help: the trait `std::marker::Sized` is not implemented for `[u8]` = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> - = note: required by `std::vec::Vec` error: aborting due to 11 previous errors diff --git a/src/test/ui/async-await/async-borrowck-escaping-block-error.fixed b/src/test/ui/async-await/async-borrowck-escaping-block-error.fixed index f004b4180dd..605cfdfe747 100644 --- a/src/test/ui/async-await/async-borrowck-escaping-block-error.fixed +++ b/src/test/ui/async-await/async-borrowck-escaping-block-error.fixed @@ -1,12 +1,18 @@ // edition:2018 // run-rustfix -fn foo() -> Box<impl std::future::Future<Output = u32>> { +fn test_boxed() -> Box<impl std::future::Future<Output = u32>> { let x = 0u32; Box::new(async move { x } ) //~^ ERROR E0373 } +fn test_ref(x: &u32) -> impl std::future::Future<Output = u32> + '_ { + async move { *x } + //~^ ERROR E0373 +} + fn main() { - let _foo = foo(); + let _ = test_boxed(); + let _ = test_ref(&0u32); } diff --git a/src/test/ui/async-await/async-borrowck-escaping-block-error.rs b/src/test/ui/async-await/async-borrowck-escaping-block-error.rs index 4f35fd52ca3..ec752c15fa2 100644 --- a/src/test/ui/async-await/async-borrowck-escaping-block-error.rs +++ b/src/test/ui/async-await/async-borrowck-escaping-block-error.rs @@ -1,12 +1,18 @@ // edition:2018 // run-rustfix -fn foo() -> Box<impl std::future::Future<Output = u32>> { +fn test_boxed() -> Box<impl std::future::Future<Output = u32>> { let x = 0u32; Box::new(async { x } ) //~^ ERROR E0373 } +fn test_ref(x: &u32) -> impl std::future::Future<Output = u32> + '_ { + async { *x } + //~^ ERROR E0373 +} + fn main() { - let _foo = foo(); + let _ = test_boxed(); + let _ = test_ref(&0u32); } diff --git a/src/test/ui/async-await/async-borrowck-escaping-block-error.stderr b/src/test/ui/async-await/async-borrowck-escaping-block-error.stderr index 0eb3971d14a..193026541d0 100644 --- a/src/test/ui/async-await/async-borrowck-escaping-block-error.stderr +++ b/src/test/ui/async-await/async-borrowck-escaping-block-error.stderr @@ -1,4 +1,4 @@ -error[E0373]: closure may outlive the current function, but it borrows `x`, which is owned by the current function +error[E0373]: async block may outlive the current function, but it borrows `x`, which is owned by the current function --> $DIR/async-borrowck-escaping-block-error.rs:6:20 | LL | Box::new(async { x } ) @@ -7,16 +7,35 @@ LL | Box::new(async { x } ) | | `x` is borrowed here | may outlive borrowed value `x` | -note: generator is returned here - --> $DIR/async-borrowck-escaping-block-error.rs:4:13 +note: async block is returned here + --> $DIR/async-borrowck-escaping-block-error.rs:4:20 | -LL | fn foo() -> Box<impl std::future::Future<Output = u32>> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn test_boxed() -> Box<impl std::future::Future<Output = u32>> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: to force the async block to take ownership of `x` (and any other referenced variables), use the `move` keyword | LL | Box::new(async move { x } ) | ^^^^^^^^^^ -error: aborting due to previous error +error[E0373]: async block may outlive the current function, but it borrows `x`, which is owned by the current function + --> $DIR/async-borrowck-escaping-block-error.rs:11:11 + | +LL | async { *x } + | ^^^-^^ + | | | + | | `x` is borrowed here + | may outlive borrowed value `x` + | +note: async block is returned here + --> $DIR/async-borrowck-escaping-block-error.rs:11:5 + | +LL | async { *x } + | ^^^^^^^^^^^^ +help: to force the async block to take ownership of `x` (and any other referenced variables), use the `move` keyword + | +LL | async move { *x } + | ^^^^^^^^^^^ + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0373`. diff --git a/src/test/ui/async-await/async-borrowck-escaping-closure-error.rs b/src/test/ui/async-await/async-borrowck-escaping-closure-error.rs index d2fa5d0a3d0..e667b72aee5 100644 --- a/src/test/ui/async-await/async-borrowck-escaping-closure-error.rs +++ b/src/test/ui/async-await/async-borrowck-escaping-closure-error.rs @@ -1,5 +1,5 @@ // edition:2018 -#![feature(async_closure,async_await)] +#![feature(async_closure)] fn foo() -> Box<dyn std::future::Future<Output = u32>> { let x = 0u32; Box::new((async || x)()) diff --git a/src/test/ui/async-await/async-fn-nonsend.stderr b/src/test/ui/async-await/async-fn-nonsend.stderr index 3a2c42b3837..04df6203e43 100644 --- a/src/test/ui/async-await/async-fn-nonsend.stderr +++ b/src/test/ui/async-await/async-fn-nonsend.stderr @@ -2,7 +2,7 @@ error: future cannot be sent between threads safely --> $DIR/async-fn-nonsend.rs:49:5 | LL | fn assert_send(_: impl Send) {} - | ----------- ---- required by this bound in `assert_send` + | ---- required by this bound in `assert_send` ... LL | assert_send(local_dropped_before_await()); | ^^^^^^^^^^^ future returned by `local_dropped_before_await` is not `Send` @@ -23,7 +23,7 @@ error: future cannot be sent between threads safely --> $DIR/async-fn-nonsend.rs:51:5 | LL | fn assert_send(_: impl Send) {} - | ----------- ---- required by this bound in `assert_send` + | ---- required by this bound in `assert_send` ... LL | assert_send(non_send_temporary_in_match()); | ^^^^^^^^^^^ future returned by `non_send_temporary_in_match` is not `Send` @@ -44,7 +44,7 @@ error: future cannot be sent between threads safely --> $DIR/async-fn-nonsend.rs:53:5 | LL | fn assert_send(_: impl Send) {} - | ----------- ---- required by this bound in `assert_send` + | ---- required by this bound in `assert_send` ... LL | assert_send(non_sync_with_method_call()); | ^^^^^^^^^^^ future returned by `non_sync_with_method_call` is not `Send` diff --git a/src/test/ui/async-await/issue-64130-1-sync.stderr b/src/test/ui/async-await/issue-64130-1-sync.stderr index 8beb31f152a..b7a88c10e74 100644 --- a/src/test/ui/async-await/issue-64130-1-sync.stderr +++ b/src/test/ui/async-await/issue-64130-1-sync.stderr @@ -2,7 +2,7 @@ error: future cannot be shared between threads safely --> $DIR/issue-64130-1-sync.rs:21:5 | LL | fn is_sync<T: Sync>(t: T) { } - | ------- ---- required by this bound in `is_sync` + | ---- required by this bound in `is_sync` ... LL | is_sync(bar()); | ^^^^^^^ future returned by `bar` is not `Sync` diff --git a/src/test/ui/async-await/issue-64130-2-send.stderr b/src/test/ui/async-await/issue-64130-2-send.stderr index 823b88e18c5..ec183088771 100644 --- a/src/test/ui/async-await/issue-64130-2-send.stderr +++ b/src/test/ui/async-await/issue-64130-2-send.stderr @@ -2,7 +2,7 @@ error: future cannot be sent between threads safely --> $DIR/issue-64130-2-send.rs:21:5 | LL | fn is_send<T: Send>(t: T) { } - | ------- ---- required by this bound in `is_send` + | ---- required by this bound in `is_send` ... LL | is_send(bar()); | ^^^^^^^ future returned by `bar` is not `Send` diff --git a/src/test/ui/async-await/issue-64130-3-other.stderr b/src/test/ui/async-await/issue-64130-3-other.stderr index 6456e7abd74..6b40cc9184d 100644 --- a/src/test/ui/async-await/issue-64130-3-other.stderr +++ b/src/test/ui/async-await/issue-64130-3-other.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `Foo: Qux` is not satisfied in `impl std::future:: --> $DIR/issue-64130-3-other.rs:24:5 | LL | fn is_qux<T: Qux>(t: T) { } - | ------ --- required by this bound in `is_qux` + | --- required by this bound in `is_qux` LL | LL | async fn bar() { | - within this `impl std::future::Future` diff --git a/src/test/ui/async-await/issue-64130-non-send-future-diags.stderr b/src/test/ui/async-await/issue-64130-non-send-future-diags.stderr index 662407f7017..0f4441edb13 100644 --- a/src/test/ui/async-await/issue-64130-non-send-future-diags.stderr +++ b/src/test/ui/async-await/issue-64130-non-send-future-diags.stderr @@ -2,7 +2,7 @@ error: future cannot be sent between threads safely --> $DIR/issue-64130-non-send-future-diags.rs:21:5 | LL | fn is_send<T: Send>(t: T) { } - | ------- ---- required by this bound in `is_send` + | ---- required by this bound in `is_send` ... LL | is_send(foo()); | ^^^^^^^ future returned by `foo` is not `Send` diff --git a/src/test/ui/async-await/issue-67252-unnamed-future.stderr b/src/test/ui/async-await/issue-67252-unnamed-future.stderr index 24aedeb9659..cbcc3cf5d78 100644 --- a/src/test/ui/async-await/issue-67252-unnamed-future.stderr +++ b/src/test/ui/async-await/issue-67252-unnamed-future.stderr @@ -2,7 +2,7 @@ error: future cannot be sent between threads safely --> $DIR/issue-67252-unnamed-future.rs:18:5 | LL | fn spawn<T: Send>(_: T) {} - | ----- ---- required by this bound in `spawn` + | ---- required by this bound in `spawn` ... LL | spawn(async { | ^^^^^ future is not `Send` diff --git a/src/test/ui/async-await/issues/issue-65436-raw-ptr-not-send.stderr b/src/test/ui/async-await/issues/issue-65436-raw-ptr-not-send.stderr index 7638ba1fe7d..73e2a92d815 100644 --- a/src/test/ui/async-await/issues/issue-65436-raw-ptr-not-send.stderr +++ b/src/test/ui/async-await/issues/issue-65436-raw-ptr-not-send.stderr @@ -2,7 +2,7 @@ error: future cannot be sent between threads safely --> $DIR/issue-65436-raw-ptr-not-send.rs:12:5 | LL | fn assert_send<T: Send>(_: T) {} - | ----------- ---- required by this bound in `assert_send` + | ---- required by this bound in `assert_send` ... LL | assert_send(async { | ^^^^^^^^^^^ future returned by `main` is not `Send` diff --git a/src/test/ui/async-await/issues/issue-69307-nested.rs b/src/test/ui/async-await/issues/issue-69307-nested.rs new file mode 100644 index 00000000000..b7cdf3987f1 --- /dev/null +++ b/src/test/ui/async-await/issues/issue-69307-nested.rs @@ -0,0 +1,30 @@ +// Regression test for #69307 +// +// Having a `async { .. foo.await .. }` block appear inside of a `+=` +// expression was causing an ICE due to a failure to save/restore +// state in the AST numbering pass when entering a nested body. +// +// check-pass +// edition:2018 + +fn block_on<F>(_: F) -> usize { + 0 +} + +fn main() {} + +async fn bar() { + let mut sum = 0; + sum += { + block_on(async { + baz().await; + let mut inner = 1; + inner += block_on(async { + baz().await; + 0 + }) + }) + }; +} + +async fn baz() {} diff --git a/src/test/ui/async-await/issues/issue-69307.rs b/src/test/ui/async-await/issues/issue-69307.rs new file mode 100644 index 00000000000..4dae96ec8a6 --- /dev/null +++ b/src/test/ui/async-await/issues/issue-69307.rs @@ -0,0 +1,23 @@ +// Regression test for #69307 +// +// Having a `async { .. foo.await .. }` block appear inside of a `+=` +// expression was causing an ICE due to a failure to save/restore +// state in the AST numbering pass when entering a nested body. +// +// check-pass +// edition:2018 + +fn block_on<F>(_: F) -> usize { + 0 +} + +fn main() {} + +async fn bar() { + let mut sum = 0; + sum += block_on(async { + baz().await; + }); +} + +async fn baz() {} diff --git a/src/test/ui/bad/bad-sized.stderr b/src/test/ui/bad/bad-sized.stderr index e9ded557281..5c169af4eb8 100644 --- a/src/test/ui/bad/bad-sized.stderr +++ b/src/test/ui/bad/bad-sized.stderr @@ -14,10 +14,14 @@ error[E0277]: the size for values of type `dyn Trait` cannot be known at compila | LL | let x: Vec<dyn Trait + Sized> = Vec::new(); | ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + ::: $SRC_DIR/liballoc/vec.rs:LL:COL + | +LL | pub struct Vec<T> { + | - required by this bound in `std::vec::Vec` | = help: the trait `std::marker::Sized` is not implemented for `dyn Trait` = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> - = note: required by `std::vec::Vec` error[E0277]: the size for values of type `dyn Trait` cannot be known at compilation time --> $DIR/bad-sized.rs:4:37 diff --git a/src/test/ui/binding/issue-53114-borrow-checks.rs b/src/test/ui/binding/issue-53114-borrow-checks.rs new file mode 100644 index 00000000000..7646472f45f --- /dev/null +++ b/src/test/ui/binding/issue-53114-borrow-checks.rs @@ -0,0 +1,84 @@ +// Issue #53114: NLL's borrow check had some deviations from the old borrow +// checker, and both had some deviations from our ideal state. This test +// captures the behavior of how `_` bindings are handled with respect to how we +// flag expressions that are meant to request unsafe blocks. +#![allow(irrefutable_let_patterns)] +struct M; + +fn let_wild_gets_moved_expr() { + let m = M; + drop(m); + let _ = m; // accepted, and want it to continue to be + + let mm = (M, M); // variation on above with `_` in substructure + let (_x, _) = mm; + let (_, _y) = mm; + let (_, _) = mm; +} + +fn match_moved_expr_to_wild() { + let m = M; + drop(m); + match m { _ => { } } // #53114: should eventually be accepted too + //~^ ERROR [E0382] + + let mm = (M, M); // variation on above with `_` in substructure + match mm { (_x, _) => { } } + match mm { (_, _y) => { } } + //~^ ERROR [E0382] + match mm { (_, _) => { } } + //~^ ERROR [E0382] +} + +fn if_let_moved_expr_to_wild() { + let m = M; + drop(m); + if let _ = m { } // #53114: should eventually be accepted too + //~^ ERROR [E0382] + + let mm = (M, M); // variation on above with `_` in substructure + if let (_x, _) = mm { } + if let (_, _y) = mm { } + //~^ ERROR [E0382] + if let (_, _) = mm { } + //~^ ERROR [E0382] +} + +fn let_wild_gets_borrowed_expr() { + let mut m = M; + let r = &mut m; + let _ = m; // accepted, and want it to continue to be + // let _x = m; // (compare with this error.) + drop(r); + + let mut mm = (M, M); // variation on above with `_` in substructure + let (r1, r2) = (&mut mm.0, &mut mm.1); + let (_, _) = mm; + drop((r1, r2)); +} + +fn match_borrowed_expr_to_wild() { + let mut m = M; + let r = &mut m; + match m { _ => {} } ; // accepted, and want it to continue to be + drop(r); + + let mut mm = (M, M); // variation on above with `_` in substructure + let (r1, r2) = (&mut mm.0, &mut mm.1); + match mm { (_, _) => { } } + drop((r1, r2)); +} + +fn if_let_borrowed_expr_to_wild() { + let mut m = M; + let r = &mut m; + if let _ = m { } // accepted, and want it to continue to be + drop(r); + + let mut mm = (M, M); // variation on above with `_` in substructure + let (r1, r2) = (&mut mm.0, &mut mm.1); + if let (_, _) = mm { } + drop((r1, r2)); +} + +fn main() { } diff --git a/src/test/ui/binding/issue-53114-borrow-checks.stderr b/src/test/ui/binding/issue-53114-borrow-checks.stderr new file mode 100644 index 00000000000..2a7a721324d --- /dev/null +++ b/src/test/ui/binding/issue-53114-borrow-checks.stderr @@ -0,0 +1,65 @@ +error[E0382]: use of moved value: `m` + --> $DIR/issue-53114-borrow-checks.rs:22:11 + | +LL | let m = M; + | - move occurs because `m` has type `M`, which does not implement the `Copy` trait +LL | drop(m); + | - value moved here +LL | match m { _ => { } } // #53114: should eventually be accepted too + | ^ value used here after move + +error[E0382]: use of moved value: `mm` + --> $DIR/issue-53114-borrow-checks.rs:27:11 + | +LL | match mm { (_x, _) => { } } + | -- value moved here +LL | match mm { (_, _y) => { } } + | ^^ value used here after partial move + | + = note: move occurs because `mm.0` has type `M`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `mm` + --> $DIR/issue-53114-borrow-checks.rs:29:11 + | +LL | match mm { (_, _y) => { } } + | -- value moved here +LL | +LL | match mm { (_, _) => { } } + | ^^ value used here after partial move + | + = note: move occurs because `mm.1` has type `M`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `m` + --> $DIR/issue-53114-borrow-checks.rs:36:16 + | +LL | let m = M; + | - move occurs because `m` has type `M`, which does not implement the `Copy` trait +LL | drop(m); + | - value moved here +LL | if let _ = m { } // #53114: should eventually be accepted too + | ^ value used here after move + +error[E0382]: use of moved value: `mm` + --> $DIR/issue-53114-borrow-checks.rs:41:22 + | +LL | if let (_x, _) = mm { } + | -- value moved here +LL | if let (_, _y) = mm { } + | ^^ value used here after partial move + | + = note: move occurs because `mm.0` has type `M`, which does not implement the `Copy` trait + +error[E0382]: use of moved value: `mm` + --> $DIR/issue-53114-borrow-checks.rs:43:21 + | +LL | if let (_, _y) = mm { } + | -- value moved here +LL | +LL | if let (_, _) = mm { } + | ^^ value used here after partial move + | + = note: move occurs because `mm.1` has type `M`, which does not implement the `Copy` trait + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0382`. diff --git a/src/test/ui/binding/issue-53114-safety-checks.rs b/src/test/ui/binding/issue-53114-safety-checks.rs new file mode 100644 index 00000000000..28adb7571a9 --- /dev/null +++ b/src/test/ui/binding/issue-53114-safety-checks.rs @@ -0,0 +1,51 @@ +// Issue #53114: NLL's borrow check had some deviations from the old borrow +// checker, and both had some deviations from our ideal state. This test +// captures the behavior of how `_` bindings are handled with respect to how we +// flag expressions that are meant to request unsafe blocks. + +#![feature(untagged_unions)] + +struct I(i64); +struct F(f64); + +union U { a: I, b: F } + +#[repr(packed)] +struct P { + a: &'static i8, + b: &'static u32, +} + +fn let_wild_gets_unsafe_field() { + let u1 = U { a: I(0) }; + let u2 = U { a: I(1) }; + let p = P { a: &2, b: &3 }; + let _ = &p.b; //~ WARN E0133 + //~^ WARN will become a hard error + let _ = u1.a; // #53114: should eventually signal error as well + let _ = &u2.a; //~ ERROR [E0133] + + // variation on above with `_` in substructure + let (_,) = (&p.b,); //~ WARN E0133 + //~^ WARN will become a hard error + let (_,) = (u1.a,); //~ ERROR [E0133] + let (_,) = (&u2.a,); //~ ERROR [E0133] +} + +fn match_unsafe_field_to_wild() { + let u1 = U { a: I(0) }; + let u2 = U { a: I(1) }; + let p = P { a: &2, b: &3 }; + match &p.b { _ => { } } //~ WARN E0133 + //~^ WARN will become a hard error + match u1.a { _ => { } } //~ ERROR [E0133] + match &u2.a { _ => { } } //~ ERROR [E0133] + + // variation on above with `_` in substructure + match (&p.b,) { (_,) => { } } //~ WARN E0133 + //~^ WARN will become a hard error + match (u1.a,) { (_,) => { } } //~ ERROR [E0133] + match (&u2.a,) { (_,) => { } } //~ ERROR [E0133] +} + +fn main() { } diff --git a/src/test/ui/binding/issue-53114-safety-checks.stderr b/src/test/ui/binding/issue-53114-safety-checks.stderr new file mode 100644 index 00000000000..fc714a78bf6 --- /dev/null +++ b/src/test/ui/binding/issue-53114-safety-checks.stderr @@ -0,0 +1,100 @@ +warning: borrow of packed field is unsafe and requires unsafe function or block (error E0133) + --> $DIR/issue-53114-safety-checks.rs:23:13 + | +LL | let _ = &p.b; + | ^^^^ + | + = note: `#[warn(safe_packed_borrows)]` on by default + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #46043 <https://github.com/rust-lang/rust/issues/46043> + = note: fields of packed structs might be misaligned: dereferencing a misaligned pointer or even just creating a misaligned reference is undefined behavior + +error[E0133]: access to union field is unsafe and requires unsafe function or block + --> $DIR/issue-53114-safety-checks.rs:26:13 + | +LL | let _ = &u2.a; + | ^^^^^ access to union field + | + = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior + +warning: borrow of packed field is unsafe and requires unsafe function or block (error E0133) + --> $DIR/issue-53114-safety-checks.rs:29:17 + | +LL | let (_,) = (&p.b,); + | ^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #46043 <https://github.com/rust-lang/rust/issues/46043> + = note: fields of packed structs might be misaligned: dereferencing a misaligned pointer or even just creating a misaligned reference is undefined behavior + +error[E0133]: access to union field is unsafe and requires unsafe function or block + --> $DIR/issue-53114-safety-checks.rs:31:17 + | +LL | let (_,) = (u1.a,); + | ^^^^ access to union field + | + = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior + +error[E0133]: access to union field is unsafe and requires unsafe function or block + --> $DIR/issue-53114-safety-checks.rs:32:17 + | +LL | let (_,) = (&u2.a,); + | ^^^^^ access to union field + | + = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior + +warning: borrow of packed field is unsafe and requires unsafe function or block (error E0133) + --> $DIR/issue-53114-safety-checks.rs:39:11 + | +LL | match &p.b { _ => { } } + | ^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #46043 <https://github.com/rust-lang/rust/issues/46043> + = note: fields of packed structs might be misaligned: dereferencing a misaligned pointer or even just creating a misaligned reference is undefined behavior + +error[E0133]: access to union field is unsafe and requires unsafe function or block + --> $DIR/issue-53114-safety-checks.rs:41:11 + | +LL | match u1.a { _ => { } } + | ^^^^ access to union field + | + = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior + +error[E0133]: access to union field is unsafe and requires unsafe function or block + --> $DIR/issue-53114-safety-checks.rs:42:11 + | +LL | match &u2.a { _ => { } } + | ^^^^^ access to union field + | + = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior + +warning: borrow of packed field is unsafe and requires unsafe function or block (error E0133) + --> $DIR/issue-53114-safety-checks.rs:45:12 + | +LL | match (&p.b,) { (_,) => { } } + | ^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #46043 <https://github.com/rust-lang/rust/issues/46043> + = note: fields of packed structs might be misaligned: dereferencing a misaligned pointer or even just creating a misaligned reference is undefined behavior + +error[E0133]: access to union field is unsafe and requires unsafe function or block + --> $DIR/issue-53114-safety-checks.rs:47:12 + | +LL | match (u1.a,) { (_,) => { } } + | ^^^^ access to union field + | + = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior + +error[E0133]: access to union field is unsafe and requires unsafe function or block + --> $DIR/issue-53114-safety-checks.rs:48:12 + | +LL | match (&u2.a,) { (_,) => { } } + | ^^^^^ access to union field + | + = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0133`. diff --git a/src/test/ui/closures/closure-bounds-cant-promote-superkind-in-struct.stderr b/src/test/ui/closures/closure-bounds-cant-promote-superkind-in-struct.stderr index f565948f479..ffd70fac6b1 100644 --- a/src/test/ui/closures/closure-bounds-cant-promote-superkind-in-struct.stderr +++ b/src/test/ui/closures/closure-bounds-cant-promote-superkind-in-struct.stderr @@ -2,7 +2,7 @@ error[E0277]: `F` cannot be sent between threads safely --> $DIR/closure-bounds-cant-promote-superkind-in-struct.rs:5:22 | LL | struct X<F> where F: FnOnce() + 'static + Send { - | ---------------------------------------------- required by `X` + | ---- required by this bound in `X` ... LL | fn foo<F>(blk: F) -> X<F> where F: FnOnce() + 'static { | ^^^^ `F` cannot be sent between threads safely diff --git a/src/test/ui/closures/closure-bounds-subtype.stderr b/src/test/ui/closures/closure-bounds-subtype.stderr index f746f8502b8..691864c9e1d 100644 --- a/src/test/ui/closures/closure-bounds-subtype.stderr +++ b/src/test/ui/closures/closure-bounds-subtype.stderr @@ -2,7 +2,7 @@ error[E0277]: `F` cannot be shared between threads safely --> $DIR/closure-bounds-subtype.rs:13:22 | LL | fn take_const_owned<F>(_: F) where F: FnOnce() + Sync + Send { - | ---------------- ---- required by this bound in `take_const_owned` + | ---- required by this bound in `take_const_owned` ... LL | take_const_owned(f); | ^ `F` cannot be shared between threads safely diff --git a/src/test/ui/coherence/coherence-unsafe-trait-object-impl.stderr b/src/test/ui/coherence/coherence-unsafe-trait-object-impl.stderr index b5a86acfb97..93a06fccbf5 100644 --- a/src/test/ui/coherence/coherence-unsafe-trait-object-impl.stderr +++ b/src/test/ui/coherence/coherence-unsafe-trait-object-impl.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `&dyn Trait: Trait` is not satisfied --> $DIR/coherence-unsafe-trait-object-impl.rs:15:13 | LL | fn takes_t<S: Trait>(s: S) { - | ------- ----- required by this bound in `takes_t` + | ----- required by this bound in `takes_t` ... LL | takes_t(t); | ^ the trait `Trait` is not implemented for `&dyn Trait` diff --git a/src/test/ui/coherence/impl-foreign-for-locally-defined-fundamental.rs b/src/test/ui/coherence/impl-foreign-for-locally-defined-fundamental.rs index 49b3abc99b7..bc1e18b657f 100644 --- a/src/test/ui/coherence/impl-foreign-for-locally-defined-fundamental.rs +++ b/src/test/ui/coherence/impl-foreign-for-locally-defined-fundamental.rs @@ -8,8 +8,8 @@ extern crate coherence_lib as lib; use lib::*; #[fundamental] -struct Local; +struct Local<T>(T); -impl Remote for Local {} +impl Remote for Local<()> {} fn main() {} diff --git a/src/test/ui/const-generics/issue-61522-array-len-succ.rs b/src/test/ui/const-generics/issue-61522-array-len-succ.rs new file mode 100644 index 00000000000..3b627a5e530 --- /dev/null +++ b/src/test/ui/const-generics/issue-61522-array-len-succ.rs @@ -0,0 +1,14 @@ +#![feature(const_generics)] +//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash + +pub struct MyArray<const COUNT: usize>([u8; COUNT + 1]); +//~^ ERROR constant expression depends on a generic parameter + +impl<const COUNT: usize> MyArray<COUNT> { + fn inner(&self) -> &[u8; COUNT + 1] { + //~^ ERROR constant expression depends on a generic parameter + &self.0 + } +} + +fn main() {} diff --git a/src/test/ui/const-generics/issue-61522-array-len-succ.stderr b/src/test/ui/const-generics/issue-61522-array-len-succ.stderr new file mode 100644 index 00000000000..0c4bd4afce4 --- /dev/null +++ b/src/test/ui/const-generics/issue-61522-array-len-succ.stderr @@ -0,0 +1,26 @@ +warning: the feature `const_generics` is incomplete and may cause the compiler to crash + --> $DIR/issue-61522-array-len-succ.rs:1:12 + | +LL | #![feature(const_generics)] + | ^^^^^^^^^^^^^^ + | + = note: `#[warn(incomplete_features)]` on by default + +error: constant expression depends on a generic parameter + --> $DIR/issue-61522-array-len-succ.rs:4:40 + | +LL | pub struct MyArray<const COUNT: usize>([u8; COUNT + 1]); + | ^^^^^^^^^^^^^^^ + | + = note: this may fail depending on what value the parameter takes + +error: constant expression depends on a generic parameter + --> $DIR/issue-61522-array-len-succ.rs:8:24 + | +LL | fn inner(&self) -> &[u8; COUNT + 1] { + | ^^^^^^^^^^^^^^^^ + | + = note: this may fail depending on what value the parameter takes + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/const-generics/issue-66596-impl-trait-for-str-const-arg.rs b/src/test/ui/const-generics/issue-66596-impl-trait-for-str-const-arg.rs new file mode 100644 index 00000000000..b677dcc4af4 --- /dev/null +++ b/src/test/ui/const-generics/issue-66596-impl-trait-for-str-const-arg.rs @@ -0,0 +1,16 @@ +// check-pass + +#![feature(const_generics)] +//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash + +trait Trait<const NAME: &'static str> { + type Assoc; +} + +impl Trait<"0"> for () { + type Assoc = (); +} + +fn main() { + let _: <() as Trait<"0">>::Assoc = (); +} diff --git a/src/test/ui/const-generics/issue-66596-impl-trait-for-str-const-arg.stderr b/src/test/ui/const-generics/issue-66596-impl-trait-for-str-const-arg.stderr new file mode 100644 index 00000000000..8ab28cc2a85 --- /dev/null +++ b/src/test/ui/const-generics/issue-66596-impl-trait-for-str-const-arg.stderr @@ -0,0 +1,8 @@ +warning: the feature `const_generics` is incomplete and may cause the compiler to crash + --> $DIR/issue-66596-impl-trait-for-str-const-arg.rs:3:12 + | +LL | #![feature(const_generics)] + | ^^^^^^^^^^^^^^ + | + = note: `#[warn(incomplete_features)]` on by default + diff --git a/src/test/ui/consts/const-eval/issue-70723.rs b/src/test/ui/consts/const-eval/issue-70723.rs new file mode 100644 index 00000000000..8b79d5d53c5 --- /dev/null +++ b/src/test/ui/consts/const-eval/issue-70723.rs @@ -0,0 +1,5 @@ +#![feature(const_loop)] + +static _X: () = loop {}; //~ ERROR could not evaluate static initializer + +fn main() {} diff --git a/src/test/ui/consts/const-eval/issue-70723.stderr b/src/test/ui/consts/const-eval/issue-70723.stderr new file mode 100644 index 00000000000..687d6565a71 --- /dev/null +++ b/src/test/ui/consts/const-eval/issue-70723.stderr @@ -0,0 +1,9 @@ +error[E0080]: could not evaluate static initializer + --> $DIR/issue-70723.rs:3:17 + | +LL | static _X: () = loop {}; + | ^^^^^^^ exceeded interpreter step limit (see `#[const_eval_limit]`) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/issue-70804-fn-subtyping.rs b/src/test/ui/consts/const-eval/issue-70804-fn-subtyping.rs new file mode 100644 index 00000000000..59d46ea66c9 --- /dev/null +++ b/src/test/ui/consts/const-eval/issue-70804-fn-subtyping.rs @@ -0,0 +1,10 @@ +// check-pass +#![feature(const_fn)] + +const fn nested(x: (for<'a> fn(&'a ()), String)) -> (fn(&'static ()), String) { + x +} + +pub const TEST: (fn(&'static ()), String) = nested((|_x| (), String::new())); + +fn main() {} diff --git a/src/test/ui/consts/too_generic_eval_ice.stderr b/src/test/ui/consts/too_generic_eval_ice.stderr index ffa28225b79..8b57d237516 100644 --- a/src/test/ui/consts/too_generic_eval_ice.stderr +++ b/src/test/ui/consts/too_generic_eval_ice.stderr @@ -15,7 +15,7 @@ error[E0277]: the size for values of type `A` cannot be known at compilation tim --> $DIR/too_generic_eval_ice.rs:7:13 | LL | pub struct Foo<A, B>(A, B); - | --------------------------- required by `Foo` + | - required by this bound in `Foo` LL | LL | impl<A, B> Foo<A, B> { | - this type parameter needs to be `std::marker::Sized` @@ -30,7 +30,7 @@ error[E0277]: the size for values of type `B` cannot be known at compilation tim --> $DIR/too_generic_eval_ice.rs:7:13 | LL | pub struct Foo<A, B>(A, B); - | --------------------------- required by `Foo` + | - required by this bound in `Foo` LL | LL | impl<A, B> Foo<A, B> { | - this type parameter needs to be `std::marker::Sized` diff --git a/src/test/ui/derives/derives-span-Eq-enum-struct-variant.stderr b/src/test/ui/derives/derives-span-Eq-enum-struct-variant.stderr index 704825c7b38..3d7487a4d92 100644 --- a/src/test/ui/derives/derives-span-Eq-enum-struct-variant.stderr +++ b/src/test/ui/derives/derives-span-Eq-enum-struct-variant.stderr @@ -3,8 +3,12 @@ error[E0277]: the trait bound `Error: std::cmp::Eq` is not satisfied | LL | x: Error | ^^^^^^^^ the trait `std::cmp::Eq` is not implemented for `Error` + | + ::: $SRC_DIR/libcore/cmp.rs:LL:COL + | +LL | pub struct AssertParamIsEq<T: Eq + ?Sized> { + | -- required by this bound in `std::cmp::AssertParamIsEq` | - = note: required by `std::cmp::AssertParamIsEq` = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/derives/derives-span-Eq-enum.stderr b/src/test/ui/derives/derives-span-Eq-enum.stderr index 8d2499614d8..00345243cac 100644 --- a/src/test/ui/derives/derives-span-Eq-enum.stderr +++ b/src/test/ui/derives/derives-span-Eq-enum.stderr @@ -3,8 +3,12 @@ error[E0277]: the trait bound `Error: std::cmp::Eq` is not satisfied | LL | Error | ^^^^^ the trait `std::cmp::Eq` is not implemented for `Error` + | + ::: $SRC_DIR/libcore/cmp.rs:LL:COL + | +LL | pub struct AssertParamIsEq<T: Eq + ?Sized> { + | -- required by this bound in `std::cmp::AssertParamIsEq` | - = note: required by `std::cmp::AssertParamIsEq` = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/derives/derives-span-Eq-struct.stderr b/src/test/ui/derives/derives-span-Eq-struct.stderr index 22db0bf08b7..3d0efa1d147 100644 --- a/src/test/ui/derives/derives-span-Eq-struct.stderr +++ b/src/test/ui/derives/derives-span-Eq-struct.stderr @@ -3,8 +3,12 @@ error[E0277]: the trait bound `Error: std::cmp::Eq` is not satisfied | LL | x: Error | ^^^^^^^^ the trait `std::cmp::Eq` is not implemented for `Error` + | + ::: $SRC_DIR/libcore/cmp.rs:LL:COL + | +LL | pub struct AssertParamIsEq<T: Eq + ?Sized> { + | -- required by this bound in `std::cmp::AssertParamIsEq` | - = note: required by `std::cmp::AssertParamIsEq` = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/derives/derives-span-Eq-tuple-struct.stderr b/src/test/ui/derives/derives-span-Eq-tuple-struct.stderr index eaf14691ff0..2aec8ffdbe7 100644 --- a/src/test/ui/derives/derives-span-Eq-tuple-struct.stderr +++ b/src/test/ui/derives/derives-span-Eq-tuple-struct.stderr @@ -3,8 +3,12 @@ error[E0277]: the trait bound `Error: std::cmp::Eq` is not satisfied | LL | Error | ^^^^^ the trait `std::cmp::Eq` is not implemented for `Error` + | + ::: $SRC_DIR/libcore/cmp.rs:LL:COL + | +LL | pub struct AssertParamIsEq<T: Eq + ?Sized> { + | -- required by this bound in `std::cmp::AssertParamIsEq` | - = note: required by `std::cmp::AssertParamIsEq` = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/derives/deriving-copyclone.stderr b/src/test/ui/derives/deriving-copyclone.stderr index e23d48ca630..5fa2710cbad 100644 --- a/src/test/ui/derives/deriving-copyclone.stderr +++ b/src/test/ui/derives/deriving-copyclone.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `C: std::marker::Copy` is not satisfied --> $DIR/deriving-copyclone.rs:31:13 | LL | fn is_copy<T: Copy>(_: T) {} - | ------- ---- required by this bound in `is_copy` + | ---- required by this bound in `is_copy` ... LL | is_copy(B { a: 1, b: C }); | ^^^^^^^^^^^^^^^^ @@ -16,7 +16,7 @@ error[E0277]: the trait bound `C: std::clone::Clone` is not satisfied --> $DIR/deriving-copyclone.rs:32:14 | LL | fn is_clone<T: Clone>(_: T) {} - | -------- ----- required by this bound in `is_clone` + | ----- required by this bound in `is_clone` ... LL | is_clone(B { a: 1, b: C }); | ^^^^^^^^^^^^^^^^ @@ -30,7 +30,7 @@ error[E0277]: the trait bound `D: std::marker::Copy` is not satisfied --> $DIR/deriving-copyclone.rs:35:13 | LL | fn is_copy<T: Copy>(_: T) {} - | ------- ---- required by this bound in `is_copy` + | ---- required by this bound in `is_copy` ... LL | is_copy(B { a: 1, b: D }); | ^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/did_you_mean/recursion_limit.stderr b/src/test/ui/did_you_mean/recursion_limit.stderr index fc14b7fa5b7..45cb054b80c 100644 --- a/src/test/ui/did_you_mean/recursion_limit.stderr +++ b/src/test/ui/did_you_mean/recursion_limit.stderr @@ -2,7 +2,7 @@ error[E0275]: overflow evaluating the requirement `J: std::marker::Send` --> $DIR/recursion_limit.rs:34:5 | LL | fn is_send<T:Send>() { } - | ------- ---- required by this bound in `is_send` + | ---- required by this bound in `is_send` ... LL | is_send::<A>(); | ^^^^^^^^^^^^ diff --git a/src/test/ui/error-codes/E0152.rs b/src/test/ui/error-codes/E0152.rs index dcaf9208835..94467b9bdde 100644 --- a/src/test/ui/error-codes/E0152.rs +++ b/src/test/ui/error-codes/E0152.rs @@ -1,6 +1,6 @@ #![feature(lang_items)] -#[lang = "arc"] +#[lang = "owned_box"] struct Foo; //~ ERROR E0152 fn main() { diff --git a/src/test/ui/error-codes/E0152.stderr b/src/test/ui/error-codes/E0152.stderr index 29981991ee0..fbaa276ce10 100644 --- a/src/test/ui/error-codes/E0152.stderr +++ b/src/test/ui/error-codes/E0152.stderr @@ -1,4 +1,4 @@ -error[E0152]: found duplicate lang item `arc` +error[E0152]: found duplicate lang item `owned_box` --> $DIR/E0152.rs:4:1 | LL | struct Foo; diff --git a/src/test/ui/error-codes/E0271.stderr b/src/test/ui/error-codes/E0271.stderr index b2dcdf8ee2e..580b5aef07e 100644 --- a/src/test/ui/error-codes/E0271.stderr +++ b/src/test/ui/error-codes/E0271.stderr @@ -2,7 +2,7 @@ error[E0271]: type mismatch resolving `<i8 as Trait>::AssociatedType == u32` --> $DIR/E0271.rs:10:5 | LL | fn foo<T>(t: T) where T: Trait<AssociatedType=u32> { - | --- ------------------ required by this bound in `foo` + | ------------------ required by this bound in `foo` ... LL | foo(3_i8); | ^^^ expected `u32`, found `&str` diff --git a/src/test/ui/error-codes/E0275.stderr b/src/test/ui/error-codes/E0275.stderr index c551a00096e..a9fd0564ff5 100644 --- a/src/test/ui/error-codes/E0275.stderr +++ b/src/test/ui/error-codes/E0275.stderr @@ -2,7 +2,7 @@ error[E0275]: overflow evaluating the requirement `Bar<Bar<Bar<Bar<Bar<Bar<Bar<B --> $DIR/E0275.rs:5:33 | LL | trait Foo {} - | --------- required by `Foo` + | --------- required by this bound in `Foo` ... LL | impl<T> Foo for T where Bar<T>: Foo {} | ^^^ diff --git a/src/test/ui/error-codes/E0277-2.stderr b/src/test/ui/error-codes/E0277-2.stderr index 407e51e4f5f..f5ba46ca01e 100644 --- a/src/test/ui/error-codes/E0277-2.stderr +++ b/src/test/ui/error-codes/E0277-2.stderr @@ -2,7 +2,7 @@ error[E0277]: `*const u8` cannot be sent between threads safely --> $DIR/E0277-2.rs:16:5 | LL | fn is_send<T: Send>() { } - | ------- ---- required by this bound in `is_send` + | ---- required by this bound in `is_send` ... LL | is_send::<Foo>(); | ^^^^^^^^^^^^^^ `*const u8` cannot be sent between threads safely diff --git a/src/test/ui/error-codes/E0277.stderr b/src/test/ui/error-codes/E0277.stderr index a069d048c88..a9ea85d14cf 100644 --- a/src/test/ui/error-codes/E0277.stderr +++ b/src/test/ui/error-codes/E0277.stderr @@ -14,7 +14,7 @@ error[E0277]: the trait bound `i32: Foo` is not satisfied --> $DIR/E0277.rs:17:15 | LL | fn some_func<T: Foo>(foo: T) { - | --------- --- required by this bound in `some_func` + | --- required by this bound in `some_func` ... LL | some_func(5i32); | ^^^^ the trait `Foo` is not implemented for `i32` diff --git a/src/test/ui/error-codes/E0283.stderr b/src/test/ui/error-codes/E0283.stderr index ae5b7c3ae8f..e95583c91a7 100644 --- a/src/test/ui/error-codes/E0283.stderr +++ b/src/test/ui/error-codes/E0283.stderr @@ -7,7 +7,7 @@ LL | fn create() -> u32; LL | let cont: u32 = Generator::create(); | ^^^^^^^^^^^^^^^^^ cannot infer type | - = note: cannot resolve `_: Generator` + = note: cannot satisfy `_: Generator` error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0718.rs b/src/test/ui/error-codes/E0718.rs index 82ab2d4af1b..909cae0ba25 100644 --- a/src/test/ui/error-codes/E0718.rs +++ b/src/test/ui/error-codes/E0718.rs @@ -1,7 +1,7 @@ #![feature(lang_items)] -// Arc is expected to be a struct, so this will error. -#[lang = "arc"] //~ ERROR language item must be applied to a struct +// Box is expected to be a struct, so this will error. +#[lang = "owned_box"] //~ ERROR language item must be applied to a struct static X: u32 = 42; fn main() {} diff --git a/src/test/ui/error-codes/E0718.stderr b/src/test/ui/error-codes/E0718.stderr index 412c856ce06..30378dd1674 100644 --- a/src/test/ui/error-codes/E0718.stderr +++ b/src/test/ui/error-codes/E0718.stderr @@ -1,8 +1,8 @@ -error[E0718]: `arc` language item must be applied to a struct +error[E0718]: `owned_box` language item must be applied to a struct --> $DIR/E0718.rs:4:1 | -LL | #[lang = "arc"] - | ^^^^^^^^^^^^^^^ attribute should be applied to a struct, not a static item +LL | #[lang = "owned_box"] + | ^^^^^^^^^^^^^^^^^^^^^ attribute should be applied to a struct, not a static item error: aborting due to previous error diff --git a/src/test/ui/error-should-say-copy-not-pod.stderr b/src/test/ui/error-should-say-copy-not-pod.stderr index d0148f418e3..96ffa6f3e06 100644 --- a/src/test/ui/error-should-say-copy-not-pod.stderr +++ b/src/test/ui/error-should-say-copy-not-pod.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `std::string::String: std::marker::Copy` is not sa --> $DIR/error-should-say-copy-not-pod.rs:6:17 | LL | fn check_bound<T:Copy>(_: T) {} - | ----------- ---- required by this bound in `check_bound` + | ---- required by this bound in `check_bound` ... LL | check_bound("nocopy".to_string()); | ^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::string::String` diff --git a/src/test/ui/extern/extern-types-not-sync-send.stderr b/src/test/ui/extern/extern-types-not-sync-send.stderr index c395f3875ea..a1138c32344 100644 --- a/src/test/ui/extern/extern-types-not-sync-send.stderr +++ b/src/test/ui/extern/extern-types-not-sync-send.stderr @@ -2,7 +2,7 @@ error[E0277]: `A` cannot be shared between threads safely --> $DIR/extern-types-not-sync-send.rs:13:19 | LL | fn assert_sync<T: ?Sized + Sync>() { } - | ----------- ---- required by this bound in `assert_sync` + | ---- required by this bound in `assert_sync` ... LL | assert_sync::<A>(); | ^ `A` cannot be shared between threads safely @@ -13,7 +13,7 @@ error[E0277]: `A` cannot be sent between threads safely --> $DIR/extern-types-not-sync-send.rs:16:19 | LL | fn assert_send<T: ?Sized + Send>() { } - | ----------- ---- required by this bound in `assert_send` + | ---- required by this bound in `assert_send` ... LL | assert_send::<A>(); | ^ `A` cannot be sent between threads safely diff --git a/src/test/ui/extern/extern-types-unsized.stderr b/src/test/ui/extern/extern-types-unsized.stderr index 871757ec7b0..9ed52511fa3 100644 --- a/src/test/ui/extern/extern-types-unsized.stderr +++ b/src/test/ui/extern/extern-types-unsized.stderr @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `A` cannot be known at compilation tim --> $DIR/extern-types-unsized.rs:22:20 | LL | fn assert_sized<T>() { } - | ------------ - required by this bound in `assert_sized` + | - required by this bound in `assert_sized` ... LL | assert_sized::<A>(); | ^ doesn't have a size known at compile-time @@ -18,7 +18,7 @@ error[E0277]: the size for values of type `A` cannot be known at compilation tim --> $DIR/extern-types-unsized.rs:25:5 | LL | fn assert_sized<T>() { } - | ------------ - required by this bound in `assert_sized` + | - required by this bound in `assert_sized` ... LL | assert_sized::<Foo>(); | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -31,7 +31,7 @@ error[E0277]: the size for values of type `A` cannot be known at compilation tim --> $DIR/extern-types-unsized.rs:28:5 | LL | fn assert_sized<T>() { } - | ------------ - required by this bound in `assert_sized` + | - required by this bound in `assert_sized` ... LL | assert_sized::<Bar<A>>(); | ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -44,7 +44,7 @@ error[E0277]: the size for values of type `A` cannot be known at compilation tim --> $DIR/extern-types-unsized.rs:31:5 | LL | fn assert_sized<T>() { } - | ------------ - required by this bound in `assert_sized` + | - required by this bound in `assert_sized` ... LL | assert_sized::<Bar<Bar<A>>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time diff --git a/src/test/ui/extern/extern-wrong-value-type.stderr b/src/test/ui/extern/extern-wrong-value-type.stderr index 9a6af8119a8..64f01b47792 100644 --- a/src/test/ui/extern/extern-wrong-value-type.stderr +++ b/src/test/ui/extern/extern-wrong-value-type.stderr @@ -2,7 +2,7 @@ error[E0277]: expected a `std::ops::Fn<()>` closure, found `extern "C" fn() {f}` --> $DIR/extern-wrong-value-type.rs:9:11 | LL | fn is_fn<F>(_: F) where F: Fn() {} - | ----- ---- required by this bound in `is_fn` + | ---- required by this bound in `is_fn` ... LL | is_fn(f); | ^ expected an `Fn<()>` closure, found `extern "C" fn() {f}` diff --git a/src/test/ui/fmt/send-sync.stderr b/src/test/ui/fmt/send-sync.stderr index c8439764eff..b3b53971a37 100644 --- a/src/test/ui/fmt/send-sync.stderr +++ b/src/test/ui/fmt/send-sync.stderr @@ -2,7 +2,7 @@ error[E0277]: `core::fmt::Opaque` cannot be shared between threads safely --> $DIR/send-sync.rs:8:5 | LL | fn send<T: Send>(_: T) {} - | ---- ---- required by this bound in `send` + | ---- required by this bound in `send` ... LL | send(format_args!("{:?}", c)); | ^^^^ `core::fmt::Opaque` cannot be shared between threads safely @@ -18,7 +18,7 @@ error[E0277]: `core::fmt::Opaque` cannot be shared between threads safely --> $DIR/send-sync.rs:9:5 | LL | fn sync<T: Sync>(_: T) {} - | ---- ---- required by this bound in `sync` + | ---- required by this bound in `sync` ... LL | sync(format_args!("{:?}", c)); | ^^^^ `core::fmt::Opaque` cannot be shared between threads safely diff --git a/src/test/ui/fn/fn-trait-formatting.stderr b/src/test/ui/fn/fn-trait-formatting.stderr index 7d4de63759b..e3ada4f6bae 100644 --- a/src/test/ui/fn/fn-trait-formatting.stderr +++ b/src/test/ui/fn/fn-trait-formatting.stderr @@ -35,7 +35,7 @@ error[E0277]: expected a `std::ops::Fn<(isize,)>` closure, found `{integer}` --> $DIR/fn-trait-formatting.rs:19:14 | LL | fn needs_fn<F>(x: F) where F: Fn(isize) -> isize {} - | -------- ------------------ required by this bound in `needs_fn` + | ------------------ required by this bound in `needs_fn` ... LL | needs_fn(1); | ^ expected an `Fn<(isize,)>` closure, found `{integer}` diff --git a/src/test/ui/generator/not-send-sync.stderr b/src/test/ui/generator/not-send-sync.stderr index 0ac1d189b79..5f5211b5092 100644 --- a/src/test/ui/generator/not-send-sync.stderr +++ b/src/test/ui/generator/not-send-sync.stderr @@ -2,7 +2,7 @@ error[E0277]: `std::cell::Cell<i32>` cannot be shared between threads safely --> $DIR/not-send-sync.rs:16:5 | LL | fn assert_send<T: Send>(_: T) {} - | ----------- ---- required by this bound in `main::assert_send` + | ---- required by this bound in `main::assert_send` ... LL | assert_send(|| { | ^^^^^^^^^^^ `std::cell::Cell<i32>` cannot be shared between threads safely @@ -15,7 +15,7 @@ error: future cannot be shared between threads safely --> $DIR/not-send-sync.rs:9:5 | LL | fn assert_sync<T: Sync>(_: T) {} - | ----------- ---- required by this bound in `main::assert_sync` + | ---- required by this bound in `main::assert_sync` ... LL | assert_sync(|| { | ^^^^^^^^^^^ future returned by `main` is not `Sync` diff --git a/src/test/ui/generator/resume-arg-late-bound.stderr b/src/test/ui/generator/resume-arg-late-bound.stderr index 7719d5123f4..ffa440daed8 100644 --- a/src/test/ui/generator/resume-arg-late-bound.stderr +++ b/src/test/ui/generator/resume-arg-late-bound.stderr @@ -2,7 +2,7 @@ error[E0631]: type mismatch in function arguments --> $DIR/resume-arg-late-bound.rs:15:10 | LL | fn test(a: impl for<'a> Generator<&'a mut bool>) {} - | ---- ------------------------------- required by this bound in `test` + | ------------------------------- required by this bound in `test` ... LL | test(gen); | ^^^ diff --git a/src/test/ui/generator/static-not-unpin.stderr b/src/test/ui/generator/static-not-unpin.stderr index 6512d67319b..3bb899cd890 100644 --- a/src/test/ui/generator/static-not-unpin.stderr +++ b/src/test/ui/generator/static-not-unpin.stderr @@ -2,7 +2,7 @@ error[E0277]: `[static generator@$DIR/static-not-unpin.rs:11:25: 13:6 _]` cannot --> $DIR/static-not-unpin.rs:14:18 | LL | fn assert_unpin<T: Unpin>(_: T) { - | ------------ ----- required by this bound in `assert_unpin` + | ----- required by this bound in `assert_unpin` ... LL | assert_unpin(generator); | ^^^^^^^^^ the trait `std::marker::Unpin` is not implemented for `[static generator@$DIR/static-not-unpin.rs:11:25: 13:6 _]` diff --git a/src/test/ui/generic-associated-types/issue-62326-parameter-out-of-range.stderr b/src/test/ui/generic-associated-types/issue-62326-parameter-out-of-range.stderr index 68742396236..88b5c6a0a01 100644 --- a/src/test/ui/generic-associated-types/issue-62326-parameter-out-of-range.stderr +++ b/src/test/ui/generic-associated-types/issue-62326-parameter-out-of-range.stderr @@ -2,9 +2,9 @@ error[E0280]: the requirement `for<'a> <Self as Iterator>::Item<'a>: 'a` is not --> $DIR/issue-62326-parameter-out-of-range.rs:7:20 | LL | trait Iterator { - | -------------- required by `Iterator` + | -------- LL | type Item<'a>: 'a; - | ^^ + | ^^ required by this bound in `Iterator` error: aborting due to previous error diff --git a/src/test/ui/generic-associated-types/iterable.stderr b/src/test/ui/generic-associated-types/iterable.stderr index b5bc0c76c2f..dc62ee53c06 100644 --- a/src/test/ui/generic-associated-types/iterable.stderr +++ b/src/test/ui/generic-associated-types/iterable.stderr @@ -38,7 +38,10 @@ error[E0271]: type mismatch resolving `for<'a> <<std::vec::Vec<T> as Iterable>:: --> $DIR/iterable.rs:19:30 | LL | trait Iterable { - | -------------- required by `Iterable` + | -------- +LL | type Item<'a> where Self: 'a; +LL | type Iter<'a>: Iterator<Item = Self::Item<'a>> where Self: 'a; + | --------------------- required by this bound in `Iterable` ... LL | fn iter<'a>(&'a self) -> Self::Iter<'a> { | ^^^^^^^^^^^^^^ expected associated type, found reference @@ -52,7 +55,10 @@ error[E0271]: type mismatch resolving `for<'a> <<[T] as Iterable>::Iter<'a> as s --> $DIR/iterable.rs:31:30 | LL | trait Iterable { - | -------------- required by `Iterable` + | -------- +LL | type Item<'a> where Self: 'a; +LL | type Iter<'a>: Iterator<Item = Self::Item<'a>> where Self: 'a; + | --------------------- required by this bound in `Iterable` ... LL | fn iter<'a>(&'a self) -> Self::Iter<'a> { | ^^^^^^^^^^^^^^ expected associated type, found reference diff --git a/src/test/ui/hrtb/issue-46989.stderr b/src/test/ui/hrtb/issue-46989.stderr index c818041e596..0a7382c4dd8 100644 --- a/src/test/ui/hrtb/issue-46989.stderr +++ b/src/test/ui/hrtb/issue-46989.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `for<'r> fn(&'r i32): Foo` is not satisfied --> $DIR/issue-46989.rs:40:18 | LL | fn assert_foo<T: Foo>() {} - | ---------- --- required by this bound in `assert_foo` + | --- required by this bound in `assert_foo` ... LL | assert_foo::<fn(&i32)>(); | ^^^^^^^^ the trait `Foo` is not implemented for `for<'r> fn(&'r i32)` diff --git a/src/test/ui/impl-trait/auto-trait-leak.stderr b/src/test/ui/impl-trait/auto-trait-leak.stderr index 3d60cbff320..164524be1bc 100644 --- a/src/test/ui/impl-trait/auto-trait-leak.stderr +++ b/src/test/ui/impl-trait/auto-trait-leak.stderr @@ -258,7 +258,7 @@ error[E0277]: `std::rc::Rc<std::string::String>` cannot be sent between threads --> $DIR/auto-trait-leak.rs:16:5 | LL | fn send<T: Send>(_: T) {} - | ---- ---- required by this bound in `send` + | ---- required by this bound in `send` ... LL | send(cycle2().clone()); | ^^^^ `std::rc::Rc<std::string::String>` cannot be sent between threads safely diff --git a/src/test/ui/impl-trait/auto-trait-leak2.stderr b/src/test/ui/impl-trait/auto-trait-leak2.stderr index a93b3dbc71b..b02ef7d4a5b 100644 --- a/src/test/ui/impl-trait/auto-trait-leak2.stderr +++ b/src/test/ui/impl-trait/auto-trait-leak2.stderr @@ -5,7 +5,7 @@ LL | fn before() -> impl Fn(i32) { | ------------ within this `impl std::ops::Fn<(i32,)>` ... LL | fn send<T: Send>(_: T) {} - | ---- ---- required by this bound in `send` + | ---- required by this bound in `send` ... LL | send(before()); | ^^^^ `std::rc::Rc<std::cell::Cell<i32>>` cannot be sent between threads safely @@ -18,7 +18,7 @@ error[E0277]: `std::rc::Rc<std::cell::Cell<i32>>` cannot be sent between threads --> $DIR/auto-trait-leak2.rs:16:5 | LL | fn send<T: Send>(_: T) {} - | ---- ---- required by this bound in `send` + | ---- required by this bound in `send` ... LL | send(after()); | ^^^^ `std::rc::Rc<std::cell::Cell<i32>>` cannot be sent between threads safely diff --git a/src/test/ui/impl-trait/does-not-live-long-enough.rs b/src/test/ui/impl-trait/does-not-live-long-enough.rs index 6179132b3f6..d2a345231eb 100644 --- a/src/test/ui/impl-trait/does-not-live-long-enough.rs +++ b/src/test/ui/impl-trait/does-not-live-long-enough.rs @@ -4,7 +4,7 @@ struct List { impl List { fn started_with<'a>(&'a self, prefix: &'a str) -> impl Iterator<Item=&'a str> { self.data.iter().filter(|s| s.starts_with(prefix)).map(|s| s.as_ref()) - //~^ ERROR does not live long enough + //~^ ERROR E0373 } } diff --git a/src/test/ui/impl-trait/does-not-live-long-enough.stderr b/src/test/ui/impl-trait/does-not-live-long-enough.stderr index 83d0f87015b..468c2f36629 100644 --- a/src/test/ui/impl-trait/does-not-live-long-enough.stderr +++ b/src/test/ui/impl-trait/does-not-live-long-enough.stderr @@ -1,21 +1,21 @@ -error[E0597]: `prefix` does not live long enough - --> $DIR/does-not-live-long-enough.rs:6:51 +error[E0373]: closure may outlive the current function, but it borrows `prefix`, which is owned by the current function + --> $DIR/does-not-live-long-enough.rs:6:33 | -LL | fn started_with<'a>(&'a self, prefix: &'a str) -> impl Iterator<Item=&'a str> { - | -- lifetime `'a` defined here --------------------------- opaque type requires that `prefix` is borrowed for `'a` LL | self.data.iter().filter(|s| s.starts_with(prefix)).map(|s| s.as_ref()) - | --- ^^^^^^ borrowed value does not live long enough + | ^^^ ------ `prefix` is borrowed here | | - | value captured here -LL | -LL | } - | - `prefix` dropped here while still borrowed + | may outlive borrowed value `prefix` + | +note: closure is returned here + --> $DIR/does-not-live-long-enough.rs:5:55 | -help: you can add a bound to the opaque type to make it last less than `'static` and match `'a` +LL | fn started_with<'a>(&'a self, prefix: &'a str) -> impl Iterator<Item=&'a str> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: to force the closure to take ownership of `prefix` (and any other referenced variables), use the `move` keyword | -LL | fn started_with<'a>(&'a self, prefix: &'a str) -> impl Iterator<Item=&'a str> + 'a { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | self.data.iter().filter(move |s| s.starts_with(prefix)).map(|s| s.as_ref()) + | ^^^^^^^^ error: aborting due to previous error -For more information about this error, try `rustc --explain E0597`. +For more information about this error, try `rustc --explain E0373`. diff --git a/src/test/ui/issues/issue-12028.stderr b/src/test/ui/issues/issue-12028.stderr index fe7e8f89f7f..434c5de2874 100644 --- a/src/test/ui/issues/issue-12028.stderr +++ b/src/test/ui/issues/issue-12028.stderr @@ -4,7 +4,7 @@ error[E0284]: type annotations needed LL | self.input_stream(&mut stream); | ^^^^^^^^^^^^ cannot infer type for type parameter `H` declared on the trait `StreamHash` | - = note: cannot resolve `<_ as StreamHasher>::S == <H as StreamHasher>::S` + = note: cannot satisfy `<_ as StreamHasher>::S == <H as StreamHasher>::S` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-18919.rs b/src/test/ui/issues/issue-18919.rs index 91fbb13cd69..f06771e9ea5 100644 --- a/src/test/ui/issues/issue-18919.rs +++ b/src/test/ui/issues/issue-18919.rs @@ -4,4 +4,9 @@ fn ho_func(f: Option<FuncType>) { //~^ ERROR the size for values of type } +enum Option<T> { + Some(T), + None, +} + fn main() {} diff --git a/src/test/ui/issues/issue-18919.stderr b/src/test/ui/issues/issue-18919.stderr index c8b9045efe6..1ea40d0728e 100644 --- a/src/test/ui/issues/issue-18919.stderr +++ b/src/test/ui/issues/issue-18919.stderr @@ -3,10 +3,12 @@ error[E0277]: the size for values of type `dyn for<'r> std::ops::Fn(&'r isize) - | LL | fn ho_func(f: Option<FuncType>) { | ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time +... +LL | enum Option<T> { + | - required by this bound in `Option` | = help: the trait `std::marker::Sized` is not implemented for `dyn for<'r> std::ops::Fn(&'r isize) -> isize` = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> - = note: required by `std::option::Option` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-1920-1.stderr b/src/test/ui/issues/issue-1920-1.stderr index 089968ede7d..3130434f6f6 100644 --- a/src/test/ui/issues/issue-1920-1.stderr +++ b/src/test/ui/issues/issue-1920-1.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `foo::issue_1920::S: std::clone::Clone` is not sat --> $DIR/issue-1920-1.rs:12:20 | LL | fn assert_clone<T>() where T : Clone { } - | ------------ ----- required by this bound in `assert_clone` + | ----- required by this bound in `assert_clone` ... LL | assert_clone::<foo::issue_1920::S>(); | ^^^^^^^^^^^^^^^^^^ the trait `std::clone::Clone` is not implemented for `foo::issue_1920::S` diff --git a/src/test/ui/issues/issue-1920-2.stderr b/src/test/ui/issues/issue-1920-2.stderr index eaf34e076c0..1084c47f001 100644 --- a/src/test/ui/issues/issue-1920-2.stderr +++ b/src/test/ui/issues/issue-1920-2.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `bar::S: std::clone::Clone` is not satisfied --> $DIR/issue-1920-2.rs:10:20 | LL | fn assert_clone<T>() where T : Clone { } - | ------------ ----- required by this bound in `assert_clone` + | ----- required by this bound in `assert_clone` ... LL | assert_clone::<bar::S>(); | ^^^^^^ the trait `std::clone::Clone` is not implemented for `bar::S` diff --git a/src/test/ui/issues/issue-1920-3.stderr b/src/test/ui/issues/issue-1920-3.stderr index 0550f5feba5..11740317e54 100644 --- a/src/test/ui/issues/issue-1920-3.stderr +++ b/src/test/ui/issues/issue-1920-3.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `issue_1920::S: std::clone::Clone` is not satisfie --> $DIR/issue-1920-3.rs:14:20 | LL | fn assert_clone<T>() where T : Clone { } - | ------------ ----- required by this bound in `assert_clone` + | ----- required by this bound in `assert_clone` ... LL | assert_clone::<foo::issue_1920::S>(); | ^^^^^^^^^^^^^^^^^^ the trait `std::clone::Clone` is not implemented for `issue_1920::S` diff --git a/src/test/ui/issues/issue-20005.stderr b/src/test/ui/issues/issue-20005.stderr index 529571a6b74..19ccf707619 100644 --- a/src/test/ui/issues/issue-20005.stderr +++ b/src/test/ui/issues/issue-20005.stderr @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `Self` cannot be known at compilation --> $DIR/issue-20005.rs:10:49 | LL | trait From<Src> { - | --------------- required by `From` + | --- required by this bound in `From` ... LL | ) -> <Dst as From<Self>>::Result where Dst: From<Self> { | ^^^^^^^^^^- help: consider further restricting `Self`: `, Self: std::marker::Sized` diff --git a/src/test/ui/issues/issue-20413.stderr b/src/test/ui/issues/issue-20413.stderr index 84e64ff74ae..ad33eef07cb 100644 --- a/src/test/ui/issues/issue-20413.stderr +++ b/src/test/ui/issues/issue-20413.stderr @@ -10,7 +10,7 @@ error[E0275]: overflow evaluating the requirement `NoData<NoData<NoData<NoData<N --> $DIR/issue-20413.rs:8:36 | LL | trait Foo { - | --------- required by `Foo` + | --------- required by this bound in `Foo` ... LL | impl<T> Foo for T where NoData<T>: Foo { | ^^^ @@ -148,7 +148,7 @@ error[E0275]: overflow evaluating the requirement `NoData<NoData<NoData<NoData<N --> $DIR/issue-20413.rs:8:36 | LL | trait Foo { - | --------- required by `Foo` + | --------- required by this bound in `Foo` ... LL | impl<T> Foo for T where NoData<T>: Foo { | ^^^ diff --git a/src/test/ui/issues/issue-20433.stderr b/src/test/ui/issues/issue-20433.stderr index abd2290952b..1dab637e489 100644 --- a/src/test/ui/issues/issue-20433.stderr +++ b/src/test/ui/issues/issue-20433.stderr @@ -3,10 +3,14 @@ error[E0277]: the size for values of type `[i32]` cannot be known at compilation | LL | fn iceman(c: Vec<[i32]>) {} | ^^^^^^^^^^ doesn't have a size known at compile-time + | + ::: $SRC_DIR/liballoc/vec.rs:LL:COL + | +LL | pub struct Vec<T> { + | - required by this bound in `std::vec::Vec` | = help: the trait `std::marker::Sized` is not implemented for `[i32]` = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> - = note: required by `std::vec::Vec` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-21763.stderr b/src/test/ui/issues/issue-21763.stderr index 2bede9120cf..3ec876f37d4 100644 --- a/src/test/ui/issues/issue-21763.stderr +++ b/src/test/ui/issues/issue-21763.stderr @@ -2,7 +2,7 @@ error[E0277]: `std::rc::Rc<()>` cannot be sent between threads safely --> $DIR/issue-21763.rs:9:5 | LL | fn foo<T: Send>() {} - | --- ---- required by this bound in `foo` + | ---- required by this bound in `foo` ... LL | foo::<HashMap<Rc<()>, Rc<()>>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::rc::Rc<()>` cannot be sent between threads safely diff --git a/src/test/ui/issues/issue-21837.stderr b/src/test/ui/issues/issue-21837.stderr index ff0c1ca64e2..f7e46b25cf8 100644 --- a/src/test/ui/issues/issue-21837.stderr +++ b/src/test/ui/issues/issue-21837.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `T: Bound` is not satisfied --> $DIR/issue-21837.rs:8:9 | LL | pub struct Foo<T: Bound>(T); - | ---------------------------- required by `Foo` + | ----- required by this bound in `Foo` ... LL | impl<T> Trait2 for Foo<T> {} | ^^^^^^ the trait `Bound` is not implemented for `T` diff --git a/src/test/ui/issues/issue-21974.stderr b/src/test/ui/issues/issue-21974.stderr index 19823499066..fea2c7d5d26 100644 --- a/src/test/ui/issues/issue-21974.stderr +++ b/src/test/ui/issues/issue-21974.stderr @@ -2,12 +2,12 @@ error[E0283]: type annotations needed --> $DIR/issue-21974.rs:11:19 | LL | trait Foo { - | --------- required by `Foo` + | --------- required by this bound in `Foo` ... LL | where &'a T : Foo, | ^^^ cannot infer type for reference `&'a T` | - = note: cannot resolve `&'a T: Foo` + = note: cannot satisfy `&'a T: Foo` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-23281.rs b/src/test/ui/issues/issue-23281.rs index d5f74728862..72716896426 100644 --- a/src/test/ui/issues/issue-23281.rs +++ b/src/test/ui/issues/issue-23281.rs @@ -5,4 +5,8 @@ impl Struct { //~^ ERROR the size for values of type } +struct Vec<T> { + t: T, +} + fn main() {} diff --git a/src/test/ui/issues/issue-23281.stderr b/src/test/ui/issues/issue-23281.stderr index 68a90c6d80f..3b4b8997a70 100644 --- a/src/test/ui/issues/issue-23281.stderr +++ b/src/test/ui/issues/issue-23281.stderr @@ -3,10 +3,12 @@ error[E0277]: the size for values of type `(dyn std::ops::Fn() + 'static)` canno | LL | pub fn function(funs: Vec<dyn Fn() -> ()>) {} | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time +... +LL | struct Vec<T> { + | - required by this bound in `Vec` | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::ops::Fn() + 'static)` = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> - = note: required by `std::vec::Vec` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-24204.stderr b/src/test/ui/issues/issue-24204.stderr index 2a714861da1..64d1b68cbed 100644 --- a/src/test/ui/issues/issue-24204.stderr +++ b/src/test/ui/issues/issue-24204.stderr @@ -2,7 +2,9 @@ error[E0271]: type mismatch resolving `<<T as Trait>::A as MultiDispatch<i32>>:: --> $DIR/issue-24204.rs:14:12 | LL | trait Trait: Sized { - | ------------------ required by `Trait` + | ----- +LL | type A: MultiDispatch<Self::B, O = Self>; + | -------- required by this bound in `Trait` ... LL | fn test<T: Trait<B=i32>>(b: i32) -> T where T::A: MultiDispatch<i32> { T::new(b) } | ^^^^^^^^^^^^ expected type parameter `T`, found associated type diff --git a/src/test/ui/issues/issue-24424.stderr b/src/test/ui/issues/issue-24424.stderr index 538d44c3b2e..9f5e934295b 100644 --- a/src/test/ui/issues/issue-24424.stderr +++ b/src/test/ui/issues/issue-24424.stderr @@ -2,12 +2,12 @@ error[E0283]: type annotations needed --> $DIR/issue-24424.rs:4:57 | LL | trait Trait0<'l0> {} - | ----------------- required by `Trait0` + | ----------------- required by this bound in `Trait0` LL | LL | impl <'l0, 'l1, T0> Trait1<'l0, T0> for bool where T0 : Trait0<'l0>, T0 : Trait0<'l1> {} | ^^^^^^^^^^^ cannot infer type for type parameter `T0` | - = note: cannot resolve `T0: Trait0<'l0>` + = note: cannot satisfy `T0: Trait0<'l0>` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-25076.stderr b/src/test/ui/issues/issue-25076.stderr index 0a13a2bc330..27c577a0d5f 100644 --- a/src/test/ui/issues/issue-25076.stderr +++ b/src/test/ui/issues/issue-25076.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `(): InOut<_>` is not satisfied --> $DIR/issue-25076.rs:10:20 | LL | fn do_fold<B, F: InOut<B, Out=B>>(init: B, f: F) {} - | ------- --------------- required by this bound in `do_fold` + | --------------- required by this bound in `do_fold` ... LL | do_fold(bot(), ()); | ^^ the trait `InOut<_>` is not implemented for `()` diff --git a/src/test/ui/issues/issue-29147.stderr b/src/test/ui/issues/issue-29147.stderr index 1efedb45cac..94aff596354 100644 --- a/src/test/ui/issues/issue-29147.stderr +++ b/src/test/ui/issues/issue-29147.stderr @@ -7,7 +7,7 @@ LL | trait Foo { fn xxx(&self); } LL | let _ = <S5<_>>::xxx; | ^^^^^^^^^^^^ cannot infer type for struct `S5<_>` | - = note: cannot resolve `S5<_>: Foo` + = note: cannot satisfy `S5<_>: Foo` error: aborting due to previous error diff --git a/src/test/ui/issues/issue-29181.rs b/src/test/ui/issues/issue-29181.rs index 45752ad4f62..70e5bc01920 100644 --- a/src/test/ui/issues/issue-29181.rs +++ b/src/test/ui/issues/issue-29181.rs @@ -4,4 +4,6 @@ extern crate issue_29181 as foo; fn main() { 0.homura(); //~ ERROR no method named `homura` found + // Issue #47759, detect existing method on the fundamental impl: + let _ = |x: f64| x * 2.0.exp(); //~ ERROR can't call method `exp` on ambiguous numeric type } diff --git a/src/test/ui/issues/issue-29181.stderr b/src/test/ui/issues/issue-29181.stderr index 250b158ab8e..b66dcb88d00 100644 --- a/src/test/ui/issues/issue-29181.stderr +++ b/src/test/ui/issues/issue-29181.stderr @@ -4,6 +4,18 @@ error[E0599]: no method named `homura` found for type `{integer}` in the current LL | 0.homura(); | ^^^^^^ method not found in `{integer}` -error: aborting due to previous error +error[E0689]: can't call method `exp` on ambiguous numeric type `{float}` + --> $DIR/issue-29181.rs:8:30 + | +LL | let _ = |x: f64| x * 2.0.exp(); + | ^^^ + | +help: you must specify a concrete type for this numeric value, like `f32` + | +LL | let _ = |x: f64| x * 2.0_f32.exp(); + | ^^^^^^^ + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0599`. +Some errors have detailed explanations: E0599, E0689. +For more information about an error, try `rustc --explain E0599`. diff --git a/src/test/ui/issues/issue-32963.stderr b/src/test/ui/issues/issue-32963.stderr index 450c37f456a..34d5c894e36 100644 --- a/src/test/ui/issues/issue-32963.stderr +++ b/src/test/ui/issues/issue-32963.stderr @@ -24,7 +24,7 @@ error[E0277]: the trait bound `dyn Misc: std::marker::Copy` is not satisfied --> $DIR/issue-32963.rs:8:5 | LL | fn size_of_copy<T: Copy+?Sized>() -> usize { mem::size_of::<T>() } - | ------------ ---- required by this bound in `size_of_copy` + | ---- required by this bound in `size_of_copy` ... LL | size_of_copy::<dyn Misc + Copy>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `dyn Misc` diff --git a/src/test/ui/issues/issue-40827.stderr b/src/test/ui/issues/issue-40827.stderr index 3fe47e249f1..a10abb89021 100644 --- a/src/test/ui/issues/issue-40827.stderr +++ b/src/test/ui/issues/issue-40827.stderr @@ -2,7 +2,7 @@ error[E0277]: `std::rc::Rc<Foo>` cannot be sent between threads safely --> $DIR/issue-40827.rs:14:5 | LL | fn f<T: Send>(_: T) {} - | - ---- required by this bound in `f` + | ---- required by this bound in `f` ... LL | f(Foo(Arc::new(Bar::B(None)))); | ^ `std::rc::Rc<Foo>` cannot be sent between threads safely @@ -16,7 +16,7 @@ error[E0277]: `std::rc::Rc<Foo>` cannot be shared between threads safely --> $DIR/issue-40827.rs:14:5 | LL | fn f<T: Send>(_: T) {} - | - ---- required by this bound in `f` + | ---- required by this bound in `f` ... LL | f(Foo(Arc::new(Bar::B(None)))); | ^ `std::rc::Rc<Foo>` cannot be shared between threads safely diff --git a/src/test/ui/issues/issue-54094.rs b/src/test/ui/issues/issue-54094.rs new file mode 100644 index 00000000000..ec38dc40e61 --- /dev/null +++ b/src/test/ui/issues/issue-54094.rs @@ -0,0 +1,14 @@ +// check-pass +trait Zoo { + type X; +} + +impl Zoo for u16 { + type X = usize; +} + +fn foo(abc: <u16 as Zoo>::X) {} + +fn main() { + let x: *const u8 = foo as _; +} diff --git a/src/test/ui/issues/issue-54954.stderr b/src/test/ui/issues/issue-54954.stderr index 4967b82216e..01ed1383ca2 100644 --- a/src/test/ui/issues/issue-54954.stderr +++ b/src/test/ui/issues/issue-54954.stderr @@ -11,9 +11,9 @@ LL | const ARR_LEN: usize = Tt::const_val::<[i8; 123]>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type ... LL | const fn const_val<T: Sized>() -> usize { - | --------- - required by this bound in `Tt::const_val` + | - required by this bound in `Tt::const_val` | - = note: cannot resolve `_: Tt` + = note: cannot satisfy `_: Tt` error[E0080]: evaluation of constant value failed --> $DIR/issue-54954.rs:13:15 diff --git a/src/test/ui/issues/issue-58022.stderr b/src/test/ui/issues/issue-58022.stderr index 70a7c38b834..fb31467ec47 100644 --- a/src/test/ui/issues/issue-58022.stderr +++ b/src/test/ui/issues/issue-58022.stderr @@ -16,7 +16,7 @@ LL | fn new(slice: &[u8; Foo::SIZE]) -> Self; | cannot infer type | help: use the fully qualified path to an implementation: `<Type as Foo>::SIZE` | - = note: cannot resolve `_: Foo` + = note: cannot satisfy `_: Foo` = note: associated constants cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl` error: aborting due to 2 previous errors diff --git a/src/test/ui/iterators/bound.stderr b/src/test/ui/iterators/bound.stderr index 92a91ff4cb1..1a5aad6c36d 100644 --- a/src/test/ui/iterators/bound.stderr +++ b/src/test/ui/iterators/bound.stderr @@ -2,7 +2,7 @@ error[E0277]: `u8` is not an iterator --> $DIR/bound.rs:2:10 | LL | struct S<I: Iterator>(I); - | ------------------------- required by `S` + | -------- required by this bound in `S` LL | struct T(S<u8>); | ^^^^^ `u8` is not an iterator | diff --git a/src/test/ui/kindck/kindck-copy.stderr b/src/test/ui/kindck/kindck-copy.stderr index 3ca9cf7e973..5a7cd458e52 100644 --- a/src/test/ui/kindck/kindck-copy.stderr +++ b/src/test/ui/kindck/kindck-copy.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `&'static mut isize: std::marker::Copy` is not sat --> $DIR/kindck-copy.rs:27:19 | LL | fn assert_copy<T:Copy>() { } - | ----------- ---- required by this bound in `assert_copy` + | ---- required by this bound in `assert_copy` ... LL | assert_copy::<&'static mut isize>(); | ^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `&'static mut isize` @@ -14,7 +14,7 @@ error[E0277]: the trait bound `&'a mut isize: std::marker::Copy` is not satisfie --> $DIR/kindck-copy.rs:28:19 | LL | fn assert_copy<T:Copy>() { } - | ----------- ---- required by this bound in `assert_copy` + | ---- required by this bound in `assert_copy` ... LL | assert_copy::<&'a mut isize>(); | ^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `&'a mut isize` @@ -26,7 +26,7 @@ error[E0277]: the trait bound `std::boxed::Box<isize>: std::marker::Copy` is not --> $DIR/kindck-copy.rs:31:19 | LL | fn assert_copy<T:Copy>() { } - | ----------- ---- required by this bound in `assert_copy` + | ---- required by this bound in `assert_copy` ... LL | assert_copy::<Box<isize>>(); | ^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box<isize>` @@ -35,7 +35,7 @@ error[E0277]: the trait bound `std::string::String: std::marker::Copy` is not sa --> $DIR/kindck-copy.rs:32:19 | LL | fn assert_copy<T:Copy>() { } - | ----------- ---- required by this bound in `assert_copy` + | ---- required by this bound in `assert_copy` ... LL | assert_copy::<String>(); | ^^^^^^ the trait `std::marker::Copy` is not implemented for `std::string::String` @@ -44,7 +44,7 @@ error[E0277]: the trait bound `std::vec::Vec<isize>: std::marker::Copy` is not s --> $DIR/kindck-copy.rs:33:19 | LL | fn assert_copy<T:Copy>() { } - | ----------- ---- required by this bound in `assert_copy` + | ---- required by this bound in `assert_copy` ... LL | assert_copy::<Vec<isize> >(); | ^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::vec::Vec<isize>` @@ -53,7 +53,7 @@ error[E0277]: the trait bound `std::boxed::Box<&'a mut isize>: std::marker::Copy --> $DIR/kindck-copy.rs:34:19 | LL | fn assert_copy<T:Copy>() { } - | ----------- ---- required by this bound in `assert_copy` + | ---- required by this bound in `assert_copy` ... LL | assert_copy::<Box<&'a mut isize>>(); | ^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box<&'a mut isize>` @@ -62,7 +62,7 @@ error[E0277]: the trait bound `std::boxed::Box<dyn Dummy>: std::marker::Copy` is --> $DIR/kindck-copy.rs:42:5 | LL | fn assert_copy<T:Copy>() { } - | ----------- ---- required by this bound in `assert_copy` + | ---- required by this bound in `assert_copy` ... LL | assert_copy::<Box<dyn Dummy>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box<dyn Dummy>` @@ -71,7 +71,7 @@ error[E0277]: the trait bound `std::boxed::Box<dyn Dummy + std::marker::Send>: s --> $DIR/kindck-copy.rs:43:5 | LL | fn assert_copy<T:Copy>() { } - | ----------- ---- required by this bound in `assert_copy` + | ---- required by this bound in `assert_copy` ... LL | assert_copy::<Box<dyn Dummy + Send>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box<dyn Dummy + std::marker::Send>` @@ -80,7 +80,7 @@ error[E0277]: the trait bound `&'a mut (dyn Dummy + std::marker::Send + 'a): std --> $DIR/kindck-copy.rs:46:19 | LL | fn assert_copy<T:Copy>() { } - | ----------- ---- required by this bound in `assert_copy` + | ---- required by this bound in `assert_copy` ... LL | assert_copy::<&'a mut (dyn Dummy + Send)>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `&'a mut (dyn Dummy + std::marker::Send + 'a)` @@ -89,7 +89,7 @@ error[E0277]: the trait bound `MyNoncopyStruct: std::marker::Copy` is not satisf --> $DIR/kindck-copy.rs:64:19 | LL | fn assert_copy<T:Copy>() { } - | ----------- ---- required by this bound in `assert_copy` + | ---- required by this bound in `assert_copy` ... LL | assert_copy::<MyNoncopyStruct>(); | ^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `MyNoncopyStruct` @@ -98,7 +98,7 @@ error[E0277]: the trait bound `std::rc::Rc<isize>: std::marker::Copy` is not sat --> $DIR/kindck-copy.rs:67:19 | LL | fn assert_copy<T:Copy>() { } - | ----------- ---- required by this bound in `assert_copy` + | ---- required by this bound in `assert_copy` ... LL | assert_copy::<Rc<isize>>(); | ^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::rc::Rc<isize>` diff --git a/src/test/ui/kindck/kindck-impl-type-params-2.stderr b/src/test/ui/kindck/kindck-impl-type-params-2.stderr index 318b7b0f10a..984960efaee 100644 --- a/src/test/ui/kindck/kindck-impl-type-params-2.stderr +++ b/src/test/ui/kindck/kindck-impl-type-params-2.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `std::boxed::Box<{integer}>: Foo` is not satisfied --> $DIR/kindck-impl-type-params-2.rs:13:16 | LL | fn take_param<T:Foo>(foo: &T) { } - | ---------- --- required by this bound in `take_param` + | --- required by this bound in `take_param` ... LL | take_param(&x); | ^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box<{integer}>` diff --git a/src/test/ui/kindck/kindck-inherited-copy-bound.curr.stderr b/src/test/ui/kindck/kindck-inherited-copy-bound.curr.stderr index 2a9fd13be5f..7df98366edb 100644 --- a/src/test/ui/kindck/kindck-inherited-copy-bound.curr.stderr +++ b/src/test/ui/kindck/kindck-inherited-copy-bound.curr.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `std::boxed::Box<{integer}>: Foo` is not satisfied --> $DIR/kindck-inherited-copy-bound.rs:21:16 | LL | fn take_param<T:Foo>(foo: &T) { } - | ---------- --- required by this bound in `take_param` + | --- required by this bound in `take_param` ... LL | take_param(&x); | ^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box<{integer}>` diff --git a/src/test/ui/kindck/kindck-inherited-copy-bound.object_safe_for_dispatch.stderr b/src/test/ui/kindck/kindck-inherited-copy-bound.object_safe_for_dispatch.stderr index 6227ada4dc9..6b511e0a6e6 100644 --- a/src/test/ui/kindck/kindck-inherited-copy-bound.object_safe_for_dispatch.stderr +++ b/src/test/ui/kindck/kindck-inherited-copy-bound.object_safe_for_dispatch.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `std::boxed::Box<{integer}>: Foo` is not satisfied --> $DIR/kindck-inherited-copy-bound.rs:21:16 | LL | fn take_param<T:Foo>(foo: &T) { } - | ---------- --- required by this bound in `take_param` + | --- required by this bound in `take_param` ... LL | take_param(&x); | ^^ the trait `std::marker::Copy` is not implemented for `std::boxed::Box<{integer}>` diff --git a/src/test/ui/kindck/kindck-nonsendable-1.stderr b/src/test/ui/kindck/kindck-nonsendable-1.stderr index 39640e37399..c7f9058dd7e 100644 --- a/src/test/ui/kindck/kindck-nonsendable-1.stderr +++ b/src/test/ui/kindck/kindck-nonsendable-1.stderr @@ -2,7 +2,7 @@ error[E0277]: `std::rc::Rc<usize>` cannot be sent between threads safely --> $DIR/kindck-nonsendable-1.rs:9:5 | LL | fn bar<F:FnOnce() + Send>(_: F) { } - | --- ---- required by this bound in `bar` + | ---- required by this bound in `bar` ... LL | bar(move|| foo(x)); | ^^^ ------------- within this `[closure@$DIR/kindck-nonsendable-1.rs:9:9: 9:22 x:std::rc::Rc<usize>]` diff --git a/src/test/ui/kindck/kindck-send-object.stderr b/src/test/ui/kindck/kindck-send-object.stderr index 8708537f863..a59a375c6c8 100644 --- a/src/test/ui/kindck/kindck-send-object.stderr +++ b/src/test/ui/kindck/kindck-send-object.stderr @@ -2,7 +2,7 @@ error[E0277]: `(dyn Dummy + 'static)` cannot be shared between threads safely --> $DIR/kindck-send-object.rs:12:5 | LL | fn assert_send<T:Send>() { } - | ----------- ---- required by this bound in `assert_send` + | ---- required by this bound in `assert_send` ... LL | assert_send::<&'static (dyn Dummy + 'static)>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'static)` cannot be shared between threads safely @@ -14,7 +14,7 @@ error[E0277]: `dyn Dummy` cannot be sent between threads safely --> $DIR/kindck-send-object.rs:17:5 | LL | fn assert_send<T:Send>() { } - | ----------- ---- required by this bound in `assert_send` + | ---- required by this bound in `assert_send` ... LL | assert_send::<Box<dyn Dummy>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `dyn Dummy` cannot be sent between threads safely diff --git a/src/test/ui/kindck/kindck-send-object1.nll.stderr b/src/test/ui/kindck/kindck-send-object1.nll.stderr index f882e06ed22..14a6f554f6d 100644 --- a/src/test/ui/kindck/kindck-send-object1.nll.stderr +++ b/src/test/ui/kindck/kindck-send-object1.nll.stderr @@ -2,7 +2,7 @@ error[E0277]: `(dyn Dummy + 'a)` cannot be shared between threads safely --> $DIR/kindck-send-object1.rs:10:5 | LL | fn assert_send<T:Send+'static>() { } - | ----------- ---- required by this bound in `assert_send` + | ---- required by this bound in `assert_send` ... LL | assert_send::<&'a dyn Dummy>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be shared between threads safely @@ -14,7 +14,7 @@ error[E0277]: `(dyn Dummy + 'a)` cannot be sent between threads safely --> $DIR/kindck-send-object1.rs:29:5 | LL | fn assert_send<T:Send+'static>() { } - | ----------- ---- required by this bound in `assert_send` + | ---- required by this bound in `assert_send` ... LL | assert_send::<Box<dyn Dummy + 'a>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be sent between threads safely diff --git a/src/test/ui/kindck/kindck-send-object1.stderr b/src/test/ui/kindck/kindck-send-object1.stderr index b2e89087e38..b6d82e3195e 100644 --- a/src/test/ui/kindck/kindck-send-object1.stderr +++ b/src/test/ui/kindck/kindck-send-object1.stderr @@ -2,7 +2,7 @@ error[E0277]: `(dyn Dummy + 'a)` cannot be shared between threads safely --> $DIR/kindck-send-object1.rs:10:5 | LL | fn assert_send<T:Send+'static>() { } - | ----------- ---- required by this bound in `assert_send` + | ---- required by this bound in `assert_send` ... LL | assert_send::<&'a dyn Dummy>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be shared between threads safely @@ -22,7 +22,7 @@ error[E0277]: `(dyn Dummy + 'a)` cannot be sent between threads safely --> $DIR/kindck-send-object1.rs:29:5 | LL | fn assert_send<T:Send+'static>() { } - | ----------- ---- required by this bound in `assert_send` + | ---- required by this bound in `assert_send` ... LL | assert_send::<Box<dyn Dummy + 'a>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'a)` cannot be sent between threads safely diff --git a/src/test/ui/kindck/kindck-send-object2.stderr b/src/test/ui/kindck/kindck-send-object2.stderr index 6cb82edf263..e6daf987c8c 100644 --- a/src/test/ui/kindck/kindck-send-object2.stderr +++ b/src/test/ui/kindck/kindck-send-object2.stderr @@ -2,7 +2,7 @@ error[E0277]: `(dyn Dummy + 'static)` cannot be shared between threads safely --> $DIR/kindck-send-object2.rs:7:5 | LL | fn assert_send<T:Send>() { } - | ----------- ---- required by this bound in `assert_send` + | ---- required by this bound in `assert_send` ... LL | assert_send::<&'static dyn Dummy>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `(dyn Dummy + 'static)` cannot be shared between threads safely @@ -14,7 +14,7 @@ error[E0277]: `dyn Dummy` cannot be sent between threads safely --> $DIR/kindck-send-object2.rs:12:5 | LL | fn assert_send<T:Send>() { } - | ----------- ---- required by this bound in `assert_send` + | ---- required by this bound in `assert_send` ... LL | assert_send::<Box<dyn Dummy>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `dyn Dummy` cannot be sent between threads safely diff --git a/src/test/ui/kindck/kindck-send-owned.stderr b/src/test/ui/kindck/kindck-send-owned.stderr index c7403495424..2c6c2c6267d 100644 --- a/src/test/ui/kindck/kindck-send-owned.stderr +++ b/src/test/ui/kindck/kindck-send-owned.stderr @@ -2,7 +2,7 @@ error[E0277]: `*mut u8` cannot be sent between threads safely --> $DIR/kindck-send-owned.rs:12:5 | LL | fn assert_send<T:Send>() { } - | ----------- ---- required by this bound in `assert_send` + | ---- required by this bound in `assert_send` ... LL | assert_send::<Box<*mut u8>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `*mut u8` cannot be sent between threads safely diff --git a/src/test/ui/kindck/kindck-send-unsafe.stderr b/src/test/ui/kindck/kindck-send-unsafe.stderr index 05ed51d0f11..34f98218193 100644 --- a/src/test/ui/kindck/kindck-send-unsafe.stderr +++ b/src/test/ui/kindck/kindck-send-unsafe.stderr @@ -2,7 +2,7 @@ error[E0277]: `*mut &'a isize` cannot be sent between threads safely --> $DIR/kindck-send-unsafe.rs:6:19 | LL | fn assert_send<T:Send>() { } - | ----------- ---- required by this bound in `assert_send` + | ---- required by this bound in `assert_send` ... LL | assert_send::<*mut &'a isize>(); | ^^^^^^^^^^^^^^ `*mut &'a isize` cannot be sent between threads safely diff --git a/src/test/ui/layout/debug.rs b/src/test/ui/layout/debug.rs index 70ae200e3e5..299151df664 100644 --- a/src/test/ui/layout/debug.rs +++ b/src/test/ui/layout/debug.rs @@ -1,15 +1,22 @@ // normalize-stderr-test "pref: Align \{\n *pow2: [1-3],\n *\}" -> "pref: $$PREF_ALIGN" -#![feature(never_type, rustc_attrs)] +#![feature(never_type, rustc_attrs, type_alias_impl_trait)] #![crate_type = "lib"] #[rustc_layout(debug)] -enum E { Foo, Bar(!, i32, i32) } //~ ERROR: layout debugging +enum E { Foo, Bar(!, i32, i32) } //~ ERROR: layout_of #[rustc_layout(debug)] -struct S { f1: i32, f2: (), f3: i32 } //~ ERROR: layout debugging +struct S { f1: i32, f2: (), f3: i32 } //~ ERROR: layout_of #[rustc_layout(debug)] -union U { f1: (i32, i32), f3: i32 } //~ ERROR: layout debugging +union U { f1: (i32, i32), f3: i32 } //~ ERROR: layout_of #[rustc_layout(debug)] -type Test = Result<i32, i32>; //~ ERROR: layout debugging +type Test = Result<i32, i32>; //~ ERROR: layout_of + +#[rustc_layout(debug)] +type T = impl std::fmt::Debug; //~ ERROR: layout_of + +fn f() -> T { + 0i32 +} diff --git a/src/test/ui/layout/debug.stderr b/src/test/ui/layout/debug.stderr index ef88cf1e4c1..153dec594d3 100644 --- a/src/test/ui/layout/debug.stderr +++ b/src/test/ui/layout/debug.stderr @@ -1,4 +1,4 @@ -error: layout debugging: Layout { +error: layout_of(E) = Layout { fields: Arbitrary { offsets: [ Size { @@ -110,7 +110,7 @@ error: layout debugging: Layout { LL | enum E { Foo, Bar(!, i32, i32) } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: layout debugging: Layout { +error: layout_of(S) = Layout { fields: Arbitrary { offsets: [ Size { @@ -164,7 +164,7 @@ error: layout debugging: Layout { LL | struct S { f1: i32, f2: (), f3: i32 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: layout debugging: Layout { +error: layout_of(U) = Layout { fields: Union( 2, ), @@ -190,7 +190,7 @@ error: layout debugging: Layout { LL | union U { f1: (i32, i32), f3: i32 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: layout debugging: Layout { +error: layout_of(std::result::Result<i32, i32>) = Layout { fields: Arbitrary { offsets: [ Size { @@ -315,5 +315,37 @@ error: layout debugging: Layout { LL | type Test = Result<i32, i32>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 4 previous errors +error: layout_of(i32) = Layout { + fields: Union( + 0, + ), + variants: Single { + index: 0, + }, + abi: Scalar( + Scalar { + value: Int( + I32, + true, + ), + valid_range: 0..=4294967295, + }, + ), + largest_niche: None, + align: AbiAndPrefAlign { + abi: Align { + pow2: 2, + }, + pref: $PREF_ALIGN, + }, + size: Size { + raw: 4, + }, +} + --> $DIR/debug.rs:18:1 + | +LL | type T = impl std::fmt::Debug; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 5 previous errors diff --git a/src/test/ui/lint/lint-unconditional-recursion.rs b/src/test/ui/lint/lint-unconditional-recursion.rs index ab60a326cd2..d2a0329585b 100644 --- a/src/test/ui/lint/lint-unconditional-recursion.rs +++ b/src/test/ui/lint/lint-unconditional-recursion.rs @@ -131,4 +131,22 @@ trait Bar { } } +// Do not trigger on functions that may diverge instead of self-recursing (#54444) + +pub fn loops(x: bool) { + if x { + loops(x); + } else { + loop {} + } +} + +pub fn panics(x: bool) { + if x { + panics(!x); + } else { + panic!("panics"); + } +} + fn main() {} diff --git a/src/test/ui/lint/unused_braces.rs b/src/test/ui/lint/unused_braces.rs index de456ee6c23..952398ef068 100644 --- a/src/test/ui/lint/unused_braces.rs +++ b/src/test/ui/lint/unused_braces.rs @@ -1,29 +1,48 @@ // check-pass #![warn(unused_braces, unused_parens)] +fn consume<T>(_: T) {} + fn main() { let _ = (7); //~^WARN unnecessary parentheses - let _ = { 7 }; - //~^ WARN unnecessary braces + // Do not emit a lint in these cases, + // as we have to be careful with + // `ref` patterns. + { + let _ = { 7 }; + + if let 7 = { 7 } { } + + match { 7 } { + _ => (), + } + } - if let 7 = { 7 } { + if { true } { + //~^ WARN unnecessary braces + } + + while { false } { //~^ WARN unnecessary braces } let _: [u8; { 3 }]; //~^ WARN unnecessary braces - // do not emit error for multiline blocks. + consume({ 7 }); + //~^ WARN unnecessary braces + + // Do not emit lint for multiline blocks. let _ = { 7 }; - // do not emit error for unsafe blocks. + // Do not emit lint for unsafe blocks. let _ = unsafe { 7 }; - // do not emit error, as the `{` would then + // Do not emit lint, as the `{` would then // be parsed as part of the `return`. if { return } { diff --git a/src/test/ui/lint/unused_braces.stderr b/src/test/ui/lint/unused_braces.stderr index 72f425ffc3e..f195c002418 100644 --- a/src/test/ui/lint/unused_braces.stderr +++ b/src/test/ui/lint/unused_braces.stderr @@ -1,5 +1,5 @@ warning: unnecessary parentheses around assigned value - --> $DIR/unused_braces.rs:5:13 + --> $DIR/unused_braces.rs:7:13 | LL | let _ = (7); | ^^^ help: remove these parentheses @@ -10,11 +10,11 @@ note: the lint level is defined here LL | #![warn(unused_braces, unused_parens)] | ^^^^^^^^^^^^^ -warning: unnecessary braces around assigned value - --> $DIR/unused_braces.rs:8:13 +warning: unnecessary braces around `if` condition + --> $DIR/unused_braces.rs:23:8 | -LL | let _ = { 7 }; - | ^^^^^ help: remove these braces +LL | if { true } { + | ^^^^^^^^ help: remove these braces | note: the lint level is defined here --> $DIR/unused_braces.rs:2:9 @@ -22,15 +22,21 @@ note: the lint level is defined here LL | #![warn(unused_braces, unused_parens)] | ^^^^^^^^^^^^^ -warning: unnecessary braces around `let` scrutinee expression - --> $DIR/unused_braces.rs:11:16 +warning: unnecessary braces around `while` condition + --> $DIR/unused_braces.rs:27:11 | -LL | if let 7 = { 7 } { - | ^^^^^ help: remove these braces +LL | while { false } { + | ^^^^^^^^^ help: remove these braces warning: unnecessary braces around const expression - --> $DIR/unused_braces.rs:15:17 + --> $DIR/unused_braces.rs:31:17 | LL | let _: [u8; { 3 }]; | ^^^^^ help: remove these braces +warning: unnecessary braces around function argument + --> $DIR/unused_braces.rs:34:13 + | +LL | consume({ 7 }); + | ^^^^^ help: remove these braces + diff --git a/src/test/ui/lint/unused_parens_borrow.rs b/src/test/ui/lint/unused_braces_borrow.rs index 98dbbecfedd..d0b059744e1 100644 --- a/src/test/ui/lint/unused_parens_borrow.rs +++ b/src/test/ui/lint/unused_braces_borrow.rs @@ -10,13 +10,15 @@ struct A { b: u32, } +fn consume<T>(_: T) {} + fn main() { let a = A { a: 42, b: 1729, }; - let _ = &{ a.b }; - let _ = { a.b }; + consume(&{ a.b }); + consume({ a.b }); //~^ WARN unnecessary braces } diff --git a/src/test/ui/lint/unused_parens_borrow.stderr b/src/test/ui/lint/unused_braces_borrow.stderr index 7e3839ae4e0..82fb4375611 100644 --- a/src/test/ui/lint/unused_parens_borrow.stderr +++ b/src/test/ui/lint/unused_braces_borrow.stderr @@ -1,11 +1,11 @@ -warning: unnecessary braces around assigned value - --> $DIR/unused_parens_borrow.rs:20:13 +warning: unnecessary braces around function argument + --> $DIR/unused_braces_borrow.rs:22:13 | -LL | let _ = { a.b }; +LL | consume({ a.b }); | ^^^^^^^ help: remove these braces | note: the lint level is defined here - --> $DIR/unused_parens_borrow.rs:2:9 + --> $DIR/unused_braces_borrow.rs:2:9 | LL | #![warn(unused_braces)] | ^^^^^^^^^^^^^ diff --git a/src/test/ui/marker_trait_attr/overlap-marker-trait.stderr b/src/test/ui/marker_trait_attr/overlap-marker-trait.stderr index 4508870746b..0fc266454ee 100644 --- a/src/test/ui/marker_trait_attr/overlap-marker-trait.stderr +++ b/src/test/ui/marker_trait_attr/overlap-marker-trait.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `NotDebugOrDisplay: Marker` is not satisfied --> $DIR/overlap-marker-trait.rs:27:17 | LL | fn is_marker<T: Marker>() { } - | --------- ------ required by this bound in `is_marker` + | ------ required by this bound in `is_marker` ... LL | is_marker::<NotDebugOrDisplay>(); | ^^^^^^^^^^^^^^^^^ the trait `Marker` is not implemented for `NotDebugOrDisplay` diff --git a/src/test/ui/mismatched_types/E0631.stderr b/src/test/ui/mismatched_types/E0631.stderr index 06f5c058f81..1b10325564a 100644 --- a/src/test/ui/mismatched_types/E0631.stderr +++ b/src/test/ui/mismatched_types/E0631.stderr @@ -2,7 +2,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/E0631.rs:7:5 | LL | fn foo<F: Fn(usize)>(_: F) {} - | --- --------- required by this bound in `foo` + | --------- required by this bound in `foo` ... LL | foo(|_: isize| {}); | ^^^ ---------- found signature of `fn(isize) -> _` @@ -13,7 +13,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/E0631.rs:8:5 | LL | fn bar<F: Fn<usize>>(_: F) {} - | --- --------- required by this bound in `bar` + | --------- required by this bound in `bar` ... LL | bar(|_: isize| {}); | ^^^ ---------- found signature of `fn(isize) -> _` @@ -24,7 +24,7 @@ error[E0631]: type mismatch in function arguments --> $DIR/E0631.rs:9:9 | LL | fn foo<F: Fn(usize)>(_: F) {} - | --- --------- required by this bound in `foo` + | --------- required by this bound in `foo` ... LL | fn f(_: u64) {} | ------------ found signature of `fn(u64) -> _` @@ -36,7 +36,7 @@ error[E0631]: type mismatch in function arguments --> $DIR/E0631.rs:10:9 | LL | fn bar<F: Fn<usize>>(_: F) {} - | --- --------- required by this bound in `bar` + | --------- required by this bound in `bar` LL | fn main() { LL | fn f(_: u64) {} | ------------ found signature of `fn(u64) -> _` diff --git a/src/test/ui/mismatched_types/closure-arg-count.stderr b/src/test/ui/mismatched_types/closure-arg-count.stderr index 13954343246..405343783de 100644 --- a/src/test/ui/mismatched_types/closure-arg-count.stderr +++ b/src/test/ui/mismatched_types/closure-arg-count.stderr @@ -49,7 +49,7 @@ error[E0593]: closure is expected to take 1 argument, but it takes 0 arguments --> $DIR/closure-arg-count.rs:13:5 | LL | fn f<F: Fn<usize>>(_: F) {} - | - --------- required by this bound in `f` + | --------- required by this bound in `f` ... LL | f(|| panic!()); | ^ -- takes 0 arguments @@ -65,7 +65,7 @@ error[E0593]: closure is expected to take 1 argument, but it takes 0 arguments --> $DIR/closure-arg-count.rs:15:5 | LL | fn f<F: Fn<usize>>(_: F) {} - | - --------- required by this bound in `f` + | --------- required by this bound in `f` ... LL | f( move || panic!()); | ^ ---------- takes 0 arguments @@ -150,7 +150,7 @@ LL | call(Foo); | ^^^ expected function that takes 0 arguments ... LL | fn call<F, R>(_: F) where F: FnOnce() -> R {} - | ---- ------------- required by this bound in `call` + | ------------- required by this bound in `call` LL | struct Foo(u8); | --------------- takes 1 argument diff --git a/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr b/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr index ed502824712..69a4b458ebf 100644 --- a/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr +++ b/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr @@ -26,7 +26,7 @@ error[E0631]: type mismatch in function arguments --> $DIR/closure-arg-type-mismatch.rs:10:9 | LL | fn baz<F: Fn(*mut &u32)>(_: F) {} - | --- ------------- required by this bound in `baz` + | ------------- required by this bound in `baz` LL | fn _test<'a>(f: fn(*mut &'a u32)) { LL | baz(f); | ^ @@ -38,7 +38,7 @@ error[E0271]: type mismatch resolving `for<'r> <fn(*mut &'a u32) as std::ops::Fn --> $DIR/closure-arg-type-mismatch.rs:10:5 | LL | fn baz<F: Fn(*mut &u32)>(_: F) {} - | --- ------------- required by this bound in `baz` + | ------------- required by this bound in `baz` LL | fn _test<'a>(f: fn(*mut &'a u32)) { LL | baz(f); | ^^^ expected bound lifetime parameter, found concrete lifetime diff --git a/src/test/ui/mismatched_types/closure-mismatch.stderr b/src/test/ui/mismatched_types/closure-mismatch.stderr index f3874c0907b..389b2157446 100644 --- a/src/test/ui/mismatched_types/closure-mismatch.stderr +++ b/src/test/ui/mismatched_types/closure-mismatch.stderr @@ -2,7 +2,7 @@ error[E0271]: type mismatch resolving `for<'r> <[closure@$DIR/closure-mismatch.r --> $DIR/closure-mismatch.rs:8:5 | LL | fn baz<T: Foo>(_: T) {} - | --- --- required by this bound in `baz` + | --- required by this bound in `baz` ... LL | baz(|_| ()); | ^^^ expected bound lifetime parameter, found concrete lifetime @@ -13,7 +13,7 @@ error[E0631]: type mismatch in closure arguments --> $DIR/closure-mismatch.rs:8:5 | LL | fn baz<T: Foo>(_: T) {} - | --- --- required by this bound in `baz` + | --- required by this bound in `baz` ... LL | baz(|_| ()); | ^^^ ------ found signature of `fn(_) -> _` diff --git a/src/test/ui/mismatched_types/fn-variance-1.stderr b/src/test/ui/mismatched_types/fn-variance-1.stderr index 88c92661994..dbb281bbf41 100644 --- a/src/test/ui/mismatched_types/fn-variance-1.stderr +++ b/src/test/ui/mismatched_types/fn-variance-1.stderr @@ -5,7 +5,7 @@ LL | fn takes_mut(x: &mut isize) { } | --------------------------- found signature of `for<'r> fn(&'r mut isize) -> _` LL | LL | fn apply<T, F>(t: T, f: F) where F: FnOnce(T) { - | ----- --------- required by this bound in `apply` + | --------- required by this bound in `apply` ... LL | apply(&3, takes_mut); | ^^^^^^^^^ expected signature of `fn(&{integer}) -> _` @@ -17,7 +17,7 @@ LL | fn takes_imm(x: &isize) { } | ----------------------- found signature of `for<'r> fn(&'r isize) -> _` ... LL | fn apply<T, F>(t: T, f: F) where F: FnOnce(T) { - | ----- --------- required by this bound in `apply` + | --------- required by this bound in `apply` ... LL | apply(&mut 3, takes_imm); | ^^^^^^^^^ expected signature of `fn(&mut {integer}) -> _` diff --git a/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.rs b/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.rs index 2bd4d338446..ab36b8536bf 100644 --- a/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.rs +++ b/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.rs @@ -6,7 +6,6 @@ fn to_fn_mut<A,F:FnMut<A>>(f: F) -> F { f } fn call_it<F:FnMut(isize,isize)->isize>(y: isize, mut f: F) -> isize { //~^ NOTE required by this bound in `call_it` -//~| NOTE f(2, y) } diff --git a/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr b/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr index 3c999f200d9..111ff4a0c32 100644 --- a/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr +++ b/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr @@ -1,8 +1,8 @@ error[E0631]: type mismatch in closure arguments - --> $DIR/unboxed-closures-vtable-mismatch.rs:16:24 + --> $DIR/unboxed-closures-vtable-mismatch.rs:15:24 | LL | fn call_it<F:FnMut(isize,isize)->isize>(y: isize, mut f: F) -> isize { - | ------- ------------------------- required by this bound in `call_it` + | ------------------------- required by this bound in `call_it` ... LL | let f = to_fn_mut(|x: usize, y: isize| -> isize { (x as isize) + y }); | ----------------------------- found signature of `fn(usize, isize) -> _` diff --git a/src/test/ui/mut/mutable-enum-indirect.stderr b/src/test/ui/mut/mutable-enum-indirect.stderr index 0290efc3d96..9decba790d2 100644 --- a/src/test/ui/mut/mutable-enum-indirect.stderr +++ b/src/test/ui/mut/mutable-enum-indirect.stderr @@ -2,7 +2,7 @@ error[E0277]: `NoSync` cannot be shared between threads safely --> $DIR/mutable-enum-indirect.rs:17:5 | LL | fn bar<T: Sync>(_: T) {} - | --- ---- required by this bound in `bar` + | ---- required by this bound in `bar` ... LL | bar(&x); | ^^^ `NoSync` cannot be shared between threads safely diff --git a/src/test/ui/mutexguard-sync.stderr b/src/test/ui/mutexguard-sync.stderr index 71a06fce4b9..8b5362490bf 100644 --- a/src/test/ui/mutexguard-sync.stderr +++ b/src/test/ui/mutexguard-sync.stderr @@ -2,7 +2,7 @@ error[E0277]: `std::cell::Cell<i32>` cannot be shared between threads safely --> $DIR/mutexguard-sync.rs:11:15 | LL | fn test_sync<T: Sync>(_t: T) {} - | --------- ---- required by this bound in `test_sync` + | ---- required by this bound in `test_sync` ... LL | test_sync(guard); | ^^^^^ `std::cell::Cell<i32>` cannot be shared between threads safely diff --git a/src/test/ui/namespace/namespace-mix.stderr b/src/test/ui/namespace/namespace-mix.stderr index 13d727de441..f82c83fd5b0 100644 --- a/src/test/ui/namespace/namespace-mix.stderr +++ b/src/test/ui/namespace/namespace-mix.stderr @@ -90,7 +90,7 @@ error[E0277]: the trait bound `c::Item: Impossible` is not satisfied --> $DIR/namespace-mix.rs:33:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(m1::S{}); | ^^^^^^^ the trait `Impossible` is not implemented for `c::Item` @@ -99,7 +99,7 @@ error[E0277]: the trait bound `c::S: Impossible` is not satisfied --> $DIR/namespace-mix.rs:35:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(m2::S{}); | ^^^^^^^ the trait `Impossible` is not implemented for `c::S` @@ -108,7 +108,7 @@ error[E0277]: the trait bound `c::Item: Impossible` is not satisfied --> $DIR/namespace-mix.rs:36:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(m2::S); | ^^^^^ the trait `Impossible` is not implemented for `c::Item` @@ -117,7 +117,7 @@ error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisf --> $DIR/namespace-mix.rs:39:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(xm1::S{}); | ^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` @@ -126,7 +126,7 @@ error[E0277]: the trait bound `namespace_mix::c::S: Impossible` is not satisfied --> $DIR/namespace-mix.rs:41:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(xm2::S{}); | ^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::S` @@ -135,7 +135,7 @@ error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisf --> $DIR/namespace-mix.rs:42:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(xm2::S); | ^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` @@ -144,7 +144,7 @@ error[E0277]: the trait bound `c::Item: Impossible` is not satisfied --> $DIR/namespace-mix.rs:55:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(m3::TS{}); | ^^^^^^^^ the trait `Impossible` is not implemented for `c::Item` @@ -153,7 +153,7 @@ error[E0277]: the trait bound `fn() -> c::TS {c::TS}: Impossible` is not satisfi --> $DIR/namespace-mix.rs:56:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(m3::TS); | ^^^^^^ the trait `Impossible` is not implemented for `fn() -> c::TS {c::TS}` @@ -162,7 +162,7 @@ error[E0277]: the trait bound `c::TS: Impossible` is not satisfied --> $DIR/namespace-mix.rs:57:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(m4::TS{}); | ^^^^^^^^ the trait `Impossible` is not implemented for `c::TS` @@ -171,7 +171,7 @@ error[E0277]: the trait bound `c::Item: Impossible` is not satisfied --> $DIR/namespace-mix.rs:58:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(m4::TS); | ^^^^^^ the trait `Impossible` is not implemented for `c::Item` @@ -180,7 +180,7 @@ error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisf --> $DIR/namespace-mix.rs:61:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(xm3::TS{}); | ^^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` @@ -189,7 +189,7 @@ error[E0277]: the trait bound `fn() -> namespace_mix::c::TS {namespace_mix::c::T --> $DIR/namespace-mix.rs:62:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(xm3::TS); | ^^^^^^^ the trait `Impossible` is not implemented for `fn() -> namespace_mix::c::TS {namespace_mix::c::TS}` @@ -198,7 +198,7 @@ error[E0277]: the trait bound `namespace_mix::c::TS: Impossible` is not satisfie --> $DIR/namespace-mix.rs:63:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(xm4::TS{}); | ^^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::TS` @@ -207,7 +207,7 @@ error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisf --> $DIR/namespace-mix.rs:64:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(xm4::TS); | ^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` @@ -216,7 +216,7 @@ error[E0277]: the trait bound `c::Item: Impossible` is not satisfied --> $DIR/namespace-mix.rs:77:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(m5::US{}); | ^^^^^^^^ the trait `Impossible` is not implemented for `c::Item` @@ -225,7 +225,7 @@ error[E0277]: the trait bound `c::US: Impossible` is not satisfied --> $DIR/namespace-mix.rs:78:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(m5::US); | ^^^^^^ the trait `Impossible` is not implemented for `c::US` @@ -234,7 +234,7 @@ error[E0277]: the trait bound `c::US: Impossible` is not satisfied --> $DIR/namespace-mix.rs:79:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(m6::US{}); | ^^^^^^^^ the trait `Impossible` is not implemented for `c::US` @@ -243,7 +243,7 @@ error[E0277]: the trait bound `c::Item: Impossible` is not satisfied --> $DIR/namespace-mix.rs:80:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(m6::US); | ^^^^^^ the trait `Impossible` is not implemented for `c::Item` @@ -252,7 +252,7 @@ error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisf --> $DIR/namespace-mix.rs:83:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(xm5::US{}); | ^^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` @@ -261,7 +261,7 @@ error[E0277]: the trait bound `namespace_mix::c::US: Impossible` is not satisfie --> $DIR/namespace-mix.rs:84:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(xm5::US); | ^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::US` @@ -270,7 +270,7 @@ error[E0277]: the trait bound `namespace_mix::c::US: Impossible` is not satisfie --> $DIR/namespace-mix.rs:85:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(xm6::US{}); | ^^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::US` @@ -279,7 +279,7 @@ error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisf --> $DIR/namespace-mix.rs:86:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(xm6::US); | ^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` @@ -288,7 +288,7 @@ error[E0277]: the trait bound `c::Item: Impossible` is not satisfied --> $DIR/namespace-mix.rs:99:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(m7::V{}); | ^^^^^^^ the trait `Impossible` is not implemented for `c::Item` @@ -297,7 +297,7 @@ error[E0277]: the trait bound `c::E: Impossible` is not satisfied --> $DIR/namespace-mix.rs:101:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(m8::V{}); | ^^^^^^^ the trait `Impossible` is not implemented for `c::E` @@ -306,7 +306,7 @@ error[E0277]: the trait bound `c::Item: Impossible` is not satisfied --> $DIR/namespace-mix.rs:102:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(m8::V); | ^^^^^ the trait `Impossible` is not implemented for `c::Item` @@ -315,7 +315,7 @@ error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisf --> $DIR/namespace-mix.rs:105:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(xm7::V{}); | ^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` @@ -324,7 +324,7 @@ error[E0277]: the trait bound `namespace_mix::c::E: Impossible` is not satisfied --> $DIR/namespace-mix.rs:107:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(xm8::V{}); | ^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::E` @@ -333,7 +333,7 @@ error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisf --> $DIR/namespace-mix.rs:108:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(xm8::V); | ^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` @@ -342,7 +342,7 @@ error[E0277]: the trait bound `c::Item: Impossible` is not satisfied --> $DIR/namespace-mix.rs:121:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(m9::TV{}); | ^^^^^^^^ the trait `Impossible` is not implemented for `c::Item` @@ -351,7 +351,7 @@ error[E0277]: the trait bound `fn() -> c::E {c::E::TV}: Impossible` is not satis --> $DIR/namespace-mix.rs:122:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(m9::TV); | ^^^^^^ the trait `Impossible` is not implemented for `fn() -> c::E {c::E::TV}` @@ -360,7 +360,7 @@ error[E0277]: the trait bound `c::E: Impossible` is not satisfied --> $DIR/namespace-mix.rs:123:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(mA::TV{}); | ^^^^^^^^ the trait `Impossible` is not implemented for `c::E` @@ -369,7 +369,7 @@ error[E0277]: the trait bound `c::Item: Impossible` is not satisfied --> $DIR/namespace-mix.rs:124:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(mA::TV); | ^^^^^^ the trait `Impossible` is not implemented for `c::Item` @@ -378,7 +378,7 @@ error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisf --> $DIR/namespace-mix.rs:127:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(xm9::TV{}); | ^^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` @@ -387,7 +387,7 @@ error[E0277]: the trait bound `fn() -> namespace_mix::c::E {namespace_mix::xm7:: --> $DIR/namespace-mix.rs:128:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(xm9::TV); | ^^^^^^^ the trait `Impossible` is not implemented for `fn() -> namespace_mix::c::E {namespace_mix::xm7::TV}` @@ -396,7 +396,7 @@ error[E0277]: the trait bound `namespace_mix::c::E: Impossible` is not satisfied --> $DIR/namespace-mix.rs:129:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(xmA::TV{}); | ^^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::E` @@ -405,7 +405,7 @@ error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisf --> $DIR/namespace-mix.rs:130:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(xmA::TV); | ^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` @@ -414,7 +414,7 @@ error[E0277]: the trait bound `c::Item: Impossible` is not satisfied --> $DIR/namespace-mix.rs:143:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(mB::UV{}); | ^^^^^^^^ the trait `Impossible` is not implemented for `c::Item` @@ -423,7 +423,7 @@ error[E0277]: the trait bound `c::E: Impossible` is not satisfied --> $DIR/namespace-mix.rs:144:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(mB::UV); | ^^^^^^ the trait `Impossible` is not implemented for `c::E` @@ -432,7 +432,7 @@ error[E0277]: the trait bound `c::E: Impossible` is not satisfied --> $DIR/namespace-mix.rs:145:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(mC::UV{}); | ^^^^^^^^ the trait `Impossible` is not implemented for `c::E` @@ -441,7 +441,7 @@ error[E0277]: the trait bound `c::Item: Impossible` is not satisfied --> $DIR/namespace-mix.rs:146:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(mC::UV); | ^^^^^^ the trait `Impossible` is not implemented for `c::Item` @@ -450,7 +450,7 @@ error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisf --> $DIR/namespace-mix.rs:149:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(xmB::UV{}); | ^^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` @@ -459,7 +459,7 @@ error[E0277]: the trait bound `namespace_mix::c::E: Impossible` is not satisfied --> $DIR/namespace-mix.rs:150:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(xmB::UV); | ^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::E` @@ -468,7 +468,7 @@ error[E0277]: the trait bound `namespace_mix::c::E: Impossible` is not satisfied --> $DIR/namespace-mix.rs:151:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(xmC::UV{}); | ^^^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::E` @@ -477,7 +477,7 @@ error[E0277]: the trait bound `namespace_mix::c::Item: Impossible` is not satisf --> $DIR/namespace-mix.rs:152:11 | LL | fn check<T: Impossible>(_: T) {} - | ----- ---------- required by this bound in `check` + | ---------- required by this bound in `check` ... LL | check(xmC::UV); | ^^^^^^^ the trait `Impossible` is not implemented for `namespace_mix::c::Item` diff --git a/src/test/ui/never_type/defaulted-never-note.rs b/src/test/ui/never_type/defaulted-never-note.rs index 1780cb6535d..c96c4784dcf 100644 --- a/src/test/ui/never_type/defaulted-never-note.rs +++ b/src/test/ui/never_type/defaulted-never-note.rs @@ -20,7 +20,6 @@ impl ImplementedForUnitButNotNever for () {} fn foo<T: ImplementedForUnitButNotNever>(_t: T) {} //~^ NOTE required by this bound in `foo` -//~| NOTE fn smeg() { let _x = return; diff --git a/src/test/ui/never_type/defaulted-never-note.stderr b/src/test/ui/never_type/defaulted-never-note.stderr index 046d0c5fa19..69691883de1 100644 --- a/src/test/ui/never_type/defaulted-never-note.stderr +++ b/src/test/ui/never_type/defaulted-never-note.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `!: ImplementedForUnitButNotNever` is not satisfied - --> $DIR/defaulted-never-note.rs:27:5 + --> $DIR/defaulted-never-note.rs:26:5 | LL | fn foo<T: ImplementedForUnitButNotNever>(_t: T) {} - | --- ----------------------------- required by this bound in `foo` + | ----------------------------- required by this bound in `foo` ... LL | foo(_x); | ^^^ the trait `ImplementedForUnitButNotNever` is not implemented for `!` diff --git a/src/test/ui/no_send-enum.stderr b/src/test/ui/no_send-enum.stderr index 8a4b2e9c7a7..95a0d77676d 100644 --- a/src/test/ui/no_send-enum.stderr +++ b/src/test/ui/no_send-enum.stderr @@ -2,7 +2,7 @@ error[E0277]: `NoSend` cannot be sent between threads safely --> $DIR/no_send-enum.rs:16:5 | LL | fn bar<T: Send>(_: T) {} - | --- ---- required by this bound in `bar` + | ---- required by this bound in `bar` ... LL | bar(x); | ^^^ `NoSend` cannot be sent between threads safely diff --git a/src/test/ui/no_send-rc.stderr b/src/test/ui/no_send-rc.stderr index bd646d0509d..1eb2edb14b8 100644 --- a/src/test/ui/no_send-rc.stderr +++ b/src/test/ui/no_send-rc.stderr @@ -2,7 +2,7 @@ error[E0277]: `std::rc::Rc<{integer}>` cannot be sent between threads safely --> $DIR/no_send-rc.rs:7:9 | LL | fn bar<T: Send>(_: T) {} - | --- ---- required by this bound in `bar` + | ---- required by this bound in `bar` ... LL | bar(x); | ^ `std::rc::Rc<{integer}>` cannot be sent between threads safely diff --git a/src/test/ui/no_send-struct.stderr b/src/test/ui/no_send-struct.stderr index 4823852c2ff..4e8801a58bf 100644 --- a/src/test/ui/no_send-struct.stderr +++ b/src/test/ui/no_send-struct.stderr @@ -2,7 +2,7 @@ error[E0277]: `Foo` cannot be sent between threads safely --> $DIR/no_send-struct.rs:15:9 | LL | fn bar<T: Send>(_: T) {} - | --- ---- required by this bound in `bar` + | ---- required by this bound in `bar` ... LL | bar(x); | ^ `Foo` cannot be sent between threads safely diff --git a/src/test/ui/no_share-enum.stderr b/src/test/ui/no_share-enum.stderr index f42228ef6ab..40996aef702 100644 --- a/src/test/ui/no_share-enum.stderr +++ b/src/test/ui/no_share-enum.stderr @@ -2,7 +2,7 @@ error[E0277]: `NoSync` cannot be shared between threads safely --> $DIR/no_share-enum.rs:14:5 | LL | fn bar<T: Sync>(_: T) {} - | --- ---- required by this bound in `bar` + | ---- required by this bound in `bar` ... LL | bar(x); | ^^^ `NoSync` cannot be shared between threads safely diff --git a/src/test/ui/no_share-struct.stderr b/src/test/ui/no_share-struct.stderr index 620b5427b9a..f14b06835f9 100644 --- a/src/test/ui/no_share-struct.stderr +++ b/src/test/ui/no_share-struct.stderr @@ -2,7 +2,7 @@ error[E0277]: `Foo` cannot be shared between threads safely --> $DIR/no_share-struct.rs:12:9 | LL | fn bar<T: Sync>(_: T) {} - | --- ---- required by this bound in `bar` + | ---- required by this bound in `bar` ... LL | bar(x); | ^ `Foo` cannot be shared between threads safely diff --git a/src/test/ui/not-panic/not-panic-safe-2.stderr b/src/test/ui/not-panic/not-panic-safe-2.stderr index 6668d2d0db1..c52d5b9adee 100644 --- a/src/test/ui/not-panic/not-panic-safe-2.stderr +++ b/src/test/ui/not-panic/not-panic-safe-2.stderr @@ -2,7 +2,7 @@ error[E0277]: the type `std::cell::UnsafeCell<i32>` may contain interior mutabil --> $DIR/not-panic-safe-2.rs:10:5 | LL | fn assert<T: UnwindSafe + ?Sized>() {} - | ------ ---------- required by this bound in `assert` + | ---------- required by this bound in `assert` ... LL | assert::<Rc<RefCell<i32>>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell<i32>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary @@ -15,7 +15,7 @@ error[E0277]: the type `std::cell::UnsafeCell<isize>` may contain interior mutab --> $DIR/not-panic-safe-2.rs:10:5 | LL | fn assert<T: UnwindSafe + ?Sized>() {} - | ------ ---------- required by this bound in `assert` + | ---------- required by this bound in `assert` ... LL | assert::<Rc<RefCell<i32>>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell<isize>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary diff --git a/src/test/ui/not-panic/not-panic-safe-3.stderr b/src/test/ui/not-panic/not-panic-safe-3.stderr index c23b08fc9ed..711346b7b1c 100644 --- a/src/test/ui/not-panic/not-panic-safe-3.stderr +++ b/src/test/ui/not-panic/not-panic-safe-3.stderr @@ -2,7 +2,7 @@ error[E0277]: the type `std::cell::UnsafeCell<i32>` may contain interior mutabil --> $DIR/not-panic-safe-3.rs:10:5 | LL | fn assert<T: UnwindSafe + ?Sized>() {} - | ------ ---------- required by this bound in `assert` + | ---------- required by this bound in `assert` ... LL | assert::<Arc<RefCell<i32>>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell<i32>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary @@ -15,7 +15,7 @@ error[E0277]: the type `std::cell::UnsafeCell<isize>` may contain interior mutab --> $DIR/not-panic-safe-3.rs:10:5 | LL | fn assert<T: UnwindSafe + ?Sized>() {} - | ------ ---------- required by this bound in `assert` + | ---------- required by this bound in `assert` ... LL | assert::<Arc<RefCell<i32>>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell<isize>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary diff --git a/src/test/ui/not-panic/not-panic-safe-4.stderr b/src/test/ui/not-panic/not-panic-safe-4.stderr index 916804a834f..ada22fe9a77 100644 --- a/src/test/ui/not-panic/not-panic-safe-4.stderr +++ b/src/test/ui/not-panic/not-panic-safe-4.stderr @@ -2,7 +2,7 @@ error[E0277]: the type `std::cell::UnsafeCell<i32>` may contain interior mutabil --> $DIR/not-panic-safe-4.rs:9:5 | LL | fn assert<T: UnwindSafe + ?Sized>() {} - | ------ ---------- required by this bound in `assert` + | ---------- required by this bound in `assert` ... LL | assert::<&RefCell<i32>>(); | ^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell<i32>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary @@ -15,7 +15,7 @@ error[E0277]: the type `std::cell::UnsafeCell<isize>` may contain interior mutab --> $DIR/not-panic-safe-4.rs:9:5 | LL | fn assert<T: UnwindSafe + ?Sized>() {} - | ------ ---------- required by this bound in `assert` + | ---------- required by this bound in `assert` ... LL | assert::<&RefCell<i32>>(); | ^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell<isize>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary diff --git a/src/test/ui/not-panic/not-panic-safe-5.stderr b/src/test/ui/not-panic/not-panic-safe-5.stderr index d5c189723f4..c987ca7c088 100644 --- a/src/test/ui/not-panic/not-panic-safe-5.stderr +++ b/src/test/ui/not-panic/not-panic-safe-5.stderr @@ -2,7 +2,7 @@ error[E0277]: the type `std::cell::UnsafeCell<i32>` may contain interior mutabil --> $DIR/not-panic-safe-5.rs:9:5 | LL | fn assert<T: UnwindSafe + ?Sized>() {} - | ------ ---------- required by this bound in `assert` + | ---------- required by this bound in `assert` ... LL | assert::<*const UnsafeCell<i32>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell<i32>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary diff --git a/src/test/ui/not-panic/not-panic-safe-6.stderr b/src/test/ui/not-panic/not-panic-safe-6.stderr index c8013a836a1..f184a459b82 100644 --- a/src/test/ui/not-panic/not-panic-safe-6.stderr +++ b/src/test/ui/not-panic/not-panic-safe-6.stderr @@ -2,7 +2,7 @@ error[E0277]: the type `std::cell::UnsafeCell<i32>` may contain interior mutabil --> $DIR/not-panic-safe-6.rs:9:5 | LL | fn assert<T: UnwindSafe + ?Sized>() {} - | ------ ---------- required by this bound in `assert` + | ---------- required by this bound in `assert` ... LL | assert::<*mut RefCell<i32>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell<i32>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary @@ -15,7 +15,7 @@ error[E0277]: the type `std::cell::UnsafeCell<isize>` may contain interior mutab --> $DIR/not-panic-safe-6.rs:9:5 | LL | fn assert<T: UnwindSafe + ?Sized>() {} - | ------ ---------- required by this bound in `assert` + | ---------- required by this bound in `assert` ... LL | assert::<*mut RefCell<i32>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell<isize>` may contain interior mutability and a reference may not be safely transferrable across a catch_unwind boundary diff --git a/src/test/ui/not-panic/not-panic-safe.stderr b/src/test/ui/not-panic/not-panic-safe.stderr index 2362ccd32de..b254a041666 100644 --- a/src/test/ui/not-panic/not-panic-safe.stderr +++ b/src/test/ui/not-panic/not-panic-safe.stderr @@ -2,7 +2,7 @@ error[E0277]: the type `&mut i32` may not be safely transferred across an unwind --> $DIR/not-panic-safe.rs:9:5 | LL | fn assert<T: UnwindSafe + ?Sized>() {} - | ------ ---------- required by this bound in `assert` + | ---------- required by this bound in `assert` ... LL | assert::<&mut i32>(); | ^^^^^^^^^^^^^^^^^^ `&mut i32` may not be safely transferred across an unwind boundary diff --git a/src/test/ui/not-sync.stderr b/src/test/ui/not-sync.stderr index 8bb4ce2e2c7..25f1a66062b 100644 --- a/src/test/ui/not-sync.stderr +++ b/src/test/ui/not-sync.stderr @@ -2,7 +2,7 @@ error[E0277]: `std::cell::Cell<i32>` cannot be shared between threads safely --> $DIR/not-sync.rs:8:12 | LL | fn test<T: Sync>() {} - | ---- ---- required by this bound in `test` + | ---- required by this bound in `test` ... LL | test::<Cell<i32>>(); | ^^^^^^^^^ `std::cell::Cell<i32>` cannot be shared between threads safely @@ -13,7 +13,7 @@ error[E0277]: `std::cell::RefCell<i32>` cannot be shared between threads safely --> $DIR/not-sync.rs:10:12 | LL | fn test<T: Sync>() {} - | ---- ---- required by this bound in `test` + | ---- required by this bound in `test` ... LL | test::<RefCell<i32>>(); | ^^^^^^^^^^^^ `std::cell::RefCell<i32>` cannot be shared between threads safely @@ -24,7 +24,7 @@ error[E0277]: `std::rc::Rc<i32>` cannot be shared between threads safely --> $DIR/not-sync.rs:13:12 | LL | fn test<T: Sync>() {} - | ---- ---- required by this bound in `test` + | ---- required by this bound in `test` ... LL | test::<Rc<i32>>(); | ^^^^^^^ `std::rc::Rc<i32>` cannot be shared between threads safely @@ -35,7 +35,7 @@ error[E0277]: `std::rc::Weak<i32>` cannot be shared between threads safely --> $DIR/not-sync.rs:15:12 | LL | fn test<T: Sync>() {} - | ---- ---- required by this bound in `test` + | ---- required by this bound in `test` ... LL | test::<Weak<i32>>(); | ^^^^^^^^^ `std::rc::Weak<i32>` cannot be shared between threads safely @@ -46,7 +46,7 @@ error[E0277]: `std::sync::mpsc::Receiver<i32>` cannot be shared between threads --> $DIR/not-sync.rs:18:12 | LL | fn test<T: Sync>() {} - | ---- ---- required by this bound in `test` + | ---- required by this bound in `test` ... LL | test::<Receiver<i32>>(); | ^^^^^^^^^^^^^ `std::sync::mpsc::Receiver<i32>` cannot be shared between threads safely @@ -57,7 +57,7 @@ error[E0277]: `std::sync::mpsc::Sender<i32>` cannot be shared between threads sa --> $DIR/not-sync.rs:20:12 | LL | fn test<T: Sync>() {} - | ---- ---- required by this bound in `test` + | ---- required by this bound in `test` ... LL | test::<Sender<i32>>(); | ^^^^^^^^^^^ `std::sync::mpsc::Sender<i32>` cannot be shared between threads safely diff --git a/src/test/ui/object-does-not-impl-trait.stderr b/src/test/ui/object-does-not-impl-trait.stderr index 7ac199d0943..1d3675bf1c1 100644 --- a/src/test/ui/object-does-not-impl-trait.stderr +++ b/src/test/ui/object-does-not-impl-trait.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `std::boxed::Box<dyn Foo>: Foo` is not satisfied --> $DIR/object-does-not-impl-trait.rs:6:44 | LL | fn take_foo<F:Foo>(f: F) {} - | -------- --- required by this bound in `take_foo` + | --- required by this bound in `take_foo` LL | fn take_object(f: Box<dyn Foo>) { take_foo(f); } | ^ the trait `Foo` is not implemented for `std::boxed::Box<dyn Foo>` diff --git a/src/test/ui/on-unimplemented/enclosing-scope.stderr b/src/test/ui/on-unimplemented/enclosing-scope.stderr index 092e560330b..4c1aaf39c7b 100644 --- a/src/test/ui/on-unimplemented/enclosing-scope.stderr +++ b/src/test/ui/on-unimplemented/enclosing-scope.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `Foo: Trait` is not satisfied --> $DIR/enclosing-scope.rs:14:11 | LL | fn f<T: Trait>(x: T) {} - | - ----- required by this bound in `f` + | ----- required by this bound in `f` ... LL | let x = || { | _____________- @@ -18,7 +18,7 @@ error[E0277]: the trait bound `Foo: Trait` is not satisfied --> $DIR/enclosing-scope.rs:16:15 | LL | fn f<T: Trait>(x: T) {} - | - ----- required by this bound in `f` + | ----- required by this bound in `f` ... LL | let y = || { | _________________- @@ -31,7 +31,7 @@ error[E0277]: the trait bound `Foo: Trait` is not satisfied --> $DIR/enclosing-scope.rs:22:15 | LL | fn f<T: Trait>(x: T) {} - | - ----- required by this bound in `f` + | ----- required by this bound in `f` LL | LL | / fn main() { LL | | let x = || { @@ -49,7 +49,7 @@ error[E0277]: the trait bound `Foo: Trait` is not satisfied --> $DIR/enclosing-scope.rs:26:7 | LL | fn f<T: Trait>(x: T) {} - | - ----- required by this bound in `f` + | ----- required by this bound in `f` LL | LL | / fn main() { LL | | let x = || { diff --git a/src/test/ui/on-unimplemented/on-trait.stderr b/src/test/ui/on-unimplemented/on-trait.stderr index 8fe7ed4a204..be8efbf2ce4 100644 --- a/src/test/ui/on-unimplemented/on-trait.stderr +++ b/src/test/ui/on-unimplemented/on-trait.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `std::option::Option<std::vec::Vec<u8>>: MyFromIte --> $DIR/on-trait.rs:28:30 | LL | fn collect<A, I: Iterator<Item=A>, B: MyFromIterator<A>>(it: I) -> B { - | ------- ----------------- required by this bound in `collect` + | ----------------- required by this bound in `collect` ... LL | let y: Option<Vec<u8>> = collect(x.iter()); // this should give approximately the same error for x.iter().collect() | ^^^^^^^ a collection of type `std::option::Option<std::vec::Vec<u8>>` cannot be built from an iterator over elements of type `&u8` @@ -13,7 +13,7 @@ error[E0277]: the trait bound `std::string::String: Bar::Foo<u8, _, u32>` is not --> $DIR/on-trait.rs:31:21 | LL | fn foobar<U: Clone, T: Foo<u8, U, u32>>() -> T { - | ------ --------------- required by this bound in `foobar` + | --------------- required by this bound in `foobar` ... LL | let x: String = foobar(); | ^^^^^^ test error `std::string::String` with `u8` `_` `u32` in `Bar::Foo` diff --git a/src/test/ui/parser/issue-32214.stderr b/src/test/ui/parser/issue-32214.stderr index 742f4fdc38b..bc61b3b74e2 100644 --- a/src/test/ui/parser/issue-32214.stderr +++ b/src/test/ui/parser/issue-32214.stderr @@ -4,7 +4,12 @@ error: generic arguments must come before the first constraint LL | pub fn test<W, I: Trait<Item=(), W> >() {} | ------- ^ generic argument | | - | the first constraint is provided here + | constraint + | +help: move the constraint after the generic argument + | +LL | pub fn test<W, I: Trait<W, Item = ()> >() {} + | ^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/phantom-oibit.stderr b/src/test/ui/phantom-oibit.stderr index f8fe6947852..fd0307f15c7 100644 --- a/src/test/ui/phantom-oibit.stderr +++ b/src/test/ui/phantom-oibit.stderr @@ -2,7 +2,7 @@ error[E0277]: `T` cannot be shared between threads safely --> $DIR/phantom-oibit.rs:21:12 | LL | fn is_zen<T: Zen>(_: T) {} - | ------ --- required by this bound in `is_zen` + | --- required by this bound in `is_zen` ... LL | is_zen(x) | ^ `T` cannot be shared between threads safely @@ -20,7 +20,7 @@ error[E0277]: `T` cannot be shared between threads safely --> $DIR/phantom-oibit.rs:26:12 | LL | fn is_zen<T: Zen>(_: T) {} - | ------ --- required by this bound in `is_zen` + | --- required by this bound in `is_zen` ... LL | is_zen(x) | ^ `T` cannot be shared between threads safely diff --git a/src/test/ui/privacy/privacy-ns1.stderr b/src/test/ui/privacy/privacy-ns1.stderr index 66e9b78f676..45ca00f55ab 100644 --- a/src/test/ui/privacy/privacy-ns1.stderr +++ b/src/test/ui/privacy/privacy-ns1.stderr @@ -63,10 +63,6 @@ LL | use foo2::Bar; | LL | use foo3::Bar; | -help: you might be missing a type parameter - | -LL | fn test_glob3<Bar>() { - | ^^^^^ error[E0107]: wrong number of const arguments: expected 0, found 1 --> $DIR/privacy-ns1.rs:35:17 diff --git a/src/test/ui/question-mark-type-infer.stderr b/src/test/ui/question-mark-type-infer.stderr index 262344fba59..64d8f685637 100644 --- a/src/test/ui/question-mark-type-infer.stderr +++ b/src/test/ui/question-mark-type-infer.stderr @@ -4,7 +4,7 @@ error[E0284]: type annotations needed LL | l.iter().map(f).collect()? | ^^^^^^^ cannot infer type | - = note: cannot resolve `<_ as std::ops::Try>::Ok == _` + = note: cannot satisfy `<_ as std::ops::Try>::Ok == _` help: consider specifying the type argument in the method call | LL | l.iter().map(f).collect::<B>()? diff --git a/src/test/ui/recursion/recursive-requirements.stderr b/src/test/ui/recursion/recursive-requirements.stderr index 9846c938ba9..0237675aee4 100644 --- a/src/test/ui/recursion/recursive-requirements.stderr +++ b/src/test/ui/recursion/recursive-requirements.stderr @@ -2,7 +2,7 @@ error[E0277]: `*const Bar` cannot be shared between threads safely --> $DIR/recursive-requirements.rs:16:12 | LL | struct AssertSync<T: Sync>(PhantomData<T>); - | ------------------------------------------- required by `AssertSync` + | ---- required by this bound in `AssertSync` ... LL | let _: AssertSync<Foo> = unimplemented!(); | ^^^^^^^^^^^^^^^ `*const Bar` cannot be shared between threads safely @@ -14,7 +14,7 @@ error[E0277]: `*const Foo` cannot be shared between threads safely --> $DIR/recursive-requirements.rs:16:12 | LL | struct AssertSync<T: Sync>(PhantomData<T>); - | ------------------------------------------- required by `AssertSync` + | ---- required by this bound in `AssertSync` ... LL | let _: AssertSync<Foo> = unimplemented!(); | ^^^^^^^^^^^^^^^ `*const Foo` cannot be shared between threads safely diff --git a/src/test/ui/repeat_count_const_in_async_fn.rs b/src/test/ui/repeat_count_const_in_async_fn.rs new file mode 100644 index 00000000000..ebabc3fbf10 --- /dev/null +++ b/src/test/ui/repeat_count_const_in_async_fn.rs @@ -0,0 +1,10 @@ +// check-pass +// edition:2018 +// compile-flags: --crate-type=lib + +pub async fn test() { + const C: usize = 4; + foo(&mut [0u8; C]).await; +} + +async fn foo(_: &mut [u8]) {} diff --git a/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.rs b/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.rs new file mode 100644 index 00000000000..cc36f054bc3 --- /dev/null +++ b/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.rs @@ -0,0 +1,20 @@ +// edition:2018 + +async fn free(); //~ ERROR without a body + +struct A; +impl A { + async fn inherent(); //~ ERROR without body +} + +trait B { + async fn associated(); + //~^ ERROR cannot be declared `async` +} +impl B for A { + async fn associated(); //~ ERROR without body + //~^ ERROR cannot be declared `async` + //~| ERROR incompatible type for trait +} + +fn main() {} diff --git a/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr b/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr new file mode 100644 index 00000000000..a324d04d394 --- /dev/null +++ b/src/test/ui/resolve/issue-70736-async-fn-no-body-def-collector.stderr @@ -0,0 +1,65 @@ +error: free function without a body + --> $DIR/issue-70736-async-fn-no-body-def-collector.rs:3:1 + | +LL | async fn free(); + | ^^^^^^^^^^^^^^^- + | | + | help: provide a definition for the function: `{ <body> }` + +error: associated function in `impl` without body + --> $DIR/issue-70736-async-fn-no-body-def-collector.rs:7:5 + | +LL | async fn inherent(); + | ^^^^^^^^^^^^^^^^^^^- + | | + | help: provide a definition for the function: `{ <body> }` + +error[E0706]: functions in traits cannot be declared `async` + --> $DIR/issue-70736-async-fn-no-body-def-collector.rs:11:5 + | +LL | async fn associated(); + | -----^^^^^^^^^^^^^^^^^ + | | + | `async` because of this + | + = note: `async` trait functions are not currently supported + = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait + +error: associated function in `impl` without body + --> $DIR/issue-70736-async-fn-no-body-def-collector.rs:15:5 + | +LL | async fn associated(); + | ^^^^^^^^^^^^^^^^^^^^^- + | | + | help: provide a definition for the function: `{ <body> }` + +error[E0706]: functions in traits cannot be declared `async` + --> $DIR/issue-70736-async-fn-no-body-def-collector.rs:15:5 + | +LL | async fn associated(); + | -----^^^^^^^^^^^^^^^^^ + | | + | `async` because of this + | + = note: `async` trait functions are not currently supported + = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait + +error[E0053]: method `associated` has an incompatible type for trait + --> $DIR/issue-70736-async-fn-no-body-def-collector.rs:15:26 + | +LL | async fn associated(); + | - type in trait +... +LL | async fn associated(); + | ^ + | | + | the `Output` of this `async fn`'s found opaque type + | expected `()`, found opaque type + | + = note: expected fn pointer `fn()` + found fn pointer `fn() -> impl std::future::Future` + +error: aborting due to 6 previous errors + +Some errors have detailed explanations: E0053, E0706. +For more information about an error, try `rustc --explain E0053`. diff --git a/src/test/ui/rfc-2091-track-caller/error-extern-fn.rs b/src/test/ui/rfc-2091-track-caller/error-extern-fn.rs deleted file mode 100644 index 9f6a69a51c0..00000000000 --- a/src/test/ui/rfc-2091-track-caller/error-extern-fn.rs +++ /dev/null @@ -1,9 +0,0 @@ -#![feature(track_caller)] -#![allow(dead_code)] - -extern "Rust" { - #[track_caller] //~ ERROR: `#[track_caller]` is not supported on foreign functions - fn bar(); -} - -fn main() {} diff --git a/src/test/ui/rfc-2091-track-caller/error-extern-fn.stderr b/src/test/ui/rfc-2091-track-caller/error-extern-fn.stderr deleted file mode 100644 index b03f5fbbdb2..00000000000 --- a/src/test/ui/rfc-2091-track-caller/error-extern-fn.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0738]: `#[track_caller]` is not supported on foreign functions - --> $DIR/error-extern-fn.rs:5:5 - | -LL | #[track_caller] - | ^^^^^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0738`. diff --git a/src/test/ui/rfc-2091-track-caller/error-with-naked.rs b/src/test/ui/rfc-2091-track-caller/error-with-naked.rs index dd9e5d04135..f4573848333 100644 --- a/src/test/ui/rfc-2091-track-caller/error-with-naked.rs +++ b/src/test/ui/rfc-2091-track-caller/error-with-naked.rs @@ -1,8 +1,21 @@ #![feature(naked_functions, track_caller)] -#[track_caller] +#[track_caller] //~ ERROR cannot use `#[track_caller]` with `#[naked]` #[naked] fn f() {} -//~^^^ ERROR cannot use `#[track_caller]` with `#[naked]` + +struct S; + +impl S { + #[track_caller] //~ ERROR cannot use `#[track_caller]` with `#[naked]` + #[naked] + fn g() {} +} + +extern "Rust" { + #[track_caller] //~ ERROR cannot use `#[track_caller]` with `#[naked]` + #[naked] + fn h(); +} fn main() {} diff --git a/src/test/ui/rfc-2091-track-caller/error-with-naked.stderr b/src/test/ui/rfc-2091-track-caller/error-with-naked.stderr index 2f5003cfdb7..1249d1df071 100644 --- a/src/test/ui/rfc-2091-track-caller/error-with-naked.stderr +++ b/src/test/ui/rfc-2091-track-caller/error-with-naked.stderr @@ -4,6 +4,18 @@ error[E0736]: cannot use `#[track_caller]` with `#[naked]` LL | #[track_caller] | ^^^^^^^^^^^^^^^ -error: aborting due to previous error +error[E0736]: cannot use `#[track_caller]` with `#[naked]` + --> $DIR/error-with-naked.rs:16:5 + | +LL | #[track_caller] + | ^^^^^^^^^^^^^^^ + +error[E0736]: cannot use `#[track_caller]` with `#[naked]` + --> $DIR/error-with-naked.rs:10:5 + | +LL | #[track_caller] + | ^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0736`. diff --git a/src/test/ui/rfc-2091-track-caller/track-caller-ffi.rs b/src/test/ui/rfc-2091-track-caller/track-caller-ffi.rs new file mode 100644 index 00000000000..23c17d743c4 --- /dev/null +++ b/src/test/ui/rfc-2091-track-caller/track-caller-ffi.rs @@ -0,0 +1,50 @@ +// run-pass + +#![feature(track_caller)] + +use std::panic::Location; + +extern "Rust" { + #[track_caller] + fn rust_track_caller_ffi_test_tracked() -> &'static Location<'static>; + fn rust_track_caller_ffi_test_untracked() -> &'static Location<'static>; +} + +fn rust_track_caller_ffi_test_nested_tracked() -> &'static Location<'static> { + unsafe { rust_track_caller_ffi_test_tracked() } +} + +mod provides { + use std::panic::Location; + #[track_caller] // UB if we did not have this! + #[no_mangle] + fn rust_track_caller_ffi_test_tracked() -> &'static Location<'static> { + Location::caller() + } + #[no_mangle] + fn rust_track_caller_ffi_test_untracked() -> &'static Location<'static> { + Location::caller() + } +} + +fn main() { + let location = Location::caller(); + assert_eq!(location.file(), file!()); + assert_eq!(location.line(), 31); + assert_eq!(location.column(), 20); + + let tracked = unsafe { rust_track_caller_ffi_test_tracked() }; + assert_eq!(tracked.file(), file!()); + assert_eq!(tracked.line(), 36); + assert_eq!(tracked.column(), 28); + + let untracked = unsafe { rust_track_caller_ffi_test_untracked() }; + assert_eq!(untracked.file(), file!()); + assert_eq!(untracked.line(), 26); + assert_eq!(untracked.column(), 9); + + let contained = rust_track_caller_ffi_test_nested_tracked(); + assert_eq!(contained.file(), file!()); + assert_eq!(contained.line(), 14); + assert_eq!(contained.column(), 14); +} diff --git a/src/test/ui/rfc-2627-raw-dylib/link-ordinal-too-large.stderr b/src/test/ui/rfc-2627-raw-dylib/link-ordinal-too-large.stderr index b3b22f9776d..b9b877aa056 100644 --- a/src/test/ui/rfc-2627-raw-dylib/link-ordinal-too-large.stderr +++ b/src/test/ui/rfc-2627-raw-dylib/link-ordinal-too-large.stderr @@ -12,7 +12,7 @@ error: ordinal value in `link_ordinal` is too large: `18446744073709551616` LL | #[link_ordinal(18446744073709551616)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: the value may not exceed `std::usize::MAX` + = note: the value may not exceed `usize::MAX` error: aborting due to previous error diff --git a/src/test/ui/sanitize-inline-always.rs b/src/test/ui/sanitize/inline-always.rs index 52dc5578180..52dc5578180 100644 --- a/src/test/ui/sanitize-inline-always.rs +++ b/src/test/ui/sanitize/inline-always.rs diff --git a/src/test/ui/sanitize-inline-always.stderr b/src/test/ui/sanitize/inline-always.stderr index 50b9474baa2..84c05af4cf8 100644 --- a/src/test/ui/sanitize-inline-always.stderr +++ b/src/test/ui/sanitize/inline-always.stderr @@ -1,12 +1,12 @@ warning: `no_sanitize` will have no effect after inlining - --> $DIR/sanitize-inline-always.rs:7:1 + --> $DIR/inline-always.rs:7:1 | LL | #[no_sanitize(address)] | ^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(inline_no_sanitize)]` on by default note: inlining requested here - --> $DIR/sanitize-inline-always.rs:5:1 + --> $DIR/inline-always.rs:5:1 | LL | #[inline(always)] | ^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/sanitize/thread.rs b/src/test/ui/sanitize/thread.rs new file mode 100644 index 00000000000..26590be8b18 --- /dev/null +++ b/src/test/ui/sanitize/thread.rs @@ -0,0 +1,57 @@ +// Verifies that ThreadSanitizer is able to detect a data race in heap allocated +// memory block. +// +// Test case minimizes the use of the standard library to avoid its ambiguous +// status with respect to instrumentation (it could vary depending on whatever +// a function call is inlined or not). +// +// The conflicting data access is de-facto synchronized with a special TSAN +// barrier, which does not introduce synchronization from TSAN perspective, but +// is necessary to make the test robust. Without the barrier data race detection +// would occasionally fail, making test flaky. +// +// needs-sanitizer-support +// only-x86_64 +// +// compile-flags: -Z sanitizer=thread -O +// +// run-fail +// error-pattern: WARNING: ThreadSanitizer: data race +// error-pattern: Location is heap block of size 4 +// error-pattern: allocated by main thread + +#![feature(raw_ref_op)] +#![feature(rustc_private)] +extern crate libc; + +use std::mem; +use std::ptr; + +static mut BARRIER: u64 = 0; + +extern "C" { + fn __tsan_testonly_barrier_init(barrier: *mut u64, count: u32); + fn __tsan_testonly_barrier_wait(barrier: *mut u64); +} + +extern "C" fn start(c: *mut libc::c_void) -> *mut libc::c_void { + unsafe { + let c: *mut u32 = c.cast(); + *c += 1; + __tsan_testonly_barrier_wait(&raw mut BARRIER); + ptr::null_mut() + } +} + +fn main() { + unsafe { + __tsan_testonly_barrier_init(&raw mut BARRIER, 2); + let c: *mut u32 = Box::into_raw(Box::new(1)); + let mut t: libc::pthread_t = mem::zeroed(); + libc::pthread_create(&mut t, ptr::null(), start, c.cast()); + __tsan_testonly_barrier_wait(&raw mut BARRIER); + *c += 1; + libc::pthread_join(t, ptr::null_mut()); + Box::from_raw(c); + } +} diff --git a/src/test/ui/str/str-mut-idx.stderr b/src/test/ui/str/str-mut-idx.stderr index d0afb2ae7af..2fd805e6469 100644 --- a/src/test/ui/str/str-mut-idx.stderr +++ b/src/test/ui/str/str-mut-idx.stderr @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `str` cannot be known at compilation t --> $DIR/str-mut-idx.rs:4:15 | LL | fn bot<T>() -> T { loop {} } - | --- - required by this bound in `bot` + | - required by this bound in `bot` ... LL | s[1..2] = bot(); | ^^^ doesn't have a size known at compile-time diff --git a/src/test/ui/substs-ppaux.normal.stderr b/src/test/ui/substs-ppaux.normal.stderr index 3ad2a1414f9..bcdeed262ec 100644 --- a/src/test/ui/substs-ppaux.normal.stderr +++ b/src/test/ui/substs-ppaux.normal.stderr @@ -74,7 +74,7 @@ error[E0277]: the size for values of type `str` cannot be known at compilation t --> $DIR/substs-ppaux.rs:49:5 | LL | fn bar<'a, T>() where T: 'a {} - | --- -- required by this bound in `Foo::bar` + | -- required by this bound in `Foo::bar` ... LL | <str as Foo<u8>>::bar; | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time diff --git a/src/test/ui/substs-ppaux.verbose.stderr b/src/test/ui/substs-ppaux.verbose.stderr index e23f06a3ef5..fb5e6fbcfe7 100644 --- a/src/test/ui/substs-ppaux.verbose.stderr +++ b/src/test/ui/substs-ppaux.verbose.stderr @@ -74,7 +74,7 @@ error[E0277]: the size for values of type `str` cannot be known at compilation t --> $DIR/substs-ppaux.rs:49:5 | LL | fn bar<'a, T>() where T: 'a {} - | --- -- required by this bound in `Foo::bar` + | -- required by this bound in `Foo::bar` ... LL | <str as Foo<u8>>::bar; | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time diff --git a/src/test/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr b/src/test/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr index 638d504d7fe..99ba4e2a646 100644 --- a/src/test/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr +++ b/src/test/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr @@ -5,7 +5,7 @@ LL | async fn foo() {} | --- consider calling this function LL | LL | fn bar(f: impl Future<Output=()>) {} - | --- ----------------- required by this bound in `bar` + | ----------------- required by this bound in `bar` ... LL | bar(foo); | ^^^ the trait `std::future::Future` is not implemented for `fn() -> impl std::future::Future {foo}` @@ -19,7 +19,7 @@ error[E0277]: the trait bound `[closure@$DIR/async-fn-ctor-passed-as-arg-where-i --> $DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:12:9 | LL | fn bar(f: impl Future<Output=()>) {} - | --- ----------------- required by this bound in `bar` + | ----------------- required by this bound in `bar` ... LL | let async_closure = async || (); | -------- consider calling this closure diff --git a/src/test/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr b/src/test/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr index ed4a0b8487d..8589a2757e9 100644 --- a/src/test/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr +++ b/src/test/ui/suggestions/fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr @@ -5,7 +5,7 @@ LL | fn foo() -> impl T<O=()> { S } | --- consider calling this function LL | LL | fn bar(f: impl T<O=()>) {} - | --- ------- required by this bound in `bar` + | ------- required by this bound in `bar` ... LL | bar(foo); | ^^^ the trait `T` is not implemented for `fn() -> impl T {foo}` @@ -19,7 +19,7 @@ error[E0277]: the trait bound `[closure@$DIR/fn-ctor-passed-as-arg-where-it-shou --> $DIR/fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:19:9 | LL | fn bar(f: impl T<O=()>) {} - | --- ------- required by this bound in `bar` + | ------- required by this bound in `bar` ... LL | let closure = || S; | -- consider calling this closure diff --git a/src/test/ui/suggestions/imm-ref-trait-object-literal.stderr b/src/test/ui/suggestions/imm-ref-trait-object-literal.stderr index 84ba935191b..df483b3912d 100644 --- a/src/test/ui/suggestions/imm-ref-trait-object-literal.stderr +++ b/src/test/ui/suggestions/imm-ref-trait-object-literal.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `&S: Trait` is not satisfied --> $DIR/imm-ref-trait-object-literal.rs:12:7 | LL | fn foo<X: Trait>(_: X) {} - | --- ----- required by this bound in `foo` + | ----- required by this bound in `foo` ... LL | foo(&s); | ^^ the trait `Trait` is not implemented for `&S` @@ -18,7 +18,7 @@ error[E0277]: the trait bound `S: Trait` is not satisfied --> $DIR/imm-ref-trait-object-literal.rs:13:7 | LL | fn foo<X: Trait>(_: X) {} - | --- ----- required by this bound in `foo` + | ----- required by this bound in `foo` ... LL | foo(s); | ^ the trait `Trait` is not implemented for `S` diff --git a/src/test/ui/suggestions/into-str.stderr b/src/test/ui/suggestions/into-str.stderr index a1e1f4d1357..7414a7cc24c 100644 --- a/src/test/ui/suggestions/into-str.stderr +++ b/src/test/ui/suggestions/into-str.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `&str: std::convert::From<std::string::String>` is --> $DIR/into-str.rs:4:5 | LL | fn foo<'a, T>(_t: T) where T: Into<&'a str> {} - | --- ------------- required by this bound in `foo` + | ------------- required by this bound in `foo` ... LL | foo(String::new()); | ^^^ the trait `std::convert::From<std::string::String>` is not implemented for `&str` diff --git a/src/test/ui/suggestions/missing-assoc-type-bound-restriction.stderr b/src/test/ui/suggestions/missing-assoc-type-bound-restriction.stderr index 31d974ed43d..6b985edae9e 100644 --- a/src/test/ui/suggestions/missing-assoc-type-bound-restriction.stderr +++ b/src/test/ui/suggestions/missing-assoc-type-bound-restriction.stderr @@ -2,7 +2,10 @@ error[E0277]: the trait bound `<T as Parent>::Assoc: Child<A>` is not satisfied --> $DIR/missing-assoc-type-bound-restriction.rs:17:19 | LL | trait Parent { - | ------------ required by `Parent` + | ------ +LL | type Ty; +LL | type Assoc: Child<Self::Ty>; + | --------------- required by this bound in `Parent` ... LL | impl<A, T: Parent<Ty = A>> Parent for ParentWrapper<T> { | ^^^^^^ - help: consider further restricting the associated type: `where <T as Parent>::Assoc: Child<A>` @@ -29,7 +32,10 @@ error[E0277]: the trait bound `<T as Parent>::Assoc: Child<A>` is not satisfied --> $DIR/missing-assoc-type-bound-restriction.rs:20:5 | LL | trait Parent { - | ------------ required by `Parent` + | ------ +LL | type Ty; +LL | type Assoc: Child<Self::Ty>; + | --------------- required by this bound in `Parent` ... LL | impl<A, T: Parent<Ty = A>> Parent for ParentWrapper<T> { | - help: consider further restricting the associated type: `where <T as Parent>::Assoc: Child<A>` diff --git a/src/test/ui/suggestions/mut-borrow-needed-by-trait.stderr b/src/test/ui/suggestions/mut-borrow-needed-by-trait.stderr index 57a389cbb49..9ccddda45e2 100644 --- a/src/test/ui/suggestions/mut-borrow-needed-by-trait.stderr +++ b/src/test/ui/suggestions/mut-borrow-needed-by-trait.stderr @@ -12,18 +12,26 @@ error[E0277]: the trait bound `&dyn std::io::Write: std::io::Write` is not satis | LL | let fp = BufWriter::new(fp); | ^^^^^^^^^^^^^^ the trait `std::io::Write` is not implemented for `&dyn std::io::Write` + | + ::: $SRC_DIR/libstd/io/buffered.rs:LL:COL + | +LL | pub struct BufWriter<W: Write> { + | ----- required by this bound in `std::io::BufWriter` | = note: `std::io::Write` is implemented for `&mut dyn std::io::Write`, but not for `&dyn std::io::Write` - = note: required by `std::io::BufWriter` error[E0277]: the trait bound `&dyn std::io::Write: std::io::Write` is not satisfied --> $DIR/mut-borrow-needed-by-trait.rs:17:14 | LL | let fp = BufWriter::new(fp); | ^^^^^^^^^^^^^^^^^^ the trait `std::io::Write` is not implemented for `&dyn std::io::Write` + | + ::: $SRC_DIR/libstd/io/buffered.rs:LL:COL + | +LL | pub struct BufWriter<W: Write> { + | ----- required by this bound in `std::io::BufWriter` | = note: `std::io::Write` is implemented for `&mut dyn std::io::Write`, but not for `&dyn std::io::Write` - = note: required by `std::io::BufWriter` error[E0599]: no method named `write_fmt` found for struct `std::io::BufWriter<&dyn std::io::Write>` in the current scope --> $DIR/mut-borrow-needed-by-trait.rs:22:5 diff --git a/src/test/ui/suggestions/no-extern-crate-in-type.stderr b/src/test/ui/suggestions/no-extern-crate-in-type.stderr index 0a73a269134..22aad3b0a9f 100644 --- a/src/test/ui/suggestions/no-extern-crate-in-type.stderr +++ b/src/test/ui/suggestions/no-extern-crate-in-type.stderr @@ -8,10 +8,6 @@ help: possible candidate is found in another module, you can import it into scop | LL | use foo::Foo; | -help: you might be missing a type parameter - | -LL | type Output<Foo> = Option<Foo>; - | ^^^^^ error: aborting due to previous error diff --git a/src/test/ui/suggestions/restrict-type-argument.stderr b/src/test/ui/suggestions/restrict-type-argument.stderr index a98cb76a683..0c52778b0d8 100644 --- a/src/test/ui/suggestions/restrict-type-argument.stderr +++ b/src/test/ui/suggestions/restrict-type-argument.stderr @@ -2,7 +2,7 @@ error[E0277]: `impl Sync` cannot be sent between threads safely --> $DIR/restrict-type-argument.rs:4:13 | LL | fn is_send<T: Send>(val: T) {} - | ------- ---- required by this bound in `is_send` + | ---- required by this bound in `is_send` ... LL | is_send(val); | ^^^ `impl Sync` cannot be sent between threads safely @@ -17,7 +17,7 @@ error[E0277]: `S` cannot be sent between threads safely --> $DIR/restrict-type-argument.rs:8:13 | LL | fn is_send<T: Send>(val: T) {} - | ------- ---- required by this bound in `is_send` + | ---- required by this bound in `is_send` ... LL | is_send(val); | ^^^ `S` cannot be sent between threads safely @@ -32,7 +32,7 @@ error[E0277]: `S` cannot be sent between threads safely --> $DIR/restrict-type-argument.rs:12:13 | LL | fn is_send<T: Send>(val: T) {} - | ------- ---- required by this bound in `is_send` + | ---- required by this bound in `is_send` ... LL | is_send(val); | ^^^ `S` cannot be sent between threads safely @@ -47,7 +47,7 @@ error[E0277]: `S` cannot be sent between threads safely --> $DIR/restrict-type-argument.rs:20:13 | LL | fn is_send<T: Send>(val: T) {} - | ------- ---- required by this bound in `is_send` + | ---- required by this bound in `is_send` ... LL | is_send(val); | ^^^ `S` cannot be sent between threads safely @@ -62,7 +62,7 @@ error[E0277]: `S` cannot be sent between threads safely --> $DIR/restrict-type-argument.rs:24:13 | LL | fn is_send<T: Send>(val: T) {} - | ------- ---- required by this bound in `is_send` + | ---- required by this bound in `is_send` ... LL | is_send(val); | ^^^ `S` cannot be sent between threads safely @@ -77,7 +77,7 @@ error[E0277]: `S` cannot be sent between threads safely --> $DIR/restrict-type-argument.rs:28:13 | LL | fn is_send<T: Send>(val: T) {} - | ------- ---- required by this bound in `is_send` + | ---- required by this bound in `is_send` ... LL | is_send(val); | ^^^ `S` cannot be sent between threads safely diff --git a/src/test/ui/suggestions/suggest-move-types.stderr b/src/test/ui/suggestions/suggest-move-types.stderr index 4dd0613757a..3bb6fd6e4f4 100644 --- a/src/test/ui/suggestions/suggest-move-types.stderr +++ b/src/test/ui/suggestions/suggest-move-types.stderr @@ -4,79 +4,103 @@ error: generic arguments must come before the first constraint LL | struct A<T, M: One<A=(), T>> { | ---- ^ generic argument | | - | the first constraint is provided here + | constraint + | +help: move the constraint after the generic argument + | +LL | struct A<T, M: One<T, A = ()>> { + | ^^^^^^^^^^^ error: generic arguments must come before the first constraint --> $DIR/suggest-move-types.rs:33:43 | LL | struct Al<'a, T, M: OneWithLifetime<A=(), T, 'a>> { - | ---- ^ ^^ generic argument - | | | - | | generic argument - | the first constraint is provided here + | ---- ^ ^^ generic arguments + | | + | constraint + | +help: move the constraint after the generic arguments + | +LL | struct Al<'a, T, M: OneWithLifetime<'a, T, A = ()>> { + | ^^^^^^^^^^^^^^^ error: generic arguments must come before the first constraint --> $DIR/suggest-move-types.rs:40:46 | LL | struct B<T, U, V, M: Three<A=(), B=(), C=(), T, U, V>> { - | ---- ^ ^ ^ generic argument - | | | | - | | | generic argument - | | generic argument - | the first constraint is provided here + | ---- ---- ---- ^ ^ ^ generic arguments + | | + | constraints + | +help: move the constraints after the generic arguments + | +LL | struct B<T, U, V, M: Three<T, U, V, A = (), B = (), C = ()>> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: generic arguments must come before the first constraint --> $DIR/suggest-move-types.rs:48:71 | LL | struct Bl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<A=(), B=(), C=(), T, U, V, 'a, 'b, 'c>> { - | ---- ^ ^ ^ ^^ ^^ ^^ generic argument - | | | | | | | - | | | | | | generic argument - | | | | | generic argument - | | | | generic argument - | | | generic argument - | | generic argument - | the first constraint is provided here + | ---- ---- ---- ^ ^ ^ ^^ ^^ ^^ generic arguments + | | + | constraints + | +help: move the constraints after the generic arguments + | +LL | struct Bl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<'a, 'b, 'c, T, U, V, A = (), B = (), C = ()>> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: generic arguments must come before the first constraint - --> $DIR/suggest-move-types.rs:57:49 + --> $DIR/suggest-move-types.rs:57:28 | LL | struct C<T, U, V, M: Three<T, A=(), B=(), C=(), U, V>> { - | ---- ^ ^ generic argument - | | | - | | generic argument - | the first constraint is provided here + | ^ ---- ---- ---- ^ ^ generic arguments + | | + | constraints + | +help: move the constraints after the generic arguments + | +LL | struct C<T, U, V, M: Three<T, U, V, A = (), B = (), C = ()>> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: generic arguments must come before the first constraint - --> $DIR/suggest-move-types.rs:65:78 + --> $DIR/suggest-move-types.rs:65:53 | LL | struct Cl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<T, 'a, A=(), B=(), C=(), U, 'b, V, 'c>> { - | ---- ^ ^^ ^ ^^ generic argument - | | | | | - | | | | generic argument - | | | generic argument - | | generic argument - | the first constraint is provided here + | ^ ^^ ---- ---- ---- ^ ^^ ^ ^^ generic arguments + | | + | constraints + | +help: move the constraints after the generic arguments + | +LL | struct Cl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<'a, 'b, 'c, T, U, V, A = (), B = (), C = ()>> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: generic arguments must come before the first constraint - --> $DIR/suggest-move-types.rs:74:43 + --> $DIR/suggest-move-types.rs:74:28 | LL | struct D<T, U, V, M: Three<T, A=(), B=(), U, C=(), V>> { - | ---- ^ ^ generic argument - | | | - | | generic argument - | the first constraint is provided here + | ^ ---- ---- ^ ---- ^ generic arguments + | | + | constraints + | +help: move the constraints after the generic arguments + | +LL | struct D<T, U, V, M: Three<T, U, V, A = (), B = (), C = ()>> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: generic arguments must come before the first constraint - --> $DIR/suggest-move-types.rs:82:72 + --> $DIR/suggest-move-types.rs:82:53 | LL | struct Dl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<T, 'a, A=(), B=(), U, 'b, C=(), V, 'c>> { - | ---- ^ ^^ ^ ^^ generic argument - | | | | | - | | | | generic argument - | | | generic argument - | | generic argument - | the first constraint is provided here + | ^ ^^ ---- ---- ^ ^^ ---- ^ ^^ generic arguments + | | + | constraints + | +help: move the constraints after the generic arguments + | +LL | struct Dl<'a, 'b, 'c, T, U, V, M: ThreeWithLifetime<'a, 'b, 'c, T, U, V, A = (), B = (), C = ()>> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0747]: type provided when a lifetime was expected --> $DIR/suggest-move-types.rs:33:43 diff --git a/src/test/ui/traits/negative-impls/negated-auto-traits-error.stderr b/src/test/ui/traits/negative-impls/negated-auto-traits-error.stderr index 69a91b09e3e..446b8dbf114 100644 --- a/src/test/ui/traits/negative-impls/negated-auto-traits-error.stderr +++ b/src/test/ui/traits/negative-impls/negated-auto-traits-error.stderr @@ -13,7 +13,7 @@ error[E0277]: `dummy::TestType` cannot be sent between threads safely --> $DIR/negated-auto-traits-error.rs:23:5 | LL | struct Outer<T: Send>(T); - | ------------------------- required by `Outer` + | ---- required by this bound in `Outer` ... LL | Outer(TestType); | ^^^^^^^^^^^^^^^ `dummy::TestType` cannot be sent between threads safely @@ -24,7 +24,7 @@ error[E0277]: `dummy1b::TestType` cannot be sent between threads safely --> $DIR/negated-auto-traits-error.rs:32:13 | LL | fn is_send<T: Send>(_: T) {} - | ------- ---- required by this bound in `is_send` + | ---- required by this bound in `is_send` ... LL | is_send(TestType); | ^^^^^^^^ `dummy1b::TestType` cannot be sent between threads safely @@ -35,7 +35,7 @@ error[E0277]: `dummy1c::TestType` cannot be sent between threads safely --> $DIR/negated-auto-traits-error.rs:40:13 | LL | fn is_send<T: Send>(_: T) {} - | ------- ---- required by this bound in `is_send` + | ---- required by this bound in `is_send` ... LL | is_send((8, TestType)); | ^^^^^^^^^^^^^ `dummy1c::TestType` cannot be sent between threads safely @@ -47,7 +47,7 @@ error[E0277]: `dummy2::TestType` cannot be sent between threads safely --> $DIR/negated-auto-traits-error.rs:48:13 | LL | fn is_send<T: Send>(_: T) {} - | ------- ---- required by this bound in `is_send` + | ---- required by this bound in `is_send` ... LL | is_send(Box::new(TestType)); | ^^^^^^^^^^^^^^^^^^ @@ -63,7 +63,7 @@ error[E0277]: `dummy3::TestType` cannot be sent between threads safely --> $DIR/negated-auto-traits-error.rs:56:13 | LL | fn is_send<T: Send>(_: T) {} - | ------- ---- required by this bound in `is_send` + | ---- required by this bound in `is_send` ... LL | is_send(Box::new(Outer2(TestType))); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `dummy3::TestType` cannot be sent between threads safely @@ -77,7 +77,7 @@ error[E0277]: `main::TestType` cannot be sent between threads safely --> $DIR/negated-auto-traits-error.rs:66:13 | LL | fn is_sync<T: Sync>(_: T) {} - | ------- ---- required by this bound in `is_sync` + | ---- required by this bound in `is_sync` ... LL | is_sync(Outer2(TestType)); | ^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/traits/trait-alias/trait-alias-cross-crate.stderr b/src/test/ui/traits/trait-alias/trait-alias-cross-crate.stderr index cad5c81f5a6..04c86cb2403 100644 --- a/src/test/ui/traits/trait-alias/trait-alias-cross-crate.stderr +++ b/src/test/ui/traits/trait-alias/trait-alias-cross-crate.stderr @@ -2,7 +2,7 @@ error[E0277]: `std::rc::Rc<u32>` cannot be sent between threads safely --> $DIR/trait-alias-cross-crate.rs:14:17 | LL | fn use_alias<T: SendSync>() {} - | --------- -------- required by this bound in `use_alias` + | -------- required by this bound in `use_alias` ... LL | use_alias::<Rc<u32>>(); | ^^^^^^^ `std::rc::Rc<u32>` cannot be sent between threads safely @@ -13,7 +13,7 @@ error[E0277]: `std::rc::Rc<u32>` cannot be shared between threads safely --> $DIR/trait-alias-cross-crate.rs:14:17 | LL | fn use_alias<T: SendSync>() {} - | --------- -------- required by this bound in `use_alias` + | -------- required by this bound in `use_alias` ... LL | use_alias::<Rc<u32>>(); | ^^^^^^^ `std::rc::Rc<u32>` cannot be shared between threads safely diff --git a/src/test/ui/traits/trait-alias/trait-alias-wf.stderr b/src/test/ui/traits/trait-alias/trait-alias-wf.stderr index ca4980ca305..e0df76381e0 100644 --- a/src/test/ui/traits/trait-alias/trait-alias-wf.stderr +++ b/src/test/ui/traits/trait-alias/trait-alias-wf.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `T: Foo` is not satisfied --> $DIR/trait-alias-wf.rs:5:14 | LL | trait A<T: Foo> {} - | --------------- required by `A` + | --- required by this bound in `A` LL | trait B<T> = A<T>; | ^^^^ the trait `Foo` is not implemented for `T` | diff --git a/src/test/ui/traits/trait-bounds-on-structs-and-enums-in-fns.stderr b/src/test/ui/traits/trait-bounds-on-structs-and-enums-in-fns.stderr index a2253021a7f..6ca8ce0707f 100644 --- a/src/test/ui/traits/trait-bounds-on-structs-and-enums-in-fns.stderr +++ b/src/test/ui/traits/trait-bounds-on-structs-and-enums-in-fns.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `u32: Trait` is not satisfied --> $DIR/trait-bounds-on-structs-and-enums-in-fns.rs:13:15 | LL | struct Foo<T:Trait> { - | ------------------- required by `Foo` + | ----- required by this bound in `Foo` ... LL | fn explode(x: Foo<u32>) {} | ^^^^^^^^ the trait `Trait` is not implemented for `u32` @@ -11,7 +11,7 @@ error[E0277]: the trait bound `f32: Trait` is not satisfied --> $DIR/trait-bounds-on-structs-and-enums-in-fns.rs:16:14 | LL | enum Bar<T:Trait> { - | ----------------- required by `Bar` + | ----- required by this bound in `Bar` ... LL | fn kaboom(y: Bar<f32>) {} | ^^^^^^^^ the trait `Trait` is not implemented for `f32` diff --git a/src/test/ui/traits/trait-bounds-on-structs-and-enums-in-impls.stderr b/src/test/ui/traits/trait-bounds-on-structs-and-enums-in-impls.stderr index 7e8db610fe2..87271e7f1ee 100644 --- a/src/test/ui/traits/trait-bounds-on-structs-and-enums-in-impls.stderr +++ b/src/test/ui/traits/trait-bounds-on-structs-and-enums-in-impls.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `u16: Trait` is not satisfied --> $DIR/trait-bounds-on-structs-and-enums-in-impls.rs:20:6 | LL | struct Foo<T:Trait> { - | ------------------- required by `Foo` + | ----- required by this bound in `Foo` ... LL | impl PolyTrait<Foo<u16>> for Struct { | ^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `u16` diff --git a/src/test/ui/traits/trait-bounds-on-structs-and-enums-locals.stderr b/src/test/ui/traits/trait-bounds-on-structs-and-enums-locals.stderr index 070b7b013e5..df016a77274 100644 --- a/src/test/ui/traits/trait-bounds-on-structs-and-enums-locals.stderr +++ b/src/test/ui/traits/trait-bounds-on-structs-and-enums-locals.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `usize: Trait` is not satisfied --> $DIR/trait-bounds-on-structs-and-enums-locals.rs:15:14 | LL | struct Foo<T:Trait> { - | ------------------- required by `Foo` + | ----- required by this bound in `Foo` ... LL | let baz: Foo<usize> = loop { }; | ^^^^^^^^^^ the trait `Trait` is not implemented for `usize` diff --git a/src/test/ui/traits/trait-bounds-on-structs-and-enums-static.stderr b/src/test/ui/traits/trait-bounds-on-structs-and-enums-static.stderr index 722f01750cb..4b650e78bad 100644 --- a/src/test/ui/traits/trait-bounds-on-structs-and-enums-static.stderr +++ b/src/test/ui/traits/trait-bounds-on-structs-and-enums-static.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `usize: Trait` is not satisfied --> $DIR/trait-bounds-on-structs-and-enums-static.rs:9:11 | LL | struct Foo<T:Trait> { - | ------------------- required by `Foo` + | ----- required by this bound in `Foo` ... LL | static X: Foo<usize> = Foo { | ^^^^^^^^^^ the trait `Trait` is not implemented for `usize` diff --git a/src/test/ui/traits/trait-bounds-on-structs-and-enums-xc.stderr b/src/test/ui/traits/trait-bounds-on-structs-and-enums-xc.stderr index c5a7746afdf..d2fa211b487 100644 --- a/src/test/ui/traits/trait-bounds-on-structs-and-enums-xc.stderr +++ b/src/test/ui/traits/trait-bounds-on-structs-and-enums-xc.stderr @@ -3,16 +3,22 @@ error[E0277]: the trait bound `usize: trait_bounds_on_structs_and_enums_xc::Trai | LL | fn explode(x: Foo<usize>) {} | ^^^^^^^^^^ the trait `trait_bounds_on_structs_and_enums_xc::Trait` is not implemented for `usize` + | + ::: $DIR/auxiliary/trait_bounds_on_structs_and_enums_xc.rs:5:18 | - = note: required by `trait_bounds_on_structs_and_enums_xc::Foo` +LL | pub struct Foo<T:Trait> { + | ----- required by this bound in `trait_bounds_on_structs_and_enums_xc::Foo` error[E0277]: the trait bound `f32: trait_bounds_on_structs_and_enums_xc::Trait` is not satisfied --> $DIR/trait-bounds-on-structs-and-enums-xc.rs:10:14 | LL | fn kaboom(y: Bar<f32>) {} | ^^^^^^^^ the trait `trait_bounds_on_structs_and_enums_xc::Trait` is not implemented for `f32` + | + ::: $DIR/auxiliary/trait_bounds_on_structs_and_enums_xc.rs:9:16 | - = note: required by `trait_bounds_on_structs_and_enums_xc::Bar` +LL | pub enum Bar<T:Trait> { + | ----- required by this bound in `trait_bounds_on_structs_and_enums_xc::Bar` error: aborting due to 2 previous errors diff --git a/src/test/ui/traits/trait-bounds-on-structs-and-enums-xc1.stderr b/src/test/ui/traits/trait-bounds-on-structs-and-enums-xc1.stderr index 57db65df5f3..ee3e755c953 100644 --- a/src/test/ui/traits/trait-bounds-on-structs-and-enums-xc1.stderr +++ b/src/test/ui/traits/trait-bounds-on-structs-and-enums-xc1.stderr @@ -3,8 +3,11 @@ error[E0277]: the trait bound `f64: trait_bounds_on_structs_and_enums_xc::Trait` | LL | let bar: Bar<f64> = return; | ^^^^^^^^ the trait `trait_bounds_on_structs_and_enums_xc::Trait` is not implemented for `f64` + | + ::: $DIR/auxiliary/trait_bounds_on_structs_and_enums_xc.rs:9:16 | - = note: required by `trait_bounds_on_structs_and_enums_xc::Bar` +LL | pub enum Bar<T:Trait> { + | ----- required by this bound in `trait_bounds_on_structs_and_enums_xc::Bar` error[E0277]: the trait bound `{integer}: trait_bounds_on_structs_and_enums_xc::Trait` is not satisfied --> $DIR/trait-bounds-on-structs-and-enums-xc1.rs:8:15 diff --git a/src/test/ui/traits/trait-bounds-on-structs-and-enums.stderr b/src/test/ui/traits/trait-bounds-on-structs-and-enums.stderr index 9e8e5e08145..271ed07ce42 100644 --- a/src/test/ui/traits/trait-bounds-on-structs-and-enums.stderr +++ b/src/test/ui/traits/trait-bounds-on-structs-and-enums.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `T: Trait` is not satisfied --> $DIR/trait-bounds-on-structs-and-enums.rs:13:9 | LL | struct Foo<T:Trait> { - | ------------------- required by `Foo` + | ----- required by this bound in `Foo` ... LL | impl<T> Foo<T> { | ^^^^^^ the trait `Trait` is not implemented for `T` @@ -16,7 +16,7 @@ error[E0277]: the trait bound `isize: Trait` is not satisfied --> $DIR/trait-bounds-on-structs-and-enums.rs:19:5 | LL | struct Foo<T:Trait> { - | ------------------- required by `Foo` + | ----- required by this bound in `Foo` ... LL | a: Foo<isize>, | ^^^^^^^^^^^^^ the trait `Trait` is not implemented for `isize` @@ -25,7 +25,7 @@ error[E0277]: the trait bound `usize: Trait` is not satisfied --> $DIR/trait-bounds-on-structs-and-enums.rs:23:10 | LL | enum Bar<T:Trait> { - | ----------------- required by `Bar` + | ----- required by this bound in `Bar` ... LL | Quux(Bar<usize>), | ^^^^^^^^^^ the trait `Trait` is not implemented for `usize` @@ -34,7 +34,7 @@ error[E0277]: the trait bound `U: Trait` is not satisfied --> $DIR/trait-bounds-on-structs-and-enums.rs:27:5 | LL | struct Foo<T:Trait> { - | ------------------- required by `Foo` + | ----- required by this bound in `Foo` ... LL | b: Foo<U>, | ^^^^^^^^^ the trait `Trait` is not implemented for `U` @@ -48,7 +48,7 @@ error[E0277]: the trait bound `V: Trait` is not satisfied --> $DIR/trait-bounds-on-structs-and-enums.rs:31:21 | LL | enum Bar<T:Trait> { - | ----------------- required by `Bar` + | ----- required by this bound in `Bar` ... LL | EvenMoreBadness(Bar<V>), | ^^^^^^ the trait `Trait` is not implemented for `V` @@ -62,7 +62,7 @@ error[E0277]: the trait bound `i32: Trait` is not satisfied --> $DIR/trait-bounds-on-structs-and-enums.rs:35:5 | LL | struct Foo<T:Trait> { - | ------------------- required by `Foo` + | ----- required by this bound in `Foo` ... LL | Foo<i32>, | ^^^^^^^^ the trait `Trait` is not implemented for `i32` @@ -71,7 +71,7 @@ error[E0277]: the trait bound `u8: Trait` is not satisfied --> $DIR/trait-bounds-on-structs-and-enums.rs:39:22 | LL | enum Bar<T:Trait> { - | ----------------- required by `Bar` + | ----- required by this bound in `Bar` ... LL | DictionaryLike { field: Bar<u8> }, | ^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `u8` diff --git a/src/test/ui/traits/trait-static-method-generic-inference.stderr b/src/test/ui/traits/trait-static-method-generic-inference.stderr index f9718dac354..8f20cc5093e 100644 --- a/src/test/ui/traits/trait-static-method-generic-inference.stderr +++ b/src/test/ui/traits/trait-static-method-generic-inference.stderr @@ -7,7 +7,7 @@ LL | fn new() -> T; LL | let _f: base::Foo = base::HasNew::new(); | ^^^^^^^^^^^^^^^^^ cannot infer type | - = note: cannot resolve `_: base::HasNew<base::Foo>` + = note: cannot satisfy `_: base::HasNew<base::Foo>` error: aborting due to previous error diff --git a/src/test/ui/traits/traits-inductive-overflow-simultaneous.stderr b/src/test/ui/traits/traits-inductive-overflow-simultaneous.stderr index 6fd6a37b22d..a0d2d13fbf3 100644 --- a/src/test/ui/traits/traits-inductive-overflow-simultaneous.stderr +++ b/src/test/ui/traits/traits-inductive-overflow-simultaneous.stderr @@ -2,7 +2,7 @@ error[E0275]: overflow evaluating the requirement `{integer}: Tweedledum` --> $DIR/traits-inductive-overflow-simultaneous.rs:18:5 | LL | fn is_ee<T: Combo>(t: T) { - | ----- ----- required by this bound in `is_ee` + | ----- required by this bound in `is_ee` ... LL | is_ee(4); | ^^^^^ diff --git a/src/test/ui/traits/traits-inductive-overflow-supertrait-oibit.stderr b/src/test/ui/traits/traits-inductive-overflow-supertrait-oibit.stderr index f44986da0e2..b97197285ed 100644 --- a/src/test/ui/traits/traits-inductive-overflow-supertrait-oibit.stderr +++ b/src/test/ui/traits/traits-inductive-overflow-supertrait-oibit.stderr @@ -10,7 +10,7 @@ error[E0277]: the trait bound `NoClone: std::marker::Copy` is not satisfied --> $DIR/traits-inductive-overflow-supertrait-oibit.rs:16:23 | LL | fn copy<T: Magic>(x: T) -> (T, T) { (x, x) } - | ---- ----- required by this bound in `copy` + | ----- required by this bound in `copy` ... LL | let (a, b) = copy(NoClone); | ^^^^^^^ the trait `std::marker::Copy` is not implemented for `NoClone` diff --git a/src/test/ui/traits/traits-inductive-overflow-supertrait.stderr b/src/test/ui/traits/traits-inductive-overflow-supertrait.stderr index 96a9343d4eb..a86648d9a17 100644 --- a/src/test/ui/traits/traits-inductive-overflow-supertrait.stderr +++ b/src/test/ui/traits/traits-inductive-overflow-supertrait.stderr @@ -2,7 +2,7 @@ error[E0275]: overflow evaluating the requirement `NoClone: Magic` --> $DIR/traits-inductive-overflow-supertrait.rs:13:18 | LL | fn copy<T: Magic>(x: T) -> (T, T) { (x, x) } - | ---- ----- required by this bound in `copy` + | ----- required by this bound in `copy` ... LL | let (a, b) = copy(NoClone); | ^^^^ diff --git a/src/test/ui/traits/traits-inductive-overflow-two-traits.stderr b/src/test/ui/traits/traits-inductive-overflow-two-traits.stderr index 447fc564348..f66cfce55c9 100644 --- a/src/test/ui/traits/traits-inductive-overflow-two-traits.stderr +++ b/src/test/ui/traits/traits-inductive-overflow-two-traits.stderr @@ -2,7 +2,7 @@ error[E0275]: overflow evaluating the requirement `*mut (): Magic` --> $DIR/traits-inductive-overflow-two-traits.rs:19:5 | LL | fn wizard<T: Magic>() { check::<<T as Magic>::X>(); } - | ------ ----- required by this bound in `wizard` + | ----- required by this bound in `wizard` ... LL | wizard::<*mut ()>(); | ^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/trivial-bounds/trivial-bounds-leak.stderr b/src/test/ui/trivial-bounds/trivial-bounds-leak.stderr index 4e153081d9f..006fa933d34 100644 --- a/src/test/ui/trivial-bounds/trivial-bounds-leak.stderr +++ b/src/test/ui/trivial-bounds/trivial-bounds-leak.stderr @@ -37,7 +37,7 @@ LL | generic_function(5i32); | ^^^^ the trait `Foo` is not implemented for `i32` ... LL | fn generic_function<T: Foo>(t: T) {} - | ---------------- --- required by this bound in `generic_function` + | --- required by this bound in `generic_function` error: aborting due to 4 previous errors diff --git a/src/test/ui/try-operator-on-main.stderr b/src/test/ui/try-operator-on-main.stderr index d8ba264583e..ecad5a7d11a 100644 --- a/src/test/ui/try-operator-on-main.stderr +++ b/src/test/ui/try-operator-on-main.stderr @@ -30,7 +30,7 @@ LL | try_trait_generic::<()>(); | ^^ the trait `std::ops::Try` is not implemented for `()` ... LL | fn try_trait_generic<T: Try>() -> T { - | ----------------- --- required by this bound in `try_trait_generic` + | --- required by this bound in `try_trait_generic` error[E0277]: the `?` operator can only be applied to values that implement `std::ops::Try` --> $DIR/try-operator-on-main.rs:22:5 diff --git a/src/test/ui/type/type-annotation-needed.rs b/src/test/ui/type/type-annotation-needed.rs index a420515be49..553318ecac6 100644 --- a/src/test/ui/type/type-annotation-needed.rs +++ b/src/test/ui/type/type-annotation-needed.rs @@ -1,10 +1,9 @@ fn foo<T: Into<String>>(x: i32) {} //~^ NOTE required by -//~| NOTE fn main() { foo(42); //~^ ERROR type annotations needed //~| NOTE cannot infer type - //~| NOTE cannot resolve + //~| NOTE cannot satisfy } diff --git a/src/test/ui/type/type-annotation-needed.stderr b/src/test/ui/type/type-annotation-needed.stderr index df7d73d7a7c..927cc507265 100644 --- a/src/test/ui/type/type-annotation-needed.stderr +++ b/src/test/ui/type/type-annotation-needed.stderr @@ -1,13 +1,13 @@ error[E0283]: type annotations needed - --> $DIR/type-annotation-needed.rs:6:5 + --> $DIR/type-annotation-needed.rs:5:5 | LL | fn foo<T: Into<String>>(x: i32) {} - | --- ------------ required by this bound in `foo` + | ------------ required by this bound in `foo` ... LL | foo(42); | ^^^ cannot infer type for type parameter `T` declared on the function `foo` | - = note: cannot resolve `_: std::convert::Into<std::string::String>` + = note: cannot satisfy `_: std::convert::Into<std::string::String>` help: consider specifying the type argument in the function call | LL | foo::<T>(42); diff --git a/src/test/ui/type/type-check-defaults.stderr b/src/test/ui/type/type-check-defaults.stderr index ca9b85bacba..e2729c65e02 100644 --- a/src/test/ui/type/type-check-defaults.stderr +++ b/src/test/ui/type/type-check-defaults.stderr @@ -2,7 +2,7 @@ error[E0277]: a value of type `i32` cannot be built from an iterator over elemen --> $DIR/type-check-defaults.rs:6:19 | LL | struct Foo<T, U: FromIterator<T>>(T, U); - | ---------------------------------------- required by `Foo` + | --------------- required by this bound in `Foo` LL | struct WellFormed<Z = Foo<i32, i32>>(Z); | ^ value of type `i32` cannot be built from `std::iter::Iterator<Item=i32>` | @@ -12,7 +12,7 @@ error[E0277]: a value of type `i32` cannot be built from an iterator over elemen --> $DIR/type-check-defaults.rs:8:27 | LL | struct Foo<T, U: FromIterator<T>>(T, U); - | ---------------------------------------- required by `Foo` + | --------------- required by this bound in `Foo` ... LL | struct WellFormedNoBounds<Z:?Sized = Foo<i32, i32>>(Z); | ^ value of type `i32` cannot be built from `std::iter::Iterator<Item=i32>` @@ -50,7 +50,7 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/type-check-defaults.rs:21:25 | LL | trait Super<T: Copy> { } - | -------------------- required by `Super` + | ---- required by this bound in `Super` LL | trait Base<T = String>: Super<T> { } | ^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` | diff --git a/src/test/ui/type/type-check/issue-40294.stderr b/src/test/ui/type/type-check/issue-40294.stderr index 2c889b6c2ca..ea7771a9c22 100644 --- a/src/test/ui/type/type-check/issue-40294.stderr +++ b/src/test/ui/type/type-check/issue-40294.stderr @@ -2,12 +2,12 @@ error[E0283]: type annotations needed --> $DIR/issue-40294.rs:6:19 | LL | trait Foo: Sized { - | ---------------- required by `Foo` + | ---------------- required by this bound in `Foo` ... LL | where &'a T : Foo, | ^^^ cannot infer type for reference `&'a T` | - = note: cannot resolve `&'a T: Foo` + = note: cannot satisfy `&'a T: Foo` error: aborting due to previous error diff --git a/src/test/ui/typeck/typeck-default-trait-impl-assoc-type.stderr b/src/test/ui/typeck/typeck-default-trait-impl-assoc-type.stderr index 2e54cdf0132..e64acfc54ff 100644 --- a/src/test/ui/typeck/typeck-default-trait-impl-assoc-type.stderr +++ b/src/test/ui/typeck/typeck-default-trait-impl-assoc-type.stderr @@ -7,7 +7,7 @@ LL | is_send::<T::AssocType>(); | ^^^^^^^^^^^^^^^^^^^^^^^ `<T as Trait>::AssocType` cannot be sent between threads safely ... LL | fn is_send<T:Send>() { - | ------- ---- required by this bound in `is_send` + | ---- required by this bound in `is_send` | = help: the trait `std::marker::Send` is not implemented for `<T as Trait>::AssocType` diff --git a/src/test/ui/typeck/typeck-default-trait-impl-constituent-types-2.stderr b/src/test/ui/typeck/typeck-default-trait-impl-constituent-types-2.stderr index 23401ca3086..53ba9b8a3f6 100644 --- a/src/test/ui/typeck/typeck-default-trait-impl-constituent-types-2.stderr +++ b/src/test/ui/typeck/typeck-default-trait-impl-constituent-types-2.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `MyS2: MyTrait` is not satisfied in `(MyS2, MyS)` --> $DIR/typeck-default-trait-impl-constituent-types-2.rs:17:5 | LL | fn is_mytrait<T: MyTrait>() {} - | ---------- ------- required by this bound in `is_mytrait` + | ------- required by this bound in `is_mytrait` ... LL | is_mytrait::<(MyS2, MyS)>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ within `(MyS2, MyS)`, the trait `MyTrait` is not implemented for `MyS2` diff --git a/src/test/ui/typeck/typeck-default-trait-impl-constituent-types.stderr b/src/test/ui/typeck/typeck-default-trait-impl-constituent-types.stderr index a30b29a3893..bc500004984 100644 --- a/src/test/ui/typeck/typeck-default-trait-impl-constituent-types.stderr +++ b/src/test/ui/typeck/typeck-default-trait-impl-constituent-types.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `MyS2: MyTrait` is not satisfied --> $DIR/typeck-default-trait-impl-constituent-types.rs:21:18 | LL | fn is_mytrait<T: MyTrait>() {} - | ---------- ------- required by this bound in `is_mytrait` + | ------- required by this bound in `is_mytrait` ... LL | is_mytrait::<MyS2>(); | ^^^^ the trait `MyTrait` is not implemented for `MyS2` diff --git a/src/test/ui/typeck/typeck-default-trait-impl-negation-send.stderr b/src/test/ui/typeck/typeck-default-trait-impl-negation-send.stderr index e30d4dfa1b3..b6ab36f5159 100644 --- a/src/test/ui/typeck/typeck-default-trait-impl-negation-send.stderr +++ b/src/test/ui/typeck/typeck-default-trait-impl-negation-send.stderr @@ -2,7 +2,7 @@ error[E0277]: `MyNotSendable` cannot be sent between threads safely --> $DIR/typeck-default-trait-impl-negation-send.rs:19:15 | LL | fn is_send<T: Send>() {} - | ------- ---- required by this bound in `is_send` + | ---- required by this bound in `is_send` ... LL | is_send::<MyNotSendable>(); | ^^^^^^^^^^^^^ `MyNotSendable` cannot be sent between threads safely diff --git a/src/test/ui/typeck/typeck-default-trait-impl-negation-sync.stderr b/src/test/ui/typeck/typeck-default-trait-impl-negation-sync.stderr index 4dd8e01cf2d..d671b8eb754 100644 --- a/src/test/ui/typeck/typeck-default-trait-impl-negation-sync.stderr +++ b/src/test/ui/typeck/typeck-default-trait-impl-negation-sync.stderr @@ -2,7 +2,7 @@ error[E0277]: `MyNotSync` cannot be shared between threads safely --> $DIR/typeck-default-trait-impl-negation-sync.rs:33:15 | LL | fn is_sync<T: Sync>() {} - | ------- ---- required by this bound in `is_sync` + | ---- required by this bound in `is_sync` ... LL | is_sync::<MyNotSync>(); | ^^^^^^^^^ `MyNotSync` cannot be shared between threads safely @@ -13,7 +13,7 @@ error[E0277]: `std::cell::UnsafeCell<u8>` cannot be shared between threads safel --> $DIR/typeck-default-trait-impl-negation-sync.rs:36:5 | LL | fn is_sync<T: Sync>() {} - | ------- ---- required by this bound in `is_sync` + | ---- required by this bound in `is_sync` ... LL | is_sync::<MyTypeWUnsafe>(); | ^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell<u8>` cannot be shared between threads safely @@ -25,7 +25,7 @@ error[E0277]: `Managed` cannot be shared between threads safely --> $DIR/typeck-default-trait-impl-negation-sync.rs:39:5 | LL | fn is_sync<T: Sync>() {} - | ------- ---- required by this bound in `is_sync` + | ---- required by this bound in `is_sync` ... LL | is_sync::<MyTypeManaged>(); | ^^^^^^^^^^^^^^^^^^^^^^^^ `Managed` cannot be shared between threads safely diff --git a/src/test/ui/typeck/typeck-default-trait-impl-negation.stderr b/src/test/ui/typeck/typeck-default-trait-impl-negation.stderr index e31bb810744..76a6994cb00 100644 --- a/src/test/ui/typeck/typeck-default-trait-impl-negation.stderr +++ b/src/test/ui/typeck/typeck-default-trait-impl-negation.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `ThisImplsUnsafeTrait: MyTrait` is not satisfied --> $DIR/typeck-default-trait-impl-negation.rs:22:19 | LL | fn is_my_trait<T: MyTrait>() {} - | ----------- ------- required by this bound in `is_my_trait` + | ------- required by this bound in `is_my_trait` ... LL | is_my_trait::<ThisImplsUnsafeTrait>(); | ^^^^^^^^^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `ThisImplsUnsafeTrait` @@ -14,7 +14,7 @@ error[E0277]: the trait bound `ThisImplsTrait: MyUnsafeTrait` is not satisfied --> $DIR/typeck-default-trait-impl-negation.rs:25:26 | LL | fn is_my_unsafe_trait<T: MyUnsafeTrait>() {} - | ------------------ ------------- required by this bound in `is_my_unsafe_trait` + | ------------- required by this bound in `is_my_unsafe_trait` ... LL | is_my_unsafe_trait::<ThisImplsTrait>(); | ^^^^^^^^^^^^^^ the trait `MyUnsafeTrait` is not implemented for `ThisImplsTrait` diff --git a/src/test/ui/typeck/typeck-default-trait-impl-precedence.stderr b/src/test/ui/typeck/typeck-default-trait-impl-precedence.stderr index 0d256094c60..5962d191292 100644 --- a/src/test/ui/typeck/typeck-default-trait-impl-precedence.stderr +++ b/src/test/ui/typeck/typeck-default-trait-impl-precedence.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `u32: Signed` is not satisfied --> $DIR/typeck-default-trait-impl-precedence.rs:19:5 | LL | fn is_defaulted<T:Defaulted>() { } - | ------------ --------- required by this bound in `is_defaulted` + | --------- required by this bound in `is_defaulted` ... LL | is_defaulted::<&'static u32>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Signed` is not implemented for `u32` diff --git a/src/test/ui/typeck/typeck-default-trait-impl-send-param.stderr b/src/test/ui/typeck/typeck-default-trait-impl-send-param.stderr index c8411017b3c..9cba3578449 100644 --- a/src/test/ui/typeck/typeck-default-trait-impl-send-param.stderr +++ b/src/test/ui/typeck/typeck-default-trait-impl-send-param.stderr @@ -5,7 +5,7 @@ LL | is_send::<T>() | ^ `T` cannot be sent between threads safely ... LL | fn is_send<T:Send>() { - | ------- ---- required by this bound in `is_send` + | ---- required by this bound in `is_send` | = help: the trait `std::marker::Send` is not implemented for `T` help: consider restricting type parameter `T` diff --git a/src/test/ui/typeck/typeck-unsafe-always-share.stderr b/src/test/ui/typeck/typeck-unsafe-always-share.stderr index d08613238f8..61585fcc1c8 100644 --- a/src/test/ui/typeck/typeck-unsafe-always-share.stderr +++ b/src/test/ui/typeck/typeck-unsafe-always-share.stderr @@ -2,7 +2,7 @@ error[E0277]: `std::cell::UnsafeCell<MySync<{integer}>>` cannot be shared betwee --> $DIR/typeck-unsafe-always-share.rs:19:10 | LL | fn test<T: Sync>(s: T) {} - | ---- ---- required by this bound in `test` + | ---- required by this bound in `test` ... LL | test(us); | ^^ `std::cell::UnsafeCell<MySync<{integer}>>` cannot be shared between threads safely @@ -13,7 +13,7 @@ error[E0277]: `std::cell::UnsafeCell<NoSync>` cannot be shared between threads s --> $DIR/typeck-unsafe-always-share.rs:23:10 | LL | fn test<T: Sync>(s: T) {} - | ---- ---- required by this bound in `test` + | ---- required by this bound in `test` ... LL | test(uns); | ^^^ `std::cell::UnsafeCell<NoSync>` cannot be shared between threads safely @@ -24,7 +24,7 @@ error[E0277]: `std::cell::UnsafeCell<NoSync>` cannot be shared between threads s --> $DIR/typeck-unsafe-always-share.rs:27:5 | LL | fn test<T: Sync>(s: T) {} - | ---- ---- required by this bound in `test` + | ---- required by this bound in `test` ... LL | test(ms); | ^^^^ `std::cell::UnsafeCell<NoSync>` cannot be shared between threads safely @@ -36,7 +36,7 @@ error[E0277]: `NoSync` cannot be shared between threads safely --> $DIR/typeck-unsafe-always-share.rs:30:10 | LL | fn test<T: Sync>(s: T) {} - | ---- ---- required by this bound in `test` + | ---- required by this bound in `test` ... LL | test(NoSync); | ^^^^^^ `NoSync` cannot be shared between threads safely diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-default.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-default.stderr index 6ec40638289..908d8543851 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-default.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-default.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `dyn Foo<(isize,), isize, Output = ()>: Eq<dyn Foo --> $DIR/unboxed-closure-sugar-default.rs:21:5 | LL | fn eq<A: ?Sized,B: ?Sized>() where A : Eq<B> { } - | -- ----- required by this bound in `eq` + | ----- required by this bound in `eq` ... LL | eq::<dyn Foo<(isize,), isize, Output=()>, dyn Foo(isize)>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Eq<dyn Foo<(isize,), Output = ()>>` is not implemented for `dyn Foo<(isize,), isize, Output = ()>` diff --git a/src/test/ui/unboxed-closures/unboxed-closure-sugar-equiv.stderr b/src/test/ui/unboxed-closures/unboxed-closure-sugar-equiv.stderr index 8dd32ee7f10..8ce7e825a1c 100644 --- a/src/test/ui/unboxed-closures/unboxed-closure-sugar-equiv.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closure-sugar-equiv.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `dyn Foo<(char,), Output = ()>: Eq<dyn Foo<(), Out --> $DIR/unboxed-closure-sugar-equiv.rs:43:5 | LL | fn eq<A: ?Sized,B: ?Sized +Eq<A>>() { } - | -- ----- required by this bound in `eq` + | ----- required by this bound in `eq` ... LL | / eq::< dyn Foo<(),Output=()>, LL | | dyn Foo(char) >(); diff --git a/src/test/ui/unboxed-closures/unboxed-closures-fnmut-as-fn.stderr b/src/test/ui/unboxed-closures/unboxed-closures-fnmut-as-fn.stderr index dc766181531..d427873ebcb 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-fnmut-as-fn.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-fnmut-as-fn.stderr @@ -2,7 +2,7 @@ error[E0277]: expected a `std::ops::Fn<(isize,)>` closure, found `S` --> $DIR/unboxed-closures-fnmut-as-fn.rs:28:21 | LL | fn call_it<F:Fn(isize)->isize>(f: &F, x: isize) -> isize { - | ------- ---------------- required by this bound in `call_it` + | ---------------- required by this bound in `call_it` ... LL | let x = call_it(&S, 22); | ^^ expected an `Fn<(isize,)>` closure, found `S` diff --git a/src/test/ui/unboxed-closures/unboxed-closures-unsafe-extern-fn.stderr b/src/test/ui/unboxed-closures/unboxed-closures-unsafe-extern-fn.stderr index 0b86719df84..b9ee9e46020 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-unsafe-extern-fn.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-unsafe-extern-fn.stderr @@ -2,7 +2,7 @@ error[E0277]: expected a `std::ops::Fn<(&isize,)>` closure, found `for<'r> unsaf --> $DIR/unboxed-closures-unsafe-extern-fn.rs:12:21 | LL | fn call_it<F:Fn(&isize)->isize>(_: &F, _: isize) -> isize { 0 } - | ------- ----------------- required by this bound in `call_it` + | ----------------- required by this bound in `call_it` ... LL | let x = call_it(&square, 22); | ^^^^^^^ expected an `Fn<(&isize,)>` closure, found `for<'r> unsafe fn(&'r isize) -> isize {square}` @@ -13,7 +13,7 @@ error[E0277]: expected a `std::ops::FnOnce<(&isize,)>` closure, found `for<'r> u --> $DIR/unboxed-closures-unsafe-extern-fn.rs:12:21 | LL | fn call_it<F:Fn(&isize)->isize>(_: &F, _: isize) -> isize { 0 } - | ------- ----- required by this bound in `call_it` + | ----- required by this bound in `call_it` ... LL | let x = call_it(&square, 22); | ^^^^^^^ expected an `FnOnce<(&isize,)>` closure, found `for<'r> unsafe fn(&'r isize) -> isize {square}` @@ -24,7 +24,7 @@ error[E0277]: expected a `std::ops::FnMut<(&isize,)>` closure, found `for<'r> un --> $DIR/unboxed-closures-unsafe-extern-fn.rs:18:25 | LL | fn call_it_mut<F:FnMut(&isize)->isize>(_: &mut F, _: isize) -> isize { 0 } - | ----------- -------------------- required by this bound in `call_it_mut` + | -------------------- required by this bound in `call_it_mut` ... LL | let y = call_it_mut(&mut square, 22); | ^^^^^^^^^^^ expected an `FnMut<(&isize,)>` closure, found `for<'r> unsafe fn(&'r isize) -> isize {square}` @@ -35,7 +35,7 @@ error[E0277]: expected a `std::ops::FnOnce<(&isize,)>` closure, found `for<'r> u --> $DIR/unboxed-closures-unsafe-extern-fn.rs:18:25 | LL | fn call_it_mut<F:FnMut(&isize)->isize>(_: &mut F, _: isize) -> isize { 0 } - | ----------- ----- required by this bound in `call_it_mut` + | ----- required by this bound in `call_it_mut` ... LL | let y = call_it_mut(&mut square, 22); | ^^^^^^^^^^^ expected an `FnOnce<(&isize,)>` closure, found `for<'r> unsafe fn(&'r isize) -> isize {square}` @@ -46,7 +46,7 @@ error[E0277]: expected a `std::ops::FnOnce<(&isize,)>` closure, found `for<'r> u --> $DIR/unboxed-closures-unsafe-extern-fn.rs:24:26 | LL | fn call_it_once<F:FnOnce(&isize)->isize>(_: F, _: isize) -> isize { 0 } - | ------------ ----- required by this bound in `call_it_once` + | ----- required by this bound in `call_it_once` ... LL | let z = call_it_once(square, 22); | ^^^^^^ expected an `FnOnce<(&isize,)>` closure, found `for<'r> unsafe fn(&'r isize) -> isize {square}` diff --git a/src/test/ui/unboxed-closures/unboxed-closures-wrong-abi.stderr b/src/test/ui/unboxed-closures/unboxed-closures-wrong-abi.stderr index 17faf047c14..654b626cf65 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-wrong-abi.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-wrong-abi.stderr @@ -2,7 +2,7 @@ error[E0277]: expected a `std::ops::Fn<(&isize,)>` closure, found `for<'r> exter --> $DIR/unboxed-closures-wrong-abi.rs:12:21 | LL | fn call_it<F:Fn(&isize)->isize>(_: &F, _: isize) -> isize { 0 } - | ------- ----------------- required by this bound in `call_it` + | ----------------- required by this bound in `call_it` ... LL | let x = call_it(&square, 22); | ^^^^^^^ expected an `Fn<(&isize,)>` closure, found `for<'r> extern "C" fn(&'r isize) -> isize {square}` @@ -13,7 +13,7 @@ error[E0277]: expected a `std::ops::FnOnce<(&isize,)>` closure, found `for<'r> e --> $DIR/unboxed-closures-wrong-abi.rs:12:21 | LL | fn call_it<F:Fn(&isize)->isize>(_: &F, _: isize) -> isize { 0 } - | ------- ----- required by this bound in `call_it` + | ----- required by this bound in `call_it` ... LL | let x = call_it(&square, 22); | ^^^^^^^ expected an `FnOnce<(&isize,)>` closure, found `for<'r> extern "C" fn(&'r isize) -> isize {square}` @@ -24,7 +24,7 @@ error[E0277]: expected a `std::ops::FnMut<(&isize,)>` closure, found `for<'r> ex --> $DIR/unboxed-closures-wrong-abi.rs:18:25 | LL | fn call_it_mut<F:FnMut(&isize)->isize>(_: &mut F, _: isize) -> isize { 0 } - | ----------- -------------------- required by this bound in `call_it_mut` + | -------------------- required by this bound in `call_it_mut` ... LL | let y = call_it_mut(&mut square, 22); | ^^^^^^^^^^^ expected an `FnMut<(&isize,)>` closure, found `for<'r> extern "C" fn(&'r isize) -> isize {square}` @@ -35,7 +35,7 @@ error[E0277]: expected a `std::ops::FnOnce<(&isize,)>` closure, found `for<'r> e --> $DIR/unboxed-closures-wrong-abi.rs:18:25 | LL | fn call_it_mut<F:FnMut(&isize)->isize>(_: &mut F, _: isize) -> isize { 0 } - | ----------- ----- required by this bound in `call_it_mut` + | ----- required by this bound in `call_it_mut` ... LL | let y = call_it_mut(&mut square, 22); | ^^^^^^^^^^^ expected an `FnOnce<(&isize,)>` closure, found `for<'r> extern "C" fn(&'r isize) -> isize {square}` @@ -46,7 +46,7 @@ error[E0277]: expected a `std::ops::FnOnce<(&isize,)>` closure, found `for<'r> e --> $DIR/unboxed-closures-wrong-abi.rs:24:26 | LL | fn call_it_once<F:FnOnce(&isize)->isize>(_: F, _: isize) -> isize { 0 } - | ------------ ----- required by this bound in `call_it_once` + | ----- required by this bound in `call_it_once` ... LL | let z = call_it_once(square, 22); | ^^^^^^ expected an `FnOnce<(&isize,)>` closure, found `for<'r> extern "C" fn(&'r isize) -> isize {square}` diff --git a/src/test/ui/unboxed-closures/unboxed-closures-wrong-arg-type-extern-fn.stderr b/src/test/ui/unboxed-closures/unboxed-closures-wrong-arg-type-extern-fn.stderr index 5b1d6eb5b68..434c8a579f6 100644 --- a/src/test/ui/unboxed-closures/unboxed-closures-wrong-arg-type-extern-fn.stderr +++ b/src/test/ui/unboxed-closures/unboxed-closures-wrong-arg-type-extern-fn.stderr @@ -2,7 +2,7 @@ error[E0277]: expected a `std::ops::Fn<(&isize,)>` closure, found `unsafe fn(isi --> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:13:21 | LL | fn call_it<F:Fn(&isize)->isize>(_: &F, _: isize) -> isize { 0 } - | ------- ----------------- required by this bound in `call_it` + | ----------------- required by this bound in `call_it` ... LL | let x = call_it(&square, 22); | ^^^^^^^ expected an `Fn<(&isize,)>` closure, found `unsafe fn(isize) -> isize {square}` @@ -13,7 +13,7 @@ error[E0277]: expected a `std::ops::FnOnce<(&isize,)>` closure, found `unsafe fn --> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:13:21 | LL | fn call_it<F:Fn(&isize)->isize>(_: &F, _: isize) -> isize { 0 } - | ------- ----- required by this bound in `call_it` + | ----- required by this bound in `call_it` ... LL | let x = call_it(&square, 22); | ^^^^^^^ expected an `FnOnce<(&isize,)>` closure, found `unsafe fn(isize) -> isize {square}` @@ -24,7 +24,7 @@ error[E0277]: expected a `std::ops::FnMut<(&isize,)>` closure, found `unsafe fn( --> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:19:25 | LL | fn call_it_mut<F:FnMut(&isize)->isize>(_: &mut F, _: isize) -> isize { 0 } - | ----------- -------------------- required by this bound in `call_it_mut` + | -------------------- required by this bound in `call_it_mut` ... LL | let y = call_it_mut(&mut square, 22); | ^^^^^^^^^^^ expected an `FnMut<(&isize,)>` closure, found `unsafe fn(isize) -> isize {square}` @@ -35,7 +35,7 @@ error[E0277]: expected a `std::ops::FnOnce<(&isize,)>` closure, found `unsafe fn --> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:19:25 | LL | fn call_it_mut<F:FnMut(&isize)->isize>(_: &mut F, _: isize) -> isize { 0 } - | ----------- ----- required by this bound in `call_it_mut` + | ----- required by this bound in `call_it_mut` ... LL | let y = call_it_mut(&mut square, 22); | ^^^^^^^^^^^ expected an `FnOnce<(&isize,)>` closure, found `unsafe fn(isize) -> isize {square}` @@ -46,7 +46,7 @@ error[E0277]: expected a `std::ops::FnOnce<(&isize,)>` closure, found `unsafe fn --> $DIR/unboxed-closures-wrong-arg-type-extern-fn.rs:25:26 | LL | fn call_it_once<F:FnOnce(&isize)->isize>(_: F, _: isize) -> isize { 0 } - | ------------ ----- required by this bound in `call_it_once` + | ----- required by this bound in `call_it_once` ... LL | let z = call_it_once(square, 22); | ^^^^^^ expected an `FnOnce<(&isize,)>` closure, found `unsafe fn(isize) -> isize {square}` diff --git a/src/test/ui/union/union-derive-clone.stderr b/src/test/ui/union/union-derive-clone.stderr index 66437611872..b536325810a 100644 --- a/src/test/ui/union/union-derive-clone.stderr +++ b/src/test/ui/union/union-derive-clone.stderr @@ -3,8 +3,12 @@ error[E0277]: the trait bound `U1: std::marker::Copy` is not satisfied | LL | #[derive(Clone)] | ^^^^^ the trait `std::marker::Copy` is not implemented for `U1` + | + ::: $SRC_DIR/libcore/clone.rs:LL:COL + | +LL | pub struct AssertParamIsCopy<T: Copy + ?Sized> { + | ---- required by this bound in `std::clone::AssertParamIsCopy` | - = note: required by `std::clone::AssertParamIsCopy` = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) error[E0599]: no method named `clone` found for union `U5<CloneNoCopy>` in the current scope diff --git a/src/test/ui/union/union-derive-eq.stderr b/src/test/ui/union/union-derive-eq.stderr index 0955c161871..ae0cd5af4b0 100644 --- a/src/test/ui/union/union-derive-eq.stderr +++ b/src/test/ui/union/union-derive-eq.stderr @@ -3,8 +3,12 @@ error[E0277]: the trait bound `PartialEqNotEq: std::cmp::Eq` is not satisfied | LL | a: PartialEqNotEq, | ^^^^^^^^^^^^^^^^^ the trait `std::cmp::Eq` is not implemented for `PartialEqNotEq` + | + ::: $SRC_DIR/libcore/cmp.rs:LL:COL + | +LL | pub struct AssertParamIsEq<T: Eq + ?Sized> { + | -- required by this bound in `std::cmp::AssertParamIsEq` | - = note: required by `std::cmp::AssertParamIsEq` = note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/unsized/unsized-bare-typaram.stderr b/src/test/ui/unsized/unsized-bare-typaram.stderr index 772de23e64c..3ff6f30db2a 100644 --- a/src/test/ui/unsized/unsized-bare-typaram.stderr +++ b/src/test/ui/unsized/unsized-bare-typaram.stderr @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim --> $DIR/unsized-bare-typaram.rs:2:29 | LL | fn bar<T: Sized>() { } - | --- - required by this bound in `bar` + | - required by this bound in `bar` LL | fn foo<T: ?Sized>() { bar::<T>() } | - ^ doesn't have a size known at compile-time | | diff --git a/src/test/ui/unsized/unsized-enum.stderr b/src/test/ui/unsized/unsized-enum.stderr index 88f7b1f77ae..f43d00f9739 100644 --- a/src/test/ui/unsized/unsized-enum.stderr +++ b/src/test/ui/unsized/unsized-enum.stderr @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim --> $DIR/unsized-enum.rs:6:36 | LL | enum Foo<U> { FooSome(U), FooNone } - | ----------- required by `Foo` + | - required by this bound in `Foo` LL | fn foo1<T>() { not_sized::<Foo<T>>() } // Hunky dory. LL | fn foo2<T: ?Sized>() { not_sized::<Foo<T>>() } | - ^^^^^^ doesn't have a size known at compile-time diff --git a/src/test/ui/unsized/unsized-inherent-impl-self-type.stderr b/src/test/ui/unsized/unsized-inherent-impl-self-type.stderr index 5688ae5b89a..808c9c583d4 100644 --- a/src/test/ui/unsized/unsized-inherent-impl-self-type.stderr +++ b/src/test/ui/unsized/unsized-inherent-impl-self-type.stderr @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim --> $DIR/unsized-inherent-impl-self-type.rs:7:17 | LL | struct S5<Y>(Y); - | ---------------- required by `S5` + | - required by this bound in `S5` LL | LL | impl<X: ?Sized> S5<X> { | - ^^^^^ doesn't have a size known at compile-time diff --git a/src/test/ui/unsized/unsized-struct.stderr b/src/test/ui/unsized/unsized-struct.stderr index 653fb5c1ae8..42fc5569ece 100644 --- a/src/test/ui/unsized/unsized-struct.stderr +++ b/src/test/ui/unsized/unsized-struct.stderr @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim --> $DIR/unsized-struct.rs:6:36 | LL | struct Foo<T> { data: T } - | ------------- required by `Foo` + | - required by this bound in `Foo` LL | fn foo1<T>() { not_sized::<Foo<T>>() } // Hunky dory. LL | fn foo2<T: ?Sized>() { not_sized::<Foo<T>>() } | - ^^^^^^ doesn't have a size known at compile-time @@ -16,7 +16,7 @@ error[E0277]: the size for values of type `T` cannot be known at compilation tim --> $DIR/unsized-struct.rs:13:24 | LL | fn is_sized<T:Sized>() { } - | -------- - required by this bound in `is_sized` + | - required by this bound in `is_sized` ... LL | fn bar2<T: ?Sized>() { is_sized::<Bar<T>>() } | - ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time diff --git a/src/test/ui/unsized/unsized-trait-impl-self-type.stderr b/src/test/ui/unsized/unsized-trait-impl-self-type.stderr index 3597073e7e6..c2b2fe40ce6 100644 --- a/src/test/ui/unsized/unsized-trait-impl-self-type.stderr +++ b/src/test/ui/unsized/unsized-trait-impl-self-type.stderr @@ -2,7 +2,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim --> $DIR/unsized-trait-impl-self-type.rs:10:17 | LL | struct S5<Y>(Y); - | ---------------- required by `S5` + | - required by this bound in `S5` LL | LL | impl<X: ?Sized> T3<X> for S5<X> { | - ^^^^^ doesn't have a size known at compile-time diff --git a/src/test/ui/unsized3.stderr b/src/test/ui/unsized3.stderr index 083c74ba1e0..cf8459609b6 100644 --- a/src/test/ui/unsized3.stderr +++ b/src/test/ui/unsized3.stderr @@ -7,7 +7,7 @@ LL | f2::<X>(x); | ^ doesn't have a size known at compile-time ... LL | fn f2<X>(x: &X) { - | -- - required by this bound in `f2` + | - required by this bound in `f2` | = help: the trait `std::marker::Sized` is not implemented for `X` = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> @@ -25,7 +25,7 @@ LL | f4::<X>(x); | ^ doesn't have a size known at compile-time ... LL | fn f4<X: T>(x: &X) { - | -- - required by this bound in `f4` + | - required by this bound in `f4` | = help: the trait `std::marker::Sized` is not implemented for `X` = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> @@ -38,7 +38,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim --> $DIR/unsized3.rs:33:8 | LL | fn f5<Y>(x: &Y) {} - | -- - required by this bound in `f5` + | - required by this bound in `f5` ... LL | fn f8<X: ?Sized>(x1: &S<X>, x2: &S<X>) { | - this type parameter needs to be `std::marker::Sized` @@ -80,7 +80,7 @@ error[E0277]: the size for values of type `X` cannot be known at compilation tim --> $DIR/unsized3.rs:45:8 | LL | fn f5<Y>(x: &Y) {} - | -- - required by this bound in `f5` + | - required by this bound in `f5` ... LL | fn f10<X: ?Sized>(x1: Box<S<X>>) { | - this type parameter needs to be `std::marker::Sized` diff --git a/src/test/ui/wf/wf-const-type.stderr b/src/test/ui/wf/wf-const-type.stderr index 531aadc25dd..1b7f8b6fca1 100644 --- a/src/test/ui/wf/wf-const-type.stderr +++ b/src/test/ui/wf/wf-const-type.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `NotCopy: std::marker::Copy` is not satisfied --> $DIR/wf-const-type.rs:10:12 | LL | struct IsCopy<T:Copy> { t: T } - | --------------------- required by `IsCopy` + | ---- required by this bound in `IsCopy` ... LL | const FOO: IsCopy<Option<NotCopy>> = IsCopy { t: None }; | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `NotCopy` diff --git a/src/test/ui/wf/wf-enum-bound.stderr b/src/test/ui/wf/wf-enum-bound.stderr index f70f67d414f..962a1b839a7 100644 --- a/src/test/ui/wf/wf-enum-bound.stderr +++ b/src/test/ui/wf/wf-enum-bound.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `U: std::marker::Copy` is not satisfied --> $DIR/wf-enum-bound.rs:10:14 | LL | trait ExtraCopy<T:Copy> { } - | ----------------------- required by `ExtraCopy` + | ---- required by this bound in `ExtraCopy` ... LL | where T: ExtraCopy<U> | ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `U` diff --git a/src/test/ui/wf/wf-enum-fields-struct-variant.stderr b/src/test/ui/wf/wf-enum-fields-struct-variant.stderr index 8634b7dba5c..0a3665fcf04 100644 --- a/src/test/ui/wf/wf-enum-fields-struct-variant.stderr +++ b/src/test/ui/wf/wf-enum-fields-struct-variant.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `A: std::marker::Copy` is not satisfied --> $DIR/wf-enum-fields-struct-variant.rs:13:9 | LL | struct IsCopy<T:Copy> { - | --------------------- required by `IsCopy` + | ---- required by this bound in `IsCopy` ... LL | f: IsCopy<A> | ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `A` diff --git a/src/test/ui/wf/wf-enum-fields.stderr b/src/test/ui/wf/wf-enum-fields.stderr index a22b2d11a91..a833eeacbdf 100644 --- a/src/test/ui/wf/wf-enum-fields.stderr +++ b/src/test/ui/wf/wf-enum-fields.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `A: std::marker::Copy` is not satisfied --> $DIR/wf-enum-fields.rs:12:17 | LL | struct IsCopy<T:Copy> { - | --------------------- required by `IsCopy` + | ---- required by this bound in `IsCopy` ... LL | SomeVariant(IsCopy<A>) | ^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `A` diff --git a/src/test/ui/wf/wf-fn-where-clause.rs b/src/test/ui/wf/wf-fn-where-clause.rs index 5fd567bd32d..adae536138b 100644 --- a/src/test/ui/wf/wf-fn-where-clause.rs +++ b/src/test/ui/wf/wf-fn-where-clause.rs @@ -13,5 +13,8 @@ fn bar() where Vec<dyn Copy>:, {} //~^ ERROR E0277 //~| ERROR E0038 +struct Vec<T> { + t: T, +} fn main() { } diff --git a/src/test/ui/wf/wf-fn-where-clause.stderr b/src/test/ui/wf/wf-fn-where-clause.stderr index cf1aeac7e3e..59a4f9bad9d 100644 --- a/src/test/ui/wf/wf-fn-where-clause.stderr +++ b/src/test/ui/wf/wf-fn-where-clause.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `U: std::marker::Copy` is not satisfied --> $DIR/wf-fn-where-clause.rs:8:24 | LL | trait ExtraCopy<T:Copy> { } - | ----------------------- required by `ExtraCopy` + | ---- required by this bound in `ExtraCopy` LL | LL | fn foo<T,U>() where T: ExtraCopy<U> | ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `U` @@ -17,10 +17,12 @@ error[E0277]: the size for values of type `(dyn std::marker::Copy + 'static)` ca | LL | fn bar() where Vec<dyn Copy>:, {} | ^^^^^^^^^^^^^ doesn't have a size known at compile-time +... +LL | struct Vec<T> { + | - required by this bound in `Vec` | = help: the trait `std::marker::Sized` is not implemented for `(dyn std::marker::Copy + 'static)` = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait> - = note: required by `std::vec::Vec` error[E0038]: the trait `std::marker::Copy` cannot be made into an object --> $DIR/wf-fn-where-clause.rs:12:16 diff --git a/src/test/ui/wf/wf-impl-associated-type-trait.stderr b/src/test/ui/wf/wf-impl-associated-type-trait.stderr index d44a6f01a47..89399e30cad 100644 --- a/src/test/ui/wf/wf-impl-associated-type-trait.stderr +++ b/src/test/ui/wf/wf-impl-associated-type-trait.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `T: MyHash` is not satisfied --> $DIR/wf-impl-associated-type-trait.rs:17:5 | LL | pub struct MySet<T:MyHash> { - | -------------------------- required by `MySet` + | ------ required by this bound in `MySet` ... LL | type Bar = MySet<T>; | ^^^^^^^^^^^^^^^^^^^^ the trait `MyHash` is not implemented for `T` diff --git a/src/test/ui/wf/wf-in-fn-arg.stderr b/src/test/ui/wf/wf-in-fn-arg.stderr index 907701440aa..84adf04a68a 100644 --- a/src/test/ui/wf/wf-in-fn-arg.stderr +++ b/src/test/ui/wf/wf-in-fn-arg.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/wf-in-fn-arg.rs:10:14 | LL | struct MustBeCopy<T:Copy> { - | ------------------------- required by `MustBeCopy` + | ---- required by this bound in `MustBeCopy` ... LL | fn bar<T>(_: &MustBeCopy<T>) | ^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` diff --git a/src/test/ui/wf/wf-in-fn-ret.stderr b/src/test/ui/wf/wf-in-fn-ret.stderr index 2ed4eecefe1..68ef734be55 100644 --- a/src/test/ui/wf/wf-in-fn-ret.stderr +++ b/src/test/ui/wf/wf-in-fn-ret.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/wf-in-fn-ret.rs:10:16 | LL | struct MustBeCopy<T:Copy> { - | ------------------------- required by `MustBeCopy` + | ---- required by this bound in `MustBeCopy` ... LL | fn bar<T>() -> MustBeCopy<T> | ^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` diff --git a/src/test/ui/wf/wf-in-fn-type-arg.stderr b/src/test/ui/wf/wf-in-fn-type-arg.stderr index 0c699838abd..c0bb3a50b1f 100644 --- a/src/test/ui/wf/wf-in-fn-type-arg.stderr +++ b/src/test/ui/wf/wf-in-fn-type-arg.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/wf-in-fn-type-arg.rs:9:5 | LL | struct MustBeCopy<T:Copy> { - | ------------------------- required by `MustBeCopy` + | ---- required by this bound in `MustBeCopy` ... LL | x: fn(MustBeCopy<T>) | ^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` diff --git a/src/test/ui/wf/wf-in-fn-type-ret.stderr b/src/test/ui/wf/wf-in-fn-type-ret.stderr index 3429ab89ffb..e2030582507 100644 --- a/src/test/ui/wf/wf-in-fn-type-ret.stderr +++ b/src/test/ui/wf/wf-in-fn-type-ret.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/wf-in-fn-type-ret.rs:9:5 | LL | struct MustBeCopy<T:Copy> { - | ------------------------- required by `MustBeCopy` + | ---- required by this bound in `MustBeCopy` ... LL | x: fn() -> MustBeCopy<T> | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` diff --git a/src/test/ui/wf/wf-in-fn-where-clause.stderr b/src/test/ui/wf/wf-in-fn-where-clause.stderr index d33749d795c..41cfb186310 100644 --- a/src/test/ui/wf/wf-in-fn-where-clause.stderr +++ b/src/test/ui/wf/wf-in-fn-where-clause.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `U: std::marker::Copy` is not satisfied --> $DIR/wf-in-fn-where-clause.rs:10:14 | LL | trait MustBeCopy<T:Copy> { - | ------------------------ required by `MustBeCopy` + | ---- required by this bound in `MustBeCopy` ... LL | where T: MustBeCopy<U> | ^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `U` diff --git a/src/test/ui/wf/wf-in-obj-type-trait.stderr b/src/test/ui/wf/wf-in-obj-type-trait.stderr index 605dc497849..6d85cdde7f9 100644 --- a/src/test/ui/wf/wf-in-obj-type-trait.stderr +++ b/src/test/ui/wf/wf-in-obj-type-trait.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/wf-in-obj-type-trait.rs:11:5 | LL | struct MustBeCopy<T:Copy> { - | ------------------------- required by `MustBeCopy` + | ---- required by this bound in `MustBeCopy` ... LL | x: dyn Object<MustBeCopy<T>> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` diff --git a/src/test/ui/wf/wf-inherent-impl-method-where-clause.stderr b/src/test/ui/wf/wf-inherent-impl-method-where-clause.stderr index da2f8085a8a..1a2a20ec684 100644 --- a/src/test/ui/wf/wf-inherent-impl-method-where-clause.stderr +++ b/src/test/ui/wf/wf-inherent-impl-method-where-clause.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `U: std::marker::Copy` is not satisfied --> $DIR/wf-inherent-impl-method-where-clause.rs:12:27 | LL | trait ExtraCopy<T:Copy> { } - | ----------------------- required by `ExtraCopy` + | ---- required by this bound in `ExtraCopy` ... LL | fn foo(self) where T: ExtraCopy<U> | ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `U` diff --git a/src/test/ui/wf/wf-inherent-impl-where-clause.stderr b/src/test/ui/wf/wf-inherent-impl-where-clause.stderr index 28d5bc62556..ba1d4a036c6 100644 --- a/src/test/ui/wf/wf-inherent-impl-where-clause.stderr +++ b/src/test/ui/wf/wf-inherent-impl-where-clause.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `U: std::marker::Copy` is not satisfied --> $DIR/wf-inherent-impl-where-clause.rs:11:29 | LL | trait ExtraCopy<T:Copy> { } - | ----------------------- required by `ExtraCopy` + | ---- required by this bound in `ExtraCopy` ... LL | impl<T,U> Foo<T,U> where T: ExtraCopy<U> | ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `U` diff --git a/src/test/ui/wf/wf-static-type.stderr b/src/test/ui/wf/wf-static-type.stderr index 05a628d7c3e..4e78090f998 100644 --- a/src/test/ui/wf/wf-static-type.stderr +++ b/src/test/ui/wf/wf-static-type.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `NotCopy: std::marker::Copy` is not satisfied --> $DIR/wf-static-type.rs:10:13 | LL | struct IsCopy<T:Copy> { t: T } - | --------------------- required by `IsCopy` + | ---- required by this bound in `IsCopy` ... LL | static FOO: IsCopy<Option<NotCopy>> = IsCopy { t: None }; | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `NotCopy` diff --git a/src/test/ui/wf/wf-struct-bound.stderr b/src/test/ui/wf/wf-struct-bound.stderr index 07e569ddac1..d9d193aa79d 100644 --- a/src/test/ui/wf/wf-struct-bound.stderr +++ b/src/test/ui/wf/wf-struct-bound.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `U: std::marker::Copy` is not satisfied --> $DIR/wf-struct-bound.rs:10:14 | LL | trait ExtraCopy<T:Copy> { } - | ----------------------- required by `ExtraCopy` + | ---- required by this bound in `ExtraCopy` ... LL | where T: ExtraCopy<U> | ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `U` diff --git a/src/test/ui/wf/wf-struct-field.stderr b/src/test/ui/wf/wf-struct-field.stderr index f3bce24eace..cda3b8fe4fd 100644 --- a/src/test/ui/wf/wf-struct-field.stderr +++ b/src/test/ui/wf/wf-struct-field.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `A: std::marker::Copy` is not satisfied --> $DIR/wf-struct-field.rs:12:5 | LL | struct IsCopy<T:Copy> { - | --------------------- required by `IsCopy` + | ---- required by this bound in `IsCopy` ... LL | data: IsCopy<A> | ^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `A` diff --git a/src/test/ui/wf/wf-trait-associated-type-bound.stderr b/src/test/ui/wf/wf-trait-associated-type-bound.stderr index 6cf7f2069b6..a4ceb41ffa5 100644 --- a/src/test/ui/wf/wf-trait-associated-type-bound.stderr +++ b/src/test/ui/wf/wf-trait-associated-type-bound.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/wf-trait-associated-type-bound.rs:10:17 | LL | trait ExtraCopy<T:Copy> { } - | ----------------------- required by `ExtraCopy` + | ---- required by this bound in `ExtraCopy` ... LL | type Type1: ExtraCopy<T>; | ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` diff --git a/src/test/ui/wf/wf-trait-associated-type-trait.stderr b/src/test/ui/wf/wf-trait-associated-type-trait.stderr index 93cb948cdbf..70cf88f262f 100644 --- a/src/test/ui/wf/wf-trait-associated-type-trait.stderr +++ b/src/test/ui/wf/wf-trait-associated-type-trait.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `<Self as SomeTrait>::Type1: std::marker::Copy` is --> $DIR/wf-trait-associated-type-trait.rs:11:5 | LL | struct IsCopy<T:Copy> { x: T } - | --------------------- required by `IsCopy` + | ---- required by this bound in `IsCopy` LL | LL | trait SomeTrait { | - help: consider further restricting the associated type: `where <Self as SomeTrait>::Type1: std::marker::Copy` diff --git a/src/test/ui/wf/wf-trait-bound.stderr b/src/test/ui/wf/wf-trait-bound.stderr index b8ffad6d180..384d668d800 100644 --- a/src/test/ui/wf/wf-trait-bound.stderr +++ b/src/test/ui/wf/wf-trait-bound.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `U: std::marker::Copy` is not satisfied --> $DIR/wf-trait-bound.rs:10:14 | LL | trait ExtraCopy<T:Copy> { } - | ----------------------- required by `ExtraCopy` + | ---- required by this bound in `ExtraCopy` ... LL | where T: ExtraCopy<U> | ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `U` diff --git a/src/test/ui/wf/wf-trait-default-fn-arg.stderr b/src/test/ui/wf/wf-trait-default-fn-arg.stderr index 6a97d31cf3e..ed563af5928 100644 --- a/src/test/ui/wf/wf-trait-default-fn-arg.stderr +++ b/src/test/ui/wf/wf-trait-default-fn-arg.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `Self: std::cmp::Eq` is not satisfied --> $DIR/wf-trait-default-fn-arg.rs:11:22 | LL | struct Bar<T:Eq+?Sized> { value: Box<T> } - | ----------------------- required by `Bar` + | -- required by this bound in `Bar` ... LL | fn bar(&self, x: &Bar<Self>) { | ^^^^^^^^^^ - help: consider further restricting `Self`: `where Self: std::cmp::Eq` diff --git a/src/test/ui/wf/wf-trait-default-fn-ret.stderr b/src/test/ui/wf/wf-trait-default-fn-ret.stderr index 36c1e486269..57cf1e9e6da 100644 --- a/src/test/ui/wf/wf-trait-default-fn-ret.stderr +++ b/src/test/ui/wf/wf-trait-default-fn-ret.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `Self: std::cmp::Eq` is not satisfied --> $DIR/wf-trait-default-fn-ret.rs:11:22 | LL | struct Bar<T:Eq+?Sized> { value: Box<T> } - | ----------------------- required by `Bar` + | -- required by this bound in `Bar` ... LL | fn bar(&self) -> Bar<Self> { | ^^^^^^^^^- help: consider further restricting `Self`: `where Self: std::cmp::Eq` diff --git a/src/test/ui/wf/wf-trait-default-fn-where-clause.stderr b/src/test/ui/wf/wf-trait-default-fn-where-clause.stderr index 6b63feaba89..534bf4d3448 100644 --- a/src/test/ui/wf/wf-trait-default-fn-where-clause.stderr +++ b/src/test/ui/wf/wf-trait-default-fn-where-clause.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `Self: std::cmp::Eq` is not satisfied --> $DIR/wf-trait-default-fn-where-clause.rs:11:31 | LL | trait Bar<T:Eq+?Sized> { } - | ---------------------- required by `Bar` + | -- required by this bound in `Bar` ... LL | fn bar<A>(&self) where A: Bar<Self> { | ^^^^^^^^^- help: consider further restricting `Self`: `, Self: std::cmp::Eq` diff --git a/src/test/ui/wf/wf-trait-fn-arg.stderr b/src/test/ui/wf/wf-trait-fn-arg.stderr index 69e2ab72912..494619a2f29 100644 --- a/src/test/ui/wf/wf-trait-fn-arg.stderr +++ b/src/test/ui/wf/wf-trait-fn-arg.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `Self: std::cmp::Eq` is not satisfied --> $DIR/wf-trait-fn-arg.rs:10:22 | LL | struct Bar<T:Eq+?Sized> { value: Box<T> } - | ----------------------- required by `Bar` + | -- required by this bound in `Bar` ... LL | fn bar(&self, x: &Bar<Self>); | ^^^^^^^^^^ - help: consider further restricting `Self`: `where Self: std::cmp::Eq` diff --git a/src/test/ui/wf/wf-trait-fn-ret.stderr b/src/test/ui/wf/wf-trait-fn-ret.stderr index bfc6265662e..6a3381d9a22 100644 --- a/src/test/ui/wf/wf-trait-fn-ret.stderr +++ b/src/test/ui/wf/wf-trait-fn-ret.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `Self: std::cmp::Eq` is not satisfied --> $DIR/wf-trait-fn-ret.rs:10:22 | LL | struct Bar<T:Eq+?Sized> { value: Box<T> } - | ----------------------- required by `Bar` + | -- required by this bound in `Bar` ... LL | fn bar(&self) -> &Bar<Self>; | ^^^^^^^^^^- help: consider further restricting `Self`: `where Self: std::cmp::Eq` diff --git a/src/test/ui/wf/wf-trait-fn-where-clause.stderr b/src/test/ui/wf/wf-trait-fn-where-clause.stderr index ec8f02c9c4f..2d6cf838f08 100644 --- a/src/test/ui/wf/wf-trait-fn-where-clause.stderr +++ b/src/test/ui/wf/wf-trait-fn-where-clause.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `Self: std::cmp::Eq` is not satisfied --> $DIR/wf-trait-fn-where-clause.rs:10:49 | LL | struct Bar<T:Eq+?Sized> { value: Box<T> } - | ----------------------- required by `Bar` + | -- required by this bound in `Bar` ... LL | fn bar(&self) where Self: Sized, Bar<Self>: Copy; | ^^^^- help: consider further restricting `Self`: `, Self: std::cmp::Eq` diff --git a/src/test/ui/wf/wf-trait-superbound.stderr b/src/test/ui/wf/wf-trait-superbound.stderr index 88b4bec0451..7d99b8f5a2a 100644 --- a/src/test/ui/wf/wf-trait-superbound.stderr +++ b/src/test/ui/wf/wf-trait-superbound.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/wf-trait-superbound.rs:9:21 | LL | trait ExtraCopy<T:Copy> { } - | ----------------------- required by `ExtraCopy` + | ---- required by this bound in `ExtraCopy` LL | LL | trait SomeTrait<T>: ExtraCopy<T> { | ^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `T` diff --git a/src/test/ui/where-clauses/where-clause-constraints-are-local-for-inherent-impl.stderr b/src/test/ui/where-clauses/where-clause-constraints-are-local-for-inherent-impl.stderr index fb1471e95bb..7e881074702 100644 --- a/src/test/ui/where-clauses/where-clause-constraints-are-local-for-inherent-impl.stderr +++ b/src/test/ui/where-clauses/where-clause-constraints-are-local-for-inherent-impl.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/where-clause-constraints-are-local-for-inherent-impl.rs:13:22 | LL | fn require_copy<T: Copy>(x: T) {} - | ------------ ---- required by this bound in `require_copy` + | ---- required by this bound in `require_copy` ... LL | require_copy(self.x); | ^^^^^^ the trait `std::marker::Copy` is not implemented for `T` diff --git a/src/test/ui/where-clauses/where-clause-constraints-are-local-for-trait-impl.stderr b/src/test/ui/where-clauses/where-clause-constraints-are-local-for-trait-impl.stderr index 6c1516d8ac9..3558d779d9d 100644 --- a/src/test/ui/where-clauses/where-clause-constraints-are-local-for-trait-impl.stderr +++ b/src/test/ui/where-clauses/where-clause-constraints-are-local-for-trait-impl.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `T: std::marker::Copy` is not satisfied --> $DIR/where-clause-constraints-are-local-for-trait-impl.rs:18:22 | LL | fn require_copy<T: Copy>(x: T) {} - | ------------ ---- required by this bound in `require_copy` + | ---- required by this bound in `require_copy` ... LL | require_copy(self.x); | ^^^^^^ the trait `std::marker::Copy` is not implemented for `T` diff --git a/src/test/ui/where-clauses/where-clauses-unsatisfied.stderr b/src/test/ui/where-clauses/where-clauses-unsatisfied.stderr index 1c859ac648c..e92a8fc83df 100644 --- a/src/test/ui/where-clauses/where-clauses-unsatisfied.stderr +++ b/src/test/ui/where-clauses/where-clauses-unsatisfied.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `Struct: std::cmp::Eq` is not satisfied --> $DIR/where-clauses-unsatisfied.rs:6:10 | LL | fn equal<T>(a: &T, b: &T) -> bool where T : Eq { a == b } - | ----- -- required by this bound in `equal` + | -- required by this bound in `equal` ... LL | drop(equal(&Struct, &Struct)) | ^^^^^ the trait `std::cmp::Eq` is not implemented for `Struct` |
