diff options
Diffstat (limited to 'tests')
205 files changed, 1787 insertions, 832 deletions
diff --git a/tests/codegen/debuginfo-inline-callsite-location.rs b/tests/codegen/debuginfo-inline-callsite-location.rs index b1475ee7931..d529f9ccead 100644 --- a/tests/codegen/debuginfo-inline-callsite-location.rs +++ b/tests/codegen/debuginfo-inline-callsite-location.rs @@ -4,9 +4,9 @@ // can correctly merge the debug info if it merges the inlined code (e.g., for merging of tail // calls to panic. -// CHECK: tail call void @_ZN4core9panicking5panic17h{{([0-9a-z]{16})}}E +// CHECK: tail call void @_ZN4core6option13unwrap_failed17h{{([0-9a-z]{16})}}E // CHECK-SAME: !dbg ![[#first_dbg:]] -// CHECK: tail call void @_ZN4core9panicking5panic17h{{([0-9a-z]{16})}}E +// CHECK: tail call void @_ZN4core6option13unwrap_failed17h{{([0-9a-z]{16})}}E // CHECK-SAME: !dbg ![[#second_dbg:]] // CHECK-DAG: ![[#func_dbg:]] = distinct !DISubprogram(name: "unwrap<i32>" diff --git a/tests/codegen/infallible-unwrap-in-opt-z.rs b/tests/codegen/infallible-unwrap-in-opt-z.rs new file mode 100644 index 00000000000..5c57b41532f --- /dev/null +++ b/tests/codegen/infallible-unwrap-in-opt-z.rs @@ -0,0 +1,26 @@ +// compile-flags: -C opt-level=z --edition=2021 +// ignore-debug + +#![crate_type = "lib"] + +// From <https://github.com/rust-lang/rust/issues/115463> + +// CHECK-LABEL: @read_up_to_8( +#[no_mangle] +pub fn read_up_to_8(buf: &[u8]) -> u64 { + // CHECK-NOT: unwrap_failed + if buf.len() < 4 { + // actual instance has more code. + return 0; + } + let lo = u32::from_le_bytes(buf[..4].try_into().unwrap()) as u64; + let hi = u32::from_le_bytes(buf[buf.len() - 4..][..4].try_into().unwrap()) as u64; + lo | (hi << 8 * (buf.len() as u64 - 4)) +} + +// CHECK-LABEL: @checking_unwrap_expectation( +#[no_mangle] +pub fn checking_unwrap_expectation(buf: &[u8]) -> &[u8; 4] { + // CHECK: call void @_ZN4core6result13unwrap_failed17h + buf.try_into().unwrap() +} diff --git a/tests/mir-opt/const_allocation.main.GVN.after.32bit.mir b/tests/mir-opt/const_allocation.main.GVN.after.32bit.mir index f089c6741fe..10d99a13463 100644 --- a/tests/mir-opt/const_allocation.main.GVN.after.32bit.mir +++ b/tests/mir-opt/const_allocation.main.GVN.after.32bit.mir @@ -7,10 +7,10 @@ fn main() -> () { bb0: { StorageLive(_1); - nop; + StorageLive(_2); _2 = const {ALLOC9: &&[(Option<i32>, &[&str])]}; _1 = (*_2); - nop; + StorageDead(_2); StorageDead(_1); _0 = const (); return; diff --git a/tests/mir-opt/const_allocation.main.GVN.after.64bit.mir b/tests/mir-opt/const_allocation.main.GVN.after.64bit.mir index 9cbbaf302be..2f23dbe9ee4 100644 --- a/tests/mir-opt/const_allocation.main.GVN.after.64bit.mir +++ b/tests/mir-opt/const_allocation.main.GVN.after.64bit.mir @@ -7,10 +7,10 @@ fn main() -> () { bb0: { StorageLive(_1); - nop; + StorageLive(_2); _2 = const {ALLOC9: &&[(Option<i32>, &[&str])]}; _1 = (*_2); - nop; + StorageDead(_2); StorageDead(_1); _0 = const (); return; diff --git a/tests/mir-opt/const_allocation2.main.GVN.after.32bit.mir b/tests/mir-opt/const_allocation2.main.GVN.after.32bit.mir index dfa2d808128..6499e3676aa 100644 --- a/tests/mir-opt/const_allocation2.main.GVN.after.32bit.mir +++ b/tests/mir-opt/const_allocation2.main.GVN.after.32bit.mir @@ -7,10 +7,10 @@ fn main() -> () { bb0: { StorageLive(_1); - nop; + StorageLive(_2); _2 = const {ALLOC9: &&[(Option<i32>, &[&u8])]}; _1 = (*_2); - nop; + StorageDead(_2); StorageDead(_1); _0 = const (); return; diff --git a/tests/mir-opt/const_allocation2.main.GVN.after.64bit.mir b/tests/mir-opt/const_allocation2.main.GVN.after.64bit.mir index 02b66987169..02f5ebab847 100644 --- a/tests/mir-opt/const_allocation2.main.GVN.after.64bit.mir +++ b/tests/mir-opt/const_allocation2.main.GVN.after.64bit.mir @@ -7,10 +7,10 @@ fn main() -> () { bb0: { StorageLive(_1); - nop; + StorageLive(_2); _2 = const {ALLOC9: &&[(Option<i32>, &[&u8])]}; _1 = (*_2); - nop; + StorageDead(_2); StorageDead(_1); _0 = const (); return; diff --git a/tests/mir-opt/const_allocation3.main.GVN.after.32bit.mir b/tests/mir-opt/const_allocation3.main.GVN.after.32bit.mir index 386a55ee6fa..c95e696946a 100644 --- a/tests/mir-opt/const_allocation3.main.GVN.after.32bit.mir +++ b/tests/mir-opt/const_allocation3.main.GVN.after.32bit.mir @@ -7,10 +7,10 @@ fn main() -> () { bb0: { StorageLive(_1); - nop; + StorageLive(_2); _2 = const {ALLOC4: &&Packed}; _1 = (*_2); - nop; + StorageDead(_2); StorageDead(_1); _0 = const (); return; diff --git a/tests/mir-opt/const_allocation3.main.GVN.after.64bit.mir b/tests/mir-opt/const_allocation3.main.GVN.after.64bit.mir index b9e98f8cd4c..198bc8bd07e 100644 --- a/tests/mir-opt/const_allocation3.main.GVN.after.64bit.mir +++ b/tests/mir-opt/const_allocation3.main.GVN.after.64bit.mir @@ -7,10 +7,10 @@ fn main() -> () { bb0: { StorageLive(_1); - nop; + StorageLive(_2); _2 = const {ALLOC2: &&Packed}; _1 = (*_2); - nop; + StorageDead(_2); StorageDead(_1); _0 = const (); return; diff --git a/tests/mir-opt/const_prop/address_of_pair.fn0.GVN.diff b/tests/mir-opt/const_prop/address_of_pair.fn0.GVN.diff index 2285962fad1..a044cfc62e2 100644 --- a/tests/mir-opt/const_prop/address_of_pair.fn0.GVN.diff +++ b/tests/mir-opt/const_prop/address_of_pair.fn0.GVN.diff @@ -24,9 +24,8 @@ bb0: { StorageLive(_2); - _2 = (const 1_i32, const false); -- StorageLive(_3); + _2 = const (1_i32, false); -+ nop; + StorageLive(_3); _3 = &raw mut (_2.1: bool); - _2 = (const 1_i32, const false); + _2 = const (1_i32, false); @@ -42,9 +41,8 @@ StorageDead(_6); _0 = _5; - StorageDead(_5); -- StorageDead(_3); -+ nop; + nop; + StorageDead(_3); StorageDead(_2); return; } diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.32bit.panic-abort.diff index a42f9291324..e1a93e31446 100644 --- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.32bit.panic-abort.diff @@ -22,18 +22,15 @@ } bb0: { -- StorageLive(_1); -+ nop; + StorageLive(_1); StorageLive(_2); -- StorageLive(_3); -+ nop; + StorageLive(_3); _9 = const _; _3 = &(*_9); _2 = &raw const (*_3); _1 = move _2 as *const [i32] (PointerCoercion(Unsize)); StorageDead(_2); -- StorageDead(_3); -+ nop; + StorageDead(_3); StorageLive(_5); StorageLive(_6); _6 = const 3_usize; @@ -50,8 +47,7 @@ StorageDead(_6); _0 = const (); StorageDead(_5); -- StorageDead(_1); -+ nop; + StorageDead(_1); return; } } diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.32bit.panic-unwind.diff index f2d6de6621b..91999145efb 100644 --- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.32bit.panic-unwind.diff @@ -22,18 +22,15 @@ } bb0: { -- StorageLive(_1); -+ nop; + StorageLive(_1); StorageLive(_2); -- StorageLive(_3); -+ nop; + StorageLive(_3); _9 = const _; _3 = &(*_9); _2 = &raw const (*_3); _1 = move _2 as *const [i32] (PointerCoercion(Unsize)); StorageDead(_2); -- StorageDead(_3); -+ nop; + StorageDead(_3); StorageLive(_5); StorageLive(_6); _6 = const 3_usize; @@ -50,8 +47,7 @@ StorageDead(_6); _0 = const (); StorageDead(_5); -- StorageDead(_1); -+ nop; + StorageDead(_1); return; } } diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.64bit.panic-abort.diff index a42f9291324..e1a93e31446 100644 --- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.64bit.panic-abort.diff @@ -22,18 +22,15 @@ } bb0: { -- StorageLive(_1); -+ nop; + StorageLive(_1); StorageLive(_2); -- StorageLive(_3); -+ nop; + StorageLive(_3); _9 = const _; _3 = &(*_9); _2 = &raw const (*_3); _1 = move _2 as *const [i32] (PointerCoercion(Unsize)); StorageDead(_2); -- StorageDead(_3); -+ nop; + StorageDead(_3); StorageLive(_5); StorageLive(_6); _6 = const 3_usize; @@ -50,8 +47,7 @@ StorageDead(_6); _0 = const (); StorageDead(_5); -- StorageDead(_1); -+ nop; + StorageDead(_1); return; } } diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.64bit.panic-unwind.diff index f2d6de6621b..91999145efb 100644 --- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.64bit.panic-unwind.diff @@ -22,18 +22,15 @@ } bb0: { -- StorageLive(_1); -+ nop; + StorageLive(_1); StorageLive(_2); -- StorageLive(_3); -+ nop; + StorageLive(_3); _9 = const _; _3 = &(*_9); _2 = &raw const (*_3); _1 = move _2 as *const [i32] (PointerCoercion(Unsize)); StorageDead(_2); -- StorageDead(_3); -+ nop; + StorageDead(_3); StorageLive(_5); StorageLive(_6); _6 = const 3_usize; @@ -50,8 +47,7 @@ StorageDead(_6); _0 = const (); StorageDead(_5); -- StorageDead(_1); -+ nop; + StorageDead(_1); return; } } diff --git a/tests/mir-opt/const_prop/indirect_mutation.bar.GVN.diff b/tests/mir-opt/const_prop/indirect_mutation.bar.GVN.diff index 7dd80d64360..b389080c497 100644 --- a/tests/mir-opt/const_prop/indirect_mutation.bar.GVN.diff +++ b/tests/mir-opt/const_prop/indirect_mutation.bar.GVN.diff @@ -22,12 +22,10 @@ - _1 = (const 1_i32,); + _1 = const (1_i32,); StorageLive(_2); -- StorageLive(_3); -+ nop; + StorageLive(_3); _3 = &raw mut (_1.0: i32); (*_3) = const 5_i32; -- StorageDead(_3); -+ nop; + StorageDead(_3); _2 = const (); StorageDead(_2); StorageLive(_4); diff --git a/tests/mir-opt/const_prop/indirect_mutation.foo.GVN.diff b/tests/mir-opt/const_prop/indirect_mutation.foo.GVN.diff index c4b647d9d2d..c21869dece6 100644 --- a/tests/mir-opt/const_prop/indirect_mutation.foo.GVN.diff +++ b/tests/mir-opt/const_prop/indirect_mutation.foo.GVN.diff @@ -17,13 +17,11 @@ bb0: { StorageLive(_1); - _1 = (const 1_i32,); -- StorageLive(_2); + _1 = const (1_i32,); -+ nop; + StorageLive(_2); _2 = &mut (_1.0: i32); (*_2) = const 5_i32; -- StorageDead(_2); -+ nop; + StorageDead(_2); StorageLive(_3); StorageLive(_4); _4 = (_1.0: i32); diff --git a/tests/mir-opt/const_prop/issue_67019.main.GVN.panic-abort.diff b/tests/mir-opt/const_prop/issue_67019.main.GVN.panic-abort.diff index fc0c8afd4cf..dfab4959516 100644 --- a/tests/mir-opt/const_prop/issue_67019.main.GVN.panic-abort.diff +++ b/tests/mir-opt/const_prop/issue_67019.main.GVN.panic-abort.diff @@ -34,9 +34,5 @@ + + ALLOC1 (size: 2, align: 1) { + 01 02 │ .. -+ } -+ -+ ALLOC2 (size: 2, align: 1) { -+ 01 02 │ .. } diff --git a/tests/mir-opt/const_prop/issue_67019.main.GVN.panic-unwind.diff b/tests/mir-opt/const_prop/issue_67019.main.GVN.panic-unwind.diff index cf4089598e7..b6d69732316 100644 --- a/tests/mir-opt/const_prop/issue_67019.main.GVN.panic-unwind.diff +++ b/tests/mir-opt/const_prop/issue_67019.main.GVN.panic-unwind.diff @@ -34,9 +34,5 @@ + + ALLOC1 (size: 2, align: 1) { + 01 02 │ .. -+ } -+ -+ ALLOC2 (size: 2, align: 1) { -+ 01 02 │ .. } diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.GVN.diff b/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.GVN.diff index bc60546cd19..4ed7c985147 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.GVN.diff +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.GVN.diff @@ -19,17 +19,15 @@ bb0: { StorageLive(_1); - _1 = (const 42_i32, const 43_i32); -- StorageLive(_2); + _1 = const (42_i32, 43_i32); -+ nop; + StorageLive(_2); _2 = &mut _1; ((*_2).1: i32) = const 99_i32; StorageLive(_3); _3 = _1; _0 = const (); StorageDead(_3); -- StorageDead(_2); -+ nop; + StorageDead(_2); StorageDead(_1); return; } diff --git a/tests/mir-opt/const_prop/mutable_variable_no_prop.main.GVN.diff b/tests/mir-opt/const_prop/mutable_variable_no_prop.main.GVN.diff index d02c392f6bd..e113f43a56e 100644 --- a/tests/mir-opt/const_prop/mutable_variable_no_prop.main.GVN.diff +++ b/tests/mir-opt/const_prop/mutable_variable_no_prop.main.GVN.diff @@ -22,14 +22,12 @@ _1 = const 42_u32; StorageLive(_2); StorageLive(_3); -- StorageLive(_4); -+ nop; + StorageLive(_4); _4 = const {ALLOC0: *mut u32}; _3 = (*_4); _1 = move _3; StorageDead(_3); -- StorageDead(_4); -+ nop; + StorageDead(_4); _2 = const (); StorageDead(_2); StorageLive(_5); diff --git a/tests/mir-opt/const_prop/pointer_expose_address.main.GVN.panic-abort.diff b/tests/mir-opt/const_prop/pointer_expose_address.main.GVN.panic-abort.diff index 425bc3ff6c1..4e79b3ad599 100644 --- a/tests/mir-opt/const_prop/pointer_expose_address.main.GVN.panic-abort.diff +++ b/tests/mir-opt/const_prop/pointer_expose_address.main.GVN.panic-abort.diff @@ -16,14 +16,12 @@ - StorageLive(_1); + nop; StorageLive(_2); -- StorageLive(_3); -+ nop; + StorageLive(_3); _3 = const _; _2 = &raw const (*_3); _1 = move _2 as usize (PointerExposeAddress); StorageDead(_2); -- StorageDead(_3); -+ nop; + StorageDead(_3); StorageLive(_4); StorageLive(_5); _5 = _1; diff --git a/tests/mir-opt/const_prop/pointer_expose_address.main.GVN.panic-unwind.diff b/tests/mir-opt/const_prop/pointer_expose_address.main.GVN.panic-unwind.diff index e9360ab8d62..fdc459b457c 100644 --- a/tests/mir-opt/const_prop/pointer_expose_address.main.GVN.panic-unwind.diff +++ b/tests/mir-opt/const_prop/pointer_expose_address.main.GVN.panic-unwind.diff @@ -16,14 +16,12 @@ - StorageLive(_1); + nop; StorageLive(_2); -- StorageLive(_3); -+ nop; + StorageLive(_3); _3 = const _; _2 = &raw const (*_3); _1 = move _2 as usize (PointerExposeAddress); StorageDead(_2); -- StorageDead(_3); -+ nop; + StorageDead(_3); StorageLive(_4); StorageLive(_5); _5 = _1; diff --git a/tests/mir-opt/const_prop/ref_deref.main.GVN.diff b/tests/mir-opt/const_prop/ref_deref.main.GVN.diff index 8f9aa20524d..56cbd00025e 100644 --- a/tests/mir-opt/const_prop/ref_deref.main.GVN.diff +++ b/tests/mir-opt/const_prop/ref_deref.main.GVN.diff @@ -13,14 +13,12 @@ bb0: { StorageLive(_1); -- StorageLive(_2); -+ nop; + StorageLive(_2); _4 = const _; _2 = &(*_4); - _1 = (*_2); -- StorageDead(_2); + _1 = const 4_i32; -+ nop; + StorageDead(_2); _0 = const (); StorageDead(_1); return; diff --git a/tests/mir-opt/const_prop/ref_deref_project.main.GVN.diff b/tests/mir-opt/const_prop/ref_deref_project.main.GVN.diff index 8d38888b7d6..d75c0c3b286 100644 --- a/tests/mir-opt/const_prop/ref_deref_project.main.GVN.diff +++ b/tests/mir-opt/const_prop/ref_deref_project.main.GVN.diff @@ -13,14 +13,12 @@ bb0: { StorageLive(_1); -- StorageLive(_2); -+ nop; + StorageLive(_2); _4 = const _; _2 = &((*_4).1: i32); - _1 = (*_2); -- StorageDead(_2); + _1 = const 5_i32; -+ nop; + StorageDead(_2); _0 = const (); StorageDead(_1); return; diff --git a/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-abort.diff index 8b2411e50ab..803be994d9a 100644 --- a/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-abort.diff @@ -18,8 +18,7 @@ bb0: { StorageLive(_1); -- StorageLive(_2); -+ nop; + StorageLive(_2); StorageLive(_3); StorageLive(_4); _9 = const _; @@ -44,8 +43,7 @@ + _1 = (*_2)[1 of 2]; StorageDead(_6); StorageDead(_4); -- StorageDead(_2); -+ nop; + StorageDead(_2); _0 = const (); StorageDead(_1); return; diff --git a/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-unwind.diff index 9b20d243f87..2a20e3eca59 100644 --- a/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-unwind.diff @@ -18,8 +18,7 @@ bb0: { StorageLive(_1); -- StorageLive(_2); -+ nop; + StorageLive(_2); StorageLive(_3); StorageLive(_4); _9 = const _; @@ -44,8 +43,7 @@ + _1 = (*_2)[1 of 2]; StorageDead(_6); StorageDead(_4); -- StorageDead(_2); -+ nop; + StorageDead(_2); _0 = const (); StorageDead(_1); return; diff --git a/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-abort.diff index 8b2411e50ab..803be994d9a 100644 --- a/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-abort.diff @@ -18,8 +18,7 @@ bb0: { StorageLive(_1); -- StorageLive(_2); -+ nop; + StorageLive(_2); StorageLive(_3); StorageLive(_4); _9 = const _; @@ -44,8 +43,7 @@ + _1 = (*_2)[1 of 2]; StorageDead(_6); StorageDead(_4); -- StorageDead(_2); -+ nop; + StorageDead(_2); _0 = const (); StorageDead(_1); return; diff --git a/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-unwind.diff index 9b20d243f87..2a20e3eca59 100644 --- a/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-unwind.diff @@ -18,8 +18,7 @@ bb0: { StorageLive(_1); -- StorageLive(_2); -+ nop; + StorageLive(_2); StorageLive(_3); StorageLive(_4); _9 = const _; @@ -44,8 +43,7 @@ + _1 = (*_2)[1 of 2]; StorageDead(_6); StorageDead(_4); -- StorageDead(_2); -+ nop; + StorageDead(_2); _0 = const (); StorageDead(_1); return; diff --git a/tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.32bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.32bit.diff index 93dfef96cf1..0ff31b1a981 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.32bit.diff @@ -13,13 +13,12 @@ bb0: { StorageLive(_1); -- StorageLive(_2); + StorageLive(_2); - _2 = const 1_usize as &mut Never (Transmute); -+ nop; +- _1 = &mut (*_2); + _2 = const {0x1 as &mut Never}; - _1 = &mut (*_2); -- StorageDead(_2); -+ nop; ++ _1 = const {0x1 as &mut Never}; + StorageDead(_2); unreachable; } } diff --git a/tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.64bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.64bit.diff index 93dfef96cf1..0ff31b1a981 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.64bit.diff @@ -13,13 +13,12 @@ bb0: { StorageLive(_1); -- StorageLive(_2); + StorageLive(_2); - _2 = const 1_usize as &mut Never (Transmute); -+ nop; +- _1 = &mut (*_2); + _2 = const {0x1 as &mut Never}; - _1 = &mut (*_2); -- StorageDead(_2); -+ nop; ++ _1 = const {0x1 as &mut Never}; + StorageDead(_2); unreachable; } } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff index 6925fdb1e70..ffbd97bb545 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff @@ -25,20 +25,21 @@ scope 11 (inlined NonNull::<[bool; 0]>::new_unchecked) { debug ptr => _6; let mut _8: *const [bool; 0]; + let mut _9: *mut [bool; 0]; scope 12 { scope 13 (inlined NonNull::<T>::new_unchecked::runtime::<[bool; 0]>) { - debug ptr => _6; + debug ptr => _9; scope 14 (inlined std::ptr::mut_ptr::<impl *mut [bool; 0]>::is_null) { - debug self => _6; - let mut _9: *mut u8; + debug self => _9; + let mut _10: *mut u8; scope 15 { scope 16 (inlined std::ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) { - debug ptr => _9; + debug ptr => _10; scope 17 (inlined std::ptr::mut_ptr::<impl *mut u8>::addr) { - debug self => _9; + debug self => _10; scope 18 { scope 19 (inlined std::ptr::mut_ptr::<impl *mut u8>::cast::<()>) { - debug self => _9; + debug self => _10; } } } @@ -74,8 +75,10 @@ StorageDead(_7); StorageLive(_8); StorageLive(_9); + StorageLive(_10); _8 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); _5 = NonNull::<[bool; 0]> { pointer: _8 }; + StorageDead(_10); StorageDead(_9); StorageDead(_8); StorageDead(_6); diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff index 82ad842505c..7b6dcf1972b 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff @@ -25,20 +25,21 @@ scope 11 (inlined NonNull::<[bool; 0]>::new_unchecked) { debug ptr => _6; let mut _8: *const [bool; 0]; + let mut _9: *mut [bool; 0]; scope 12 { scope 13 (inlined NonNull::<T>::new_unchecked::runtime::<[bool; 0]>) { - debug ptr => _6; + debug ptr => _9; scope 14 (inlined std::ptr::mut_ptr::<impl *mut [bool; 0]>::is_null) { - debug self => _6; - let mut _9: *mut u8; + debug self => _9; + let mut _10: *mut u8; scope 15 { scope 16 (inlined std::ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) { - debug ptr => _9; + debug ptr => _10; scope 17 (inlined std::ptr::mut_ptr::<impl *mut u8>::addr) { - debug self => _9; + debug self => _10; scope 18 { scope 19 (inlined std::ptr::mut_ptr::<impl *mut u8>::cast::<()>) { - debug self => _9; + debug self => _10; } } } @@ -74,8 +75,10 @@ StorageDead(_7); StorageLive(_8); StorageLive(_9); + StorageLive(_10); _8 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); _5 = NonNull::<[bool; 0]> { pointer: _8 }; + StorageDead(_10); StorageDead(_9); StorageDead(_8); StorageDead(_6); diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff index 6925fdb1e70..ffbd97bb545 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff @@ -25,20 +25,21 @@ scope 11 (inlined NonNull::<[bool; 0]>::new_unchecked) { debug ptr => _6; let mut _8: *const [bool; 0]; + let mut _9: *mut [bool; 0]; scope 12 { scope 13 (inlined NonNull::<T>::new_unchecked::runtime::<[bool; 0]>) { - debug ptr => _6; + debug ptr => _9; scope 14 (inlined std::ptr::mut_ptr::<impl *mut [bool; 0]>::is_null) { - debug self => _6; - let mut _9: *mut u8; + debug self => _9; + let mut _10: *mut u8; scope 15 { scope 16 (inlined std::ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) { - debug ptr => _9; + debug ptr => _10; scope 17 (inlined std::ptr::mut_ptr::<impl *mut u8>::addr) { - debug self => _9; + debug self => _10; scope 18 { scope 19 (inlined std::ptr::mut_ptr::<impl *mut u8>::cast::<()>) { - debug self => _9; + debug self => _10; } } } @@ -74,8 +75,10 @@ StorageDead(_7); StorageLive(_8); StorageLive(_9); + StorageLive(_10); _8 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); _5 = NonNull::<[bool; 0]> { pointer: _8 }; + StorageDead(_10); StorageDead(_9); StorageDead(_8); StorageDead(_6); diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff index 82ad842505c..7b6dcf1972b 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff @@ -25,20 +25,21 @@ scope 11 (inlined NonNull::<[bool; 0]>::new_unchecked) { debug ptr => _6; let mut _8: *const [bool; 0]; + let mut _9: *mut [bool; 0]; scope 12 { scope 13 (inlined NonNull::<T>::new_unchecked::runtime::<[bool; 0]>) { - debug ptr => _6; + debug ptr => _9; scope 14 (inlined std::ptr::mut_ptr::<impl *mut [bool; 0]>::is_null) { - debug self => _6; - let mut _9: *mut u8; + debug self => _9; + let mut _10: *mut u8; scope 15 { scope 16 (inlined std::ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) { - debug ptr => _9; + debug ptr => _10; scope 17 (inlined std::ptr::mut_ptr::<impl *mut u8>::addr) { - debug self => _9; + debug self => _10; scope 18 { scope 19 (inlined std::ptr::mut_ptr::<impl *mut u8>::cast::<()>) { - debug self => _9; + debug self => _10; } } } @@ -74,8 +75,10 @@ StorageDead(_7); StorageLive(_8); StorageLive(_9); + StorageLive(_10); _8 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); _5 = NonNull::<[bool; 0]> { pointer: _8 }; + StorageDead(_10); StorageDead(_9); StorageDead(_8); StorageDead(_6); diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff index 13545aa464a..df68ce496fd 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff @@ -25,20 +25,21 @@ scope 11 (inlined NonNull::<[bool; 0]>::new_unchecked) { debug ptr => _6; let mut _8: *const [bool; 0]; + let mut _9: *mut [bool; 0]; scope 12 { scope 13 (inlined NonNull::<T>::new_unchecked::runtime::<[bool; 0]>) { - debug ptr => _6; + debug ptr => _9; scope 14 (inlined std::ptr::mut_ptr::<impl *mut [bool; 0]>::is_null) { - debug self => _6; - let mut _9: *mut u8; + debug self => _9; + let mut _10: *mut u8; scope 15 { scope 16 (inlined std::ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) { - debug ptr => _9; + debug ptr => _10; scope 17 (inlined std::ptr::mut_ptr::<impl *mut u8>::addr) { - debug self => _9; + debug self => _10; scope 18 { scope 19 (inlined std::ptr::mut_ptr::<impl *mut u8>::cast::<()>) { - debug self => _9; + debug self => _10; } } } @@ -76,9 +77,11 @@ StorageDead(_7); StorageLive(_8); StorageLive(_9); + StorageLive(_10); - _8 = _6 as *const [bool; 0] (PointerCoercion(MutToConstPointer)); + _8 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); _5 = NonNull::<[bool; 0]> { pointer: _8 }; + StorageDead(_10); StorageDead(_9); StorageDead(_8); StorageDead(_6); diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff index bf326915381..e16ea22091e 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff @@ -25,20 +25,21 @@ scope 11 (inlined NonNull::<[bool; 0]>::new_unchecked) { debug ptr => _6; let mut _8: *const [bool; 0]; + let mut _9: *mut [bool; 0]; scope 12 { scope 13 (inlined NonNull::<T>::new_unchecked::runtime::<[bool; 0]>) { - debug ptr => _6; + debug ptr => _9; scope 14 (inlined std::ptr::mut_ptr::<impl *mut [bool; 0]>::is_null) { - debug self => _6; - let mut _9: *mut u8; + debug self => _9; + let mut _10: *mut u8; scope 15 { scope 16 (inlined std::ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) { - debug ptr => _9; + debug ptr => _10; scope 17 (inlined std::ptr::mut_ptr::<impl *mut u8>::addr) { - debug self => _9; + debug self => _10; scope 18 { scope 19 (inlined std::ptr::mut_ptr::<impl *mut u8>::cast::<()>) { - debug self => _9; + debug self => _10; } } } @@ -76,9 +77,11 @@ StorageDead(_7); StorageLive(_8); StorageLive(_9); + StorageLive(_10); - _8 = _6 as *const [bool; 0] (PointerCoercion(MutToConstPointer)); + _8 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); _5 = NonNull::<[bool; 0]> { pointer: _8 }; + StorageDead(_10); StorageDead(_9); StorageDead(_8); StorageDead(_6); diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff index 13545aa464a..df68ce496fd 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff @@ -25,20 +25,21 @@ scope 11 (inlined NonNull::<[bool; 0]>::new_unchecked) { debug ptr => _6; let mut _8: *const [bool; 0]; + let mut _9: *mut [bool; 0]; scope 12 { scope 13 (inlined NonNull::<T>::new_unchecked::runtime::<[bool; 0]>) { - debug ptr => _6; + debug ptr => _9; scope 14 (inlined std::ptr::mut_ptr::<impl *mut [bool; 0]>::is_null) { - debug self => _6; - let mut _9: *mut u8; + debug self => _9; + let mut _10: *mut u8; scope 15 { scope 16 (inlined std::ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) { - debug ptr => _9; + debug ptr => _10; scope 17 (inlined std::ptr::mut_ptr::<impl *mut u8>::addr) { - debug self => _9; + debug self => _10; scope 18 { scope 19 (inlined std::ptr::mut_ptr::<impl *mut u8>::cast::<()>) { - debug self => _9; + debug self => _10; } } } @@ -76,9 +77,11 @@ StorageDead(_7); StorageLive(_8); StorageLive(_9); + StorageLive(_10); - _8 = _6 as *const [bool; 0] (PointerCoercion(MutToConstPointer)); + _8 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); _5 = NonNull::<[bool; 0]> { pointer: _8 }; + StorageDead(_10); StorageDead(_9); StorageDead(_8); StorageDead(_6); diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff index bf326915381..e16ea22091e 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff @@ -25,20 +25,21 @@ scope 11 (inlined NonNull::<[bool; 0]>::new_unchecked) { debug ptr => _6; let mut _8: *const [bool; 0]; + let mut _9: *mut [bool; 0]; scope 12 { scope 13 (inlined NonNull::<T>::new_unchecked::runtime::<[bool; 0]>) { - debug ptr => _6; + debug ptr => _9; scope 14 (inlined std::ptr::mut_ptr::<impl *mut [bool; 0]>::is_null) { - debug self => _6; - let mut _9: *mut u8; + debug self => _9; + let mut _10: *mut u8; scope 15 { scope 16 (inlined std::ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) { - debug ptr => _9; + debug ptr => _10; scope 17 (inlined std::ptr::mut_ptr::<impl *mut u8>::addr) { - debug self => _9; + debug self => _10; scope 18 { scope 19 (inlined std::ptr::mut_ptr::<impl *mut u8>::cast::<()>) { - debug self => _9; + debug self => _10; } } } @@ -76,9 +77,11 @@ StorageDead(_7); StorageLive(_8); StorageLive(_9); + StorageLive(_10); - _8 = _6 as *const [bool; 0] (PointerCoercion(MutToConstPointer)); + _8 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); _5 = NonNull::<[bool; 0]> { pointer: _8 }; + StorageDead(_10); StorageDead(_9); StorageDead(_8); StorageDead(_6); diff --git a/tests/mir-opt/dead-store-elimination/call_arg_copy.move_packed.DeadStoreElimination.panic-abort.diff b/tests/mir-opt/dead-store-elimination/call_arg_copy.move_packed.DeadStoreElimination-final.panic-abort.diff index dc0f9073416..07fb8301b9a 100644 --- a/tests/mir-opt/dead-store-elimination/call_arg_copy.move_packed.DeadStoreElimination.panic-abort.diff +++ b/tests/mir-opt/dead-store-elimination/call_arg_copy.move_packed.DeadStoreElimination-final.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `move_packed` before DeadStoreElimination -+ // MIR for `move_packed` after DeadStoreElimination +- // MIR for `move_packed` before DeadStoreElimination-final ++ // MIR for `move_packed` after DeadStoreElimination-final fn move_packed(_1: Packed) -> () { let mut _0: (); diff --git a/tests/mir-opt/dead-store-elimination/call_arg_copy.move_packed.DeadStoreElimination.panic-unwind.diff b/tests/mir-opt/dead-store-elimination/call_arg_copy.move_packed.DeadStoreElimination-final.panic-unwind.diff index 86ef026ec5c..cac3badfa67 100644 --- a/tests/mir-opt/dead-store-elimination/call_arg_copy.move_packed.DeadStoreElimination.panic-unwind.diff +++ b/tests/mir-opt/dead-store-elimination/call_arg_copy.move_packed.DeadStoreElimination-final.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `move_packed` before DeadStoreElimination -+ // MIR for `move_packed` after DeadStoreElimination +- // MIR for `move_packed` before DeadStoreElimination-final ++ // MIR for `move_packed` after DeadStoreElimination-final fn move_packed(_1: Packed) -> () { let mut _0: (); diff --git a/tests/mir-opt/dead-store-elimination/call_arg_copy.move_simple.DeadStoreElimination.panic-abort.diff b/tests/mir-opt/dead-store-elimination/call_arg_copy.move_simple.DeadStoreElimination-final.panic-abort.diff index 8f799b33f45..f9bc9405d6a 100644 --- a/tests/mir-opt/dead-store-elimination/call_arg_copy.move_simple.DeadStoreElimination.panic-abort.diff +++ b/tests/mir-opt/dead-store-elimination/call_arg_copy.move_simple.DeadStoreElimination-final.panic-abort.diff @@ -1,12 +1,12 @@ -- // MIR for `move_simple` before DeadStoreElimination -+ // MIR for `move_simple` after DeadStoreElimination +- // MIR for `move_simple` before DeadStoreElimination-final ++ // MIR for `move_simple` after DeadStoreElimination-final fn move_simple(_1: i32) -> () { debug x => _1; let mut _0: (); let _2: (); -- let mut _3: i32; -- let mut _4: i32; + let mut _3: i32; + let mut _4: i32; bb0: { StorageLive(_2); diff --git a/tests/mir-opt/dead-store-elimination/call_arg_copy.move_simple.DeadStoreElimination.panic-unwind.diff b/tests/mir-opt/dead-store-elimination/call_arg_copy.move_simple.DeadStoreElimination-final.panic-unwind.diff index 0551d663b50..efe165422d9 100644 --- a/tests/mir-opt/dead-store-elimination/call_arg_copy.move_simple.DeadStoreElimination.panic-unwind.diff +++ b/tests/mir-opt/dead-store-elimination/call_arg_copy.move_simple.DeadStoreElimination-final.panic-unwind.diff @@ -1,12 +1,12 @@ -- // MIR for `move_simple` before DeadStoreElimination -+ // MIR for `move_simple` after DeadStoreElimination +- // MIR for `move_simple` before DeadStoreElimination-final ++ // MIR for `move_simple` after DeadStoreElimination-final fn move_simple(_1: i32) -> () { debug x => _1; let mut _0: (); let _2: (); -- let mut _3: i32; -- let mut _4: i32; + let mut _3: i32; + let mut _4: i32; bb0: { StorageLive(_2); diff --git a/tests/mir-opt/dead-store-elimination/call_arg_copy.rs b/tests/mir-opt/dead-store-elimination/call_arg_copy.rs index 490a4aa502c..37b3313f7d0 100644 --- a/tests/mir-opt/dead-store-elimination/call_arg_copy.rs +++ b/tests/mir-opt/dead-store-elimination/call_arg_copy.rs @@ -1,6 +1,5 @@ -// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -// unit-test: DeadStoreElimination +// unit-test: DeadStoreElimination-final // compile-flags: -Zmir-enable-passes=+CopyProp #![feature(core_intrinsics)] @@ -12,8 +11,10 @@ use std::intrinsics::mir::*; #[inline(never)] fn use_both(_: i32, _: i32) {} -// EMIT_MIR call_arg_copy.move_simple.DeadStoreElimination.diff +// EMIT_MIR call_arg_copy.move_simple.DeadStoreElimination-final.diff fn move_simple(x: i32) { + // CHECK-LABEL: fn move_simple( + // CHECK: = use_both(_1, move _1) use_both(x, x); } @@ -23,11 +24,14 @@ struct Packed { y: i32, } -// EMIT_MIR call_arg_copy.move_packed.DeadStoreElimination.diff +// EMIT_MIR call_arg_copy.move_packed.DeadStoreElimination-final.diff #[custom_mir(dialect = "analysis")] fn move_packed(packed: Packed) { + // CHECK-LABEL: fn move_packed( + // CHECK: = use_both(const 0_i32, (_1.1: i32)) mir!( { + // We have a packed struct, verify that the copy is not turned into a move. Call(RET = use_both(0, packed.y), ReturnTo(ret), UnwindContinue()) } ret = { diff --git a/tests/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination.diff b/tests/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination-initial.diff index cf73358dc52..2766b6ce6a9 100644 --- a/tests/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination.diff +++ b/tests/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination-initial.diff @@ -1,10 +1,10 @@ -- // MIR for `cycle` before DeadStoreElimination -+ // MIR for `cycle` after DeadStoreElimination +- // MIR for `cycle` before DeadStoreElimination-initial ++ // MIR for `cycle` after DeadStoreElimination-initial fn cycle(_1: i32, _2: i32, _3: i32) -> () { let mut _0: (); let mut _4: bool; -- let mut _5: i32; + let mut _5: i32; bb0: { _4 = cond() -> [return: bb1, unwind continue]; @@ -19,6 +19,10 @@ - _3 = _2; - _2 = _1; - _1 = _5; ++ nop; ++ nop; ++ nop; ++ nop; _4 = cond() -> [return: bb1, unwind continue]; } diff --git a/tests/mir-opt/dead-store-elimination/cycle.rs b/tests/mir-opt/dead-store-elimination/cycle.rs index 13e5411275d..e8f566b4aa7 100644 --- a/tests/mir-opt/dead-store-elimination/cycle.rs +++ b/tests/mir-opt/dead-store-elimination/cycle.rs @@ -1,9 +1,8 @@ -// skip-filecheck // This example is interesting because the non-transitive version of `MaybeLiveLocals` would // report that *all* of these stores are live. // // needs-unwind -// unit-test: DeadStoreElimination +// unit-test: DeadStoreElimination-initial #![feature(core_intrinsics, custom_mir)] use std::intrinsics::mir::*; @@ -13,9 +12,13 @@ fn cond() -> bool { false } -// EMIT_MIR cycle.cycle.DeadStoreElimination.diff +// EMIT_MIR cycle.cycle.DeadStoreElimination-initial.diff #[custom_mir(dialect = "runtime", phase = "post-cleanup")] fn cycle(mut x: i32, mut y: i32, mut z: i32) { + // CHECK-LABEL: fn cycle( + // CHECK-NOT: {{_.*}} = {{_.*}}; + // CHECK-NOT: {{_.*}} = move {{_.*}}; + // We use custom MIR to avoid generating debuginfo, that would force to preserve writes. mir!( let condition: bool; diff --git a/tests/mir-opt/dead-store-elimination/place_mention.main.DeadStoreElimination.diff b/tests/mir-opt/dead-store-elimination/place_mention.main.DeadStoreElimination-initial.diff index 2130518771a..5a550285871 100644 --- a/tests/mir-opt/dead-store-elimination/place_mention.main.DeadStoreElimination.diff +++ b/tests/mir-opt/dead-store-elimination/place_mention.main.DeadStoreElimination-initial.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before DeadStoreElimination -+ // MIR for `main` after DeadStoreElimination +- // MIR for `main` before DeadStoreElimination-initial ++ // MIR for `main` after DeadStoreElimination-initial fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/dead-store-elimination/place_mention.rs b/tests/mir-opt/dead-store-elimination/place_mention.rs index 4813cf7ee2b..ae75e622ff7 100644 --- a/tests/mir-opt/dead-store-elimination/place_mention.rs +++ b/tests/mir-opt/dead-store-elimination/place_mention.rs @@ -1,10 +1,15 @@ -// skip-filecheck -// unit-test: DeadStoreElimination +// Verify that we account for the `PlaceMention` statement as a use of the tuple, +// and don't remove it as a dead store. +// +// unit-test: DeadStoreElimination-initial // compile-flags: -Zmir-keep-place-mention -// EMIT_MIR place_mention.main.DeadStoreElimination.diff +// EMIT_MIR place_mention.main.DeadStoreElimination-initial.diff fn main() { - // Verify that we account for the `PlaceMention` statement as a use of the tuple, - // and don't remove it as a dead store. + // CHECK-LABEL: fn main( + // CHECK-NOT: PlaceMention( + // CHECK: [[tmp:_.*]] = + // CHECK-NEXT: PlaceMention([[tmp:_.*]]); + let (_, _) = ("Hello", "World"); } diff --git a/tests/mir-opt/dead-store-elimination/provenance_soundness.pointer_to_int.DeadStoreElimination.diff b/tests/mir-opt/dead-store-elimination/provenance_soundness.pointer_to_int.DeadStoreElimination-initial.diff index 31f727e5fb3..9b0dc6b6af6 100644 --- a/tests/mir-opt/dead-store-elimination/provenance_soundness.pointer_to_int.DeadStoreElimination.diff +++ b/tests/mir-opt/dead-store-elimination/provenance_soundness.pointer_to_int.DeadStoreElimination-initial.diff @@ -1,5 +1,5 @@ -- // MIR for `pointer_to_int` before DeadStoreElimination -+ // MIR for `pointer_to_int` after DeadStoreElimination +- // MIR for `pointer_to_int` before DeadStoreElimination-initial ++ // MIR for `pointer_to_int` after DeadStoreElimination-initial fn pointer_to_int(_1: *mut i32) -> () { debug p => _1; diff --git a/tests/mir-opt/dead-store-elimination/provenance_soundness.retags.DeadStoreElimination.diff b/tests/mir-opt/dead-store-elimination/provenance_soundness.retags.DeadStoreElimination-initial.diff index e1ebc39aacc..ab74d2411bb 100644 --- a/tests/mir-opt/dead-store-elimination/provenance_soundness.retags.DeadStoreElimination.diff +++ b/tests/mir-opt/dead-store-elimination/provenance_soundness.retags.DeadStoreElimination-initial.diff @@ -1,5 +1,5 @@ -- // MIR for `retags` before DeadStoreElimination -+ // MIR for `retags` after DeadStoreElimination +- // MIR for `retags` before DeadStoreElimination-initial ++ // MIR for `retags` after DeadStoreElimination-initial fn retags(_1: &mut i32) -> () { debug _r => _1; diff --git a/tests/mir-opt/dead-store-elimination/provenance_soundness.rs b/tests/mir-opt/dead-store-elimination/provenance_soundness.rs index 24ffbe980eb..916c393b9de 100644 --- a/tests/mir-opt/dead-store-elimination/provenance_soundness.rs +++ b/tests/mir-opt/dead-store-elimination/provenance_soundness.rs @@ -1,17 +1,21 @@ -// skip-filecheck -// unit-test: DeadStoreElimination -// compile-flags: -Zmir-emit-retag - // Test that we don't remove pointer to int casts or retags +// unit-test: DeadStoreElimination-initial +// compile-flags: -Zmir-emit-retag -// EMIT_MIR provenance_soundness.pointer_to_int.DeadStoreElimination.diff +// EMIT_MIR provenance_soundness.pointer_to_int.DeadStoreElimination-initial.diff fn pointer_to_int(p: *mut i32) { + // CHECK-LABEL: fn pointer_to_int( + // CHECK: {{_.*}} = {{.*}} as usize (PointerExposeAddress); + // CHECK: {{_.*}} = {{.*}} as isize (PointerExposeAddress); let _x = p as usize; let _y = p as isize; } -// EMIT_MIR provenance_soundness.retags.DeadStoreElimination.diff -fn retags(_r: &mut i32) {} +// EMIT_MIR provenance_soundness.retags.DeadStoreElimination-initial.diff +fn retags(_r: &mut i32) { + // CHECK-LABEL: fn retags( + // CHECK: Retag([fn entry] _1); +} fn main() { pointer_to_int(&mut 5 as *mut _); diff --git a/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-abort.diff b/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-abort.diff index 993e0f1d1a6..0af3faf28f0 100644 --- a/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-abort.diff +++ b/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-abort.diff @@ -5,12 +5,13 @@ let mut _0: (); let _1: main::Un; let mut _2: u32; + let mut _3: u32; scope 1 { debug un => _1; scope 2 { } scope 4 (inlined std::mem::drop::<u32>) { - debug _x => _2; + debug _x => _3; } } scope 3 (inlined val) { @@ -18,10 +19,13 @@ bb0: { StorageLive(_1); - _1 = Un { us: const 1_u32 }; StorageLive(_2); - _2 = (_1.0: u32); + _2 = const 1_u32; + _1 = Un { us: const 1_u32 }; StorageDead(_2); + StorageLive(_3); + _3 = (_1.0: u32); + StorageDead(_3); StorageDead(_1); return; } diff --git a/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-unwind.diff b/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-unwind.diff index 993e0f1d1a6..0af3faf28f0 100644 --- a/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-unwind.diff +++ b/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-unwind.diff @@ -5,12 +5,13 @@ let mut _0: (); let _1: main::Un; let mut _2: u32; + let mut _3: u32; scope 1 { debug un => _1; scope 2 { } scope 4 (inlined std::mem::drop::<u32>) { - debug _x => _2; + debug _x => _3; } } scope 3 (inlined val) { @@ -18,10 +19,13 @@ bb0: { StorageLive(_1); - _1 = Un { us: const 1_u32 }; StorageLive(_2); - _2 = (_1.0: u32); + _2 = const 1_u32; + _1 = Un { us: const 1_u32 }; StorageDead(_2); + StorageLive(_3); + _3 = (_1.0: u32); + StorageDead(_3); StorageDead(_1); return; } diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-abort.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-abort.diff index 0ba1bac0a03..080478ea884 100644 --- a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-abort.diff +++ b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-abort.diff @@ -73,31 +73,59 @@ } bb4: { +- StorageLive(_8); ++ nop; _8 = ((_6 as Some).0: usize); + StorageLive(_9); + _9 = _1; + StorageLive(_10); + _10 = _2; StorageLive(_11); _11 = _5; StorageLive(_12); StorageLive(_13); - _13 = _8 as u32 (IntToInt); + StorageLive(_14); + _14 = _8; +- _13 = move _14 as u32 (IntToInt); ++ _13 = _8 as u32 (IntToInt); + StorageDead(_14); _12 = Add(move _13, const 1_u32); StorageDead(_13); - _0 = float_to_exponential_common_exact::<T>(_1, _2, move _11, move _12, _3) -> [return: bb5, unwind unreachable]; + StorageLive(_15); + _15 = _3; +- _0 = float_to_exponential_common_exact::<T>(move _9, move _10, move _11, move _12, move _15) -> [return: bb5, unwind unreachable]; ++ _0 = float_to_exponential_common_exact::<T>(_1, _2, move _11, move _12, _3) -> [return: bb5, unwind unreachable]; } bb5: { + StorageDead(_15); StorageDead(_12); StorageDead(_11); + StorageDead(_10); + StorageDead(_9); +- StorageDead(_8); ++ nop; goto -> bb8; } bb6: { + StorageLive(_16); + _16 = _1; + StorageLive(_17); + _17 = _2; StorageLive(_18); _18 = _5; - _0 = float_to_exponential_common_shortest::<T>(_1, _2, move _18, _3) -> [return: bb7, unwind unreachable]; + StorageLive(_19); + _19 = _3; +- _0 = float_to_exponential_common_shortest::<T>(move _16, move _17, move _18, move _19) -> [return: bb7, unwind unreachable]; ++ _0 = float_to_exponential_common_shortest::<T>(_1, _2, move _18, _3) -> [return: bb7, unwind unreachable]; } bb7: { + StorageDead(_19); StorageDead(_18); + StorageDead(_17); + StorageDead(_16); goto -> bb8; } diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-unwind.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-unwind.diff index 27ea43ef12b..ff8933fca8b 100644 --- a/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-unwind.diff +++ b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-unwind.diff @@ -73,31 +73,59 @@ } bb4: { +- StorageLive(_8); ++ nop; _8 = ((_6 as Some).0: usize); + StorageLive(_9); + _9 = _1; + StorageLive(_10); + _10 = _2; StorageLive(_11); _11 = _5; StorageLive(_12); StorageLive(_13); - _13 = _8 as u32 (IntToInt); + StorageLive(_14); + _14 = _8; +- _13 = move _14 as u32 (IntToInt); ++ _13 = _8 as u32 (IntToInt); + StorageDead(_14); _12 = Add(move _13, const 1_u32); StorageDead(_13); - _0 = float_to_exponential_common_exact::<T>(_1, _2, move _11, move _12, _3) -> [return: bb5, unwind continue]; + StorageLive(_15); + _15 = _3; +- _0 = float_to_exponential_common_exact::<T>(move _9, move _10, move _11, move _12, move _15) -> [return: bb5, unwind continue]; ++ _0 = float_to_exponential_common_exact::<T>(_1, _2, move _11, move _12, _3) -> [return: bb5, unwind continue]; } bb5: { + StorageDead(_15); StorageDead(_12); StorageDead(_11); + StorageDead(_10); + StorageDead(_9); +- StorageDead(_8); ++ nop; goto -> bb8; } bb6: { + StorageLive(_16); + _16 = _1; + StorageLive(_17); + _17 = _2; StorageLive(_18); _18 = _5; - _0 = float_to_exponential_common_shortest::<T>(_1, _2, move _18, _3) -> [return: bb7, unwind continue]; + StorageLive(_19); + _19 = _3; +- _0 = float_to_exponential_common_shortest::<T>(move _16, move _17, move _18, move _19) -> [return: bb7, unwind continue]; ++ _0 = float_to_exponential_common_shortest::<T>(_1, _2, move _18, _3) -> [return: bb7, unwind continue]; } bb7: { + StorageDead(_19); StorageDead(_18); + StorageDead(_17); + StorageDead(_16); goto -> bb8; } diff --git a/tests/mir-opt/gvn.dereferences.GVN.panic-abort.diff b/tests/mir-opt/gvn.dereferences.GVN.panic-abort.diff index a587b1e6b1d..46bf13985da 100644 --- a/tests/mir-opt/gvn.dereferences.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.dereferences.GVN.panic-abort.diff @@ -72,8 +72,7 @@ bb2: { StorageDead(_7); StorageDead(_6); -- StorageLive(_8); -+ nop; + StorageLive(_8); _8 = &raw const (*_1); StorageLive(_9); StorageLive(_10); @@ -93,8 +92,7 @@ bb4: { StorageDead(_12); StorageDead(_11); -- StorageLive(_13); -+ nop; + StorageLive(_13); _13 = &raw mut (*_1); StorageLive(_14); StorageLive(_15); @@ -114,8 +112,7 @@ bb6: { StorageDead(_17); StorageDead(_16); -- StorageLive(_18); -+ nop; + StorageLive(_18); _18 = &(*_1); StorageLive(_19); - StorageLive(_20); @@ -191,12 +188,9 @@ StorageDead(_32); StorageDead(_31); _0 = const (); -- StorageDead(_18); -- StorageDead(_13); -- StorageDead(_8); -+ nop; -+ nop; -+ nop; + StorageDead(_18); + StorageDead(_13); + StorageDead(_8); return; } } diff --git a/tests/mir-opt/gvn.dereferences.GVN.panic-unwind.diff b/tests/mir-opt/gvn.dereferences.GVN.panic-unwind.diff index 6fdda5e9988..3e731ead859 100644 --- a/tests/mir-opt/gvn.dereferences.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.dereferences.GVN.panic-unwind.diff @@ -72,8 +72,7 @@ bb2: { StorageDead(_7); StorageDead(_6); -- StorageLive(_8); -+ nop; + StorageLive(_8); _8 = &raw const (*_1); StorageLive(_9); StorageLive(_10); @@ -93,8 +92,7 @@ bb4: { StorageDead(_12); StorageDead(_11); -- StorageLive(_13); -+ nop; + StorageLive(_13); _13 = &raw mut (*_1); StorageLive(_14); StorageLive(_15); @@ -114,8 +112,7 @@ bb6: { StorageDead(_17); StorageDead(_16); -- StorageLive(_18); -+ nop; + StorageLive(_18); _18 = &(*_1); StorageLive(_19); - StorageLive(_20); @@ -191,12 +188,9 @@ StorageDead(_32); StorageDead(_31); _0 = const (); -- StorageDead(_18); -- StorageDead(_13); -- StorageDead(_8); -+ nop; -+ nop; -+ nop; + StorageDead(_18); + StorageDead(_13); + StorageDead(_8); return; } } diff --git a/tests/mir-opt/gvn.slices.GVN.panic-abort.diff b/tests/mir-opt/gvn.slices.GVN.panic-abort.diff index ec449980312..f3f9073909e 100644 --- a/tests/mir-opt/gvn.slices.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.slices.GVN.panic-abort.diff @@ -194,15 +194,13 @@ - _23 = move _21; + _23 = const core::panicking::AssertKind::Eq; StorageLive(_24); -- StorageLive(_25); + StorageLive(_25); - _25 = &(*_15); -+ nop; + _25 = &(*_9); _24 = &(*_25); StorageLive(_26); -- StorageLive(_27); + StorageLive(_27); - _27 = &(*_16); -+ nop; + _27 = &(*_12); _26 = &(*_27); StorageLive(_28); @@ -293,15 +291,13 @@ - _49 = move _47; + _49 = const core::panicking::AssertKind::Eq; StorageLive(_50); -- StorageLive(_51); + StorageLive(_51); - _51 = &(*_41); -+ nop; + _51 = &(*_35); _50 = &(*_51); StorageLive(_52); -- StorageLive(_53); + StorageLive(_53); - _53 = &(*_42); -+ nop; + _53 = &(*_38); _52 = &(*_53); StorageLive(_54); diff --git a/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff b/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff index 56a78ca8694..383152cce5e 100644 --- a/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff @@ -194,15 +194,13 @@ - _23 = move _21; + _23 = const core::panicking::AssertKind::Eq; StorageLive(_24); -- StorageLive(_25); + StorageLive(_25); - _25 = &(*_15); -+ nop; + _25 = &(*_9); _24 = &(*_25); StorageLive(_26); -- StorageLive(_27); + StorageLive(_27); - _27 = &(*_16); -+ nop; + _27 = &(*_12); _26 = &(*_27); StorageLive(_28); @@ -293,15 +291,13 @@ - _49 = move _47; + _49 = const core::panicking::AssertKind::Eq; StorageLive(_50); -- StorageLive(_51); + StorageLive(_51); - _51 = &(*_41); -+ nop; + _51 = &(*_35); _50 = &(*_51); StorageLive(_52); -- StorageLive(_53); + StorageLive(_53); - _53 = &(*_42); -+ nop; + _53 = &(*_38); _52 = &(*_53); StorageLive(_54); diff --git a/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-abort.diff b/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-abort.diff index 0a747d3aef0..3ecd4650d81 100644 --- a/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-abort.diff @@ -757,8 +757,7 @@ bb34: { StorageDead(_121); StorageDead(_120); -- StorageLive(_126); -+ nop; + StorageLive(_126); _126 = &_3; StorageLive(_127); - StorageLive(_128); @@ -799,8 +798,7 @@ bb36: { StorageDead(_132); StorageDead(_131); -- StorageLive(_135); -+ nop; + StorageLive(_135); _135 = &mut _3; StorageLive(_136); StorageLive(_137); @@ -835,8 +833,7 @@ StorageDead(_141); StorageDead(_140); StorageLive(_144); -- StorageLive(_145); -+ nop; + StorageLive(_145); _145 = &raw const _3; StorageLive(_146); StorageLive(_147); @@ -870,8 +867,7 @@ bb40: { StorageDead(_151); StorageDead(_150); -- StorageLive(_154); -+ nop; + StorageLive(_154); _154 = &raw mut _3; StorageLive(_155); StorageLive(_156); @@ -906,13 +902,10 @@ StorageDead(_160); StorageDead(_159); _144 = const (); -- StorageDead(_154); -- StorageDead(_145); -+ nop; -+ nop; + StorageDead(_154); + StorageDead(_145); StorageDead(_144); -- StorageLive(_163); -+ nop; + StorageLive(_163); _163 = &_3; StorageLive(_164); - StorageLive(_165); @@ -954,12 +947,9 @@ StorageDead(_169); StorageDead(_168); _0 = const (); -- StorageDead(_163); -- StorageDead(_135); -- StorageDead(_126); -+ nop; -+ nop; -+ nop; + StorageDead(_163); + StorageDead(_135); + StorageDead(_126); return; } } diff --git a/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-unwind.diff b/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-unwind.diff index 119a4d9bbe9..bf448280b1e 100644 --- a/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-unwind.diff @@ -757,8 +757,7 @@ bb34: { StorageDead(_121); StorageDead(_120); -- StorageLive(_126); -+ nop; + StorageLive(_126); _126 = &_3; StorageLive(_127); - StorageLive(_128); @@ -799,8 +798,7 @@ bb36: { StorageDead(_132); StorageDead(_131); -- StorageLive(_135); -+ nop; + StorageLive(_135); _135 = &mut _3; StorageLive(_136); StorageLive(_137); @@ -835,8 +833,7 @@ StorageDead(_141); StorageDead(_140); StorageLive(_144); -- StorageLive(_145); -+ nop; + StorageLive(_145); _145 = &raw const _3; StorageLive(_146); StorageLive(_147); @@ -870,8 +867,7 @@ bb40: { StorageDead(_151); StorageDead(_150); -- StorageLive(_154); -+ nop; + StorageLive(_154); _154 = &raw mut _3; StorageLive(_155); StorageLive(_156); @@ -906,13 +902,10 @@ StorageDead(_160); StorageDead(_159); _144 = const (); -- StorageDead(_154); -- StorageDead(_145); -+ nop; -+ nop; + StorageDead(_154); + StorageDead(_145); StorageDead(_144); -- StorageLive(_163); -+ nop; + StorageLive(_163); _163 = &_3; StorageLive(_164); - StorageLive(_165); @@ -954,12 +947,9 @@ StorageDead(_169); StorageDead(_168); _0 = const (); -- StorageDead(_163); -- StorageDead(_135); -- StorageDead(_126); -+ nop; -+ nop; -+ nop; + StorageDead(_163); + StorageDead(_135); + StorageDead(_126); return; } } diff --git a/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff index 68c612314f6..8e53427e7e0 100644 --- a/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff @@ -36,7 +36,7 @@ - _4 = g() -> [return: bb1, unwind unreachable]; + _4 = {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8 (#0)}; + _3 = &mut _4; -+ _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}> { pointer: move _3 }; ++ _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}> { pointer: _3 }; + StorageDead(_3); + StorageLive(_5); + _5 = const false; diff --git a/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff index 1bf14e8c3b3..b06db41af9d 100644 --- a/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff @@ -36,7 +36,7 @@ - _4 = g() -> [return: bb1, unwind continue]; + _4 = {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8 (#0)}; + _3 = &mut _4; -+ _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}> { pointer: move _3 }; ++ _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}> { pointer: _3 }; + StorageDead(_3); + StorageLive(_5); + _5 = const false; diff --git a/tests/mir-opt/inline/inline_diverging.h.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_diverging.h.Inline.panic-abort.diff index da45ebcb4d8..2bbb830fc77 100644 --- a/tests/mir-opt/inline/inline_diverging.h.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/inline_diverging.h.Inline.panic-abort.diff @@ -40,7 +40,7 @@ + + bb2: { + StorageDead(_5); -+ _1 = (move _4, move _6); ++ _1 = (_4, _6); + drop(_2) -> [return: bb3, unwind unreachable]; + } + diff --git a/tests/mir-opt/inline/inline_diverging.h.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_diverging.h.Inline.panic-unwind.diff index d65c65e5fd0..bc4f2d24df0 100644 --- a/tests/mir-opt/inline/inline_diverging.h.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_diverging.h.Inline.panic-unwind.diff @@ -43,7 +43,7 @@ + StorageDead(_5); + StorageLive(_7); + _7 = move _4; -+ _1 = (move _7, move _6); ++ _1 = (move _7, _6); + StorageDead(_7); + StorageDead(_4); + drop(_2) -> [return: bb3, unwind continue]; diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-abort.mir b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-abort.mir index aeb93bd334f..d6a608476df 100644 --- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-abort.mir @@ -31,7 +31,7 @@ fn unwrap_unchecked(_1: Option<T>) -> T { _2 = discriminant(_1); _3 = Eq(_2, const 1_isize); assume(move _3); - _0 = move ((_1 as Some).0: T); + _0 = ((_1 as Some).0: T); StorageDead(_3); StorageDead(_2); StorageDead(_4); diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-unwind.mir index aeb93bd334f..d6a608476df 100644 --- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-unwind.mir @@ -31,7 +31,7 @@ fn unwrap_unchecked(_1: Option<T>) -> T { _2 = discriminant(_1); _3 = Eq(_2, const 1_isize); assume(move _3); - _0 = move ((_1 as Some).0: T); + _0 = ((_1 as Some).0: T); StorageDead(_3); StorageDead(_2); StorageDead(_4); diff --git a/tests/mir-opt/issue_101973.inner.GVN.panic-abort.diff b/tests/mir-opt/issue_101973.inner.GVN.panic-abort.diff index d2db8f61916..b04728a9b0f 100644 --- a/tests/mir-opt/issue_101973.inner.GVN.panic-abort.diff +++ b/tests/mir-opt/issue_101973.inner.GVN.panic-abort.diff @@ -17,7 +17,7 @@ let mut _12: u32; let mut _13: bool; scope 1 (inlined imm8) { - debug x => _1; + debug x => _5; let mut _14: u32; let mut _15: u32; scope 2 { @@ -33,17 +33,23 @@ StorageLive(_2); StorageLive(_3); StorageLive(_4); + StorageLive(_5); + _5 = _1; _4 = const 0_u32; StorageLive(_15); StorageLive(_14); - _14 = Shr(_1, const 0_i32); +- _14 = Shr(_5, const 0_i32); ++ _14 = Shr(_1, const 0_i32); _15 = BitAnd(move _14, const 255_u32); StorageDead(_14); _4 = BitOr(const 0_u32, move _15); StorageDead(_15); + StorageDead(_5); StorageLive(_6); StorageLive(_7); StorageLive(_8); + StorageLive(_9); + _9 = _1; - _10 = const 8_i32 as u32 (IntToInt); - _11 = Lt(move _10, const 32_u32); - assert(move _11, "attempt to shift right by `{}`, which would overflow", const 8_i32) -> [success: bb1, unwind unreachable]; @@ -53,7 +59,9 @@ } bb1: { - _8 = Shr(_1, const 8_i32); +- _8 = Shr(move _9, const 8_i32); ++ _8 = Shr(_1, const 8_i32); + StorageDead(_9); _7 = BitAnd(move _8, const 15_u32); StorageDead(_8); - _12 = const 1_i32 as u32 (IntToInt); diff --git a/tests/mir-opt/issue_101973.inner.GVN.panic-unwind.diff b/tests/mir-opt/issue_101973.inner.GVN.panic-unwind.diff index 514183b3bc0..fcf99ac6918 100644 --- a/tests/mir-opt/issue_101973.inner.GVN.panic-unwind.diff +++ b/tests/mir-opt/issue_101973.inner.GVN.panic-unwind.diff @@ -17,7 +17,7 @@ let mut _12: u32; let mut _13: bool; scope 1 (inlined imm8) { - debug x => _1; + debug x => _5; let mut _14: u32; let mut _15: u32; scope 2 { @@ -33,17 +33,23 @@ StorageLive(_2); StorageLive(_3); StorageLive(_4); + StorageLive(_5); + _5 = _1; _4 = const 0_u32; StorageLive(_15); StorageLive(_14); - _14 = Shr(_1, const 0_i32); +- _14 = Shr(_5, const 0_i32); ++ _14 = Shr(_1, const 0_i32); _15 = BitAnd(move _14, const 255_u32); StorageDead(_14); _4 = BitOr(const 0_u32, move _15); StorageDead(_15); + StorageDead(_5); StorageLive(_6); StorageLive(_7); StorageLive(_8); + StorageLive(_9); + _9 = _1; - _10 = const 8_i32 as u32 (IntToInt); - _11 = Lt(move _10, const 32_u32); - assert(move _11, "attempt to shift right by `{}`, which would overflow", const 8_i32) -> [success: bb1, unwind continue]; @@ -53,7 +59,9 @@ } bb1: { - _8 = Shr(_1, const 8_i32); +- _8 = Shr(move _9, const 8_i32); ++ _8 = Shr(_1, const 8_i32); + StorageDead(_9); _7 = BitAnd(move _8, const 15_u32); StorageDead(_8); - _12 = const 1_i32 as u32 (IntToInt); diff --git a/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-abort.mir b/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-abort.mir index 5d25c655700..f7be8b75db7 100644 --- a/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-abort.mir @@ -51,7 +51,7 @@ fn num_to_digit(_1: char) -> u32 { } bb4: { - _7 = core::panicking::panic(const "called `Option::unwrap()` on a `None` value") -> unwind unreachable; + _7 = option::unwrap_failed() -> unwind unreachable; } bb5: { diff --git a/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-unwind.mir index 4677c0108e3..e76fe992ac7 100644 --- a/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.panic-unwind.mir @@ -51,7 +51,7 @@ fn num_to_digit(_1: char) -> u32 { } bb4: { - _7 = core::panicking::panic(const "called `Option::unwrap()` on a `None` value") -> unwind continue; + _7 = option::unwrap_failed() -> unwind continue; } bb5: { diff --git a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff index f04ca72dd6d..9cc4385f60b 100644 --- a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff +++ b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff @@ -110,7 +110,7 @@ bb6: { _12 = move ((_4 as Err).0: i32); StorageLive(_13); - _13 = Result::<Infallible, i32>::Err(move _12); + _13 = Result::<Infallible, i32>::Err(_12); _3 = ControlFlow::<Result<Infallible, i32>, i32>::Break(move _13); StorageDead(_13); - goto -> bb5; @@ -119,7 +119,7 @@ bb7: { _11 = move ((_4 as Ok).0: i32); - _3 = ControlFlow::<Result<Infallible, i32>, i32>::Continue(move _11); + _3 = ControlFlow::<Result<Infallible, i32>, i32>::Continue(_11); goto -> bb5; + } + diff --git a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff index f04ca72dd6d..9cc4385f60b 100644 --- a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff +++ b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff @@ -110,7 +110,7 @@ bb6: { _12 = move ((_4 as Err).0: i32); StorageLive(_13); - _13 = Result::<Infallible, i32>::Err(move _12); + _13 = Result::<Infallible, i32>::Err(_12); _3 = ControlFlow::<Result<Infallible, i32>, i32>::Break(move _13); StorageDead(_13); - goto -> bb5; @@ -119,7 +119,7 @@ bb7: { _11 = move ((_4 as Ok).0: i32); - _3 = ControlFlow::<Result<Infallible, i32>, i32>::Continue(move _11); + _3 = ControlFlow::<Result<Infallible, i32>, i32>::Continue(_11); goto -> bb5; + } + diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff index 47e0d402347..de9a1a075ad 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff @@ -19,7 +19,7 @@ } scope 5 (inlined <std::alloc::Global as Allocator>::allocate) { debug self => _9; - debug layout => _1; + debug layout => _8; } scope 6 (inlined #[track_caller] Result::<NonNull<[u8]>, std::alloc::AllocError>::unwrap) { debug self => _6; @@ -51,6 +51,8 @@ } bb0: { +- StorageLive(_1); ++ nop; StorageLive(_2); - _2 = Option::<Layout>::None; + _2 = const Option::<Layout>::None; @@ -62,7 +64,7 @@ } bb1: { - _11 = core::panicking::panic(const "called `Option::unwrap()` on a `None` value") -> unwind unreachable; + _11 = option::unwrap_failed() -> unwind unreachable; } bb2: { @@ -74,12 +76,20 @@ StorageLive(_4); StorageLive(_5); StorageLive(_6); + StorageLive(_7); _9 = const _; -- _6 = std::alloc::Global::alloc_impl(_9, _1, const false) -> [return: bb3, unwind unreachable]; +- _7 = _9; ++ _7 = const {ALLOC1<imm>: &std::alloc::Global}; + StorageLive(_8); +- _8 = _1; +- _6 = std::alloc::Global::alloc_impl(move _7, move _8, const false) -> [return: bb3, unwind unreachable]; ++ _8 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum32) }}; + _6 = std::alloc::Global::alloc_impl(const {ALLOC1<imm>: &std::alloc::Global}, const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum32) }}, const false) -> [return: bb3, unwind unreachable]; } bb3: { + StorageDead(_8); + StorageDead(_7); StorageLive(_12); StorageLive(_15); _12 = discriminant(_6); @@ -109,6 +119,8 @@ _3 = move _4 as *mut u8 (PtrToPtr); StorageDead(_4); StorageDead(_3); +- StorageDead(_1); ++ nop; return; } diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff index dee57ce6c27..f784db0f409 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff @@ -19,7 +19,7 @@ } scope 5 (inlined <std::alloc::Global as Allocator>::allocate) { debug self => _9; - debug layout => _1; + debug layout => _8; } scope 6 (inlined NonNull::<[u8]>::as_ptr) { debug self => _5; @@ -36,6 +36,8 @@ } bb0: { +- StorageLive(_1); ++ nop; StorageLive(_2); - _2 = Option::<Layout>::None; + _2 = const Option::<Layout>::None; @@ -56,11 +58,13 @@ _3 = move _4 as *mut u8 (PtrToPtr); StorageDead(_4); StorageDead(_3); +- StorageDead(_1); ++ nop; return; } bb2: { - _11 = core::panicking::panic(const "called `Option::unwrap()` on a `None` value") -> unwind continue; + _11 = option::unwrap_failed() -> unwind continue; } bb3: { @@ -72,12 +76,20 @@ StorageLive(_4); StorageLive(_5); StorageLive(_6); + StorageLive(_7); _9 = const _; -- _6 = std::alloc::Global::alloc_impl(_9, _1, const false) -> [return: bb4, unwind continue]; +- _7 = _9; ++ _7 = const {ALLOC1<imm>: &std::alloc::Global}; + StorageLive(_8); +- _8 = _1; +- _6 = std::alloc::Global::alloc_impl(move _7, move _8, const false) -> [return: bb4, unwind continue]; ++ _8 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum32) }}; + _6 = std::alloc::Global::alloc_impl(const {ALLOC1<imm>: &std::alloc::Global}, const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x00000000): std::ptr::alignment::AlignmentEnum32) }}, const false) -> [return: bb4, unwind continue]; } bb4: { + StorageDead(_8); + StorageDead(_7); _5 = Result::<NonNull<[u8]>, std::alloc::AllocError>::unwrap(move _6) -> [return: bb1, unwind continue]; } diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff index a255b15920c..162b7fa4618 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff @@ -19,7 +19,7 @@ } scope 5 (inlined <std::alloc::Global as Allocator>::allocate) { debug self => _9; - debug layout => _1; + debug layout => _8; } scope 6 (inlined #[track_caller] Result::<NonNull<[u8]>, std::alloc::AllocError>::unwrap) { debug self => _6; @@ -51,6 +51,8 @@ } bb0: { +- StorageLive(_1); ++ nop; StorageLive(_2); - _2 = Option::<Layout>::None; + _2 = const Option::<Layout>::None; @@ -62,7 +64,7 @@ } bb1: { - _11 = core::panicking::panic(const "called `Option::unwrap()` on a `None` value") -> unwind unreachable; + _11 = option::unwrap_failed() -> unwind unreachable; } bb2: { @@ -74,12 +76,20 @@ StorageLive(_4); StorageLive(_5); StorageLive(_6); + StorageLive(_7); _9 = const _; -- _6 = std::alloc::Global::alloc_impl(_9, _1, const false) -> [return: bb3, unwind unreachable]; +- _7 = _9; ++ _7 = const {ALLOC1<imm>: &std::alloc::Global}; + StorageLive(_8); +- _8 = _1; +- _6 = std::alloc::Global::alloc_impl(move _7, move _8, const false) -> [return: bb3, unwind unreachable]; ++ _8 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum64) }}; + _6 = std::alloc::Global::alloc_impl(const {ALLOC1<imm>: &std::alloc::Global}, const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum64) }}, const false) -> [return: bb3, unwind unreachable]; } bb3: { + StorageDead(_8); + StorageDead(_7); StorageLive(_12); StorageLive(_15); _12 = discriminant(_6); @@ -109,6 +119,8 @@ _3 = move _4 as *mut u8 (PtrToPtr); StorageDead(_4); StorageDead(_3); +- StorageDead(_1); ++ nop; return; } diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff index 192ffea2591..400aac6d64b 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff @@ -19,7 +19,7 @@ } scope 5 (inlined <std::alloc::Global as Allocator>::allocate) { debug self => _9; - debug layout => _1; + debug layout => _8; } scope 6 (inlined NonNull::<[u8]>::as_ptr) { debug self => _5; @@ -36,6 +36,8 @@ } bb0: { +- StorageLive(_1); ++ nop; StorageLive(_2); - _2 = Option::<Layout>::None; + _2 = const Option::<Layout>::None; @@ -56,11 +58,13 @@ _3 = move _4 as *mut u8 (PtrToPtr); StorageDead(_4); StorageDead(_3); +- StorageDead(_1); ++ nop; return; } bb2: { - _11 = core::panicking::panic(const "called `Option::unwrap()` on a `None` value") -> unwind continue; + _11 = option::unwrap_failed() -> unwind continue; } bb3: { @@ -72,12 +76,20 @@ StorageLive(_4); StorageLive(_5); StorageLive(_6); + StorageLive(_7); _9 = const _; -- _6 = std::alloc::Global::alloc_impl(_9, _1, const false) -> [return: bb4, unwind continue]; +- _7 = _9; ++ _7 = const {ALLOC1<imm>: &std::alloc::Global}; + StorageLive(_8); +- _8 = _1; +- _6 = std::alloc::Global::alloc_impl(move _7, move _8, const false) -> [return: bb4, unwind continue]; ++ _8 = const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum64) }}; + _6 = std::alloc::Global::alloc_impl(const {ALLOC1<imm>: &std::alloc::Global}, const Layout {{ size: Indirect { alloc_id: ALLOC0, offset: Size(8 bytes) }: usize, align: std::ptr::Alignment(Scalar(0x0000000000000000): std::ptr::alignment::AlignmentEnum64) }}, const false) -> [return: bb4, unwind continue]; } bb4: { + StorageDead(_8); + StorageDead(_7); _5 = Result::<NonNull<[u8]>, std::alloc::AllocError>::unwrap(move _6) -> [return: bb1, unwind continue]; } diff --git a/tests/mir-opt/pre-codegen/loops.filter_mapped.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.filter_mapped.PreCodegen.after.mir index 8dbb688999a..8d182069adc 100644 --- a/tests/mir-opt/pre-codegen/loops.filter_mapped.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/loops.filter_mapped.PreCodegen.after.mir @@ -32,7 +32,7 @@ fn filter_mapped(_1: impl Iterator<Item = T>, _2: impl Fn(T) -> Option<U>) -> () bb1: { StorageLive(_4); - _4 = move _3; + _4 = _3; goto -> bb2; } diff --git a/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir index 42c7eb3c6aa..e27e417ed4a 100644 --- a/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/loops.int_range.PreCodegen.after.mir @@ -46,7 +46,7 @@ fn int_range(_1: usize, _2: usize) -> () { bb0: { _3 = std::ops::Range::<usize> { start: _1, end: _2 }; StorageLive(_4); - _4 = move _3; + _4 = _3; goto -> bb1; } diff --git a/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir index 30bdc131090..b800a1be22b 100644 --- a/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/loops.mapped.PreCodegen.after.mir @@ -27,7 +27,7 @@ fn mapped(_1: impl Iterator<Item = T>, _2: impl Fn(T) -> U) -> () { bb1: { StorageLive(_4); - _4 = move _3; + _4 = _3; goto -> bb2; } diff --git a/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir index 713d6cc558a..f0cb4ca31fe 100644 --- a/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir @@ -19,22 +19,23 @@ fn mem_replace(_1: &mut u32, _2: u32) -> u32 { } scope 4 (inlined std::ptr::read::<u32>) { debug src => _1; + let mut _3: *const u32; scope 5 { scope 6 (inlined std::ptr::read::runtime::<u32>) { - debug src => _1; + debug src => _3; scope 7 (inlined intrinsics::is_aligned_and_not_null::<u32>) { - debug ptr => _1; + debug ptr => _3; scope 8 (inlined std::ptr::const_ptr::<impl *const u32>::is_null) { - debug self => _1; - let mut _3: *const u8; + debug self => _3; + let mut _4: *const u8; scope 9 { scope 10 (inlined std::ptr::const_ptr::<impl *const T>::is_null::runtime_impl) { - debug ptr => _3; + debug ptr => _4; scope 11 (inlined std::ptr::const_ptr::<impl *const u8>::addr) { - debug self => _3; + debug self => _4; scope 12 { scope 13 (inlined std::ptr::const_ptr::<impl *const u8>::cast::<()>) { - debug self => _3; + debug self => _4; } } } @@ -42,7 +43,7 @@ fn mem_replace(_1: &mut u32, _2: u32) -> u32 { } } scope 14 (inlined std::ptr::const_ptr::<impl *const u32>::is_aligned) { - debug self => _1; + debug self => _3; scope 15 (inlined align_of::<u32>) { } } @@ -55,7 +56,9 @@ fn mem_replace(_1: &mut u32, _2: u32) -> u32 { bb0: { StorageLive(_3); + StorageLive(_4); _0 = (*_1); + StorageDead(_4); StorageDead(_3); (*_1) = _2; return; diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-abort.diff index 4e34233a979..0e7e1f971ec 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-abort.diff @@ -17,7 +17,7 @@ debug y => _3; let _8: u32; scope 3 { - debug z => _9; + debug z => _8; } } } @@ -50,7 +50,13 @@ + _3 = const 3_i32; StorageDead(_5); StorageDead(_4); + StorageLive(_8); + StorageLive(_9); _9 = const 42_u32; +- _8 = _9; ++ _8 = const 42_u32; + StorageDead(_9); + StorageDead(_8); StorageDead(_3); StorageDead(_1); return; diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-unwind.diff index 275f17e52ae..9071a3339c0 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-unwind.diff @@ -17,7 +17,7 @@ debug y => _3; let _8: u32; scope 3 { - debug z => _9; + debug z => _8; } } } @@ -50,7 +50,13 @@ + _3 = const 3_i32; StorageDead(_5); StorageDead(_4); + StorageLive(_8); + StorageLive(_9); _9 = const 42_u32; +- _8 = _9; ++ _8 = const 42_u32; + StorageDead(_9); + StorageDead(_8); StorageDead(_3); StorageDead(_1); return; diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-abort.diff index 4e34233a979..0e7e1f971ec 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-abort.diff @@ -17,7 +17,7 @@ debug y => _3; let _8: u32; scope 3 { - debug z => _9; + debug z => _8; } } } @@ -50,7 +50,13 @@ + _3 = const 3_i32; StorageDead(_5); StorageDead(_4); + StorageLive(_8); + StorageLive(_9); _9 = const 42_u32; +- _8 = _9; ++ _8 = const 42_u32; + StorageDead(_9); + StorageDead(_8); StorageDead(_3); StorageDead(_1); return; diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-unwind.diff index 275f17e52ae..9071a3339c0 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-unwind.diff @@ -17,7 +17,7 @@ debug y => _3; let _8: u32; scope 3 { - debug z => _9; + debug z => _8; } } } @@ -50,7 +50,13 @@ + _3 = const 3_i32; StorageDead(_5); StorageDead(_4); + StorageLive(_8); + StorageLive(_9); _9 = const 42_u32; +- _8 = _9; ++ _8 = const 42_u32; + StorageDead(_9); + StorageDead(_8); StorageDead(_3); StorageDead(_1); return; diff --git a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir index e5940bd8201..99805da5669 100644 --- a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir @@ -49,7 +49,7 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { bb0: { _4 = std::ops::Range::<u32> { start: _1, end: _2 }; StorageLive(_5); - _5 = move _4; + _5 = _4; goto -> bb1; } diff --git a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir index 87e7485cb36..f40f1307175 100644 --- a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir @@ -49,7 +49,7 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { bb0: { _4 = std::ops::Range::<u32> { start: _1, end: _2 }; StorageLive(_5); - _5 = move _4; + _5 = _4; goto -> bb1; } diff --git a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-abort.mir index 1b23e421368..0836600cb6e 100644 --- a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-abort.mir @@ -34,7 +34,7 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { bb0: { _4 = RangeInclusive::<u32> { start: _1, end: _2, exhausted: const false }; StorageLive(_5); - _5 = move _4; + _5 = _4; goto -> bb1; } diff --git a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir index a677e8b439f..8c1794de524 100644 --- a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir @@ -34,7 +34,7 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { bb0: { _4 = RangeInclusive::<u32> { start: _1, end: _2, exhausted: const false }; StorageLive(_5); - _5 = move _4; + _5 = _4; goto -> bb1; } diff --git a/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir index cc009e45e7e..7370da5629c 100644 --- a/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir @@ -94,6 +94,8 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:8:25: 8:39}, _2 StorageLive(_9); _9 = _6; _10 = &_9; + StorageLive(_11); + StorageLive(_12); _11 = _4; _12 = _9; StorageLive(_13); @@ -103,6 +105,8 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:8:25: 8:39}, _2 _15 = Le(move _13, move _14); StorageDead(_14); StorageDead(_13); + StorageDead(_12); + StorageDead(_11); switchInt(move _15) -> [0: bb1, otherwise: bb2]; } @@ -124,6 +128,8 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:8:25: 8:39}, _2 StorageLive(_17); _17 = _5; _18 = &_17; + StorageLive(_19); + StorageLive(_20); _19 = _7; _20 = _17; StorageLive(_21); @@ -133,6 +139,8 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:8:25: 8:39}, _2 _23 = Le(move _21, move _22); StorageDead(_22); StorageDead(_21); + StorageDead(_20); + StorageDead(_19); switchInt(move _23) -> [0: bb3, otherwise: bb8]; } @@ -151,6 +159,8 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:8:25: 8:39}, _2 StorageLive(_25); _25 = _4; _26 = &_25; + StorageLive(_27); + StorageLive(_28); _27 = _6; _28 = _25; StorageLive(_29); @@ -160,6 +170,8 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:8:25: 8:39}, _2 _31 = Le(move _29, move _30); StorageDead(_30); StorageDead(_29); + StorageDead(_28); + StorageDead(_27); switchInt(move _31) -> [0: bb5, otherwise: bb6]; } @@ -181,6 +193,8 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:8:25: 8:39}, _2 StorageLive(_33); _33 = _7; _34 = &_33; + StorageLive(_35); + StorageLive(_36); _35 = _5; _36 = _33; StorageLive(_37); @@ -190,6 +204,8 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:8:25: 8:39}, _2 _0 = Le(move _37, move _38); StorageDead(_38); StorageDead(_37); + StorageDead(_36); + StorageDead(_35); StorageDead(_33); StorageDead(_34); StorageDead(_32); diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir index a12411a0413..bc7617bb6dd 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-abort.mir @@ -20,7 +20,8 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { debug self => _2; debug slice => _5; let mut _6: *mut u32; - let mut _9: &[&str]; + let mut _9: *mut [u32]; + let mut _10: &[&str]; scope 5 { scope 10 (inlined std::ptr::mut_ptr::<impl *mut [u32]>::as_mut_ptr) { debug self => _5; @@ -33,16 +34,16 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { } } scope 6 (inlined std::ptr::mut_ptr::<impl *mut [u32]>::len) { - debug self => _5; - let mut _10: *const [u32]; + debug self => _9; + let mut _11: *const [u32]; scope 7 (inlined std::ptr::metadata::<[u32]>) { - debug ptr => _10; + debug ptr => _11; scope 8 { } } } scope 9 (inlined Arguments::<'_>::new_const) { - debug pieces => _9; + debug pieces => _10; } } } @@ -50,6 +51,7 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { } bb0: { + StorageLive(_7); StorageLive(_4); StorageLive(_3); _3 = Len((*_1)); @@ -70,10 +72,12 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { _5 = &raw mut (*_1); StorageLive(_9); StorageLive(_10); + StorageLive(_11); StorageLive(_6); _6 = _5 as *mut u32 (PtrToPtr); _7 = Offset(_6, _2); StorageDead(_6); + StorageDead(_11); StorageDead(_10); StorageDead(_9); StorageDead(_5); @@ -85,6 +89,7 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { bb3: { StorageDead(_4); + StorageDead(_7); return; } } diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir index a12411a0413..bc7617bb6dd 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_mut_usize.PreCodegen.after.panic-unwind.mir @@ -20,7 +20,8 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { debug self => _2; debug slice => _5; let mut _6: *mut u32; - let mut _9: &[&str]; + let mut _9: *mut [u32]; + let mut _10: &[&str]; scope 5 { scope 10 (inlined std::ptr::mut_ptr::<impl *mut [u32]>::as_mut_ptr) { debug self => _5; @@ -33,16 +34,16 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { } } scope 6 (inlined std::ptr::mut_ptr::<impl *mut [u32]>::len) { - debug self => _5; - let mut _10: *const [u32]; + debug self => _9; + let mut _11: *const [u32]; scope 7 (inlined std::ptr::metadata::<[u32]>) { - debug ptr => _10; + debug ptr => _11; scope 8 { } } } scope 9 (inlined Arguments::<'_>::new_const) { - debug pieces => _9; + debug pieces => _10; } } } @@ -50,6 +51,7 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { } bb0: { + StorageLive(_7); StorageLive(_4); StorageLive(_3); _3 = Len((*_1)); @@ -70,10 +72,12 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { _5 = &raw mut (*_1); StorageLive(_9); StorageLive(_10); + StorageLive(_11); StorageLive(_6); _6 = _5 as *mut u32 (PtrToPtr); _7 = Offset(_6, _2); StorageDead(_6); + StorageDead(_11); StorageDead(_10); StorageDead(_9); StorageDead(_5); @@ -85,6 +89,7 @@ fn slice_get_mut_usize(_1: &mut [u32], _2: usize) -> Option<&mut u32> { bb3: { StorageDead(_4); + StorageDead(_7); return; } } diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir index 0d95f81c37c..36329f8fc68 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-abort.mir @@ -19,7 +19,8 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) -> debug slice => _5; let mut _7: *mut u32; let mut _8: *mut u32; - let mut _14: &[&str]; + let mut _14: *mut [u32]; + let mut _15: &[&str]; scope 4 { let _6: usize; scope 5 { @@ -53,16 +54,16 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) -> } } scope 6 (inlined std::ptr::mut_ptr::<impl *mut [u32]>::len) { - debug self => _5; - let mut _15: *const [u32]; + debug self => _14; + let mut _16: *const [u32]; scope 7 (inlined std::ptr::metadata::<[u32]>) { - debug ptr => _15; + debug ptr => _16; scope 8 { } } } scope 9 (inlined Arguments::<'_>::new_const) { - debug pieces => _14; + debug pieces => _15; } } } @@ -74,8 +75,9 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) -> StorageLive(_5); _5 = &raw mut (*_1); StorageLive(_14); - StorageLive(_6); StorageLive(_15); + StorageLive(_6); + StorageLive(_16); _6 = SubUnchecked(_4, _3); StorageLive(_8); StorageLive(_7); @@ -96,8 +98,9 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) -> StorageDead(_12); StorageDead(_9); StorageDead(_8); - StorageDead(_15); + StorageDead(_16); StorageDead(_6); + StorageDead(_15); StorageDead(_14); StorageDead(_5); _0 = &mut (*_13); diff --git a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir index 0d95f81c37c..36329f8fc68 100644 --- a/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_index.slice_get_unchecked_mut_range.PreCodegen.after.panic-unwind.mir @@ -19,7 +19,8 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) -> debug slice => _5; let mut _7: *mut u32; let mut _8: *mut u32; - let mut _14: &[&str]; + let mut _14: *mut [u32]; + let mut _15: &[&str]; scope 4 { let _6: usize; scope 5 { @@ -53,16 +54,16 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) -> } } scope 6 (inlined std::ptr::mut_ptr::<impl *mut [u32]>::len) { - debug self => _5; - let mut _15: *const [u32]; + debug self => _14; + let mut _16: *const [u32]; scope 7 (inlined std::ptr::metadata::<[u32]>) { - debug ptr => _15; + debug ptr => _16; scope 8 { } } } scope 9 (inlined Arguments::<'_>::new_const) { - debug pieces => _14; + debug pieces => _15; } } } @@ -74,8 +75,9 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) -> StorageLive(_5); _5 = &raw mut (*_1); StorageLive(_14); - StorageLive(_6); StorageLive(_15); + StorageLive(_6); + StorageLive(_16); _6 = SubUnchecked(_4, _3); StorageLive(_8); StorageLive(_7); @@ -96,8 +98,9 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) -> StorageDead(_12); StorageDead(_9); StorageDead(_8); - StorageDead(_15); + StorageDead(_16); StorageDead(_6); + StorageDead(_15); StorageDead(_14); StorageDead(_5); _0 = &mut (*_13); diff --git a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir index c58b630a0c3..26b2663fa35 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-abort.mir @@ -42,20 +42,21 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { scope 13 (inlined NonNull::<T>::new_unchecked) { debug ptr => _9; let mut _10: *const T; + let mut _24: *mut T; scope 14 { scope 15 (inlined NonNull::<T>::new_unchecked::runtime::<T>) { - debug ptr => _9; + debug ptr => _24; scope 16 (inlined std::ptr::mut_ptr::<impl *mut T>::is_null) { - debug self => _9; - let mut _24: *mut u8; + debug self => _24; + let mut _25: *mut u8; scope 17 { scope 18 (inlined std::ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) { - debug ptr => _24; + debug ptr => _25; scope 19 (inlined std::ptr::mut_ptr::<impl *mut u8>::addr) { - debug self => _24; + debug self => _25; scope 20 { scope 21 (inlined std::ptr::mut_ptr::<impl *mut u8>::cast::<()>) { - debug self => _24; + debug self => _25; } } } @@ -131,8 +132,10 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { _9 = _4 as *mut T (PtrToPtr); StorageLive(_10); StorageLive(_24); + StorageLive(_25); _10 = _9 as *const T (PointerCoercion(MutToConstPointer)); _11 = NonNull::<T> { pointer: _10 }; + StorageDead(_25); StorageDead(_24); StorageDead(_10); StorageDead(_9); @@ -143,10 +146,10 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { StorageDead(_11); StorageDead(_7); StorageDead(_4); - _14 = Enumerate::<std::slice::Iter<'_, T>> { iter: move _13, count: const 0_usize }; + _14 = Enumerate::<std::slice::Iter<'_, T>> { iter: _13, count: const 0_usize }; StorageDead(_13); StorageLive(_15); - _15 = move _14; + _15 = _14; goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir index 1a805f0fd8d..a055612bd5f 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.enumerated_loop.PreCodegen.after.panic-unwind.mir @@ -42,20 +42,21 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { scope 13 (inlined NonNull::<T>::new_unchecked) { debug ptr => _9; let mut _10: *const T; + let mut _24: *mut T; scope 14 { scope 15 (inlined NonNull::<T>::new_unchecked::runtime::<T>) { - debug ptr => _9; + debug ptr => _24; scope 16 (inlined std::ptr::mut_ptr::<impl *mut T>::is_null) { - debug self => _9; - let mut _24: *mut u8; + debug self => _24; + let mut _25: *mut u8; scope 17 { scope 18 (inlined std::ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) { - debug ptr => _24; + debug ptr => _25; scope 19 (inlined std::ptr::mut_ptr::<impl *mut u8>::addr) { - debug self => _24; + debug self => _25; scope 20 { scope 21 (inlined std::ptr::mut_ptr::<impl *mut u8>::cast::<()>) { - debug self => _24; + debug self => _25; } } } @@ -131,8 +132,10 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { _9 = _4 as *mut T (PtrToPtr); StorageLive(_10); StorageLive(_24); + StorageLive(_25); _10 = _9 as *const T (PointerCoercion(MutToConstPointer)); _11 = NonNull::<T> { pointer: _10 }; + StorageDead(_25); StorageDead(_24); StorageDead(_10); StorageDead(_9); @@ -143,10 +146,10 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { StorageDead(_11); StorageDead(_7); StorageDead(_4); - _14 = Enumerate::<std::slice::Iter<'_, T>> { iter: move _13, count: const 0_usize }; + _14 = Enumerate::<std::slice::Iter<'_, T>> { iter: _13, count: const 0_usize }; StorageDead(_13); StorageLive(_15); - _15 = move _14; + _15 = _14; goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir index 09075eed6a9..471491108e0 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-abort.mir @@ -39,20 +39,21 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { scope 13 (inlined NonNull::<T>::new_unchecked) { debug ptr => _9; let mut _10: *const T; + let mut _22: *mut T; scope 14 { scope 15 (inlined NonNull::<T>::new_unchecked::runtime::<T>) { - debug ptr => _9; + debug ptr => _22; scope 16 (inlined std::ptr::mut_ptr::<impl *mut T>::is_null) { - debug self => _9; - let mut _22: *mut u8; + debug self => _22; + let mut _23: *mut u8; scope 17 { scope 18 (inlined std::ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) { - debug ptr => _22; + debug ptr => _23; scope 19 (inlined std::ptr::mut_ptr::<impl *mut u8>::addr) { - debug self => _22; + debug self => _23; scope 20 { scope 21 (inlined std::ptr::mut_ptr::<impl *mut u8>::cast::<()>) { - debug self => _22; + debug self => _23; } } } @@ -121,8 +122,10 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { _9 = _4 as *mut T (PtrToPtr); StorageLive(_10); StorageLive(_22); + StorageLive(_23); _10 = _9 as *const T (PointerCoercion(MutToConstPointer)); _11 = NonNull::<T> { pointer: _10 }; + StorageDead(_23); StorageDead(_22); StorageDead(_10); StorageDead(_9); @@ -134,7 +137,7 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { StorageDead(_7); StorageDead(_4); StorageLive(_14); - _14 = move _13; + _14 = _13; goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir index 47b84746468..bbf38aba91f 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.forward_loop.PreCodegen.after.panic-unwind.mir @@ -39,20 +39,21 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { scope 13 (inlined NonNull::<T>::new_unchecked) { debug ptr => _9; let mut _10: *const T; + let mut _22: *mut T; scope 14 { scope 15 (inlined NonNull::<T>::new_unchecked::runtime::<T>) { - debug ptr => _9; + debug ptr => _22; scope 16 (inlined std::ptr::mut_ptr::<impl *mut T>::is_null) { - debug self => _9; - let mut _22: *mut u8; + debug self => _22; + let mut _23: *mut u8; scope 17 { scope 18 (inlined std::ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) { - debug ptr => _22; + debug ptr => _23; scope 19 (inlined std::ptr::mut_ptr::<impl *mut u8>::addr) { - debug self => _22; + debug self => _23; scope 20 { scope 21 (inlined std::ptr::mut_ptr::<impl *mut u8>::cast::<()>) { - debug self => _22; + debug self => _23; } } } @@ -121,8 +122,10 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { _9 = _4 as *mut T (PtrToPtr); StorageLive(_10); StorageLive(_22); + StorageLive(_23); _10 = _9 as *const T (PointerCoercion(MutToConstPointer)); _11 = NonNull::<T> { pointer: _10 }; + StorageDead(_23); StorageDead(_22); StorageDead(_10); StorageDead(_9); @@ -134,7 +137,7 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { StorageDead(_7); StorageDead(_4); StorageLive(_14); - _14 = move _13; + _14 = _13; goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir index 6a99f15774f..83915d3c449 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir @@ -58,7 +58,7 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { _4 = std::ops::Range::<usize> { start: const 0_usize, end: move _3 }; StorageDead(_3); StorageLive(_5); - _5 = move _4; + _5 = _4; goto -> bb1; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir index 4f028fa0a64..0a005a460e8 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir @@ -58,7 +58,7 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { _4 = std::ops::Range::<usize> { start: const 0_usize, end: move _3 }; StorageDead(_3); StorageLive(_5); - _5 = move _4; + _5 = _4; goto -> bb1; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir index 5ed7ca5e2b8..f9c8ab4db60 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-abort.mir @@ -44,20 +44,21 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { scope 13 (inlined NonNull::<T>::new_unchecked) { debug ptr => _9; let mut _10: *const T; + let mut _24: *mut T; scope 14 { scope 15 (inlined NonNull::<T>::new_unchecked::runtime::<T>) { - debug ptr => _9; + debug ptr => _24; scope 16 (inlined std::ptr::mut_ptr::<impl *mut T>::is_null) { - debug self => _9; - let mut _24: *mut u8; + debug self => _24; + let mut _25: *mut u8; scope 17 { scope 18 (inlined std::ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) { - debug ptr => _24; + debug ptr => _25; scope 19 (inlined std::ptr::mut_ptr::<impl *mut u8>::addr) { - debug self => _24; + debug self => _25; scope 20 { scope 21 (inlined std::ptr::mut_ptr::<impl *mut u8>::cast::<()>) { - debug self => _24; + debug self => _25; } } } @@ -133,8 +134,10 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { _9 = _4 as *mut T (PtrToPtr); StorageLive(_10); StorageLive(_24); + StorageLive(_25); _10 = _9 as *const T (PointerCoercion(MutToConstPointer)); _11 = NonNull::<T> { pointer: _10 }; + StorageDead(_25); StorageDead(_24); StorageDead(_10); StorageDead(_9); @@ -145,10 +148,10 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { StorageDead(_11); StorageDead(_7); StorageDead(_4); - _14 = Rev::<std::slice::Iter<'_, T>> { iter: move _13 }; + _14 = Rev::<std::slice::Iter<'_, T>> { iter: _13 }; StorageDead(_13); StorageLive(_15); - _15 = move _14; + _15 = _14; goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir index bbb979d23b3..65f423ac326 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.reverse_loop.PreCodegen.after.panic-unwind.mir @@ -44,20 +44,21 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { scope 13 (inlined NonNull::<T>::new_unchecked) { debug ptr => _9; let mut _10: *const T; + let mut _24: *mut T; scope 14 { scope 15 (inlined NonNull::<T>::new_unchecked::runtime::<T>) { - debug ptr => _9; + debug ptr => _24; scope 16 (inlined std::ptr::mut_ptr::<impl *mut T>::is_null) { - debug self => _9; - let mut _24: *mut u8; + debug self => _24; + let mut _25: *mut u8; scope 17 { scope 18 (inlined std::ptr::mut_ptr::<impl *mut T>::is_null::runtime_impl) { - debug ptr => _24; + debug ptr => _25; scope 19 (inlined std::ptr::mut_ptr::<impl *mut u8>::addr) { - debug self => _24; + debug self => _25; scope 20 { scope 21 (inlined std::ptr::mut_ptr::<impl *mut u8>::cast::<()>) { - debug self => _24; + debug self => _25; } } } @@ -133,8 +134,10 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { _9 = _4 as *mut T (PtrToPtr); StorageLive(_10); StorageLive(_24); + StorageLive(_25); _10 = _9 as *const T (PointerCoercion(MutToConstPointer)); _11 = NonNull::<T> { pointer: _10 }; + StorageDead(_25); StorageDead(_24); StorageDead(_10); StorageDead(_9); @@ -145,10 +148,10 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { StorageDead(_11); StorageDead(_7); StorageDead(_4); - _14 = Rev::<std::slice::Iter<'_, T>> { iter: move _13 }; + _14 = Rev::<std::slice::Iter<'_, T>> { iter: _13 }; StorageDead(_13); StorageLive(_15); - _15 = move _14; + _15 = _14; goto -> bb4; } diff --git a/tests/mir-opt/pre-codegen/try_identity.new.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/try_identity.new.PreCodegen.after.mir index 0bf4a267002..c1d4d4871d0 100644 --- a/tests/mir-opt/pre-codegen/try_identity.new.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/try_identity.new.PreCodegen.after.mir @@ -31,13 +31,13 @@ fn new(_1: Result<T, E>) -> Result<T, E> { bb1: { _3 = move ((_1 as Ok).0: T); - _4 = ControlFlow::<E, T>::Continue(move _3); + _4 = ControlFlow::<E, T>::Continue(_3); goto -> bb3; } bb2: { _5 = move ((_1 as Err).0: E); - _4 = ControlFlow::<E, T>::Break(move _5); + _4 = ControlFlow::<E, T>::Break(_5); goto -> bb3; } @@ -48,14 +48,14 @@ fn new(_1: Result<T, E>) -> Result<T, E> { bb4: { _7 = move ((_4 as Continue).0: T); - _0 = Result::<T, E>::Ok(move _7); + _0 = Result::<T, E>::Ok(_7); StorageDead(_4); goto -> bb6; } bb5: { _8 = move ((_4 as Break).0: E); - _0 = Result::<T, E>::Err(move _8); + _0 = Result::<T, E>::Err(_8); StorageDead(_4); goto -> bb6; } diff --git a/tests/mir-opt/pre-codegen/try_identity.old.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/try_identity.old.PreCodegen.after.mir index 7ccb8b0430d..d6883ac9fda 100644 --- a/tests/mir-opt/pre-codegen/try_identity.old.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/try_identity.old.PreCodegen.after.mir @@ -20,13 +20,13 @@ fn old(_1: Result<T, E>) -> Result<T, E> { bb1: { _3 = move ((_1 as Ok).0: T); - _0 = Result::<T, E>::Ok(move _3); + _0 = Result::<T, E>::Ok(_3); goto -> bb3; } bb2: { _4 = move ((_1 as Err).0: E); - _0 = Result::<T, E>::Err(move _4); + _0 = Result::<T, E>::Err(_4); goto -> bb3; } diff --git a/tests/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff b/tests/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff index a12db0a730c..e7280f14837 100644 --- a/tests/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff +++ b/tests/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff @@ -4,92 +4,96 @@ fn identity(_1: Result<i32, i32>) -> Result<i32, i32> { debug x => _1; let mut _0: std::result::Result<i32, i32>; - let mut _2: i32; - let mut _3: std::ops::ControlFlow<std::result::Result<std::convert::Infallible, i32>, i32>; - let mut _4: std::result::Result<i32, i32>; - let mut _5: isize; - let _6: std::result::Result<std::convert::Infallible, i32>; - let mut _7: std::result::Result<std::convert::Infallible, i32>; - let _8: i32; + let mut _2: std::ops::ControlFlow<std::result::Result<std::convert::Infallible, i32>, i32>; + let mut _3: std::result::Result<i32, i32>; + let mut _4: isize; + let _5: std::result::Result<std::convert::Infallible, i32>; + let mut _6: std::result::Result<std::convert::Infallible, i32>; + let _7: i32; scope 1 { - debug residual => _6; + debug residual => _5; scope 2 { scope 8 (inlined #[track_caller] <Result<i32, i32> as FromResidual<Result<Infallible, i32>>>::from_residual) { debug residual => _6; - let _13: i32; - let mut _14: i32; + let _12: i32; scope 9 { - debug e => _13; + debug e => _12; scope 10 (inlined <i32 as From<i32>>::from) { - debug t => _13; + debug t => _12; } } } } } scope 3 { - debug val => _8; + debug val => _7; scope 4 { } } scope 5 (inlined <Result<i32, i32> as Try>::branch) { - debug self => _1; - let mut _9: isize; + debug self => _3; + let mut _8: isize; + let _9: i32; let _10: i32; - let _11: i32; - let mut _12: std::result::Result<std::convert::Infallible, i32>; + let mut _11: std::result::Result<std::convert::Infallible, i32>; scope 6 { - debug v => _10; + debug v => _9; } scope 7 { - debug e => _11; + debug e => _10; } } bb0: { + StorageLive(_2); StorageLive(_3); + _3 = _1; + StorageLive(_8); StorageLive(_9); StorageLive(_10); - StorageLive(_11); - _9 = discriminant(_1); - switchInt(move _9) -> [0: bb5, 1: bb4, otherwise: bb6]; + _8 = discriminant(_1); + switchInt(move _8) -> [0: bb5, 1: bb4, otherwise: bb6]; } bb1: { - _8 = ((_3 as Continue).0: i32); - _0 = Result::<i32, i32>::Ok(_8); - StorageDead(_3); + _7 = ((_2 as Continue).0: i32); + _0 = Result::<i32, i32>::Ok(_7); + StorageDead(_2); return; } bb2: { - _6 = ((_3 as Break).0: std::result::Result<std::convert::Infallible, i32>); - _13 = ((_6 as Err).0: i32); - _0 = Result::<i32, i32>::Err(move _13); - StorageDead(_3); + _5 = ((_2 as Break).0: std::result::Result<std::convert::Infallible, i32>); + StorageLive(_6); + _6 = _5; + _12 = move ((_5 as Err).0: i32); + _0 = Result::<i32, i32>::Err(_12); + StorageDead(_6); + StorageDead(_2); return; } bb3: { - StorageDead(_11); StorageDead(_10); StorageDead(_9); - _5 = discriminant(_3); - switchInt(move _5) -> [0: bb1, 1: bb2, otherwise: bb6]; + StorageDead(_8); + StorageDead(_3); + _4 = discriminant(_2); + switchInt(move _4) -> [0: bb1, 1: bb2, otherwise: bb6]; } bb4: { - _11 = ((_1 as Err).0: i32); - StorageLive(_12); - _12 = Result::<Infallible, i32>::Err(move _11); - _3 = ControlFlow::<Result<Infallible, i32>, i32>::Break(move _12); - StorageDead(_12); + _10 = move ((_1 as Err).0: i32); + StorageLive(_11); + _11 = Result::<Infallible, i32>::Err(_10); + _2 = ControlFlow::<Result<Infallible, i32>, i32>::Break(move _11); + StorageDead(_11); goto -> bb3; } bb5: { - _10 = ((_1 as Ok).0: i32); - _3 = ControlFlow::<Result<Infallible, i32>, i32>::Continue(move _10); + _9 = move ((_1 as Ok).0: i32); + _2 = ControlFlow::<Result<Infallible, i32>, i32>::Continue(_9); goto -> bb3; } diff --git a/tests/mir-opt/separate_const_switch.too_complex.SeparateConstSwitch.diff b/tests/mir-opt/separate_const_switch.too_complex.SeparateConstSwitch.diff index 80f40b86919..294bfa661cf 100644 --- a/tests/mir-opt/separate_const_switch.too_complex.SeparateConstSwitch.diff +++ b/tests/mir-opt/separate_const_switch.too_complex.SeparateConstSwitch.diff @@ -7,24 +7,21 @@ let mut _2: std::ops::ControlFlow<usize, i32>; let mut _3: isize; let _4: i32; - let mut _5: i32; - let _6: usize; - let mut _7: usize; - let mut _8: isize; - let _9: i32; - let mut _10: i32; - let _11: usize; + let _5: usize; + let mut _6: isize; + let _7: i32; + let _8: usize; scope 1 { debug v => _4; } scope 2 { - debug r => _6; + debug r => _5; } scope 3 { - debug v => _9; + debug v => _7; } scope 4 { - debug r => _11; + debug r => _8; } bb0: { @@ -34,8 +31,8 @@ } bb1: { - _6 = ((_1 as Err).0: usize); - _2 = ControlFlow::<usize, i32>::Break(_6); + _5 = ((_1 as Err).0: usize); + _2 = ControlFlow::<usize, i32>::Break(_5); goto -> bb3; } @@ -46,21 +43,21 @@ } bb3: { - _8 = discriminant(_2); - switchInt(move _8) -> [0: bb5, 1: bb4, otherwise: bb7]; + _6 = discriminant(_2); + switchInt(move _6) -> [0: bb5, 1: bb4, otherwise: bb7]; } bb4: { - StorageLive(_11); - _11 = ((_2 as Break).0: usize); - _0 = Option::<i32>::None; - StorageDead(_11); + StorageLive(_8); + _8 = ((_2 as Break).0: usize); + _0 = const Option::<i32>::None; + StorageDead(_8); goto -> bb6; } bb5: { - _9 = ((_2 as Continue).0: i32); - _0 = Option::<i32>::Some(_9); + _7 = ((_2 as Continue).0: i32); + _0 = Option::<i32>::Some(_7); goto -> bb6; } @@ -74,3 +71,7 @@ } } + ALLOC0 (size: 8, align: 4) { + 00 00 00 00 __ __ __ __ │ ....░░░░ + } + diff --git a/tests/mir-opt/simplify_match.main.GVN.panic-abort.diff b/tests/mir-opt/simplify_match.main.GVN.panic-abort.diff index d7ade041e4c..33b36f660cb 100644 --- a/tests/mir-opt/simplify_match.main.GVN.panic-abort.diff +++ b/tests/mir-opt/simplify_match.main.GVN.panic-abort.diff @@ -10,8 +10,15 @@ } bb0: { + StorageLive(_1); +- StorageLive(_2); ++ nop; _2 = const false; -- switchInt(_2) -> [0: bb2, otherwise: bb1]; +- _1 = _2; +- StorageDead(_2); +- switchInt(_1) -> [0: bb2, otherwise: bb1]; ++ _1 = const false; ++ nop; + switchInt(const false) -> [0: bb2, otherwise: bb1]; } @@ -20,6 +27,7 @@ } bb2: { + StorageDead(_1); return; } } diff --git a/tests/mir-opt/simplify_match.main.GVN.panic-unwind.diff b/tests/mir-opt/simplify_match.main.GVN.panic-unwind.diff index 931c5c43c4c..e5c3adff623 100644 --- a/tests/mir-opt/simplify_match.main.GVN.panic-unwind.diff +++ b/tests/mir-opt/simplify_match.main.GVN.panic-unwind.diff @@ -10,8 +10,15 @@ } bb0: { + StorageLive(_1); +- StorageLive(_2); ++ nop; _2 = const false; -- switchInt(_2) -> [0: bb2, otherwise: bb1]; +- _1 = _2; +- StorageDead(_2); +- switchInt(_1) -> [0: bb2, otherwise: bb1]; ++ _1 = const false; ++ nop; + switchInt(const false) -> [0: bb2, otherwise: bb1]; } @@ -20,6 +27,7 @@ } bb2: { + StorageDead(_1); return; } } diff --git a/tests/rustdoc/issue-52873.rs b/tests/rustdoc-ui/ice-blanket-impl-52873.rs index 8000ce73bd4..2520957bd00 100644 --- a/tests/rustdoc/issue-52873.rs +++ b/tests/rustdoc-ui/ice-blanket-impl-52873.rs @@ -1,3 +1,7 @@ +// check-pass +// https://github.com/rust-lang/rust/issues/52873 +#![crate_name="foo"] + // Regression test for #52873. We used to ICE due to unexpected // overflows when checking for "blanket impl inclusion". diff --git a/tests/rustdoc/issue-55001.rs b/tests/rustdoc-ui/ice-blanket-impl-selection-55001.rs index f6c7f9a3d08..babcb3dda14 100644 --- a/tests/rustdoc/issue-55001.rs +++ b/tests/rustdoc-ui/ice-blanket-impl-selection-55001.rs @@ -1,3 +1,7 @@ +// check-pass +// https://github.com/rust-lang/rust/issues/55001 +#![crate_name="foo"] + // Regression test for issue #55001. Previously, we would incorrectly // cache certain trait selection results when checking for blanket impls, // resulting in an ICE when we tried to confirm the cached ParamCandidate diff --git a/tests/rustdoc/issue-50159.rs b/tests/rustdoc/auto-trait-bounds-by-associated-type-50159.rs index 13bedd5dbb0..0663ed5fc81 100644 --- a/tests/rustdoc/issue-50159.rs +++ b/tests/rustdoc/auto-trait-bounds-by-associated-type-50159.rs @@ -1,3 +1,6 @@ +// https://github.com/rust-lang/rust/issues/50159 +#![crate_name="foo"] + pub trait Signal { type Item; } @@ -10,7 +13,7 @@ impl<B, C> Signal2 for B where B: Signal<Item = C> { type Item2 = C; } -// @has issue_50159/struct.Switch.html +// @has foo/struct.Switch.html // @has - '//h3[@class="code-header"]' 'impl<B> Send for Switch<B>where <B as Signal>::Item: Send' // @has - '//h3[@class="code-header"]' 'impl<B> Sync for Switch<B>where <B as Signal>::Item: Sync' // @count - '//*[@id="implementations-list"]//*[@class="impl"]' 0 diff --git a/tests/rustdoc/issue-54705.rs b/tests/rustdoc/auto-trait-bounds-inference-variables-54705.rs index a886eb0de24..00be0042fb0 100644 --- a/tests/rustdoc/issue-54705.rs +++ b/tests/rustdoc/auto-trait-bounds-inference-variables-54705.rs @@ -1,6 +1,9 @@ +// https://github.com/rust-lang/rust/issues/54705 +#![crate_name="foo"] + pub trait ScopeHandle<'scope> {} -// @has issue_54705/struct.ScopeFutureContents.html +// @has foo/struct.ScopeFutureContents.html // @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ // "impl<'scope, S> Send for ScopeFutureContents<'scope, S>where S: Sync" // diff --git a/tests/rustdoc/issue-51236.rs b/tests/rustdoc/auto-trait-bounds-where-51236.rs index 04664805a88..30c81e79601 100644 --- a/tests/rustdoc/issue-51236.rs +++ b/tests/rustdoc/auto-trait-bounds-where-51236.rs @@ -1,3 +1,6 @@ +// https://github.com/rust-lang/rust/issues/51236 +#![crate_name="foo"] + use std::marker::PhantomData; pub mod traits { @@ -6,7 +9,7 @@ pub mod traits { } } -// @has issue_51236/struct.Owned.html +// @has foo/struct.Owned.html // @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ // "impl<T> Send for Owned<T>where <T as Owned<'static>>::Reader: Send" pub struct Owned<T> where T: for<'a> ::traits::Owned<'a> { diff --git a/tests/rustdoc/issue-55321.rs b/tests/rustdoc/auto-trait-negative-impl-55321.rs index d3c2070d915..e9be1ff854e 100644 --- a/tests/rustdoc/issue-55321.rs +++ b/tests/rustdoc/auto-trait-negative-impl-55321.rs @@ -1,6 +1,9 @@ +// https://github.com/rust-lang/rust/issues/55321 +#![crate_name="foo"] + #![feature(negative_impls)] -// @has issue_55321/struct.A.html +// @has foo/struct.A.html // @has - '//*[@id="trait-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ // "impl !Send for A" // @has - '//*[@id="trait-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ @@ -10,7 +13,7 @@ pub struct A(); impl !Send for A {} impl !Sync for A {} -// @has issue_55321/struct.B.html +// @has foo/struct.B.html // @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ // "impl<T> !Send for B<T>" // @has - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]//h3[@class="code-header"]' \ diff --git a/tests/rustdoc/blank-line-in-doc-block-47197.rs b/tests/rustdoc/blank-line-in-doc-block-47197.rs new file mode 100644 index 00000000000..79492b4fa76 --- /dev/null +++ b/tests/rustdoc/blank-line-in-doc-block-47197.rs @@ -0,0 +1,11 @@ +// https://github.com/rust-lang/rust/issues/47197 +#![crate_name="foo"] + +// @has foo/fn.whose_woods_these_are_i_think_i_know.html + +/** +* snow + +* ice +*/ +pub fn whose_woods_these_are_i_think_i_know() {} diff --git a/tests/rustdoc/issue-54478-demo-allocator.rs b/tests/rustdoc/demo-allocator-54478.rs index 4811f363bc9..39acee36d88 100644 --- a/tests/rustdoc/issue-54478-demo-allocator.rs +++ b/tests/rustdoc/demo-allocator-54478.rs @@ -1,3 +1,6 @@ +// https://github.com/rust-lang/rust/issues/54478 +#![crate_name="foo"] + // Issue #54478: regression test showing that we can demonstrate // `#[global_allocator]` in code blocks built by `rustdoc`. // diff --git a/tests/rustdoc/issue-35169-2.rs b/tests/rustdoc/deref-mut-35169-2.rs index f08466baf8b..c82323ddc6a 100644 --- a/tests/rustdoc/issue-35169-2.rs +++ b/tests/rustdoc/deref-mut-35169-2.rs @@ -1,3 +1,6 @@ +// https://github.com/rust-lang/rust/issues/35169 +#![crate_name="foo"] + use std::ops::Deref; use std::ops::DerefMut; @@ -23,7 +26,7 @@ impl DerefMut for Bar { fn deref_mut(&mut self) -> &mut Foo { loop {} } } -// @has issue_35169_2/struct.Bar.html +// @has foo/struct.Bar.html // @has - '//*[@id="method.by_ref"]//h4[@class="code-header"]' 'fn by_ref(&self)' // @has - '//*[@id="method.by_ref"]' 'fn by_ref(&self)' // @has - '//*[@id="method.by_explicit_ref"]//h4[@class="code-header"]' 'fn by_explicit_ref(self: &Foo)' diff --git a/tests/rustdoc/issue-35169.rs b/tests/rustdoc/deref-mut-35169.rs index 70a2265c806..44afaf2e903 100644 --- a/tests/rustdoc/issue-35169.rs +++ b/tests/rustdoc/deref-mut-35169.rs @@ -1,3 +1,6 @@ +// https://github.com/rust-lang/rust/issues/35169 +#![crate_name="foo"] + use std::ops::Deref; pub struct Foo; @@ -18,7 +21,7 @@ impl Deref for Bar { fn deref(&self) -> &Foo { loop {} } } -// @has issue_35169/struct.Bar.html +// @has foo/struct.Bar.html // @has - '//*[@id="method.by_ref"]//h4[@class="code-header"]' 'fn by_ref(&self)' // @has - '//*[@id="method.by_ref"]' 'fn by_ref(&self)' // @has - '//*[@id="method.by_explicit_ref"]//h4[@class="code-header"]' 'fn by_explicit_ref(self: &Foo)' diff --git a/tests/rustdoc/issue-42760.rs b/tests/rustdoc/doc-attr-comment-mix-42760.rs index a5394c7d92a..16c1705eb00 100644 --- a/tests/rustdoc/issue-42760.rs +++ b/tests/rustdoc/doc-attr-comment-mix-42760.rs @@ -1,6 +1,9 @@ +// https://github.com/rust-lang/rust/issues/42760 +#![crate_name="foo"] + #![allow(rustdoc::invalid_rust_codeblocks)] -// @has issue_42760/struct.NonGen.html +// @has foo/struct.NonGen.html // @has - '//h2' 'Example' /// Item docs. diff --git a/tests/rustdoc/issue-41783.codeblock.html b/tests/rustdoc/doctest/doctest-escape-boring-41783.codeblock.html index 3bca4536cd5..3bca4536cd5 100644 --- a/tests/rustdoc/issue-41783.codeblock.html +++ b/tests/rustdoc/doctest/doctest-escape-boring-41783.codeblock.html diff --git a/tests/rustdoc/issue-41783.rs b/tests/rustdoc/doctest/doctest-escape-boring-41783.rs index 7578d49daa5..7782e148fd9 100644 --- a/tests/rustdoc/issue-41783.rs +++ b/tests/rustdoc/doctest/doctest-escape-boring-41783.rs @@ -1,4 +1,7 @@ -// @has issue_41783/struct.Foo.html +// https://github.com/rust-lang/rust/issues/41783 +#![crate_name="foo"] + +// @has foo/struct.Foo.html // @!hasraw - 'space' // @!hasraw - 'comment' // @hasraw - '<span class="attr">#[outer]' diff --git a/tests/rustdoc/enum-variant-reexport-35488.rs b/tests/rustdoc/enum-variant-reexport-35488.rs new file mode 100644 index 00000000000..ed955dcd770 --- /dev/null +++ b/tests/rustdoc/enum-variant-reexport-35488.rs @@ -0,0 +1,16 @@ +// https://github.com/rust-lang/rust/issues/35488 +#![crate_name="foo"] + +mod foo { + pub enum Foo { + Bar, + } + pub use self::Foo::*; +} + +// @has 'foo/index.html' '//code' 'pub use self::Foo::*;' +// @has 'foo/enum.Foo.html' +pub use self::foo::*; + +// @has 'foo/index.html' '//code' 'pub use std::option::Option::None;' +pub use std::option::Option::None; diff --git a/tests/rustdoc/issue-53689.rs b/tests/rustdoc/impl-blanket-53689.rs index 832140e061b..7c2edd01a60 100644 --- a/tests/rustdoc/issue-53689.rs +++ b/tests/rustdoc/impl-blanket-53689.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/53689 // aux-build:issue-53689.rs #![crate_name = "foo"] diff --git a/tests/rustdoc/issue-43869.rs b/tests/rustdoc/impl-trait-43869.rs index 767d09d8558..9c4ed841f79 100644 --- a/tests/rustdoc/issue-43869.rs +++ b/tests/rustdoc/impl-trait-43869.rs @@ -1,3 +1,6 @@ +// https://github.com/rust-lang/rust/issues/43869 +#![crate_name="foo"] + pub fn g() -> impl Iterator<Item=u8> { Some(1u8).into_iter() } @@ -58,15 +61,15 @@ pub fn test_44731_4() -> Box<Iterator<Item=impl Clone>> { Box::new(g()) } -// @has issue_43869/fn.g.html -// @has issue_43869/fn.h.html -// @has issue_43869/fn.i.html -// @has issue_43869/fn.j.html -// @has issue_43869/fn.k.html -// @has issue_43869/fn.l.html -// @has issue_43869/fn.m.html -// @has issue_43869/fn.n.html -// @has issue_43869/fn.o.html -// @has issue_43869/fn.test_44731_0.html -// @has issue_43869/fn.test_44731_1.html -// @has issue_43869/fn.test_44731_4.html +// @has foo/fn.g.html +// @has foo/fn.h.html +// @has foo/fn.i.html +// @has foo/fn.j.html +// @has foo/fn.k.html +// @has foo/fn.l.html +// @has foo/fn.m.html +// @has foo/fn.n.html +// @has foo/fn.o.html +// @has foo/fn.test_44731_0.html +// @has foo/fn.test_44731_1.html +// @has foo/fn.test_44731_4.html diff --git a/tests/rustdoc/auxiliary/issue-46727.rs b/tests/rustdoc/inline_cross/auxiliary/issue-46727.rs index 30dccfa77b5..30dccfa77b5 100644 --- a/tests/rustdoc/auxiliary/issue-46727.rs +++ b/tests/rustdoc/inline_cross/auxiliary/issue-46727.rs diff --git a/tests/rustdoc/issue-46727.rs b/tests/rustdoc/inline_cross/const-eval-46727.rs index 8cfc4827a7f..d0ce9c34f51 100644 --- a/tests/rustdoc/issue-46727.rs +++ b/tests/rustdoc/inline_cross/const-eval-46727.rs @@ -1,7 +1,10 @@ +// https://github.com/rust-lang/rust/issues/46727 +#![crate_name="foo"] + // aux-build:issue-46727.rs extern crate issue_46727; -// @has issue_46727/trait.Foo.html +// @has foo/trait.Foo.html // @has - '//h3[@class="code-header"]' 'impl<T> Foo for Bar<[T; 3]>' pub use issue_46727::{Foo, Bar}; diff --git a/tests/rustdoc/issue-55364.rs b/tests/rustdoc/intra-doc/module-scope-name-resolution-55364.rs index 941cb3ce1ca..c07aba628c9 100644 --- a/tests/rustdoc/issue-55364.rs +++ b/tests/rustdoc/intra-doc/module-scope-name-resolution-55364.rs @@ -1,6 +1,9 @@ +// https://github.com/rust-lang/rust/issues/55364 +#![crate_name="foo"] + // First a module with inner documentation -// @has issue_55364/subone/index.html +// @has foo/subone/index.html // These foo/bar links in the module's documentation should refer inside `subone` // @has - '//section[@id="main-content"]/details[@open=""]/div[@class="docblock"]//a[@href="fn.foo.html"]' 'foo' // @has - '//section[@id="main-content"]/details[@open=""]/div[@class="docblock"]//a[@href="fn.bar.html"]' 'bar' @@ -8,12 +11,12 @@ pub mod subone { //! See either [foo] or [bar]. // This should refer to subone's `bar` - // @has issue_55364/subone/fn.foo.html + // @has foo/subone/fn.foo.html // @has - '//section[@id="main-content"]/details/div[@class="docblock"]//a[@href="fn.bar.html"]' 'bar' /// See [bar] pub fn foo() {} // This should refer to subone's `foo` - // @has issue_55364/subone/fn.bar.html + // @has foo/subone/fn.bar.html // @has - '//section[@id="main-content"]/details/div[@class="docblock"]//a[@href="fn.foo.html"]' 'foo' /// See [foo] pub fn bar() {} @@ -21,7 +24,7 @@ pub mod subone { // A module with outer documentation -// @has issue_55364/subtwo/index.html +// @has foo/subtwo/index.html // These foo/bar links in the module's documentation should not reference inside `subtwo` // @!has - '//section[@id="main-content"]/div[@class="docblock"]//a[@href="fn.foo.html"]' 'foo' // @!has - '//section[@id="main-content"]/div[@class="docblock"]//a[@href="fn.bar.html"]' 'bar' @@ -36,13 +39,13 @@ pub mod subtwo { // Despite the module's docs referring to the top level foo/bar, // this should refer to subtwo's `bar` - // @has issue_55364/subtwo/fn.foo.html + // @has foo/subtwo/fn.foo.html // @has - '//section[@id="main-content"]/details/div[@class="docblock"]//a[@href="fn.bar.html"]' 'bar' /// See [bar] pub fn foo() {} // Despite the module's docs referring to the top level foo/bar, // this should refer to subtwo's `foo` - // @has issue_55364/subtwo/fn.bar.html + // @has foo/subtwo/fn.bar.html // @has - '//section[@id="main-content"]/details/div[@class="docblock"]//a[@href="fn.foo.html"]' 'foo' /// See [foo] pub fn bar() {} @@ -57,7 +60,7 @@ pub fn bar() {} // This module refers to the outer foo/bar by means of `super::` -// @has issue_55364/subthree/index.html +// @has foo/subthree/index.html // This module should also refer to the top level foo/bar // @has - '//section[@id="main-content"]/details/div[@class="docblock"]//a[@href="../fn.foo.html"]' 'foo' // @has - '//section[@id="main-content"]/details/div[@class="docblock"]//a[@href="../fn.bar.html"]' 'bar' @@ -67,7 +70,7 @@ pub mod subthree { // Next we go *deeper* - In order to ensure it's not just "this or parent" // we test `crate::` and a `super::super::...` chain -// @has issue_55364/subfour/subfive/subsix/subseven/subeight/index.html +// @has foo/subfour/subfive/subsix/subseven/subeight/index.html // @has - '//section[@id="main-content"]/ul[@class="item-table"]//div[@class="desc docblock-short"]//a[@href="../../../../../subone/fn.foo.html"]' 'other foo' // @has - '//section[@id="main-content"]/ul[@class="item-table"]//div[@class="desc docblock-short"]//a[@href="../../../../../subtwo/fn.bar.html"]' 'other bar' pub mod subfour { diff --git a/tests/rustdoc/issue-35488.rs b/tests/rustdoc/issue-35488.rs deleted file mode 100644 index c1bf9ceeac1..00000000000 --- a/tests/rustdoc/issue-35488.rs +++ /dev/null @@ -1,13 +0,0 @@ -mod foo { - pub enum Foo { - Bar, - } - pub use self::Foo::*; -} - -// @has 'issue_35488/index.html' '//code' 'pub use self::Foo::*;' -// @has 'issue_35488/enum.Foo.html' -pub use self::foo::*; - -// @has 'issue_35488/index.html' '//code' 'pub use std::option::Option::None;' -pub use std::option::Option::None; diff --git a/tests/rustdoc/issue-46377.rs b/tests/rustdoc/issue-46377.rs deleted file mode 100644 index 1311b4721e2..00000000000 --- a/tests/rustdoc/issue-46377.rs +++ /dev/null @@ -1,3 +0,0 @@ -// @has 'issue_46377/index.html' '//*[@class="desc docblock-short"]' 'Check out this struct!' -/// # Check out this struct! -pub struct SomeStruct; diff --git a/tests/rustdoc/issue-47197-blank-line-in-doc-block.rs b/tests/rustdoc/issue-47197-blank-line-in-doc-block.rs deleted file mode 100644 index 19994475de2..00000000000 --- a/tests/rustdoc/issue-47197-blank-line-in-doc-block.rs +++ /dev/null @@ -1,8 +0,0 @@ -// @has issue_47197_blank_line_in_doc_block/fn.whose_woods_these_are_i_think_i_know.html - -/** -* snow - -* ice -*/ -pub fn whose_woods_these_are_i_think_i_know() {} diff --git a/tests/rustdoc/issue-46380-2.rs b/tests/rustdoc/public-impl-mention-private-generic-46380-2.rs index 7004d18dc66..96ebd888eb5 100644 --- a/tests/rustdoc/issue-46380-2.rs +++ b/tests/rustdoc/public-impl-mention-private-generic-46380-2.rs @@ -1,6 +1,9 @@ +// https://github.com/rust-lang/rust/issues/46380 +#![crate_name="foo"] + pub trait PublicTrait<T> {} -// @has issue_46380_2/struct.PublicStruct.html +// @has foo/struct.PublicStruct.html pub struct PublicStruct; // @!has - '//*[@class="impl"]' 'impl PublicTrait<PrivateStruct> for PublicStruct' diff --git a/tests/rustdoc/issue-53812.rs b/tests/rustdoc/sort-53812.rs index dc1eb304c3d..968ae035043 100644 --- a/tests/rustdoc/issue-53812.rs +++ b/tests/rustdoc/sort-53812.rs @@ -1,3 +1,6 @@ +// https://github.com/rust-lang/rust/issues/53812 +#![crate_name="foo"] + pub trait MyIterator {} pub struct MyStruct<T>(T); @@ -11,7 +14,7 @@ macro_rules! array_impls { } } -// @has issue_53812/trait.MyIterator.html +// @has foo/trait.MyIterator.html // @has - '//*[@id="implementors-list"]/*[@class="impl"][1]' 'MyStruct<[T; 0]>' // @has - '//*[@id="implementors-list"]/*[@class="impl"][2]' 'MyStruct<[T; 1]>' // @has - '//*[@id="implementors-list"]/*[@class="impl"][3]' 'MyStruct<[T; 2]>' diff --git a/tests/rustdoc/summary-header-46377.rs b/tests/rustdoc/summary-header-46377.rs new file mode 100644 index 00000000000..aec74f493d4 --- /dev/null +++ b/tests/rustdoc/summary-header-46377.rs @@ -0,0 +1,6 @@ +// https://github.com/rust-lang/rust/issues/46377 +#![crate_name="foo"] + +// @has 'foo/index.html' '//*[@class="desc docblock-short"]' 'Check out this struct!' +/// # Check out this struct! +pub struct SomeStruct; diff --git a/tests/ui-fulldeps/stable-mir/check_allocation.rs b/tests/ui-fulldeps/stable-mir/check_allocation.rs index 7ce3597206b..93def93127c 100644 --- a/tests/ui-fulldeps/stable-mir/check_allocation.rs +++ b/tests/ui-fulldeps/stable-mir/check_allocation.rs @@ -111,7 +111,7 @@ fn check_other_consts(item: CrateItem) { // Instance body will force constant evaluation. let body = Instance::try_from(item).unwrap().body().unwrap(); let assigns = collect_consts(&body); - assert_eq!(assigns.len(), 9); + assert_eq!(assigns.len(), 8); for (name, alloc) in assigns { match name.as_str() { "_max_u128" => { diff --git a/tests/ui/async-await/issues/issue-65159.rs b/tests/ui/async-await/issues/issue-65159.rs index aed111e2144..7197a4fb91a 100644 --- a/tests/ui/async-await/issues/issue-65159.rs +++ b/tests/ui/async-await/issues/issue-65159.rs @@ -5,7 +5,7 @@ async fn copy() -> Result<()> //~^ ERROR enum takes 2 generic arguments { - Ok(()) //~ ERROR: type annotations needed + Ok(()) } -fn main() { } +fn main() {} diff --git a/tests/ui/async-await/issues/issue-65159.stderr b/tests/ui/async-await/issues/issue-65159.stderr index 77a0ea5027c..19512116a66 100644 --- a/tests/ui/async-await/issues/issue-65159.stderr +++ b/tests/ui/async-await/issues/issue-65159.stderr @@ -11,18 +11,6 @@ help: add missing generic argument LL | async fn copy() -> Result<(), E> | +++ -error[E0282]: type annotations needed - --> $DIR/issue-65159.rs:8:5 - | -LL | Ok(()) - | ^^ cannot infer type of the type parameter `E` declared on the enum `Result` - | -help: consider specifying the generic arguments - | -LL | Ok::<(), E>(()) - | +++++++++ - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0107, E0282. -For more information about an error, try `rustc --explain E0107`. +For more information about this error, try `rustc --explain E0107`. diff --git a/tests/ui/binop/binary-op-suggest-deref.rs b/tests/ui/binop/binary-op-suggest-deref.rs index 57f24a4c28e..ae442a0d0b4 100644 --- a/tests/ui/binop/binary-op-suggest-deref.rs +++ b/tests/ui/binop/binary-op-suggest-deref.rs @@ -72,4 +72,12 @@ fn baz() { //~^ERROR can't compare `str` with `&String` [E0277] } +fn qux() { + // Issue #119352 + const FOO: i32 = 42; + let _ = FOO & (*"Sized".to_string().into_boxed_str()); + //~^ ERROR the size for values of type `str` cannot be known at compilation time + //~| ERROR no implementation for `i32 & str` [E0277] +} + fn main() {} diff --git a/tests/ui/binop/binary-op-suggest-deref.stderr b/tests/ui/binop/binary-op-suggest-deref.stderr index 68b5a24bf97..a98a2ab0706 100644 --- a/tests/ui/binop/binary-op-suggest-deref.stderr +++ b/tests/ui/binop/binary-op-suggest-deref.stderr @@ -295,7 +295,28 @@ help: consider dereferencing here LL | _ = partial[..3] == *string_ref; | + -error: aborting due to 22 previous errors +error[E0277]: no implementation for `i32 & str` + --> $DIR/binary-op-suggest-deref.rs:78:17 + | +LL | let _ = FOO & (*"Sized".to_string().into_boxed_str()); + | ^ no implementation for `i32 & str` + | + = help: the trait `BitAnd<str>` is not implemented for `i32` + = help: the following other types implement trait `BitAnd<Rhs>`: + <i32 as BitAnd> + <i32 as BitAnd<&i32>> + <&'a i32 as BitAnd<i32>> + <&i32 as BitAnd<&i32>> + +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/binary-op-suggest-deref.rs:78:17 + | +LL | let _ = FOO & (*"Sized".to_string().into_boxed_str()); + | ^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `str` + +error: aborting due to 24 previous errors Some errors have detailed explanations: E0277, E0308, E0369. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/borrowck/fn-item-check-trait-ref.rs b/tests/ui/borrowck/fn-item-check-trait-ref.rs new file mode 100644 index 00000000000..bdbb52e974f --- /dev/null +++ b/tests/ui/borrowck/fn-item-check-trait-ref.rs @@ -0,0 +1,15 @@ +// The method `assert_static` should be callable only for static values, +// because the impl has an implied bound `where T: 'static`. + +// check-fail + +trait AnyStatic<Witness>: Sized { + fn assert_static(self) {} +} + +impl<T> AnyStatic<&'static T> for T {} + +fn main() { + (&String::new()).assert_static(); + //~^ ERROR temporary value dropped while borrowed +} diff --git a/tests/ui/borrowck/fn-item-check-trait-ref.stderr b/tests/ui/borrowck/fn-item-check-trait-ref.stderr new file mode 100644 index 00000000000..92fd67c316c --- /dev/null +++ b/tests/ui/borrowck/fn-item-check-trait-ref.stderr @@ -0,0 +1,12 @@ +error[E0716]: temporary value dropped while borrowed + --> $DIR/fn-item-check-trait-ref.rs:13:7 + | +LL | (&String::new()).assert_static(); + | --^^^^^^^^^^^^^------------------ temporary value is freed at the end of this statement + | | | + | | creates a temporary value which is freed while still in use + | argument requires that borrow lasts for `'static` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0716`. diff --git a/tests/ui/borrowck/fn-item-check-type-params.rs b/tests/ui/borrowck/fn-item-check-type-params.rs new file mode 100644 index 00000000000..805c0d00de5 --- /dev/null +++ b/tests/ui/borrowck/fn-item-check-type-params.rs @@ -0,0 +1,57 @@ +// Regression test for #104005. +// +// Previously, different borrowck implementations used to disagree here. +// The status of each is documented on `fn test_*`. + +// check-fail + +use std::fmt::Display; + +trait Displayable { + fn display(self) -> Box<dyn Display>; +} + +impl<T: Display> Displayable for (T, Option<&'static T>) { + fn display(self) -> Box<dyn Display> { + Box::new(self.0) + } +} + +fn extend_lt<T, U>(val: T) -> Box<dyn Display> +where + (T, Option<U>): Displayable, +{ + Displayable::display((val, None)) +} + +// AST: fail +// HIR: pass +// MIR: pass +pub fn test_call<'a>(val: &'a str) { + extend_lt(val); + //~^ ERROR borrowed data escapes outside of function +} + +// AST: fail +// HIR: fail +// MIR: pass +pub fn test_coercion<'a>() { + let _: fn(&'a str) -> _ = extend_lt; + //~^ ERROR lifetime may not live long enough +} + +// AST: fail +// HIR: fail +// MIR: fail +pub fn test_arg() { + fn want<I, O>(_: I, _: impl Fn(I) -> O) {} + want(&String::new(), extend_lt); + //~^ ERROR temporary value dropped while borrowed +} + +// An exploit of the unsoundness. +fn main() { + let val = extend_lt(&String::from("blah blah blah")); + //~^ ERROR temporary value dropped while borrowed + println!("{}", val); +} diff --git a/tests/ui/borrowck/fn-item-check-type-params.stderr b/tests/ui/borrowck/fn-item-check-type-params.stderr new file mode 100644 index 00000000000..3a29edc55c5 --- /dev/null +++ b/tests/ui/borrowck/fn-item-check-type-params.stderr @@ -0,0 +1,43 @@ +error[E0521]: borrowed data escapes outside of function + --> $DIR/fn-item-check-type-params.rs:31:5 + | +LL | pub fn test_call<'a>(val: &'a str) { + | -- --- `val` is a reference that is only valid in the function body + | | + | lifetime `'a` defined here +LL | extend_lt(val); + | ^^^^^^^^^^^^^^ + | | + | `val` escapes the function body here + | argument requires that `'a` must outlive `'static` + +error: lifetime may not live long enough + --> $DIR/fn-item-check-type-params.rs:39:12 + | +LL | pub fn test_coercion<'a>() { + | -- lifetime `'a` defined here +LL | let _: fn(&'a str) -> _ = extend_lt; + | ^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` + +error[E0716]: temporary value dropped while borrowed + --> $DIR/fn-item-check-type-params.rs:48:11 + | +LL | want(&String::new(), extend_lt); + | ------^^^^^^^^^^^^^------------- temporary value is freed at the end of this statement + | | | + | | creates a temporary value which is freed while still in use + | argument requires that borrow lasts for `'static` + +error[E0716]: temporary value dropped while borrowed + --> $DIR/fn-item-check-type-params.rs:54:26 + | +LL | let val = extend_lt(&String::from("blah blah blah")); + | -----------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-- temporary value is freed at the end of this statement + | | | + | | creates a temporary value which is freed while still in use + | argument requires that borrow lasts for `'static` + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0521, E0716. +For more information about an error, try `rustc --explain E0521`. diff --git a/tests/ui/borrowck/issue-119915-bad-clone-suggestion.rs b/tests/ui/borrowck/issue-119915-bad-clone-suggestion.rs new file mode 100644 index 00000000000..0b0ac9448db --- /dev/null +++ b/tests/ui/borrowck/issue-119915-bad-clone-suggestion.rs @@ -0,0 +1,28 @@ +use std::marker::PhantomData; + +struct Example<E, FakeParam>(PhantomData<(fn(E), fn(FakeParam))>); + +struct NoLifetime; +struct Immutable<'a>(PhantomData<&'a ()>); + +impl<'a, E: 'a> Copy for Example<E, Immutable<'a>> {} +impl<'a, E: 'a> Clone for Example<E, Immutable<'a>> { + fn clone(&self) -> Self { + *self + } +} + +impl<E, FakeParam> Example<E, FakeParam> { + unsafe fn change<NewFakeParam>(self) -> Example<E, NewFakeParam> { + Example(PhantomData) + } +} + +impl<E> Example<E, NoLifetime> { + fn the_ice(&mut self) -> Example<E, Immutable<'_>> { + unsafe { self.change() } + //~^ ERROR cannot move out of `*self` which is behind a mutable reference + } +} + +fn main() {} diff --git a/tests/ui/borrowck/issue-119915-bad-clone-suggestion.stderr b/tests/ui/borrowck/issue-119915-bad-clone-suggestion.stderr new file mode 100644 index 00000000000..ab42205d510 --- /dev/null +++ b/tests/ui/borrowck/issue-119915-bad-clone-suggestion.stderr @@ -0,0 +1,17 @@ +error[E0507]: cannot move out of `*self` which is behind a mutable reference + --> $DIR/issue-119915-bad-clone-suggestion.rs:23:18 + | +LL | unsafe { self.change() } + | ^^^^ -------- `*self` moved due to this method call + | | + | move occurs because `*self` has type `Example<E, NoLifetime>`, which does not implement the `Copy` trait + | +note: `Example::<E, FakeParam>::change` takes ownership of the receiver `self`, which moves `*self` + --> $DIR/issue-119915-bad-clone-suggestion.rs:16:36 + | +LL | unsafe fn change<NewFakeParam>(self) -> Example<E, NewFakeParam> { + | ^^^^ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0507`. diff --git a/tests/ui/borrowck/issue-82126-mismatched-subst-and-hir.rs b/tests/ui/borrowck/issue-82126-mismatched-subst-and-hir.rs index c10246eec64..b52939ffc11 100644 --- a/tests/ui/borrowck/issue-82126-mismatched-subst-and-hir.rs +++ b/tests/ui/borrowck/issue-82126-mismatched-subst-and-hir.rs @@ -17,7 +17,6 @@ async fn buy_lock(coroutine: &Mutex<MarketMultiplier>) -> LockedMarket<'_> { //~^ ERROR struct takes 0 lifetime arguments but 1 lifetime argument was supplied //~^^ ERROR struct takes 1 generic argument but 0 generic arguments were supplied LockedMarket(coroutine.lock().unwrap().buy()) - //~^ ERROR: cannot return value referencing temporary value } struct LockedMarket<T>(T); diff --git a/tests/ui/borrowck/issue-82126-mismatched-subst-and-hir.stderr b/tests/ui/borrowck/issue-82126-mismatched-subst-and-hir.stderr index 2b10cf67d15..516c1d065e6 100644 --- a/tests/ui/borrowck/issue-82126-mismatched-subst-and-hir.stderr +++ b/tests/ui/borrowck/issue-82126-mismatched-subst-and-hir.stderr @@ -7,7 +7,7 @@ LL | async fn buy_lock(coroutine: &Mutex<MarketMultiplier>) -> LockedMarket<'_> | expected 0 lifetime arguments | note: struct defined here, with 0 lifetime parameters - --> $DIR/issue-82126-mismatched-subst-and-hir.rs:23:8 + --> $DIR/issue-82126-mismatched-subst-and-hir.rs:22:8 | LL | struct LockedMarket<T>(T); | ^^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | async fn buy_lock(coroutine: &Mutex<MarketMultiplier>) -> LockedMarket<'_> | ^^^^^^^^^^^^ expected 1 generic argument | note: struct defined here, with 1 generic parameter: `T` - --> $DIR/issue-82126-mismatched-subst-and-hir.rs:23:8 + --> $DIR/issue-82126-mismatched-subst-and-hir.rs:22:8 | LL | struct LockedMarket<T>(T); | ^^^^^^^^^^^^ - @@ -28,16 +28,6 @@ help: add missing generic argument LL | async fn buy_lock(coroutine: &Mutex<MarketMultiplier>) -> LockedMarket<'_, T> { | +++ -error[E0515]: cannot return value referencing temporary value - --> $DIR/issue-82126-mismatched-subst-and-hir.rs:19:5 - | -LL | LockedMarket(coroutine.lock().unwrap().buy()) - | ^^^^^^^^^^^^^-------------------------^^^^^^^ - | | | - | | temporary value created here - | returns a value referencing data owned by the current function - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0107, E0515. -For more information about an error, try `rustc --explain E0107`. +For more information about this error, try `rustc --explain E0107`. diff --git a/tests/ui/borrowck/issue-85765-closure.rs b/tests/ui/borrowck/issue-85765-closure.rs index edc9eeaffb5..f2d1dd0fbc3 100644 --- a/tests/ui/borrowck/issue-85765-closure.rs +++ b/tests/ui/borrowck/issue-85765-closure.rs @@ -3,7 +3,6 @@ fn main() { let mut test = Vec::new(); let rofl: &Vec<Vec<i32>> = &mut test; //~^ HELP consider changing this binding's type - //~| HELP you can `clone` the `Vec<Vec<i32>>` value and consume it, but this might not be your desired behavior rofl.push(Vec::new()); //~^ ERROR cannot borrow `*rofl` as mutable, as it is behind a `&` reference //~| NOTE `rofl` is a `&` reference, so the data it refers to cannot be borrowed as mutable diff --git a/tests/ui/borrowck/issue-85765-closure.stderr b/tests/ui/borrowck/issue-85765-closure.stderr index 4a6a0e94bec..936ddd67bcd 100644 --- a/tests/ui/borrowck/issue-85765-closure.stderr +++ b/tests/ui/borrowck/issue-85765-closure.stderr @@ -1,21 +1,16 @@ error[E0596]: cannot borrow `*rofl` as mutable, as it is behind a `&` reference - --> $DIR/issue-85765-closure.rs:7:9 + --> $DIR/issue-85765-closure.rs:6:9 | LL | rofl.push(Vec::new()); | ^^^^ `rofl` is a `&` reference, so the data it refers to cannot be borrowed as mutable | -help: you can `clone` the `Vec<Vec<i32>>` value and consume it, but this might not be your desired behavior - --> $DIR/issue-85765-closure.rs:4:36 - | -LL | let rofl: &Vec<Vec<i32>> = &mut test; - | ^^^^^^^^^ help: consider changing this binding's type | LL | let rofl: &mut Vec<Vec<i32>> = &mut test; | ~~~~~~~~~~~~~~~~~~ error[E0594]: cannot assign to `*r`, which is behind a `&` reference - --> $DIR/issue-85765-closure.rs:14:9 + --> $DIR/issue-85765-closure.rs:13:9 | LL | *r = 0; | ^^^^^^ `r` is a `&` reference, so the data it refers to cannot be written @@ -26,7 +21,7 @@ LL | let r = &mut mutvar; | +++ error[E0594]: cannot assign to `*x`, which is behind a `&` reference - --> $DIR/issue-85765-closure.rs:21:9 + --> $DIR/issue-85765-closure.rs:20:9 | LL | *x = 1; | ^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written @@ -37,7 +32,7 @@ LL | let x: &mut usize = &mut{0}; | ~~~~~~~~~~ error[E0594]: cannot assign to `*y`, which is behind a `&` reference - --> $DIR/issue-85765-closure.rs:28:9 + --> $DIR/issue-85765-closure.rs:27:9 | LL | *y = 1; | ^^^^^^ `y` is a `&` reference, so the data it refers to cannot be written diff --git a/tests/ui/borrowck/issue-85765.rs b/tests/ui/borrowck/issue-85765.rs index ce5740bc0e7..76e0b517354 100644 --- a/tests/ui/borrowck/issue-85765.rs +++ b/tests/ui/borrowck/issue-85765.rs @@ -2,7 +2,6 @@ fn main() { let mut test = Vec::new(); let rofl: &Vec<Vec<i32>> = &mut test; //~^ HELP consider changing this binding's type - //~| HELP you can `clone` the `Vec<Vec<i32>>` value and consume it, but this might not be your desired behavior rofl.push(Vec::new()); //~^ ERROR cannot borrow `*rofl` as mutable, as it is behind a `&` reference //~| NOTE `rofl` is a `&` reference, so the data it refers to cannot be borrowed as mutable diff --git a/tests/ui/borrowck/issue-85765.stderr b/tests/ui/borrowck/issue-85765.stderr index 4889f774afa..57900bfb612 100644 --- a/tests/ui/borrowck/issue-85765.stderr +++ b/tests/ui/borrowck/issue-85765.stderr @@ -1,21 +1,16 @@ error[E0596]: cannot borrow `*rofl` as mutable, as it is behind a `&` reference - --> $DIR/issue-85765.rs:6:5 + --> $DIR/issue-85765.rs:5:5 | LL | rofl.push(Vec::new()); | ^^^^ `rofl` is a `&` reference, so the data it refers to cannot be borrowed as mutable | -help: you can `clone` the `Vec<Vec<i32>>` value and consume it, but this might not be your desired behavior - --> $DIR/issue-85765.rs:3:32 - | -LL | let rofl: &Vec<Vec<i32>> = &mut test; - | ^^^^^^^^^ help: consider changing this binding's type | LL | let rofl: &mut Vec<Vec<i32>> = &mut test; | ~~~~~~~~~~~~~~~~~~ error[E0594]: cannot assign to `*r`, which is behind a `&` reference - --> $DIR/issue-85765.rs:13:5 + --> $DIR/issue-85765.rs:12:5 | LL | *r = 0; | ^^^^^^ `r` is a `&` reference, so the data it refers to cannot be written @@ -26,7 +21,7 @@ LL | let r = &mut mutvar; | +++ error[E0594]: cannot assign to `*x`, which is behind a `&` reference - --> $DIR/issue-85765.rs:20:5 + --> $DIR/issue-85765.rs:19:5 | LL | *x = 1; | ^^^^^^ `x` is a `&` reference, so the data it refers to cannot be written @@ -37,7 +32,7 @@ LL | let x: &mut usize = &mut{0}; | ~~~~~~~~~~ error[E0594]: cannot assign to `*y`, which is behind a `&` reference - --> $DIR/issue-85765.rs:27:5 + --> $DIR/issue-85765.rs:26:5 | LL | *y = 1; | ^^^^^^ `y` is a `&` reference, so the data it refers to cannot be written diff --git a/tests/ui/borrowck/issue-91206.rs b/tests/ui/borrowck/issue-91206.rs index c60ac62fa34..e062a253767 100644 --- a/tests/ui/borrowck/issue-91206.rs +++ b/tests/ui/borrowck/issue-91206.rs @@ -10,7 +10,6 @@ fn main() { let client = TestClient; let inner = client.get_inner_ref(); //~^ HELP consider specifying this binding's type - //~| HELP you can `clone` the `Vec<usize>` value and consume it, but this might not be your desired behavior inner.clear(); //~^ ERROR cannot borrow `*inner` as mutable, as it is behind a `&` reference [E0596] //~| NOTE `inner` is a `&` reference, so the data it refers to cannot be borrowed as mutable diff --git a/tests/ui/borrowck/issue-91206.stderr b/tests/ui/borrowck/issue-91206.stderr index e3dd65b6419..f96b0c7d9e1 100644 --- a/tests/ui/borrowck/issue-91206.stderr +++ b/tests/ui/borrowck/issue-91206.stderr @@ -1,14 +1,9 @@ error[E0596]: cannot borrow `*inner` as mutable, as it is behind a `&` reference - --> $DIR/issue-91206.rs:14:5 + --> $DIR/issue-91206.rs:13:5 | LL | inner.clear(); | ^^^^^ `inner` is a `&` reference, so the data it refers to cannot be borrowed as mutable | -help: you can `clone` the `Vec<usize>` value and consume it, but this might not be your desired behavior - --> $DIR/issue-91206.rs:11:17 - | -LL | let inner = client.get_inner_ref(); - | ^^^^^^^^^^^^^^^^^^^^^^ help: consider specifying this binding's type | LL | let inner: &mut Vec<usize> = client.get_inner_ref(); diff --git a/tests/ui/cfg/diagnostics-cross-crate.rs b/tests/ui/cfg/diagnostics-cross-crate.rs index d2725c94b08..ad4e47b7b2e 100644 --- a/tests/ui/cfg/diagnostics-cross-crate.rs +++ b/tests/ui/cfg/diagnostics-cross-crate.rs @@ -14,9 +14,9 @@ fn main() { // The module isn't found - we would like to get a diagnostic, but currently don't due to // the awkward way the resolver diagnostics are currently implemented. - // FIXME(Nilstrieb): Also add a note to the cfg diagnostic here cfged_out::inner::doesnt_exist::hello(); //~ ERROR failed to resolve //~^ NOTE could not find `doesnt_exist` in `inner` + //~| NOTE found an item that was configured out // It should find the one in the right module, not the wrong one. cfged_out::inner::right::meow(); //~ ERROR cannot find function diff --git a/tests/ui/cfg/diagnostics-cross-crate.stderr b/tests/ui/cfg/diagnostics-cross-crate.stderr index 046929bc260..8a238f36404 100644 --- a/tests/ui/cfg/diagnostics-cross-crate.stderr +++ b/tests/ui/cfg/diagnostics-cross-crate.stderr @@ -1,8 +1,14 @@ error[E0433]: failed to resolve: could not find `doesnt_exist` in `inner` - --> $DIR/diagnostics-cross-crate.rs:18:23 + --> $DIR/diagnostics-cross-crate.rs:17:23 | LL | cfged_out::inner::doesnt_exist::hello(); | ^^^^^^^^^^^^ could not find `doesnt_exist` in `inner` + | +note: found an item that was configured out + --> $DIR/auxiliary/cfged_out.rs:6:13 + | +LL | pub mod doesnt_exist { + | ^^^^^^^^^^^^ error[E0425]: cannot find function `uwu` in crate `cfged_out` --> $DIR/diagnostics-cross-crate.rs:7:16 diff --git a/tests/ui/cfg/diagnostics-same-crate.rs b/tests/ui/cfg/diagnostics-same-crate.rs index f76ace06a76..2d0907c6dfb 100644 --- a/tests/ui/cfg/diagnostics-same-crate.rs +++ b/tests/ui/cfg/diagnostics-same-crate.rs @@ -4,7 +4,7 @@ pub mod inner { //~^ NOTE found an item that was configured out #[cfg(FALSE)] - pub mod doesnt_exist { + pub mod doesnt_exist { //~ NOTE found an item that was configured out pub fn hello() {} } @@ -34,7 +34,6 @@ fn main() { // The module isn't found - we would like to get a diagnostic, but currently don't due to // the awkward way the resolver diagnostics are currently implemented. - // FIXME(Nilstrieb): Also add a note to the cfg diagnostic here inner::doesnt_exist::hello(); //~ ERROR failed to resolve //~| NOTE could not find `doesnt_exist` in `inner` diff --git a/tests/ui/cfg/diagnostics-same-crate.stderr b/tests/ui/cfg/diagnostics-same-crate.stderr index 30ee6479bd2..62a9d132de0 100644 --- a/tests/ui/cfg/diagnostics-same-crate.stderr +++ b/tests/ui/cfg/diagnostics-same-crate.stderr @@ -1,8 +1,14 @@ error[E0433]: failed to resolve: could not find `doesnt_exist` in `inner` - --> $DIR/diagnostics-same-crate.rs:38:12 + --> $DIR/diagnostics-same-crate.rs:37:12 | LL | inner::doesnt_exist::hello(); | ^^^^^^^^^^^^ could not find `doesnt_exist` in `inner` + | +note: found an item that was configured out + --> $DIR/diagnostics-same-crate.rs:7:13 + | +LL | pub mod doesnt_exist { + | ^^^^^^^^^^^^ error[E0425]: cannot find function `uwu` in module `inner` --> $DIR/diagnostics-same-crate.rs:32:12 @@ -17,7 +23,7 @@ LL | pub fn uwu() {} | ^^^ error[E0425]: cannot find function `meow` in module `inner::right` - --> $DIR/diagnostics-same-crate.rs:42:19 + --> $DIR/diagnostics-same-crate.rs:41:19 | LL | inner::right::meow(); | ^^^^ not found in `inner::right` @@ -36,7 +42,7 @@ LL | uwu(); | ^^^ not found in this scope error[E0425]: cannot find function `vanished` in this scope - --> $DIR/diagnostics-same-crate.rs:49:5 + --> $DIR/diagnostics-same-crate.rs:48:5 | LL | vanished(); | ^^^^^^^^ not found in this scope diff --git a/tests/ui/deprecation/issue-66340-deprecated-attr-non-meta-grammar.rs b/tests/ui/deprecation/issue-66340-deprecated-attr-non-meta-grammar.rs index c0cde75d4ca..6653bd15ddd 100644 --- a/tests/ui/deprecation/issue-66340-deprecated-attr-non-meta-grammar.rs +++ b/tests/ui/deprecation/issue-66340-deprecated-attr-non-meta-grammar.rs @@ -7,5 +7,5 @@ fn main() { } #[deprecated(note = test)] -//~^ ERROR expected unsuffixed literal or identifier, found `test` +//~^ ERROR expected unsuffixed literal, found `test` fn foo() {} diff --git a/tests/ui/deprecation/issue-66340-deprecated-attr-non-meta-grammar.stderr b/tests/ui/deprecation/issue-66340-deprecated-attr-non-meta-grammar.stderr index 48c763c50e3..078c766deed 100644 --- a/tests/ui/deprecation/issue-66340-deprecated-attr-non-meta-grammar.stderr +++ b/tests/ui/deprecation/issue-66340-deprecated-attr-non-meta-grammar.stderr @@ -1,8 +1,13 @@ -error: expected unsuffixed literal or identifier, found `test` +error: expected unsuffixed literal, found `test` --> $DIR/issue-66340-deprecated-attr-non-meta-grammar.rs:9:21 | LL | #[deprecated(note = test)] | ^^^^ + | +help: surround the identifier with quotation marks to parse it as a string + | +LL | #[deprecated(note = "test")] + | + + error: aborting due to 1 previous error diff --git a/tests/ui/feature-gates/feature-gate-never_patterns.rs b/tests/ui/feature-gates/feature-gate-never_patterns.rs index f3910622313..d23405ada2d 100644 --- a/tests/ui/feature-gates/feature-gate-never_patterns.rs +++ b/tests/ui/feature-gates/feature-gate-never_patterns.rs @@ -7,7 +7,6 @@ fn main() { let res: Result<u32, Void> = Ok(0); let (Ok(_x) | Err(&!)) = res.as_ref(); //~^ ERROR `!` patterns are experimental - //~| ERROR: is not bound in all patterns unsafe { let ptr: *const Void = NonNull::dangling().as_ptr(); diff --git a/tests/ui/feature-gates/feature-gate-never_patterns.stderr b/tests/ui/feature-gates/feature-gate-never_patterns.stderr index 1b5485d22fb..9f94e962035 100644 --- a/tests/ui/feature-gates/feature-gate-never_patterns.stderr +++ b/tests/ui/feature-gates/feature-gate-never_patterns.stderr @@ -1,5 +1,5 @@ error: unexpected `,` in pattern - --> $DIR/feature-gate-never_patterns.rs:34:16 + --> $DIR/feature-gate-never_patterns.rs:33:16 | LL | Some(_), | ^ @@ -13,14 +13,6 @@ help: ...or a vertical bar to match on multiple alternatives LL | Some(_) | | -error[E0408]: variable `_x` is not bound in all patterns - --> $DIR/feature-gate-never_patterns.rs:8:19 - | -LL | let (Ok(_x) | Err(&!)) = res.as_ref(); - | -- ^^^^^^^ pattern doesn't bind `_x` - | | - | variable not in all patterns - error[E0658]: `!` patterns are experimental --> $DIR/feature-gate-never_patterns.rs:8:24 | @@ -32,7 +24,7 @@ LL | let (Ok(_x) | Err(&!)) = res.as_ref(); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `!` patterns are experimental - --> $DIR/feature-gate-never_patterns.rs:15:13 + --> $DIR/feature-gate-never_patterns.rs:14:13 | LL | ! | ^ @@ -42,7 +34,7 @@ LL | ! = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `!` patterns are experimental - --> $DIR/feature-gate-never_patterns.rs:21:13 + --> $DIR/feature-gate-never_patterns.rs:20:13 | LL | ! | ^ @@ -52,7 +44,7 @@ LL | ! = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `!` patterns are experimental - --> $DIR/feature-gate-never_patterns.rs:26:13 + --> $DIR/feature-gate-never_patterns.rs:25:13 | LL | ! => {} | ^ @@ -62,25 +54,25 @@ LL | ! => {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: `match` arm with no body - --> $DIR/feature-gate-never_patterns.rs:39:9 + --> $DIR/feature-gate-never_patterns.rs:38:9 | LL | Some(_) | ^^^^^^^- help: add a body after the pattern: `=> todo!(),` error: `match` arm with no body - --> $DIR/feature-gate-never_patterns.rs:44:9 + --> $DIR/feature-gate-never_patterns.rs:43:9 | LL | Some(_) if false, | ^^^^^^^- help: add a body after the pattern: `=> todo!(),` error: `match` arm with no body - --> $DIR/feature-gate-never_patterns.rs:46:9 + --> $DIR/feature-gate-never_patterns.rs:45:9 | LL | Some(_) if false | ^^^^^^^- help: add a body after the pattern: `=> todo!(),` error[E0658]: `!` patterns are experimental - --> $DIR/feature-gate-never_patterns.rs:51:13 + --> $DIR/feature-gate-never_patterns.rs:50:13 | LL | Err(!), | ^ @@ -90,7 +82,7 @@ LL | Err(!), = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `!` patterns are experimental - --> $DIR/feature-gate-never_patterns.rs:55:13 + --> $DIR/feature-gate-never_patterns.rs:54:13 | LL | Err(!) if false, | ^ @@ -100,24 +92,23 @@ LL | Err(!) if false, = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error: `match` arm with no body - --> $DIR/feature-gate-never_patterns.rs:65:9 + --> $DIR/feature-gate-never_patterns.rs:64:9 | LL | Some(_) | ^^^^^^^- help: add a body after the pattern: `=> todo!(),` error: `match` arm with no body - --> $DIR/feature-gate-never_patterns.rs:71:9 + --> $DIR/feature-gate-never_patterns.rs:70:9 | LL | Some(_) if false | ^^^^^^^- help: add a body after the pattern: `=> todo!(),` error: a guard on a never pattern will never be run - --> $DIR/feature-gate-never_patterns.rs:55:19 + --> $DIR/feature-gate-never_patterns.rs:54:19 | LL | Err(!) if false, | ^^^^^ help: remove this guard -error: aborting due to 14 previous errors +error: aborting due to 13 previous errors -Some errors have detailed explanations: E0408, E0658. -For more information about an error, try `rustc --explain E0408`. +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-proc_macro_c_str_literals.rs b/tests/ui/feature-gates/feature-gate-proc_macro_c_str_literals.rs new file mode 100644 index 00000000000..5554c813925 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-proc_macro_c_str_literals.rs @@ -0,0 +1,11 @@ +// edition: 2021 +// force-host +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::Literal; + +fn test() { + Literal::c_string(c"a"); //~ ERROR use of unstable library feature 'proc_macro_c_str_literals' +} diff --git a/tests/ui/feature-gates/feature-gate-proc_macro_c_str_literals.stderr b/tests/ui/feature-gates/feature-gate-proc_macro_c_str_literals.stderr new file mode 100644 index 00000000000..9bba1d50ce3 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-proc_macro_c_str_literals.stderr @@ -0,0 +1,13 @@ +error[E0658]: use of unstable library feature 'proc_macro_c_str_literals' + --> $DIR/feature-gate-proc_macro_c_str_literals.rs:10:5 + | +LL | Literal::c_string(c"a"); + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #119750 <https://github.com/rust-lang/rust/issues/119750> for more information + = help: add `#![feature(proc_macro_c_str_literals)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/generic-associated-types/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.rs b/tests/ui/generic-associated-types/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.rs new file mode 100644 index 00000000000..252dc7d751e --- /dev/null +++ b/tests/ui/generic-associated-types/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.rs @@ -0,0 +1,33 @@ +use std::ops::Deref; + +trait PointerFamily { + type Pointer<T>: Deref<Target = T>; +} + +struct RcFamily; + +impl PointerFamily for RcFamily { + type Pointer<T> = dyn Deref<Target = T>; + //~^ ERROR the size for values of type `(dyn Deref<Target = T> + 'static)` cannot be known at compilation time +} + +enum Node<T, P: PointerFamily> { + Cons(T, P::Pointer<Node<T, P>>), + Nil, +} + +type RcNode<T> = Node<T, RcFamily>; + +impl<T, P: PointerFamily> Node<T, P> +where + P::Pointer<Node<T, P>>: Sized, +{ + fn new() -> P::Pointer<Self> { + todo!() + } +} + +fn main() { + let mut list = RcNode::<i32>::new(); + //~^ ERROR the size for values of type `Node<i32, RcFamily>` cannot be known at compilation time +} diff --git a/tests/ui/generic-associated-types/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.stderr b/tests/ui/generic-associated-types/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.stderr new file mode 100644 index 00000000000..3a973d356dc --- /dev/null +++ b/tests/ui/generic-associated-types/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.stderr @@ -0,0 +1,52 @@ +error[E0277]: the size for values of type `(dyn Deref<Target = T> + 'static)` cannot be known at compilation time + --> $DIR/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.rs:10:23 + | +LL | type Pointer<T> = dyn Deref<Target = T>; + | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn Deref<Target = T> + 'static)` +note: required by a bound in `PointerFamily::Pointer` + --> $DIR/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.rs:4:5 + | +LL | type Pointer<T>: Deref<Target = T>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `PointerFamily::Pointer` +help: consider relaxing the implicit `Sized` restriction + | +LL | type Pointer<T>: Deref<Target = T> + ?Sized; + | ++++++++ + +error[E0599]: the size for values of type `Node<i32, RcFamily>` cannot be known at compilation time + --> $DIR/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.rs:31:35 + | +LL | enum Node<T, P: PointerFamily> { + | ------------------------------ + | | + | variant or associated item `new` not found for this enum + | doesn't satisfy `Node<i32, RcFamily>: Sized` +... +LL | let mut list = RcNode::<i32>::new(); + | ^^^ doesn't have a size known at compile-time + --> $SRC_DIR/core/src/ops/deref.rs:LL:COL + | + = note: doesn't satisfy `_: Sized` + | +note: trait bound `Node<i32, RcFamily>: Sized` was not satisfied + --> $DIR/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.rs:4:18 + | +LL | type Pointer<T>: Deref<Target = T>; + | ------- ^ unsatisfied trait bound introduced here +note: trait bound `(dyn Deref<Target = Node<i32, RcFamily>> + 'static): Sized` was not satisfied + --> $DIR/issue-119942-unsatisified-gat-bound-during-assoc-ty-selection.rs:23:29 + | +LL | impl<T, P: PointerFamily> Node<T, P> + | ---------- +LL | where +LL | P::Pointer<Node<T, P>>: Sized, + | ^^^^^ unsatisfied trait bound introduced here +note: the trait `Sized` must be implemented + --> $SRC_DIR/core/src/marker.rs:LL:COL + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0277, E0599. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/higher-ranked/trait-bounds/issue-59311.rs b/tests/ui/higher-ranked/trait-bounds/issue-59311.rs index 3ad548450e5..387c78a802a 100644 --- a/tests/ui/higher-ranked/trait-bounds/issue-59311.rs +++ b/tests/ui/higher-ranked/trait-bounds/issue-59311.rs @@ -17,6 +17,7 @@ where v.t(|| {}); //~^ ERROR: higher-ranked lifetime error //~| ERROR: higher-ranked lifetime error + //~| ERROR: higher-ranked lifetime error } fn main() {} diff --git a/tests/ui/higher-ranked/trait-bounds/issue-59311.stderr b/tests/ui/higher-ranked/trait-bounds/issue-59311.stderr index e50aad876d8..3053a299802 100644 --- a/tests/ui/higher-ranked/trait-bounds/issue-59311.stderr +++ b/tests/ui/higher-ranked/trait-bounds/issue-59311.stderr @@ -7,6 +7,15 @@ LL | v.t(|| {}); = note: could not prove `{closure@$DIR/issue-59311.rs:17:9: 17:11} well-formed` error: higher-ranked lifetime error + --> $DIR/issue-59311.rs:17:5 + | +LL | v.t(|| {}); + | ^^^^^^^^^^ + | + = note: could not prove `{closure@$DIR/issue-59311.rs:17:9: 17:11} well-formed` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: higher-ranked lifetime error --> $DIR/issue-59311.rs:17:9 | LL | v.t(|| {}); @@ -14,5 +23,5 @@ LL | v.t(|| {}); | = note: could not prove `for<'a> &'a V: 'b` -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/impl-trait/issue-72911.rs b/tests/ui/impl-trait/issue-72911.rs index 63f4898f430..7ba8579e24f 100644 --- a/tests/ui/impl-trait/issue-72911.rs +++ b/tests/ui/impl-trait/issue-72911.rs @@ -15,6 +15,7 @@ fn gather_from_file(dir_entry: &foo::MissingItem) -> impl Iterator<Item = Lint> fn lint_files() -> impl Iterator<Item = foo::MissingItem> { //~^ ERROR: failed to resolve + //~| ERROR: `()` is not an iterator unimplemented!() } diff --git a/tests/ui/impl-trait/issue-72911.stderr b/tests/ui/impl-trait/issue-72911.stderr index 0e86561aa27..44c20a7be53 100644 --- a/tests/ui/impl-trait/issue-72911.stderr +++ b/tests/ui/impl-trait/issue-72911.stderr @@ -1,3 +1,11 @@ +error[E0277]: `()` is not an iterator + --> $DIR/issue-72911.rs:16:20 + | +LL | fn lint_files() -> impl Iterator<Item = foo::MissingItem> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not an iterator + | + = help: the trait `Iterator` is not implemented for `()` + error[E0433]: failed to resolve: use of undeclared crate or module `foo` --> $DIR/issue-72911.rs:11:33 | @@ -10,6 +18,7 @@ error[E0433]: failed to resolve: use of undeclared crate or module `foo` LL | fn lint_files() -> impl Iterator<Item = foo::MissingItem> { | ^^^ use of undeclared crate or module `foo` -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0433`. +Some errors have detailed explanations: E0277, E0433. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/issues/issue-92305.rs b/tests/ui/impl-trait/issues/issue-92305.rs index e16199caaaa..4a89238d07e 100644 --- a/tests/ui/impl-trait/issues/issue-92305.rs +++ b/tests/ui/impl-trait/issues/issue-92305.rs @@ -5,7 +5,6 @@ use std::iter; fn f<T>(data: &[T]) -> impl Iterator<Item = Vec> { //~^ ERROR: missing generics for struct `Vec` [E0107] iter::empty() - //~^ ERROR: type annotations needed } fn g<T>(data: &[T], target: T) -> impl Iterator<Item = Vec<T>> { diff --git a/tests/ui/impl-trait/issues/issue-92305.stderr b/tests/ui/impl-trait/issues/issue-92305.stderr index 55e966bd7bf..88fb1fb2707 100644 --- a/tests/ui/impl-trait/issues/issue-92305.stderr +++ b/tests/ui/impl-trait/issues/issue-92305.stderr @@ -9,18 +9,6 @@ help: add missing generic argument LL | fn f<T>(data: &[T]) -> impl Iterator<Item = Vec<T>> { | +++ -error[E0282]: type annotations needed - --> $DIR/issue-92305.rs:7:5 - | -LL | iter::empty() - | ^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `empty` - | -help: consider specifying the generic argument - | -LL | iter::empty::<T>() - | +++++ - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0107, E0282. -For more information about an error, try `rustc --explain E0107`. +For more information about this error, try `rustc --explain E0107`. diff --git a/tests/ui/implied-bounds/implied-bounds-on-trait-hierarchy.rs b/tests/ui/implied-bounds/implied-bounds-on-trait-hierarchy-1.rs index 9c26cd59d10..b532a110a1c 100644 --- a/tests/ui/implied-bounds/implied-bounds-on-trait-hierarchy.rs +++ b/tests/ui/implied-bounds/implied-bounds-on-trait-hierarchy-1.rs @@ -1,9 +1,7 @@ -// check-pass -// known-bug: #84591 +// issue: #84591 -// Should fail. Subtrait can incorrectly extend supertrait lifetimes even when -// supertrait has weaker implied bounds than subtrait. Strongly related to -// issue #25860. +// Subtrait was able to incorrectly extend supertrait lifetimes even when +// supertrait had weaker implied bounds than subtrait. trait Subtrait<T>: Supertrait {} trait Supertrait { @@ -34,6 +32,7 @@ fn main() { { let x = "Hello World".to_string(); subs_to_soup((x.as_str(), &mut d)); + //~^ does not live long enough } println!("{}", d); } diff --git a/tests/ui/implied-bounds/implied-bounds-on-trait-hierarchy-1.stderr b/tests/ui/implied-bounds/implied-bounds-on-trait-hierarchy-1.stderr new file mode 100644 index 00000000000..f44defccf58 --- /dev/null +++ b/tests/ui/implied-bounds/implied-bounds-on-trait-hierarchy-1.stderr @@ -0,0 +1,16 @@ +error[E0597]: `x` does not live long enough + --> $DIR/implied-bounds-on-trait-hierarchy-1.rs:34:23 + | +LL | let x = "Hello World".to_string(); + | - binding `x` declared here +LL | subs_to_soup((x.as_str(), &mut d)); + | ^ borrowed value does not live long enough +LL | +LL | } + | - `x` dropped here while still borrowed +LL | println!("{}", d); + | - borrow later used here + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/tests/ui/implied-bounds/implied-bounds-on-trait-hierarchy-2.rs b/tests/ui/implied-bounds/implied-bounds-on-trait-hierarchy-2.rs new file mode 100644 index 00000000000..511a9ad9a2a --- /dev/null +++ b/tests/ui/implied-bounds/implied-bounds-on-trait-hierarchy-2.rs @@ -0,0 +1,45 @@ +// check-pass +// known-bug: #84591 + +trait Subtrait<'a, 'b, R>: Supertrait<'a, 'b> {} +trait Supertrait<'a, 'b> { + fn convert<T: ?Sized>(x: &'a T) -> &'b T; +} + +fn need_hrtb_subtrait<'a_, 'b_, S, T: ?Sized>(x: &'a_ T) -> &'b_ T +where + S: for<'a, 'b> Subtrait<'a, 'b, &'b &'a ()>, +{ + need_hrtb_supertrait::<S, T>(x) + // This call works and drops the implied bound `'a: 'b` + // of the where-bound. This means the where-bound can + // now be used to transmute any two lifetimes. +} + +fn need_hrtb_supertrait<'a_, 'b_, S, T: ?Sized>(x: &'a_ T) -> &'b_ T +where + S: for<'a, 'b> Supertrait<'a, 'b>, +{ + S::convert(x) +} + +struct MyStruct; +impl<'a: 'b, 'b> Supertrait<'a, 'b> for MyStruct { + fn convert<T: ?Sized>(x: &'a T) -> &'b T { + x + } +} +impl<'a, 'b> Subtrait<'a, 'b, &'b &'a ()> for MyStruct {} + +fn extend_lifetime<'a, 'b, T: ?Sized>(x: &'a T) -> &'b T { + need_hrtb_subtrait::<MyStruct, T>(x) +} + +fn main() { + let d; + { + let x = "Hello World".to_string(); + d = extend_lifetime(&x); + } + println!("{}", d); +} diff --git a/tests/ui/lifetimes/lifetime-errors/issue_74400.rs b/tests/ui/lifetimes/lifetime-errors/issue_74400.rs index ddb8bacce8f..f17e0a678c9 100644 --- a/tests/ui/lifetimes/lifetime-errors/issue_74400.rs +++ b/tests/ui/lifetimes/lifetime-errors/issue_74400.rs @@ -11,6 +11,8 @@ fn f<T, S>(data: &[T], key: impl Fn(&T) -> S) { fn g<T>(data: &[T]) { f(data, identity) //~^ ERROR the parameter type + //~| ERROR the parameter type + //~| ERROR the parameter type //~| ERROR mismatched types //~| ERROR implementation of `FnOnce` is not general } diff --git a/tests/ui/lifetimes/lifetime-errors/issue_74400.stderr b/tests/ui/lifetimes/lifetime-errors/issue_74400.stderr index 677f918fe93..beb838d2ff8 100644 --- a/tests/ui/lifetimes/lifetime-errors/issue_74400.stderr +++ b/tests/ui/lifetimes/lifetime-errors/issue_74400.stderr @@ -12,6 +12,36 @@ help: consider adding an explicit lifetime bound LL | fn g<T: 'static>(data: &[T]) { | +++++++++ +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/issue_74400.rs:12:5 + | +LL | f(data, identity) + | ^^^^^^^^^^^^^^^^^ + | | + | the parameter type `T` must be valid for the static lifetime... + | ...so that the type `T` will meet its required lifetime bounds + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: consider adding an explicit lifetime bound + | +LL | fn g<T: 'static>(data: &[T]) { + | +++++++++ + +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/issue_74400.rs:12:5 + | +LL | f(data, identity) + | ^^^^^^^^^^^^^^^^^ + | | + | the parameter type `T` must be valid for the static lifetime... + | ...so that the type `T` will meet its required lifetime bounds + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: consider adding an explicit lifetime bound + | +LL | fn g<T: 'static>(data: &[T]) { + | +++++++++ + error[E0308]: mismatched types --> $DIR/issue_74400.rs:12:5 | @@ -35,7 +65,7 @@ LL | f(data, identity) = note: `fn(&'2 T) -> &'2 T {identity::<&'2 T>}` must implement `FnOnce<(&'1 T,)>`, for any lifetime `'1`... = note: ...but it actually implements `FnOnce<(&'2 T,)>`, for some specific lifetime `'2` -error: aborting due to 3 previous errors +error: aborting due to 5 previous errors Some errors have detailed explanations: E0308, E0310. For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/lint/large_assignments/box_rc_arc_allowed.stderr b/tests/ui/lint/large_assignments/box_rc_arc_allowed.stderr index b45cbe5da4d..fefb3a9621b 100644 --- a/tests/ui/lint/large_assignments/box_rc_arc_allowed.stderr +++ b/tests/ui/lint/large_assignments/box_rc_arc_allowed.stderr @@ -1,8 +1,8 @@ error: moving 9999 bytes - --> $DIR/box_rc_arc_allowed.rs:16:13 + --> $DIR/box_rc_arc_allowed.rs:16:25 | LL | let _ = NotBox::new([0; 9999]); - | ^^^^^^^^^^^^^^^^^^^^^^ value moved from here + | ^^^^^^^^^ value moved from here | = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` note: the lint level is defined here diff --git a/tests/ui/lint/large_assignments/copy_into_fn.rs b/tests/ui/lint/large_assignments/copy_into_fn.rs new file mode 100644 index 00000000000..ee204bf7af1 --- /dev/null +++ b/tests/ui/lint/large_assignments/copy_into_fn.rs @@ -0,0 +1,24 @@ +// build-fail + +#![feature(large_assignments)] +#![move_size_limit = "1000"] +#![deny(large_assignments)] +#![allow(unused)] + +// We want copy semantics, because moving data into functions generally do not +// translate to actual `memcpy`s. +#[derive(Copy, Clone)] +struct Data([u8; 9999]); + +fn main() { + one_arg(Data([0; 9999])); //~ ERROR large_assignments + + // each individual large arg shall have its own span + many_args(Data([0; 9999]), true, Data([0; 9999])); + //~^ ERROR large_assignments + //~| ERROR large_assignments +} + +fn one_arg(a: Data) {} + +fn many_args(a: Data, b: bool, c: Data) {} diff --git a/tests/ui/lint/large_assignments/copy_into_fn.stderr b/tests/ui/lint/large_assignments/copy_into_fn.stderr new file mode 100644 index 00000000000..f05fc33e17e --- /dev/null +++ b/tests/ui/lint/large_assignments/copy_into_fn.stderr @@ -0,0 +1,31 @@ +error: moving 9999 bytes + --> $DIR/copy_into_fn.rs:14:13 + | +LL | one_arg(Data([0; 9999])); + | ^^^^^^^^^^^^^^^ value moved from here + | + = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` +note: the lint level is defined here + --> $DIR/copy_into_fn.rs:5:9 + | +LL | #![deny(large_assignments)] + | ^^^^^^^^^^^^^^^^^ + +error: moving 9999 bytes + --> $DIR/copy_into_fn.rs:17:15 + | +LL | many_args(Data([0; 9999]), true, Data([0; 9999])); + | ^^^^^^^^^^^^^^^ value moved from here + | + = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` + +error: moving 9999 bytes + --> $DIR/copy_into_fn.rs:17:38 + | +LL | many_args(Data([0; 9999]), true, Data([0; 9999])); + | ^^^^^^^^^^^^^^^ value moved from here + | + = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` + +error: aborting due to 3 previous errors + diff --git a/tests/ui/moves/move-fn-self-receiver.stderr b/tests/ui/moves/move-fn-self-receiver.stderr index 462deacbe8d..17f48f5f7bf 100644 --- a/tests/ui/moves/move-fn-self-receiver.stderr +++ b/tests/ui/moves/move-fn-self-receiver.stderr @@ -55,10 +55,15 @@ note: `Foo::use_box_self` takes ownership of the receiver `self`, which moves `b | LL | fn use_box_self(self: Box<Self>) {} | ^^^^ -help: you could `clone` the value and consume it, if the `Box<Foo>: Clone` trait bound could be satisfied +help: you could `clone` the value and consume it, if the `Foo: Clone` trait bound could be satisfied | LL | boxed_foo.clone().use_box_self(); | ++++++++ +help: consider annotating `Foo` with `#[derive(Clone)]` + | +LL + #[derive(Clone)] +LL | struct Foo; + | error[E0382]: use of moved value: `pin_box_foo` --> $DIR/move-fn-self-receiver.rs:46:5 @@ -75,10 +80,15 @@ note: `Foo::use_pin_box_self` takes ownership of the receiver `self`, which move | LL | fn use_pin_box_self(self: Pin<Box<Self>>) {} | ^^^^ -help: you could `clone` the value and consume it, if the `Box<Foo>: Clone` trait bound could be satisfied +help: you could `clone` the value and consume it, if the `Foo: Clone` trait bound could be satisfied | LL | pin_box_foo.clone().use_pin_box_self(); | ++++++++ +help: consider annotating `Foo` with `#[derive(Clone)]` + | +LL + #[derive(Clone)] +LL | struct Foo; + | error[E0505]: cannot move out of `mut_foo` because it is borrowed --> $DIR/move-fn-self-receiver.rs:50:5 diff --git a/tests/ui/parser/attribute/attr-unquoted-ident.fixed b/tests/ui/parser/attribute/attr-unquoted-ident.fixed new file mode 100644 index 00000000000..6cdf22f7ec0 --- /dev/null +++ b/tests/ui/parser/attribute/attr-unquoted-ident.fixed @@ -0,0 +1,15 @@ +// compile-flags: -Zdeduplicate-diagnostics=yes +// run-rustfix + +fn main() { + #[cfg(key="foo")] + //~^ ERROR expected unsuffixed literal, found `foo` + //~| HELP surround the identifier with quotation marks to parse it as a string + println!(); + #[cfg(key="bar")] + println!(); + #[cfg(key="foo bar baz")] + //~^ ERROR expected unsuffixed literal, found `foo` + //~| HELP surround the identifier with quotation marks to parse it as a string + println!(); +} diff --git a/tests/ui/parser/attribute/attr-unquoted-ident.rs b/tests/ui/parser/attribute/attr-unquoted-ident.rs new file mode 100644 index 00000000000..75af015c9fe --- /dev/null +++ b/tests/ui/parser/attribute/attr-unquoted-ident.rs @@ -0,0 +1,15 @@ +// compile-flags: -Zdeduplicate-diagnostics=yes +// run-rustfix + +fn main() { + #[cfg(key=foo)] + //~^ ERROR expected unsuffixed literal, found `foo` + //~| HELP surround the identifier with quotation marks to parse it as a string + println!(); + #[cfg(key="bar")] + println!(); + #[cfg(key=foo bar baz)] + //~^ ERROR expected unsuffixed literal, found `foo` + //~| HELP surround the identifier with quotation marks to parse it as a string + println!(); +} diff --git a/tests/ui/parser/attribute/attr-unquoted-ident.stderr b/tests/ui/parser/attribute/attr-unquoted-ident.stderr new file mode 100644 index 00000000000..bc028f39be6 --- /dev/null +++ b/tests/ui/parser/attribute/attr-unquoted-ident.stderr @@ -0,0 +1,24 @@ +error: expected unsuffixed literal, found `foo` + --> $DIR/attr-unquoted-ident.rs:5:15 + | +LL | #[cfg(key=foo)] + | ^^^ + | +help: surround the identifier with quotation marks to parse it as a string + | +LL | #[cfg(key="foo")] + | + + + +error: expected unsuffixed literal, found `foo` + --> $DIR/attr-unquoted-ident.rs:11:15 + | +LL | #[cfg(key=foo bar baz)] + | ^^^ + | +help: surround the identifier with quotation marks to parse it as a string + | +LL | #[cfg(key="foo bar baz")] + | + + + +error: aborting due to 2 previous errors + diff --git a/tests/ui/pattern/never_patterns.rs b/tests/ui/pattern/never_patterns.rs index 915f3e75e7b..8f44f8a6559 100644 --- a/tests/ui/pattern/never_patterns.rs +++ b/tests/ui/pattern/never_patterns.rs @@ -7,12 +7,9 @@ fn main() {} // The classic use for empty types. fn safe_unwrap_result<T>(res: Result<T, Void>) { - let Ok(_x) = res; - // FIXME(never_patterns): These should be allowed + let Ok(_x) = res; //~ ERROR refutable pattern in local binding let (Ok(_x) | Err(!)) = &res; - //~^ ERROR: is not bound in all patterns let (Ok(_x) | Err(&!)) = res.as_ref(); - //~^ ERROR: is not bound in all patterns } // Check we only accept `!` where we want to. @@ -74,26 +71,3 @@ fn never_pattern_location(void: Void) { Some(&(_, !)), } } - -fn never_and_bindings() { - let x: Result<bool, &(u32, Void)> = Ok(false); - - // FIXME(never_patterns): Never patterns in or-patterns don't need to share the same bindings. - match x { - Ok(_x) | Err(&!) => {} - //~^ ERROR: is not bound in all patterns - } - let (Ok(_x) | Err(&!)) = x; - //~^ ERROR: is not bound in all patterns - - // FIXME(never_patterns): A never pattern mustn't have bindings. - match x { - Ok(_) => {} - Err(&(_b, !)), - } - match x { - Ok(_a) | Err(&(_b, !)) => {} - //~^ ERROR: is not bound in all patterns - //~| ERROR: is not bound in all patterns - } -} diff --git a/tests/ui/pattern/never_patterns.stderr b/tests/ui/pattern/never_patterns.stderr index 11e50debfd3..20eeb01cf71 100644 --- a/tests/ui/pattern/never_patterns.stderr +++ b/tests/ui/pattern/never_patterns.stderr @@ -1,51 +1,17 @@ -error[E0408]: variable `_x` is not bound in all patterns - --> $DIR/never_patterns.rs:12:19 +error[E0005]: refutable pattern in local binding + --> $DIR/never_patterns.rs:10:9 | -LL | let (Ok(_x) | Err(!)) = &res; - | -- ^^^^^^ pattern doesn't bind `_x` - | | - | variable not in all patterns - -error[E0408]: variable `_x` is not bound in all patterns - --> $DIR/never_patterns.rs:14:19 - | -LL | let (Ok(_x) | Err(&!)) = res.as_ref(); - | -- ^^^^^^^ pattern doesn't bind `_x` - | | - | variable not in all patterns - -error[E0408]: variable `_x` is not bound in all patterns - --> $DIR/never_patterns.rs:83:18 - | -LL | Ok(_x) | Err(&!) => {} - | -- ^^^^^^^ pattern doesn't bind `_x` - | | - | variable not in all patterns - -error[E0408]: variable `_x` is not bound in all patterns - --> $DIR/never_patterns.rs:86:19 - | -LL | let (Ok(_x) | Err(&!)) = x; - | -- ^^^^^^^ pattern doesn't bind `_x` - | | - | variable not in all patterns - -error[E0408]: variable `_b` is not bound in all patterns - --> $DIR/never_patterns.rs:95:9 +LL | let Ok(_x) = res; + | ^^^^^^ pattern `Err(_)` not covered | -LL | Ok(_a) | Err(&(_b, !)) => {} - | ^^^^^^ -- variable not in all patterns - | | - | pattern doesn't bind `_b` - -error[E0408]: variable `_a` is not bound in all patterns - --> $DIR/never_patterns.rs:95:18 + = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant + = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html + = note: the matched value is of type `Result<T, Void>` +help: you might want to use `let else` to handle the variant that isn't matched | -LL | Ok(_a) | Err(&(_b, !)) => {} - | -- ^^^^^^^^^^^^^ pattern doesn't bind `_a` - | | - | variable not in all patterns +LL | let Ok(_x) = res else { todo!() }; + | ++++++++++++++++ -error: aborting due to 6 previous errors +error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0408`. +For more information about this error, try `rustc --explain E0005`. diff --git a/tests/ui/proc-macro/auxiliary/api/mod.rs b/tests/ui/proc-macro/auxiliary/api/mod.rs index 3bea5d75779..5a533b9e17e 100644 --- a/tests/ui/proc-macro/auxiliary/api/mod.rs +++ b/tests/ui/proc-macro/auxiliary/api/mod.rs @@ -1,10 +1,12 @@ // force-host // no-prefer-dynamic +// edition: 2021 #![crate_type = "proc-macro"] #![crate_name = "proc_macro_api_tests"] #![feature(proc_macro_span)] #![feature(proc_macro_byte_character)] +#![feature(proc_macro_c_str_literals)] #![deny(dead_code)] // catch if a test function is never called extern crate proc_macro; diff --git a/tests/ui/proc-macro/auxiliary/api/parse.rs b/tests/ui/proc-macro/auxiliary/api/parse.rs index 07c9f464961..801c616c804 100644 --- a/tests/ui/proc-macro/auxiliary/api/parse.rs +++ b/tests/ui/proc-macro/auxiliary/api/parse.rs @@ -19,10 +19,8 @@ fn test_display_literal() { "10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0", ); - assert_eq!( - Literal::string("a \t ❤ ' \" \u{1}").to_string(), - "\"a \\t ❤ ' \\\" \\u{1}\"", - ); + assert_eq!(Literal::string("a \t ❤ ' \" \u{1}").to_string(), "\"a \\t ❤ ' \\\" \\u{1}\"",); + assert_eq!(Literal::c_string(c"\'\"\x7f\u{7fff}").to_string(), r#"c"\'\"\x7f\xe7\xbf\xbf""#); assert_eq!(Literal::character('a').to_string(), "'a'"); assert_eq!(Literal::character('\t').to_string(), "'\\t'"); assert_eq!(Literal::character('❤').to_string(), "'❤'"); @@ -41,6 +39,7 @@ fn test_parse_literal() { assert_eq!("b'a'".parse::<Literal>().unwrap().to_string(), "b'a'"); assert_eq!("\"\n\"".parse::<Literal>().unwrap().to_string(), "\"\n\""); assert_eq!("b\"\"".parse::<Literal>().unwrap().to_string(), "b\"\""); + assert_eq!("c\"\"".parse::<Literal>().unwrap().to_string(), "c\"\""); assert_eq!("r##\"\"##".parse::<Literal>().unwrap().to_string(), "r##\"\"##"); assert_eq!("10ulong".parse::<Literal>().unwrap().to_string(), "10ulong"); assert_eq!("-10ulong".parse::<Literal>().unwrap().to_string(), "-10ulong"); diff --git a/tests/ui/proc-macro/test.rs b/tests/ui/proc-macro/test.rs index c96aa73175f..2ec62072020 100644 --- a/tests/ui/proc-macro/test.rs +++ b/tests/ui/proc-macro/test.rs @@ -1,5 +1,6 @@ // check-pass // aux-build:api/mod.rs +// edition: 2021 //! This is for everything that *would* be a #[test] inside of libproc_macro, //! except for the fact that proc_macro objects are not capable of existing diff --git a/tests/ui/rfcs/rfc-0000-never_patterns/bindings.rs b/tests/ui/rfcs/rfc-0000-never_patterns/bindings.rs new file mode 100644 index 00000000000..f2e238ecb13 --- /dev/null +++ b/tests/ui/rfcs/rfc-0000-never_patterns/bindings.rs @@ -0,0 +1,46 @@ +#![feature(never_patterns)] +#![allow(incomplete_features)] + +enum Void {} + +fn main() { + let x: Result<bool, &(u32, u32, Void)> = Ok(false); + + match x { + Ok(_x) | Err(&!) => {} + } + let (Ok(_x) | Err(&!)) = x; + + match x { + Ok(_) => {} + Err(&(_a, _b, !)), + //~^ ERROR: never patterns cannot contain variable bindings + //~| ERROR: never patterns cannot contain variable bindings + } + match x { + Ok(_ok) | Err(&(_a, _b, !)) => {} + //~^ ERROR: never patterns cannot contain variable bindings + //~| ERROR: never patterns cannot contain variable bindings + } +} + +fn void(void: Void) { + let (_a | !) = void; + let (! | _a) = void; + let ((_a, _) | (_a, _ | !)) = (true, void); + let (_a | (! | !,)) = (void,); + let ((_a,) | (!,)) = (void,); + + let (_a, (! | !)) = (true, void); + //~^ ERROR: never patterns cannot contain variable bindings + let (_a, (_b | !)) = (true, void); + + let _a @ ! = void; + //~^ ERROR: never patterns cannot contain variable bindings + let _a @ (_b | !) = void; + let (_a @ (), !) = ((), void); + //~^ ERROR: never patterns cannot contain variable bindings + let (_a | + (_b @ (_, !))) = (true, void); + //~^ ERROR: never patterns cannot contain variable bindings +} diff --git a/tests/ui/rfcs/rfc-0000-never_patterns/bindings.stderr b/tests/ui/rfcs/rfc-0000-never_patterns/bindings.stderr new file mode 100644 index 00000000000..b69ba80af88 --- /dev/null +++ b/tests/ui/rfcs/rfc-0000-never_patterns/bindings.stderr @@ -0,0 +1,50 @@ +error: never patterns cannot contain variable bindings + --> $DIR/bindings.rs:16:15 + | +LL | Err(&(_a, _b, !)), + | ^^ help: use a wildcard `_` instead + +error: never patterns cannot contain variable bindings + --> $DIR/bindings.rs:16:19 + | +LL | Err(&(_a, _b, !)), + | ^^ help: use a wildcard `_` instead + +error: never patterns cannot contain variable bindings + --> $DIR/bindings.rs:21:25 + | +LL | Ok(_ok) | Err(&(_a, _b, !)) => {} + | ^^ help: use a wildcard `_` instead + +error: never patterns cannot contain variable bindings + --> $DIR/bindings.rs:21:29 + | +LL | Ok(_ok) | Err(&(_a, _b, !)) => {} + | ^^ help: use a wildcard `_` instead + +error: never patterns cannot contain variable bindings + --> $DIR/bindings.rs:34:10 + | +LL | let (_a, (! | !)) = (true, void); + | ^^ help: use a wildcard `_` instead + +error: never patterns cannot contain variable bindings + --> $DIR/bindings.rs:38:9 + | +LL | let _a @ ! = void; + | ^^ help: use a wildcard `_` instead + +error: never patterns cannot contain variable bindings + --> $DIR/bindings.rs:41:10 + | +LL | let (_a @ (), !) = ((), void); + | ^^ help: use a wildcard `_` instead + +error: never patterns cannot contain variable bindings + --> $DIR/bindings.rs:44:14 + | +LL | (_b @ (_, !))) = (true, void); + | ^^ help: use a wildcard `_` instead + +error: aborting due to 8 previous errors + diff --git a/tests/ui/rfcs/rfc-0000-never_patterns/parse.rs b/tests/ui/rfcs/rfc-0000-never_patterns/parse.rs index f254b9c201c..566bb071646 100644 --- a/tests/ui/rfcs/rfc-0000-never_patterns/parse.rs +++ b/tests/ui/rfcs/rfc-0000-never_patterns/parse.rs @@ -71,6 +71,7 @@ fn parse(x: Void) { let ! = x; let y @ ! = x; + //~^ ERROR: never patterns cannot contain variable bindings } fn foo(!: Void) {} diff --git a/tests/ui/rfcs/rfc-0000-never_patterns/parse.stderr b/tests/ui/rfcs/rfc-0000-never_patterns/parse.stderr index e81a13a3967..17d1b7e0d43 100644 --- a/tests/ui/rfcs/rfc-0000-never_patterns/parse.stderr +++ b/tests/ui/rfcs/rfc-0000-never_patterns/parse.stderr @@ -22,6 +22,12 @@ error: top-level or-patterns are not allowed in `let` bindings LL | let Ok(_) | Err(!) = &res; // Disallowed; see #82048. | ^^^^^^^^^^^^^^ help: wrap the pattern in parentheses: `(Ok(_) | Err(!))` +error: never patterns cannot contain variable bindings + --> $DIR/parse.rs:73:9 + | +LL | let y @ ! = x; + | ^ help: use a wildcard `_` instead + error: a guard on a never pattern will never be run --> $DIR/parse.rs:31:20 | @@ -40,5 +46,5 @@ error: a guard on a never pattern will never be run LL | never!() if true, | ^^^^ help: remove this guard -error: aborting due to 7 previous errors +error: aborting due to 8 previous errors diff --git a/tests/ui/specialization/allow_internal_unstable.rs b/tests/ui/specialization/allow_internal_unstable.rs new file mode 100644 index 00000000000..317782b7b72 --- /dev/null +++ b/tests/ui/specialization/allow_internal_unstable.rs @@ -0,0 +1,18 @@ +// check-pass +// test for #119950 +// compile-flags: --crate-type lib + +#![allow(internal_features)] +#![feature(allow_internal_unstable)] + +#[allow_internal_unstable(min_specialization)] +macro_rules! test { + () => { + struct T<U>(U); + trait Tr {} + impl<U> Tr for T<U> {} + impl Tr for T<u8> {} + } +} + +test! {} diff --git a/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.current.stderr b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.current.stderr new file mode 100644 index 00000000000..4082d6d47e7 --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.current.stderr @@ -0,0 +1,11 @@ +warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/unifying-placeholders-in-query-response-2.rs:5:12 + | +LL | #![feature(non_lifetime_binders)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.next.stderr b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.next.stderr new file mode 100644 index 00000000000..4082d6d47e7 --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.next.stderr @@ -0,0 +1,11 @@ +warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/unifying-placeholders-in-query-response-2.rs:5:12 + | +LL | #![feature(non_lifetime_binders)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.rs b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.rs new file mode 100644 index 00000000000..bbf1a1f72db --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response-2.rs @@ -0,0 +1,23 @@ +// revisions: current next +//[next] compile-flags: -Znext-solver +// check-pass + +#![feature(non_lifetime_binders)] +//~^ WARN the feature `non_lifetime_binders` is incomplete + +trait Id { + type Output: ?Sized; +} + +impl<T: ?Sized> Id for T { + type Output = T; +} + +trait Everyone {} +impl<T: ?Sized> Everyone for T {} + +fn hello() where for<T> <T as Id>::Output: Everyone {} + +fn main() { + hello(); +} diff --git a/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.current.stderr b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.current.stderr new file mode 100644 index 00000000000..040009efbde --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.current.stderr @@ -0,0 +1,11 @@ +warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/unifying-placeholders-in-query-response.rs:5:12 + | +LL | #![feature(non_lifetime_binders)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.next.stderr b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.next.stderr new file mode 100644 index 00000000000..040009efbde --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.next.stderr @@ -0,0 +1,11 @@ +warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/unifying-placeholders-in-query-response.rs:5:12 + | +LL | #![feature(non_lifetime_binders)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.rs b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.rs new file mode 100644 index 00000000000..5e28a2ba8b9 --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/unifying-placeholders-in-query-response.rs @@ -0,0 +1,27 @@ +// revisions: current next +//[next] compile-flags: -Znext-solver +// check-pass + +#![feature(non_lifetime_binders)] +//~^ WARN the feature `non_lifetime_binders` is incomplete + +pub trait Foo<T: ?Sized> { + type Bar<K: ?Sized>: ?Sized; +} + +impl Foo<usize> for () { + type Bar<K: ?Sized> = K; +} + +pub fn f<T1, T2>(a: T1, b: T2) +where + T1: for<T> Foo<usize, Bar<T> = T>, + T2: for<T> Foo<usize, Bar<T> = <T1 as Foo<usize>>::Bar<T>>, +{ +} + +fn it_works() { + f((), ()); +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/nested_inference_failure.rs b/tests/ui/type-alias-impl-trait/nested_inference_failure.rs new file mode 100644 index 00000000000..d2091ca96ea --- /dev/null +++ b/tests/ui/type-alias-impl-trait/nested_inference_failure.rs @@ -0,0 +1,28 @@ +// check-pass +// revisions: new old +//[new] compile-flags: -Znext-solver + +//! This test checks that we can successfully infer +//! the hidden type of `FooImpl` to be `Foo<i32, {closure}>` +//! and `ImplT` to be `i32`. This test used to fail, because +//! we were unable to make the connection that the closure +//! argument is the same as the first argument of `Foo`. + +#![feature(type_alias_impl_trait)] + +use std::fmt::Debug; +use std::marker::PhantomData; + +struct Foo<T: Debug, F: FnOnce(T)> { + f: F, + _phantom: PhantomData<T>, +} + +type ImplT = impl Debug; +type FooImpl = Foo<ImplT, impl FnOnce(ImplT)>; + +fn bar() -> FooImpl { + Foo::<i32, _> { f: |_| (), _phantom: PhantomData } +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/wf-nested.fail.stderr b/tests/ui/type-alias-impl-trait/wf-nested.fail.stderr index dcc4b8021ea..17c1f8897bf 100644 --- a/tests/ui/type-alias-impl-trait/wf-nested.fail.stderr +++ b/tests/ui/type-alias-impl-trait/wf-nested.fail.stderr @@ -1,5 +1,5 @@ error[E0310]: the parameter type `T` may not live long enough - --> $DIR/wf-nested.rs:55:27 + --> $DIR/wf-nested.rs:57:27 | LL | type InnerOpaque<T> = impl Sized; | ^^^^^^^^^^ diff --git a/tests/ui/type-alias-impl-trait/wf-nested.pass_sound.stderr b/tests/ui/type-alias-impl-trait/wf-nested.pass_sound.stderr index 121664bd956..f5d3a218542 100644 --- a/tests/ui/type-alias-impl-trait/wf-nested.pass_sound.stderr +++ b/tests/ui/type-alias-impl-trait/wf-nested.pass_sound.stderr @@ -12,6 +12,21 @@ help: consider adding an explicit lifetime bound LL | fn test<T: 'static>() { | +++++++++ -error: aborting due to 1 previous error +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/wf-nested.rs:46:17 + | +LL | let _ = outer.get(); + | ^^^^^^^^^^^ + | | + | the parameter type `T` must be valid for the static lifetime... + | ...so that the type `T` will meet its required lifetime bounds + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: consider adding an explicit lifetime bound + | +LL | fn test<T: 'static>() { + | +++++++++ + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0310`. diff --git a/tests/ui/type-alias-impl-trait/wf-nested.rs b/tests/ui/type-alias-impl-trait/wf-nested.rs index de388329489..2f90c4e00e3 100644 --- a/tests/ui/type-alias-impl-trait/wf-nested.rs +++ b/tests/ui/type-alias-impl-trait/wf-nested.rs @@ -43,7 +43,9 @@ mod pass_sound { fn test<T>() { let outer = define::<T>(); - let _ = outer.get(); //[pass_sound]~ ERROR `T` may not live long enough + let _ = outer.get(); + //[pass_sound]~^ ERROR `T` may not live long enough + //[pass_sound]~| ERROR `T` may not live long enough } } diff --git a/tests/ui/wf/wf-associated-const.rs b/tests/ui/wf/wf-associated-const.rs new file mode 100644 index 00000000000..629d807cb7f --- /dev/null +++ b/tests/ui/wf/wf-associated-const.rs @@ -0,0 +1,41 @@ +// check that associated consts can assume the impl header is well-formed. + +trait Foo<'a, 'b, T>: Sized { + const EVIL: fn(u: &'b u32) -> &'a u32; +} + +struct Evil<'a, 'b: 'a>(Option<&'a &'b ()>); + +impl<'a, 'b> Foo<'a, 'b, Evil<'a, 'b>> for () { + const EVIL: fn(&'b u32) -> &'a u32 = { |u| u }; +} + +struct IndirectEvil<'a, 'b: 'a>(Option<&'a &'b ()>); + +impl<'a, 'b> Foo<'a, 'b, ()> for IndirectEvil<'a, 'b> { + const EVIL: fn(&'b u32) -> &'a u32 = { |u| u }; +} + +impl<'a, 'b> Evil<'a, 'b> { + const INHERENT_EVIL: fn(&'b u32) -> &'a u32 = { |u| u }; +} + +// while static methods can *assume* this, we should still +// *check* that it holds at the use site. + +fn evil<'a, 'b>(b: &'b u32) -> &'a u32 { + <()>::EVIL(b) + //~^ ERROR lifetime may not live long enough +} + +fn indirect_evil<'a, 'b>(b: &'b u32) -> &'a u32 { + <IndirectEvil>::EVIL(b) + //~^ ERROR lifetime may not live long enough +} + +fn inherent_evil<'a, 'b>(b: &'b u32) -> &'a u32 { + <Evil>::INHERENT_EVIL(b) + //~^ ERROR lifetime may not live long enough +} + +fn main() {} diff --git a/tests/ui/wf/wf-associated-const.stderr b/tests/ui/wf/wf-associated-const.stderr new file mode 100644 index 00000000000..b0e1a118fab --- /dev/null +++ b/tests/ui/wf/wf-associated-const.stderr @@ -0,0 +1,38 @@ +error: lifetime may not live long enough + --> $DIR/wf-associated-const.rs:27:5 + | +LL | fn evil<'a, 'b>(b: &'b u32) -> &'a u32 { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +LL | <()>::EVIL(b) + | ^^^^^^^^^^^^^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b` + | + = help: consider adding the following bound: `'b: 'a` + +error: lifetime may not live long enough + --> $DIR/wf-associated-const.rs:32:5 + | +LL | fn indirect_evil<'a, 'b>(b: &'b u32) -> &'a u32 { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +LL | <IndirectEvil>::EVIL(b) + | ^^^^^^^^^^^^^^^^^^^^^^^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b` + | + = help: consider adding the following bound: `'b: 'a` + +error: lifetime may not live long enough + --> $DIR/wf-associated-const.rs:37:5 + | +LL | fn inherent_evil<'a, 'b>(b: &'b u32) -> &'a u32 { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +LL | <Evil>::INHERENT_EVIL(b) + | ^^^^^^^^^^^^^^^^^^^^^^^^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b` + | + = help: consider adding the following bound: `'b: 'a` + +error: aborting due to 3 previous errors + diff --git a/tests/ui/wf/wf-in-fn-type-implicit.rs b/tests/ui/wf/wf-in-fn-type-implicit.rs deleted file mode 100644 index c5ff92c8875..00000000000 --- a/tests/ui/wf/wf-in-fn-type-implicit.rs +++ /dev/null @@ -1,37 +0,0 @@ -// check-pass -// known-bug: #104005 - -// Should fail. Function type parameters with implicit type annotations are not -// checked for well-formedness, which allows incorrect borrowing. - -// In contrast, user annotations are always checked for well-formedness, and the -// commented code below is correctly rejected by the borrow checker. - -use std::fmt::Display; - -trait Displayable { - fn display(self) -> Box<dyn Display>; -} - -impl<T: Display> Displayable for (T, Option<&'static T>) { - fn display(self) -> Box<dyn Display> { - Box::new(self.0) - } -} - -fn extend_lt<T, U>(val: T) -> Box<dyn Display> -where - (T, Option<U>): Displayable, -{ - Displayable::display((val, None)) -} - -fn main() { - // *incorrectly* compiles - let val = extend_lt(&String::from("blah blah blah")); - println!("{}", val); - - // *correctly* fails to compile - // let val = extend_lt::<_, &_>(&String::from("blah blah blah")); - // println!("{}", val); -} diff --git a/tests/ui/wf/wf-static-method.rs b/tests/ui/wf/wf-static-method.rs index 7ff195230bf..66546ac489d 100644 --- a/tests/ui/wf/wf-static-method.rs +++ b/tests/ui/wf/wf-static-method.rs @@ -1,8 +1,4 @@ -// check that static methods don't get to assume their trait-ref -// is well-formed. -// FIXME(#27579): this is just a bug. However, our checking with -// static inherent methods isn't quite working - need to -// fix that before removing the check. +// check that static methods can assume their trait-ref is well-formed. trait Foo<'a, 'b, T>: Sized { fn make_me() -> Self { loop {} } @@ -15,7 +11,6 @@ impl<'a, 'b> Foo<'a, 'b, Evil<'a, 'b>> for () { fn make_me() -> Self { } fn static_evil(u: &'b u32) -> &'a u32 { u - //~^ ERROR lifetime may not live long enough } } @@ -25,7 +20,6 @@ impl<'a, 'b> Foo<'a, 'b, ()> for IndirectEvil<'a, 'b> { fn make_me() -> Self { IndirectEvil(None) } fn static_evil(u: &'b u32) -> &'a u32 { let me = Self::make_me(); - //~^ ERROR lifetime may not live long enough loop {} // (`me` could be used for the lifetime transmute). } } @@ -33,12 +27,11 @@ impl<'a, 'b> Foo<'a, 'b, ()> for IndirectEvil<'a, 'b> { impl<'a, 'b> Evil<'a, 'b> { fn inherent_evil(u: &'b u32) -> &'a u32 { u - //~^ ERROR lifetime may not live long enough } } -// while static methods don't get to *assume* this, we still -// *check* that they hold. +// while static methods can *assume* this, we should still +// *check* that it holds at the use site. fn evil<'a, 'b>(b: &'b u32) -> &'a u32 { <()>::static_evil(b) diff --git a/tests/ui/wf/wf-static-method.stderr b/tests/ui/wf/wf-static-method.stderr index 161609a5f86..6c49098aad3 100644 --- a/tests/ui/wf/wf-static-method.stderr +++ b/tests/ui/wf/wf-static-method.stderr @@ -1,44 +1,5 @@ error: lifetime may not live long enough - --> $DIR/wf-static-method.rs:17:9 - | -LL | impl<'a, 'b> Foo<'a, 'b, Evil<'a, 'b>> for () { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -... -LL | u - | ^ associated function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b` - | - = help: consider adding the following bound: `'b: 'a` - -error: lifetime may not live long enough - --> $DIR/wf-static-method.rs:27:18 - | -LL | impl<'a, 'b> Foo<'a, 'b, ()> for IndirectEvil<'a, 'b> { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -... -LL | let me = Self::make_me(); - | ^^^^^^^^^^^^^ requires that `'b` must outlive `'a` - | - = help: consider adding the following bound: `'b: 'a` - -error: lifetime may not live long enough - --> $DIR/wf-static-method.rs:35:9 - | -LL | impl<'a, 'b> Evil<'a, 'b> { - | -- -- lifetime `'b` defined here - | | - | lifetime `'a` defined here -LL | fn inherent_evil(u: &'b u32) -> &'a u32 { -LL | u - | ^ associated function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b` - | - = help: consider adding the following bound: `'b: 'a` - -error: lifetime may not live long enough - --> $DIR/wf-static-method.rs:44:5 + --> $DIR/wf-static-method.rs:37:5 | LL | fn evil<'a, 'b>(b: &'b u32) -> &'a u32 { | -- -- lifetime `'b` defined here @@ -50,7 +11,7 @@ LL | <()>::static_evil(b) = help: consider adding the following bound: `'b: 'a` error: lifetime may not live long enough - --> $DIR/wf-static-method.rs:49:5 + --> $DIR/wf-static-method.rs:42:5 | LL | fn indirect_evil<'a, 'b>(b: &'b u32) -> &'a u32 { | -- -- lifetime `'b` defined here @@ -62,7 +23,7 @@ LL | <IndirectEvil>::static_evil(b) = help: consider adding the following bound: `'b: 'a` error: lifetime may not live long enough - --> $DIR/wf-static-method.rs:54:5 + --> $DIR/wf-static-method.rs:47:5 | LL | fn inherent_evil<'a, 'b>(b: &'b u32) -> &'a u32 { | -- -- lifetime `'b` defined here @@ -73,5 +34,5 @@ LL | <Evil>::inherent_evil(b) | = help: consider adding the following bound: `'b: 'a` -error: aborting due to 6 previous errors +error: aborting due to 3 previous errors |
