diff options
Diffstat (limited to 'tests')
313 files changed, 7949 insertions, 4307 deletions
diff --git a/tests/codegen/comparison-operators-2-tuple.rs b/tests/codegen/comparison-operators-2-tuple.rs index 7a2a3fc93f8..633cfe3a8ac 100644 --- a/tests/codegen/comparison-operators-2-tuple.rs +++ b/tests/codegen/comparison-operators-2-tuple.rs @@ -10,8 +10,10 @@ type TwoTuple = (i16, u16); // // The operators are all overridden directly, so should optimize easily. // -// Yes, the `s[lg]t` is correct for the `[lg]e` version because it's only used -// in the side of the select where we know the values are *not* equal. +// slt-vs-sle and sgt-vs-sge don't matter because they're only used in the side +// of the select where we know the values are not equal, and thus the tests +// use a regex to allow either, since unimportant changes to the implementation +// sometimes result in changing what LLVM decides to emit for this. // // CHECK-LABEL: @check_lt_direct @@ -19,7 +21,7 @@ type TwoTuple = (i16, u16); #[no_mangle] pub fn check_lt_direct(a: TwoTuple, b: TwoTuple) -> bool { // CHECK-DAG: %[[EQ:.+]] = icmp eq i16 %[[A0]], %[[B0]] - // CHECK-DAG: %[[CMP0:.+]] = icmp slt i16 %[[A0]], %[[B0]] + // CHECK-DAG: %[[CMP0:.+]] = icmp {{slt|sle}} i16 %[[A0]], %[[B0]] // CHECK-DAG: %[[CMP1:.+]] = icmp ult i16 %[[A1]], %[[B1]] // CHECK: %[[R:.+]] = select i1 %[[EQ]], i1 %[[CMP1]], i1 %[[CMP0]] // CHECK: ret i1 %[[R]] @@ -31,7 +33,7 @@ pub fn check_lt_direct(a: TwoTuple, b: TwoTuple) -> bool { #[no_mangle] pub fn check_le_direct(a: TwoTuple, b: TwoTuple) -> bool { // CHECK-DAG: %[[EQ:.+]] = icmp eq i16 %[[A0]], %[[B0]] - // CHECK-DAG: %[[CMP0:.+]] = icmp slt i16 %[[A0]], %[[B0]] + // CHECK-DAG: %[[CMP0:.+]] = icmp {{slt|sle}} i16 %[[A0]], %[[B0]] // CHECK-DAG: %[[CMP1:.+]] = icmp ule i16 %[[A1]], %[[B1]] // CHECK: %[[R:.+]] = select i1 %[[EQ]], i1 %[[CMP1]], i1 %[[CMP0]] // CHECK: ret i1 %[[R]] @@ -43,7 +45,7 @@ pub fn check_le_direct(a: TwoTuple, b: TwoTuple) -> bool { #[no_mangle] pub fn check_gt_direct(a: TwoTuple, b: TwoTuple) -> bool { // CHECK-DAG: %[[EQ:.+]] = icmp eq i16 %[[A0]], %[[B0]] - // CHECK-DAG: %[[CMP0:.+]] = icmp sgt i16 %[[A0]], %[[B0]] + // CHECK-DAG: %[[CMP0:.+]] = icmp {{sgt|sge}} i16 %[[A0]], %[[B0]] // CHECK-DAG: %[[CMP1:.+]] = icmp ugt i16 %[[A1]], %[[B1]] // CHECK: %[[R:.+]] = select i1 %[[EQ]], i1 %[[CMP1]], i1 %[[CMP0]] // CHECK: ret i1 %[[R]] @@ -55,7 +57,7 @@ pub fn check_gt_direct(a: TwoTuple, b: TwoTuple) -> bool { #[no_mangle] pub fn check_ge_direct(a: TwoTuple, b: TwoTuple) -> bool { // CHECK-DAG: %[[EQ:.+]] = icmp eq i16 %[[A0]], %[[B0]] - // CHECK-DAG: %[[CMP0:.+]] = icmp sgt i16 %[[A0]], %[[B0]] + // CHECK-DAG: %[[CMP0:.+]] = icmp {{sgt|sge}} i16 %[[A0]], %[[B0]] // CHECK-DAG: %[[CMP1:.+]] = icmp uge i16 %[[A1]], %[[B1]] // CHECK: %[[R:.+]] = select i1 %[[EQ]], i1 %[[CMP1]], i1 %[[CMP0]] // CHECK: ret i1 %[[R]] diff --git a/tests/codegen/iter-repeat-n-trivial-drop.rs b/tests/codegen/iter-repeat-n-trivial-drop.rs index 0b08e578151..b052d339917 100644 --- a/tests/codegen/iter-repeat-n-trivial-drop.rs +++ b/tests/codegen/iter-repeat-n-trivial-drop.rs @@ -47,7 +47,7 @@ pub fn iter_repeat_n_next(it: &mut std::iter::RepeatN<NotCopy>) -> Option<NotCop #[no_mangle] // CHECK-LABEL: @vec_extend_via_iter_repeat_n pub fn vec_extend_via_iter_repeat_n() -> Vec<u8> { - // CHECK: %[[ADDR:.+]] = tail call noundef dereferenceable_or_null(1234) ptr @__rust_alloc(i64 noundef 1234, i64 noundef 1) + // CHECK: %[[ADDR:.+]] = tail call {{(noalias )?}}noundef dereferenceable_or_null(1234) ptr @__rust_alloc(i64 noundef 1234, i64 noundef 1) // CHECK: tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(1234) %[[ADDR]], i8 42, i64 1234, let n = 1234_usize; diff --git a/tests/coverage/closure.cov-map b/tests/coverage/closure.cov-map index 921ca6cf4e1..9f0d33745bc 100644 --- a/tests/coverage/closure.cov-map +++ b/tests/coverage/closure.cov-map @@ -33,20 +33,16 @@ Number of file 0 mappings: 24 - Code(Expression(1, Add)) at (prev + 1, 5) to (start + 3, 2) = (c1 + (c0 - c1)) -Function name: closure::main::{closure#0} -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 28, 05, 02, 14, 05, 02, 15, 02, 0a, 02, 02, 0a, 00, 0b, 07, 01, 09, 01, 06] +Function name: closure::main::{closure#0} (unused) +Raw bytes (24): 0x[01, 01, 00, 04, 00, 28, 05, 02, 14, 00, 02, 15, 02, 0a, 00, 02, 0a, 00, 0b, 00, 01, 09, 01, 06] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 -- expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of expressions: 0 Number of file 0 mappings: 4 -- Code(Counter(0)) at (prev + 40, 5) to (start + 2, 20) -- Code(Counter(1)) at (prev + 2, 21) to (start + 2, 10) -- Code(Expression(0, Sub)) at (prev + 2, 10) to (start + 0, 11) - = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 1, 9) to (start + 1, 6) - = (c1 + (c0 - c1)) +- Code(Zero) at (prev + 40, 5) to (start + 2, 20) +- Code(Zero) at (prev + 2, 21) to (start + 2, 10) +- Code(Zero) at (prev + 2, 10) to (start + 0, 11) +- Code(Zero) at (prev + 1, 9) to (start + 1, 6) Function name: closure::main::{closure#10} (unused) Raw bytes (10): 0x[01, 01, 00, 01, 00, 9b, 01, 07, 00, 21] @@ -148,20 +144,16 @@ Number of file 0 mappings: 6 - Code(Expression(0, Add)) at (prev + 2, 9) to (start + 0, 10) = (c1 + (c0 - c1)) -Function name: closure::main::{closure#18} -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 19, 0d, 02, 1c, 05, 02, 1d, 02, 12, 02, 02, 12, 00, 13, 07, 01, 11, 01, 0e] +Function name: closure::main::{closure#18} (unused) +Raw bytes (24): 0x[01, 01, 00, 04, 00, 19, 0d, 02, 1c, 00, 02, 1d, 02, 12, 00, 02, 12, 00, 13, 00, 01, 11, 01, 0e] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 -- expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Counter(1), rhs = Expression(0, Sub) +Number of expressions: 0 Number of file 0 mappings: 4 -- Code(Counter(0)) at (prev + 25, 13) to (start + 2, 28) -- Code(Counter(1)) at (prev + 2, 29) to (start + 2, 18) -- Code(Expression(0, Sub)) at (prev + 2, 18) to (start + 0, 19) - = (c0 - c1) -- Code(Expression(1, Add)) at (prev + 1, 17) to (start + 1, 14) - = (c1 + (c0 - c1)) +- Code(Zero) at (prev + 25, 13) to (start + 2, 28) +- Code(Zero) at (prev + 2, 29) to (start + 2, 18) +- Code(Zero) at (prev + 2, 18) to (start + 0, 19) +- Code(Zero) at (prev + 1, 17) to (start + 1, 14) Function name: closure::main::{closure#19} Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 43, 0d, 02, 1c, 05, 02, 1d, 02, 12, 02, 02, 12, 00, 13, 07, 01, 11, 01, 0e] diff --git a/tests/coverage/issue-84561.cov-map b/tests/coverage/issue-84561.cov-map index 88436964af0..a81884ea942 100644 --- a/tests/coverage/issue-84561.cov-map +++ b/tests/coverage/issue-84561.cov-map @@ -77,7 +77,7 @@ Number of file 0 mappings: 1 - Code(Counter(0)) at (prev + 167, 9) to (start + 2, 10) Function name: issue_84561::test3 -Raw bytes (436): 0x[01, 01, 41, 05, 09, 0d, 00, 15, 19, 12, 00, 15, 19, 21, 00, 1e, 00, 21, 00, 31, 00, 3d, 41, 2e, 45, 3d, 41, 42, 49, 45, 00, 3f, 51, 42, 49, 45, 00, 5d, 8a, 01, 8f, 01, 5d, 92, 01, 55, 51, 00, 92, 01, 55, 51, 00, 8f, 01, 5d, 92, 01, 55, 51, 00, 87, 01, 61, 5d, 8a, 01, 8f, 01, 5d, 92, 01, 55, 51, 00, 82, 01, 65, 87, 01, 61, 5d, 8a, 01, 8f, 01, 5d, 92, 01, 55, 51, 00, 75, f6, 01, fb, 01, 79, 71, fe, 01, 82, 02, 71, 69, 6d, 71, fe, 01, 82, 02, 71, 69, 6d, 69, 6d, 82, 02, 71, 69, 6d, fb, 01, 79, 71, fe, 01, 82, 02, 71, 69, 6d, f3, 01, 7d, 75, f6, 01, fb, 01, 79, 71, fe, 01, 82, 02, 71, 69, 6d, ee, 01, 00, f3, 01, 7d, 75, f6, 01, fb, 01, 79, 71, fe, 01, 82, 02, 71, 69, 6d, 33, 01, 08, 01, 03, 1c, 05, 04, 09, 01, 1c, 02, 02, 05, 04, 1f, 0d, 05, 05, 00, 1f, 06, 01, 05, 00, 1f, 15, 01, 09, 01, 1c, 12, 02, 05, 00, 1f, 0e, 01, 05, 00, 0f, 00, 00, 20, 00, 30, 21, 01, 05, 03, 0f, 00, 03, 20, 00, 30, 00, 00, 33, 00, 41, 00, 00, 4b, 00, 5a, 1e, 01, 05, 00, 0f, 00, 05, 09, 03, 10, 00, 05, 0d, 00, 1b, 00, 02, 0d, 00, 1c, 1a, 04, 09, 05, 06, 31, 06, 05, 03, 06, 22, 04, 05, 03, 06, 3d, 04, 09, 04, 06, 2e, 05, 08, 00, 0f, 45, 01, 09, 03, 0a, 2a, 05, 09, 03, 0a, 3f, 05, 08, 00, 0f, 51, 01, 09, 00, 13, 00, 03, 0d, 00, 1d, 3a, 03, 09, 00, 13, 00, 03, 0d, 00, 1d, 87, 01, 03, 05, 00, 0f, 8f, 01, 01, 0c, 00, 13, 5d, 01, 0d, 00, 13, 8a, 01, 02, 0d, 00, 13, 82, 01, 04, 05, 02, 13, 65, 03, 0d, 00, 13, 7e, 02, 0d, 00, 13, f3, 01, 03, 05, 00, 0f, 69, 01, 0c, 00, 13, 6d, 01, 0d, 03, 0e, 75, 04, 0d, 00, 13, fb, 01, 02, 0d, 00, 17, 82, 02, 01, 14, 00, 1b, 71, 01, 15, 00, 1b, fe, 01, 02, 15, 00, 1b, f6, 01, 04, 0d, 00, 13, 7d, 03, 09, 00, 19, ee, 01, 02, 05, 00, 0f, ea, 01, 03, 09, 00, 22, 00, 02, 05, 00, 0f, 00, 03, 09, 00, 2c, 00, 02, 01, 00, 02] +Raw bytes (436): 0x[01, 01, 41, 05, 09, 0d, 00, 15, 19, 12, 00, 15, 19, 21, 00, 1e, 00, 21, 00, 31, 00, 3d, 41, 2e, 45, 3d, 41, 42, 49, 45, 00, 3f, 51, 42, 49, 45, 00, 5d, 8a, 01, 8f, 01, 5d, 92, 01, 55, 51, 00, 92, 01, 55, 51, 00, 8f, 01, 5d, 92, 01, 55, 51, 00, 87, 01, 61, 5d, 8a, 01, 8f, 01, 5d, 92, 01, 55, 51, 00, 82, 01, 65, 87, 01, 61, 5d, 8a, 01, 8f, 01, 5d, 92, 01, 55, 51, 00, 75, f6, 01, fb, 01, 79, 00, fe, 01, 82, 02, 00, 69, 6d, 00, fe, 01, 82, 02, 00, 69, 6d, 69, 6d, 82, 02, 00, 69, 6d, fb, 01, 79, 00, fe, 01, 82, 02, 00, 69, 6d, f3, 01, 7d, 75, f6, 01, fb, 01, 79, 00, fe, 01, 82, 02, 00, 69, 6d, ee, 01, 00, f3, 01, 7d, 75, f6, 01, fb, 01, 79, 00, fe, 01, 82, 02, 00, 69, 6d, 33, 01, 08, 01, 03, 1c, 05, 04, 09, 01, 1c, 02, 02, 05, 04, 1f, 0d, 05, 05, 00, 1f, 06, 01, 05, 00, 1f, 15, 01, 09, 01, 1c, 12, 02, 05, 00, 1f, 0e, 01, 05, 00, 0f, 00, 00, 20, 00, 30, 21, 01, 05, 03, 0f, 00, 03, 20, 00, 30, 00, 00, 33, 00, 41, 00, 00, 4b, 00, 5a, 1e, 01, 05, 00, 0f, 00, 05, 09, 03, 10, 00, 05, 0d, 00, 1b, 00, 02, 0d, 00, 1c, 1a, 04, 09, 05, 06, 31, 06, 05, 03, 06, 22, 04, 05, 03, 06, 3d, 04, 09, 04, 06, 2e, 05, 08, 00, 0f, 45, 01, 09, 03, 0a, 2a, 05, 09, 03, 0a, 3f, 05, 08, 00, 0f, 51, 01, 09, 00, 13, 00, 03, 0d, 00, 1d, 3a, 03, 09, 00, 13, 00, 03, 0d, 00, 1d, 87, 01, 03, 05, 00, 0f, 8f, 01, 01, 0c, 00, 13, 5d, 01, 0d, 00, 13, 8a, 01, 02, 0d, 00, 13, 82, 01, 04, 05, 02, 13, 65, 03, 0d, 00, 13, 7e, 02, 0d, 00, 13, f3, 01, 03, 05, 00, 0f, 69, 01, 0c, 00, 13, 6d, 01, 0d, 03, 0e, 75, 04, 0d, 00, 13, fb, 01, 02, 0d, 00, 17, 82, 02, 01, 14, 00, 1b, 00, 01, 15, 00, 1b, fe, 01, 02, 15, 00, 1b, f6, 01, 04, 0d, 00, 13, 7d, 03, 09, 00, 19, ee, 01, 02, 05, 00, 0f, ea, 01, 03, 09, 00, 22, 00, 02, 05, 00, 0f, 00, 03, 09, 00, 2c, 00, 02, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 65 @@ -120,31 +120,31 @@ Number of expressions: 65 - expression 36 operands: lhs = Counter(20), rhs = Zero - expression 37 operands: lhs = Counter(29), rhs = Expression(61, Sub) - expression 38 operands: lhs = Expression(62, Add), rhs = Counter(30) -- expression 39 operands: lhs = Counter(28), rhs = Expression(63, Sub) -- expression 40 operands: lhs = Expression(64, Sub), rhs = Counter(28) +- expression 39 operands: lhs = Zero, rhs = Expression(63, Sub) +- expression 40 operands: lhs = Expression(64, Sub), rhs = Zero - expression 41 operands: lhs = Counter(26), rhs = Counter(27) -- expression 42 operands: lhs = Counter(28), rhs = Expression(63, Sub) -- expression 43 operands: lhs = Expression(64, Sub), rhs = Counter(28) +- expression 42 operands: lhs = Zero, rhs = Expression(63, Sub) +- expression 43 operands: lhs = Expression(64, Sub), rhs = Zero - expression 44 operands: lhs = Counter(26), rhs = Counter(27) - expression 45 operands: lhs = Counter(26), rhs = Counter(27) -- expression 46 operands: lhs = Expression(64, Sub), rhs = Counter(28) +- expression 46 operands: lhs = Expression(64, Sub), rhs = Zero - expression 47 operands: lhs = Counter(26), rhs = Counter(27) - expression 48 operands: lhs = Expression(62, Add), rhs = Counter(30) -- expression 49 operands: lhs = Counter(28), rhs = Expression(63, Sub) -- expression 50 operands: lhs = Expression(64, Sub), rhs = Counter(28) +- expression 49 operands: lhs = Zero, rhs = Expression(63, Sub) +- expression 50 operands: lhs = Expression(64, Sub), rhs = Zero - expression 51 operands: lhs = Counter(26), rhs = Counter(27) - expression 52 operands: lhs = Expression(60, Add), rhs = Counter(31) - expression 53 operands: lhs = Counter(29), rhs = Expression(61, Sub) - expression 54 operands: lhs = Expression(62, Add), rhs = Counter(30) -- expression 55 operands: lhs = Counter(28), rhs = Expression(63, Sub) -- expression 56 operands: lhs = Expression(64, Sub), rhs = Counter(28) +- expression 55 operands: lhs = Zero, rhs = Expression(63, Sub) +- expression 56 operands: lhs = Expression(64, Sub), rhs = Zero - expression 57 operands: lhs = Counter(26), rhs = Counter(27) - expression 58 operands: lhs = Expression(59, Sub), rhs = Zero - expression 59 operands: lhs = Expression(60, Add), rhs = Counter(31) - expression 60 operands: lhs = Counter(29), rhs = Expression(61, Sub) - expression 61 operands: lhs = Expression(62, Add), rhs = Counter(30) -- expression 62 operands: lhs = Counter(28), rhs = Expression(63, Sub) -- expression 63 operands: lhs = Expression(64, Sub), rhs = Counter(28) +- expression 62 operands: lhs = Zero, rhs = Expression(63, Sub) +- expression 63 operands: lhs = Expression(64, Sub), rhs = Zero - expression 64 operands: lhs = Counter(26), rhs = Counter(27) Number of file 0 mappings: 51 - Code(Counter(0)) at (prev + 8, 1) to (start + 3, 28) @@ -200,24 +200,24 @@ Number of file 0 mappings: 51 - Code(Expression(31, Sub)) at (prev + 2, 13) to (start + 0, 19) = (((c23 + (((c20 - Zero) + c21) - c23)) - c24) - c25) - Code(Expression(60, Add)) at (prev + 3, 5) to (start + 0, 15) - = (c29 + ((c28 + ((c26 - c27) - c28)) - c30)) + = (c29 + ((Zero + ((c26 - c27) - Zero)) - c30)) - Code(Counter(26)) at (prev + 1, 12) to (start + 0, 19) - Code(Counter(27)) at (prev + 1, 13) to (start + 3, 14) - Code(Counter(29)) at (prev + 4, 13) to (start + 0, 19) - Code(Expression(62, Add)) at (prev + 2, 13) to (start + 0, 23) - = (c28 + ((c26 - c27) - c28)) + = (Zero + ((c26 - c27) - Zero)) - Code(Expression(64, Sub)) at (prev + 1, 20) to (start + 0, 27) = (c26 - c27) -- Code(Counter(28)) at (prev + 1, 21) to (start + 0, 27) +- Code(Zero) at (prev + 1, 21) to (start + 0, 27) - Code(Expression(63, Sub)) at (prev + 2, 21) to (start + 0, 27) - = ((c26 - c27) - c28) + = ((c26 - c27) - Zero) - Code(Expression(61, Sub)) at (prev + 4, 13) to (start + 0, 19) - = ((c28 + ((c26 - c27) - c28)) - c30) + = ((Zero + ((c26 - c27) - Zero)) - c30) - Code(Counter(31)) at (prev + 3, 9) to (start + 0, 25) - Code(Expression(59, Sub)) at (prev + 2, 5) to (start + 0, 15) - = ((c29 + ((c28 + ((c26 - c27) - c28)) - c30)) - c31) + = ((c29 + ((Zero + ((c26 - c27) - Zero)) - c30)) - c31) - Code(Expression(58, Sub)) at (prev + 3, 9) to (start + 0, 34) - = (((c29 + ((c28 + ((c26 - c27) - c28)) - c30)) - c31) - Zero) + = (((c29 + ((Zero + ((c26 - c27) - Zero)) - c30)) - c31) - Zero) - Code(Zero) at (prev + 2, 5) to (start + 0, 15) - Code(Zero) at (prev + 3, 9) to (start + 0, 44) - Code(Zero) at (prev + 2, 1) to (start + 0, 2) diff --git a/tests/coverage/try_error_result.cov-map b/tests/coverage/try_error_result.cov-map index 5cfb40ce528..83f1869a31e 100644 --- a/tests/coverage/try_error_result.cov-map +++ b/tests/coverage/try_error_result.cov-map @@ -59,162 +59,131 @@ Number of file 0 mappings: 4 = (c1 + (c0 - c1)) Function name: try_error_result::test1 -Raw bytes (77): 0x[01, 01, 09, 01, 07, 05, 09, 03, 0d, 1d, 11, 16, 1d, 03, 0d, 1f, 0d, 23, 19, 11, 15, 0b, 01, 0d, 01, 02, 17, 03, 07, 09, 00, 0e, 16, 02, 09, 04, 1a, 1d, 06, 0d, 00, 29, 11, 00, 29, 00, 2a, 0e, 01, 0d, 00, 2a, 15, 00, 2a, 00, 2b, 12, 04, 0d, 00, 2a, 19, 00, 2a, 00, 2b, 0d, 03, 05, 00, 0b, 1b, 01, 01, 00, 02] +Raw bytes (75): 0x[01, 01, 08, 01, 07, 00, 09, 03, 0d, 12, 1d, 03, 0d, 1b, 0d, 1f, 00, 11, 00, 0b, 01, 0d, 01, 02, 17, 03, 07, 09, 00, 0e, 12, 02, 09, 04, 1a, 1d, 06, 0d, 00, 29, 11, 00, 29, 00, 2a, 00, 01, 0d, 00, 2a, 00, 00, 2a, 00, 2b, 0e, 04, 0d, 00, 2a, 00, 00, 2a, 00, 2b, 0d, 03, 05, 00, 0b, 17, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 9 +Number of expressions: 8 - expression 0 operands: lhs = Counter(0), rhs = Expression(1, Add) -- expression 1 operands: lhs = Counter(1), rhs = Counter(2) +- expression 1 operands: lhs = Zero, rhs = Counter(2) - expression 2 operands: lhs = Expression(0, Add), rhs = Counter(3) -- expression 3 operands: lhs = Counter(7), rhs = Counter(4) -- expression 4 operands: lhs = Expression(5, Sub), rhs = Counter(7) -- expression 5 operands: lhs = Expression(0, Add), rhs = Counter(3) -- expression 6 operands: lhs = Expression(7, Add), rhs = Counter(3) -- expression 7 operands: lhs = Expression(8, Add), rhs = Counter(6) -- expression 8 operands: lhs = Counter(4), rhs = Counter(5) +- expression 3 operands: lhs = Expression(4, Sub), rhs = Counter(7) +- expression 4 operands: lhs = Expression(0, Add), rhs = Counter(3) +- expression 5 operands: lhs = Expression(6, Add), rhs = Counter(3) +- expression 6 operands: lhs = Expression(7, Add), rhs = Zero +- expression 7 operands: lhs = Counter(4), rhs = Zero Number of file 0 mappings: 11 - Code(Counter(0)) at (prev + 13, 1) to (start + 2, 23) - Code(Expression(0, Add)) at (prev + 7, 9) to (start + 0, 14) - = (c0 + (c1 + c2)) -- Code(Expression(5, Sub)) at (prev + 2, 9) to (start + 4, 26) - = ((c0 + (c1 + c2)) - c3) + = (c0 + (Zero + c2)) +- Code(Expression(4, Sub)) at (prev + 2, 9) to (start + 4, 26) + = ((c0 + (Zero + c2)) - c3) - Code(Counter(7)) at (prev + 6, 13) to (start + 0, 41) - Code(Counter(4)) at (prev + 0, 41) to (start + 0, 42) -- Code(Expression(3, Sub)) at (prev + 1, 13) to (start + 0, 42) - = (c7 - c4) -- Code(Counter(5)) at (prev + 0, 42) to (start + 0, 43) -- Code(Expression(4, Sub)) at (prev + 4, 13) to (start + 0, 42) - = (((c0 + (c1 + c2)) - c3) - c7) -- Code(Counter(6)) at (prev + 0, 42) to (start + 0, 43) +- Code(Zero) at (prev + 1, 13) to (start + 0, 42) +- Code(Zero) at (prev + 0, 42) to (start + 0, 43) +- Code(Expression(3, Sub)) at (prev + 4, 13) to (start + 0, 42) + = (((c0 + (Zero + c2)) - c3) - c7) +- Code(Zero) at (prev + 0, 42) to (start + 0, 43) - Code(Counter(3)) at (prev + 3, 5) to (start + 0, 11) -- Code(Expression(6, Add)) at (prev + 1, 1) to (start + 0, 2) - = (((c4 + c5) + c6) + c3) +- Code(Expression(5, Add)) at (prev + 1, 1) to (start + 0, 2) + = (((c4 + Zero) + Zero) + c3) Function name: try_error_result::test2 -Raw bytes (358): 0x[01, 01, 3b, 01, 07, 05, 09, 03, 0d, 41, 11, 4a, 15, 41, 11, 42, 1d, 46, 19, 4a, 15, 41, 11, 4a, 15, 41, 11, 46, 19, 4a, 15, 41, 11, 42, 1d, 46, 19, 4a, 15, 41, 11, 5e, 25, 49, 21, 49, 21, 5e, 25, 49, 21, 8a, 01, 2d, 8e, 01, 29, 92, 01, 41, 03, 0d, 92, 01, 41, 03, 0d, 8e, 01, 29, 92, 01, 41, 03, 0d, 8a, 01, 2d, 8e, 01, 29, 92, 01, 41, 03, 0d, a6, 01, 35, 45, 31, 45, 31, a6, 01, 35, 45, 31, ba, 01, 3d, 4d, 39, 4d, 39, ba, 01, 3d, 4d, 39, c3, 01, 0d, c7, 01, db, 01, cb, 01, cf, 01, 11, 15, d3, 01, d7, 01, 19, 1d, 21, 25, df, 01, e3, 01, 29, 2d, e7, 01, eb, 01, 31, 35, 39, 3d, 28, 01, 3e, 01, 03, 17, 03, 08, 09, 00, 0e, 92, 01, 02, 09, 04, 1a, 41, 06, 0d, 00, 2f, 11, 00, 2f, 00, 30, 4a, 00, 31, 03, 35, 15, 04, 11, 00, 12, 46, 02, 11, 04, 12, 3e, 05, 11, 00, 14, 46, 00, 17, 00, 41, 19, 00, 41, 00, 42, 42, 00, 43, 00, 5f, 1d, 00, 5f, 00, 60, 3e, 01, 0d, 00, 20, 5a, 01, 11, 00, 14, 49, 00, 17, 00, 41, 21, 00, 41, 00, 42, 5e, 00, 43, 00, 60, 25, 00, 60, 00, 61, 5a, 01, 0d, 00, 20, 86, 01, 04, 11, 00, 14, 8e, 01, 00, 17, 00, 42, 29, 00, 42, 00, 43, 8a, 01, 00, 44, 00, 61, 2d, 00, 61, 00, 62, 86, 01, 01, 0d, 00, 20, a2, 01, 01, 11, 00, 14, 45, 00, 17, 01, 36, 31, 01, 36, 00, 37, a6, 01, 01, 12, 00, 2f, 35, 00, 2f, 00, 30, a2, 01, 01, 0d, 00, 20, b6, 01, 01, 11, 00, 14, 4d, 00, 17, 01, 36, 39, 02, 11, 00, 12, ba, 01, 01, 12, 00, 2f, 3d, 01, 11, 00, 12, b6, 01, 02, 0d, 00, 20, 0d, 03, 05, 00, 0b, bf, 01, 01, 01, 00, 02] +Raw bytes (280): 0x[01, 01, 24, 01, 07, 00, 09, 03, 0d, 41, 00, 1e, 00, 41, 00, 1e, 00, 41, 00, 4a, 00, 4e, 00, 52, 41, 03, 0d, 52, 41, 03, 0d, 4e, 00, 52, 41, 03, 0d, 4a, 00, 4e, 00, 52, 41, 03, 0d, 66, 00, 45, 00, 45, 00, 66, 00, 45, 00, 7a, 00, 4d, 00, 4d, 00, 7a, 00, 4d, 00, 83, 01, 0d, 87, 01, 00, 00, 8b, 01, 8f, 01, 00, 19, 00, 28, 01, 3e, 01, 03, 17, 03, 08, 09, 00, 0e, 52, 02, 09, 04, 1a, 41, 06, 0d, 00, 2f, 00, 00, 2f, 00, 30, 1e, 00, 31, 03, 35, 00, 04, 11, 00, 12, 1a, 02, 11, 04, 12, 00, 05, 11, 00, 14, 1a, 00, 17, 00, 41, 19, 00, 41, 00, 42, 00, 00, 43, 00, 5f, 00, 00, 5f, 00, 60, 00, 01, 0d, 00, 20, 00, 01, 11, 00, 14, 00, 00, 17, 00, 41, 00, 00, 41, 00, 42, 00, 00, 43, 00, 60, 00, 00, 60, 00, 61, 00, 01, 0d, 00, 20, 46, 04, 11, 00, 14, 4e, 00, 17, 00, 42, 00, 00, 42, 00, 43, 4a, 00, 44, 00, 61, 00, 00, 61, 00, 62, 46, 01, 0d, 00, 20, 62, 01, 11, 00, 14, 45, 00, 17, 01, 36, 00, 01, 36, 00, 37, 66, 01, 12, 00, 2f, 00, 00, 2f, 00, 30, 62, 01, 0d, 00, 20, 76, 01, 11, 00, 14, 4d, 00, 17, 01, 36, 00, 02, 11, 00, 12, 7a, 01, 12, 00, 2f, 00, 01, 11, 00, 12, 76, 02, 0d, 00, 20, 0d, 03, 05, 00, 0b, 7f, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 59 +Number of expressions: 36 - expression 0 operands: lhs = Counter(0), rhs = Expression(1, Add) -- expression 1 operands: lhs = Counter(1), rhs = Counter(2) +- expression 1 operands: lhs = Zero, rhs = Counter(2) - expression 2 operands: lhs = Expression(0, Add), rhs = Counter(3) -- expression 3 operands: lhs = Counter(16), rhs = Counter(4) -- expression 4 operands: lhs = Expression(18, Sub), rhs = Counter(5) -- expression 5 operands: lhs = Counter(16), rhs = Counter(4) -- expression 6 operands: lhs = Expression(16, Sub), rhs = Counter(7) -- expression 7 operands: lhs = Expression(17, Sub), rhs = Counter(6) -- expression 8 operands: lhs = Expression(18, Sub), rhs = Counter(5) -- expression 9 operands: lhs = Counter(16), rhs = Counter(4) -- expression 10 operands: lhs = Expression(18, Sub), rhs = Counter(5) -- expression 11 operands: lhs = Counter(16), rhs = Counter(4) -- expression 12 operands: lhs = Expression(17, Sub), rhs = Counter(6) -- expression 13 operands: lhs = Expression(18, Sub), rhs = Counter(5) -- expression 14 operands: lhs = Counter(16), rhs = Counter(4) -- expression 15 operands: lhs = Expression(16, Sub), rhs = Counter(7) -- expression 16 operands: lhs = Expression(17, Sub), rhs = Counter(6) -- expression 17 operands: lhs = Expression(18, Sub), rhs = Counter(5) -- expression 18 operands: lhs = Counter(16), rhs = Counter(4) -- expression 19 operands: lhs = Expression(23, Sub), rhs = Counter(9) -- expression 20 operands: lhs = Counter(18), rhs = Counter(8) -- expression 21 operands: lhs = Counter(18), rhs = Counter(8) -- expression 22 operands: lhs = Expression(23, Sub), rhs = Counter(9) -- expression 23 operands: lhs = Counter(18), rhs = Counter(8) -- expression 24 operands: lhs = Expression(34, Sub), rhs = Counter(11) -- expression 25 operands: lhs = Expression(35, Sub), rhs = Counter(10) -- expression 26 operands: lhs = Expression(36, Sub), rhs = Counter(16) -- expression 27 operands: lhs = Expression(0, Add), rhs = Counter(3) -- expression 28 operands: lhs = Expression(36, Sub), rhs = Counter(16) -- expression 29 operands: lhs = Expression(0, Add), rhs = Counter(3) -- expression 30 operands: lhs = Expression(35, Sub), rhs = Counter(10) -- expression 31 operands: lhs = Expression(36, Sub), rhs = Counter(16) -- expression 32 operands: lhs = Expression(0, Add), rhs = Counter(3) -- expression 33 operands: lhs = Expression(34, Sub), rhs = Counter(11) -- expression 34 operands: lhs = Expression(35, Sub), rhs = Counter(10) -- expression 35 operands: lhs = Expression(36, Sub), rhs = Counter(16) -- expression 36 operands: lhs = Expression(0, Add), rhs = Counter(3) -- expression 37 operands: lhs = Expression(41, Sub), rhs = Counter(13) -- expression 38 operands: lhs = Counter(17), rhs = Counter(12) -- expression 39 operands: lhs = Counter(17), rhs = Counter(12) -- expression 40 operands: lhs = Expression(41, Sub), rhs = Counter(13) -- expression 41 operands: lhs = Counter(17), rhs = Counter(12) -- expression 42 operands: lhs = Expression(46, Sub), rhs = Counter(15) -- expression 43 operands: lhs = Counter(19), rhs = Counter(14) -- expression 44 operands: lhs = Counter(19), rhs = Counter(14) -- expression 45 operands: lhs = Expression(46, Sub), rhs = Counter(15) -- expression 46 operands: lhs = Counter(19), rhs = Counter(14) -- expression 47 operands: lhs = Expression(48, Add), rhs = Counter(3) -- expression 48 operands: lhs = Expression(49, Add), rhs = Expression(54, Add) -- expression 49 operands: lhs = Expression(50, Add), rhs = Expression(51, Add) -- expression 50 operands: lhs = Counter(4), rhs = Counter(5) -- expression 51 operands: lhs = Expression(52, Add), rhs = Expression(53, Add) -- expression 52 operands: lhs = Counter(6), rhs = Counter(7) -- expression 53 operands: lhs = Counter(8), rhs = Counter(9) -- expression 54 operands: lhs = Expression(55, Add), rhs = Expression(56, Add) -- expression 55 operands: lhs = Counter(10), rhs = Counter(11) -- expression 56 operands: lhs = Expression(57, Add), rhs = Expression(58, Add) -- expression 57 operands: lhs = Counter(12), rhs = Counter(13) -- expression 58 operands: lhs = Counter(14), rhs = Counter(15) +- expression 3 operands: lhs = Counter(16), rhs = Zero +- expression 4 operands: lhs = Expression(7, Sub), rhs = Zero +- expression 5 operands: lhs = Counter(16), rhs = Zero +- expression 6 operands: lhs = Expression(7, Sub), rhs = Zero +- expression 7 operands: lhs = Counter(16), rhs = Zero +- expression 8 operands: lhs = Expression(18, Sub), rhs = Zero +- expression 9 operands: lhs = Expression(19, Sub), rhs = Zero +- expression 10 operands: lhs = Expression(20, Sub), rhs = Counter(16) +- expression 11 operands: lhs = Expression(0, Add), rhs = Counter(3) +- expression 12 operands: lhs = Expression(20, Sub), rhs = Counter(16) +- expression 13 operands: lhs = Expression(0, Add), rhs = Counter(3) +- expression 14 operands: lhs = Expression(19, Sub), rhs = Zero +- expression 15 operands: lhs = Expression(20, Sub), rhs = Counter(16) +- expression 16 operands: lhs = Expression(0, Add), rhs = Counter(3) +- expression 17 operands: lhs = Expression(18, Sub), rhs = Zero +- expression 18 operands: lhs = Expression(19, Sub), rhs = Zero +- expression 19 operands: lhs = Expression(20, Sub), rhs = Counter(16) +- expression 20 operands: lhs = Expression(0, Add), rhs = Counter(3) +- expression 21 operands: lhs = Expression(25, Sub), rhs = Zero +- expression 22 operands: lhs = Counter(17), rhs = Zero +- expression 23 operands: lhs = Counter(17), rhs = Zero +- expression 24 operands: lhs = Expression(25, Sub), rhs = Zero +- expression 25 operands: lhs = Counter(17), rhs = Zero +- expression 26 operands: lhs = Expression(30, Sub), rhs = Zero +- expression 27 operands: lhs = Counter(19), rhs = Zero +- expression 28 operands: lhs = Counter(19), rhs = Zero +- expression 29 operands: lhs = Expression(30, Sub), rhs = Zero +- expression 30 operands: lhs = Counter(19), rhs = Zero +- expression 31 operands: lhs = Expression(32, Add), rhs = Counter(3) +- expression 32 operands: lhs = Expression(33, Add), rhs = Zero +- expression 33 operands: lhs = Zero, rhs = Expression(34, Add) +- expression 34 operands: lhs = Expression(35, Add), rhs = Zero +- expression 35 operands: lhs = Counter(6), rhs = Zero Number of file 0 mappings: 40 - Code(Counter(0)) at (prev + 62, 1) to (start + 3, 23) - Code(Expression(0, Add)) at (prev + 8, 9) to (start + 0, 14) - = (c0 + (c1 + c2)) -- Code(Expression(36, Sub)) at (prev + 2, 9) to (start + 4, 26) - = ((c0 + (c1 + c2)) - c3) + = (c0 + (Zero + c2)) +- Code(Expression(20, Sub)) at (prev + 2, 9) to (start + 4, 26) + = ((c0 + (Zero + c2)) - c3) - Code(Counter(16)) at (prev + 6, 13) to (start + 0, 47) -- Code(Counter(4)) at (prev + 0, 47) to (start + 0, 48) -- Code(Expression(18, Sub)) at (prev + 0, 49) to (start + 3, 53) - = (c16 - c4) -- Code(Counter(5)) at (prev + 4, 17) to (start + 0, 18) -- Code(Expression(17, Sub)) at (prev + 2, 17) to (start + 4, 18) - = ((c16 - c4) - c5) -- Code(Expression(15, Sub)) at (prev + 5, 17) to (start + 0, 20) - = ((((c16 - c4) - c5) - c6) - c7) -- Code(Expression(17, Sub)) at (prev + 0, 23) to (start + 0, 65) - = ((c16 - c4) - c5) +- Code(Zero) at (prev + 0, 47) to (start + 0, 48) +- Code(Expression(7, Sub)) at (prev + 0, 49) to (start + 3, 53) + = (c16 - Zero) +- Code(Zero) at (prev + 4, 17) to (start + 0, 18) +- Code(Expression(6, Sub)) at (prev + 2, 17) to (start + 4, 18) + = ((c16 - Zero) - Zero) +- Code(Zero) at (prev + 5, 17) to (start + 0, 20) +- Code(Expression(6, Sub)) at (prev + 0, 23) to (start + 0, 65) + = ((c16 - Zero) - Zero) - Code(Counter(6)) at (prev + 0, 65) to (start + 0, 66) -- Code(Expression(16, Sub)) at (prev + 0, 67) to (start + 0, 95) - = (((c16 - c4) - c5) - c6) -- Code(Counter(7)) at (prev + 0, 95) to (start + 0, 96) -- Code(Expression(15, Sub)) at (prev + 1, 13) to (start + 0, 32) - = ((((c16 - c4) - c5) - c6) - c7) -- Code(Expression(22, Sub)) at (prev + 1, 17) to (start + 0, 20) - = ((c18 - c8) - c9) -- Code(Counter(18)) at (prev + 0, 23) to (start + 0, 65) -- Code(Counter(8)) at (prev + 0, 65) to (start + 0, 66) -- Code(Expression(23, Sub)) at (prev + 0, 67) to (start + 0, 96) - = (c18 - c8) -- Code(Counter(9)) at (prev + 0, 96) to (start + 0, 97) -- Code(Expression(22, Sub)) at (prev + 1, 13) to (start + 0, 32) - = ((c18 - c8) - c9) -- Code(Expression(33, Sub)) at (prev + 4, 17) to (start + 0, 20) - = (((((c0 + (c1 + c2)) - c3) - c16) - c10) - c11) -- Code(Expression(35, Sub)) at (prev + 0, 23) to (start + 0, 66) - = (((c0 + (c1 + c2)) - c3) - c16) -- Code(Counter(10)) at (prev + 0, 66) to (start + 0, 67) -- Code(Expression(34, Sub)) at (prev + 0, 68) to (start + 0, 97) - = ((((c0 + (c1 + c2)) - c3) - c16) - c10) -- Code(Counter(11)) at (prev + 0, 97) to (start + 0, 98) -- Code(Expression(33, Sub)) at (prev + 1, 13) to (start + 0, 32) - = (((((c0 + (c1 + c2)) - c3) - c16) - c10) - c11) -- Code(Expression(40, Sub)) at (prev + 1, 17) to (start + 0, 20) - = ((c17 - c12) - c13) +- Code(Zero) at (prev + 0, 67) to (start + 0, 95) +- Code(Zero) at (prev + 0, 95) to (start + 0, 96) +- Code(Zero) at (prev + 1, 13) to (start + 0, 32) +- Code(Zero) at (prev + 1, 17) to (start + 0, 20) +- Code(Zero) at (prev + 0, 23) to (start + 0, 65) +- Code(Zero) at (prev + 0, 65) to (start + 0, 66) +- Code(Zero) at (prev + 0, 67) to (start + 0, 96) +- Code(Zero) at (prev + 0, 96) to (start + 0, 97) +- Code(Zero) at (prev + 1, 13) to (start + 0, 32) +- Code(Expression(17, Sub)) at (prev + 4, 17) to (start + 0, 20) + = (((((c0 + (Zero + c2)) - c3) - c16) - Zero) - Zero) +- Code(Expression(19, Sub)) at (prev + 0, 23) to (start + 0, 66) + = (((c0 + (Zero + c2)) - c3) - c16) +- Code(Zero) at (prev + 0, 66) to (start + 0, 67) +- Code(Expression(18, Sub)) at (prev + 0, 68) to (start + 0, 97) + = ((((c0 + (Zero + c2)) - c3) - c16) - Zero) +- Code(Zero) at (prev + 0, 97) to (start + 0, 98) +- Code(Expression(17, Sub)) at (prev + 1, 13) to (start + 0, 32) + = (((((c0 + (Zero + c2)) - c3) - c16) - Zero) - Zero) +- Code(Expression(24, Sub)) at (prev + 1, 17) to (start + 0, 20) + = ((c17 - Zero) - Zero) - Code(Counter(17)) at (prev + 0, 23) to (start + 1, 54) -- Code(Counter(12)) at (prev + 1, 54) to (start + 0, 55) -- Code(Expression(41, Sub)) at (prev + 1, 18) to (start + 0, 47) - = (c17 - c12) -- Code(Counter(13)) at (prev + 0, 47) to (start + 0, 48) -- Code(Expression(40, Sub)) at (prev + 1, 13) to (start + 0, 32) - = ((c17 - c12) - c13) -- Code(Expression(45, Sub)) at (prev + 1, 17) to (start + 0, 20) - = ((c19 - c14) - c15) +- Code(Zero) at (prev + 1, 54) to (start + 0, 55) +- Code(Expression(25, Sub)) at (prev + 1, 18) to (start + 0, 47) + = (c17 - Zero) +- Code(Zero) at (prev + 0, 47) to (start + 0, 48) +- Code(Expression(24, Sub)) at (prev + 1, 13) to (start + 0, 32) + = ((c17 - Zero) - Zero) +- Code(Expression(29, Sub)) at (prev + 1, 17) to (start + 0, 20) + = ((c19 - Zero) - Zero) - Code(Counter(19)) at (prev + 0, 23) to (start + 1, 54) -- Code(Counter(14)) at (prev + 2, 17) to (start + 0, 18) -- Code(Expression(46, Sub)) at (prev + 1, 18) to (start + 0, 47) - = (c19 - c14) -- Code(Counter(15)) at (prev + 1, 17) to (start + 0, 18) -- Code(Expression(45, Sub)) at (prev + 2, 13) to (start + 0, 32) - = ((c19 - c14) - c15) +- Code(Zero) at (prev + 2, 17) to (start + 0, 18) +- Code(Expression(30, Sub)) at (prev + 1, 18) to (start + 0, 47) + = (c19 - Zero) +- Code(Zero) at (prev + 1, 17) to (start + 0, 18) +- Code(Expression(29, Sub)) at (prev + 2, 13) to (start + 0, 32) + = ((c19 - Zero) - Zero) - Code(Counter(3)) at (prev + 3, 5) to (start + 0, 11) -- Code(Expression(47, Add)) at (prev + 1, 1) to (start + 0, 2) - = ((((c4 + c5) + ((c6 + c7) + (c8 + c9))) + ((c10 + c11) + ((c12 + c13) + (c14 + c15)))) + c3) +- Code(Expression(31, Add)) at (prev + 1, 1) to (start + 0, 2) + = (((Zero + ((c6 + Zero) + Zero)) + Zero) + c3) diff --git a/tests/coverage/yield.cov-map b/tests/coverage/yield.cov-map index c9c9709fa4f..9cc67dfe88a 100644 --- a/tests/coverage/yield.cov-map +++ b/tests/coverage/yield.cov-map @@ -1,9 +1,9 @@ Function name: yield::main -Raw bytes (106): 0x[01, 01, 0b, 05, 09, 0d, 11, 22, 15, 0d, 11, 11, 15, 22, 15, 0d, 11, 22, 15, 0d, 11, 19, 1d, 25, 29, 10, 01, 07, 01, 01, 16, 01, 06, 0b, 00, 2e, 0d, 01, 27, 00, 29, 03, 01, 0e, 00, 34, 0d, 02, 0b, 00, 2e, 22, 01, 22, 00, 27, 1e, 00, 2c, 00, 2e, 13, 01, 0e, 00, 34, 1e, 03, 09, 00, 16, 1e, 07, 0b, 00, 2e, 21, 01, 27, 00, 29, 27, 01, 0e, 00, 34, 21, 02, 0b, 00, 2e, 2d, 01, 27, 00, 29, 2b, 01, 0e, 00, 34, 2d, 02, 01, 00, 02] +Raw bytes (106): 0x[01, 01, 0b, 05, 00, 0d, 11, 22, 15, 0d, 11, 11, 15, 22, 15, 0d, 11, 22, 15, 0d, 11, 19, 1d, 25, 29, 10, 01, 07, 01, 01, 16, 01, 06, 0b, 00, 2e, 0d, 01, 27, 00, 29, 03, 01, 0e, 00, 34, 0d, 02, 0b, 00, 2e, 22, 01, 22, 00, 27, 1e, 00, 2c, 00, 2e, 13, 01, 0e, 00, 34, 1e, 03, 09, 00, 16, 1e, 07, 0b, 00, 2e, 21, 01, 27, 00, 29, 27, 01, 0e, 00, 34, 21, 02, 0b, 00, 2e, 2d, 01, 27, 00, 29, 2b, 01, 0e, 00, 34, 2d, 02, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 11 -- expression 0 operands: lhs = Counter(1), rhs = Counter(2) +- expression 0 operands: lhs = Counter(1), rhs = Zero - expression 1 operands: lhs = Counter(3), rhs = Counter(4) - expression 2 operands: lhs = Expression(8, Sub), rhs = Counter(5) - expression 3 operands: lhs = Counter(3), rhs = Counter(4) @@ -19,7 +19,7 @@ Number of file 0 mappings: 16 - Code(Counter(0)) at (prev + 6, 11) to (start + 0, 46) - Code(Counter(3)) at (prev + 1, 39) to (start + 0, 41) - Code(Expression(0, Add)) at (prev + 1, 14) to (start + 0, 52) - = (c1 + c2) + = (c1 + Zero) - Code(Counter(3)) at (prev + 2, 11) to (start + 0, 46) - Code(Expression(8, Sub)) at (prev + 1, 34) to (start + 0, 39) = (c3 - c4) diff --git a/tests/incremental/delayed_span_bug.rs b/tests/incremental/delayed_span_bug.rs index cc9831fff96..5c9d3c2c1d5 100644 --- a/tests/incremental/delayed_span_bug.rs +++ b/tests/incremental/delayed_span_bug.rs @@ -1,8 +1,8 @@ // revisions: cfail1 cfail2 // should-ice -// error-pattern: delayed span bug triggered by #[rustc_error(span_delayed_bug_from_inside_query)] +// error-pattern: delayed bug triggered by #[rustc_error(delayed_bug_from_inside_query)] #![feature(rustc_attrs)] -#[rustc_error(span_delayed_bug_from_inside_query)] +#[rustc_error(delayed_bug_from_inside_query)] fn main() {} diff --git a/tests/incremental/hashes/trait_impls.rs b/tests/incremental/hashes/trait_impls.rs index 2e97a35d36b..e103be0a085 100644 --- a/tests/incremental/hashes/trait_impls.rs +++ b/tests/incremental/hashes/trait_impls.rs @@ -462,9 +462,9 @@ impl AddTypeParameterToImpl<u32> for Bar<u32> { } #[cfg(not(any(cfail1,cfail4)))] -#[rustc_clean(except="opt_hir_owner_nodes,generics_of,impl_trait_ref", cfg="cfail2")] +#[rustc_clean(except="opt_hir_owner_nodes,generics_of,impl_trait_header", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] -#[rustc_clean(except="opt_hir_owner_nodes,generics_of,impl_trait_ref", cfg="cfail5")] +#[rustc_clean(except="opt_hir_owner_nodes,generics_of,impl_trait_header", cfg="cfail5")] #[rustc_clean(cfg="cfail6")] impl<TTT> AddTypeParameterToImpl<TTT> for Bar<TTT> { #[rustc_clean( @@ -493,9 +493,9 @@ impl ChangeSelfTypeOfImpl for u32 { } #[cfg(not(any(cfail1,cfail4)))] -#[rustc_clean(except="opt_hir_owner_nodes,impl_trait_ref", cfg="cfail2")] +#[rustc_clean(except="opt_hir_owner_nodes,impl_trait_header", cfg="cfail2")] #[rustc_clean(cfg="cfail3")] -#[rustc_clean(except="opt_hir_owner_nodes,impl_trait_ref", cfg="cfail5")] +#[rustc_clean(except="opt_hir_owner_nodes,impl_trait_header", cfg="cfail5")] #[rustc_clean(cfg="cfail6")] impl ChangeSelfTypeOfImpl for u64 { #[rustc_clean(except="fn_sig,typeck,optimized_mir", cfg="cfail2")] diff --git a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_move.0.panic-abort.mir b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_move.0.panic-abort.mir index 7df4eb49260..21a9f6f8721 100644 --- a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_move.0.panic-abort.mir +++ b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_move.0.panic-abort.mir @@ -1,6 +1,6 @@ // MIR for `main::{closure#0}::{closure#0}` 0 coroutine_closure_by_move -fn main::{closure#0}::{closure#0}(_1: {coroutine-closure@$DIR/async_closure_shims.rs:39:33: 39:52}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10} { +fn main::{closure#0}::{closure#0}(_1: {async closure@$DIR/async_closure_shims.rs:39:33: 39:52}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10} { let mut _0: {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10}; bb0: { diff --git a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_move.0.panic-unwind.mir b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_move.0.panic-unwind.mir index 7df4eb49260..21a9f6f8721 100644 --- a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_move.0.panic-unwind.mir +++ b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_move.0.panic-unwind.mir @@ -1,6 +1,6 @@ // MIR for `main::{closure#0}::{closure#0}` 0 coroutine_closure_by_move -fn main::{closure#0}::{closure#0}(_1: {coroutine-closure@$DIR/async_closure_shims.rs:39:33: 39:52}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10} { +fn main::{closure#0}::{closure#0}(_1: {async closure@$DIR/async_closure_shims.rs:39:33: 39:52}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10} { let mut _0: {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10}; bb0: { diff --git a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_mut.0.panic-abort.mir b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_mut.0.panic-abort.mir index 517b8d0dd88..1cfb6c2f3ea 100644 --- a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_mut.0.panic-abort.mir +++ b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_mut.0.panic-abort.mir @@ -1,6 +1,6 @@ // MIR for `main::{closure#0}::{closure#0}` 0 coroutine_closure_by_mut -fn main::{closure#0}::{closure#0}(_1: &mut {coroutine-closure@$DIR/async_closure_shims.rs:39:33: 39:52}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10} { +fn main::{closure#0}::{closure#0}(_1: &mut {async closure@$DIR/async_closure_shims.rs:39:33: 39:52}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10} { debug a => _2; debug b => ((*_1).0: i32); let mut _0: {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10}; diff --git a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_mut.0.panic-unwind.mir b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_mut.0.panic-unwind.mir index 517b8d0dd88..1cfb6c2f3ea 100644 --- a/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_mut.0.panic-unwind.mir +++ b/tests/mir-opt/async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_mut.0.panic-unwind.mir @@ -1,6 +1,6 @@ // MIR for `main::{closure#0}::{closure#0}` 0 coroutine_closure_by_mut -fn main::{closure#0}::{closure#0}(_1: &mut {coroutine-closure@$DIR/async_closure_shims.rs:39:33: 39:52}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10} { +fn main::{closure#0}::{closure#0}(_1: &mut {async closure@$DIR/async_closure_shims.rs:39:33: 39:52}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10} { debug a => _2; debug b => ((*_1).0: i32); let mut _0: {async closure body@$DIR/async_closure_shims.rs:39:53: 42:10}; diff --git a/tests/mir-opt/building/async_await.b-{closure#0}.coroutine_resume.0.mir b/tests/mir-opt/building/async_await.b-{closure#0}.coroutine_resume.0.mir index 9c8cf8763fd..2f7c4f7d402 100644 --- a/tests/mir-opt/building/async_await.b-{closure#0}.coroutine_resume.0.mir +++ b/tests/mir-opt/building/async_await.b-{closure#0}.coroutine_resume.0.mir @@ -110,7 +110,7 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:15:18: 18:2}>, bb0: { _39 = discriminant((*(_1.0: &mut {async fn body@$DIR/async_await.rs:15:18: 18:2}))); - switchInt(move _39) -> [0: bb1, 1: bb29, 3: bb27, 4: bb28, otherwise: bb9]; + switchInt(move _39) -> [0: bb1, 1: bb29, 3: bb27, 4: bb28, otherwise: bb8]; } bb1: { @@ -165,10 +165,14 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:15:18: 18:2}>, StorageDead(_10); PlaceMention(_9); _16 = discriminant(_9); - switchInt(move _16) -> [0: bb10, 1: bb8, otherwise: bb9]; + switchInt(move _16) -> [0: bb10, 1: bb9, otherwise: bb8]; } bb8: { + unreachable; + } + + bb9: { _8 = const (); StorageDead(_14); StorageDead(_12); @@ -186,10 +190,6 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:15:18: 18:2}>, return; } - bb9: { - unreachable; - } - bb10: { StorageLive(_17); _17 = ((_9 as Ready).0: ()); @@ -267,7 +267,7 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:15:18: 18:2}>, StorageDead(_26); PlaceMention(_25); _32 = discriminant(_25); - switchInt(move _32) -> [0: bb21, 1: bb20, otherwise: bb9]; + switchInt(move _32) -> [0: bb21, 1: bb20, otherwise: bb8]; } bb20: { diff --git a/tests/mir-opt/building/issue_101867.main.built.after.mir b/tests/mir-opt/building/issue_101867.main.built.after.mir index 57f8cca9abc..028d7ee7cd8 100644 --- a/tests/mir-opt/building/issue_101867.main.built.after.mir +++ b/tests/mir-opt/building/issue_101867.main.built.after.mir @@ -27,13 +27,13 @@ fn main() -> () { StorageLive(_5); PlaceMention(_1); _6 = discriminant(_1); - switchInt(move _6) -> [1: bb4, otherwise: bb3]; + switchInt(move _6) -> [1: bb5, otherwise: bb4]; } bb1: { StorageLive(_3); StorageLive(_4); - _4 = begin_panic::<&str>(const "explicit panic") -> bb7; + _4 = begin_panic::<&str>(const "explicit panic") -> bb8; } bb2: { @@ -43,14 +43,19 @@ fn main() -> () { } bb3: { - goto -> bb6; + FakeRead(ForMatchedPlace(None), _1); + unreachable; } bb4: { - falseEdge -> [real: bb5, imaginary: bb3]; + goto -> bb7; } bb5: { + falseEdge -> [real: bb6, imaginary: bb4]; + } + + bb6: { _5 = ((_1 as Some).0: u8); _0 = const (); StorageDead(_5); @@ -58,12 +63,12 @@ fn main() -> () { return; } - bb6: { + bb7: { StorageDead(_5); goto -> bb1; } - bb7 (cleanup): { + bb8 (cleanup): { resume; } } diff --git a/tests/mir-opt/building/issue_49232.main.built.after.mir b/tests/mir-opt/building/issue_49232.main.built.after.mir index ac50b388910..7c1f5a6ec72 100644 --- a/tests/mir-opt/building/issue_49232.main.built.after.mir +++ b/tests/mir-opt/building/issue_49232.main.built.after.mir @@ -17,7 +17,7 @@ fn main() -> () { } bb1: { - falseUnwind -> [real: bb2, unwind: bb11]; + falseUnwind -> [real: bb2, unwind: bb12]; } bb2: { @@ -25,41 +25,46 @@ fn main() -> () { StorageLive(_3); _3 = const true; PlaceMention(_3); - switchInt(_3) -> [0: bb3, otherwise: bb4]; + switchInt(_3) -> [0: bb4, otherwise: bb5]; } bb3: { - falseEdge -> [real: bb5, imaginary: bb4]; + FakeRead(ForMatchedPlace(None), _3); + unreachable; } bb4: { - _0 = const (); - goto -> bb10; + falseEdge -> [real: bb6, imaginary: bb5]; } bb5: { - _2 = const 4_i32; - goto -> bb8; + _0 = const (); + goto -> bb11; } bb6: { - unreachable; + _2 = const 4_i32; + goto -> bb9; } bb7: { - goto -> bb8; + unreachable; } bb8: { + goto -> bb9; + } + + bb9: { FakeRead(ForLet(None), _2); StorageDead(_3); StorageLive(_5); StorageLive(_6); _6 = &_2; - _5 = std::mem::drop::<&i32>(move _6) -> [return: bb9, unwind: bb11]; + _5 = std::mem::drop::<&i32>(move _6) -> [return: bb10, unwind: bb12]; } - bb9: { + bb10: { StorageDead(_6); StorageDead(_5); _1 = const (); @@ -67,13 +72,13 @@ fn main() -> () { goto -> bb1; } - bb10: { + bb11: { StorageDead(_3); StorageDead(_2); return; } - bb11 (cleanup): { + bb12 (cleanup): { resume; } } diff --git a/tests/mir-opt/building/logical_or_in_conditional.test_complex.built.after.mir b/tests/mir-opt/building/logical_or_in_conditional.test_complex.built.after.mir index 7407e7a8b2a..d7c758d8876 100644 --- a/tests/mir-opt/building/logical_or_in_conditional.test_complex.built.after.mir +++ b/tests/mir-opt/building/logical_or_in_conditional.test_complex.built.after.mir @@ -19,168 +19,178 @@ fn test_complex() -> () { bb0: { StorageLive(_1); StorageLive(_2); - _2 = E::f() -> [return: bb1, unwind: bb31]; + _2 = E::f() -> [return: bb1, unwind: bb33]; } bb1: { PlaceMention(_2); _3 = discriminant(_2); - switchInt(move _3) -> [0: bb2, otherwise: bb3]; + switchInt(move _3) -> [0: bb4, otherwise: bb3]; } bb2: { - falseEdge -> [real: bb4, imaginary: bb3]; + FakeRead(ForMatchedPlace(None), _2); + unreachable; } bb3: { - goto -> bb19; + goto -> bb20; } bb4: { - StorageLive(_4); - _4 = always_true() -> [return: bb5, unwind: bb31]; + falseEdge -> [real: bb5, imaginary: bb3]; } bb5: { - switchInt(move _4) -> [0: bb7, otherwise: bb6]; + StorageLive(_4); + _4 = always_true() -> [return: bb6, unwind: bb33]; } bb6: { + switchInt(move _4) -> [0: bb8, otherwise: bb7]; + } + + bb7: { StorageLive(_5); StorageLive(_6); StorageLive(_7); _7 = Droppy(const 0_u8); _6 = (_7.0: u8); _5 = Gt(move _6, const 0_u8); - switchInt(move _5) -> [0: bb9, otherwise: bb8]; - } - - bb7: { - goto -> bb13; + switchInt(move _5) -> [0: bb10, otherwise: bb9]; } bb8: { - drop(_7) -> [return: bb10, unwind: bb31]; + goto -> bb14; } bb9: { - goto -> bb11; + drop(_7) -> [return: bb11, unwind: bb33]; } bb10: { - StorageDead(_7); - StorageDead(_6); - goto -> bb16; + goto -> bb12; } bb11: { - drop(_7) -> [return: bb12, unwind: bb31]; + StorageDead(_7); + StorageDead(_6); + goto -> bb17; } bb12: { + drop(_7) -> [return: bb13, unwind: bb33]; + } + + bb13: { StorageDead(_7); StorageDead(_6); - goto -> bb13; + goto -> bb14; } - bb13: { + bb14: { StorageLive(_8); StorageLive(_9); StorageLive(_10); _10 = Droppy(const 1_u8); _9 = (_10.0: u8); _8 = Gt(move _9, const 1_u8); - switchInt(move _8) -> [0: bb15, otherwise: bb14]; - } - - bb14: { - drop(_10) -> [return: bb16, unwind: bb31]; + switchInt(move _8) -> [0: bb16, otherwise: bb15]; } bb15: { - goto -> bb17; + drop(_10) -> [return: bb17, unwind: bb33]; } bb16: { + goto -> bb18; + } + + bb17: { StorageDead(_10); StorageDead(_9); _1 = const (); - goto -> bb20; + goto -> bb21; } - bb17: { - drop(_10) -> [return: bb18, unwind: bb31]; + bb18: { + drop(_10) -> [return: bb19, unwind: bb33]; } - bb18: { + bb19: { StorageDead(_10); StorageDead(_9); - goto -> bb19; + goto -> bb20; } - bb19: { + bb20: { _1 = const (); - goto -> bb20; + goto -> bb21; } - bb20: { + bb21: { StorageDead(_8); StorageDead(_5); StorageDead(_4); StorageDead(_2); StorageDead(_1); StorageLive(_11); - _11 = always_true() -> [return: bb21, unwind: bb31]; - } - - bb21: { - switchInt(move _11) -> [0: bb23, otherwise: bb22]; + _11 = always_true() -> [return: bb22, unwind: bb33]; } bb22: { - goto -> bb29; + switchInt(move _11) -> [0: bb24, otherwise: bb23]; } bb23: { - goto -> bb24; + goto -> bb31; } bb24: { - StorageLive(_12); - _12 = E::f() -> [return: bb25, unwind: bb31]; + goto -> bb25; } bb25: { - PlaceMention(_12); - _13 = discriminant(_12); - switchInt(move _13) -> [1: bb27, otherwise: bb26]; + StorageLive(_12); + _12 = E::f() -> [return: bb26, unwind: bb33]; } bb26: { - goto -> bb29; + PlaceMention(_12); + _13 = discriminant(_12); + switchInt(move _13) -> [1: bb29, otherwise: bb28]; } bb27: { - falseEdge -> [real: bb28, imaginary: bb26]; + FakeRead(ForMatchedPlace(None), _12); + unreachable; } bb28: { - _0 = const (); - goto -> bb30; + goto -> bb31; } bb29: { - _0 = const (); - goto -> bb30; + falseEdge -> [real: bb30, imaginary: bb28]; } bb30: { + _0 = const (); + goto -> bb32; + } + + bb31: { + _0 = const (); + goto -> bb32; + } + + bb32: { StorageDead(_11); StorageDead(_12); return; } - bb31 (cleanup): { + bb33 (cleanup): { resume; } } diff --git a/tests/mir-opt/building/match_false_edges.full_tested_match.built.after.mir b/tests/mir-opt/building/match_false_edges.full_tested_match.built.after.mir index b99b0b99559..88292dd0597 100644 --- a/tests/mir-opt/building/match_false_edges.full_tested_match.built.after.mir +++ b/tests/mir-opt/building/match_false_edges.full_tested_match.built.after.mir @@ -28,25 +28,25 @@ fn full_tested_match() -> () { _2 = Option::<i32>::Some(const 42_i32); PlaceMention(_2); _3 = discriminant(_2); - switchInt(move _3) -> [0: bb1, 1: bb2, otherwise: bb4]; + switchInt(move _3) -> [0: bb2, 1: bb3, otherwise: bb1]; } bb1: { - _1 = (const 3_i32, const 3_i32); - goto -> bb11; + FakeRead(ForMatchedPlace(None), _2); + unreachable; } bb2: { - falseEdge -> [real: bb5, imaginary: bb3]; + _1 = (const 3_i32, const 3_i32); + goto -> bb11; } bb3: { - falseEdge -> [real: bb10, imaginary: bb1]; + falseEdge -> [real: bb5, imaginary: bb4]; } bb4: { - FakeRead(ForMatchedPlace(None), _2); - unreachable; + falseEdge -> [real: bb10, imaginary: bb2]; } bb5: { @@ -54,7 +54,7 @@ fn full_tested_match() -> () { _6 = &((_2 as Some).0: i32); _4 = &fake _2; StorageLive(_7); - _7 = guard() -> [return: bb6, unwind: bb12]; + _7 = guard() -> [return: bb6, unwind: bb13]; } bb6: { @@ -83,7 +83,7 @@ fn full_tested_match() -> () { bb9: { StorageDead(_7); StorageDead(_6); - goto -> bb3; + goto -> bb4; } bb10: { @@ -105,7 +105,12 @@ fn full_tested_match() -> () { return; } - bb12 (cleanup): { + bb12: { + FakeRead(ForMatchedPlace(None), _1); + unreachable; + } + + bb13 (cleanup): { resume; } } diff --git a/tests/mir-opt/building/match_false_edges.full_tested_match2.built.after.mir b/tests/mir-opt/building/match_false_edges.full_tested_match2.built.after.mir index d1d86b55d68..205bb4980d9 100644 --- a/tests/mir-opt/building/match_false_edges.full_tested_match2.built.after.mir +++ b/tests/mir-opt/building/match_false_edges.full_tested_match2.built.after.mir @@ -28,18 +28,23 @@ fn full_tested_match2() -> () { _2 = Option::<i32>::Some(const 42_i32); PlaceMention(_2); _3 = discriminant(_2); - switchInt(move _3) -> [0: bb1, 1: bb2, otherwise: bb4]; + switchInt(move _3) -> [0: bb2, 1: bb3, otherwise: bb1]; } bb1: { - falseEdge -> [real: bb10, imaginary: bb3]; + FakeRead(ForMatchedPlace(None), _2); + unreachable; } bb2: { - falseEdge -> [real: bb5, imaginary: bb1]; + falseEdge -> [real: bb10, imaginary: bb4]; } bb3: { + falseEdge -> [real: bb5, imaginary: bb2]; + } + + bb4: { StorageLive(_9); _9 = ((_2 as Some).0: i32); StorageLive(_10); @@ -50,17 +55,12 @@ fn full_tested_match2() -> () { goto -> bb11; } - bb4: { - FakeRead(ForMatchedPlace(None), _2); - unreachable; - } - bb5: { StorageLive(_6); _6 = &((_2 as Some).0: i32); _4 = &fake _2; StorageLive(_7); - _7 = guard() -> [return: bb6, unwind: bb12]; + _7 = guard() -> [return: bb6, unwind: bb13]; } bb6: { @@ -89,7 +89,7 @@ fn full_tested_match2() -> () { bb9: { StorageDead(_7); StorageDead(_6); - falseEdge -> [real: bb3, imaginary: bb1]; + falseEdge -> [real: bb4, imaginary: bb2]; } bb10: { @@ -105,7 +105,12 @@ fn full_tested_match2() -> () { return; } - bb12 (cleanup): { + bb12: { + FakeRead(ForMatchedPlace(None), _1); + unreachable; + } + + bb13 (cleanup): { resume; } } diff --git a/tests/mir-opt/building/match_false_edges.main.built.after.mir b/tests/mir-opt/building/match_false_edges.main.built.after.mir index 1d4fe67f350..21f377a6404 100644 --- a/tests/mir-opt/building/match_false_edges.main.built.after.mir +++ b/tests/mir-opt/building/match_false_edges.main.built.after.mir @@ -39,55 +39,60 @@ fn main() -> () { _2 = Option::<i32>::Some(const 1_i32); PlaceMention(_2); _4 = discriminant(_2); - switchInt(move _4) -> [1: bb2, otherwise: bb1]; + switchInt(move _4) -> [1: bb7, otherwise: bb2]; } bb1: { - falseEdge -> [real: bb13, imaginary: bb6]; + FakeRead(ForMatchedPlace(None), _2); + unreachable; } bb2: { - falseEdge -> [real: bb8, imaginary: bb1]; + falseEdge -> [real: bb14, imaginary: bb5]; } bb3: { - goto -> bb1; - } - - bb4: { _3 = discriminant(_2); - switchInt(move _3) -> [1: bb6, otherwise: bb5]; + switchInt(move _3) -> [1: bb5, otherwise: bb4]; } - bb5: { + bb4: { StorageLive(_14); _14 = _2; _1 = const 4_i32; StorageDead(_14); - goto -> bb19; + goto -> bb20; + } + + bb5: { + falseEdge -> [real: bb15, imaginary: bb4]; } bb6: { - falseEdge -> [real: bb14, imaginary: bb5]; + goto -> bb4; } bb7: { - goto -> bb5; + falseEdge -> [real: bb9, imaginary: bb2]; } bb8: { + goto -> bb2; + } + + bb9: { StorageLive(_7); _7 = &((_2 as Some).0: i32); _5 = &fake _2; StorageLive(_8); - _8 = guard() -> [return: bb9, unwind: bb20]; + _8 = guard() -> [return: bb10, unwind: bb22]; } - bb9: { - switchInt(move _8) -> [0: bb11, otherwise: bb10]; + bb10: { + switchInt(move _8) -> [0: bb12, otherwise: bb11]; } - bb10: { + bb11: { StorageDead(_8); FakeRead(ForMatchGuard, _5); FakeRead(ForGuardBinding, _7); @@ -96,42 +101,42 @@ fn main() -> () { _1 = const 1_i32; StorageDead(_6); StorageDead(_7); - goto -> bb19; + goto -> bb20; } - bb11: { - goto -> bb12; + bb12: { + goto -> bb13; } - bb12: { + bb13: { StorageDead(_8); StorageDead(_7); - falseEdge -> [real: bb3, imaginary: bb1]; + falseEdge -> [real: bb8, imaginary: bb2]; } - bb13: { + bb14: { StorageLive(_9); _9 = _2; _1 = const 2_i32; StorageDead(_9); - goto -> bb19; + goto -> bb20; } - bb14: { + bb15: { StorageLive(_11); _11 = &((_2 as Some).0: i32); _5 = &fake _2; StorageLive(_12); StorageLive(_13); _13 = (*_11); - _12 = guard2(move _13) -> [return: bb15, unwind: bb20]; + _12 = guard2(move _13) -> [return: bb16, unwind: bb22]; } - bb15: { - switchInt(move _12) -> [0: bb17, otherwise: bb16]; + bb16: { + switchInt(move _12) -> [0: bb18, otherwise: bb17]; } - bb16: { + bb17: { StorageDead(_13); StorageDead(_12); FakeRead(ForMatchGuard, _5); @@ -141,21 +146,21 @@ fn main() -> () { _1 = const 3_i32; StorageDead(_10); StorageDead(_11); - goto -> bb19; + goto -> bb20; } - bb17: { - goto -> bb18; + bb18: { + goto -> bb19; } - bb18: { + bb19: { StorageDead(_13); StorageDead(_12); StorageDead(_11); - falseEdge -> [real: bb7, imaginary: bb5]; + falseEdge -> [real: bb6, imaginary: bb4]; } - bb19: { + bb20: { PlaceMention(_1); StorageDead(_2); StorageDead(_1); @@ -163,7 +168,12 @@ fn main() -> () { return; } - bb20 (cleanup): { + bb21: { + FakeRead(ForMatchedPlace(None), _1); + unreachable; + } + + bb22 (cleanup): { resume; } } diff --git a/tests/mir-opt/building/simple_match.match_bool.built.after.mir b/tests/mir-opt/building/simple_match.match_bool.built.after.mir index 06de4c51051..cd51c942bee 100644 --- a/tests/mir-opt/building/simple_match.match_bool.built.after.mir +++ b/tests/mir-opt/building/simple_match.match_bool.built.after.mir @@ -6,24 +6,29 @@ fn match_bool(_1: bool) -> usize { bb0: { PlaceMention(_1); - switchInt(_1) -> [0: bb2, otherwise: bb1]; + switchInt(_1) -> [0: bb2, otherwise: bb3]; } bb1: { - falseEdge -> [real: bb3, imaginary: bb2]; + FakeRead(ForMatchedPlace(None), _1); + unreachable; } bb2: { _0 = const 20_usize; - goto -> bb4; + goto -> bb5; } bb3: { - _0 = const 10_usize; - goto -> bb4; + falseEdge -> [real: bb4, imaginary: bb2]; } bb4: { + _0 = const 10_usize; + goto -> bb5; + } + + bb5: { return; } } diff --git a/tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir b/tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir index 82424de0392..282c9704ffc 100644 --- a/tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir +++ b/tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir @@ -30,7 +30,7 @@ fn move_out_by_subslice() -> () { StorageLive(_2); _3 = SizeOf(i32); _4 = AlignOf(i32); - _5 = alloc::alloc::exchange_malloc(move _3, move _4) -> [return: bb1, unwind: bb12]; + _5 = alloc::alloc::exchange_malloc(move _3, move _4) -> [return: bb1, unwind: bb13]; } bb1: { @@ -38,7 +38,7 @@ fn move_out_by_subslice() -> () { _6 = ShallowInitBox(move _5, i32); (*_6) = const 1_i32; _2 = move _6; - drop(_6) -> [return: bb2, unwind: bb11]; + drop(_6) -> [return: bb2, unwind: bb12]; } bb2: { @@ -46,7 +46,7 @@ fn move_out_by_subslice() -> () { StorageLive(_7); _8 = SizeOf(i32); _9 = AlignOf(i32); - _10 = alloc::alloc::exchange_malloc(move _8, move _9) -> [return: bb3, unwind: bb11]; + _10 = alloc::alloc::exchange_malloc(move _8, move _9) -> [return: bb3, unwind: bb12]; } bb3: { @@ -54,18 +54,18 @@ fn move_out_by_subslice() -> () { _11 = ShallowInitBox(move _10, i32); (*_11) = const 2_i32; _7 = move _11; - drop(_11) -> [return: bb4, unwind: bb10]; + drop(_11) -> [return: bb4, unwind: bb11]; } bb4: { StorageDead(_11); _1 = [move _2, move _7]; - drop(_7) -> [return: bb5, unwind: bb11]; + drop(_7) -> [return: bb5, unwind: bb12]; } bb5: { StorageDead(_7); - drop(_2) -> [return: bb6, unwind: bb12]; + drop(_2) -> [return: bb6, unwind: bb13]; } bb6: { @@ -75,32 +75,37 @@ fn move_out_by_subslice() -> () { StorageLive(_12); _12 = move _1[0..2]; _0 = const (); - drop(_12) -> [return: bb7, unwind: bb9]; + drop(_12) -> [return: bb8, unwind: bb10]; } bb7: { - StorageDead(_12); - drop(_1) -> [return: bb8, unwind: bb12]; + FakeRead(ForMatchedPlace(None), _1); + unreachable; } bb8: { - StorageDead(_1); - return; + StorageDead(_12); + drop(_1) -> [return: bb9, unwind: bb13]; } - bb9 (cleanup): { - drop(_1) -> [return: bb12, unwind terminate(cleanup)]; + bb9: { + StorageDead(_1); + return; } bb10 (cleanup): { - drop(_7) -> [return: bb11, unwind terminate(cleanup)]; + drop(_1) -> [return: bb13, unwind terminate(cleanup)]; } bb11 (cleanup): { - drop(_2) -> [return: bb12, unwind terminate(cleanup)]; + drop(_7) -> [return: bb12, unwind terminate(cleanup)]; } bb12 (cleanup): { + drop(_2) -> [return: bb13, unwind terminate(cleanup)]; + } + + bb13 (cleanup): { resume; } } diff --git a/tests/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir b/tests/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir index 0872d1b6ac0..d1956c91b88 100644 --- a/tests/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir +++ b/tests/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir @@ -30,7 +30,7 @@ fn move_out_from_end() -> () { StorageLive(_2); _3 = SizeOf(i32); _4 = AlignOf(i32); - _5 = alloc::alloc::exchange_malloc(move _3, move _4) -> [return: bb1, unwind: bb12]; + _5 = alloc::alloc::exchange_malloc(move _3, move _4) -> [return: bb1, unwind: bb13]; } bb1: { @@ -38,7 +38,7 @@ fn move_out_from_end() -> () { _6 = ShallowInitBox(move _5, i32); (*_6) = const 1_i32; _2 = move _6; - drop(_6) -> [return: bb2, unwind: bb11]; + drop(_6) -> [return: bb2, unwind: bb12]; } bb2: { @@ -46,7 +46,7 @@ fn move_out_from_end() -> () { StorageLive(_7); _8 = SizeOf(i32); _9 = AlignOf(i32); - _10 = alloc::alloc::exchange_malloc(move _8, move _9) -> [return: bb3, unwind: bb11]; + _10 = alloc::alloc::exchange_malloc(move _8, move _9) -> [return: bb3, unwind: bb12]; } bb3: { @@ -54,18 +54,18 @@ fn move_out_from_end() -> () { _11 = ShallowInitBox(move _10, i32); (*_11) = const 2_i32; _7 = move _11; - drop(_11) -> [return: bb4, unwind: bb10]; + drop(_11) -> [return: bb4, unwind: bb11]; } bb4: { StorageDead(_11); _1 = [move _2, move _7]; - drop(_7) -> [return: bb5, unwind: bb11]; + drop(_7) -> [return: bb5, unwind: bb12]; } bb5: { StorageDead(_7); - drop(_2) -> [return: bb6, unwind: bb12]; + drop(_2) -> [return: bb6, unwind: bb13]; } bb6: { @@ -75,32 +75,37 @@ fn move_out_from_end() -> () { StorageLive(_12); _12 = move _1[1 of 2]; _0 = const (); - drop(_12) -> [return: bb7, unwind: bb9]; + drop(_12) -> [return: bb8, unwind: bb10]; } bb7: { - StorageDead(_12); - drop(_1) -> [return: bb8, unwind: bb12]; + FakeRead(ForMatchedPlace(None), _1); + unreachable; } bb8: { - StorageDead(_1); - return; + StorageDead(_12); + drop(_1) -> [return: bb9, unwind: bb13]; } - bb9 (cleanup): { - drop(_1) -> [return: bb12, unwind terminate(cleanup)]; + bb9: { + StorageDead(_1); + return; } bb10 (cleanup): { - drop(_7) -> [return: bb11, unwind terminate(cleanup)]; + drop(_1) -> [return: bb13, unwind terminate(cleanup)]; } bb11 (cleanup): { - drop(_2) -> [return: bb12, unwind terminate(cleanup)]; + drop(_7) -> [return: bb12, unwind terminate(cleanup)]; } bb12 (cleanup): { + drop(_2) -> [return: bb13, unwind terminate(cleanup)]; + } + + bb13 (cleanup): { resume; } } diff --git a/tests/mir-opt/const_goto.issue_77355_opt.ConstGoto.diff b/tests/mir-opt/const_goto.issue_77355_opt.ConstGoto.diff deleted file mode 100644 index 43bdb431129..00000000000 --- a/tests/mir-opt/const_goto.issue_77355_opt.ConstGoto.diff +++ /dev/null @@ -1,50 +0,0 @@ -- // MIR for `issue_77355_opt` before ConstGoto -+ // MIR for `issue_77355_opt` after ConstGoto - - fn issue_77355_opt(_1: Foo) -> u64 { - debug num => _1; - let mut _0: u64; -- let mut _2: bool; -- let mut _3: isize; -+ let mut _2: isize; - - bb0: { -- StorageLive(_2); -- _3 = discriminant(_1); -- switchInt(move _3) -> [1: bb2, 2: bb2, otherwise: bb1]; -+ _2 = discriminant(_1); -+ switchInt(move _2) -> [1: bb2, 2: bb2, otherwise: bb1]; - } - - bb1: { -- _2 = const false; -+ _0 = const 42_u64; - goto -> bb3; - } - - bb2: { -- _2 = const true; -+ _0 = const 23_u64; - goto -> bb3; - } - - bb3: { -- switchInt(move _2) -> [0: bb5, otherwise: bb4]; -- } -- -- bb4: { -- _0 = const 23_u64; -- goto -> bb6; -- } -- -- bb5: { -- _0 = const 42_u64; -- goto -> bb6; -- } -- -- bb6: { -- StorageDead(_2); - return; - } - } - diff --git a/tests/mir-opt/const_goto.rs b/tests/mir-opt/const_goto.rs deleted file mode 100644 index 93cb71c3a0f..00000000000 --- a/tests/mir-opt/const_goto.rs +++ /dev/null @@ -1,19 +0,0 @@ -// skip-filecheck -// unit-test: ConstGoto - -pub enum Foo { - A, - B, - C, - D, - E, - F, -} - -// EMIT_MIR const_goto.issue_77355_opt.ConstGoto.diff -fn issue_77355_opt(num: Foo) -> u64 { - if matches!(num, Foo::B | Foo::C) { 23 } else { 42 } -} -fn main() { - issue_77355_opt(Foo::A); -} diff --git a/tests/mir-opt/const_goto_const_eval_fail.f.ConstGoto.diff b/tests/mir-opt/const_goto_const_eval_fail.f.ConstGoto.diff deleted file mode 100644 index 84a13f28a31..00000000000 --- a/tests/mir-opt/const_goto_const_eval_fail.f.ConstGoto.diff +++ /dev/null @@ -1,51 +0,0 @@ -- // MIR for `f` before ConstGoto -+ // MIR for `f` after ConstGoto - - fn f() -> u64 { - let mut _0: u64; - let mut _1: bool; - let mut _2: i32; - - bb0: { - StorageLive(_1); - StorageLive(_2); - _2 = const A; - switchInt(_2) -> [1: bb2, 2: bb2, 3: bb2, otherwise: bb1]; - } - - bb1: { - _1 = const true; - goto -> bb3; - } - - bb2: { - _1 = const B; -- goto -> bb3; -+ switchInt(_1) -> [0: bb4, otherwise: bb3]; - } - - bb3: { -- switchInt(_1) -> [0: bb5, otherwise: bb4]; -- } -- -- bb4: { - _0 = const 2_u64; -- goto -> bb6; -+ goto -> bb5; - } - -- bb5: { -+ bb4: { - _0 = const 1_u64; -- goto -> bb6; -+ goto -> bb5; - } - -- bb6: { -+ bb5: { - StorageDead(_2); - StorageDead(_1); - return; - } - } - diff --git a/tests/mir-opt/const_goto_const_eval_fail.f.JumpThreading.diff b/tests/mir-opt/const_goto_const_eval_fail.f.JumpThreading.diff new file mode 100644 index 00000000000..4fc9254b7ba --- /dev/null +++ b/tests/mir-opt/const_goto_const_eval_fail.f.JumpThreading.diff @@ -0,0 +1,47 @@ +- // MIR for `f` before JumpThreading ++ // MIR for `f` after JumpThreading + + fn f() -> u64 { + let mut _0: u64; + let mut _1: bool; + + bb0: { + StorageLive(_1); + switchInt(const A) -> [1: bb2, 2: bb2, 3: bb2, otherwise: bb1]; + } + + bb1: { + _1 = const true; +- goto -> bb3; ++ goto -> bb7; + } + + bb2: { + _1 = const B; + goto -> bb3; + } + + bb3: { + switchInt(_1) -> [0: bb5, otherwise: bb4]; + } + + bb4: { + _0 = const 2_u64; + goto -> bb6; + } + + bb5: { + _0 = const 1_u64; + goto -> bb6; + } + + bb6: { + StorageDead(_1); + return; ++ } ++ ++ bb7: { ++ goto -> bb4; + } + } + diff --git a/tests/mir-opt/const_goto_const_eval_fail.rs b/tests/mir-opt/const_goto_const_eval_fail.rs index 869f916001c..c0e8e144b15 100644 --- a/tests/mir-opt/const_goto_const_eval_fail.rs +++ b/tests/mir-opt/const_goto_const_eval_fail.rs @@ -5,7 +5,7 @@ // compile-flags: -Zunsound-mir-opts // If const eval fails, then don't crash -// EMIT_MIR const_goto_const_eval_fail.f.ConstGoto.diff +// EMIT_MIR const_goto_const_eval_fail.f.JumpThreading.diff pub fn f<const A: i32, const B: bool>() -> u64 { match { match A { diff --git a/tests/mir-opt/const_goto_storage.match_nested_if.ConstGoto.diff b/tests/mir-opt/const_goto_storage.match_nested_if.ConstGoto.diff deleted file mode 100644 index 1768298d521..00000000000 --- a/tests/mir-opt/const_goto_storage.match_nested_if.ConstGoto.diff +++ /dev/null @@ -1,102 +0,0 @@ -- // MIR for `match_nested_if` before ConstGoto -+ // MIR for `match_nested_if` after ConstGoto - - fn match_nested_if() -> bool { - let mut _0: bool; - let _1: bool; -- let mut _2: (); -- let mut _3: bool; -- let mut _4: bool; -- let mut _5: bool; -- let mut _6: bool; -+ let mut _2: bool; - scope 1 { - debug val => _1; - } - - bb0: { - StorageLive(_1); - StorageLive(_2); -- _2 = (); -- StorageLive(_3); -- StorageLive(_4); -- StorageLive(_5); -- StorageLive(_6); -- _6 = const true; -- switchInt(move _6) -> [0: bb2, otherwise: bb1]; -+ _2 = const true; -+ switchInt(move _2) -> [0: bb2, otherwise: bb1]; - } - - bb1: { -- _5 = const true; -+ StorageDead(_2); -+ _1 = const true; - goto -> bb3; - } - - bb2: { -- _5 = const false; -+ StorageDead(_2); -+ _1 = const false; - goto -> bb3; - } - - bb3: { -- switchInt(move _5) -> [0: bb5, otherwise: bb4]; -- } -- -- bb4: { -- StorageDead(_6); -- _4 = const true; -- goto -> bb6; -- } -- -- bb5: { -- StorageDead(_6); -- _4 = const false; -- goto -> bb6; -- } -- -- bb6: { -- switchInt(move _4) -> [0: bb8, otherwise: bb7]; -- } -- -- bb7: { -- StorageDead(_5); -- _3 = const true; -- goto -> bb9; -- } -- -- bb8: { -- StorageDead(_5); -- _3 = const false; -- goto -> bb9; -- } -- -- bb9: { -- switchInt(move _3) -> [0: bb11, otherwise: bb10]; -- } -- -- bb10: { -- StorageDead(_4); -- StorageDead(_3); -- _1 = const true; -- goto -> bb12; -- } -- -- bb11: { -- StorageDead(_4); -- StorageDead(_3); -- _1 = const false; -- goto -> bb12; -- } -- -- bb12: { -- StorageDead(_2); - _0 = _1; - StorageDead(_1); - return; - } - } - diff --git a/tests/mir-opt/const_goto_storage.rs b/tests/mir-opt/const_goto_storage.rs deleted file mode 100644 index 9d43da23990..00000000000 --- a/tests/mir-opt/const_goto_storage.rs +++ /dev/null @@ -1,22 +0,0 @@ -// skip-filecheck -// unit-test: ConstGoto - -// EMIT_MIR const_goto_storage.match_nested_if.ConstGoto.diff -fn match_nested_if() -> bool { - let val = match () { - () if if if if true { true } else { false } { true } else { false } { - true - } else { - false - } => - { - true - } - _ => false, - }; - val -} - -fn main() { - let _ = match_nested_if(); -} 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 803be994d9a..5c21c628f85 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 @@ -31,16 +31,17 @@ StorageDead(_3); StorageLive(_6); _6 = const 1_usize; - _7 = Len((*_2)); +- _7 = Len((*_2)); - _8 = Lt(_6, _7); - assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind unreachable]; -+ _8 = Lt(const 1_usize, _7); -+ assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, const 1_usize) -> [success: bb1, unwind unreachable]; ++ _7 = const 3_usize; ++ _8 = const true; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 1_usize) -> [success: bb1, unwind unreachable]; } bb1: { - _1 = (*_2)[_6]; -+ _1 = (*_2)[1 of 2]; ++ _1 = const 2_u32; StorageDead(_6); StorageDead(_4); StorageDead(_2); 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 2a20e3eca59..470cd9c9d8f 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 @@ -31,16 +31,17 @@ StorageDead(_3); StorageLive(_6); _6 = const 1_usize; - _7 = Len((*_2)); +- _7 = Len((*_2)); - _8 = Lt(_6, _7); - assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue]; -+ _8 = Lt(const 1_usize, _7); -+ assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, const 1_usize) -> [success: bb1, unwind continue]; ++ _7 = const 3_usize; ++ _8 = const true; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 1_usize) -> [success: bb1, unwind continue]; } bb1: { - _1 = (*_2)[_6]; -+ _1 = (*_2)[1 of 2]; ++ _1 = const 2_u32; StorageDead(_6); StorageDead(_4); StorageDead(_2); 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 803be994d9a..5c21c628f85 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 @@ -31,16 +31,17 @@ StorageDead(_3); StorageLive(_6); _6 = const 1_usize; - _7 = Len((*_2)); +- _7 = Len((*_2)); - _8 = Lt(_6, _7); - assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind unreachable]; -+ _8 = Lt(const 1_usize, _7); -+ assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, const 1_usize) -> [success: bb1, unwind unreachable]; ++ _7 = const 3_usize; ++ _8 = const true; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 1_usize) -> [success: bb1, unwind unreachable]; } bb1: { - _1 = (*_2)[_6]; -+ _1 = (*_2)[1 of 2]; ++ _1 = const 2_u32; StorageDead(_6); StorageDead(_4); StorageDead(_2); 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 2a20e3eca59..470cd9c9d8f 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 @@ -31,16 +31,17 @@ StorageDead(_3); StorageLive(_6); _6 = const 1_usize; - _7 = Len((*_2)); +- _7 = Len((*_2)); - _8 = Lt(_6, _7); - assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue]; -+ _8 = Lt(const 1_usize, _7); -+ assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, const 1_usize) -> [success: bb1, unwind continue]; ++ _7 = const 3_usize; ++ _8 = const true; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 1_usize) -> [success: bb1, unwind continue]; } bb1: { - _1 = (*_2)[_6]; -+ _1 = (*_2)[1 of 2]; ++ _1 = const 2_u32; StorageDead(_6); StorageDead(_4); StorageDead(_2); diff --git a/tests/mir-opt/const_prop/slice_len.rs b/tests/mir-opt/const_prop/slice_len.rs index 79cd926df21..a4973c099cd 100644 --- a/tests/mir-opt/const_prop/slice_len.rs +++ b/tests/mir-opt/const_prop/slice_len.rs @@ -8,9 +8,7 @@ fn main() { // CHECK-LABEL: fn main( // CHECK: debug a => [[a:_.*]]; // CHECK: [[slice:_.*]] = const {{.*}} as &[u32] (PointerCoercion(Unsize)); - // FIXME(cjgillot) simplify Len and projection into unsized slice. - // CHECK-NOT: assert(const true, - // CHECK: [[a]] = (*[[slice]])[1 of 2]; - // CHECK-NOT: [[a]] = const 2_u32; + // CHECK: assert(const true, + // CHECK: [[a]] = const 2_u32; let a = (&[1u32, 2, 3] as &[u32])[1]; } diff --git a/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.panic-abort.diff b/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.panic-abort.diff index a802d0256d4..51390e2abbe 100644 --- a/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.panic-abort.diff +++ b/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.panic-abort.diff @@ -79,10 +79,14 @@ bb4: { StorageDead(_12); _14 = discriminant(_11); - switchInt(move _14) -> [0: bb7, 1: bb5, otherwise: bb6]; + switchInt(move _14) -> [0: bb7, 1: bb6, otherwise: bb5]; } bb5: { + unreachable; + } + + bb6: { - StorageLive(_16); _16 = ((_11 as Some).0: usize); StorageLive(_17); @@ -95,10 +99,6 @@ + assert(move _20, "index out of bounds: the length is {} but the index is {}", move _19, _16) -> [success: bb8, unwind unreachable]; } - bb6: { - unreachable; - } - bb7: { _0 = const (); StorageDead(_13); diff --git a/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.panic-unwind.diff index 35f852098c3..8a2cbb68824 100644 --- a/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.panic-unwind.diff +++ b/tests/mir-opt/copy-prop/issue_107511.main.CopyProp.panic-unwind.diff @@ -79,10 +79,14 @@ bb4: { StorageDead(_12); _14 = discriminant(_11); - switchInt(move _14) -> [0: bb7, 1: bb5, otherwise: bb6]; + switchInt(move _14) -> [0: bb7, 1: bb6, otherwise: bb5]; } bb5: { + unreachable; + } + + bb6: { - StorageLive(_16); _16 = ((_11 as Some).0: usize); StorageLive(_17); @@ -95,10 +99,6 @@ + assert(move _20, "index out of bounds: the length is {} but the index is {}", move _19, _16) -> [success: bb8, unwind continue]; } - bb6: { - unreachable; - } - bb7: { _0 = const (); StorageDead(_13); 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 94cfb4e63fc..80191a21f4f 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 @@ -69,28 +69,40 @@ } bb2: { - _10 = const {0x1 as *mut [bool; 0]} as *mut () (PtrToPtr); - _9 = NonNull::<T>::new_unchecked::precondition_check(move _10) -> [return: bb3, unwind unreachable]; + _10 = const {0x1 as *mut ()}; + _9 = NonNull::<T>::new_unchecked::precondition_check(const {0x1 as *mut ()}) -> [return: bb3, unwind unreachable]; } bb3: { StorageDead(_8); - _11 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); - _5 = NonNull::<[bool; 0]> { pointer: _11 }; + _11 = const {0x1 as *const [bool; 0]}; + _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; StorageDead(_11); StorageDead(_10); StorageDead(_6); - _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; + _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); + _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = Box::<[bool]>(_3, const std::alloc::Global); + _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_9); StorageDead(_3); - _1 = A { foo: move _2 }; + _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind unreachable]; } } + ALLOC2 (size: 8, align: 4) { + 01 00 00 00 00 00 00 00 │ ........ + } + + ALLOC1 (size: 8, align: 4) { + 01 00 00 00 00 00 00 00 │ ........ + } + + ALLOC0 (size: 8, align: 4) { + 01 00 00 00 00 00 00 00 │ ........ + } + 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 ee85287882b..ed878978e4b 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 @@ -73,28 +73,40 @@ } bb3: { - _10 = const {0x1 as *mut [bool; 0]} as *mut () (PtrToPtr); - _9 = NonNull::<T>::new_unchecked::precondition_check(move _10) -> [return: bb4, unwind unreachable]; + _10 = const {0x1 as *mut ()}; + _9 = NonNull::<T>::new_unchecked::precondition_check(const {0x1 as *mut ()}) -> [return: bb4, unwind unreachable]; } bb4: { StorageDead(_8); - _11 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); - _5 = NonNull::<[bool; 0]> { pointer: _11 }; + _11 = const {0x1 as *const [bool; 0]}; + _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; StorageDead(_11); StorageDead(_10); StorageDead(_6); - _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; + _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); + _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = Box::<[bool]>(_3, const std::alloc::Global); + _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_9); StorageDead(_3); - _1 = A { foo: move _2 }; + _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind: bb2]; } } + ALLOC2 (size: 8, align: 4) { + 01 00 00 00 00 00 00 00 │ ........ + } + + ALLOC1 (size: 8, align: 4) { + 01 00 00 00 00 00 00 00 │ ........ + } + + ALLOC0 (size: 8, align: 4) { + 01 00 00 00 00 00 00 00 │ ........ + } + 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 94cfb4e63fc..a61902501bf 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 @@ -69,28 +69,40 @@ } bb2: { - _10 = const {0x1 as *mut [bool; 0]} as *mut () (PtrToPtr); - _9 = NonNull::<T>::new_unchecked::precondition_check(move _10) -> [return: bb3, unwind unreachable]; + _10 = const {0x1 as *mut ()}; + _9 = NonNull::<T>::new_unchecked::precondition_check(const {0x1 as *mut ()}) -> [return: bb3, unwind unreachable]; } bb3: { StorageDead(_8); - _11 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); - _5 = NonNull::<[bool; 0]> { pointer: _11 }; + _11 = const {0x1 as *const [bool; 0]}; + _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; StorageDead(_11); StorageDead(_10); StorageDead(_6); - _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; + _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); + _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = Box::<[bool]>(_3, const std::alloc::Global); + _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_9); StorageDead(_3); - _1 = A { foo: move _2 }; + _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind unreachable]; } } + ALLOC2 (size: 16, align: 8) { + 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ + } + + ALLOC1 (size: 16, align: 8) { + 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ + } + + ALLOC0 (size: 16, align: 8) { + 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ + } + 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 ee85287882b..fca7fe89b4a 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 @@ -73,28 +73,40 @@ } bb3: { - _10 = const {0x1 as *mut [bool; 0]} as *mut () (PtrToPtr); - _9 = NonNull::<T>::new_unchecked::precondition_check(move _10) -> [return: bb4, unwind unreachable]; + _10 = const {0x1 as *mut ()}; + _9 = NonNull::<T>::new_unchecked::precondition_check(const {0x1 as *mut ()}) -> [return: bb4, unwind unreachable]; } bb4: { StorageDead(_8); - _11 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); - _5 = NonNull::<[bool; 0]> { pointer: _11 }; + _11 = const {0x1 as *const [bool; 0]}; + _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; StorageDead(_11); StorageDead(_10); StorageDead(_6); - _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; + _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); + _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = Box::<[bool]>(_3, const std::alloc::Global); + _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_9); StorageDead(_3); - _1 = A { foo: move _2 }; + _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind: bb2]; } } + ALLOC2 (size: 16, align: 8) { + 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ + } + + ALLOC1 (size: 16, align: 8) { + 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ + } + + ALLOC0 (size: 16, align: 8) { + 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ + } + 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 4df38d6e61b..0ced2e4deed 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 @@ -72,29 +72,47 @@ bb2: { - _10 = _6 as *mut () (PtrToPtr); -+ _10 = const {0x1 as *mut [bool; 0]} as *mut () (PtrToPtr); - _9 = NonNull::<T>::new_unchecked::precondition_check(move _10) -> [return: bb3, unwind unreachable]; +- _9 = NonNull::<T>::new_unchecked::precondition_check(move _10) -> [return: bb3, unwind unreachable]; ++ _10 = const {0x1 as *mut ()}; ++ _9 = NonNull::<T>::new_unchecked::precondition_check(const {0x1 as *mut ()}) -> [return: bb3, unwind unreachable]; } bb3: { StorageDead(_8); - _11 = _6 as *const [bool; 0] (PointerCoercion(MutToConstPointer)); -+ _11 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); - _5 = NonNull::<[bool; 0]> { pointer: _11 }; +- _5 = NonNull::<[bool; 0]> { pointer: _11 }; ++ _11 = const {0x1 as *const [bool; 0]}; ++ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; StorageDead(_11); StorageDead(_10); StorageDead(_6); - _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; +- _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; ++ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); +- _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); ++ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = Box::<[bool]>(_3, const std::alloc::Global); +- _2 = Box::<[bool]>(_3, const std::alloc::Global); ++ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_9); StorageDead(_3); - _1 = A { foo: move _2 }; +- _1 = A { foo: move _2 }; ++ _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind unreachable]; } ++ } ++ ++ ALLOC2 (size: 8, align: 4) { ++ 01 00 00 00 00 00 00 00 │ ........ ++ } ++ ++ ALLOC1 (size: 8, align: 4) { ++ 01 00 00 00 00 00 00 00 │ ........ ++ } ++ ++ ALLOC0 (size: 8, align: 4) { ++ 01 00 00 00 00 00 00 00 │ ........ } 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 6aac30bcd17..e17d76a6d95 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 @@ -76,29 +76,47 @@ bb3: { - _10 = _6 as *mut () (PtrToPtr); -+ _10 = const {0x1 as *mut [bool; 0]} as *mut () (PtrToPtr); - _9 = NonNull::<T>::new_unchecked::precondition_check(move _10) -> [return: bb4, unwind unreachable]; +- _9 = NonNull::<T>::new_unchecked::precondition_check(move _10) -> [return: bb4, unwind unreachable]; ++ _10 = const {0x1 as *mut ()}; ++ _9 = NonNull::<T>::new_unchecked::precondition_check(const {0x1 as *mut ()}) -> [return: bb4, unwind unreachable]; } bb4: { StorageDead(_8); - _11 = _6 as *const [bool; 0] (PointerCoercion(MutToConstPointer)); -+ _11 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); - _5 = NonNull::<[bool; 0]> { pointer: _11 }; +- _5 = NonNull::<[bool; 0]> { pointer: _11 }; ++ _11 = const {0x1 as *const [bool; 0]}; ++ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; StorageDead(_11); StorageDead(_10); StorageDead(_6); - _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; +- _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; ++ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); +- _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); ++ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = Box::<[bool]>(_3, const std::alloc::Global); +- _2 = Box::<[bool]>(_3, const std::alloc::Global); ++ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_9); StorageDead(_3); - _1 = A { foo: move _2 }; +- _1 = A { foo: move _2 }; ++ _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind: bb2]; } ++ } ++ ++ ALLOC2 (size: 8, align: 4) { ++ 01 00 00 00 00 00 00 00 │ ........ ++ } ++ ++ ALLOC1 (size: 8, align: 4) { ++ 01 00 00 00 00 00 00 00 │ ........ ++ } ++ ++ ALLOC0 (size: 8, align: 4) { ++ 01 00 00 00 00 00 00 00 │ ........ } 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 4df38d6e61b..ff68b3c2d55 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 @@ -72,29 +72,47 @@ bb2: { - _10 = _6 as *mut () (PtrToPtr); -+ _10 = const {0x1 as *mut [bool; 0]} as *mut () (PtrToPtr); - _9 = NonNull::<T>::new_unchecked::precondition_check(move _10) -> [return: bb3, unwind unreachable]; +- _9 = NonNull::<T>::new_unchecked::precondition_check(move _10) -> [return: bb3, unwind unreachable]; ++ _10 = const {0x1 as *mut ()}; ++ _9 = NonNull::<T>::new_unchecked::precondition_check(const {0x1 as *mut ()}) -> [return: bb3, unwind unreachable]; } bb3: { StorageDead(_8); - _11 = _6 as *const [bool; 0] (PointerCoercion(MutToConstPointer)); -+ _11 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); - _5 = NonNull::<[bool; 0]> { pointer: _11 }; +- _5 = NonNull::<[bool; 0]> { pointer: _11 }; ++ _11 = const {0x1 as *const [bool; 0]}; ++ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; StorageDead(_11); StorageDead(_10); StorageDead(_6); - _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; +- _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; ++ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); +- _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); ++ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = Box::<[bool]>(_3, const std::alloc::Global); +- _2 = Box::<[bool]>(_3, const std::alloc::Global); ++ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_9); StorageDead(_3); - _1 = A { foo: move _2 }; +- _1 = A { foo: move _2 }; ++ _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind unreachable]; } ++ } ++ ++ ALLOC2 (size: 16, align: 8) { ++ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ ++ } ++ ++ ALLOC1 (size: 16, align: 8) { ++ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ ++ } ++ ++ ALLOC0 (size: 16, align: 8) { ++ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ } 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 6aac30bcd17..de951e57fb9 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 @@ -76,29 +76,47 @@ bb3: { - _10 = _6 as *mut () (PtrToPtr); -+ _10 = const {0x1 as *mut [bool; 0]} as *mut () (PtrToPtr); - _9 = NonNull::<T>::new_unchecked::precondition_check(move _10) -> [return: bb4, unwind unreachable]; +- _9 = NonNull::<T>::new_unchecked::precondition_check(move _10) -> [return: bb4, unwind unreachable]; ++ _10 = const {0x1 as *mut ()}; ++ _9 = NonNull::<T>::new_unchecked::precondition_check(const {0x1 as *mut ()}) -> [return: bb4, unwind unreachable]; } bb4: { StorageDead(_8); - _11 = _6 as *const [bool; 0] (PointerCoercion(MutToConstPointer)); -+ _11 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); - _5 = NonNull::<[bool; 0]> { pointer: _11 }; +- _5 = NonNull::<[bool; 0]> { pointer: _11 }; ++ _11 = const {0x1 as *const [bool; 0]}; ++ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; StorageDead(_11); StorageDead(_10); StorageDead(_6); - _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; +- _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; ++ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; StorageDead(_5); - _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); +- _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); ++ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; StorageDead(_4); - _2 = Box::<[bool]>(_3, const std::alloc::Global); +- _2 = Box::<[bool]>(_3, const std::alloc::Global); ++ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); StorageDead(_9); StorageDead(_3); - _1 = A { foo: move _2 }; +- _1 = A { foo: move _2 }; ++ _1 = const A {{ foo: Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }}; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind: bb2]; } ++ } ++ ++ ALLOC2 (size: 16, align: 8) { ++ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ ++ } ++ ++ ALLOC1 (size: 16, align: 8) { ++ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ ++ } ++ ++ ALLOC0 (size: 16, align: 8) { ++ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs index fb708e5084b..6c1aafcfa5d 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs @@ -16,14 +16,11 @@ struct A { // CHECK-LABEL: fn main( fn main() { // ConstProp will create a constant of type `Box<[bool]>`. - // FIXME: it is not yet a constant. - // Verify that `DataflowConstProp` does not ICE trying to dereference it directly. // CHECK: debug a => [[a:_.*]]; // We may check other inlined functions as well... - // CHECK: {{_.*}} = Box::<[bool]>( - // FIXME: should be `{{_.*}} = const Box::<[bool]>` + // CHECK: {{_.*}} = const Box::<[bool]>( let a: A = A { foo: Box::default() }; } diff --git a/tests/mir-opt/dataflow-const-prop/enum.constant.DataflowConstProp.32bit.diff b/tests/mir-opt/dataflow-const-prop/enum.constant.DataflowConstProp.32bit.diff index f50a763ef9a..fc814f7e7a9 100644 --- a/tests/mir-opt/dataflow-const-prop/enum.constant.DataflowConstProp.32bit.diff +++ b/tests/mir-opt/dataflow-const-prop/enum.constant.DataflowConstProp.32bit.diff @@ -26,12 +26,16 @@ _1 = const _; StorageLive(_2); - _3 = discriminant(_1); -- switchInt(move _3) -> [0: bb3, 1: bb1, otherwise: bb2]; +- switchInt(move _3) -> [0: bb3, 1: bb2, otherwise: bb1]; + _3 = const 0_isize; -+ switchInt(const 0_isize) -> [0: bb3, 1: bb1, otherwise: bb2]; ++ switchInt(const 0_isize) -> [0: bb3, 1: bb2, otherwise: bb1]; } bb1: { + unreachable; + } + + bb2: { StorageLive(_5); _5 = ((_1 as V2).0: i32); _2 = _5; @@ -39,10 +43,6 @@ goto -> bb4; } - bb2: { - unreachable; - } - bb3: { StorageLive(_4); - _4 = ((_1 as V1).0: i32); diff --git a/tests/mir-opt/dataflow-const-prop/enum.constant.DataflowConstProp.64bit.diff b/tests/mir-opt/dataflow-const-prop/enum.constant.DataflowConstProp.64bit.diff index f50a763ef9a..fc814f7e7a9 100644 --- a/tests/mir-opt/dataflow-const-prop/enum.constant.DataflowConstProp.64bit.diff +++ b/tests/mir-opt/dataflow-const-prop/enum.constant.DataflowConstProp.64bit.diff @@ -26,12 +26,16 @@ _1 = const _; StorageLive(_2); - _3 = discriminant(_1); -- switchInt(move _3) -> [0: bb3, 1: bb1, otherwise: bb2]; +- switchInt(move _3) -> [0: bb3, 1: bb2, otherwise: bb1]; + _3 = const 0_isize; -+ switchInt(const 0_isize) -> [0: bb3, 1: bb1, otherwise: bb2]; ++ switchInt(const 0_isize) -> [0: bb3, 1: bb2, otherwise: bb1]; } bb1: { + unreachable; + } + + bb2: { StorageLive(_5); _5 = ((_1 as V2).0: i32); _2 = _5; @@ -39,10 +43,6 @@ goto -> bb4; } - bb2: { - unreachable; - } - bb3: { StorageLive(_4); - _4 = ((_1 as V1).0: i32); diff --git a/tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.32bit.diff b/tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.32bit.diff index 6bf702b8568..10d33767c90 100644 --- a/tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.32bit.diff +++ b/tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.32bit.diff @@ -49,16 +49,16 @@ StorageDead(_4); StorageLive(_6); _7 = discriminant(_3); - switchInt(move _7) -> [0: bb4, 1: bb6, otherwise: bb5]; + switchInt(move _7) -> [0: bb5, 1: bb6, otherwise: bb4]; } bb4: { - _6 = const 0_u8; - goto -> bb7; + unreachable; } bb5: { - unreachable; + _6 = const 0_u8; + goto -> bb7; } bb6: { diff --git a/tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.64bit.diff b/tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.64bit.diff index 6bf702b8568..10d33767c90 100644 --- a/tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.64bit.diff +++ b/tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.64bit.diff @@ -49,16 +49,16 @@ StorageDead(_4); StorageLive(_6); _7 = discriminant(_3); - switchInt(move _7) -> [0: bb4, 1: bb6, otherwise: bb5]; + switchInt(move _7) -> [0: bb5, 1: bb6, otherwise: bb4]; } bb4: { - _6 = const 0_u8; - goto -> bb7; + unreachable; } bb5: { - unreachable; + _6 = const 0_u8; + goto -> bb7; } bb6: { diff --git a/tests/mir-opt/dataflow-const-prop/enum.rs b/tests/mir-opt/dataflow-const-prop/enum.rs index 7ad64d05be4..78410e49d2a 100644 --- a/tests/mir-opt/dataflow-const-prop/enum.rs +++ b/tests/mir-opt/dataflow-const-prop/enum.rs @@ -20,7 +20,7 @@ fn simple() { // CHECK: [[e]] = const E::V1(0_i32); let e = E::V1(0); - // CHECK: switchInt(const 0_isize) -> [0: [[target_bb:bb.*]], 1: bb1, otherwise: bb2]; + // CHECK: switchInt(const 0_isize) -> [0: [[target_bb:bb.*]], 1: bb2, otherwise: bb1]; // CHECK: [[target_bb]]: { // CHECK: [[x]] = const 0_i32; let x = match e { E::V1(x1) => x1, E::V2(x2) => x2 }; @@ -36,7 +36,7 @@ fn constant() { // CHECK: [[e]] = const _; let e = C; - // CHECK: switchInt(const 0_isize) -> [0: [[target_bb:bb.*]], 1: bb1, otherwise: bb2]; + // CHECK: switchInt(const 0_isize) -> [0: [[target_bb:bb.*]], 1: bb2, otherwise: bb1]; // CHECK: [[target_bb]]: { // CHECK: [[x]] = const 0_i32; let x = match e { E::V1(x1) => x1, E::V2(x2) => x2 }; @@ -55,7 +55,7 @@ fn statics() { // CHECK: [[e1]] = const E::V1(0_i32); let e1 = C; - // CHECK: switchInt(const 0_isize) -> [0: [[target_bb:bb.*]], 1: bb1, otherwise: bb2]; + // CHECK: switchInt(const 0_isize) -> [0: [[target_bb:bb.*]], 1: bb2, otherwise: bb1]; // CHECK: [[target_bb]]: { // CHECK: [[x1]] = const 0_i32; let x1 = match e1 { E::V1(x11) => x11, E::V2(x12) => x12 }; diff --git a/tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.32bit.diff b/tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.32bit.diff index b31f98460e4..89ed26f065b 100644 --- a/tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.32bit.diff +++ b/tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.32bit.diff @@ -27,12 +27,16 @@ + _1 = const E::V1(0_i32); StorageLive(_2); - _3 = discriminant(_1); -- switchInt(move _3) -> [0: bb3, 1: bb1, otherwise: bb2]; +- switchInt(move _3) -> [0: bb3, 1: bb2, otherwise: bb1]; + _3 = const 0_isize; -+ switchInt(const 0_isize) -> [0: bb3, 1: bb1, otherwise: bb2]; ++ switchInt(const 0_isize) -> [0: bb3, 1: bb2, otherwise: bb1]; } bb1: { + unreachable; + } + + bb2: { StorageLive(_5); _5 = ((_1 as V2).0: i32); _2 = _5; @@ -40,10 +44,6 @@ goto -> bb4; } - bb2: { - unreachable; - } - bb3: { StorageLive(_4); - _4 = ((_1 as V1).0: i32); diff --git a/tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.64bit.diff b/tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.64bit.diff index b31f98460e4..89ed26f065b 100644 --- a/tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.64bit.diff +++ b/tests/mir-opt/dataflow-const-prop/enum.simple.DataflowConstProp.64bit.diff @@ -27,12 +27,16 @@ + _1 = const E::V1(0_i32); StorageLive(_2); - _3 = discriminant(_1); -- switchInt(move _3) -> [0: bb3, 1: bb1, otherwise: bb2]; +- switchInt(move _3) -> [0: bb3, 1: bb2, otherwise: bb1]; + _3 = const 0_isize; -+ switchInt(const 0_isize) -> [0: bb3, 1: bb1, otherwise: bb2]; ++ switchInt(const 0_isize) -> [0: bb3, 1: bb2, otherwise: bb1]; } bb1: { + unreachable; + } + + bb2: { StorageLive(_5); _5 = ((_1 as V2).0: i32); _2 = _5; @@ -40,10 +44,6 @@ goto -> bb4; } - bb2: { - unreachable; - } - bb3: { StorageLive(_4); - _4 = ((_1 as V1).0: i32); diff --git a/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.32bit.diff b/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.32bit.diff index 44e8d39cca3..fe8ed011489 100644 --- a/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.32bit.diff +++ b/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.32bit.diff @@ -49,12 +49,16 @@ StorageDead(_2); StorageLive(_3); - _4 = discriminant(_1); -- switchInt(move _4) -> [0: bb3, 1: bb1, otherwise: bb2]; +- switchInt(move _4) -> [0: bb3, 1: bb2, otherwise: bb1]; + _4 = const 0_isize; -+ switchInt(const 0_isize) -> [0: bb3, 1: bb1, otherwise: bb2]; ++ switchInt(const 0_isize) -> [0: bb3, 1: bb2, otherwise: bb1]; } bb1: { + unreachable; + } + + bb2: { StorageLive(_6); _6 = ((_1 as V2).0: i32); _3 = _6; @@ -62,10 +66,6 @@ goto -> bb4; } - bb2: { - unreachable; - } - bb3: { StorageLive(_5); - _5 = ((_1 as V1).0: i32); @@ -84,7 +84,7 @@ StorageDead(_8); StorageLive(_9); _10 = discriminant((*_7)); - switchInt(move _10) -> [0: bb6, 1: bb5, otherwise: bb2]; + switchInt(move _10) -> [0: bb6, 1: bb5, otherwise: bb1]; } bb5: { diff --git a/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.64bit.diff b/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.64bit.diff index ac4ca086d0f..df3a989d09e 100644 --- a/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.64bit.diff +++ b/tests/mir-opt/dataflow-const-prop/enum.statics.DataflowConstProp.64bit.diff @@ -49,12 +49,16 @@ StorageDead(_2); StorageLive(_3); - _4 = discriminant(_1); -- switchInt(move _4) -> [0: bb3, 1: bb1, otherwise: bb2]; +- switchInt(move _4) -> [0: bb3, 1: bb2, otherwise: bb1]; + _4 = const 0_isize; -+ switchInt(const 0_isize) -> [0: bb3, 1: bb1, otherwise: bb2]; ++ switchInt(const 0_isize) -> [0: bb3, 1: bb2, otherwise: bb1]; } bb1: { + unreachable; + } + + bb2: { StorageLive(_6); _6 = ((_1 as V2).0: i32); _3 = _6; @@ -62,10 +66,6 @@ goto -> bb4; } - bb2: { - unreachable; - } - bb3: { StorageLive(_5); - _5 = ((_1 as V1).0: i32); @@ -84,7 +84,7 @@ StorageDead(_8); StorageLive(_9); _10 = discriminant((*_7)); - switchInt(move _10) -> [0: bb6, 1: bb5, otherwise: bb2]; + switchInt(move _10) -> [0: bb6, 1: bb5, otherwise: bb1]; } bb5: { diff --git a/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-abort.diff b/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-abort.diff index 5c4fc06a2ba..938b9bb14ad 100644 --- a/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-abort.diff +++ b/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-abort.diff @@ -25,58 +25,66 @@ _7 = Len((*_2)); _8 = const 4_usize; _9 = Ge(move _7, move _8); - switchInt(move _9) -> [0: bb6, otherwise: bb2]; +- switchInt(move _9) -> [0: bb2, otherwise: bb7]; ++ switchInt(move _9) -> [0: bb2, otherwise: bb6]; } bb2: { - switchInt((*_2)[0 of 4]) -> [47: bb3, otherwise: bb6]; + _4 = Len((*_2)); + _5 = const 3_usize; + _6 = Ge(move _4, move _5); +- switchInt(move _6) -> [0: bb3, otherwise: bb4]; ++ switchInt(move _6) -> [0: bb10, otherwise: bb3]; } bb3: { - switchInt((*_2)[1 of 4]) -> [47: bb4, otherwise: bb6]; +- _0 = const false; +- goto -> bb14; ++ switchInt((*_2)[0 of 3]) -> [47: bb4, otherwise: bb10]; } bb4: { - switchInt((*_2)[2 of 4]) -> [47: bb5, otherwise: bb6]; +- switchInt((*_2)[0 of 3]) -> [47: bb5, otherwise: bb3]; ++ switchInt((*_2)[1 of 3]) -> [47: bb5, otherwise: bb10]; } bb5: { -- switchInt((*_2)[3 of 4]) -> [47: bb11, otherwise: bb6]; -+ switchInt((*_2)[3 of 4]) -> [47: bb10, otherwise: bb6]; +- switchInt((*_2)[1 of 3]) -> [47: bb6, otherwise: bb3]; ++ switchInt((*_2)[2 of 3]) -> [47: bb11, 33: bb11, otherwise: bb10]; } bb6: { - _4 = Len((*_2)); - _5 = const 3_usize; - _6 = Ge(move _4, move _5); - switchInt(move _6) -> [0: bb10, otherwise: bb7]; +- switchInt((*_2)[2 of 3]) -> [47: bb12, 33: bb13, otherwise: bb3]; ++ switchInt((*_2)[0 of 4]) -> [47: bb7, otherwise: bb2]; } bb7: { - switchInt((*_2)[0 of 3]) -> [47: bb8, otherwise: bb10]; +- switchInt((*_2)[0 of 4]) -> [47: bb8, otherwise: bb2]; ++ switchInt((*_2)[1 of 4]) -> [47: bb8, otherwise: bb2]; } bb8: { - switchInt((*_2)[1 of 3]) -> [47: bb9, otherwise: bb10]; +- switchInt((*_2)[1 of 4]) -> [47: bb9, otherwise: bb2]; ++ switchInt((*_2)[2 of 4]) -> [47: bb9, otherwise: bb2]; } bb9: { -- switchInt((*_2)[2 of 3]) -> [47: bb12, 33: bb13, otherwise: bb10]; -+ switchInt((*_2)[2 of 3]) -> [47: bb11, 33: bb11, otherwise: bb10]; +- switchInt((*_2)[2 of 4]) -> [47: bb10, otherwise: bb2]; ++ switchInt((*_2)[3 of 4]) -> [47: bb10, otherwise: bb2]; } bb10: { +- switchInt((*_2)[3 of 4]) -> [47: bb11, otherwise: bb2]; +- } +- +- bb11: { _0 = const false; - goto -> bb14; + goto -> bb12; } - bb11: { -- _0 = const false; -- goto -> bb14; -- } -- - bb12: { ++ bb11: { _0 = const true; - goto -> bb14; + goto -> bb12; diff --git a/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-unwind.diff b/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-unwind.diff index 3d9aa829052..ce89694076b 100644 --- a/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-unwind.diff +++ b/tests/mir-opt/deduplicate_blocks.is_line_doc_comment_2.DeduplicateBlocks.panic-unwind.diff @@ -25,58 +25,66 @@ _7 = Len((*_2)); _8 = const 4_usize; _9 = Ge(move _7, move _8); - switchInt(move _9) -> [0: bb6, otherwise: bb2]; +- switchInt(move _9) -> [0: bb2, otherwise: bb7]; ++ switchInt(move _9) -> [0: bb2, otherwise: bb6]; } bb2: { - switchInt((*_2)[0 of 4]) -> [47: bb3, otherwise: bb6]; + _4 = Len((*_2)); + _5 = const 3_usize; + _6 = Ge(move _4, move _5); +- switchInt(move _6) -> [0: bb3, otherwise: bb4]; ++ switchInt(move _6) -> [0: bb10, otherwise: bb3]; } bb3: { - switchInt((*_2)[1 of 4]) -> [47: bb4, otherwise: bb6]; +- _0 = const false; +- goto -> bb14; ++ switchInt((*_2)[0 of 3]) -> [47: bb4, otherwise: bb10]; } bb4: { - switchInt((*_2)[2 of 4]) -> [47: bb5, otherwise: bb6]; +- switchInt((*_2)[0 of 3]) -> [47: bb5, otherwise: bb3]; ++ switchInt((*_2)[1 of 3]) -> [47: bb5, otherwise: bb10]; } bb5: { -- switchInt((*_2)[3 of 4]) -> [47: bb11, otherwise: bb6]; -+ switchInt((*_2)[3 of 4]) -> [47: bb10, otherwise: bb6]; +- switchInt((*_2)[1 of 3]) -> [47: bb6, otherwise: bb3]; ++ switchInt((*_2)[2 of 3]) -> [47: bb11, 33: bb11, otherwise: bb10]; } bb6: { - _4 = Len((*_2)); - _5 = const 3_usize; - _6 = Ge(move _4, move _5); - switchInt(move _6) -> [0: bb10, otherwise: bb7]; +- switchInt((*_2)[2 of 3]) -> [47: bb12, 33: bb13, otherwise: bb3]; ++ switchInt((*_2)[0 of 4]) -> [47: bb7, otherwise: bb2]; } bb7: { - switchInt((*_2)[0 of 3]) -> [47: bb8, otherwise: bb10]; +- switchInt((*_2)[0 of 4]) -> [47: bb8, otherwise: bb2]; ++ switchInt((*_2)[1 of 4]) -> [47: bb8, otherwise: bb2]; } bb8: { - switchInt((*_2)[1 of 3]) -> [47: bb9, otherwise: bb10]; +- switchInt((*_2)[1 of 4]) -> [47: bb9, otherwise: bb2]; ++ switchInt((*_2)[2 of 4]) -> [47: bb9, otherwise: bb2]; } bb9: { -- switchInt((*_2)[2 of 3]) -> [47: bb12, 33: bb13, otherwise: bb10]; -+ switchInt((*_2)[2 of 3]) -> [47: bb11, 33: bb11, otherwise: bb10]; +- switchInt((*_2)[2 of 4]) -> [47: bb10, otherwise: bb2]; ++ switchInt((*_2)[3 of 4]) -> [47: bb10, otherwise: bb2]; } bb10: { +- switchInt((*_2)[3 of 4]) -> [47: bb11, otherwise: bb2]; +- } +- +- bb11: { _0 = const false; - goto -> bb14; + goto -> bb12; } - bb11: { -- _0 = const false; -- goto -> bb14; -- } -- - bb12: { ++ bb11: { _0 = const true; - goto -> bb14; + goto -> bb12; diff --git a/tests/mir-opt/derefer_complex_case.main.Derefer.panic-abort.diff b/tests/mir-opt/derefer_complex_case.main.Derefer.panic-abort.diff index 0fad716a2cb..6654e710625 100644 --- a/tests/mir-opt/derefer_complex_case.main.Derefer.panic-abort.diff +++ b/tests/mir-opt/derefer_complex_case.main.Derefer.panic-abort.diff @@ -55,10 +55,14 @@ StorageDead(_8); PlaceMention(_7); _10 = discriminant(_7); - switchInt(move _10) -> [0: bb6, 1: bb4, otherwise: bb5]; + switchInt(move _10) -> [0: bb6, 1: bb5, otherwise: bb4]; } bb4: { + unreachable; + } + + bb5: { StorageLive(_12); - _12 = (*((_7 as Some).0: &i32)); + _15 = deref_copy ((_7 as Some).0: &i32); @@ -68,10 +72,6 @@ _6 = std::mem::drop::<i32>(move _13) -> [return: bb7, unwind: bb8]; } - bb5: { - unreachable; - } - bb6: { _0 = const (); StorageDead(_9); diff --git a/tests/mir-opt/derefer_complex_case.main.Derefer.panic-unwind.diff b/tests/mir-opt/derefer_complex_case.main.Derefer.panic-unwind.diff index ae5656f02a5..18fc27e7cf7 100644 --- a/tests/mir-opt/derefer_complex_case.main.Derefer.panic-unwind.diff +++ b/tests/mir-opt/derefer_complex_case.main.Derefer.panic-unwind.diff @@ -55,10 +55,14 @@ StorageDead(_8); PlaceMention(_7); _10 = discriminant(_7); - switchInt(move _10) -> [0: bb6, 1: bb4, otherwise: bb5]; + switchInt(move _10) -> [0: bb6, 1: bb5, otherwise: bb4]; } bb4: { + unreachable; + } + + bb5: { StorageLive(_12); - _12 = (*((_7 as Some).0: &i32)); + _15 = deref_copy ((_7 as Some).0: &i32); @@ -68,10 +72,6 @@ _6 = std::mem::drop::<i32>(move _13) -> [return: bb7, unwind continue]; } - bb5: { - unreachable; - } - bb6: { _0 = const (); StorageDead(_9); diff --git a/tests/mir-opt/early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff b/tests/mir-opt/early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff index b91a469225c..32a8dd8b8b4 100644 --- a/tests/mir-opt/early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff +++ b/tests/mir-opt/early_otherwise_branch.opt2.EarlyOtherwiseBranch.diff @@ -30,7 +30,7 @@ StorageDead(_5); StorageDead(_4); _8 = discriminant((_3.0: std::option::Option<u32>)); -- switchInt(move _8) -> [0: bb1, 1: bb3, otherwise: bb2]; +- switchInt(move _8) -> [0: bb2, 1: bb3, otherwise: bb1]; + StorageLive(_11); + _11 = discriminant((_3.1: std::option::Option<u32>)); + StorageLive(_12); @@ -40,24 +40,23 @@ } bb1: { -- _6 = discriminant((_3.1: std::option::Option<u32>)); -- switchInt(move _6) -> [0: bb5, otherwise: bb2]; -- } -- -- bb2: { + StorageDead(_12); _0 = const 1_u32; - goto -> bb6; + goto -> bb4; } + bb2: { +- _6 = discriminant((_3.1: std::option::Option<u32>)); +- switchInt(move _6) -> [0: bb5, otherwise: bb1]; +- } +- - bb3: { - _7 = discriminant((_3.1: std::option::Option<u32>)); -- switchInt(move _7) -> [1: bb4, otherwise: bb2]; +- switchInt(move _7) -> [1: bb4, otherwise: bb1]; - } - - bb4: { -+ bb2: { StorageLive(_10); _10 = (((_3.1: std::option::Option<u32>) as Some).0: u32); StorageLive(_9); diff --git a/tests/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff b/tests/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff index 79cf1c0e34a..6179bab11fe 100644 --- a/tests/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff +++ b/tests/mir-opt/early_otherwise_branch_68867.try_sum.EarlyOtherwiseBranch.diff @@ -78,16 +78,10 @@ StorageDead(_5); _34 = deref_copy (_4.0: &ViewportPercentageLength); _11 = discriminant((*_34)); - switchInt(move _11) -> [0: bb1, 1: bb3, 2: bb4, 3: bb5, otherwise: bb2]; + switchInt(move _11) -> [0: bb2, 1: bb3, 2: bb4, 3: bb5, otherwise: bb1]; } bb1: { - _35 = deref_copy (_4.1: &ViewportPercentageLength); - _7 = discriminant((*_35)); - switchInt(move _7) -> [0: bb6, otherwise: bb2]; - } - - bb2: { StorageLive(_33); _33 = (); _0 = Result::<ViewportPercentageLength, ()>::Err(move _33); @@ -97,22 +91,28 @@ goto -> bb11; } + bb2: { + _35 = deref_copy (_4.1: &ViewportPercentageLength); + _7 = discriminant((*_35)); + switchInt(move _7) -> [0: bb6, otherwise: bb1]; + } + bb3: { _36 = deref_copy (_4.1: &ViewportPercentageLength); _8 = discriminant((*_36)); - switchInt(move _8) -> [1: bb7, otherwise: bb2]; + switchInt(move _8) -> [1: bb7, otherwise: bb1]; } bb4: { _37 = deref_copy (_4.1: &ViewportPercentageLength); _9 = discriminant((*_37)); - switchInt(move _9) -> [2: bb8, otherwise: bb2]; + switchInt(move _9) -> [2: bb8, otherwise: bb1]; } bb5: { _38 = deref_copy (_4.1: &ViewportPercentageLength); _10 = discriminant((*_38)); - switchInt(move _10) -> [3: bb9, otherwise: bb2]; + switchInt(move _10) -> [3: bb9, otherwise: bb1]; } bb6: { diff --git a/tests/mir-opt/early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff b/tests/mir-opt/early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff index af0337d0a7e..d7908ab3cd2 100644 --- a/tests/mir-opt/early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff +++ b/tests/mir-opt/early_otherwise_branch_noopt.noopt1.EarlyOtherwiseBranch.diff @@ -36,26 +36,26 @@ StorageDead(_5); StorageDead(_4); _8 = discriminant((_3.0: std::option::Option<u32>)); - switchInt(move _8) -> [0: bb1, 1: bb4, otherwise: bb3]; + switchInt(move _8) -> [0: bb2, 1: bb4, otherwise: bb1]; } bb1: { - _6 = discriminant((_3.1: std::option::Option<u32>)); - switchInt(move _6) -> [0: bb2, 1: bb7, otherwise: bb3]; + unreachable; } bb2: { - _0 = const 3_u32; - goto -> bb8; + _6 = discriminant((_3.1: std::option::Option<u32>)); + switchInt(move _6) -> [0: bb3, 1: bb7, otherwise: bb1]; } bb3: { - unreachable; + _0 = const 3_u32; + goto -> bb8; } bb4: { _7 = discriminant((_3.1: std::option::Option<u32>)); - switchInt(move _7) -> [0: bb6, 1: bb5, otherwise: bb3]; + switchInt(move _7) -> [0: bb6, 1: bb5, otherwise: bb1]; } bb5: { diff --git a/tests/mir-opt/gvn.rs b/tests/mir-opt/gvn.rs index 31ea237cbec..fccd4484a29 100644 --- a/tests/mir-opt/gvn.rs +++ b/tests/mir-opt/gvn.rs @@ -644,25 +644,80 @@ fn constant_index_overflow<T: Copy>(x: &[T]) { opaque(b) } -fn wide_ptr_ops() { +/// Check that we do not attempt to simplify anything when there is provenance. +fn wide_ptr_provenance() { + // CHECK-LABEL: fn wide_ptr_provenance( let a: *const dyn Send = &1 as &dyn Send; let b: *const dyn Send = &1 as &dyn Send; - let _val = a == b; - let _val = a != b; - let _val = a < b; - let _val = a <= b; - let _val = a > b; - let _val = a >= b; + + // CHECK: [[eqp:_.*]] = Eq([[a:_.*]], [[b:_.*]]); + // CHECK: opaque::<bool>(move [[eqp]]) + opaque(a == b); + // CHECK: [[nep:_.*]] = Ne([[a]], [[b]]); + // CHECK: opaque::<bool>(move [[nep]]) + opaque(a != b); + // CHECK: [[ltp:_.*]] = Lt([[a]], [[b]]); + // CHECK: opaque::<bool>(move [[ltp]]) + opaque(a < b); + // CHECK: [[lep:_.*]] = Le([[a]], [[b]]); + // CHECK: opaque::<bool>(move [[lep]]) + opaque(a <= b); + // CHECK: [[gtp:_.*]] = Gt([[a]], [[b]]); + // CHECK: opaque::<bool>(move [[gtp]]) + opaque(a > b); + // CHECK: [[gep:_.*]] = Ge([[a]], [[b]]); + // CHECK: opaque::<bool>(move [[gep]]) + opaque(a >= b); +} + +/// Both pointers come form the same allocation, so we could probably fold the comparisons. +fn wide_ptr_same_provenance() { + // CHECK-LABEL: fn wide_ptr_same_provenance( + let slice = &[1, 2]; + let a: *const dyn Send = &slice[0] as &dyn Send; + let b: *const dyn Send = &slice[1] as &dyn Send; + + // CHECK: [[eqp:_.*]] = Eq([[a:_.*]], [[b:_.*]]); + // CHECK: opaque::<bool>(move [[eqp]]) + opaque(a == b); + // CHECK: [[nep:_.*]] = Ne([[a]], [[b]]); + // CHECK: opaque::<bool>(move [[nep]]) + opaque(a != b); + // CHECK: [[ltp:_.*]] = Lt([[a]], [[b]]); + // CHECK: opaque::<bool>(move [[ltp]]) + opaque(a < b); + // CHECK: [[lep:_.*]] = Le([[a]], [[b]]); + // CHECK: opaque::<bool>(move [[lep]]) + opaque(a <= b); + // CHECK: [[gtp:_.*]] = Gt([[a]], [[b]]); + // CHECK: opaque::<bool>(move [[gtp]]) + opaque(a > b); + // CHECK: [[gep:_.*]] = Ge([[a]], [[b]]); + // CHECK: opaque::<bool>(move [[gep]]) + opaque(a >= b); +} + +/// Check that we do simplify when there is no provenance, and do not ICE. +fn wide_ptr_integer() { + // CHECK-LABEL: fn wide_ptr_integer( + // CHECK: debug a => [[a:_.*]]; + // CHECK: debug b => [[b:_.*]]; let a: *const [u8] = unsafe { transmute((1usize, 1usize)) }; let b: *const [u8] = unsafe { transmute((1usize, 2usize)) }; - opaque(!(a == b)); + // CHECK: opaque::<bool>(const false) + opaque(a == b); + // CHECK: opaque::<bool>(const true) opaque(a != b); - opaque(a <= b); + // CHECK: opaque::<bool>(const true) opaque(a < b); - opaque(!(a >= b)); - opaque(!(a > b)); + // CHECK: opaque::<bool>(const true) + opaque(a <= b); + // CHECK: opaque::<bool>(const false) + opaque(a > b); + // CHECK: opaque::<bool>(const false) + opaque(a >= b); } fn main() { @@ -685,7 +740,8 @@ fn main() { fn_pointers(); indirect_static(); constant_index_overflow(&[5, 3]); - wide_ptr_ops(); + wide_ptr_provenance(); + wide_ptr_integer(); } #[inline(never)] @@ -714,4 +770,6 @@ fn identity<T>(x: T) -> T { // EMIT_MIR gvn.fn_pointers.GVN.diff // EMIT_MIR gvn.indirect_static.GVN.diff // EMIT_MIR gvn.constant_index_overflow.GVN.diff -// EMIT_MIR gvn.wide_ptr_ops.GVN.diff +// EMIT_MIR gvn.wide_ptr_provenance.GVN.diff +// EMIT_MIR gvn.wide_ptr_same_provenance.GVN.diff +// EMIT_MIR gvn.wide_ptr_integer.GVN.diff diff --git a/tests/mir-opt/gvn.wide_ptr_integer.GVN.panic-abort.diff b/tests/mir-opt/gvn.wide_ptr_integer.GVN.panic-abort.diff new file mode 100644 index 00000000000..11cd43fc0e0 --- /dev/null +++ b/tests/mir-opt/gvn.wide_ptr_integer.GVN.panic-abort.diff @@ -0,0 +1,192 @@ +- // MIR for `wide_ptr_integer` before GVN ++ // MIR for `wide_ptr_integer` after GVN + + fn wide_ptr_integer() -> () { + let mut _0: (); + let _1: *const [u8]; + let mut _2: (usize, usize); + let mut _4: (usize, usize); + let _5: (); + let mut _6: bool; + let mut _7: *const [u8]; + let mut _8: *const [u8]; + let _9: (); + let mut _10: bool; + let mut _11: *const [u8]; + let mut _12: *const [u8]; + let _13: (); + let mut _14: bool; + let mut _15: *const [u8]; + let mut _16: *const [u8]; + let _17: (); + let mut _18: bool; + let mut _19: *const [u8]; + let mut _20: *const [u8]; + let _21: (); + let mut _22: bool; + let mut _23: *const [u8]; + let mut _24: *const [u8]; + let _25: (); + let mut _26: bool; + let mut _27: *const [u8]; + let mut _28: *const [u8]; + scope 1 { + debug a => _1; + let _3: *const [u8]; + scope 3 { + debug b => _3; + } + scope 4 { + } + } + scope 2 { + } + + bb0: { +- StorageLive(_1); ++ nop; + StorageLive(_2); +- _2 = (const 1_usize, const 1_usize); +- _1 = move _2 as *const [u8] (Transmute); ++ _2 = const (1_usize, 1_usize); ++ _1 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; + StorageDead(_2); +- StorageLive(_3); ++ nop; + StorageLive(_4); +- _4 = (const 1_usize, const 2_usize); +- _3 = move _4 as *const [u8] (Transmute); ++ _4 = const (1_usize, 2_usize); ++ _3 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; + StorageDead(_4); + StorageLive(_5); + StorageLive(_6); + StorageLive(_7); +- _7 = _1; ++ _7 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; + StorageLive(_8); +- _8 = _3; +- _6 = Eq(move _7, move _8); ++ _8 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; ++ _6 = const false; + StorageDead(_8); + StorageDead(_7); +- _5 = opaque::<bool>(move _6) -> [return: bb1, unwind unreachable]; ++ _5 = opaque::<bool>(const false) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_6); + StorageDead(_5); + StorageLive(_9); + StorageLive(_10); + StorageLive(_11); +- _11 = _1; ++ _11 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; + StorageLive(_12); +- _12 = _3; +- _10 = Ne(move _11, move _12); ++ _12 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; ++ _10 = const true; + StorageDead(_12); + StorageDead(_11); +- _9 = opaque::<bool>(move _10) -> [return: bb2, unwind unreachable]; ++ _9 = opaque::<bool>(const true) -> [return: bb2, unwind unreachable]; + } + + bb2: { + StorageDead(_10); + StorageDead(_9); + StorageLive(_13); + StorageLive(_14); + StorageLive(_15); +- _15 = _1; ++ _15 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; + StorageLive(_16); +- _16 = _3; +- _14 = Lt(move _15, move _16); ++ _16 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; ++ _14 = const true; + StorageDead(_16); + StorageDead(_15); +- _13 = opaque::<bool>(move _14) -> [return: bb3, unwind unreachable]; ++ _13 = opaque::<bool>(const true) -> [return: bb3, unwind unreachable]; + } + + bb3: { + StorageDead(_14); + StorageDead(_13); + StorageLive(_17); + StorageLive(_18); + StorageLive(_19); +- _19 = _1; ++ _19 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; + StorageLive(_20); +- _20 = _3; +- _18 = Le(move _19, move _20); ++ _20 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; ++ _18 = const true; + StorageDead(_20); + StorageDead(_19); +- _17 = opaque::<bool>(move _18) -> [return: bb4, unwind unreachable]; ++ _17 = opaque::<bool>(const true) -> [return: bb4, unwind unreachable]; + } + + bb4: { + StorageDead(_18); + StorageDead(_17); + StorageLive(_21); + StorageLive(_22); + StorageLive(_23); +- _23 = _1; ++ _23 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; + StorageLive(_24); +- _24 = _3; +- _22 = Gt(move _23, move _24); ++ _24 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; ++ _22 = const false; + StorageDead(_24); + StorageDead(_23); +- _21 = opaque::<bool>(move _22) -> [return: bb5, unwind unreachable]; ++ _21 = opaque::<bool>(const false) -> [return: bb5, unwind unreachable]; + } + + bb5: { + StorageDead(_22); + StorageDead(_21); + StorageLive(_25); + StorageLive(_26); + StorageLive(_27); +- _27 = _1; ++ _27 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; + StorageLive(_28); +- _28 = _3; +- _26 = Ge(move _27, move _28); ++ _28 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; ++ _26 = const false; + StorageDead(_28); + StorageDead(_27); +- _25 = opaque::<bool>(move _26) -> [return: bb6, unwind unreachable]; ++ _25 = opaque::<bool>(const false) -> [return: bb6, unwind unreachable]; + } + + bb6: { + StorageDead(_26); + StorageDead(_25); + _0 = const (); +- StorageDead(_3); +- StorageDead(_1); ++ nop; ++ nop; + return; + } ++ } ++ ++ ALLOC1 (size: 16, align: 8) { ++ 01 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 │ ................ ++ } ++ ++ ALLOC0 (size: 16, align: 8) { ++ 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 │ ................ + } + diff --git a/tests/mir-opt/gvn.wide_ptr_integer.GVN.panic-unwind.diff b/tests/mir-opt/gvn.wide_ptr_integer.GVN.panic-unwind.diff new file mode 100644 index 00000000000..c77cd07c60c --- /dev/null +++ b/tests/mir-opt/gvn.wide_ptr_integer.GVN.panic-unwind.diff @@ -0,0 +1,192 @@ +- // MIR for `wide_ptr_integer` before GVN ++ // MIR for `wide_ptr_integer` after GVN + + fn wide_ptr_integer() -> () { + let mut _0: (); + let _1: *const [u8]; + let mut _2: (usize, usize); + let mut _4: (usize, usize); + let _5: (); + let mut _6: bool; + let mut _7: *const [u8]; + let mut _8: *const [u8]; + let _9: (); + let mut _10: bool; + let mut _11: *const [u8]; + let mut _12: *const [u8]; + let _13: (); + let mut _14: bool; + let mut _15: *const [u8]; + let mut _16: *const [u8]; + let _17: (); + let mut _18: bool; + let mut _19: *const [u8]; + let mut _20: *const [u8]; + let _21: (); + let mut _22: bool; + let mut _23: *const [u8]; + let mut _24: *const [u8]; + let _25: (); + let mut _26: bool; + let mut _27: *const [u8]; + let mut _28: *const [u8]; + scope 1 { + debug a => _1; + let _3: *const [u8]; + scope 3 { + debug b => _3; + } + scope 4 { + } + } + scope 2 { + } + + bb0: { +- StorageLive(_1); ++ nop; + StorageLive(_2); +- _2 = (const 1_usize, const 1_usize); +- _1 = move _2 as *const [u8] (Transmute); ++ _2 = const (1_usize, 1_usize); ++ _1 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; + StorageDead(_2); +- StorageLive(_3); ++ nop; + StorageLive(_4); +- _4 = (const 1_usize, const 2_usize); +- _3 = move _4 as *const [u8] (Transmute); ++ _4 = const (1_usize, 2_usize); ++ _3 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; + StorageDead(_4); + StorageLive(_5); + StorageLive(_6); + StorageLive(_7); +- _7 = _1; ++ _7 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; + StorageLive(_8); +- _8 = _3; +- _6 = Eq(move _7, move _8); ++ _8 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; ++ _6 = const false; + StorageDead(_8); + StorageDead(_7); +- _5 = opaque::<bool>(move _6) -> [return: bb1, unwind continue]; ++ _5 = opaque::<bool>(const false) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_6); + StorageDead(_5); + StorageLive(_9); + StorageLive(_10); + StorageLive(_11); +- _11 = _1; ++ _11 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; + StorageLive(_12); +- _12 = _3; +- _10 = Ne(move _11, move _12); ++ _12 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; ++ _10 = const true; + StorageDead(_12); + StorageDead(_11); +- _9 = opaque::<bool>(move _10) -> [return: bb2, unwind continue]; ++ _9 = opaque::<bool>(const true) -> [return: bb2, unwind continue]; + } + + bb2: { + StorageDead(_10); + StorageDead(_9); + StorageLive(_13); + StorageLive(_14); + StorageLive(_15); +- _15 = _1; ++ _15 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; + StorageLive(_16); +- _16 = _3; +- _14 = Lt(move _15, move _16); ++ _16 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; ++ _14 = const true; + StorageDead(_16); + StorageDead(_15); +- _13 = opaque::<bool>(move _14) -> [return: bb3, unwind continue]; ++ _13 = opaque::<bool>(const true) -> [return: bb3, unwind continue]; + } + + bb3: { + StorageDead(_14); + StorageDead(_13); + StorageLive(_17); + StorageLive(_18); + StorageLive(_19); +- _19 = _1; ++ _19 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; + StorageLive(_20); +- _20 = _3; +- _18 = Le(move _19, move _20); ++ _20 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; ++ _18 = const true; + StorageDead(_20); + StorageDead(_19); +- _17 = opaque::<bool>(move _18) -> [return: bb4, unwind continue]; ++ _17 = opaque::<bool>(const true) -> [return: bb4, unwind continue]; + } + + bb4: { + StorageDead(_18); + StorageDead(_17); + StorageLive(_21); + StorageLive(_22); + StorageLive(_23); +- _23 = _1; ++ _23 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; + StorageLive(_24); +- _24 = _3; +- _22 = Gt(move _23, move _24); ++ _24 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; ++ _22 = const false; + StorageDead(_24); + StorageDead(_23); +- _21 = opaque::<bool>(move _22) -> [return: bb5, unwind continue]; ++ _21 = opaque::<bool>(const false) -> [return: bb5, unwind continue]; + } + + bb5: { + StorageDead(_22); + StorageDead(_21); + StorageLive(_25); + StorageLive(_26); + StorageLive(_27); +- _27 = _1; ++ _27 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; + StorageLive(_28); +- _28 = _3; +- _26 = Ge(move _27, move _28); ++ _28 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; ++ _26 = const false; + StorageDead(_28); + StorageDead(_27); +- _25 = opaque::<bool>(move _26) -> [return: bb6, unwind continue]; ++ _25 = opaque::<bool>(const false) -> [return: bb6, unwind continue]; + } + + bb6: { + StorageDead(_26); + StorageDead(_25); + _0 = const (); +- StorageDead(_3); +- StorageDead(_1); ++ nop; ++ nop; + return; + } ++ } ++ ++ ALLOC1 (size: 16, align: 8) { ++ 01 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 │ ................ ++ } ++ ++ ALLOC0 (size: 16, align: 8) { ++ 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 │ ................ + } + diff --git a/tests/mir-opt/gvn.wide_ptr_ops.GVN.panic-abort.diff b/tests/mir-opt/gvn.wide_ptr_ops.GVN.panic-abort.diff deleted file mode 100644 index e49d759b8fc..00000000000 --- a/tests/mir-opt/gvn.wide_ptr_ops.GVN.panic-abort.diff +++ /dev/null @@ -1,386 +0,0 @@ -- // MIR for `wide_ptr_ops` before GVN -+ // MIR for `wide_ptr_ops` after GVN - - fn wide_ptr_ops() -> () { - let mut _0: (); - let _1: *const dyn std::marker::Send; - let mut _2: *const dyn std::marker::Send; - let _3: &dyn std::marker::Send; - let mut _4: &i32; - let _5: &i32; - let _6: i32; - let mut _8: *const dyn std::marker::Send; - let _9: &dyn std::marker::Send; - let mut _10: &i32; - let _11: &i32; - let _12: i32; - let mut _14: *const dyn std::marker::Send; - let mut _15: *const dyn std::marker::Send; - let mut _16: *const dyn std::marker::Send; - let mut _18: *const dyn std::marker::Send; - let mut _19: *const dyn std::marker::Send; - let mut _20: *const dyn std::marker::Send; - let mut _22: *const dyn std::marker::Send; - let mut _23: *const dyn std::marker::Send; - let mut _24: *const dyn std::marker::Send; - let mut _26: *const dyn std::marker::Send; - let mut _27: *const dyn std::marker::Send; - let mut _28: *const dyn std::marker::Send; - let mut _30: *const dyn std::marker::Send; - let mut _31: *const dyn std::marker::Send; - let mut _32: *const dyn std::marker::Send; - let mut _34: *const dyn std::marker::Send; - let mut _35: *const dyn std::marker::Send; - let mut _36: *const dyn std::marker::Send; - let mut _38: (usize, usize); - let mut _40: (usize, usize); - let _41: (); - let mut _42: bool; - let mut _43: bool; - let mut _44: *const [u8]; - let mut _45: *const [u8]; - let _46: (); - let mut _47: bool; - let mut _48: *const [u8]; - let mut _49: *const [u8]; - let _50: (); - let mut _51: bool; - let mut _52: *const [u8]; - let mut _53: *const [u8]; - let _54: (); - let mut _55: bool; - let mut _56: *const [u8]; - let mut _57: *const [u8]; - let _58: (); - let mut _59: bool; - let mut _60: bool; - let mut _61: *const [u8]; - let mut _62: *const [u8]; - let _63: (); - let mut _64: bool; - let mut _65: bool; - let mut _66: *const [u8]; - let mut _67: *const [u8]; - let mut _69: &i32; - scope 1 { - debug a => _1; - let _7: *const dyn std::marker::Send; - let mut _68: &i32; - scope 2 { - debug b => _7; - let _13: bool; - scope 3 { - debug _val => _13; - let _17: bool; - scope 4 { - debug _val => _17; - let _21: bool; - scope 5 { - debug _val => _21; - let _25: bool; - scope 6 { - debug _val => _25; - let _29: bool; - scope 7 { - debug _val => _29; - let _33: bool; - scope 8 { - debug _val => _33; - let _37: *const [u8]; - scope 9 { - debug a => _37; - let _39: *const [u8]; - scope 11 { - debug b => _39; - } - scope 12 { - } - } - scope 10 { - } - } - } - } - } - } - } - } - } - - bb0: { -- StorageLive(_1); -+ nop; - StorageLive(_2); - StorageLive(_3); - StorageLive(_4); - StorageLive(_5); - _69 = const _; - _5 = &(*_69); - _4 = &(*_5); - _3 = move _4 as &dyn std::marker::Send (PointerCoercion(Unsize)); - StorageDead(_4); - _2 = &raw const (*_3); - _1 = move _2 as *const dyn std::marker::Send (PointerCoercion(Unsize)); - StorageDead(_2); - StorageDead(_5); - StorageDead(_3); -- StorageLive(_7); -+ nop; - StorageLive(_8); - StorageLive(_9); - StorageLive(_10); - StorageLive(_11); - _68 = const _; - _11 = &(*_68); - _10 = &(*_11); - _9 = move _10 as &dyn std::marker::Send (PointerCoercion(Unsize)); - StorageDead(_10); - _8 = &raw const (*_9); - _7 = move _8 as *const dyn std::marker::Send (PointerCoercion(Unsize)); - StorageDead(_8); - StorageDead(_11); - StorageDead(_9); - StorageLive(_13); - StorageLive(_14); - _14 = _1; -- StorageLive(_15); -+ nop; - StorageLive(_16); - _16 = _7; -- _15 = move _16 as *const dyn std::marker::Send (PointerCoercion(Unsize)); -+ _15 = _7 as *const dyn std::marker::Send (PointerCoercion(Unsize)); - StorageDead(_16); -- _13 = Eq(move _14, move _15); -- StorageDead(_15); -+ _13 = Eq(_1, _15); -+ nop; - StorageDead(_14); - StorageLive(_17); - StorageLive(_18); - _18 = _1; - StorageLive(_19); - StorageLive(_20); - _20 = _7; -- _19 = move _20 as *const dyn std::marker::Send (PointerCoercion(Unsize)); -+ _19 = _15; - StorageDead(_20); -- _17 = Ne(move _18, move _19); -+ _17 = Ne(_1, _15); - StorageDead(_19); - StorageDead(_18); - StorageLive(_21); - StorageLive(_22); - _22 = _1; - StorageLive(_23); - StorageLive(_24); - _24 = _7; -- _23 = move _24 as *const dyn std::marker::Send (PointerCoercion(Unsize)); -+ _23 = _15; - StorageDead(_24); -- _21 = Lt(move _22, move _23); -+ _21 = Lt(_1, _15); - StorageDead(_23); - StorageDead(_22); - StorageLive(_25); - StorageLive(_26); - _26 = _1; - StorageLive(_27); - StorageLive(_28); - _28 = _7; -- _27 = move _28 as *const dyn std::marker::Send (PointerCoercion(Unsize)); -+ _27 = _15; - StorageDead(_28); -- _25 = Le(move _26, move _27); -+ _25 = Le(_1, _15); - StorageDead(_27); - StorageDead(_26); - StorageLive(_29); - StorageLive(_30); - _30 = _1; - StorageLive(_31); - StorageLive(_32); - _32 = _7; -- _31 = move _32 as *const dyn std::marker::Send (PointerCoercion(Unsize)); -+ _31 = _15; - StorageDead(_32); -- _29 = Gt(move _30, move _31); -+ _29 = Gt(_1, _15); - StorageDead(_31); - StorageDead(_30); - StorageLive(_33); - StorageLive(_34); - _34 = _1; - StorageLive(_35); - StorageLive(_36); - _36 = _7; -- _35 = move _36 as *const dyn std::marker::Send (PointerCoercion(Unsize)); -+ _35 = _15; - StorageDead(_36); -- _33 = Ge(move _34, move _35); -+ _33 = Ge(_1, _15); - StorageDead(_35); - StorageDead(_34); -- StorageLive(_37); -+ nop; - StorageLive(_38); -- _38 = (const 1_usize, const 1_usize); -- _37 = move _38 as *const [u8] (Transmute); -+ _38 = const (1_usize, 1_usize); -+ _37 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; - StorageDead(_38); -- StorageLive(_39); -+ nop; - StorageLive(_40); -- _40 = (const 1_usize, const 2_usize); -- _39 = move _40 as *const [u8] (Transmute); -+ _40 = const (1_usize, 2_usize); -+ _39 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; - StorageDead(_40); - StorageLive(_41); -- StorageLive(_42); -+ nop; - StorageLive(_43); - StorageLive(_44); -- _44 = _37; -+ _44 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; - StorageLive(_45); -- _45 = _39; -- _43 = Eq(move _44, move _45); -+ _45 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; -+ _43 = Eq(const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8], const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]); - StorageDead(_45); - StorageDead(_44); - _42 = Not(move _43); - StorageDead(_43); -- _41 = opaque::<bool>(move _42) -> [return: bb1, unwind unreachable]; -+ _41 = opaque::<bool>(_42) -> [return: bb1, unwind unreachable]; - } - - bb1: { -- StorageDead(_42); -+ nop; - StorageDead(_41); - StorageLive(_46); - StorageLive(_47); - StorageLive(_48); -- _48 = _37; -+ _48 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; - StorageLive(_49); -- _49 = _39; -- _47 = Ne(move _48, move _49); -+ _49 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; -+ _47 = _42; - StorageDead(_49); - StorageDead(_48); -- _46 = opaque::<bool>(move _47) -> [return: bb2, unwind unreachable]; -+ _46 = opaque::<bool>(_42) -> [return: bb2, unwind unreachable]; - } - - bb2: { - StorageDead(_47); - StorageDead(_46); - StorageLive(_50); - StorageLive(_51); - StorageLive(_52); -- _52 = _37; -+ _52 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; - StorageLive(_53); -- _53 = _39; -- _51 = Le(move _52, move _53); -+ _53 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; -+ _51 = Le(const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8], const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]); - StorageDead(_53); - StorageDead(_52); - _50 = opaque::<bool>(move _51) -> [return: bb3, unwind unreachable]; - } - - bb3: { - StorageDead(_51); - StorageDead(_50); - StorageLive(_54); - StorageLive(_55); - StorageLive(_56); -- _56 = _37; -+ _56 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; - StorageLive(_57); -- _57 = _39; -- _55 = Lt(move _56, move _57); -+ _57 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; -+ _55 = Lt(const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8], const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]); - StorageDead(_57); - StorageDead(_56); - _54 = opaque::<bool>(move _55) -> [return: bb4, unwind unreachable]; - } - - bb4: { - StorageDead(_55); - StorageDead(_54); - StorageLive(_58); - StorageLive(_59); - StorageLive(_60); - StorageLive(_61); -- _61 = _37; -+ _61 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; - StorageLive(_62); -- _62 = _39; -- _60 = Ge(move _61, move _62); -+ _62 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; -+ _60 = Ge(const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8], const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]); - StorageDead(_62); - StorageDead(_61); - _59 = Not(move _60); - StorageDead(_60); - _58 = opaque::<bool>(move _59) -> [return: bb5, unwind unreachable]; - } - - bb5: { - StorageDead(_59); - StorageDead(_58); - StorageLive(_63); - StorageLive(_64); - StorageLive(_65); - StorageLive(_66); -- _66 = _37; -+ _66 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; - StorageLive(_67); -- _67 = _39; -- _65 = Gt(move _66, move _67); -+ _67 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; -+ _65 = Gt(const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8], const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]); - StorageDead(_67); - StorageDead(_66); - _64 = Not(move _65); - StorageDead(_65); - _63 = opaque::<bool>(move _64) -> [return: bb6, unwind unreachable]; - } - - bb6: { - StorageDead(_64); - StorageDead(_63); - _0 = const (); -- StorageDead(_39); -- StorageDead(_37); -+ nop; -+ nop; - StorageDead(_33); - StorageDead(_29); - StorageDead(_25); - StorageDead(_21); - StorageDead(_17); - StorageDead(_13); -- StorageDead(_7); -- StorageDead(_1); -+ nop; -+ nop; - return; - } -+ } -+ -+ ALLOC1 (size: 16, align: 8) { -+ 01 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 │ ................ -+ } -+ -+ ALLOC0 (size: 16, align: 8) { -+ 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 │ ................ - } - diff --git a/tests/mir-opt/gvn.wide_ptr_ops.GVN.panic-unwind.diff b/tests/mir-opt/gvn.wide_ptr_ops.GVN.panic-unwind.diff deleted file mode 100644 index 4e5608a4425..00000000000 --- a/tests/mir-opt/gvn.wide_ptr_ops.GVN.panic-unwind.diff +++ /dev/null @@ -1,386 +0,0 @@ -- // MIR for `wide_ptr_ops` before GVN -+ // MIR for `wide_ptr_ops` after GVN - - fn wide_ptr_ops() -> () { - let mut _0: (); - let _1: *const dyn std::marker::Send; - let mut _2: *const dyn std::marker::Send; - let _3: &dyn std::marker::Send; - let mut _4: &i32; - let _5: &i32; - let _6: i32; - let mut _8: *const dyn std::marker::Send; - let _9: &dyn std::marker::Send; - let mut _10: &i32; - let _11: &i32; - let _12: i32; - let mut _14: *const dyn std::marker::Send; - let mut _15: *const dyn std::marker::Send; - let mut _16: *const dyn std::marker::Send; - let mut _18: *const dyn std::marker::Send; - let mut _19: *const dyn std::marker::Send; - let mut _20: *const dyn std::marker::Send; - let mut _22: *const dyn std::marker::Send; - let mut _23: *const dyn std::marker::Send; - let mut _24: *const dyn std::marker::Send; - let mut _26: *const dyn std::marker::Send; - let mut _27: *const dyn std::marker::Send; - let mut _28: *const dyn std::marker::Send; - let mut _30: *const dyn std::marker::Send; - let mut _31: *const dyn std::marker::Send; - let mut _32: *const dyn std::marker::Send; - let mut _34: *const dyn std::marker::Send; - let mut _35: *const dyn std::marker::Send; - let mut _36: *const dyn std::marker::Send; - let mut _38: (usize, usize); - let mut _40: (usize, usize); - let _41: (); - let mut _42: bool; - let mut _43: bool; - let mut _44: *const [u8]; - let mut _45: *const [u8]; - let _46: (); - let mut _47: bool; - let mut _48: *const [u8]; - let mut _49: *const [u8]; - let _50: (); - let mut _51: bool; - let mut _52: *const [u8]; - let mut _53: *const [u8]; - let _54: (); - let mut _55: bool; - let mut _56: *const [u8]; - let mut _57: *const [u8]; - let _58: (); - let mut _59: bool; - let mut _60: bool; - let mut _61: *const [u8]; - let mut _62: *const [u8]; - let _63: (); - let mut _64: bool; - let mut _65: bool; - let mut _66: *const [u8]; - let mut _67: *const [u8]; - let mut _69: &i32; - scope 1 { - debug a => _1; - let _7: *const dyn std::marker::Send; - let mut _68: &i32; - scope 2 { - debug b => _7; - let _13: bool; - scope 3 { - debug _val => _13; - let _17: bool; - scope 4 { - debug _val => _17; - let _21: bool; - scope 5 { - debug _val => _21; - let _25: bool; - scope 6 { - debug _val => _25; - let _29: bool; - scope 7 { - debug _val => _29; - let _33: bool; - scope 8 { - debug _val => _33; - let _37: *const [u8]; - scope 9 { - debug a => _37; - let _39: *const [u8]; - scope 11 { - debug b => _39; - } - scope 12 { - } - } - scope 10 { - } - } - } - } - } - } - } - } - } - - bb0: { -- StorageLive(_1); -+ nop; - StorageLive(_2); - StorageLive(_3); - StorageLive(_4); - StorageLive(_5); - _69 = const _; - _5 = &(*_69); - _4 = &(*_5); - _3 = move _4 as &dyn std::marker::Send (PointerCoercion(Unsize)); - StorageDead(_4); - _2 = &raw const (*_3); - _1 = move _2 as *const dyn std::marker::Send (PointerCoercion(Unsize)); - StorageDead(_2); - StorageDead(_5); - StorageDead(_3); -- StorageLive(_7); -+ nop; - StorageLive(_8); - StorageLive(_9); - StorageLive(_10); - StorageLive(_11); - _68 = const _; - _11 = &(*_68); - _10 = &(*_11); - _9 = move _10 as &dyn std::marker::Send (PointerCoercion(Unsize)); - StorageDead(_10); - _8 = &raw const (*_9); - _7 = move _8 as *const dyn std::marker::Send (PointerCoercion(Unsize)); - StorageDead(_8); - StorageDead(_11); - StorageDead(_9); - StorageLive(_13); - StorageLive(_14); - _14 = _1; -- StorageLive(_15); -+ nop; - StorageLive(_16); - _16 = _7; -- _15 = move _16 as *const dyn std::marker::Send (PointerCoercion(Unsize)); -+ _15 = _7 as *const dyn std::marker::Send (PointerCoercion(Unsize)); - StorageDead(_16); -- _13 = Eq(move _14, move _15); -- StorageDead(_15); -+ _13 = Eq(_1, _15); -+ nop; - StorageDead(_14); - StorageLive(_17); - StorageLive(_18); - _18 = _1; - StorageLive(_19); - StorageLive(_20); - _20 = _7; -- _19 = move _20 as *const dyn std::marker::Send (PointerCoercion(Unsize)); -+ _19 = _15; - StorageDead(_20); -- _17 = Ne(move _18, move _19); -+ _17 = Ne(_1, _15); - StorageDead(_19); - StorageDead(_18); - StorageLive(_21); - StorageLive(_22); - _22 = _1; - StorageLive(_23); - StorageLive(_24); - _24 = _7; -- _23 = move _24 as *const dyn std::marker::Send (PointerCoercion(Unsize)); -+ _23 = _15; - StorageDead(_24); -- _21 = Lt(move _22, move _23); -+ _21 = Lt(_1, _15); - StorageDead(_23); - StorageDead(_22); - StorageLive(_25); - StorageLive(_26); - _26 = _1; - StorageLive(_27); - StorageLive(_28); - _28 = _7; -- _27 = move _28 as *const dyn std::marker::Send (PointerCoercion(Unsize)); -+ _27 = _15; - StorageDead(_28); -- _25 = Le(move _26, move _27); -+ _25 = Le(_1, _15); - StorageDead(_27); - StorageDead(_26); - StorageLive(_29); - StorageLive(_30); - _30 = _1; - StorageLive(_31); - StorageLive(_32); - _32 = _7; -- _31 = move _32 as *const dyn std::marker::Send (PointerCoercion(Unsize)); -+ _31 = _15; - StorageDead(_32); -- _29 = Gt(move _30, move _31); -+ _29 = Gt(_1, _15); - StorageDead(_31); - StorageDead(_30); - StorageLive(_33); - StorageLive(_34); - _34 = _1; - StorageLive(_35); - StorageLive(_36); - _36 = _7; -- _35 = move _36 as *const dyn std::marker::Send (PointerCoercion(Unsize)); -+ _35 = _15; - StorageDead(_36); -- _33 = Ge(move _34, move _35); -+ _33 = Ge(_1, _15); - StorageDead(_35); - StorageDead(_34); -- StorageLive(_37); -+ nop; - StorageLive(_38); -- _38 = (const 1_usize, const 1_usize); -- _37 = move _38 as *const [u8] (Transmute); -+ _38 = const (1_usize, 1_usize); -+ _37 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; - StorageDead(_38); -- StorageLive(_39); -+ nop; - StorageLive(_40); -- _40 = (const 1_usize, const 2_usize); -- _39 = move _40 as *const [u8] (Transmute); -+ _40 = const (1_usize, 2_usize); -+ _39 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; - StorageDead(_40); - StorageLive(_41); -- StorageLive(_42); -+ nop; - StorageLive(_43); - StorageLive(_44); -- _44 = _37; -+ _44 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; - StorageLive(_45); -- _45 = _39; -- _43 = Eq(move _44, move _45); -+ _45 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; -+ _43 = Eq(const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8], const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]); - StorageDead(_45); - StorageDead(_44); - _42 = Not(move _43); - StorageDead(_43); -- _41 = opaque::<bool>(move _42) -> [return: bb1, unwind continue]; -+ _41 = opaque::<bool>(_42) -> [return: bb1, unwind continue]; - } - - bb1: { -- StorageDead(_42); -+ nop; - StorageDead(_41); - StorageLive(_46); - StorageLive(_47); - StorageLive(_48); -- _48 = _37; -+ _48 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; - StorageLive(_49); -- _49 = _39; -- _47 = Ne(move _48, move _49); -+ _49 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; -+ _47 = _42; - StorageDead(_49); - StorageDead(_48); -- _46 = opaque::<bool>(move _47) -> [return: bb2, unwind continue]; -+ _46 = opaque::<bool>(_42) -> [return: bb2, unwind continue]; - } - - bb2: { - StorageDead(_47); - StorageDead(_46); - StorageLive(_50); - StorageLive(_51); - StorageLive(_52); -- _52 = _37; -+ _52 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; - StorageLive(_53); -- _53 = _39; -- _51 = Le(move _52, move _53); -+ _53 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; -+ _51 = Le(const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8], const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]); - StorageDead(_53); - StorageDead(_52); - _50 = opaque::<bool>(move _51) -> [return: bb3, unwind continue]; - } - - bb3: { - StorageDead(_51); - StorageDead(_50); - StorageLive(_54); - StorageLive(_55); - StorageLive(_56); -- _56 = _37; -+ _56 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; - StorageLive(_57); -- _57 = _39; -- _55 = Lt(move _56, move _57); -+ _57 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; -+ _55 = Lt(const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8], const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]); - StorageDead(_57); - StorageDead(_56); - _54 = opaque::<bool>(move _55) -> [return: bb4, unwind continue]; - } - - bb4: { - StorageDead(_55); - StorageDead(_54); - StorageLive(_58); - StorageLive(_59); - StorageLive(_60); - StorageLive(_61); -- _61 = _37; -+ _61 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; - StorageLive(_62); -- _62 = _39; -- _60 = Ge(move _61, move _62); -+ _62 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; -+ _60 = Ge(const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8], const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]); - StorageDead(_62); - StorageDead(_61); - _59 = Not(move _60); - StorageDead(_60); - _58 = opaque::<bool>(move _59) -> [return: bb5, unwind continue]; - } - - bb5: { - StorageDead(_59); - StorageDead(_58); - StorageLive(_63); - StorageLive(_64); - StorageLive(_65); - StorageLive(_66); -- _66 = _37; -+ _66 = const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8]; - StorageLive(_67); -- _67 = _39; -- _65 = Gt(move _66, move _67); -+ _67 = const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]; -+ _65 = Gt(const Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [u8], const Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [u8]); - StorageDead(_67); - StorageDead(_66); - _64 = Not(move _65); - StorageDead(_65); - _63 = opaque::<bool>(move _64) -> [return: bb6, unwind continue]; - } - - bb6: { - StorageDead(_64); - StorageDead(_63); - _0 = const (); -- StorageDead(_39); -- StorageDead(_37); -+ nop; -+ nop; - StorageDead(_33); - StorageDead(_29); - StorageDead(_25); - StorageDead(_21); - StorageDead(_17); - StorageDead(_13); -- StorageDead(_7); -- StorageDead(_1); -+ nop; -+ nop; - return; - } -+ } -+ -+ ALLOC1 (size: 16, align: 8) { -+ 01 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 │ ................ -+ } -+ -+ ALLOC0 (size: 16, align: 8) { -+ 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 │ ................ - } - diff --git a/tests/mir-opt/gvn.wide_ptr_provenance.GVN.panic-abort.diff b/tests/mir-opt/gvn.wide_ptr_provenance.GVN.panic-abort.diff new file mode 100644 index 00000000000..efb3dbec6f2 --- /dev/null +++ b/tests/mir-opt/gvn.wide_ptr_provenance.GVN.panic-abort.diff @@ -0,0 +1,232 @@ +- // MIR for `wide_ptr_provenance` before GVN ++ // MIR for `wide_ptr_provenance` after GVN + + fn wide_ptr_provenance() -> () { + let mut _0: (); + let _1: *const dyn std::marker::Send; + let mut _2: *const dyn std::marker::Send; + let _3: &dyn std::marker::Send; + let mut _4: &i32; + let _5: &i32; + let _6: i32; + let mut _8: *const dyn std::marker::Send; + let _9: &dyn std::marker::Send; + let mut _10: &i32; + let _11: &i32; + let _12: i32; + let _13: (); + let mut _14: bool; + let mut _15: *const dyn std::marker::Send; + let mut _16: *const dyn std::marker::Send; + let mut _17: *const dyn std::marker::Send; + let _18: (); + let mut _19: bool; + let mut _20: *const dyn std::marker::Send; + let mut _21: *const dyn std::marker::Send; + let mut _22: *const dyn std::marker::Send; + let _23: (); + let mut _24: bool; + let mut _25: *const dyn std::marker::Send; + let mut _26: *const dyn std::marker::Send; + let mut _27: *const dyn std::marker::Send; + let _28: (); + let mut _29: bool; + let mut _30: *const dyn std::marker::Send; + let mut _31: *const dyn std::marker::Send; + let mut _32: *const dyn std::marker::Send; + let _33: (); + let mut _34: bool; + let mut _35: *const dyn std::marker::Send; + let mut _36: *const dyn std::marker::Send; + let mut _37: *const dyn std::marker::Send; + let _38: (); + let mut _39: bool; + let mut _40: *const dyn std::marker::Send; + let mut _41: *const dyn std::marker::Send; + let mut _42: *const dyn std::marker::Send; + let mut _44: &i32; + scope 1 { + debug a => _1; + let _7: *const dyn std::marker::Send; + let mut _43: &i32; + scope 2 { + debug b => _7; + } + } + + bb0: { + StorageLive(_1); +- StorageLive(_2); ++ nop; + StorageLive(_3); + StorageLive(_4); + StorageLive(_5); + _44 = const _; + _5 = &(*_44); + _4 = &(*_5); + _3 = move _4 as &dyn std::marker::Send (PointerCoercion(Unsize)); + StorageDead(_4); + _2 = &raw const (*_3); +- _1 = move _2 as *const dyn std::marker::Send (PointerCoercion(Unsize)); +- StorageDead(_2); ++ _1 = _2; ++ nop; + StorageDead(_5); + StorageDead(_3); + StorageLive(_7); +- StorageLive(_8); ++ nop; + StorageLive(_9); + StorageLive(_10); + StorageLive(_11); + _43 = const _; + _11 = &(*_43); + _10 = &(*_11); + _9 = move _10 as &dyn std::marker::Send (PointerCoercion(Unsize)); + StorageDead(_10); + _8 = &raw const (*_9); +- _7 = move _8 as *const dyn std::marker::Send (PointerCoercion(Unsize)); +- StorageDead(_8); ++ _7 = _8; ++ nop; + StorageDead(_11); + StorageDead(_9); + StorageLive(_13); + StorageLive(_14); + StorageLive(_15); +- _15 = _1; ++ _15 = _2; + StorageLive(_16); + StorageLive(_17); +- _17 = _7; +- _16 = move _17 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _17 = _8; ++ _16 = _8; + StorageDead(_17); +- _14 = Eq(move _15, move _16); ++ _14 = Eq(_2, _8); + StorageDead(_16); + StorageDead(_15); + _13 = opaque::<bool>(move _14) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_14); + StorageDead(_13); + StorageLive(_18); + StorageLive(_19); + StorageLive(_20); +- _20 = _1; ++ _20 = _2; + StorageLive(_21); + StorageLive(_22); +- _22 = _7; +- _21 = move _22 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _22 = _8; ++ _21 = _8; + StorageDead(_22); +- _19 = Ne(move _20, move _21); ++ _19 = Ne(_2, _8); + StorageDead(_21); + StorageDead(_20); + _18 = opaque::<bool>(move _19) -> [return: bb2, unwind unreachable]; + } + + bb2: { + StorageDead(_19); + StorageDead(_18); + StorageLive(_23); + StorageLive(_24); + StorageLive(_25); +- _25 = _1; ++ _25 = _2; + StorageLive(_26); + StorageLive(_27); +- _27 = _7; +- _26 = move _27 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _27 = _8; ++ _26 = _8; + StorageDead(_27); +- _24 = Lt(move _25, move _26); ++ _24 = Lt(_2, _8); + StorageDead(_26); + StorageDead(_25); + _23 = opaque::<bool>(move _24) -> [return: bb3, unwind unreachable]; + } + + bb3: { + StorageDead(_24); + StorageDead(_23); + StorageLive(_28); + StorageLive(_29); + StorageLive(_30); +- _30 = _1; ++ _30 = _2; + StorageLive(_31); + StorageLive(_32); +- _32 = _7; +- _31 = move _32 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _32 = _8; ++ _31 = _8; + StorageDead(_32); +- _29 = Le(move _30, move _31); ++ _29 = Le(_2, _8); + StorageDead(_31); + StorageDead(_30); + _28 = opaque::<bool>(move _29) -> [return: bb4, unwind unreachable]; + } + + bb4: { + StorageDead(_29); + StorageDead(_28); + StorageLive(_33); + StorageLive(_34); + StorageLive(_35); +- _35 = _1; ++ _35 = _2; + StorageLive(_36); + StorageLive(_37); +- _37 = _7; +- _36 = move _37 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _37 = _8; ++ _36 = _8; + StorageDead(_37); +- _34 = Gt(move _35, move _36); ++ _34 = Gt(_2, _8); + StorageDead(_36); + StorageDead(_35); + _33 = opaque::<bool>(move _34) -> [return: bb5, unwind unreachable]; + } + + bb5: { + StorageDead(_34); + StorageDead(_33); + StorageLive(_38); + StorageLive(_39); + StorageLive(_40); +- _40 = _1; ++ _40 = _2; + StorageLive(_41); + StorageLive(_42); +- _42 = _7; +- _41 = move _42 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _42 = _8; ++ _41 = _8; + StorageDead(_42); +- _39 = Ge(move _40, move _41); ++ _39 = Ge(_2, _8); + StorageDead(_41); + StorageDead(_40); + _38 = opaque::<bool>(move _39) -> [return: bb6, unwind unreachable]; + } + + bb6: { + StorageDead(_39); + StorageDead(_38); + _0 = const (); + StorageDead(_7); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/gvn.wide_ptr_provenance.GVN.panic-unwind.diff b/tests/mir-opt/gvn.wide_ptr_provenance.GVN.panic-unwind.diff new file mode 100644 index 00000000000..ce8415e75ea --- /dev/null +++ b/tests/mir-opt/gvn.wide_ptr_provenance.GVN.panic-unwind.diff @@ -0,0 +1,232 @@ +- // MIR for `wide_ptr_provenance` before GVN ++ // MIR for `wide_ptr_provenance` after GVN + + fn wide_ptr_provenance() -> () { + let mut _0: (); + let _1: *const dyn std::marker::Send; + let mut _2: *const dyn std::marker::Send; + let _3: &dyn std::marker::Send; + let mut _4: &i32; + let _5: &i32; + let _6: i32; + let mut _8: *const dyn std::marker::Send; + let _9: &dyn std::marker::Send; + let mut _10: &i32; + let _11: &i32; + let _12: i32; + let _13: (); + let mut _14: bool; + let mut _15: *const dyn std::marker::Send; + let mut _16: *const dyn std::marker::Send; + let mut _17: *const dyn std::marker::Send; + let _18: (); + let mut _19: bool; + let mut _20: *const dyn std::marker::Send; + let mut _21: *const dyn std::marker::Send; + let mut _22: *const dyn std::marker::Send; + let _23: (); + let mut _24: bool; + let mut _25: *const dyn std::marker::Send; + let mut _26: *const dyn std::marker::Send; + let mut _27: *const dyn std::marker::Send; + let _28: (); + let mut _29: bool; + let mut _30: *const dyn std::marker::Send; + let mut _31: *const dyn std::marker::Send; + let mut _32: *const dyn std::marker::Send; + let _33: (); + let mut _34: bool; + let mut _35: *const dyn std::marker::Send; + let mut _36: *const dyn std::marker::Send; + let mut _37: *const dyn std::marker::Send; + let _38: (); + let mut _39: bool; + let mut _40: *const dyn std::marker::Send; + let mut _41: *const dyn std::marker::Send; + let mut _42: *const dyn std::marker::Send; + let mut _44: &i32; + scope 1 { + debug a => _1; + let _7: *const dyn std::marker::Send; + let mut _43: &i32; + scope 2 { + debug b => _7; + } + } + + bb0: { + StorageLive(_1); +- StorageLive(_2); ++ nop; + StorageLive(_3); + StorageLive(_4); + StorageLive(_5); + _44 = const _; + _5 = &(*_44); + _4 = &(*_5); + _3 = move _4 as &dyn std::marker::Send (PointerCoercion(Unsize)); + StorageDead(_4); + _2 = &raw const (*_3); +- _1 = move _2 as *const dyn std::marker::Send (PointerCoercion(Unsize)); +- StorageDead(_2); ++ _1 = _2; ++ nop; + StorageDead(_5); + StorageDead(_3); + StorageLive(_7); +- StorageLive(_8); ++ nop; + StorageLive(_9); + StorageLive(_10); + StorageLive(_11); + _43 = const _; + _11 = &(*_43); + _10 = &(*_11); + _9 = move _10 as &dyn std::marker::Send (PointerCoercion(Unsize)); + StorageDead(_10); + _8 = &raw const (*_9); +- _7 = move _8 as *const dyn std::marker::Send (PointerCoercion(Unsize)); +- StorageDead(_8); ++ _7 = _8; ++ nop; + StorageDead(_11); + StorageDead(_9); + StorageLive(_13); + StorageLive(_14); + StorageLive(_15); +- _15 = _1; ++ _15 = _2; + StorageLive(_16); + StorageLive(_17); +- _17 = _7; +- _16 = move _17 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _17 = _8; ++ _16 = _8; + StorageDead(_17); +- _14 = Eq(move _15, move _16); ++ _14 = Eq(_2, _8); + StorageDead(_16); + StorageDead(_15); + _13 = opaque::<bool>(move _14) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_14); + StorageDead(_13); + StorageLive(_18); + StorageLive(_19); + StorageLive(_20); +- _20 = _1; ++ _20 = _2; + StorageLive(_21); + StorageLive(_22); +- _22 = _7; +- _21 = move _22 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _22 = _8; ++ _21 = _8; + StorageDead(_22); +- _19 = Ne(move _20, move _21); ++ _19 = Ne(_2, _8); + StorageDead(_21); + StorageDead(_20); + _18 = opaque::<bool>(move _19) -> [return: bb2, unwind continue]; + } + + bb2: { + StorageDead(_19); + StorageDead(_18); + StorageLive(_23); + StorageLive(_24); + StorageLive(_25); +- _25 = _1; ++ _25 = _2; + StorageLive(_26); + StorageLive(_27); +- _27 = _7; +- _26 = move _27 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _27 = _8; ++ _26 = _8; + StorageDead(_27); +- _24 = Lt(move _25, move _26); ++ _24 = Lt(_2, _8); + StorageDead(_26); + StorageDead(_25); + _23 = opaque::<bool>(move _24) -> [return: bb3, unwind continue]; + } + + bb3: { + StorageDead(_24); + StorageDead(_23); + StorageLive(_28); + StorageLive(_29); + StorageLive(_30); +- _30 = _1; ++ _30 = _2; + StorageLive(_31); + StorageLive(_32); +- _32 = _7; +- _31 = move _32 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _32 = _8; ++ _31 = _8; + StorageDead(_32); +- _29 = Le(move _30, move _31); ++ _29 = Le(_2, _8); + StorageDead(_31); + StorageDead(_30); + _28 = opaque::<bool>(move _29) -> [return: bb4, unwind continue]; + } + + bb4: { + StorageDead(_29); + StorageDead(_28); + StorageLive(_33); + StorageLive(_34); + StorageLive(_35); +- _35 = _1; ++ _35 = _2; + StorageLive(_36); + StorageLive(_37); +- _37 = _7; +- _36 = move _37 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _37 = _8; ++ _36 = _8; + StorageDead(_37); +- _34 = Gt(move _35, move _36); ++ _34 = Gt(_2, _8); + StorageDead(_36); + StorageDead(_35); + _33 = opaque::<bool>(move _34) -> [return: bb5, unwind continue]; + } + + bb5: { + StorageDead(_34); + StorageDead(_33); + StorageLive(_38); + StorageLive(_39); + StorageLive(_40); +- _40 = _1; ++ _40 = _2; + StorageLive(_41); + StorageLive(_42); +- _42 = _7; +- _41 = move _42 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _42 = _8; ++ _41 = _8; + StorageDead(_42); +- _39 = Ge(move _40, move _41); ++ _39 = Ge(_2, _8); + StorageDead(_41); + StorageDead(_40); + _38 = opaque::<bool>(move _39) -> [return: bb6, unwind continue]; + } + + bb6: { + StorageDead(_39); + StorageDead(_38); + _0 = const (); + StorageDead(_7); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/gvn.wide_ptr_same_provenance.GVN.panic-abort.diff b/tests/mir-opt/gvn.wide_ptr_same_provenance.GVN.panic-abort.diff new file mode 100644 index 00000000000..ef211ce3da2 --- /dev/null +++ b/tests/mir-opt/gvn.wide_ptr_same_provenance.GVN.panic-abort.diff @@ -0,0 +1,268 @@ +- // MIR for `wide_ptr_same_provenance` before GVN ++ // MIR for `wide_ptr_same_provenance` after GVN + + fn wide_ptr_same_provenance() -> () { + let mut _0: (); + let _1: &[i32; 2]; + let _2: [i32; 2]; + let mut _4: *const dyn std::marker::Send; + let _5: &dyn std::marker::Send; + let mut _6: &i32; + let _7: &i32; + let _8: usize; + let mut _9: usize; + let mut _10: bool; + let mut _12: *const dyn std::marker::Send; + let _13: &dyn std::marker::Send; + let mut _14: &i32; + let _15: &i32; + let _16: usize; + let mut _17: usize; + let mut _18: bool; + let _19: (); + let mut _20: bool; + let mut _21: *const dyn std::marker::Send; + let mut _22: *const dyn std::marker::Send; + let mut _23: *const dyn std::marker::Send; + let _24: (); + let mut _25: bool; + let mut _26: *const dyn std::marker::Send; + let mut _27: *const dyn std::marker::Send; + let mut _28: *const dyn std::marker::Send; + let _29: (); + let mut _30: bool; + let mut _31: *const dyn std::marker::Send; + let mut _32: *const dyn std::marker::Send; + let mut _33: *const dyn std::marker::Send; + let _34: (); + let mut _35: bool; + let mut _36: *const dyn std::marker::Send; + let mut _37: *const dyn std::marker::Send; + let mut _38: *const dyn std::marker::Send; + let _39: (); + let mut _40: bool; + let mut _41: *const dyn std::marker::Send; + let mut _42: *const dyn std::marker::Send; + let mut _43: *const dyn std::marker::Send; + let _44: (); + let mut _45: bool; + let mut _46: *const dyn std::marker::Send; + let mut _47: *const dyn std::marker::Send; + let mut _48: *const dyn std::marker::Send; + let mut _49: &[i32; 2]; + scope 1 { + debug slice => _1; + let _3: *const dyn std::marker::Send; + scope 2 { + debug a => _3; + let _11: *const dyn std::marker::Send; + scope 3 { + debug b => _11; + } + } + } + + bb0: { + StorageLive(_1); + _49 = const _; + _1 = &(*_49); + StorageLive(_3); +- StorageLive(_4); ++ nop; + StorageLive(_5); + StorageLive(_6); + StorageLive(_7); + StorageLive(_8); + _8 = const 0_usize; +- _9 = Len((*_1)); +- _10 = Lt(_8, _9); +- assert(move _10, "index out of bounds: the length is {} but the index is {}", move _9, _8) -> [success: bb1, unwind unreachable]; ++ _9 = const 2_usize; ++ _10 = const true; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 2_usize, const 0_usize) -> [success: bb1, unwind unreachable]; + } + + bb1: { +- _7 = &(*_1)[_8]; ++ _7 = &(*_1)[0 of 1]; + _6 = &(*_7); + _5 = move _6 as &dyn std::marker::Send (PointerCoercion(Unsize)); + StorageDead(_6); + _4 = &raw const (*_5); +- _3 = move _4 as *const dyn std::marker::Send (PointerCoercion(Unsize)); +- StorageDead(_4); ++ _3 = _4; ++ nop; + StorageDead(_7); + StorageDead(_5); + StorageLive(_11); +- StorageLive(_12); ++ nop; + StorageLive(_13); + StorageLive(_14); + StorageLive(_15); + StorageLive(_16); + _16 = const 1_usize; +- _17 = Len((*_1)); +- _18 = Lt(_16, _17); +- assert(move _18, "index out of bounds: the length is {} but the index is {}", move _17, _16) -> [success: bb2, unwind unreachable]; ++ _17 = const 2_usize; ++ _18 = const true; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 2_usize, const 1_usize) -> [success: bb2, unwind unreachable]; + } + + bb2: { +- _15 = &(*_1)[_16]; ++ _15 = &(*_1)[1 of 2]; + _14 = &(*_15); + _13 = move _14 as &dyn std::marker::Send (PointerCoercion(Unsize)); + StorageDead(_14); + _12 = &raw const (*_13); +- _11 = move _12 as *const dyn std::marker::Send (PointerCoercion(Unsize)); +- StorageDead(_12); ++ _11 = _12; ++ nop; + StorageDead(_15); + StorageDead(_13); + StorageLive(_19); + StorageLive(_20); + StorageLive(_21); +- _21 = _3; ++ _21 = _4; + StorageLive(_22); + StorageLive(_23); +- _23 = _11; +- _22 = move _23 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _23 = _12; ++ _22 = _12; + StorageDead(_23); +- _20 = Eq(move _21, move _22); ++ _20 = Eq(_4, _12); + StorageDead(_22); + StorageDead(_21); + _19 = opaque::<bool>(move _20) -> [return: bb3, unwind unreachable]; + } + + bb3: { + StorageDead(_20); + StorageDead(_19); + StorageLive(_24); + StorageLive(_25); + StorageLive(_26); +- _26 = _3; ++ _26 = _4; + StorageLive(_27); + StorageLive(_28); +- _28 = _11; +- _27 = move _28 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _28 = _12; ++ _27 = _12; + StorageDead(_28); +- _25 = Ne(move _26, move _27); ++ _25 = Ne(_4, _12); + StorageDead(_27); + StorageDead(_26); + _24 = opaque::<bool>(move _25) -> [return: bb4, unwind unreachable]; + } + + bb4: { + StorageDead(_25); + StorageDead(_24); + StorageLive(_29); + StorageLive(_30); + StorageLive(_31); +- _31 = _3; ++ _31 = _4; + StorageLive(_32); + StorageLive(_33); +- _33 = _11; +- _32 = move _33 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _33 = _12; ++ _32 = _12; + StorageDead(_33); +- _30 = Lt(move _31, move _32); ++ _30 = Lt(_4, _12); + StorageDead(_32); + StorageDead(_31); + _29 = opaque::<bool>(move _30) -> [return: bb5, unwind unreachable]; + } + + bb5: { + StorageDead(_30); + StorageDead(_29); + StorageLive(_34); + StorageLive(_35); + StorageLive(_36); +- _36 = _3; ++ _36 = _4; + StorageLive(_37); + StorageLive(_38); +- _38 = _11; +- _37 = move _38 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _38 = _12; ++ _37 = _12; + StorageDead(_38); +- _35 = Le(move _36, move _37); ++ _35 = Le(_4, _12); + StorageDead(_37); + StorageDead(_36); + _34 = opaque::<bool>(move _35) -> [return: bb6, unwind unreachable]; + } + + bb6: { + StorageDead(_35); + StorageDead(_34); + StorageLive(_39); + StorageLive(_40); + StorageLive(_41); +- _41 = _3; ++ _41 = _4; + StorageLive(_42); + StorageLive(_43); +- _43 = _11; +- _42 = move _43 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _43 = _12; ++ _42 = _12; + StorageDead(_43); +- _40 = Gt(move _41, move _42); ++ _40 = Gt(_4, _12); + StorageDead(_42); + StorageDead(_41); + _39 = opaque::<bool>(move _40) -> [return: bb7, unwind unreachable]; + } + + bb7: { + StorageDead(_40); + StorageDead(_39); + StorageLive(_44); + StorageLive(_45); + StorageLive(_46); +- _46 = _3; ++ _46 = _4; + StorageLive(_47); + StorageLive(_48); +- _48 = _11; +- _47 = move _48 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _48 = _12; ++ _47 = _12; + StorageDead(_48); +- _45 = Ge(move _46, move _47); ++ _45 = Ge(_4, _12); + StorageDead(_47); + StorageDead(_46); + _44 = opaque::<bool>(move _45) -> [return: bb8, unwind unreachable]; + } + + bb8: { + StorageDead(_45); + StorageDead(_44); + _0 = const (); + StorageDead(_16); + StorageDead(_11); + StorageDead(_8); + StorageDead(_3); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/gvn.wide_ptr_same_provenance.GVN.panic-unwind.diff b/tests/mir-opt/gvn.wide_ptr_same_provenance.GVN.panic-unwind.diff new file mode 100644 index 00000000000..31f7371ac33 --- /dev/null +++ b/tests/mir-opt/gvn.wide_ptr_same_provenance.GVN.panic-unwind.diff @@ -0,0 +1,268 @@ +- // MIR for `wide_ptr_same_provenance` before GVN ++ // MIR for `wide_ptr_same_provenance` after GVN + + fn wide_ptr_same_provenance() -> () { + let mut _0: (); + let _1: &[i32; 2]; + let _2: [i32; 2]; + let mut _4: *const dyn std::marker::Send; + let _5: &dyn std::marker::Send; + let mut _6: &i32; + let _7: &i32; + let _8: usize; + let mut _9: usize; + let mut _10: bool; + let mut _12: *const dyn std::marker::Send; + let _13: &dyn std::marker::Send; + let mut _14: &i32; + let _15: &i32; + let _16: usize; + let mut _17: usize; + let mut _18: bool; + let _19: (); + let mut _20: bool; + let mut _21: *const dyn std::marker::Send; + let mut _22: *const dyn std::marker::Send; + let mut _23: *const dyn std::marker::Send; + let _24: (); + let mut _25: bool; + let mut _26: *const dyn std::marker::Send; + let mut _27: *const dyn std::marker::Send; + let mut _28: *const dyn std::marker::Send; + let _29: (); + let mut _30: bool; + let mut _31: *const dyn std::marker::Send; + let mut _32: *const dyn std::marker::Send; + let mut _33: *const dyn std::marker::Send; + let _34: (); + let mut _35: bool; + let mut _36: *const dyn std::marker::Send; + let mut _37: *const dyn std::marker::Send; + let mut _38: *const dyn std::marker::Send; + let _39: (); + let mut _40: bool; + let mut _41: *const dyn std::marker::Send; + let mut _42: *const dyn std::marker::Send; + let mut _43: *const dyn std::marker::Send; + let _44: (); + let mut _45: bool; + let mut _46: *const dyn std::marker::Send; + let mut _47: *const dyn std::marker::Send; + let mut _48: *const dyn std::marker::Send; + let mut _49: &[i32; 2]; + scope 1 { + debug slice => _1; + let _3: *const dyn std::marker::Send; + scope 2 { + debug a => _3; + let _11: *const dyn std::marker::Send; + scope 3 { + debug b => _11; + } + } + } + + bb0: { + StorageLive(_1); + _49 = const _; + _1 = &(*_49); + StorageLive(_3); +- StorageLive(_4); ++ nop; + StorageLive(_5); + StorageLive(_6); + StorageLive(_7); + StorageLive(_8); + _8 = const 0_usize; +- _9 = Len((*_1)); +- _10 = Lt(_8, _9); +- assert(move _10, "index out of bounds: the length is {} but the index is {}", move _9, _8) -> [success: bb1, unwind continue]; ++ _9 = const 2_usize; ++ _10 = const true; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 2_usize, const 0_usize) -> [success: bb1, unwind continue]; + } + + bb1: { +- _7 = &(*_1)[_8]; ++ _7 = &(*_1)[0 of 1]; + _6 = &(*_7); + _5 = move _6 as &dyn std::marker::Send (PointerCoercion(Unsize)); + StorageDead(_6); + _4 = &raw const (*_5); +- _3 = move _4 as *const dyn std::marker::Send (PointerCoercion(Unsize)); +- StorageDead(_4); ++ _3 = _4; ++ nop; + StorageDead(_7); + StorageDead(_5); + StorageLive(_11); +- StorageLive(_12); ++ nop; + StorageLive(_13); + StorageLive(_14); + StorageLive(_15); + StorageLive(_16); + _16 = const 1_usize; +- _17 = Len((*_1)); +- _18 = Lt(_16, _17); +- assert(move _18, "index out of bounds: the length is {} but the index is {}", move _17, _16) -> [success: bb2, unwind continue]; ++ _17 = const 2_usize; ++ _18 = const true; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 2_usize, const 1_usize) -> [success: bb2, unwind continue]; + } + + bb2: { +- _15 = &(*_1)[_16]; ++ _15 = &(*_1)[1 of 2]; + _14 = &(*_15); + _13 = move _14 as &dyn std::marker::Send (PointerCoercion(Unsize)); + StorageDead(_14); + _12 = &raw const (*_13); +- _11 = move _12 as *const dyn std::marker::Send (PointerCoercion(Unsize)); +- StorageDead(_12); ++ _11 = _12; ++ nop; + StorageDead(_15); + StorageDead(_13); + StorageLive(_19); + StorageLive(_20); + StorageLive(_21); +- _21 = _3; ++ _21 = _4; + StorageLive(_22); + StorageLive(_23); +- _23 = _11; +- _22 = move _23 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _23 = _12; ++ _22 = _12; + StorageDead(_23); +- _20 = Eq(move _21, move _22); ++ _20 = Eq(_4, _12); + StorageDead(_22); + StorageDead(_21); + _19 = opaque::<bool>(move _20) -> [return: bb3, unwind continue]; + } + + bb3: { + StorageDead(_20); + StorageDead(_19); + StorageLive(_24); + StorageLive(_25); + StorageLive(_26); +- _26 = _3; ++ _26 = _4; + StorageLive(_27); + StorageLive(_28); +- _28 = _11; +- _27 = move _28 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _28 = _12; ++ _27 = _12; + StorageDead(_28); +- _25 = Ne(move _26, move _27); ++ _25 = Ne(_4, _12); + StorageDead(_27); + StorageDead(_26); + _24 = opaque::<bool>(move _25) -> [return: bb4, unwind continue]; + } + + bb4: { + StorageDead(_25); + StorageDead(_24); + StorageLive(_29); + StorageLive(_30); + StorageLive(_31); +- _31 = _3; ++ _31 = _4; + StorageLive(_32); + StorageLive(_33); +- _33 = _11; +- _32 = move _33 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _33 = _12; ++ _32 = _12; + StorageDead(_33); +- _30 = Lt(move _31, move _32); ++ _30 = Lt(_4, _12); + StorageDead(_32); + StorageDead(_31); + _29 = opaque::<bool>(move _30) -> [return: bb5, unwind continue]; + } + + bb5: { + StorageDead(_30); + StorageDead(_29); + StorageLive(_34); + StorageLive(_35); + StorageLive(_36); +- _36 = _3; ++ _36 = _4; + StorageLive(_37); + StorageLive(_38); +- _38 = _11; +- _37 = move _38 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _38 = _12; ++ _37 = _12; + StorageDead(_38); +- _35 = Le(move _36, move _37); ++ _35 = Le(_4, _12); + StorageDead(_37); + StorageDead(_36); + _34 = opaque::<bool>(move _35) -> [return: bb6, unwind continue]; + } + + bb6: { + StorageDead(_35); + StorageDead(_34); + StorageLive(_39); + StorageLive(_40); + StorageLive(_41); +- _41 = _3; ++ _41 = _4; + StorageLive(_42); + StorageLive(_43); +- _43 = _11; +- _42 = move _43 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _43 = _12; ++ _42 = _12; + StorageDead(_43); +- _40 = Gt(move _41, move _42); ++ _40 = Gt(_4, _12); + StorageDead(_42); + StorageDead(_41); + _39 = opaque::<bool>(move _40) -> [return: bb7, unwind continue]; + } + + bb7: { + StorageDead(_40); + StorageDead(_39); + StorageLive(_44); + StorageLive(_45); + StorageLive(_46); +- _46 = _3; ++ _46 = _4; + StorageLive(_47); + StorageLive(_48); +- _48 = _11; +- _47 = move _48 as *const dyn std::marker::Send (PointerCoercion(Unsize)); ++ _48 = _12; ++ _47 = _12; + StorageDead(_48); +- _45 = Ge(move _46, move _47); ++ _45 = Ge(_4, _12); + StorageDead(_47); + StorageDead(_46); + _44 = opaque::<bool>(move _45) -> [return: bb8, unwind continue]; + } + + bb8: { + StorageDead(_45); + StorageDead(_44); + _0 = const (); + StorageDead(_16); + StorageDead(_11); + StorageDead(_8); + StorageDead(_3); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-abort.diff b/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-abort.diff index 62710ba8fbf..a5c29c191ad 100644 --- a/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-abort.diff @@ -21,18 +21,18 @@ + _2 = Option::<T>::Some(_1); StorageDead(_3); - _4 = discriminant(_2); -- switchInt(move _4) -> [0: bb1, 1: bb3, otherwise: bb2]; +- switchInt(move _4) -> [0: bb2, 1: bb3, otherwise: bb1]; + _4 = const 1_isize; -+ switchInt(const 1_isize) -> [0: bb1, 1: bb3, otherwise: bb2]; ++ switchInt(const 1_isize) -> [0: bb2, 1: bb3, otherwise: bb1]; } bb1: { - StorageLive(_6); - _6 = begin_panic::<&str>(const "explicit panic") -> unwind unreachable; + unreachable; } bb2: { - unreachable; + StorageLive(_6); + _6 = begin_panic::<&str>(const "explicit panic") -> unwind unreachable; } bb3: { diff --git a/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-unwind.diff b/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-unwind.diff index ad46a065b1e..6f2e5248271 100644 --- a/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-unwind.diff @@ -21,18 +21,18 @@ + _2 = Option::<T>::Some(_1); StorageDead(_3); - _4 = discriminant(_2); -- switchInt(move _4) -> [0: bb1, 1: bb3, otherwise: bb2]; +- switchInt(move _4) -> [0: bb2, 1: bb3, otherwise: bb1]; + _4 = const 1_isize; -+ switchInt(const 1_isize) -> [0: bb1, 1: bb3, otherwise: bb2]; ++ switchInt(const 1_isize) -> [0: bb2, 1: bb3, otherwise: bb1]; } bb1: { - StorageLive(_6); - _6 = begin_panic::<&str>(const "explicit panic") -> unwind continue; + unreachable; } bb2: { - unreachable; + StorageLive(_6); + _6 = begin_panic::<&str>(const "explicit panic") -> unwind continue; } bb3: { diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff index 9358a64b4fa..52688c2e867 100644 --- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-abort.diff @@ -28,18 +28,18 @@ + StorageLive(_3); + StorageLive(_5); + _3 = discriminant(_2); -+ switchInt(move _3) -> [0: bb1, 1: bb3, otherwise: bb2]; ++ switchInt(move _3) -> [0: bb2, 1: bb3, otherwise: bb1]; } bb1: { -+ StorageLive(_4); -+ _4 = cfg!(debug_assertions); -+ assume(_4); -+ _5 = unreachable_unchecked::precondition_check() -> [return: bb2, unwind unreachable]; ++ unreachable; + } + + bb2: { -+ unreachable; ++ StorageLive(_4); ++ _4 = cfg!(debug_assertions); ++ assume(_4); ++ _5 = unreachable_unchecked::precondition_check() -> [return: bb1, unwind unreachable]; + } + + bb3: { diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff index ac33c126155..fd83f1cb331 100644 --- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.Inline.panic-unwind.diff @@ -28,22 +28,22 @@ + StorageLive(_3); + StorageLive(_5); + _3 = discriminant(_2); -+ switchInt(move _3) -> [0: bb1, 1: bb3, otherwise: bb2]; ++ switchInt(move _3) -> [0: bb2, 1: bb3, otherwise: bb1]; } bb1: { - StorageDead(_2); - return; -+ StorageLive(_4); -+ _4 = cfg!(debug_assertions); -+ assume(_4); -+ _5 = unreachable_unchecked::precondition_check() -> [return: bb2, unwind unreachable]; ++ unreachable; } - bb2 (cleanup): { - resume; + bb2: { -+ unreachable; ++ StorageLive(_4); ++ _4 = cfg!(debug_assertions); ++ assume(_4); ++ _5 = unreachable_unchecked::precondition_check() -> [return: bb1, unwind unreachable]; + } + + bb3: { diff --git a/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-abort.mir b/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-abort.mir index fadfdfc87be..91dee82fde0 100644 --- a/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-abort.mir +++ b/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-abort.mir @@ -47,10 +47,14 @@ fn test() -> Option<Box<u32>> { StorageDead(_7); PlaceMention(_6); _8 = discriminant(_6); - switchInt(move _8) -> [0: bb3, 1: bb5, otherwise: bb4]; + switchInt(move _8) -> [0: bb4, 1: bb5, otherwise: bb3]; } bb3: { + unreachable; + } + + bb4: { StorageLive(_12); _12 = ((_6 as Continue).0: u32); (*_5) = _12; @@ -59,10 +63,6 @@ fn test() -> Option<Box<u32>> { drop(_5) -> [return: bb7, unwind: bb11]; } - bb4: { - unreachable; - } - bb5: { StorageLive(_9); _9 = ((_6 as Break).0: std::option::Option<std::convert::Infallible>); diff --git a/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-unwind.mir b/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-unwind.mir index 8f94165a108..ff7fc74ff61 100644 --- a/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-unwind.mir +++ b/tests/mir-opt/issue_62289.test.ElaborateDrops.before.panic-unwind.mir @@ -47,10 +47,14 @@ fn test() -> Option<Box<u32>> { StorageDead(_7); PlaceMention(_6); _8 = discriminant(_6); - switchInt(move _8) -> [0: bb3, 1: bb5, otherwise: bb4]; + switchInt(move _8) -> [0: bb4, 1: bb5, otherwise: bb3]; } bb3: { + unreachable; + } + + bb4: { StorageLive(_12); _12 = ((_6 as Continue).0: u32); (*_5) = _12; @@ -59,10 +63,6 @@ fn test() -> Option<Box<u32>> { drop(_5) -> [return: bb7, unwind: bb11]; } - bb4: { - unreachable; - } - bb5: { StorageLive(_9); _9 = ((_6 as Break).0: std::option::Option<std::convert::Infallible>); diff --git a/tests/mir-opt/issue_72181.bar.built.after.mir b/tests/mir-opt/issue_72181.bar.built.after.mir index c2e4e2072de..b6cc7d22195 100644 --- a/tests/mir-opt/issue_72181.bar.built.after.mir +++ b/tests/mir-opt/issue_72181.bar.built.after.mir @@ -14,4 +14,9 @@ fn bar(_1: [(Never, u32); 1]) -> u32 { StorageDead(_2); return; } + + bb1: { + FakeRead(ForMatchedPlace(None), _1); + unreachable; + } } diff --git a/tests/mir-opt/issue_72181.main.built.after.mir b/tests/mir-opt/issue_72181.main.built.after.mir index 4e4071536b1..12c4a2b6325 100644 --- a/tests/mir-opt/issue_72181.main.built.after.mir +++ b/tests/mir-opt/issue_72181.main.built.after.mir @@ -22,7 +22,7 @@ fn main() -> () { bb0: { StorageLive(_1); - _1 = std::mem::size_of::<Foo>() -> [return: bb1, unwind: bb3]; + _1 = std::mem::size_of::<Foo>() -> [return: bb1, unwind: bb5]; } bb1: { @@ -42,10 +42,15 @@ fn main() -> () { _6 = const 0_usize; _7 = Len(_2); _8 = Lt(_6, _7); - assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb2, unwind: bb3]; + assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb3, unwind: bb5]; } bb2: { + FakeRead(ForMatchedPlace(None), _1); + unreachable; + } + + bb3: { _5 = (_2[_6].0: u64); PlaceMention(_5); StorageDead(_6); @@ -55,7 +60,12 @@ fn main() -> () { return; } - bb3 (cleanup): { + bb4: { + FakeRead(ForMatchedPlace(None), _5); + unreachable; + } + + bb5 (cleanup): { resume; } } diff --git a/tests/mir-opt/issue_72181_1.f.built.after.mir b/tests/mir-opt/issue_72181_1.f.built.after.mir index 89da9a80113..674a4013fe7 100644 --- a/tests/mir-opt/issue_72181_1.f.built.after.mir +++ b/tests/mir-opt/issue_72181_1.f.built.after.mir @@ -6,11 +6,15 @@ fn f(_1: Void) -> ! { bb0: { PlaceMention(_1); + goto -> bb1; + } + + bb1: { FakeRead(ForMatchedPlace(None), _1); unreachable; } - bb1: { + bb2: { return; } } diff --git a/tests/mir-opt/issue_91633.bar.built.after.mir b/tests/mir-opt/issue_91633.bar.built.after.mir index cce1a1fd2ef..53829588a1b 100644 --- a/tests/mir-opt/issue_91633.bar.built.after.mir +++ b/tests/mir-opt/issue_91633.bar.built.after.mir @@ -12,7 +12,7 @@ fn bar(_1: Box<[T]>) -> () { StorageLive(_2); StorageLive(_3); _3 = &(*_1); - _2 = <[T] as Index<usize>>::index(move _3, const 0_usize) -> [return: bb1, unwind: bb3]; + _2 = <[T] as Index<usize>>::index(move _3, const 0_usize) -> [return: bb1, unwind: bb4]; } bb1: { @@ -20,18 +20,23 @@ fn bar(_1: Box<[T]>) -> () { PlaceMention((*_2)); StorageDead(_2); _0 = const (); - drop(_1) -> [return: bb2, unwind: bb4]; + drop(_1) -> [return: bb3, unwind: bb5]; } bb2: { - return; + FakeRead(ForMatchedPlace(None), (*_2)); + unreachable; } - bb3 (cleanup): { - drop(_1) -> [return: bb4, unwind terminate(cleanup)]; + bb3: { + return; } bb4 (cleanup): { + drop(_1) -> [return: bb5, unwind terminate(cleanup)]; + } + + bb5 (cleanup): { resume; } } diff --git a/tests/mir-opt/issue_91633.hey.built.after.mir b/tests/mir-opt/issue_91633.hey.built.after.mir index aa8f31f8156..a537e509996 100644 --- a/tests/mir-opt/issue_91633.hey.built.after.mir +++ b/tests/mir-opt/issue_91633.hey.built.after.mir @@ -14,7 +14,7 @@ fn hey(_1: &[T]) -> () { StorageLive(_3); StorageLive(_4); _4 = &(*_1); - _3 = <[T] as Index<usize>>::index(move _4, const 0_usize) -> [return: bb1, unwind: bb2]; + _3 = <[T] as Index<usize>>::index(move _4, const 0_usize) -> [return: bb1, unwind: bb3]; } bb1: { @@ -27,7 +27,12 @@ fn hey(_1: &[T]) -> () { return; } - bb2 (cleanup): { + bb2: { + FakeRead(ForMatchedPlace(None), _2); + unreachable; + } + + bb3 (cleanup): { resume; } } diff --git a/tests/mir-opt/issue_99325.main.built.after.32bit.mir b/tests/mir-opt/issue_99325.main.built.after.32bit.mir index a10061ed941..53254f76dbc 100644 --- a/tests/mir-opt/issue_99325.main.built.after.32bit.mir +++ b/tests/mir-opt/issue_99325.main.built.after.32bit.mir @@ -67,7 +67,7 @@ fn main() -> () { StorageLive(_2); StorageLive(_3); StorageLive(_4); - _4 = function_with_bytes::<&*b"AAAA">() -> [return: bb1, unwind: bb21]; + _4 = function_with_bytes::<&*b"AAAA">() -> [return: bb1, unwind: bb23]; } bb1: { @@ -91,24 +91,29 @@ fn main() -> () { _11 = &(*_8); StorageLive(_12); _12 = &(*_9); - _10 = <&[u8] as PartialEq<&[u8; 4]>>::eq(move _11, move _12) -> [return: bb2, unwind: bb21]; + _10 = <&[u8] as PartialEq<&[u8; 4]>>::eq(move _11, move _12) -> [return: bb3, unwind: bb23]; } bb2: { - switchInt(move _10) -> [0: bb4, otherwise: bb3]; + FakeRead(ForMatchedPlace(None), _2); + unreachable; } bb3: { - StorageDead(_12); - StorageDead(_11); - goto -> bb8; + switchInt(move _10) -> [0: bb5, otherwise: bb4]; } bb4: { - goto -> bb5; + StorageDead(_12); + StorageDead(_11); + goto -> bb9; } bb5: { + goto -> bb6; + } + + bb6: { StorageDead(_12); StorageDead(_11); StorageLive(_14); @@ -127,10 +132,10 @@ fn main() -> () { _19 = &(*_20); StorageLive(_21); _21 = Option::<Arguments<'_>>::None; - _15 = core::panicking::assert_failed::<&[u8], &[u8; 4]>(move _16, move _17, move _19, move _21) -> bb21; + _15 = core::panicking::assert_failed::<&[u8], &[u8; 4]>(move _16, move _17, move _19, move _21) -> bb23; } - bb6: { + bb7: { StorageDead(_21); StorageDead(_19); StorageDead(_17); @@ -142,23 +147,23 @@ fn main() -> () { unreachable; } - bb7: { - goto -> bb9; + bb8: { + goto -> bb10; } - bb8: { + bb9: { _1 = const (); - goto -> bb9; + goto -> bb10; } - bb9: { + bb10: { StorageDead(_10); StorageDead(_9); StorageDead(_8); - goto -> bb10; + goto -> bb11; } - bb10: { + bb11: { StorageDead(_7); StorageDead(_6); StorageDead(_4); @@ -168,10 +173,10 @@ fn main() -> () { StorageLive(_23); StorageLive(_24); StorageLive(_25); - _25 = function_with_bytes::<&*b"AAAA">() -> [return: bb11, unwind: bb21]; + _25 = function_with_bytes::<&*b"AAAA">() -> [return: bb12, unwind: bb23]; } - bb11: { + bb12: { _24 = &_25; StorageLive(_26); StorageLive(_27); @@ -190,24 +195,29 @@ fn main() -> () { _31 = &(*_28); StorageLive(_32); _32 = &(*_29); - _30 = <&[u8] as PartialEq<&[u8; 4]>>::eq(move _31, move _32) -> [return: bb12, unwind: bb21]; + _30 = <&[u8] as PartialEq<&[u8; 4]>>::eq(move _31, move _32) -> [return: bb14, unwind: bb23]; } - bb12: { - switchInt(move _30) -> [0: bb14, otherwise: bb13]; + bb13: { + FakeRead(ForMatchedPlace(None), _23); + unreachable; } - bb13: { + bb14: { + switchInt(move _30) -> [0: bb16, otherwise: bb15]; + } + + bb15: { StorageDead(_32); StorageDead(_31); - goto -> bb18; + goto -> bb20; } - bb14: { - goto -> bb15; + bb16: { + goto -> bb17; } - bb15: { + bb17: { StorageDead(_32); StorageDead(_31); StorageLive(_34); @@ -226,10 +236,10 @@ fn main() -> () { _39 = &(*_40); StorageLive(_41); _41 = Option::<Arguments<'_>>::None; - _35 = core::panicking::assert_failed::<&[u8], &[u8; 4]>(move _36, move _37, move _39, move _41) -> bb21; + _35 = core::panicking::assert_failed::<&[u8], &[u8; 4]>(move _36, move _37, move _39, move _41) -> bb23; } - bb16: { + bb18: { StorageDead(_41); StorageDead(_39); StorageDead(_37); @@ -241,23 +251,23 @@ fn main() -> () { unreachable; } - bb17: { - goto -> bb19; + bb19: { + goto -> bb21; } - bb18: { + bb20: { _22 = const (); - goto -> bb19; + goto -> bb21; } - bb19: { + bb21: { StorageDead(_30); StorageDead(_29); StorageDead(_28); - goto -> bb20; + goto -> bb22; } - bb20: { + bb22: { StorageDead(_27); StorageDead(_25); StorageDead(_23); @@ -266,7 +276,7 @@ fn main() -> () { return; } - bb21 (cleanup): { + bb23 (cleanup): { resume; } } diff --git a/tests/mir-opt/issue_99325.main.built.after.64bit.mir b/tests/mir-opt/issue_99325.main.built.after.64bit.mir index a10061ed941..53254f76dbc 100644 --- a/tests/mir-opt/issue_99325.main.built.after.64bit.mir +++ b/tests/mir-opt/issue_99325.main.built.after.64bit.mir @@ -67,7 +67,7 @@ fn main() -> () { StorageLive(_2); StorageLive(_3); StorageLive(_4); - _4 = function_with_bytes::<&*b"AAAA">() -> [return: bb1, unwind: bb21]; + _4 = function_with_bytes::<&*b"AAAA">() -> [return: bb1, unwind: bb23]; } bb1: { @@ -91,24 +91,29 @@ fn main() -> () { _11 = &(*_8); StorageLive(_12); _12 = &(*_9); - _10 = <&[u8] as PartialEq<&[u8; 4]>>::eq(move _11, move _12) -> [return: bb2, unwind: bb21]; + _10 = <&[u8] as PartialEq<&[u8; 4]>>::eq(move _11, move _12) -> [return: bb3, unwind: bb23]; } bb2: { - switchInt(move _10) -> [0: bb4, otherwise: bb3]; + FakeRead(ForMatchedPlace(None), _2); + unreachable; } bb3: { - StorageDead(_12); - StorageDead(_11); - goto -> bb8; + switchInt(move _10) -> [0: bb5, otherwise: bb4]; } bb4: { - goto -> bb5; + StorageDead(_12); + StorageDead(_11); + goto -> bb9; } bb5: { + goto -> bb6; + } + + bb6: { StorageDead(_12); StorageDead(_11); StorageLive(_14); @@ -127,10 +132,10 @@ fn main() -> () { _19 = &(*_20); StorageLive(_21); _21 = Option::<Arguments<'_>>::None; - _15 = core::panicking::assert_failed::<&[u8], &[u8; 4]>(move _16, move _17, move _19, move _21) -> bb21; + _15 = core::panicking::assert_failed::<&[u8], &[u8; 4]>(move _16, move _17, move _19, move _21) -> bb23; } - bb6: { + bb7: { StorageDead(_21); StorageDead(_19); StorageDead(_17); @@ -142,23 +147,23 @@ fn main() -> () { unreachable; } - bb7: { - goto -> bb9; + bb8: { + goto -> bb10; } - bb8: { + bb9: { _1 = const (); - goto -> bb9; + goto -> bb10; } - bb9: { + bb10: { StorageDead(_10); StorageDead(_9); StorageDead(_8); - goto -> bb10; + goto -> bb11; } - bb10: { + bb11: { StorageDead(_7); StorageDead(_6); StorageDead(_4); @@ -168,10 +173,10 @@ fn main() -> () { StorageLive(_23); StorageLive(_24); StorageLive(_25); - _25 = function_with_bytes::<&*b"AAAA">() -> [return: bb11, unwind: bb21]; + _25 = function_with_bytes::<&*b"AAAA">() -> [return: bb12, unwind: bb23]; } - bb11: { + bb12: { _24 = &_25; StorageLive(_26); StorageLive(_27); @@ -190,24 +195,29 @@ fn main() -> () { _31 = &(*_28); StorageLive(_32); _32 = &(*_29); - _30 = <&[u8] as PartialEq<&[u8; 4]>>::eq(move _31, move _32) -> [return: bb12, unwind: bb21]; + _30 = <&[u8] as PartialEq<&[u8; 4]>>::eq(move _31, move _32) -> [return: bb14, unwind: bb23]; } - bb12: { - switchInt(move _30) -> [0: bb14, otherwise: bb13]; + bb13: { + FakeRead(ForMatchedPlace(None), _23); + unreachable; } - bb13: { + bb14: { + switchInt(move _30) -> [0: bb16, otherwise: bb15]; + } + + bb15: { StorageDead(_32); StorageDead(_31); - goto -> bb18; + goto -> bb20; } - bb14: { - goto -> bb15; + bb16: { + goto -> bb17; } - bb15: { + bb17: { StorageDead(_32); StorageDead(_31); StorageLive(_34); @@ -226,10 +236,10 @@ fn main() -> () { _39 = &(*_40); StorageLive(_41); _41 = Option::<Arguments<'_>>::None; - _35 = core::panicking::assert_failed::<&[u8], &[u8; 4]>(move _36, move _37, move _39, move _41) -> bb21; + _35 = core::panicking::assert_failed::<&[u8], &[u8; 4]>(move _36, move _37, move _39, move _41) -> bb23; } - bb16: { + bb18: { StorageDead(_41); StorageDead(_39); StorageDead(_37); @@ -241,23 +251,23 @@ fn main() -> () { unreachable; } - bb17: { - goto -> bb19; + bb19: { + goto -> bb21; } - bb18: { + bb20: { _22 = const (); - goto -> bb19; + goto -> bb21; } - bb19: { + bb21: { StorageDead(_30); StorageDead(_29); StorageDead(_28); - goto -> bb20; + goto -> bb22; } - bb20: { + bb22: { StorageDead(_27); StorageDead(_25); StorageDead(_23); @@ -266,7 +276,7 @@ fn main() -> () { return; } - bb21 (cleanup): { + bb23 (cleanup): { resume; } } diff --git a/tests/mir-opt/jump_threading.dfa.JumpThreading.panic-abort.diff b/tests/mir-opt/jump_threading.dfa.JumpThreading.panic-abort.diff index ad5846c97de..bbbfe90691f 100644 --- a/tests/mir-opt/jump_threading.dfa.JumpThreading.panic-abort.diff +++ b/tests/mir-opt/jump_threading.dfa.JumpThreading.panic-abort.diff @@ -24,20 +24,20 @@ bb1: { _4 = discriminant(_1); - switchInt(move _4) -> [0: bb4, 1: bb5, 2: bb6, 3: bb2, otherwise: bb3]; + switchInt(move _4) -> [0: bb4, 1: bb5, 2: bb6, 3: bb3, otherwise: bb2]; } bb2: { + unreachable; + } + + bb3: { _0 = const (); StorageDead(_2); StorageDead(_1); return; } - bb3: { - unreachable; - } - bb4: { StorageLive(_5); _5 = DFA::B; diff --git a/tests/mir-opt/jump_threading.dfa.JumpThreading.panic-unwind.diff b/tests/mir-opt/jump_threading.dfa.JumpThreading.panic-unwind.diff index ad5846c97de..bbbfe90691f 100644 --- a/tests/mir-opt/jump_threading.dfa.JumpThreading.panic-unwind.diff +++ b/tests/mir-opt/jump_threading.dfa.JumpThreading.panic-unwind.diff @@ -24,20 +24,20 @@ bb1: { _4 = discriminant(_1); - switchInt(move _4) -> [0: bb4, 1: bb5, 2: bb6, 3: bb2, otherwise: bb3]; + switchInt(move _4) -> [0: bb4, 1: bb5, 2: bb6, 3: bb3, otherwise: bb2]; } bb2: { + unreachable; + } + + bb3: { _0 = const (); StorageDead(_2); StorageDead(_1); return; } - bb3: { - unreachable; - } - bb4: { StorageLive(_5); _5 = DFA::B; 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 9cc4385f60b..d67477ab1b9 100644 --- a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff +++ b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-abort.diff @@ -56,10 +56,14 @@ StorageLive(_11); StorageLive(_12); _10 = discriminant(_4); - switchInt(move _10) -> [0: bb7, 1: bb6, otherwise: bb2]; + switchInt(move _10) -> [0: bb7, 1: bb6, otherwise: bb1]; } bb1: { + unreachable; + } + + bb2: { StorageLive(_9); _9 = ((_3 as Continue).0: i32); _2 = _9; @@ -70,10 +74,6 @@ goto -> bb4; } - bb2: { - unreachable; - } - bb3: { StorageLive(_6); _6 = ((_3 as Break).0: std::result::Result<std::convert::Infallible, i32>); @@ -103,8 +103,8 @@ StorageDead(_10); StorageDead(_4); _5 = discriminant(_3); -- switchInt(move _5) -> [0: bb1, 1: bb3, otherwise: bb2]; -+ goto -> bb1; +- switchInt(move _5) -> [0: bb2, 1: bb3, otherwise: bb1]; ++ goto -> bb2; } bb6: { 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 9cc4385f60b..d67477ab1b9 100644 --- a/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff +++ b/tests/mir-opt/jump_threading.identity.JumpThreading.panic-unwind.diff @@ -56,10 +56,14 @@ StorageLive(_11); StorageLive(_12); _10 = discriminant(_4); - switchInt(move _10) -> [0: bb7, 1: bb6, otherwise: bb2]; + switchInt(move _10) -> [0: bb7, 1: bb6, otherwise: bb1]; } bb1: { + unreachable; + } + + bb2: { StorageLive(_9); _9 = ((_3 as Continue).0: i32); _2 = _9; @@ -70,10 +74,6 @@ goto -> bb4; } - bb2: { - unreachable; - } - bb3: { StorageLive(_6); _6 = ((_3 as Break).0: std::result::Result<std::convert::Infallible, i32>); @@ -103,8 +103,8 @@ StorageDead(_10); StorageDead(_4); _5 = discriminant(_3); -- switchInt(move _5) -> [0: bb1, 1: bb3, otherwise: bb2]; -+ goto -> bb1; +- switchInt(move _5) -> [0: bb2, 1: bb3, otherwise: bb1]; ++ goto -> bb2; } bb6: { diff --git a/tests/mir-opt/jump_threading.rs b/tests/mir-opt/jump_threading.rs index a66fe8b57e7..512aebd857a 100644 --- a/tests/mir-opt/jump_threading.rs +++ b/tests/mir-opt/jump_threading.rs @@ -12,12 +12,12 @@ use std::ops::ControlFlow; fn too_complex(x: Result<i32, usize>) -> Option<i32> { // CHECK-LABEL: fn too_complex( // CHECK: bb0: { - // CHECK: switchInt(move {{_.*}}) -> [0: bb3, 1: bb1, otherwise: bb2]; + // CHECK: switchInt(move {{_.*}}) -> [0: bb3, 1: bb2, otherwise: bb1]; // CHECK: bb1: { + // CHECK: unreachable; + // CHECK: bb2: { // CHECK: [[controlflow:_.*]] = ControlFlow::<usize, i32>::Break( // CHECK: goto -> bb8; - // CHECK: bb2: { - // CHECK: unreachable; // CHECK: bb3: { // CHECK: [[controlflow]] = ControlFlow::<usize, i32>::Continue( // CHECK: goto -> bb4; @@ -50,13 +50,13 @@ fn identity(x: Result<i32, i32>) -> Result<i32, i32> { // CHECK-LABEL: fn identity( // CHECK: bb0: { // CHECK: [[x:_.*]] = _1; - // CHECK: switchInt(move {{_.*}}) -> [0: bb7, 1: bb6, otherwise: bb2]; + // CHECK: switchInt(move {{_.*}}) -> [0: bb7, 1: bb6, otherwise: bb1]; // CHECK: bb1: { + // CHECK: unreachable; + // CHECK: bb2: { // CHECK: {{_.*}} = (([[controlflow:_.*]] as Continue).0: i32); // CHECK: _0 = Result::<i32, i32>::Ok( // CHECK: goto -> bb4; - // CHECK: bb2: { - // CHECK: unreachable; // CHECK: bb3: { // CHECK: {{_.*}} = (([[controlflow]] as Break).0: std::result::Result<std::convert::Infallible, i32>); // CHECK: _0 = Result::<i32, i32>::Err( @@ -64,7 +64,7 @@ fn identity(x: Result<i32, i32>) -> Result<i32, i32> { // CHECK: bb4: { // CHECK: return; // CHECK: bb5: { - // CHECK: goto -> bb1; + // CHECK: goto -> bb2; // CHECK: bb6: { // CHECK: {{_.*}} = move (([[x]] as Err).0: i32); // CHECK: [[controlflow]] = ControlFlow::<Result<Infallible, i32>, i32>::Break( @@ -93,11 +93,11 @@ fn dfa() { // CHECK: {{_.*}} = DFA::A; // CHECK: goto -> bb1; // CHECK: bb1: { - // CHECK: switchInt({{.*}}) -> [0: bb4, 1: bb5, 2: bb6, 3: bb2, otherwise: bb3]; + // CHECK: switchInt({{.*}}) -> [0: bb4, 1: bb5, 2: bb6, 3: bb3, otherwise: bb2]; // CHECK: bb2: { - // CHECK: return; - // CHECK: bb3: { // CHECK: unreachable; + // CHECK: bb3: { + // CHECK: return; // CHECK: bb4: { // CHECK: {{_.*}} = DFA::B; // CHECK: goto -> bb1; diff --git a/tests/mir-opt/jump_threading.too_complex.JumpThreading.panic-abort.diff b/tests/mir-opt/jump_threading.too_complex.JumpThreading.panic-abort.diff index f5eade4a914..365d9d6b32b 100644 --- a/tests/mir-opt/jump_threading.too_complex.JumpThreading.panic-abort.diff +++ b/tests/mir-opt/jump_threading.too_complex.JumpThreading.panic-abort.diff @@ -30,10 +30,14 @@ bb0: { StorageLive(_2); _3 = discriminant(_1); - switchInt(move _3) -> [0: bb3, 1: bb1, otherwise: bb2]; + switchInt(move _3) -> [0: bb3, 1: bb2, otherwise: bb1]; } bb1: { + unreachable; + } + + bb2: { StorageLive(_6); _6 = ((_1 as Err).0: usize); StorageLive(_7); @@ -45,10 +49,6 @@ + goto -> bb8; } - bb2: { - unreachable; - } - bb3: { StorageLive(_4); _4 = ((_1 as Ok).0: i32); @@ -62,7 +62,7 @@ bb4: { _8 = discriminant(_2); -- switchInt(move _8) -> [0: bb6, 1: bb5, otherwise: bb2]; +- switchInt(move _8) -> [0: bb6, 1: bb5, otherwise: bb1]; + goto -> bb6; } diff --git a/tests/mir-opt/jump_threading.too_complex.JumpThreading.panic-unwind.diff b/tests/mir-opt/jump_threading.too_complex.JumpThreading.panic-unwind.diff index f5eade4a914..365d9d6b32b 100644 --- a/tests/mir-opt/jump_threading.too_complex.JumpThreading.panic-unwind.diff +++ b/tests/mir-opt/jump_threading.too_complex.JumpThreading.panic-unwind.diff @@ -30,10 +30,14 @@ bb0: { StorageLive(_2); _3 = discriminant(_1); - switchInt(move _3) -> [0: bb3, 1: bb1, otherwise: bb2]; + switchInt(move _3) -> [0: bb3, 1: bb2, otherwise: bb1]; } bb1: { + unreachable; + } + + bb2: { StorageLive(_6); _6 = ((_1 as Err).0: usize); StorageLive(_7); @@ -45,10 +49,6 @@ + goto -> bb8; } - bb2: { - unreachable; - } - bb3: { StorageLive(_4); _4 = ((_1 as Ok).0: i32); @@ -62,7 +62,7 @@ bb4: { _8 = discriminant(_2); -- switchInt(move _8) -> [0: bb6, 1: bb5, otherwise: bb2]; +- switchInt(move _8) -> [0: bb6, 1: bb5, otherwise: bb1]; + goto -> bb6; } diff --git a/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff b/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff index b4bd45ba597..307f7105dd2 100644 --- a/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff +++ b/tests/mir-opt/match_arm_scopes.complicated_match.panic-abort.SimplifyCfg-initial.after-ElaborateDrops.after.diff @@ -32,33 +32,25 @@ bb0: { PlaceMention(_2); -- switchInt((_2.0: bool)) -> [0: bb1, otherwise: bb2]; +- switchInt((_2.0: bool)) -> [0: bb6, otherwise: bb1]; + switchInt((_2.0: bool)) -> [0: bb5, otherwise: bb1]; } bb1: { -- falseEdge -> [real: bb8, imaginary: bb3]; +- switchInt((_2.1: bool)) -> [0: bb5, otherwise: bb2]; + switchInt((_2.1: bool)) -> [0: bb10, otherwise: bb2]; } bb2: { -- switchInt((_2.1: bool)) -> [0: bb3, otherwise: bb4]; +- switchInt((_2.0: bool)) -> [0: bb4, otherwise: bb3]; + switchInt((_2.0: bool)) -> [0: bb3, otherwise: bb17]; } bb3: { -- falseEdge -> [real: bb13, imaginary: bb5]; +- falseEdge -> [real: bb20, imaginary: bb4]; - } - - bb4: { -- switchInt((_2.0: bool)) -> [0: bb6, otherwise: bb5]; -- } -- -- bb5: { -- falseEdge -> [real: bb20, imaginary: bb6]; -- } -- -- bb6: { StorageLive(_15); _15 = (_2.1: bool); StorageLive(_16); @@ -67,6 +59,14 @@ + goto -> bb16; } +- bb5: { +- falseEdge -> [real: bb13, imaginary: bb3]; +- } +- +- bb6: { +- falseEdge -> [real: bb8, imaginary: bb5]; +- } +- - bb7: { + bb4: { _0 = const 1_i32; @@ -127,7 +127,7 @@ StorageDead(_9); StorageDead(_8); StorageDead(_6); -- falseEdge -> [real: bb2, imaginary: bb3]; +- falseEdge -> [real: bb1, imaginary: bb5]; + goto -> bb1; } @@ -184,7 +184,7 @@ StorageDead(_12); StorageDead(_8); StorageDead(_6); -- falseEdge -> [real: bb4, imaginary: bb5]; +- falseEdge -> [real: bb2, imaginary: bb3]; + goto -> bb2; } diff --git a/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff b/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff index b4bd45ba597..307f7105dd2 100644 --- a/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff +++ b/tests/mir-opt/match_arm_scopes.complicated_match.panic-unwind.SimplifyCfg-initial.after-ElaborateDrops.after.diff @@ -32,33 +32,25 @@ bb0: { PlaceMention(_2); -- switchInt((_2.0: bool)) -> [0: bb1, otherwise: bb2]; +- switchInt((_2.0: bool)) -> [0: bb6, otherwise: bb1]; + switchInt((_2.0: bool)) -> [0: bb5, otherwise: bb1]; } bb1: { -- falseEdge -> [real: bb8, imaginary: bb3]; +- switchInt((_2.1: bool)) -> [0: bb5, otherwise: bb2]; + switchInt((_2.1: bool)) -> [0: bb10, otherwise: bb2]; } bb2: { -- switchInt((_2.1: bool)) -> [0: bb3, otherwise: bb4]; +- switchInt((_2.0: bool)) -> [0: bb4, otherwise: bb3]; + switchInt((_2.0: bool)) -> [0: bb3, otherwise: bb17]; } bb3: { -- falseEdge -> [real: bb13, imaginary: bb5]; +- falseEdge -> [real: bb20, imaginary: bb4]; - } - - bb4: { -- switchInt((_2.0: bool)) -> [0: bb6, otherwise: bb5]; -- } -- -- bb5: { -- falseEdge -> [real: bb20, imaginary: bb6]; -- } -- -- bb6: { StorageLive(_15); _15 = (_2.1: bool); StorageLive(_16); @@ -67,6 +59,14 @@ + goto -> bb16; } +- bb5: { +- falseEdge -> [real: bb13, imaginary: bb3]; +- } +- +- bb6: { +- falseEdge -> [real: bb8, imaginary: bb5]; +- } +- - bb7: { + bb4: { _0 = const 1_i32; @@ -127,7 +127,7 @@ StorageDead(_9); StorageDead(_8); StorageDead(_6); -- falseEdge -> [real: bb2, imaginary: bb3]; +- falseEdge -> [real: bb1, imaginary: bb5]; + goto -> bb1; } @@ -184,7 +184,7 @@ StorageDead(_12); StorageDead(_8); StorageDead(_6); -- falseEdge -> [real: bb4, imaginary: bb5]; +- falseEdge -> [real: bb2, imaginary: bb3]; + goto -> bb2; } diff --git a/tests/mir-opt/match_test.main.SimplifyCfg-initial.after.mir b/tests/mir-opt/match_test.main.SimplifyCfg-initial.after.mir index 5bf78b6150f..107f56f7f69 100644 --- a/tests/mir-opt/match_test.main.SimplifyCfg-initial.after.mir +++ b/tests/mir-opt/match_test.main.SimplifyCfg-initial.after.mir @@ -32,12 +32,12 @@ fn main() -> () { } bb1: { - falseEdge -> [real: bb9, imaginary: bb4]; + _3 = const 3_i32; + goto -> bb14; } bb2: { - _3 = const 3_i32; - goto -> bb14; + falseEdge -> [real: bb9, imaginary: bb4]; } bb3: { @@ -50,11 +50,11 @@ fn main() -> () { } bb5: { - switchInt(_1) -> [4294967295: bb6, otherwise: bb2]; + switchInt(_1) -> [4294967295: bb6, otherwise: bb1]; } bb6: { - falseEdge -> [real: bb13, imaginary: bb2]; + falseEdge -> [real: bb13, imaginary: bb1]; } bb7: { @@ -64,7 +64,7 @@ fn main() -> () { bb8: { _7 = Lt(_1, const 10_i32); - switchInt(move _7) -> [0: bb3, otherwise: bb1]; + switchInt(move _7) -> [0: bb3, otherwise: bb2]; } bb9: { @@ -83,7 +83,7 @@ fn main() -> () { bb11: { StorageDead(_9); - falseEdge -> [real: bb2, imaginary: bb4]; + falseEdge -> [real: bb1, imaginary: bb4]; } bb12: { diff --git a/tests/mir-opt/matches_u8.exhaustive_match.MatchBranchSimplification.diff b/tests/mir-opt/matches_u8.exhaustive_match.MatchBranchSimplification.diff index fec58556366..157f9c98353 100644 --- a/tests/mir-opt/matches_u8.exhaustive_match.MatchBranchSimplification.diff +++ b/tests/mir-opt/matches_u8.exhaustive_match.MatchBranchSimplification.diff @@ -8,16 +8,16 @@ bb0: { _2 = discriminant(_1); - switchInt(move _2) -> [0: bb3, 1: bb1, otherwise: bb2]; + switchInt(move _2) -> [0: bb3, 1: bb2, otherwise: bb1]; } bb1: { - _0 = const 1_u8; - goto -> bb4; + unreachable; } bb2: { - unreachable; + _0 = const 1_u8; + goto -> bb4; } bb3: { diff --git a/tests/mir-opt/matches_u8.exhaustive_match_i8.MatchBranchSimplification.diff b/tests/mir-opt/matches_u8.exhaustive_match_i8.MatchBranchSimplification.diff index 94d3ce6c971..19083771fd9 100644 --- a/tests/mir-opt/matches_u8.exhaustive_match_i8.MatchBranchSimplification.diff +++ b/tests/mir-opt/matches_u8.exhaustive_match_i8.MatchBranchSimplification.diff @@ -8,16 +8,16 @@ bb0: { _2 = discriminant(_1); - switchInt(move _2) -> [0: bb3, 1: bb1, otherwise: bb2]; + switchInt(move _2) -> [0: bb3, 1: bb2, otherwise: bb1]; } bb1: { - _0 = const 1_i8; - goto -> bb4; + unreachable; } bb2: { - unreachable; + _0 = const 1_i8; + goto -> bb4; } bb3: { diff --git a/tests/mir-opt/no_drop_for_inactive_variant.unwrap.SimplifyCfg-elaborate-drops.after.panic-abort.mir b/tests/mir-opt/no_drop_for_inactive_variant.unwrap.SimplifyCfg-elaborate-drops.after.panic-abort.mir index 08695523646..31a6a1d8b3d 100644 --- a/tests/mir-opt/no_drop_for_inactive_variant.unwrap.SimplifyCfg-elaborate-drops.after.panic-abort.mir +++ b/tests/mir-opt/no_drop_for_inactive_variant.unwrap.SimplifyCfg-elaborate-drops.after.panic-abort.mir @@ -15,16 +15,16 @@ fn unwrap(_1: Option<T>) -> T { bb0: { _2 = discriminant(_1); - switchInt(move _2) -> [0: bb1, 1: bb3, otherwise: bb2]; + switchInt(move _2) -> [0: bb2, 1: bb3, otherwise: bb1]; } bb1: { - StorageLive(_4); - _4 = begin_panic::<&str>(const "explicit panic") -> unwind unreachable; + unreachable; } bb2: { - unreachable; + StorageLive(_4); + _4 = begin_panic::<&str>(const "explicit panic") -> unwind unreachable; } bb3: { diff --git a/tests/mir-opt/no_drop_for_inactive_variant.unwrap.SimplifyCfg-elaborate-drops.after.panic-unwind.mir b/tests/mir-opt/no_drop_for_inactive_variant.unwrap.SimplifyCfg-elaborate-drops.after.panic-unwind.mir index 6276d854846..53352fbb19f 100644 --- a/tests/mir-opt/no_drop_for_inactive_variant.unwrap.SimplifyCfg-elaborate-drops.after.panic-unwind.mir +++ b/tests/mir-opt/no_drop_for_inactive_variant.unwrap.SimplifyCfg-elaborate-drops.after.panic-unwind.mir @@ -15,16 +15,16 @@ fn unwrap(_1: Option<T>) -> T { bb0: { _2 = discriminant(_1); - switchInt(move _2) -> [0: bb1, 1: bb3, otherwise: bb2]; + switchInt(move _2) -> [0: bb2, 1: bb3, otherwise: bb1]; } bb1: { - StorageLive(_4); - _4 = begin_panic::<&str>(const "explicit panic") -> bb4; + unreachable; } bb2: { - unreachable; + StorageLive(_4); + _4 = begin_panic::<&str>(const "explicit panic") -> bb4; } bb3: { diff --git a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.mir index cf7feef0051..f1d0da28b4e 100644 --- a/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/checked_ops.step_forward.PreCodegen.after.mir @@ -4,66 +4,12 @@ fn step_forward(_1: u32, _2: usize) -> u32 { debug x => _1; debug n => _2; let mut _0: u32; - scope 1 (inlined <u32 as Step>::forward) { - debug start => _1; - debug n => _2; - let _3: std::option::Option<u32>; - let mut _4: &std::option::Option<u32>; - let mut _7: bool; - let mut _8: u32; - scope 2 { - } - scope 3 (inlined Option::<u32>::is_none) { - debug self => _4; - let mut _6: bool; - scope 4 (inlined Option::<u32>::is_some) { - debug self => _4; - let mut _5: isize; - } - } - scope 5 (inlined core::num::<impl u32>::wrapping_add) { - debug self => _1; - debug rhs => _8; - } - } bb0: { - StorageLive(_7); - StorageLive(_4); - StorageLive(_3); - _3 = <u32 as Step>::forward_checked(_1, _2) -> [return: bb1, unwind continue]; + _0 = <u32 as Step>::forward(move _1, move _2) -> [return: bb1, unwind continue]; } bb1: { - _4 = &_3; - StorageLive(_6); - StorageLive(_5); - _5 = discriminant(_3); - _6 = Eq(_5, const 1_isize); - StorageDead(_5); - _7 = Not(move _6); - StorageDead(_6); - switchInt(move _7) -> [0: bb2, otherwise: bb3]; - } - - bb2: { - StorageDead(_3); - StorageDead(_4); - goto -> bb4; - } - - bb3: { - StorageDead(_3); - StorageDead(_4); - assert(!const true, "attempt to compute `{} + {}`, which would overflow", const _, const 1_u32) -> [success: bb4, unwind continue]; - } - - bb4: { - StorageDead(_7); - StorageLive(_8); - _8 = _2 as u32 (IntToInt); - _0 = Add(_1, _8); - StorageDead(_8); return; } } 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 de9a1a075ad..4c71a4358e7 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 @@ -111,12 +111,16 @@ StorageDead(_15); StorageDead(_12); StorageDead(_6); - StorageLive(_18); +- StorageLive(_18); ++ nop; _18 = (_5.0: *const [u8]); - _4 = move _18 as *mut [u8] (PtrToPtr); - StorageDead(_18); +- _4 = move _18 as *mut [u8] (PtrToPtr); +- StorageDead(_18); ++ _4 = _18 as *mut [u8] (PtrToPtr); ++ nop; StorageDead(_5); - _3 = move _4 as *mut u8 (PtrToPtr); +- _3 = move _4 as *mut u8 (PtrToPtr); ++ _3 = _18 as *mut u8 (PtrToPtr); StorageDead(_4); StorageDead(_3); - StorageDead(_1); 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 f784db0f409..44de4f8e98a 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 @@ -50,12 +50,16 @@ bb1: { StorageDead(_6); - StorageLive(_12); +- StorageLive(_12); ++ nop; _12 = (_5.0: *const [u8]); - _4 = move _12 as *mut [u8] (PtrToPtr); - StorageDead(_12); +- _4 = move _12 as *mut [u8] (PtrToPtr); +- StorageDead(_12); ++ _4 = _12 as *mut [u8] (PtrToPtr); ++ nop; StorageDead(_5); - _3 = move _4 as *mut u8 (PtrToPtr); +- _3 = move _4 as *mut u8 (PtrToPtr); ++ _3 = _12 as *mut u8 (PtrToPtr); StorageDead(_4); StorageDead(_3); - StorageDead(_1); 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 162b7fa4618..e27a96a4018 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 @@ -111,12 +111,16 @@ StorageDead(_15); StorageDead(_12); StorageDead(_6); - StorageLive(_18); +- StorageLive(_18); ++ nop; _18 = (_5.0: *const [u8]); - _4 = move _18 as *mut [u8] (PtrToPtr); - StorageDead(_18); +- _4 = move _18 as *mut [u8] (PtrToPtr); +- StorageDead(_18); ++ _4 = _18 as *mut [u8] (PtrToPtr); ++ nop; StorageDead(_5); - _3 = move _4 as *mut u8 (PtrToPtr); +- _3 = move _4 as *mut u8 (PtrToPtr); ++ _3 = _18 as *mut u8 (PtrToPtr); StorageDead(_4); StorageDead(_3); - StorageDead(_1); 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 400aac6d64b..6145f92a075 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 @@ -50,12 +50,16 @@ bb1: { StorageDead(_6); - StorageLive(_12); +- StorageLive(_12); ++ nop; _12 = (_5.0: *const [u8]); - _4 = move _12 as *mut [u8] (PtrToPtr); - StorageDead(_12); +- _4 = move _12 as *mut [u8] (PtrToPtr); +- StorageDead(_12); ++ _4 = _12 as *mut [u8] (PtrToPtr); ++ nop; StorageDead(_5); - _3 = move _4 as *mut u8 (PtrToPtr); +- _3 = move _4 as *mut u8 (PtrToPtr); ++ _3 = _12 as *mut u8 (PtrToPtr); StorageDead(_4); StorageDead(_3); - StorageDead(_1); 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 e27e417ed4a..0b5ed6ee169 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 @@ -7,14 +7,13 @@ fn int_range(_1: usize, _2: usize) -> () { let mut _3: std::ops::Range<usize>; let mut _4: std::ops::Range<usize>; let mut _5: &mut std::ops::Range<usize>; - let mut _11: std::option::Option<usize>; - let mut _14: isize; - let _16: (); + let mut _13: std::option::Option<usize>; + let _15: (); scope 1 { debug iter => _4; - let _15: usize; + let _14: usize; scope 2 { - debug i => _15; + debug i => _14; } scope 4 (inlined iter::range::<impl Iterator for std::ops::Range<usize>>::next) { debug self => _5; @@ -23,10 +22,10 @@ fn int_range(_1: usize, _2: usize) -> () { let mut _6: &usize; let mut _7: &usize; let mut _10: bool; - let _12: usize; - let mut _13: usize; + let _11: usize; + let mut _12: usize; scope 6 { - debug old => _12; + debug old => _11; scope 7 { } } @@ -51,9 +50,9 @@ fn int_range(_1: usize, _2: usize) -> () { } bb1: { - StorageLive(_11); + StorageLive(_13); _5 = &mut _4; - StorageLive(_12); + StorageLive(_11); StorageLive(_10); StorageLive(_6); _6 = &(_4.0: usize); @@ -72,53 +71,33 @@ fn int_range(_1: usize, _2: usize) -> () { bb2: { StorageDead(_7); StorageDead(_6); - _11 = const Option::<usize>::None; - goto -> bb5; + StorageDead(_10); + StorageDead(_11); + StorageDead(_13); + StorageDead(_4); + return; } bb3: { StorageDead(_7); StorageDead(_6); - _12 = (_4.0: usize); - StorageLive(_13); - _13 = <usize as Step>::forward_unchecked(_12, const 1_usize) -> [return: bb4, unwind continue]; + _11 = (_4.0: usize); + StorageLive(_12); + _12 = <usize as Step>::forward_unchecked(_11, const 1_usize) -> [return: bb4, unwind continue]; } bb4: { - (_4.0: usize) = move _13; - StorageDead(_13); - _11 = Option::<usize>::Some(_12); - goto -> bb5; - } - - bb5: { - StorageDead(_10); + (_4.0: usize) = move _12; StorageDead(_12); - _14 = discriminant(_11); - switchInt(move _14) -> [0: bb6, 1: bb7, otherwise: bb9]; - } - - bb6: { + _13 = Option::<usize>::Some(_11); + StorageDead(_10); StorageDead(_11); - StorageDead(_4); - return; - } - - bb7: { - _15 = ((_11 as Some).0: usize); - _16 = opaque::<usize>(move _15) -> [return: bb8, unwind continue]; + _14 = ((_13 as Some).0: usize); + _15 = opaque::<usize>(move _14) -> [return: bb5, unwind continue]; } - bb8: { - StorageDead(_11); + bb5: { + StorageDead(_13); goto -> bb1; } - - bb9: { - unreachable; - } -} - -ALLOC0 (size: 16, align: 8) { - 00 00 00 00 00 00 00 00 __ __ __ __ __ __ __ __ │ ........░░░░░░░░ } diff --git a/tests/mir-opt/pre-codegen/matches_macro.issue_77355_opt.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/matches_macro.issue_77355_opt.PreCodegen.after.mir new file mode 100644 index 00000000000..d41135c6a4f --- /dev/null +++ b/tests/mir-opt/pre-codegen/matches_macro.issue_77355_opt.PreCodegen.after.mir @@ -0,0 +1,22 @@ +// MIR for `issue_77355_opt` after PreCodegen + +fn issue_77355_opt(_1: Foo) -> u64 { + debug num => _1; + let mut _0: u64; + let mut _2: isize; + + bb0: { + _2 = discriminant(_1); + switchInt(move _2) -> [1: bb1, 2: bb1, otherwise: bb2]; + } + + bb1: { + _0 = const 23_u64; + return; + } + + bb2: { + _0 = const 42_u64; + return; + } +} diff --git a/tests/mir-opt/pre-codegen/matches_macro.rs b/tests/mir-opt/pre-codegen/matches_macro.rs new file mode 100644 index 00000000000..42de2296571 --- /dev/null +++ b/tests/mir-opt/pre-codegen/matches_macro.rs @@ -0,0 +1,27 @@ +// This test verifies that the MIR we output using the `matches!()` macro is close +// to the MIR for an `if let` branch. + +pub enum Foo { + A, + B, + C, + D, + E, + F, +} + +// EMIT_MIR matches_macro.issue_77355_opt.PreCodegen.after.mir +fn issue_77355_opt(num: Foo) -> u64 { + // CHECK-LABEL: fn issue_77355_opt( + // CHECK: switchInt({{.*}}) -> [1: bb1, 2: bb1, otherwise: bb2]; + // CHECK: bb1: { + // CHECK-NEXT: _0 = const 23_u64; + // CHECK-NEXT: return; + // CHECK: bb2: { + // CHECK-NEXT: _0 = const 42_u64; + // CHECK-NEXT: return; + if matches!(num, Foo::B | Foo::C) { 23 } else { 42 } +} +fn main() { + issue_77355_opt(Foo::A); +} 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 99805da5669..ed965770adb 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 @@ -8,16 +8,15 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { let mut _4: std::ops::Range<u32>; let mut _5: std::ops::Range<u32>; let mut _6: &mut std::ops::Range<u32>; - let mut _12: std::option::Option<u32>; - let mut _15: isize; - let mut _17: &impl Fn(u32); - let mut _18: (u32,); - let _19: (); + let mut _14: std::option::Option<u32>; + let mut _16: &impl Fn(u32); + let mut _17: (u32,); + let _18: (); scope 1 { debug iter => _5; - let _16: u32; + let _15: u32; scope 2 { - debug x => _16; + debug x => _15; } scope 4 (inlined iter::range::<impl Iterator for std::ops::Range<u32>>::next) { debug self => _6; @@ -26,10 +25,10 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { let mut _7: &u32; let mut _8: &u32; let mut _11: bool; - let _13: u32; - let mut _14: u32; + let _12: u32; + let mut _13: u32; scope 6 { - debug old => _13; + debug old => _12; scope 7 { } } @@ -54,9 +53,9 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb1: { - StorageLive(_12); + StorageLive(_14); _6 = &mut _5; - StorageLive(_13); + StorageLive(_12); StorageLive(_11); StorageLive(_7); _7 = &(_5.0: u32); @@ -69,69 +68,49 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { _11 = Lt(move _9, move _10); StorageDead(_10); StorageDead(_9); - switchInt(move _11) -> [0: bb2, otherwise: bb3]; + switchInt(move _11) -> [0: bb2, otherwise: bb4]; } bb2: { StorageDead(_8); StorageDead(_7); - _12 = const Option::<u32>::None; - goto -> bb5; + StorageDead(_11); + StorageDead(_12); + StorageDead(_14); + StorageDead(_5); + drop(_3) -> [return: bb3, unwind unreachable]; } bb3: { - StorageDead(_8); - StorageDead(_7); - _13 = (_5.0: u32); - StorageLive(_14); - _14 = <u32 as Step>::forward_unchecked(_13, const 1_usize) -> [return: bb4, unwind unreachable]; + return; } bb4: { - (_5.0: u32) = move _14; - StorageDead(_14); - _12 = Option::<u32>::Some(_13); - goto -> bb5; + StorageDead(_8); + StorageDead(_7); + _12 = (_5.0: u32); + StorageLive(_13); + _13 = <u32 as Step>::forward_unchecked(_12, const 1_usize) -> [return: bb5, unwind unreachable]; } bb5: { - StorageDead(_11); + (_5.0: u32) = move _13; StorageDead(_13); - _15 = discriminant(_12); - switchInt(move _15) -> [0: bb6, 1: bb8, otherwise: bb10]; - } - - bb6: { + _14 = Option::<u32>::Some(_12); + StorageDead(_11); StorageDead(_12); - StorageDead(_5); - drop(_3) -> [return: bb7, unwind unreachable]; - } - - bb7: { - return; - } - - bb8: { - _16 = ((_12 as Some).0: u32); + _15 = ((_14 as Some).0: u32); + StorageLive(_16); + _16 = &_3; StorageLive(_17); - _17 = &_3; - StorageLive(_18); - _18 = (_16,); - _19 = <impl Fn(u32) as Fn<(u32,)>>::call(move _17, move _18) -> [return: bb9, unwind unreachable]; + _17 = (_15,); + _18 = <impl Fn(u32) as Fn<(u32,)>>::call(move _16, move _17) -> [return: bb6, unwind unreachable]; } - bb9: { - StorageDead(_18); + bb6: { StorageDead(_17); - StorageDead(_12); + StorageDead(_16); + StorageDead(_14); goto -> bb1; } - - bb10: { - unreachable; - } -} - -ALLOC0 (size: 8, align: 4) { - 00 00 00 00 __ __ __ __ │ ....░░░░ } 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 f40f1307175..a7ee9be19bd 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 @@ -8,16 +8,15 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { let mut _4: std::ops::Range<u32>; let mut _5: std::ops::Range<u32>; let mut _6: &mut std::ops::Range<u32>; - let mut _12: std::option::Option<u32>; - let mut _15: isize; - let mut _17: &impl Fn(u32); - let mut _18: (u32,); - let _19: (); + let mut _14: std::option::Option<u32>; + let mut _16: &impl Fn(u32); + let mut _17: (u32,); + let _18: (); scope 1 { debug iter => _5; - let _16: u32; + let _15: u32; scope 2 { - debug x => _16; + debug x => _15; } scope 4 (inlined iter::range::<impl Iterator for std::ops::Range<u32>>::next) { debug self => _6; @@ -26,10 +25,10 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { let mut _7: &u32; let mut _8: &u32; let mut _11: bool; - let _13: u32; - let mut _14: u32; + let _12: u32; + let mut _13: u32; scope 6 { - debug old => _13; + debug old => _12; scope 7 { } } @@ -54,9 +53,9 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { } bb1: { - StorageLive(_12); + StorageLive(_14); _6 = &mut _5; - StorageLive(_13); + StorageLive(_12); StorageLive(_11); StorageLive(_7); _7 = &(_5.0: u32); @@ -69,77 +68,57 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { _11 = Lt(move _9, move _10); StorageDead(_10); StorageDead(_9); - switchInt(move _11) -> [0: bb2, otherwise: bb3]; + switchInt(move _11) -> [0: bb2, otherwise: bb4]; } bb2: { StorageDead(_8); StorageDead(_7); - _12 = const Option::<u32>::None; - goto -> bb5; + StorageDead(_11); + StorageDead(_12); + StorageDead(_14); + StorageDead(_5); + drop(_3) -> [return: bb3, unwind continue]; } bb3: { - StorageDead(_8); - StorageDead(_7); - _13 = (_5.0: u32); - StorageLive(_14); - _14 = <u32 as Step>::forward_unchecked(_13, const 1_usize) -> [return: bb4, unwind: bb11]; + return; } bb4: { - (_5.0: u32) = move _14; - StorageDead(_14); - _12 = Option::<u32>::Some(_13); - goto -> bb5; + StorageDead(_8); + StorageDead(_7); + _12 = (_5.0: u32); + StorageLive(_13); + _13 = <u32 as Step>::forward_unchecked(_12, const 1_usize) -> [return: bb5, unwind: bb7]; } bb5: { - StorageDead(_11); + (_5.0: u32) = move _13; StorageDead(_13); - _15 = discriminant(_12); - switchInt(move _15) -> [0: bb6, 1: bb8, otherwise: bb10]; - } - - bb6: { + _14 = Option::<u32>::Some(_12); + StorageDead(_11); StorageDead(_12); - StorageDead(_5); - drop(_3) -> [return: bb7, unwind continue]; - } - - bb7: { - return; - } - - bb8: { - _16 = ((_12 as Some).0: u32); + _15 = ((_14 as Some).0: u32); + StorageLive(_16); + _16 = &_3; StorageLive(_17); - _17 = &_3; - StorageLive(_18); - _18 = (_16,); - _19 = <impl Fn(u32) as Fn<(u32,)>>::call(move _17, move _18) -> [return: bb9, unwind: bb11]; + _17 = (_15,); + _18 = <impl Fn(u32) as Fn<(u32,)>>::call(move _16, move _17) -> [return: bb6, unwind: bb7]; } - bb9: { - StorageDead(_18); + bb6: { StorageDead(_17); - StorageDead(_12); + StorageDead(_16); + StorageDead(_14); goto -> bb1; } - bb10: { - unreachable; + bb7 (cleanup): { + drop(_3) -> [return: bb8, unwind terminate(cleanup)]; } - bb11 (cleanup): { - drop(_3) -> [return: bb12, unwind terminate(cleanup)]; - } - - bb12 (cleanup): { + bb8 (cleanup): { resume; } } - -ALLOC0 (size: 8, align: 4) { - 00 00 00 00 __ __ __ __ │ ....░░░░ -} 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 dc37c1b4cbf..2fdc21d636f 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 @@ -89,7 +89,7 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) -> StorageLive(_12); StorageLive(_11); StorageLive(_10); - _10 = _9 as *const () (PointerCoercion(MutToConstPointer)); + _10 = _8 as *const () (PtrToPtr); _11 = std::ptr::metadata::PtrComponents::<[u32]> { data_pointer: move _10, metadata: _6 }; StorageDead(_10); _12 = std::ptr::metadata::PtrRepr::<[u32]> { const_ptr: move _11 }; 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 dc37c1b4cbf..2fdc21d636f 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 @@ -89,7 +89,7 @@ fn slice_get_unchecked_mut_range(_1: &mut [u32], _2: std::ops::Range<usize>) -> StorageLive(_12); StorageLive(_11); StorageLive(_10); - _10 = _9 as *const () (PointerCoercion(MutToConstPointer)); + _10 = _8 as *const () (PtrToPtr); _11 = std::ptr::metadata::PtrComponents::<[u32]> { data_pointer: move _10, metadata: _6 }; StorageDead(_10); _12 = std::ptr::metadata::PtrRepr::<[u32]> { const_ptr: move _11 }; 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 4906c86f8ed..05b01404b69 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 @@ -4,22 +4,22 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { debug slice => _1; debug f => _2; let mut _0: (); - let mut _15: std::slice::Iter<'_, T>; - let mut _16: std::iter::Enumerate<std::slice::Iter<'_, T>>; - let mut _17: std::iter::Enumerate<std::slice::Iter<'_, T>>; - let mut _18: &mut std::iter::Enumerate<std::slice::Iter<'_, T>>; - let mut _19: std::option::Option<(usize, &T)>; - let mut _20: isize; - let mut _23: &impl Fn(usize, &T); - let mut _24: (usize, &T); - let _25: (); + let mut _13: std::slice::Iter<'_, T>; + let mut _14: std::iter::Enumerate<std::slice::Iter<'_, T>>; + let mut _15: std::iter::Enumerate<std::slice::Iter<'_, T>>; + let mut _16: &mut std::iter::Enumerate<std::slice::Iter<'_, T>>; + let mut _17: std::option::Option<(usize, &T)>; + let mut _18: isize; + let mut _21: &impl Fn(usize, &T); + let mut _22: (usize, &T); + let _23: (); scope 1 { - debug iter => _17; - let _21: usize; - let _22: &T; + debug iter => _15; + let _19: usize; + let _20: &T; scope 2 { - debug i => _21; - debug x => _22; + debug i => _19; + debug x => _20; } } scope 3 (inlined core::slice::<impl [T]>::iter) { @@ -28,19 +28,19 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { debug slice => _1; let _3: usize; let mut _5: std::ptr::NonNull<[T]>; - let mut _10: bool; - let mut _11: *mut T; - let mut _12: *mut T; - let mut _14: *const T; + let mut _8: bool; + let mut _9: *mut T; + let mut _10: *mut T; + let mut _12: *const T; scope 5 { debug len => _3; - let _9: std::ptr::NonNull<T>; + let _7: std::ptr::NonNull<T>; scope 6 { - debug ptr => _9; + debug ptr => _7; scope 7 { - let _13: *const T; + let _11: *const T; scope 8 { - debug end_or_len => _13; + debug end_or_len => _11; } scope 14 (inlined invalid::<T>) { debug addr => _3; @@ -48,10 +48,10 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } } scope 16 (inlined NonNull::<T>::as_ptr) { - debug self => _9; + debug self => _7; } scope 17 (inlined std::ptr::mut_ptr::<impl *mut T>::add) { - debug self => _11; + debug self => _9; debug count => _3; scope 18 { } @@ -66,9 +66,7 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } scope 11 (inlined NonNull::<[T]>::cast::<T>) { debug self => _5; - let mut _6: *mut [T]; - let mut _7: *mut T; - let mut _8: *const T; + let mut _6: *const T; scope 12 { scope 13 (inlined NonNull::<[T]>::as_ptr) { debug self => _5; @@ -79,90 +77,84 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } } scope 19 (inlined <std::slice::Iter<'_, T> as Iterator>::enumerate) { - debug self => _15; + debug self => _13; scope 20 (inlined Enumerate::<std::slice::Iter<'_, T>>::new) { - debug iter => _15; + debug iter => _13; } } scope 21 (inlined <Enumerate<std::slice::Iter<'_, T>> as IntoIterator>::into_iter) { - debug self => _16; + debug self => _14; } bb0: { - StorageLive(_15); + StorageLive(_13); StorageLive(_3); - StorageLive(_9); + StorageLive(_7); StorageLive(_4); - StorageLive(_8); + StorageLive(_6); _3 = Len((*_1)); StorageLive(_5); _4 = &raw const (*_1); _5 = NonNull::<[T]> { pointer: _4 }; - StorageLive(_7); - StorageLive(_6); - _6 = _4 as *mut [T] (PtrToPtr); - _7 = move _6 as *mut T (PtrToPtr); - _8 = move _7 as *const T (PointerCoercion(MutToConstPointer)); - StorageDead(_6); - StorageDead(_7); - _9 = NonNull::<T> { pointer: _8 }; + _6 = _4 as *const T (PtrToPtr); + _7 = NonNull::<T> { pointer: _6 }; StorageDead(_5); - StorageLive(_13); - StorageLive(_10); - _10 = const _; - switchInt(move _10) -> [0: bb1, otherwise: bb2]; + StorageLive(_11); + StorageLive(_8); + _8 = const _; + switchInt(move _8) -> [0: bb1, otherwise: bb2]; } bb1: { - StorageLive(_12); - StorageLive(_11); - _11 = _8 as *mut T (PtrToPtr); - _12 = Offset(_11, _3); - StorageDead(_11); - _13 = move _12 as *const T (PointerCoercion(MutToConstPointer)); - StorageDead(_12); + StorageLive(_10); + StorageLive(_9); + _9 = _4 as *mut T (PtrToPtr); + _10 = Offset(_9, _3); + StorageDead(_9); + _11 = move _10 as *const T (PointerCoercion(MutToConstPointer)); + StorageDead(_10); goto -> bb3; } bb2: { - _13 = _3 as *const T (Transmute); + _11 = _3 as *const T (Transmute); goto -> bb3; } bb3: { - StorageDead(_10); - StorageLive(_14); - _14 = _13; - _15 = std::slice::Iter::<'_, T> { ptr: _9, end_or_len: move _14, _marker: const ZeroSized: PhantomData<&T> }; - StorageDead(_14); - StorageDead(_13); StorageDead(_8); + StorageLive(_12); + _12 = _11; + _13 = std::slice::Iter::<'_, T> { ptr: _7, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> }; + StorageDead(_12); + StorageDead(_11); + StorageDead(_6); StorageDead(_4); - StorageDead(_9); + StorageDead(_7); StorageDead(_3); - _16 = Enumerate::<std::slice::Iter<'_, T>> { iter: _15, count: const 0_usize }; - StorageDead(_15); - StorageLive(_17); - _17 = _16; + _14 = Enumerate::<std::slice::Iter<'_, T>> { iter: _13, count: const 0_usize }; + StorageDead(_13); + StorageLive(_15); + _15 = _14; goto -> bb4; } bb4: { - StorageLive(_19); - StorageLive(_18); - _18 = &mut _17; - _19 = <Enumerate<std::slice::Iter<'_, T>> as Iterator>::next(move _18) -> [return: bb5, unwind unreachable]; + StorageLive(_17); + StorageLive(_16); + _16 = &mut _15; + _17 = <Enumerate<std::slice::Iter<'_, T>> as Iterator>::next(move _16) -> [return: bb5, unwind unreachable]; } bb5: { - StorageDead(_18); - _20 = discriminant(_19); - switchInt(move _20) -> [0: bb6, 1: bb8, otherwise: bb10]; + StorageDead(_16); + _18 = discriminant(_17); + switchInt(move _18) -> [0: bb6, 1: bb8, otherwise: bb10]; } bb6: { - StorageDead(_19); StorageDead(_17); + StorageDead(_15); drop(_2) -> [return: bb7, unwind unreachable]; } @@ -171,19 +163,19 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb8: { - _21 = (((_19 as Some).0: (usize, &T)).0: usize); - _22 = (((_19 as Some).0: (usize, &T)).1: &T); - StorageLive(_23); - _23 = &_2; - StorageLive(_24); - _24 = (_21, _22); - _25 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _23, move _24) -> [return: bb9, unwind unreachable]; + _19 = (((_17 as Some).0: (usize, &T)).0: usize); + _20 = (((_17 as Some).0: (usize, &T)).1: &T); + StorageLive(_21); + _21 = &_2; + StorageLive(_22); + _22 = (_19, _20); + _23 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _21, move _22) -> [return: bb9, unwind unreachable]; } bb9: { - StorageDead(_24); - StorageDead(_23); - StorageDead(_19); + StorageDead(_22); + StorageDead(_21); + StorageDead(_17); 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 25a5ecdc6c3..1fb29f5c662 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 @@ -4,22 +4,22 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { debug slice => _1; debug f => _2; let mut _0: (); - let mut _15: std::slice::Iter<'_, T>; - let mut _16: std::iter::Enumerate<std::slice::Iter<'_, T>>; - let mut _17: std::iter::Enumerate<std::slice::Iter<'_, T>>; - let mut _18: &mut std::iter::Enumerate<std::slice::Iter<'_, T>>; - let mut _19: std::option::Option<(usize, &T)>; - let mut _20: isize; - let mut _23: &impl Fn(usize, &T); - let mut _24: (usize, &T); - let _25: (); + let mut _13: std::slice::Iter<'_, T>; + let mut _14: std::iter::Enumerate<std::slice::Iter<'_, T>>; + let mut _15: std::iter::Enumerate<std::slice::Iter<'_, T>>; + let mut _16: &mut std::iter::Enumerate<std::slice::Iter<'_, T>>; + let mut _17: std::option::Option<(usize, &T)>; + let mut _18: isize; + let mut _21: &impl Fn(usize, &T); + let mut _22: (usize, &T); + let _23: (); scope 1 { - debug iter => _17; - let _21: usize; - let _22: &T; + debug iter => _15; + let _19: usize; + let _20: &T; scope 2 { - debug i => _21; - debug x => _22; + debug i => _19; + debug x => _20; } } scope 3 (inlined core::slice::<impl [T]>::iter) { @@ -28,19 +28,19 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { debug slice => _1; let _3: usize; let mut _5: std::ptr::NonNull<[T]>; - let mut _10: bool; - let mut _11: *mut T; - let mut _12: *mut T; - let mut _14: *const T; + let mut _8: bool; + let mut _9: *mut T; + let mut _10: *mut T; + let mut _12: *const T; scope 5 { debug len => _3; - let _9: std::ptr::NonNull<T>; + let _7: std::ptr::NonNull<T>; scope 6 { - debug ptr => _9; + debug ptr => _7; scope 7 { - let _13: *const T; + let _11: *const T; scope 8 { - debug end_or_len => _13; + debug end_or_len => _11; } scope 14 (inlined invalid::<T>) { debug addr => _3; @@ -48,10 +48,10 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } } scope 16 (inlined NonNull::<T>::as_ptr) { - debug self => _9; + debug self => _7; } scope 17 (inlined std::ptr::mut_ptr::<impl *mut T>::add) { - debug self => _11; + debug self => _9; debug count => _3; scope 18 { } @@ -66,9 +66,7 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } scope 11 (inlined NonNull::<[T]>::cast::<T>) { debug self => _5; - let mut _6: *mut [T]; - let mut _7: *mut T; - let mut _8: *const T; + let mut _6: *const T; scope 12 { scope 13 (inlined NonNull::<[T]>::as_ptr) { debug self => _5; @@ -79,90 +77,84 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } } scope 19 (inlined <std::slice::Iter<'_, T> as Iterator>::enumerate) { - debug self => _15; + debug self => _13; scope 20 (inlined Enumerate::<std::slice::Iter<'_, T>>::new) { - debug iter => _15; + debug iter => _13; } } scope 21 (inlined <Enumerate<std::slice::Iter<'_, T>> as IntoIterator>::into_iter) { - debug self => _16; + debug self => _14; } bb0: { - StorageLive(_15); + StorageLive(_13); StorageLive(_3); - StorageLive(_9); + StorageLive(_7); StorageLive(_4); - StorageLive(_8); + StorageLive(_6); _3 = Len((*_1)); StorageLive(_5); _4 = &raw const (*_1); _5 = NonNull::<[T]> { pointer: _4 }; - StorageLive(_7); - StorageLive(_6); - _6 = _4 as *mut [T] (PtrToPtr); - _7 = move _6 as *mut T (PtrToPtr); - _8 = move _7 as *const T (PointerCoercion(MutToConstPointer)); - StorageDead(_6); - StorageDead(_7); - _9 = NonNull::<T> { pointer: _8 }; + _6 = _4 as *const T (PtrToPtr); + _7 = NonNull::<T> { pointer: _6 }; StorageDead(_5); - StorageLive(_13); - StorageLive(_10); - _10 = const _; - switchInt(move _10) -> [0: bb1, otherwise: bb2]; + StorageLive(_11); + StorageLive(_8); + _8 = const _; + switchInt(move _8) -> [0: bb1, otherwise: bb2]; } bb1: { - StorageLive(_12); - StorageLive(_11); - _11 = _8 as *mut T (PtrToPtr); - _12 = Offset(_11, _3); - StorageDead(_11); - _13 = move _12 as *const T (PointerCoercion(MutToConstPointer)); - StorageDead(_12); + StorageLive(_10); + StorageLive(_9); + _9 = _4 as *mut T (PtrToPtr); + _10 = Offset(_9, _3); + StorageDead(_9); + _11 = move _10 as *const T (PointerCoercion(MutToConstPointer)); + StorageDead(_10); goto -> bb3; } bb2: { - _13 = _3 as *const T (Transmute); + _11 = _3 as *const T (Transmute); goto -> bb3; } bb3: { - StorageDead(_10); - StorageLive(_14); - _14 = _13; - _15 = std::slice::Iter::<'_, T> { ptr: _9, end_or_len: move _14, _marker: const ZeroSized: PhantomData<&T> }; - StorageDead(_14); - StorageDead(_13); StorageDead(_8); + StorageLive(_12); + _12 = _11; + _13 = std::slice::Iter::<'_, T> { ptr: _7, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> }; + StorageDead(_12); + StorageDead(_11); + StorageDead(_6); StorageDead(_4); - StorageDead(_9); + StorageDead(_7); StorageDead(_3); - _16 = Enumerate::<std::slice::Iter<'_, T>> { iter: _15, count: const 0_usize }; - StorageDead(_15); - StorageLive(_17); - _17 = _16; + _14 = Enumerate::<std::slice::Iter<'_, T>> { iter: _13, count: const 0_usize }; + StorageDead(_13); + StorageLive(_15); + _15 = _14; goto -> bb4; } bb4: { - StorageLive(_19); - StorageLive(_18); - _18 = &mut _17; - _19 = <Enumerate<std::slice::Iter<'_, T>> as Iterator>::next(move _18) -> [return: bb5, unwind: bb11]; + StorageLive(_17); + StorageLive(_16); + _16 = &mut _15; + _17 = <Enumerate<std::slice::Iter<'_, T>> as Iterator>::next(move _16) -> [return: bb5, unwind: bb11]; } bb5: { - StorageDead(_18); - _20 = discriminant(_19); - switchInt(move _20) -> [0: bb6, 1: bb8, otherwise: bb10]; + StorageDead(_16); + _18 = discriminant(_17); + switchInt(move _18) -> [0: bb6, 1: bb8, otherwise: bb10]; } bb6: { - StorageDead(_19); StorageDead(_17); + StorageDead(_15); drop(_2) -> [return: bb7, unwind continue]; } @@ -171,19 +163,19 @@ fn enumerated_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb8: { - _21 = (((_19 as Some).0: (usize, &T)).0: usize); - _22 = (((_19 as Some).0: (usize, &T)).1: &T); - StorageLive(_23); - _23 = &_2; - StorageLive(_24); - _24 = (_21, _22); - _25 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _23, move _24) -> [return: bb9, unwind: bb11]; + _19 = (((_17 as Some).0: (usize, &T)).0: usize); + _20 = (((_17 as Some).0: (usize, &T)).1: &T); + StorageLive(_21); + _21 = &_2; + StorageLive(_22); + _22 = (_19, _20); + _23 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _21, move _22) -> [return: bb9, unwind: bb11]; } bb9: { - StorageDead(_24); - StorageDead(_23); - StorageDead(_19); + StorageDead(_22); + StorageDead(_21); + StorageDead(_17); 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 133d6f53fce..2e63030aa5e 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 @@ -4,19 +4,19 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { debug slice => _1; debug f => _2; let mut _0: (); - let mut _15: std::slice::Iter<'_, T>; - let mut _16: std::slice::Iter<'_, T>; - let mut _17: &mut std::slice::Iter<'_, T>; - let mut _18: std::option::Option<&T>; - let mut _19: isize; - let mut _21: &impl Fn(&T); - let mut _22: (&T,); - let _23: (); + let mut _13: std::slice::Iter<'_, T>; + let mut _14: std::slice::Iter<'_, T>; + let mut _15: &mut std::slice::Iter<'_, T>; + let mut _16: std::option::Option<&T>; + let mut _17: isize; + let mut _19: &impl Fn(&T); + let mut _20: (&T,); + let _21: (); scope 1 { - debug iter => _16; - let _20: &T; + debug iter => _14; + let _18: &T; scope 2 { - debug x => _20; + debug x => _18; } } scope 3 (inlined core::slice::<impl [T]>::iter) { @@ -25,19 +25,19 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { debug slice => _1; let _3: usize; let mut _5: std::ptr::NonNull<[T]>; - let mut _10: bool; - let mut _11: *mut T; - let mut _12: *mut T; - let mut _14: *const T; + let mut _8: bool; + let mut _9: *mut T; + let mut _10: *mut T; + let mut _12: *const T; scope 5 { debug len => _3; - let _9: std::ptr::NonNull<T>; + let _7: std::ptr::NonNull<T>; scope 6 { - debug ptr => _9; + debug ptr => _7; scope 7 { - let _13: *const T; + let _11: *const T; scope 8 { - debug end_or_len => _13; + debug end_or_len => _11; } scope 14 (inlined invalid::<T>) { debug addr => _3; @@ -45,10 +45,10 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } } scope 16 (inlined NonNull::<T>::as_ptr) { - debug self => _9; + debug self => _7; } scope 17 (inlined std::ptr::mut_ptr::<impl *mut T>::add) { - debug self => _11; + debug self => _9; debug count => _3; scope 18 { } @@ -63,9 +63,7 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } scope 11 (inlined NonNull::<[T]>::cast::<T>) { debug self => _5; - let mut _6: *mut [T]; - let mut _7: *mut T; - let mut _8: *const T; + let mut _6: *const T; scope 12 { scope 13 (inlined NonNull::<[T]>::as_ptr) { debug self => _5; @@ -76,81 +74,75 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } } scope 19 (inlined <std::slice::Iter<'_, T> as IntoIterator>::into_iter) { - debug self => _15; + debug self => _13; } bb0: { StorageLive(_3); - StorageLive(_9); + StorageLive(_7); StorageLive(_4); - StorageLive(_8); + StorageLive(_6); _3 = Len((*_1)); StorageLive(_5); _4 = &raw const (*_1); _5 = NonNull::<[T]> { pointer: _4 }; - StorageLive(_7); - StorageLive(_6); - _6 = _4 as *mut [T] (PtrToPtr); - _7 = move _6 as *mut T (PtrToPtr); - _8 = move _7 as *const T (PointerCoercion(MutToConstPointer)); - StorageDead(_6); - StorageDead(_7); - _9 = NonNull::<T> { pointer: _8 }; + _6 = _4 as *const T (PtrToPtr); + _7 = NonNull::<T> { pointer: _6 }; StorageDead(_5); - StorageLive(_13); - StorageLive(_10); - _10 = const _; - switchInt(move _10) -> [0: bb1, otherwise: bb2]; + StorageLive(_11); + StorageLive(_8); + _8 = const _; + switchInt(move _8) -> [0: bb1, otherwise: bb2]; } bb1: { - StorageLive(_12); - StorageLive(_11); - _11 = _8 as *mut T (PtrToPtr); - _12 = Offset(_11, _3); - StorageDead(_11); - _13 = move _12 as *const T (PointerCoercion(MutToConstPointer)); - StorageDead(_12); + StorageLive(_10); + StorageLive(_9); + _9 = _4 as *mut T (PtrToPtr); + _10 = Offset(_9, _3); + StorageDead(_9); + _11 = move _10 as *const T (PointerCoercion(MutToConstPointer)); + StorageDead(_10); goto -> bb3; } bb2: { - _13 = _3 as *const T (Transmute); + _11 = _3 as *const T (Transmute); goto -> bb3; } bb3: { - StorageDead(_10); - StorageLive(_14); - _14 = _13; - _15 = std::slice::Iter::<'_, T> { ptr: _9, end_or_len: move _14, _marker: const ZeroSized: PhantomData<&T> }; - StorageDead(_14); - StorageDead(_13); StorageDead(_8); + StorageLive(_12); + _12 = _11; + _13 = std::slice::Iter::<'_, T> { ptr: _7, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> }; + StorageDead(_12); + StorageDead(_11); + StorageDead(_6); StorageDead(_4); - StorageDead(_9); + StorageDead(_7); StorageDead(_3); - StorageLive(_16); - _16 = _15; + StorageLive(_14); + _14 = _13; goto -> bb4; } bb4: { - StorageLive(_18); - StorageLive(_17); - _17 = &mut _16; - _18 = <std::slice::Iter<'_, T> as Iterator>::next(move _17) -> [return: bb5, unwind unreachable]; + StorageLive(_16); + StorageLive(_15); + _15 = &mut _14; + _16 = <std::slice::Iter<'_, T> as Iterator>::next(move _15) -> [return: bb5, unwind unreachable]; } bb5: { - StorageDead(_17); - _19 = discriminant(_18); - switchInt(move _19) -> [0: bb6, 1: bb8, otherwise: bb10]; + StorageDead(_15); + _17 = discriminant(_16); + switchInt(move _17) -> [0: bb6, 1: bb8, otherwise: bb10]; } bb6: { - StorageDead(_18); StorageDead(_16); + StorageDead(_14); drop(_2) -> [return: bb7, unwind unreachable]; } @@ -159,18 +151,18 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb8: { - _20 = ((_18 as Some).0: &T); - StorageLive(_21); - _21 = &_2; - StorageLive(_22); - _22 = (_20,); - _23 = <impl Fn(&T) as Fn<(&T,)>>::call(move _21, move _22) -> [return: bb9, unwind unreachable]; + _18 = ((_16 as Some).0: &T); + StorageLive(_19); + _19 = &_2; + StorageLive(_20); + _20 = (_18,); + _21 = <impl Fn(&T) as Fn<(&T,)>>::call(move _19, move _20) -> [return: bb9, unwind unreachable]; } bb9: { - StorageDead(_22); - StorageDead(_21); - StorageDead(_18); + StorageDead(_20); + StorageDead(_19); + StorageDead(_16); 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 4e74253e541..b6b6b6972e9 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 @@ -4,19 +4,19 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { debug slice => _1; debug f => _2; let mut _0: (); - let mut _15: std::slice::Iter<'_, T>; - let mut _16: std::slice::Iter<'_, T>; - let mut _17: &mut std::slice::Iter<'_, T>; - let mut _18: std::option::Option<&T>; - let mut _19: isize; - let mut _21: &impl Fn(&T); - let mut _22: (&T,); - let _23: (); + let mut _13: std::slice::Iter<'_, T>; + let mut _14: std::slice::Iter<'_, T>; + let mut _15: &mut std::slice::Iter<'_, T>; + let mut _16: std::option::Option<&T>; + let mut _17: isize; + let mut _19: &impl Fn(&T); + let mut _20: (&T,); + let _21: (); scope 1 { - debug iter => _16; - let _20: &T; + debug iter => _14; + let _18: &T; scope 2 { - debug x => _20; + debug x => _18; } } scope 3 (inlined core::slice::<impl [T]>::iter) { @@ -25,19 +25,19 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { debug slice => _1; let _3: usize; let mut _5: std::ptr::NonNull<[T]>; - let mut _10: bool; - let mut _11: *mut T; - let mut _12: *mut T; - let mut _14: *const T; + let mut _8: bool; + let mut _9: *mut T; + let mut _10: *mut T; + let mut _12: *const T; scope 5 { debug len => _3; - let _9: std::ptr::NonNull<T>; + let _7: std::ptr::NonNull<T>; scope 6 { - debug ptr => _9; + debug ptr => _7; scope 7 { - let _13: *const T; + let _11: *const T; scope 8 { - debug end_or_len => _13; + debug end_or_len => _11; } scope 14 (inlined invalid::<T>) { debug addr => _3; @@ -45,10 +45,10 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } } scope 16 (inlined NonNull::<T>::as_ptr) { - debug self => _9; + debug self => _7; } scope 17 (inlined std::ptr::mut_ptr::<impl *mut T>::add) { - debug self => _11; + debug self => _9; debug count => _3; scope 18 { } @@ -63,9 +63,7 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } scope 11 (inlined NonNull::<[T]>::cast::<T>) { debug self => _5; - let mut _6: *mut [T]; - let mut _7: *mut T; - let mut _8: *const T; + let mut _6: *const T; scope 12 { scope 13 (inlined NonNull::<[T]>::as_ptr) { debug self => _5; @@ -76,81 +74,75 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } } scope 19 (inlined <std::slice::Iter<'_, T> as IntoIterator>::into_iter) { - debug self => _15; + debug self => _13; } bb0: { StorageLive(_3); - StorageLive(_9); + StorageLive(_7); StorageLive(_4); - StorageLive(_8); + StorageLive(_6); _3 = Len((*_1)); StorageLive(_5); _4 = &raw const (*_1); _5 = NonNull::<[T]> { pointer: _4 }; - StorageLive(_7); - StorageLive(_6); - _6 = _4 as *mut [T] (PtrToPtr); - _7 = move _6 as *mut T (PtrToPtr); - _8 = move _7 as *const T (PointerCoercion(MutToConstPointer)); - StorageDead(_6); - StorageDead(_7); - _9 = NonNull::<T> { pointer: _8 }; + _6 = _4 as *const T (PtrToPtr); + _7 = NonNull::<T> { pointer: _6 }; StorageDead(_5); - StorageLive(_13); - StorageLive(_10); - _10 = const _; - switchInt(move _10) -> [0: bb1, otherwise: bb2]; + StorageLive(_11); + StorageLive(_8); + _8 = const _; + switchInt(move _8) -> [0: bb1, otherwise: bb2]; } bb1: { - StorageLive(_12); - StorageLive(_11); - _11 = _8 as *mut T (PtrToPtr); - _12 = Offset(_11, _3); - StorageDead(_11); - _13 = move _12 as *const T (PointerCoercion(MutToConstPointer)); - StorageDead(_12); + StorageLive(_10); + StorageLive(_9); + _9 = _4 as *mut T (PtrToPtr); + _10 = Offset(_9, _3); + StorageDead(_9); + _11 = move _10 as *const T (PointerCoercion(MutToConstPointer)); + StorageDead(_10); goto -> bb3; } bb2: { - _13 = _3 as *const T (Transmute); + _11 = _3 as *const T (Transmute); goto -> bb3; } bb3: { - StorageDead(_10); - StorageLive(_14); - _14 = _13; - _15 = std::slice::Iter::<'_, T> { ptr: _9, end_or_len: move _14, _marker: const ZeroSized: PhantomData<&T> }; - StorageDead(_14); - StorageDead(_13); StorageDead(_8); + StorageLive(_12); + _12 = _11; + _13 = std::slice::Iter::<'_, T> { ptr: _7, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> }; + StorageDead(_12); + StorageDead(_11); + StorageDead(_6); StorageDead(_4); - StorageDead(_9); + StorageDead(_7); StorageDead(_3); - StorageLive(_16); - _16 = _15; + StorageLive(_14); + _14 = _13; goto -> bb4; } bb4: { - StorageLive(_18); - StorageLive(_17); - _17 = &mut _16; - _18 = <std::slice::Iter<'_, T> as Iterator>::next(move _17) -> [return: bb5, unwind: bb11]; + StorageLive(_16); + StorageLive(_15); + _15 = &mut _14; + _16 = <std::slice::Iter<'_, T> as Iterator>::next(move _15) -> [return: bb5, unwind: bb11]; } bb5: { - StorageDead(_17); - _19 = discriminant(_18); - switchInt(move _19) -> [0: bb6, 1: bb8, otherwise: bb10]; + StorageDead(_15); + _17 = discriminant(_16); + switchInt(move _17) -> [0: bb6, 1: bb8, otherwise: bb10]; } bb6: { - StorageDead(_18); StorageDead(_16); + StorageDead(_14); drop(_2) -> [return: bb7, unwind continue]; } @@ -159,18 +151,18 @@ fn forward_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb8: { - _20 = ((_18 as Some).0: &T); - StorageLive(_21); - _21 = &_2; - StorageLive(_22); - _22 = (_20,); - _23 = <impl Fn(&T) as Fn<(&T,)>>::call(move _21, move _22) -> [return: bb9, unwind: bb11]; + _18 = ((_16 as Some).0: &T); + StorageLive(_19); + _19 = &_2; + StorageLive(_20); + _20 = (_18,); + _21 = <impl Fn(&T) as Fn<(&T,)>>::call(move _19, move _20) -> [return: bb9, unwind: bb11]; } bb9: { - StorageDead(_22); - StorageDead(_21); - StorageDead(_18); + StorageDead(_20); + StorageDead(_19); + StorageDead(_16); 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 83915d3c449..543e8918e39 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 @@ -8,21 +8,20 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { let mut _4: std::ops::Range<usize>; let mut _5: std::ops::Range<usize>; let mut _6: &mut std::ops::Range<usize>; - let mut _12: std::option::Option<usize>; - let mut _15: isize; - let mut _17: usize; - let mut _18: bool; - let mut _20: &impl Fn(usize, &T); - let mut _21: (usize, &T); - let _22: (); + let mut _14: std::option::Option<usize>; + let mut _16: usize; + let mut _17: bool; + let mut _19: &impl Fn(usize, &T); + let mut _20: (usize, &T); + let _21: (); scope 1 { debug iter => _5; - let _16: usize; + let _15: usize; scope 2 { - debug i => _16; - let _19: &T; + debug i => _15; + let _18: &T; scope 3 { - debug x => _19; + debug x => _18; } } scope 5 (inlined iter::range::<impl Iterator for std::ops::Range<usize>>::next) { @@ -32,10 +31,10 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { let mut _7: &usize; let mut _8: &usize; let mut _11: bool; - let _13: usize; - let mut _14: usize; + let _12: usize; + let mut _13: usize; scope 7 { - debug old => _13; + debug old => _12; scope 8 { } } @@ -63,9 +62,9 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb1: { - StorageLive(_12); + StorageLive(_14); _6 = &mut _5; - StorageLive(_13); + StorageLive(_12); StorageLive(_11); StorageLive(_7); _7 = &(_5.0: usize); @@ -78,76 +77,56 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { _11 = Lt(move _9, move _10); StorageDead(_10); StorageDead(_9); - switchInt(move _11) -> [0: bb2, otherwise: bb3]; + switchInt(move _11) -> [0: bb2, otherwise: bb4]; } bb2: { StorageDead(_8); StorageDead(_7); - _12 = const Option::<usize>::None; - goto -> bb5; + StorageDead(_11); + StorageDead(_12); + StorageDead(_14); + StorageDead(_5); + drop(_2) -> [return: bb3, unwind unreachable]; } bb3: { - StorageDead(_8); - StorageDead(_7); - _13 = (_5.0: usize); - StorageLive(_14); - _14 = <usize as Step>::forward_unchecked(_13, const 1_usize) -> [return: bb4, unwind unreachable]; + return; } bb4: { - (_5.0: usize) = move _14; - StorageDead(_14); - _12 = Option::<usize>::Some(_13); - goto -> bb5; + StorageDead(_8); + StorageDead(_7); + _12 = (_5.0: usize); + StorageLive(_13); + _13 = <usize as Step>::forward_unchecked(_12, const 1_usize) -> [return: bb5, unwind unreachable]; } bb5: { - StorageDead(_11); + (_5.0: usize) = move _13; StorageDead(_13); - _15 = discriminant(_12); - switchInt(move _15) -> [0: bb6, 1: bb8, otherwise: bb11]; - } - - bb6: { + _14 = Option::<usize>::Some(_12); + StorageDead(_11); StorageDead(_12); - StorageDead(_5); - drop(_2) -> [return: bb7, unwind unreachable]; - } - - bb7: { - return; - } - - bb8: { - _16 = ((_12 as Some).0: usize); - _17 = Len((*_1)); - _18 = Lt(_16, _17); - assert(move _18, "index out of bounds: the length is {} but the index is {}", move _17, _16) -> [success: bb9, unwind unreachable]; + _15 = ((_14 as Some).0: usize); + _16 = Len((*_1)); + _17 = Lt(_15, _16); + assert(move _17, "index out of bounds: the length is {} but the index is {}", move _16, _15) -> [success: bb6, unwind unreachable]; } - bb9: { - _19 = &(*_1)[_16]; + bb6: { + _18 = &(*_1)[_15]; + StorageLive(_19); + _19 = &_2; StorageLive(_20); - _20 = &_2; - StorageLive(_21); - _21 = (_16, _19); - _22 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _20, move _21) -> [return: bb10, unwind unreachable]; + _20 = (_15, _18); + _21 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _19, move _20) -> [return: bb7, unwind unreachable]; } - bb10: { - StorageDead(_21); + bb7: { StorageDead(_20); - StorageDead(_12); + StorageDead(_19); + StorageDead(_14); goto -> bb1; } - - bb11: { - unreachable; - } -} - -ALLOC0 (size: 16, align: 8) { - 00 00 00 00 00 00 00 00 __ __ __ __ __ __ __ __ │ ........░░░░░░░░ } 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 0a005a460e8..a16e9cd9e51 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 @@ -8,21 +8,20 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { let mut _4: std::ops::Range<usize>; let mut _5: std::ops::Range<usize>; let mut _6: &mut std::ops::Range<usize>; - let mut _12: std::option::Option<usize>; - let mut _15: isize; - let mut _17: usize; - let mut _18: bool; - let mut _20: &impl Fn(usize, &T); - let mut _21: (usize, &T); - let _22: (); + let mut _14: std::option::Option<usize>; + let mut _16: usize; + let mut _17: bool; + let mut _19: &impl Fn(usize, &T); + let mut _20: (usize, &T); + let _21: (); scope 1 { debug iter => _5; - let _16: usize; + let _15: usize; scope 2 { - debug i => _16; - let _19: &T; + debug i => _15; + let _18: &T; scope 3 { - debug x => _19; + debug x => _18; } } scope 5 (inlined iter::range::<impl Iterator for std::ops::Range<usize>>::next) { @@ -32,10 +31,10 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { let mut _7: &usize; let mut _8: &usize; let mut _11: bool; - let _13: usize; - let mut _14: usize; + let _12: usize; + let mut _13: usize; scope 7 { - debug old => _13; + debug old => _12; scope 8 { } } @@ -63,9 +62,9 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { } bb1: { - StorageLive(_12); + StorageLive(_14); _6 = &mut _5; - StorageLive(_13); + StorageLive(_12); StorageLive(_11); StorageLive(_7); _7 = &(_5.0: usize); @@ -78,84 +77,64 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { _11 = Lt(move _9, move _10); StorageDead(_10); StorageDead(_9); - switchInt(move _11) -> [0: bb2, otherwise: bb3]; + switchInt(move _11) -> [0: bb2, otherwise: bb4]; } bb2: { StorageDead(_8); StorageDead(_7); - _12 = const Option::<usize>::None; - goto -> bb5; + StorageDead(_11); + StorageDead(_12); + StorageDead(_14); + StorageDead(_5); + drop(_2) -> [return: bb3, unwind continue]; } bb3: { - StorageDead(_8); - StorageDead(_7); - _13 = (_5.0: usize); - StorageLive(_14); - _14 = <usize as Step>::forward_unchecked(_13, const 1_usize) -> [return: bb4, unwind: bb12]; + return; } bb4: { - (_5.0: usize) = move _14; - StorageDead(_14); - _12 = Option::<usize>::Some(_13); - goto -> bb5; + StorageDead(_8); + StorageDead(_7); + _12 = (_5.0: usize); + StorageLive(_13); + _13 = <usize as Step>::forward_unchecked(_12, const 1_usize) -> [return: bb5, unwind: bb8]; } bb5: { - StorageDead(_11); + (_5.0: usize) = move _13; StorageDead(_13); - _15 = discriminant(_12); - switchInt(move _15) -> [0: bb6, 1: bb8, otherwise: bb11]; - } - - bb6: { + _14 = Option::<usize>::Some(_12); + StorageDead(_11); StorageDead(_12); - StorageDead(_5); - drop(_2) -> [return: bb7, unwind continue]; - } - - bb7: { - return; - } - - bb8: { - _16 = ((_12 as Some).0: usize); - _17 = Len((*_1)); - _18 = Lt(_16, _17); - assert(move _18, "index out of bounds: the length is {} but the index is {}", move _17, _16) -> [success: bb9, unwind: bb12]; + _15 = ((_14 as Some).0: usize); + _16 = Len((*_1)); + _17 = Lt(_15, _16); + assert(move _17, "index out of bounds: the length is {} but the index is {}", move _16, _15) -> [success: bb6, unwind: bb8]; } - bb9: { - _19 = &(*_1)[_16]; + bb6: { + _18 = &(*_1)[_15]; + StorageLive(_19); + _19 = &_2; StorageLive(_20); - _20 = &_2; - StorageLive(_21); - _21 = (_16, _19); - _22 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _20, move _21) -> [return: bb10, unwind: bb12]; + _20 = (_15, _18); + _21 = <impl Fn(usize, &T) as Fn<(usize, &T)>>::call(move _19, move _20) -> [return: bb7, unwind: bb8]; } - bb10: { - StorageDead(_21); + bb7: { StorageDead(_20); - StorageDead(_12); + StorageDead(_19); + StorageDead(_14); goto -> bb1; } - bb11: { - unreachable; + bb8 (cleanup): { + drop(_2) -> [return: bb9, unwind terminate(cleanup)]; } - bb12 (cleanup): { - drop(_2) -> [return: bb13, unwind terminate(cleanup)]; - } - - bb13 (cleanup): { + bb9 (cleanup): { resume; } } - -ALLOC0 (size: 16, align: 8) { - 00 00 00 00 00 00 00 00 __ __ __ __ __ __ __ __ │ ........░░░░░░░░ -} 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 639e1a51430..a78e46a0b78 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 @@ -4,24 +4,24 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { debug slice => _1; debug f => _2; let mut _0: (); - let mut _15: std::slice::Iter<'_, T>; - let mut _16: std::iter::Rev<std::slice::Iter<'_, T>>; - let mut _17: std::iter::Rev<std::slice::Iter<'_, T>>; - let mut _18: &mut std::iter::Rev<std::slice::Iter<'_, T>>; - let mut _20: std::option::Option<&T>; - let mut _21: isize; - let mut _23: &impl Fn(&T); - let mut _24: (&T,); - let _25: (); + let mut _13: std::slice::Iter<'_, T>; + let mut _14: std::iter::Rev<std::slice::Iter<'_, T>>; + let mut _15: std::iter::Rev<std::slice::Iter<'_, T>>; + let mut _16: &mut std::iter::Rev<std::slice::Iter<'_, T>>; + let mut _18: std::option::Option<&T>; + let mut _19: isize; + let mut _21: &impl Fn(&T); + let mut _22: (&T,); + let _23: (); scope 1 { - debug iter => _17; - let _22: &T; + debug iter => _15; + let _20: &T; scope 2 { - debug x => _22; + debug x => _20; } scope 22 (inlined <Rev<std::slice::Iter<'_, T>> as Iterator>::next) { - debug self => _18; - let mut _19: &mut std::slice::Iter<'_, T>; + debug self => _16; + let mut _17: &mut std::slice::Iter<'_, T>; } } scope 3 (inlined core::slice::<impl [T]>::iter) { @@ -30,19 +30,19 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { debug slice => _1; let _3: usize; let mut _5: std::ptr::NonNull<[T]>; - let mut _10: bool; - let mut _11: *mut T; - let mut _12: *mut T; - let mut _14: *const T; + let mut _8: bool; + let mut _9: *mut T; + let mut _10: *mut T; + let mut _12: *const T; scope 5 { debug len => _3; - let _9: std::ptr::NonNull<T>; + let _7: std::ptr::NonNull<T>; scope 6 { - debug ptr => _9; + debug ptr => _7; scope 7 { - let _13: *const T; + let _11: *const T; scope 8 { - debug end_or_len => _13; + debug end_or_len => _11; } scope 14 (inlined invalid::<T>) { debug addr => _3; @@ -50,10 +50,10 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } } scope 16 (inlined NonNull::<T>::as_ptr) { - debug self => _9; + debug self => _7; } scope 17 (inlined std::ptr::mut_ptr::<impl *mut T>::add) { - debug self => _11; + debug self => _9; debug count => _3; scope 18 { } @@ -68,9 +68,7 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } scope 11 (inlined NonNull::<[T]>::cast::<T>) { debug self => _5; - let mut _6: *mut [T]; - let mut _7: *mut T; - let mut _8: *const T; + let mut _6: *const T; scope 12 { scope 13 (inlined NonNull::<[T]>::as_ptr) { debug self => _5; @@ -81,91 +79,85 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } } scope 19 (inlined <std::slice::Iter<'_, T> as Iterator>::rev) { - debug self => _15; + debug self => _13; scope 20 (inlined Rev::<std::slice::Iter<'_, T>>::new) { - debug iter => _15; + debug iter => _13; } } scope 21 (inlined <Rev<std::slice::Iter<'_, T>> as IntoIterator>::into_iter) { - debug self => _16; + debug self => _14; } bb0: { - StorageLive(_15); + StorageLive(_13); StorageLive(_3); - StorageLive(_9); + StorageLive(_7); StorageLive(_4); - StorageLive(_8); + StorageLive(_6); _3 = Len((*_1)); StorageLive(_5); _4 = &raw const (*_1); _5 = NonNull::<[T]> { pointer: _4 }; - StorageLive(_7); - StorageLive(_6); - _6 = _4 as *mut [T] (PtrToPtr); - _7 = move _6 as *mut T (PtrToPtr); - _8 = move _7 as *const T (PointerCoercion(MutToConstPointer)); - StorageDead(_6); - StorageDead(_7); - _9 = NonNull::<T> { pointer: _8 }; + _6 = _4 as *const T (PtrToPtr); + _7 = NonNull::<T> { pointer: _6 }; StorageDead(_5); - StorageLive(_13); - StorageLive(_10); - _10 = const _; - switchInt(move _10) -> [0: bb1, otherwise: bb2]; + StorageLive(_11); + StorageLive(_8); + _8 = const _; + switchInt(move _8) -> [0: bb1, otherwise: bb2]; } bb1: { - StorageLive(_12); - StorageLive(_11); - _11 = _8 as *mut T (PtrToPtr); - _12 = Offset(_11, _3); - StorageDead(_11); - _13 = move _12 as *const T (PointerCoercion(MutToConstPointer)); - StorageDead(_12); + StorageLive(_10); + StorageLive(_9); + _9 = _4 as *mut T (PtrToPtr); + _10 = Offset(_9, _3); + StorageDead(_9); + _11 = move _10 as *const T (PointerCoercion(MutToConstPointer)); + StorageDead(_10); goto -> bb3; } bb2: { - _13 = _3 as *const T (Transmute); + _11 = _3 as *const T (Transmute); goto -> bb3; } bb3: { - StorageDead(_10); - StorageLive(_14); - _14 = _13; - _15 = std::slice::Iter::<'_, T> { ptr: _9, end_or_len: move _14, _marker: const ZeroSized: PhantomData<&T> }; - StorageDead(_14); - StorageDead(_13); StorageDead(_8); + StorageLive(_12); + _12 = _11; + _13 = std::slice::Iter::<'_, T> { ptr: _7, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> }; + StorageDead(_12); + StorageDead(_11); + StorageDead(_6); StorageDead(_4); - StorageDead(_9); + StorageDead(_7); StorageDead(_3); - _16 = Rev::<std::slice::Iter<'_, T>> { iter: _15 }; - StorageDead(_15); - StorageLive(_17); - _17 = _16; + _14 = Rev::<std::slice::Iter<'_, T>> { iter: _13 }; + StorageDead(_13); + StorageLive(_15); + _15 = _14; goto -> bb4; } bb4: { - StorageLive(_20); - _18 = &mut _17; - StorageLive(_19); - _19 = &mut (_17.0: std::slice::Iter<'_, T>); - _20 = <std::slice::Iter<'_, T> as DoubleEndedIterator>::next_back(move _19) -> [return: bb5, unwind unreachable]; + StorageLive(_18); + _16 = &mut _15; + StorageLive(_17); + _17 = &mut (_15.0: std::slice::Iter<'_, T>); + _18 = <std::slice::Iter<'_, T> as DoubleEndedIterator>::next_back(move _17) -> [return: bb5, unwind unreachable]; } bb5: { - StorageDead(_19); - _21 = discriminant(_20); - switchInt(move _21) -> [0: bb6, 1: bb8, otherwise: bb10]; + StorageDead(_17); + _19 = discriminant(_18); + switchInt(move _19) -> [0: bb6, 1: bb8, otherwise: bb10]; } bb6: { - StorageDead(_20); - StorageDead(_17); + StorageDead(_18); + StorageDead(_15); drop(_2) -> [return: bb7, unwind unreachable]; } @@ -174,18 +166,18 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb8: { - _22 = ((_20 as Some).0: &T); - StorageLive(_23); - _23 = &_2; - StorageLive(_24); - _24 = (_22,); - _25 = <impl Fn(&T) as Fn<(&T,)>>::call(move _23, move _24) -> [return: bb9, unwind unreachable]; + _20 = ((_18 as Some).0: &T); + StorageLive(_21); + _21 = &_2; + StorageLive(_22); + _22 = (_20,); + _23 = <impl Fn(&T) as Fn<(&T,)>>::call(move _21, move _22) -> [return: bb9, unwind unreachable]; } bb9: { - StorageDead(_24); - StorageDead(_23); - StorageDead(_20); + StorageDead(_22); + StorageDead(_21); + StorageDead(_18); 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 2237fd7dbd1..4e54a23e819 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 @@ -4,24 +4,24 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { debug slice => _1; debug f => _2; let mut _0: (); - let mut _15: std::slice::Iter<'_, T>; - let mut _16: std::iter::Rev<std::slice::Iter<'_, T>>; - let mut _17: std::iter::Rev<std::slice::Iter<'_, T>>; - let mut _18: &mut std::iter::Rev<std::slice::Iter<'_, T>>; - let mut _20: std::option::Option<&T>; - let mut _21: isize; - let mut _23: &impl Fn(&T); - let mut _24: (&T,); - let _25: (); + let mut _13: std::slice::Iter<'_, T>; + let mut _14: std::iter::Rev<std::slice::Iter<'_, T>>; + let mut _15: std::iter::Rev<std::slice::Iter<'_, T>>; + let mut _16: &mut std::iter::Rev<std::slice::Iter<'_, T>>; + let mut _18: std::option::Option<&T>; + let mut _19: isize; + let mut _21: &impl Fn(&T); + let mut _22: (&T,); + let _23: (); scope 1 { - debug iter => _17; - let _22: &T; + debug iter => _15; + let _20: &T; scope 2 { - debug x => _22; + debug x => _20; } scope 22 (inlined <Rev<std::slice::Iter<'_, T>> as Iterator>::next) { - debug self => _18; - let mut _19: &mut std::slice::Iter<'_, T>; + debug self => _16; + let mut _17: &mut std::slice::Iter<'_, T>; } } scope 3 (inlined core::slice::<impl [T]>::iter) { @@ -30,19 +30,19 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { debug slice => _1; let _3: usize; let mut _5: std::ptr::NonNull<[T]>; - let mut _10: bool; - let mut _11: *mut T; - let mut _12: *mut T; - let mut _14: *const T; + let mut _8: bool; + let mut _9: *mut T; + let mut _10: *mut T; + let mut _12: *const T; scope 5 { debug len => _3; - let _9: std::ptr::NonNull<T>; + let _7: std::ptr::NonNull<T>; scope 6 { - debug ptr => _9; + debug ptr => _7; scope 7 { - let _13: *const T; + let _11: *const T; scope 8 { - debug end_or_len => _13; + debug end_or_len => _11; } scope 14 (inlined invalid::<T>) { debug addr => _3; @@ -50,10 +50,10 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } } scope 16 (inlined NonNull::<T>::as_ptr) { - debug self => _9; + debug self => _7; } scope 17 (inlined std::ptr::mut_ptr::<impl *mut T>::add) { - debug self => _11; + debug self => _9; debug count => _3; scope 18 { } @@ -68,9 +68,7 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } scope 11 (inlined NonNull::<[T]>::cast::<T>) { debug self => _5; - let mut _6: *mut [T]; - let mut _7: *mut T; - let mut _8: *const T; + let mut _6: *const T; scope 12 { scope 13 (inlined NonNull::<[T]>::as_ptr) { debug self => _5; @@ -81,91 +79,85 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } } scope 19 (inlined <std::slice::Iter<'_, T> as Iterator>::rev) { - debug self => _15; + debug self => _13; scope 20 (inlined Rev::<std::slice::Iter<'_, T>>::new) { - debug iter => _15; + debug iter => _13; } } scope 21 (inlined <Rev<std::slice::Iter<'_, T>> as IntoIterator>::into_iter) { - debug self => _16; + debug self => _14; } bb0: { - StorageLive(_15); + StorageLive(_13); StorageLive(_3); - StorageLive(_9); + StorageLive(_7); StorageLive(_4); - StorageLive(_8); + StorageLive(_6); _3 = Len((*_1)); StorageLive(_5); _4 = &raw const (*_1); _5 = NonNull::<[T]> { pointer: _4 }; - StorageLive(_7); - StorageLive(_6); - _6 = _4 as *mut [T] (PtrToPtr); - _7 = move _6 as *mut T (PtrToPtr); - _8 = move _7 as *const T (PointerCoercion(MutToConstPointer)); - StorageDead(_6); - StorageDead(_7); - _9 = NonNull::<T> { pointer: _8 }; + _6 = _4 as *const T (PtrToPtr); + _7 = NonNull::<T> { pointer: _6 }; StorageDead(_5); - StorageLive(_13); - StorageLive(_10); - _10 = const _; - switchInt(move _10) -> [0: bb1, otherwise: bb2]; + StorageLive(_11); + StorageLive(_8); + _8 = const _; + switchInt(move _8) -> [0: bb1, otherwise: bb2]; } bb1: { - StorageLive(_12); - StorageLive(_11); - _11 = _8 as *mut T (PtrToPtr); - _12 = Offset(_11, _3); - StorageDead(_11); - _13 = move _12 as *const T (PointerCoercion(MutToConstPointer)); - StorageDead(_12); + StorageLive(_10); + StorageLive(_9); + _9 = _4 as *mut T (PtrToPtr); + _10 = Offset(_9, _3); + StorageDead(_9); + _11 = move _10 as *const T (PointerCoercion(MutToConstPointer)); + StorageDead(_10); goto -> bb3; } bb2: { - _13 = _3 as *const T (Transmute); + _11 = _3 as *const T (Transmute); goto -> bb3; } bb3: { - StorageDead(_10); - StorageLive(_14); - _14 = _13; - _15 = std::slice::Iter::<'_, T> { ptr: _9, end_or_len: move _14, _marker: const ZeroSized: PhantomData<&T> }; - StorageDead(_14); - StorageDead(_13); StorageDead(_8); + StorageLive(_12); + _12 = _11; + _13 = std::slice::Iter::<'_, T> { ptr: _7, end_or_len: move _12, _marker: const ZeroSized: PhantomData<&T> }; + StorageDead(_12); + StorageDead(_11); + StorageDead(_6); StorageDead(_4); - StorageDead(_9); + StorageDead(_7); StorageDead(_3); - _16 = Rev::<std::slice::Iter<'_, T>> { iter: _15 }; - StorageDead(_15); - StorageLive(_17); - _17 = _16; + _14 = Rev::<std::slice::Iter<'_, T>> { iter: _13 }; + StorageDead(_13); + StorageLive(_15); + _15 = _14; goto -> bb4; } bb4: { - StorageLive(_20); - _18 = &mut _17; - StorageLive(_19); - _19 = &mut (_17.0: std::slice::Iter<'_, T>); - _20 = <std::slice::Iter<'_, T> as DoubleEndedIterator>::next_back(move _19) -> [return: bb5, unwind: bb11]; + StorageLive(_18); + _16 = &mut _15; + StorageLive(_17); + _17 = &mut (_15.0: std::slice::Iter<'_, T>); + _18 = <std::slice::Iter<'_, T> as DoubleEndedIterator>::next_back(move _17) -> [return: bb5, unwind: bb11]; } bb5: { - StorageDead(_19); - _21 = discriminant(_20); - switchInt(move _21) -> [0: bb6, 1: bb8, otherwise: bb10]; + StorageDead(_17); + _19 = discriminant(_18); + switchInt(move _19) -> [0: bb6, 1: bb8, otherwise: bb10]; } bb6: { - StorageDead(_20); - StorageDead(_17); + StorageDead(_18); + StorageDead(_15); drop(_2) -> [return: bb7, unwind continue]; } @@ -174,18 +166,18 @@ fn reverse_loop(_1: &[T], _2: impl Fn(&T)) -> () { } bb8: { - _22 = ((_20 as Some).0: &T); - StorageLive(_23); - _23 = &_2; - StorageLive(_24); - _24 = (_22,); - _25 = <impl Fn(&T) as Fn<(&T,)>>::call(move _23, move _24) -> [return: bb9, unwind: bb11]; + _20 = ((_18 as Some).0: &T); + StorageLive(_21); + _21 = &_2; + StorageLive(_22); + _22 = (_20,); + _23 = <impl Fn(&T) as Fn<(&T,)>>::call(move _21, move _22) -> [return: bb9, unwind: bb11]; } bb9: { - StorageDead(_24); - StorageDead(_23); - StorageDead(_20); + StorageDead(_22); + StorageDead(_21); + StorageDead(_18); 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 c1d4d4871d0..16d6d9719b6 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 @@ -6,65 +6,51 @@ fn new(_1: Result<T, E>) -> Result<T, E> { let mut _2: isize; let _3: T; let mut _4: std::ops::ControlFlow<E, T>; - let _5: E; - let mut _6: isize; - let _7: T; - let _8: E; + let _5: T; + let _6: E; + let _7: E; scope 1 { debug v => _3; } scope 2 { - debug e => _5; + debug e => _6; } scope 3 { - debug v => _7; + debug v => _5; } scope 4 { - debug e => _8; + debug e => _7; } bb0: { StorageLive(_4); _2 = discriminant(_1); - switchInt(move _2) -> [0: bb1, 1: bb2, otherwise: bb7]; + switchInt(move _2) -> [0: bb1, 1: bb2, otherwise: bb4]; } bb1: { _3 = move ((_1 as Ok).0: T); _4 = ControlFlow::<E, T>::Continue(_3); + _5 = move ((_4 as Continue).0: T); + _0 = Result::<T, E>::Ok(_5); + StorageDead(_4); goto -> bb3; } bb2: { - _5 = move ((_1 as Err).0: E); - _4 = ControlFlow::<E, T>::Break(_5); + _6 = move ((_1 as Err).0: E); + _4 = ControlFlow::<E, T>::Break(_6); + _7 = move ((_4 as Break).0: E); + _0 = Result::<T, E>::Err(_7); + StorageDead(_4); goto -> bb3; } bb3: { - _6 = discriminant(_4); - switchInt(move _6) -> [0: bb4, 1: bb5, otherwise: bb7]; - } - - bb4: { - _7 = move ((_4 as Continue).0: T); - _0 = Result::<T, E>::Ok(_7); - StorageDead(_4); - goto -> bb6; - } - - bb5: { - _8 = move ((_4 as Break).0: E); - _0 = Result::<T, E>::Err(_8); - StorageDead(_4); - goto -> bb6; - } - - bb6: { return; } - bb7: { + bb4: { unreachable; } } diff --git a/tests/mir-opt/reference_prop.debuginfo.ReferencePropagation.diff b/tests/mir-opt/reference_prop.debuginfo.ReferencePropagation.diff index 1648f5dd8ca..84350b0dc51 100644 --- a/tests/mir-opt/reference_prop.debuginfo.ReferencePropagation.diff +++ b/tests/mir-opt/reference_prop.debuginfo.ReferencePropagation.diff @@ -67,10 +67,14 @@ StorageLive(_7); _7 = Option::<i32>::Some(const 0_i32); _8 = discriminant(_7); - switchInt(move _8) -> [0: bb3, 1: bb1, otherwise: bb2]; + switchInt(move _8) -> [0: bb3, 1: bb2, otherwise: bb1]; } bb1: { + unreachable; + } + + bb2: { StorageLive(_9); _27 = const _; _9 = &(((*_27) as Some).0: i32); @@ -79,10 +83,6 @@ goto -> bb4; } - bb2: { - unreachable; - } - bb3: { - _6 = const (); goto -> bb4; diff --git a/tests/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.panic-abort.diff b/tests/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.panic-abort.diff index 8804e671527..14762b9c40f 100644 --- a/tests/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.panic-abort.diff +++ b/tests/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.panic-abort.diff @@ -55,10 +55,14 @@ bb3: { - StorageDead(_8); _10 = discriminant(_7); - switchInt(move _10) -> [0: bb6, 1: bb4, otherwise: bb5]; + switchInt(move _10) -> [0: bb6, 1: bb5, otherwise: bb4]; } bb4: { + unreachable; + } + + bb5: { - StorageLive(_12); _12 = ((_7 as Some).0: i32); - StorageLive(_13); @@ -74,10 +78,6 @@ goto -> bb2; } - bb5: { - unreachable; - } - bb6: { _0 = const (); - StorageDead(_9); diff --git a/tests/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.panic-unwind.diff b/tests/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.panic-unwind.diff index faaebc300ef..24797424b5c 100644 --- a/tests/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.panic-unwind.diff +++ b/tests/mir-opt/remove_storage_markers.main.RemoveStorageMarkers.panic-unwind.diff @@ -55,10 +55,14 @@ bb3: { - StorageDead(_8); _10 = discriminant(_7); - switchInt(move _10) -> [0: bb6, 1: bb4, otherwise: bb5]; + switchInt(move _10) -> [0: bb6, 1: bb5, otherwise: bb4]; } bb4: { + unreachable; + } + + bb5: { - StorageLive(_12); _12 = ((_7 as Some).0: i32); - StorageLive(_13); @@ -74,10 +78,6 @@ goto -> bb2; } - bb5: { - unreachable; - } - bb6: { _0 = const (); - StorageDead(_9); diff --git a/tests/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff b/tests/mir-opt/separate_const_switch.identity.JumpThreading.diff index d2731615284..ab3d91ab918 100644 --- a/tests/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff +++ b/tests/mir-opt/separate_const_switch.identity.JumpThreading.diff @@ -1,5 +1,5 @@ -- // MIR for `identity` before SeparateConstSwitch -+ // MIR for `identity` after SeparateConstSwitch +- // MIR for `identity` before JumpThreading ++ // MIR for `identity` after JumpThreading fn identity(_1: Result<i32, i32>) -> Result<i32, i32> { debug x => _1; @@ -79,7 +79,8 @@ StorageDead(_8); StorageDead(_3); _4 = discriminant(_2); - switchInt(move _4) -> [0: bb1, 1: bb2, otherwise: bb6]; +- switchInt(move _4) -> [0: bb1, 1: bb2, otherwise: bb6]; ++ goto -> bb1; } bb4: { @@ -88,7 +89,8 @@ _11 = Result::<Infallible, i32>::Err(_10); _2 = ControlFlow::<Result<Infallible, i32>, i32>::Break(move _11); StorageDead(_11); - goto -> bb3; +- goto -> bb3; ++ goto -> bb7; } bb5: { @@ -99,6 +101,15 @@ bb6: { unreachable; ++ } ++ ++ bb7: { ++ StorageDead(_10); ++ StorageDead(_9); ++ StorageDead(_8); ++ StorageDead(_3); ++ _4 = discriminant(_2); ++ goto -> bb2; } } diff --git a/tests/mir-opt/separate_const_switch.rs b/tests/mir-opt/separate_const_switch.rs index 3f43cdf4350..bad61d97475 100644 --- a/tests/mir-opt/separate_const_switch.rs +++ b/tests/mir-opt/separate_const_switch.rs @@ -6,7 +6,7 @@ use std::ops::ControlFlow; -// EMIT_MIR separate_const_switch.too_complex.SeparateConstSwitch.diff +// EMIT_MIR separate_const_switch.too_complex.JumpThreading.diff fn too_complex(x: Result<i32, usize>) -> Option<i32> { // The pass should break the outer match into // two blocks that only have one parent each. @@ -23,7 +23,7 @@ fn too_complex(x: Result<i32, usize>) -> Option<i32> { } } -// EMIT_MIR separate_const_switch.identity.SeparateConstSwitch.diff +// EMIT_MIR separate_const_switch.identity.JumpThreading.diff fn identity(x: Result<i32, i32>) -> Result<i32, i32> { Ok(x?) } diff --git a/tests/mir-opt/separate_const_switch.too_complex.SeparateConstSwitch.diff b/tests/mir-opt/separate_const_switch.too_complex.JumpThreading.diff index 294bfa661cf..1ac527e9338 100644 --- a/tests/mir-opt/separate_const_switch.too_complex.SeparateConstSwitch.diff +++ b/tests/mir-opt/separate_const_switch.too_complex.JumpThreading.diff @@ -1,5 +1,5 @@ -- // MIR for `too_complex` before SeparateConstSwitch -+ // MIR for `too_complex` after SeparateConstSwitch +- // MIR for `too_complex` before JumpThreading ++ // MIR for `too_complex` after JumpThreading fn too_complex(_1: Result<i32, usize>) -> Option<i32> { debug x => _1; @@ -33,7 +33,8 @@ bb1: { _5 = ((_1 as Err).0: usize); _2 = ControlFlow::<usize, i32>::Break(_5); - goto -> bb3; +- goto -> bb3; ++ goto -> bb8; } bb2: { @@ -44,7 +45,8 @@ bb3: { _6 = discriminant(_2); - switchInt(move _6) -> [0: bb5, 1: bb4, otherwise: bb7]; +- switchInt(move _6) -> [0: bb5, 1: bb4, otherwise: bb7]; ++ goto -> bb5; } bb4: { @@ -68,6 +70,11 @@ bb7: { unreachable; ++ } ++ ++ bb8: { ++ _6 = discriminant(_2); ++ goto -> bb4; } } diff --git a/tests/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals-before-const-prop.diff b/tests/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals-before-const-prop.diff index 9ff32b26b77..5611d679b78 100644 --- a/tests/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals-before-const-prop.diff +++ b/tests/mir-opt/simplify_locals_removes_unused_discriminant_reads.map.SimplifyLocals-before-const-prop.diff @@ -18,10 +18,14 @@ - _5 = const false; - _5 = const true; _2 = discriminant(_1); - switchInt(move _2) -> [0: bb3, 1: bb1, otherwise: bb2]; + switchInt(move _2) -> [0: bb3, 1: bb2, otherwise: bb1]; } bb1: { + unreachable; + } + + bb2: { StorageLive(_3); _3 = move ((_1 as Some).0: std::boxed::Box<()>); StorageLive(_4); @@ -32,10 +36,6 @@ goto -> bb4; } - bb2: { - unreachable; - } - bb3: { _0 = Option::<Box<()>>::None; goto -> bb4; diff --git a/tests/mir-opt/uninhabited_enum_branching.byref.UninhabitedEnumBranching.diff b/tests/mir-opt/uninhabited_enum_branching.byref.UninhabitedEnumBranching.diff index 7919450cdc5..5a3544f8538 100644 --- a/tests/mir-opt/uninhabited_enum_branching.byref.UninhabitedEnumBranching.diff +++ b/tests/mir-opt/uninhabited_enum_branching.byref.UninhabitedEnumBranching.diff @@ -30,11 +30,15 @@ StorageLive(_4); _4 = &(_1.1: Test3); _5 = discriminant((*_4)); -- switchInt(move _5) -> [0: bb3, 1: bb4, 2: bb5, 3: bb1, otherwise: bb2]; -+ switchInt(move _5) -> [0: bb12, 1: bb12, 2: bb5, 3: bb1, otherwise: bb12]; +- switchInt(move _5) -> [0: bb3, 1: bb4, 2: bb5, 3: bb2, otherwise: bb1]; ++ switchInt(move _5) -> [0: bb12, 1: bb12, 2: bb5, 3: bb2, otherwise: bb12]; } bb1: { + unreachable; + } + + bb2: { StorageLive(_8); _8 = const "D"; _3 = &(*_8); @@ -42,10 +46,6 @@ goto -> bb6; } - bb2: { - unreachable; - } - bb3: { _3 = const "A(Empty)"; goto -> bb6; @@ -72,7 +72,7 @@ StorageDead(_3); StorageLive(_9); _10 = discriminant((_1.1: Test3)); -- switchInt(move _10) -> [0: bb8, 1: bb9, 2: bb10, 3: bb7, otherwise: bb2]; +- switchInt(move _10) -> [0: bb8, 1: bb9, 2: bb10, 3: bb7, otherwise: bb1]; + switchInt(move _10) -> [0: bb12, 1: bb12, 2: bb10, 3: bb7, otherwise: bb12]; } diff --git a/tests/mir-opt/uninhabited_enum_branching.custom_discriminant.UninhabitedEnumBranching.diff b/tests/mir-opt/uninhabited_enum_branching.custom_discriminant.UninhabitedEnumBranching.diff index 5e15298a78c..121374553ed 100644 --- a/tests/mir-opt/uninhabited_enum_branching.custom_discriminant.UninhabitedEnumBranching.diff +++ b/tests/mir-opt/uninhabited_enum_branching.custom_discriminant.UninhabitedEnumBranching.diff @@ -13,11 +13,15 @@ StorageLive(_2); _2 = Test2::D; _3 = discriminant(_2); -- switchInt(move _3) -> [4: bb3, 5: bb1, otherwise: bb2]; -+ switchInt(move _3) -> [4: bb3, 5: bb1, otherwise: bb5]; +- switchInt(move _3) -> [4: bb3, 5: bb2, otherwise: bb1]; ++ switchInt(move _3) -> [4: bb3, 5: bb2, otherwise: bb5]; } bb1: { + unreachable; + } + + bb2: { StorageLive(_4); _4 = const "E"; _1 = &(*_4); @@ -25,10 +29,6 @@ goto -> bb4; } - bb2: { - unreachable; - } - bb3: { _1 = const "D"; goto -> bb4; diff --git a/tests/mir-opt/uninhabited_enum_branching.rs b/tests/mir-opt/uninhabited_enum_branching.rs index 60389117b16..65552fb058a 100644 --- a/tests/mir-opt/uninhabited_enum_branching.rs +++ b/tests/mir-opt/uninhabited_enum_branching.rs @@ -32,7 +32,7 @@ struct Plop { fn simple() { // CHECK-LABEL: fn simple( // CHECK: [[discr:_.*]] = discriminant( - // CHECK: switchInt(move [[discr]]) -> [0: [[unreachable:bb.*]], 1: [[unreachable]], 2: bb1, otherwise: [[unreachable]]]; + // CHECK: switchInt(move [[discr]]) -> [0: [[unreachable:bb.*]], 1: [[unreachable]], 2: bb2, otherwise: [[unreachable]]]; // CHECK: [[unreachable]]: { // CHECK-NEXT: unreachable; match Test1::C { @@ -46,7 +46,7 @@ fn simple() { fn custom_discriminant() { // CHECK-LABEL: fn custom_discriminant( // CHECK: [[discr:_.*]] = discriminant( - // CHECK: switchInt(move [[discr]]) -> [4: bb3, 5: bb1, otherwise: bb5]; + // CHECK: switchInt(move [[discr]]) -> [4: bb3, 5: bb2, otherwise: bb5]; // CHECK: bb5: { // CHECK-NEXT: unreachable; match Test2::D { @@ -61,7 +61,7 @@ fn byref() { let plop = Plop { xx: 51, test3: Test3::C }; // CHECK: [[ref_discr:_.*]] = discriminant((* - // CHECK: switchInt(move [[ref_discr]]) -> [0: [[unreachable:bb.*]], 1: [[unreachable]], 2: bb5, 3: bb1, otherwise: [[unreachable]]]; + // CHECK: switchInt(move [[ref_discr]]) -> [0: [[unreachable:bb.*]], 1: [[unreachable]], 2: bb5, 3: bb2, otherwise: [[unreachable]]]; match &plop.test3 { Test3::A(_) => "A(Empty)", Test3::B(_) => "B(Empty)", diff --git a/tests/mir-opt/uninhabited_enum_branching.simple.UninhabitedEnumBranching.diff b/tests/mir-opt/uninhabited_enum_branching.simple.UninhabitedEnumBranching.diff index 410db79802e..6ce61e15287 100644 --- a/tests/mir-opt/uninhabited_enum_branching.simple.UninhabitedEnumBranching.diff +++ b/tests/mir-opt/uninhabited_enum_branching.simple.UninhabitedEnumBranching.diff @@ -14,11 +14,15 @@ StorageLive(_2); _2 = Test1::C; _3 = discriminant(_2); -- switchInt(move _3) -> [0: bb3, 1: bb4, 2: bb1, otherwise: bb2]; -+ switchInt(move _3) -> [0: bb6, 1: bb6, 2: bb1, otherwise: bb6]; +- switchInt(move _3) -> [0: bb3, 1: bb4, 2: bb2, otherwise: bb1]; ++ switchInt(move _3) -> [0: bb6, 1: bb6, 2: bb2, otherwise: bb6]; } bb1: { + unreachable; + } + + bb2: { StorageLive(_5); _5 = const "C"; _1 = &(*_5); @@ -26,10 +30,6 @@ goto -> bb5; } - bb2: { - unreachable; - } - bb3: { _1 = const "A(Empty)"; goto -> bb5; diff --git a/tests/mir-opt/unnamed-fields/field_access.bar.SimplifyCfg-initial.after.mir b/tests/mir-opt/unnamed-fields/field_access.bar.SimplifyCfg-initial.after.mir new file mode 100644 index 00000000000..8edc7b5df88 --- /dev/null +++ b/tests/mir-opt/unnamed-fields/field_access.bar.SimplifyCfg-initial.after.mir @@ -0,0 +1,61 @@ +// MIR for `bar` after SimplifyCfg-initial + +fn bar(_1: Bar) -> () { + debug bar => _1; + let mut _0: (); + let _2: (); + let mut _3: u8; + let _4: (); + let mut _5: i8; + let _6: (); + let mut _7: bool; + let _8: (); + let mut _9: [u8; 1]; + scope 1 { + } + + bb0: { + StorageLive(_2); + StorageLive(_3); + _3 = (_1.0: u8); + _2 = access::<u8>(move _3) -> [return: bb1, unwind: bb5]; + } + + bb1: { + StorageDead(_3); + StorageDead(_2); + StorageLive(_4); + StorageLive(_5); + _5 = ((_1.1: Bar::{anon_adt#0}).0: i8); + _4 = access::<i8>(move _5) -> [return: bb2, unwind: bb5]; + } + + bb2: { + StorageDead(_5); + StorageDead(_4); + StorageLive(_6); + StorageLive(_7); + _7 = ((_1.1: Bar::{anon_adt#0}).1: bool); + _6 = access::<bool>(move _7) -> [return: bb3, unwind: bb5]; + } + + bb3: { + StorageDead(_7); + StorageDead(_6); + StorageLive(_8); + StorageLive(_9); + _9 = (((_1.2: Bar::{anon_adt#1}).0: Bar::{anon_adt#1}::{anon_adt#0}).0: [u8; 1]); + _8 = access::<[u8; 1]>(move _9) -> [return: bb4, unwind: bb5]; + } + + bb4: { + StorageDead(_9); + StorageDead(_8); + _0 = const (); + return; + } + + bb5 (cleanup): { + resume; + } +} diff --git a/tests/mir-opt/unnamed-fields/field_access.foo.SimplifyCfg-initial.after.mir b/tests/mir-opt/unnamed-fields/field_access.foo.SimplifyCfg-initial.after.mir new file mode 100644 index 00000000000..d48a969f06e --- /dev/null +++ b/tests/mir-opt/unnamed-fields/field_access.foo.SimplifyCfg-initial.after.mir @@ -0,0 +1,59 @@ +// MIR for `foo` after SimplifyCfg-initial + +fn foo(_1: Foo) -> () { + debug foo => _1; + let mut _0: (); + let _2: (); + let mut _3: u8; + let _4: (); + let mut _5: i8; + let _6: (); + let mut _7: bool; + let _8: (); + let mut _9: [u8; 1]; + + bb0: { + StorageLive(_2); + StorageLive(_3); + _3 = (_1.0: u8); + _2 = access::<u8>(move _3) -> [return: bb1, unwind: bb5]; + } + + bb1: { + StorageDead(_3); + StorageDead(_2); + StorageLive(_4); + StorageLive(_5); + _5 = ((_1.1: Foo::{anon_adt#0}).0: i8); + _4 = access::<i8>(move _5) -> [return: bb2, unwind: bb5]; + } + + bb2: { + StorageDead(_5); + StorageDead(_4); + StorageLive(_6); + StorageLive(_7); + _7 = ((_1.1: Foo::{anon_adt#0}).1: bool); + _6 = access::<bool>(move _7) -> [return: bb3, unwind: bb5]; + } + + bb3: { + StorageDead(_7); + StorageDead(_6); + StorageLive(_8); + StorageLive(_9); + _9 = (((_1.2: Foo::{anon_adt#1}).0: Foo::{anon_adt#1}::{anon_adt#0}).0: [u8; 1]); + _8 = access::<[u8; 1]>(move _9) -> [return: bb4, unwind: bb5]; + } + + bb4: { + StorageDead(_9); + StorageDead(_8); + _0 = const (); + return; + } + + bb5 (cleanup): { + resume; + } +} diff --git a/tests/mir-opt/unnamed-fields/field_access.rs b/tests/mir-opt/unnamed-fields/field_access.rs new file mode 100644 index 00000000000..3d33ca26875 --- /dev/null +++ b/tests/mir-opt/unnamed-fields/field_access.rs @@ -0,0 +1,56 @@ +// skip-filecheck +// EMIT_MIR field_access.foo.SimplifyCfg-initial.after.mir +// EMIT_MIR field_access.bar.SimplifyCfg-initial.after.mir + +#![allow(incomplete_features)] +#![feature(unnamed_fields)] + +#[repr(C)] +struct Foo { + a: u8, + _: struct { + b: i8, + c: bool, + }, + _: struct { + _: struct { + d: [u8; 1], + } + } +} + +#[repr(C)] +union Bar { + a: u8, + _: union { + b: i8, + c: bool, + }, + _: union { + _: union { + d: [u8; 1], + } + } +} + + +fn access<T>(_: T) {} + +fn foo(foo: Foo) { + access(foo.a); + access(foo.b); + access(foo.c); + access(foo.d); +} + +fn bar(bar: Bar) { + unsafe { + access(bar.a); + access(bar.b); + access(bar.c); + access(bar.d); + } +} + + +fn main() {} diff --git a/tests/mir-opt/unreachable.as_match.UnreachablePropagation.panic-abort.diff b/tests/mir-opt/unreachable.as_match.UnreachablePropagation.panic-abort.diff index f6e594ffac7..da7a2bd10e0 100644 --- a/tests/mir-opt/unreachable.as_match.UnreachablePropagation.panic-abort.diff +++ b/tests/mir-opt/unreachable.as_match.UnreachablePropagation.panic-abort.diff @@ -19,20 +19,20 @@ bb1: { _2 = discriminant(_1); -- switchInt(move _2) -> [0: bb4, 1: bb2, otherwise: bb3]; +- switchInt(move _2) -> [0: bb4, 1: bb3, otherwise: bb2]; + _5 = Eq(_2, const 0_isize); + assume(move _5); + goto -> bb4; } bb2: { -- StorageLive(_3); -- _3 = move ((_1 as Some).0: Empty); -- StorageLive(_4); unreachable; } bb3: { +- StorageLive(_3); +- _3 = move ((_1 as Some).0: Empty); +- StorageLive(_4); unreachable; } diff --git a/tests/mir-opt/unreachable.as_match.UnreachablePropagation.panic-unwind.diff b/tests/mir-opt/unreachable.as_match.UnreachablePropagation.panic-unwind.diff index 2813d64672e..a2121fc684f 100644 --- a/tests/mir-opt/unreachable.as_match.UnreachablePropagation.panic-unwind.diff +++ b/tests/mir-opt/unreachable.as_match.UnreachablePropagation.panic-unwind.diff @@ -19,20 +19,20 @@ bb1: { _2 = discriminant(_1); -- switchInt(move _2) -> [0: bb4, 1: bb2, otherwise: bb3]; +- switchInt(move _2) -> [0: bb4, 1: bb3, otherwise: bb2]; + _5 = Eq(_2, const 0_isize); + assume(move _5); + goto -> bb4; } bb2: { -- StorageLive(_3); -- _3 = move ((_1 as Some).0: Empty); -- StorageLive(_4); unreachable; } bb3: { +- StorageLive(_3); +- _3 = move ((_1 as Some).0: Empty); +- StorageLive(_4); unreachable; } diff --git a/tests/rustdoc-ui/normalize-in-inlined-type-alias.rs b/tests/rustdoc-ui/normalize-in-inlined-type-alias.rs new file mode 100644 index 00000000000..45e04a70c09 --- /dev/null +++ b/tests/rustdoc-ui/normalize-in-inlined-type-alias.rs @@ -0,0 +1,14 @@ +// check-pass +// compile-flags: -Znormalize-docs + +trait Woo<T> { + type Assoc; +} + +impl<T> Woo<T> for () { + type Assoc = (); +} + +type Alias<P> = <() as Woo<P>>::Assoc; + +pub fn hello<S>() -> Alias<S> {} diff --git a/tests/rustdoc/glob-reexport-attribute-merge-doc-auto-cfg.rs b/tests/rustdoc/glob-reexport-attribute-merge-doc-auto-cfg.rs new file mode 100644 index 00000000000..3e3e602eb1b --- /dev/null +++ b/tests/rustdoc/glob-reexport-attribute-merge-doc-auto-cfg.rs @@ -0,0 +1,29 @@ +// This test ensures that non-glob reexports don't get their attributes merge with +// the reexported item whereas glob reexports do with the `doc_auto_cfg` feature. + +#![crate_name = "foo"] +#![feature(doc_auto_cfg)] + +// @has 'foo/index.html' +// There are two items. +// @count - '//*[@class="item-table"]//div[@class="item-name"]' 2 +// Only one of them should have an attribute. +// @count - '//*[@class="item-table"]//div[@class="item-name"]/*[@class="stab portability"]' 1 + +mod a { + #[cfg(not(feature = "a"))] + pub struct Test1; +} + +mod b { + #[cfg(not(feature = "a"))] + pub struct Test2; +} + +// @has 'foo/struct.Test1.html' +// @count - '//*[@id="main-content"]/*[@class="item-info"]' 1 +// @has - '//*[@id="main-content"]/*[@class="item-info"]' 'Available on non-crate feature a only.' +pub use a::*; +// @has 'foo/struct.Test2.html' +// @count - '//*[@id="main-content"]/*[@class="item-info"]' 0 +pub use b::Test2; diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr index 67257c28b6e..2032b8a972a 100644 --- a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr @@ -2,7 +2,7 @@ error: unsupported type attribute for diagnostic derive enum --> $DIR/diagnostic-derive.rs:47:1 | LL | #[diag(no_crate_example, code = E0123)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ error: diagnostic slug not specified --> $DIR/diagnostic-derive.rs:50:5 @@ -24,27 +24,21 @@ error: `#[nonsense(...)]` is not a valid attribute --> $DIR/diagnostic-derive.rs:63:1 | LL | #[nonsense(no_crate_example, code = E0123)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ error: diagnostic slug not specified --> $DIR/diagnostic-derive.rs:63:1 | -LL | / #[nonsense(no_crate_example, code = E0123)] -LL | | -LL | | -LL | | -LL | | struct InvalidStructAttr {} - | |___________________________^ +LL | #[nonsense(no_crate_example, code = E0123)] + | ^ | = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: diagnostic slug not specified --> $DIR/diagnostic-derive.rs:70:1 | -LL | / #[diag(code = E0123)] -LL | | -LL | | struct InvalidLitNestedAttr {} - | |______________________________^ +LL | #[diag(code = E0123)] + | ^ | = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` @@ -57,11 +51,8 @@ LL | #[diag(nonsense("foo"), code = E0123, slug = "foo")] error: diagnostic slug not specified --> $DIR/diagnostic-derive.rs:80:1 | -LL | / #[diag(nonsense("foo"), code = E0123, slug = "foo")] -LL | | -LL | | -LL | | struct InvalidNestedStructAttr1 {} - | |__________________________________^ +LL | #[diag(nonsense("foo"), code = E0123, slug = "foo")] + | ^ | = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` @@ -76,11 +67,8 @@ LL | #[diag(nonsense = "...", code = E0123, slug = "foo")] error: diagnostic slug not specified --> $DIR/diagnostic-derive.rs:86:1 | -LL | / #[diag(nonsense = "...", code = E0123, slug = "foo")] -LL | | -LL | | -LL | | struct InvalidNestedStructAttr2 {} - | |__________________________________^ +LL | #[diag(nonsense = "...", code = E0123, slug = "foo")] + | ^ | = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` @@ -95,11 +83,8 @@ LL | #[diag(nonsense = 4, code = E0123, slug = "foo")] error: diagnostic slug not specified --> $DIR/diagnostic-derive.rs:92:1 | -LL | / #[diag(nonsense = 4, code = E0123, slug = "foo")] -LL | | -LL | | -LL | | struct InvalidNestedStructAttr3 {} - | |__________________________________^ +LL | #[diag(nonsense = 4, code = E0123, slug = "foo")] + | ^ | = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` @@ -115,7 +100,7 @@ error: `#[suggestion = ...]` is not a valid attribute --> $DIR/diagnostic-derive.rs:105:5 | LL | #[suggestion = "bar"] - | ^^^^^^^^^^^^^^^^^^^^^ + | ^ error: specified multiple times --> $DIR/diagnostic-derive.rs:112:8 @@ -163,17 +148,15 @@ error: diagnostic slug not specified --> $DIR/diagnostic-derive.rs:128:1 | LL | struct KindNotProvided {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^ | = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` error: diagnostic slug not specified --> $DIR/diagnostic-derive.rs:131:1 | -LL | / #[diag(code = E0123)] -LL | | -LL | | struct SlugNotProvided {} - | |_________________________^ +LL | #[diag(code = E0123)] + | ^ | = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` @@ -181,19 +164,19 @@ error: the `#[primary_span]` attribute can only be applied to fields of type `Sp --> $DIR/diagnostic-derive.rs:142:5 | LL | #[primary_span] - | ^^^^^^^^^^^^^^^ + | ^ error: `#[nonsense]` is not a valid attribute --> $DIR/diagnostic-derive.rs:150:5 | LL | #[nonsense] - | ^^^^^^^^^^^ + | ^ error: the `#[label(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` --> $DIR/diagnostic-derive.rs:167:5 | LL | #[label(no_crate_label)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ error: `name` doesn't refer to a field on this type --> $DIR/diagnostic-derive.rs:175:46 @@ -223,13 +206,13 @@ error: the `#[label(...)]` attribute can only be applied to fields of type `Span --> $DIR/diagnostic-derive.rs:210:5 | LL | #[label(no_crate_label)] - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ error: suggestion without `code = "..."` --> $DIR/diagnostic-derive.rs:229:5 | LL | #[suggestion(no_crate_suggestion)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ error: invalid nested attribute --> $DIR/diagnostic-derive.rs:237:18 @@ -243,7 +226,7 @@ error: suggestion without `code = "..."` --> $DIR/diagnostic-derive.rs:237:5 | LL | #[suggestion(nonsense = "bar")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ error: invalid nested attribute --> $DIR/diagnostic-derive.rs:246:18 @@ -257,15 +240,13 @@ error: suggestion without `code = "..."` --> $DIR/diagnostic-derive.rs:246:5 | LL | #[suggestion(msg = "bar")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ error: wrong field type for suggestion --> $DIR/diagnostic-derive.rs:269:5 | -LL | / #[suggestion(no_crate_suggestion, code = "This is suggested code")] -LL | | -LL | | suggestion: Applicability, - | |_____________________________^ +LL | #[suggestion(no_crate_suggestion, code = "This is suggested code")] + | ^ | = help: `#[suggestion(...)]` should be applied to fields of type `Span` or `(Span, Applicability)` @@ -297,13 +278,13 @@ error: `#[label = ...]` is not a valid attribute --> $DIR/diagnostic-derive.rs:300:5 | LL | #[label = "bar"] - | ^^^^^^^^^^^^^^^^ + | ^ error: specified multiple times --> $DIR/diagnostic-derive.rs:451:5 | LL | #[suggestion(no_crate_suggestion, code = "...", applicability = "maybe-incorrect")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ | note: previously specified here --> $DIR/diagnostic-derive.rs:453:24 @@ -321,7 +302,7 @@ error: the `#[help(...)]` attribute can only be applied to fields of type `Span` --> $DIR/diagnostic-derive.rs:526:5 | LL | #[help(no_crate_help)] - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^ error: a diagnostic slug must be the first argument to the attribute --> $DIR/diagnostic-derive.rs:535:32 @@ -345,7 +326,7 @@ error: `#[primary_span]` is not a valid attribute --> $DIR/diagnostic-derive.rs:563:5 | LL | #[primary_span] - | ^^^^^^^^^^^^^^^ + | ^ | = help: the `primary_span` field attribute is not valid for lint diagnostics @@ -353,17 +334,13 @@ error: `#[error(...)]` is not a valid attribute --> $DIR/diagnostic-derive.rs:583:1 | LL | #[error(no_crate_example, code = E0123)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ error: diagnostic slug not specified --> $DIR/diagnostic-derive.rs:583:1 | -LL | / #[error(no_crate_example, code = E0123)] -LL | | -LL | | -LL | | -LL | | struct ErrorAttribute {} - | |________________________^ +LL | #[error(no_crate_example, code = E0123)] + | ^ | = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` @@ -371,17 +348,13 @@ error: `#[warn_(...)]` is not a valid attribute --> $DIR/diagnostic-derive.rs:590:1 | LL | #[warn_(no_crate_example, code = E0123)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ error: diagnostic slug not specified --> $DIR/diagnostic-derive.rs:590:1 | -LL | / #[warn_(no_crate_example, code = E0123)] -LL | | -LL | | -LL | | -LL | | struct WarnAttribute {} - | |_______________________^ +LL | #[warn_(no_crate_example, code = E0123)] + | ^ | = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` @@ -389,17 +362,13 @@ error: `#[lint(...)]` is not a valid attribute --> $DIR/diagnostic-derive.rs:597:1 | LL | #[lint(no_crate_example, code = E0123)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ error: diagnostic slug not specified --> $DIR/diagnostic-derive.rs:597:1 | -LL | / #[lint(no_crate_example, code = E0123)] -LL | | -LL | | -LL | | -LL | | struct LintAttributeOnSessionDiag {} - | |____________________________________^ +LL | #[lint(no_crate_example, code = E0123)] + | ^ | = help: specify the slug as the first argument to the `#[diag(...)]` attribute, such as `#[diag(hir_analysis_example_error)]` @@ -407,26 +376,21 @@ error: `#[lint(...)]` is not a valid attribute --> $DIR/diagnostic-derive.rs:604:1 | LL | #[lint(no_crate_example, code = E0123)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ error: `#[lint(...)]` is not a valid attribute --> $DIR/diagnostic-derive.rs:604:1 | LL | #[lint(no_crate_example, code = E0123)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: diagnostic slug not specified --> $DIR/diagnostic-derive.rs:604:1 | -LL | / #[lint(no_crate_example, code = E0123)] -LL | | -LL | | -LL | | -LL | | -LL | | struct LintAttributeOnLintDiag {} - | |_________________________________^ +LL | #[lint(no_crate_example, code = E0123)] + | ^ | = help: specify the slug as the first argument to the attribute, such as `#[diag(compiletest_example)]` @@ -462,13 +426,13 @@ error: suggestion without `code = "..."` --> $DIR/diagnostic-derive.rs:638:5 | LL | #[suggestion(no_crate_suggestion)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ error: `#[multipart_suggestion(...)]` is not a valid attribute --> $DIR/diagnostic-derive.rs:645:1 | LL | #[multipart_suggestion(no_crate_suggestion)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ | = help: consider creating a `Subdiagnostic` instead @@ -476,7 +440,7 @@ error: `#[multipart_suggestion(...)]` is not a valid attribute --> $DIR/diagnostic-derive.rs:648:1 | LL | #[multipart_suggestion()] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ | = help: consider creating a `Subdiagnostic` instead @@ -484,7 +448,7 @@ error: `#[multipart_suggestion(...)]` is not a valid attribute --> $DIR/diagnostic-derive.rs:652:5 | LL | #[multipart_suggestion(no_crate_suggestion)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ | = help: consider creating a `Subdiagnostic` instead @@ -492,7 +456,7 @@ error: `#[suggestion(...)]` is not a valid attribute --> $DIR/diagnostic-derive.rs:660:1 | LL | #[suggestion(no_crate_suggestion, code = "...")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ | = help: `#[label]` and `#[suggestion]` can only be applied to fields @@ -500,7 +464,7 @@ error: `#[label]` is not a valid attribute --> $DIR/diagnostic-derive.rs:669:1 | LL | #[label] - | ^^^^^^^^ + | ^ | = help: `#[label]` and `#[suggestion]` can only be applied to fields @@ -508,31 +472,31 @@ error: `eager` is the only supported nested attribute for `subdiagnostic` --> $DIR/diagnostic-derive.rs:703:7 | LL | #[subdiagnostic(bad)] - | ^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^ error: `#[subdiagnostic = ...]` is not a valid attribute --> $DIR/diagnostic-derive.rs:711:5 | LL | #[subdiagnostic = "bad"] - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ error: `eager` is the only supported nested attribute for `subdiagnostic` --> $DIR/diagnostic-derive.rs:719:7 | LL | #[subdiagnostic(bad, bad)] - | ^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^ error: `eager` is the only supported nested attribute for `subdiagnostic` --> $DIR/diagnostic-derive.rs:727:7 | LL | #[subdiagnostic("bad")] - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^ error: `#[subdiagnostic(...)]` is not a valid attribute --> $DIR/diagnostic-derive.rs:735:5 | LL | #[subdiagnostic(eager)] - | ^^^^^^^^^^^^^^^^^^^^^^^ + | ^ | = help: eager subdiagnostics are not supported on lints @@ -552,7 +516,7 @@ error: `#[suggestion(...)]` is not a valid attribute --> $DIR/diagnostic-derive.rs:825:5 | LL | #[suggestion(no_crate_suggestion, code = "")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ | = note: `#[suggestion(...)]` applied to `Vec` field is ambiguous = help: to show a suggestion consisting of multiple parts, use a `Subdiagnostic` annotated with `#[multipart_suggestion(...)]` diff --git a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr index 80bee3bd6e6..fccf3757dbe 100644 --- a/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr +++ b/tests/ui-fulldeps/session-diagnostic/subdiagnostic-derive.stderr @@ -1,30 +1,26 @@ error: label without `#[primary_span]` field --> $DIR/subdiagnostic-derive.rs:51:1 | -LL | / #[label(no_crate_example)] -LL | | -LL | | struct C { -LL | | var: String, -LL | | } - | |_^ +LL | #[label(no_crate_example)] + | ^ error: diagnostic slug must be first argument of a `#[label(...)]` attribute --> $DIR/subdiagnostic-derive.rs:58:1 | LL | #[label] - | ^^^^^^^^ + | ^ error: `#[foo]` is not a valid attribute --> $DIR/subdiagnostic-derive.rs:67:1 | LL | #[foo] - | ^^^^^^ + | ^ error: `#[label = ...]` is not a valid attribute --> $DIR/subdiagnostic-derive.rs:77:1 | LL | #[label = "..."] - | ^^^^^^^^^^^^^^^^ + | ^ error: only `no_span` is a valid nested attribute --> $DIR/subdiagnostic-derive.rs:86:9 @@ -36,7 +32,7 @@ error: diagnostic slug must be first argument of a `#[label(...)]` attribute --> $DIR/subdiagnostic-derive.rs:86:1 | LL | #[label(bug = "...")] - | ^^^^^^^^^^^^^^^^^^^^^ + | ^ error: only `no_span` is a valid nested attribute --> $DIR/subdiagnostic-derive.rs:106:9 @@ -48,7 +44,7 @@ error: diagnostic slug must be first argument of a `#[label(...)]` attribute --> $DIR/subdiagnostic-derive.rs:106:1 | LL | #[label(slug = 4)] - | ^^^^^^^^^^^^^^^^^^ + | ^ error: only `no_span` is a valid nested attribute --> $DIR/subdiagnostic-derive.rs:116:9 @@ -60,13 +56,13 @@ error: diagnostic slug must be first argument of a `#[label(...)]` attribute --> $DIR/subdiagnostic-derive.rs:116:1 | LL | #[label(slug("..."))] - | ^^^^^^^^^^^^^^^^^^^^^ + | ^ error: diagnostic slug must be first argument of a `#[label(...)]` attribute --> $DIR/subdiagnostic-derive.rs:136:1 | LL | #[label()] - | ^^^^^^^^^^ + | ^ error: only `no_span` is a valid nested attribute --> $DIR/subdiagnostic-derive.rs:145:27 @@ -84,31 +80,31 @@ error: unsupported type attribute for subdiagnostic enum --> $DIR/subdiagnostic-derive.rs:163:1 | LL | #[foo] - | ^^^^^^ + | ^ error: `#[bar]` is not a valid attribute --> $DIR/subdiagnostic-derive.rs:177:5 | LL | #[bar] - | ^^^^^^ + | ^ error: `#[bar = ...]` is not a valid attribute --> $DIR/subdiagnostic-derive.rs:189:5 | LL | #[bar = "..."] - | ^^^^^^^^^^^^^^ + | ^ error: `#[bar = ...]` is not a valid attribute --> $DIR/subdiagnostic-derive.rs:201:5 | LL | #[bar = 4] - | ^^^^^^^^^^ + | ^ error: `#[bar(...)]` is not a valid attribute --> $DIR/subdiagnostic-derive.rs:213:5 | LL | #[bar("...")] - | ^^^^^^^^^^^^^ + | ^ error: only `no_span` is a valid nested attribute --> $DIR/subdiagnostic-derive.rs:225:13 @@ -120,37 +116,31 @@ error: diagnostic slug must be first argument of a `#[label(...)]` attribute --> $DIR/subdiagnostic-derive.rs:225:5 | LL | #[label(code = "...")] - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^ error: the `#[primary_span]` attribute can only be applied to fields of type `Span` or `MultiSpan` --> $DIR/subdiagnostic-derive.rs:254:5 | LL | #[primary_span] - | ^^^^^^^^^^^^^^^ + | ^ error: label without `#[primary_span]` field --> $DIR/subdiagnostic-derive.rs:251:1 | -LL | / #[label(no_crate_example)] -LL | | -LL | | struct W { -LL | | #[primary_span] -LL | | -LL | | span: String, -LL | | } - | |_^ +LL | #[label(no_crate_example)] + | ^ error: `#[applicability]` is only valid on suggestions --> $DIR/subdiagnostic-derive.rs:264:5 | LL | #[applicability] - | ^^^^^^^^^^^^^^^^ + | ^ error: `#[bar]` is not a valid attribute --> $DIR/subdiagnostic-derive.rs:274:5 | LL | #[bar] - | ^^^^^^ + | ^ | = help: only `primary_span`, `applicability` and `skip_arg` are valid field attributes @@ -158,13 +148,13 @@ error: `#[bar = ...]` is not a valid attribute --> $DIR/subdiagnostic-derive.rs:285:5 | LL | #[bar = "..."] - | ^^^^^^^^^^^^^^ + | ^ error: `#[bar(...)]` is not a valid attribute --> $DIR/subdiagnostic-derive.rs:296:5 | LL | #[bar("...")] - | ^^^^^^^^^^^^^ + | ^ | = help: only `primary_span`, `applicability` and `skip_arg` are valid field attributes @@ -178,13 +168,13 @@ error: specified multiple times --> $DIR/subdiagnostic-derive.rs:341:5 | LL | #[primary_span] - | ^^^^^^^^^^^^^^^ + | ^ | note: previously specified here --> $DIR/subdiagnostic-derive.rs:338:5 | LL | #[primary_span] - | ^^^^^^^^^^^^^^^ + | ^ error: subdiagnostic kind not specified --> $DIR/subdiagnostic-derive.rs:347:8 @@ -208,25 +198,25 @@ error: specified multiple times --> $DIR/subdiagnostic-derive.rs:402:5 | LL | #[applicability] - | ^^^^^^^^^^^^^^^^ + | ^ | note: previously specified here --> $DIR/subdiagnostic-derive.rs:399:5 | LL | #[applicability] - | ^^^^^^^^^^^^^^^^ + | ^ error: the `#[applicability]` attribute can only be applied to fields of type `Applicability` --> $DIR/subdiagnostic-derive.rs:412:5 | LL | #[applicability] - | ^^^^^^^^^^^^^^^^ + | ^ error: suggestion without `code = "..."` --> $DIR/subdiagnostic-derive.rs:425:1 | LL | #[suggestion(no_crate_example)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ error: invalid applicability --> $DIR/subdiagnostic-derive.rs:435:62 @@ -237,18 +227,14 @@ LL | #[suggestion(no_crate_example, code = "...", applicability = "foo")] error: suggestion without `#[primary_span]` field --> $DIR/subdiagnostic-derive.rs:453:1 | -LL | / #[suggestion(no_crate_example, code = "...")] -LL | | -LL | | struct AR { -LL | | var: String, -LL | | } - | |_^ +LL | #[suggestion(no_crate_example, code = "...")] + | ^ error: unsupported type attribute for subdiagnostic enum --> $DIR/subdiagnostic-derive.rs:467:1 | LL | #[label] - | ^^^^^^^^ + | ^ error: `var` doesn't refer to a field on this type --> $DIR/subdiagnostic-derive.rs:487:39 @@ -266,7 +252,7 @@ error: `#[suggestion_part]` is not a valid attribute --> $DIR/subdiagnostic-derive.rs:529:5 | LL | #[suggestion_part] - | ^^^^^^^^^^^^^^^^^^ + | ^ | = help: `#[suggestion_part(...)]` is only valid in multipart suggestions, use `#[primary_span]` instead @@ -274,21 +260,15 @@ error: `#[suggestion_part(...)]` is not a valid attribute --> $DIR/subdiagnostic-derive.rs:532:5 | LL | #[suggestion_part(code = "...")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ | = help: `#[suggestion_part(...)]` is only valid in multipart suggestions error: suggestion without `#[primary_span]` field --> $DIR/subdiagnostic-derive.rs:526:1 | -LL | / #[suggestion(no_crate_example, code = "...")] -LL | | -LL | | struct BA { -LL | | #[suggestion_part] -... | -LL | | var: String, -LL | | } - | |_^ +LL | #[suggestion(no_crate_example, code = "...")] + | ^ error: invalid nested attribute --> $DIR/subdiagnostic-derive.rs:541:42 @@ -301,57 +281,46 @@ LL | #[multipart_suggestion(no_crate_example, code = "...", applicability = "mac error: multipart suggestion without any `#[suggestion_part(...)]` fields --> $DIR/subdiagnostic-derive.rs:541:1 | -LL | / #[multipart_suggestion(no_crate_example, code = "...", applicability = "machine-applicable")] -LL | | -LL | | -LL | | struct BBa { -LL | | var: String, -LL | | } - | |_^ +LL | #[multipart_suggestion(no_crate_example, code = "...", applicability = "machine-applicable")] + | ^ error: `#[suggestion_part(...)]` attribute without `code = "..."` --> $DIR/subdiagnostic-derive.rs:551:5 | LL | #[suggestion_part] - | ^^^^^^^^^^^^^^^^^^ + | ^ error: `#[suggestion_part(...)]` attribute without `code = "..."` --> $DIR/subdiagnostic-derive.rs:559:5 | LL | #[suggestion_part()] - | ^^^^^^^^^^^^^^^^^^^^ + | ^ error: `#[primary_span]` is not a valid attribute --> $DIR/subdiagnostic-derive.rs:568:5 | LL | #[primary_span] - | ^^^^^^^^^^^^^^^ + | ^ | = help: multipart suggestions use one or more `#[suggestion_part]`s rather than one `#[primary_span]` error: multipart suggestion without any `#[suggestion_part(...)]` fields --> $DIR/subdiagnostic-derive.rs:565:1 | -LL | / #[multipart_suggestion(no_crate_example)] -LL | | -LL | | struct BC { -LL | | #[primary_span] -LL | | -LL | | span: Span, -LL | | } - | |_^ +LL | #[multipart_suggestion(no_crate_example)] + | ^ error: `#[suggestion_part(...)]` attribute without `code = "..."` --> $DIR/subdiagnostic-derive.rs:576:5 | LL | #[suggestion_part] - | ^^^^^^^^^^^^^^^^^^ + | ^ error: `#[suggestion_part(...)]` attribute without `code = "..."` --> $DIR/subdiagnostic-derive.rs:579:5 | LL | #[suggestion_part()] - | ^^^^^^^^^^^^^^^^^^^^ + | ^ error: `code` is the only valid nested attribute --> $DIR/subdiagnostic-derive.rs:582:23 @@ -363,13 +332,13 @@ error: the `#[suggestion_part(...)]` attribute can only be applied to fields of --> $DIR/subdiagnostic-derive.rs:587:5 | LL | #[suggestion_part(code = "...")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ error: the `#[suggestion_part(...)]` attribute can only be applied to fields of type `Span` or `MultiSpan` --> $DIR/subdiagnostic-derive.rs:590:5 | LL | #[suggestion_part()] - | ^^^^^^^^^^^^^^^^^^^^ + | ^ error: specified multiple times --> $DIR/subdiagnostic-derive.rs:598:37 @@ -387,7 +356,7 @@ error: `#[applicability]` has no effect if all `#[suggestion]`/`#[multipart_sugg --> $DIR/subdiagnostic-derive.rs:627:5 | LL | #[applicability] - | ^^^^^^^^^^^^^^^^ + | ^ error: expected exactly one string literal for `code = ...` --> $DIR/subdiagnostic-derive.rs:675:34 @@ -417,19 +386,19 @@ error: specified multiple times --> $DIR/subdiagnostic-derive.rs:763:1 | LL | #[suggestion(no_crate_example, code = "", style = "hidden", style = "normal")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ | note: previously specified here --> $DIR/subdiagnostic-derive.rs:763:1 | LL | #[suggestion(no_crate_example, code = "", style = "hidden", style = "normal")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ error: `#[suggestion_hidden(...)]` is not a valid attribute --> $DIR/subdiagnostic-derive.rs:772:1 | LL | #[suggestion_hidden(no_crate_example, code = "")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ | = help: Use `#[suggestion(..., style = "hidden")]` instead @@ -437,7 +406,7 @@ error: `#[suggestion_hidden(...)]` is not a valid attribute --> $DIR/subdiagnostic-derive.rs:780:1 | LL | #[suggestion_hidden(no_crate_example, code = "", style = "normal")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ | = help: Use `#[suggestion(..., style = "hidden")]` instead @@ -471,7 +440,7 @@ error: `#[primary_span]` is not a valid attribute --> $DIR/subdiagnostic-derive.rs:825:5 | LL | #[primary_span] - | ^^^^^^^^^^^^^^^ + | ^ | = note: there must be exactly one primary span = help: to create a suggestion with multiple spans, use `#[multipart_suggestion]` instead @@ -479,14 +448,8 @@ LL | #[primary_span] error: suggestion without `#[primary_span]` field --> $DIR/subdiagnostic-derive.rs:822:1 | -LL | / #[suggestion(no_crate_example, code = "")] -LL | | -LL | | struct PrimarySpanOnVec { -LL | | #[primary_span] -... | -LL | | sub: Vec<Span>, -LL | | } - | |_^ +LL | #[suggestion(no_crate_example, code = "")] + | ^ error[E0433]: failed to resolve: maybe a missing crate `core`? --> $DIR/subdiagnostic-derive.rs:96:9 diff --git a/tests/ui/array-slice-vec/check-static-mut-slices.rs b/tests/ui/array-slice-vec/check-static-mut-slices.rs deleted file mode 100644 index b89c634036e..00000000000 --- a/tests/ui/array-slice-vec/check-static-mut-slices.rs +++ /dev/null @@ -1,15 +0,0 @@ -// run-pass -#![allow(dead_code)] - -// Checks that mutable static items can have mutable slices - - -static mut TEST: &'static mut [isize] = &mut [1]; -static mut EMPTY: &'static mut [isize] = &mut []; - -pub fn main() { - unsafe { - TEST[0] += 1; - assert_eq!(TEST[0], 2); - } -} diff --git a/tests/ui/asm/aarch64/type-check-4.rs b/tests/ui/asm/aarch64/type-check-4.rs index 5dec60a2138..a14010481fc 100644 --- a/tests/ui/asm/aarch64/type-check-4.rs +++ b/tests/ui/asm/aarch64/type-check-4.rs @@ -23,10 +23,10 @@ const fn const_bar<T>(x: T) -> T { x } global_asm!("{}", const S); -//~^ ERROR constants cannot refer to statics +//~^ ERROR referencing statics global_asm!("{}", const const_foo(0)); global_asm!("{}", const const_foo(S)); -//~^ ERROR constants cannot refer to statics +//~^ ERROR referencing statics global_asm!("{}", const const_bar(0)); global_asm!("{}", const const_bar(S)); -//~^ ERROR constants cannot refer to statics +//~^ ERROR referencing statics diff --git a/tests/ui/asm/aarch64/type-check-4.stderr b/tests/ui/asm/aarch64/type-check-4.stderr index 4837e647bea..3e675f69e84 100644 --- a/tests/ui/asm/aarch64/type-check-4.stderr +++ b/tests/ui/asm/aarch64/type-check-4.stderr @@ -1,27 +1,39 @@ -error[E0013]: constants cannot refer to statics +error[E0658]: referencing statics in constants is unstable --> $DIR/type-check-4.rs:25:25 | LL | global_asm!("{}", const S); | ^ | - = help: consider extracting the value of the `static` to a `const`, and referring to that + = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information + = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable. + = help: to fix this, the value can be extracted to a `const` and then used. -error[E0013]: constants cannot refer to statics +error[E0658]: referencing statics in constants is unstable --> $DIR/type-check-4.rs:28:35 | LL | global_asm!("{}", const const_foo(S)); | ^ | - = help: consider extracting the value of the `static` to a `const`, and referring to that + = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information + = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable. + = help: to fix this, the value can be extracted to a `const` and then used. -error[E0013]: constants cannot refer to statics +error[E0658]: referencing statics in constants is unstable --> $DIR/type-check-4.rs:31:35 | LL | global_asm!("{}", const const_bar(S)); | ^ | - = help: consider extracting the value of the `static` to a `const`, and referring to that + = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information + = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable. + = help: to fix this, the value can be extracted to a `const` and then used. error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0013`. +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/asm/x86_64/type-check-4.rs b/tests/ui/asm/x86_64/type-check-4.rs index 3d5d3807c53..d0dacda4afb 100644 --- a/tests/ui/asm/x86_64/type-check-4.rs +++ b/tests/ui/asm/x86_64/type-check-4.rs @@ -19,10 +19,10 @@ const fn const_bar<T>(x: T) -> T { x } global_asm!("{}", const S); -//~^ ERROR constants cannot refer to statics +//~^ ERROR referencing statics global_asm!("{}", const const_foo(0)); global_asm!("{}", const const_foo(S)); -//~^ ERROR constants cannot refer to statics +//~^ ERROR referencing statics global_asm!("{}", const const_bar(0)); global_asm!("{}", const const_bar(S)); -//~^ ERROR constants cannot refer to statics +//~^ ERROR referencing statics diff --git a/tests/ui/asm/x86_64/type-check-4.stderr b/tests/ui/asm/x86_64/type-check-4.stderr index 3875bcc2112..cbdc051b343 100644 --- a/tests/ui/asm/x86_64/type-check-4.stderr +++ b/tests/ui/asm/x86_64/type-check-4.stderr @@ -1,27 +1,39 @@ -error[E0013]: constants cannot refer to statics +error[E0658]: referencing statics in constants is unstable --> $DIR/type-check-4.rs:21:25 | LL | global_asm!("{}", const S); | ^ | - = help: consider extracting the value of the `static` to a `const`, and referring to that + = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information + = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable. + = help: to fix this, the value can be extracted to a `const` and then used. -error[E0013]: constants cannot refer to statics +error[E0658]: referencing statics in constants is unstable --> $DIR/type-check-4.rs:24:35 | LL | global_asm!("{}", const const_foo(S)); | ^ | - = help: consider extracting the value of the `static` to a `const`, and referring to that + = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information + = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable. + = help: to fix this, the value can be extracted to a `const` and then used. -error[E0013]: constants cannot refer to statics +error[E0658]: referencing statics in constants is unstable --> $DIR/type-check-4.rs:27:35 | LL | global_asm!("{}", const const_bar(S)); | ^ | - = help: consider extracting the value of the `static` to a `const`, and referring to that + = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information + = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable. + = help: to fix this, the value can be extracted to a `const` and then used. error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0013`. +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.rs b/tests/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.rs index 4c36289f47b..8a580e19186 100644 --- a/tests/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.rs +++ b/tests/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.rs @@ -28,9 +28,9 @@ impl Bar for AssocNoCopy { impl Thing for AssocNoCopy { type Out = Box<dyn Bar<Assoc: Copy>>; + //~^ ERROR associated type bounds are not allowed in `dyn` types fn func() -> Self::Out { - //~^ ERROR the trait bound `String: Copy` is not satisfied Box::new(AssocNoCopy) } } diff --git a/tests/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.stderr b/tests/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.stderr index 7942992874d..ad540909411 100644 --- a/tests/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.stderr +++ b/tests/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.stderr @@ -1,9 +1,13 @@ -error[E0277]: the trait bound `String: Copy` is not satisfied - --> $DIR/assoc-type-eq-with-dyn-atb-fail.rs:32:18 +error: associated type bounds are not allowed in `dyn` types + --> $DIR/assoc-type-eq-with-dyn-atb-fail.rs:30:28 | -LL | fn func() -> Self::Out { - | ^^^^^^^^^ the trait `Copy` is not implemented for `String` +LL | type Out = Box<dyn Bar<Assoc: Copy>>; + | ^^^^^^^^^^^ + | +help: use `impl Trait` to introduce a type instead + | +LL | type Out = Box<dyn Bar<Assoc = impl Copy>>; + | ~~~~~~ error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/associated-type-bounds/bad-universal-in-dyn-in-where-clause.rs b/tests/ui/associated-type-bounds/bad-universal-in-dyn-in-where-clause.rs index 8cab1f66c27..81c8fe829f9 100644 --- a/tests/ui/associated-type-bounds/bad-universal-in-dyn-in-where-clause.rs +++ b/tests/ui/associated-type-bounds/bad-universal-in-dyn-in-where-clause.rs @@ -7,7 +7,7 @@ trait B { fn f() where dyn for<'j> B<AssocType: 'j>:, - //~^ ERROR associated type bounds are only allowed in where clauses and function signatures + //~^ ERROR associated type bounds are not allowed in `dyn` types { } diff --git a/tests/ui/associated-type-bounds/bad-universal-in-dyn-in-where-clause.stderr b/tests/ui/associated-type-bounds/bad-universal-in-dyn-in-where-clause.stderr index fe300a7de42..7d9870c72d4 100644 --- a/tests/ui/associated-type-bounds/bad-universal-in-dyn-in-where-clause.stderr +++ b/tests/ui/associated-type-bounds/bad-universal-in-dyn-in-where-clause.stderr @@ -1,4 +1,4 @@ -error: associated type bounds are only allowed in where clauses and function signatures, not in bounds +error: associated type bounds are not allowed in `dyn` types --> $DIR/bad-universal-in-dyn-in-where-clause.rs:9:19 | LL | dyn for<'j> B<AssocType: 'j>:, diff --git a/tests/ui/associated-type-bounds/bad-universal-in-impl-sig.rs b/tests/ui/associated-type-bounds/bad-universal-in-impl-sig.rs index 1d5d181efcc..f465123f34c 100644 --- a/tests/ui/associated-type-bounds/bad-universal-in-impl-sig.rs +++ b/tests/ui/associated-type-bounds/bad-universal-in-impl-sig.rs @@ -8,6 +8,6 @@ trait Trait2 {} // It's not possible to insert a universal `impl Trait` here! impl dyn Trait<Item: Trait2> {} -//~^ ERROR associated type bounds are only allowed in where clauses and function signatures +//~^ ERROR associated type bounds are not allowed in `dyn` types fn main() {} diff --git a/tests/ui/associated-type-bounds/bad-universal-in-impl-sig.stderr b/tests/ui/associated-type-bounds/bad-universal-in-impl-sig.stderr index 7bdb2c5a7c2..8855bd9c312 100644 --- a/tests/ui/associated-type-bounds/bad-universal-in-impl-sig.stderr +++ b/tests/ui/associated-type-bounds/bad-universal-in-impl-sig.stderr @@ -1,4 +1,4 @@ -error: associated type bounds are only allowed in where clauses and function signatures, not in impl headers +error: associated type bounds are not allowed in `dyn` types --> $DIR/bad-universal-in-impl-sig.rs:10:16 | LL | impl dyn Trait<Item: Trait2> {} diff --git a/tests/ui/associated-type-bounds/duplicate.rs b/tests/ui/associated-type-bounds/duplicate.rs index 036f8ede1b3..54c8cd3fde0 100644 --- a/tests/ui/associated-type-bounds/duplicate.rs +++ b/tests/ui/associated-type-bounds/duplicate.rs @@ -261,11 +261,4 @@ trait TRA3 { //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] } -type TADyn1 = dyn Iterator<Item: Copy, Item: Send>; -//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] -type TADyn2 = Box<dyn Iterator<Item: Copy, Item: Copy>>; -//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] -type TADyn3 = dyn Iterator<Item: 'static, Item: 'static>; -//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] - fn main() {} diff --git a/tests/ui/associated-type-bounds/duplicate.stderr b/tests/ui/associated-type-bounds/duplicate.stderr index bf6aab96dc7..9816d11a40a 100644 --- a/tests/ui/associated-type-bounds/duplicate.stderr +++ b/tests/ui/associated-type-bounds/duplicate.stderr @@ -7,30 +7,6 @@ LL | struct SI1<T: Iterator<Item: Copy, Item: Send>> { | `Item` bound here first error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified - --> $DIR/duplicate.rs:264:40 - | -LL | type TADyn1 = dyn Iterator<Item: Copy, Item: Send>; - | ---------- ^^^^^^^^^^ re-bound here - | | - | `Item` bound here first - -error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified - --> $DIR/duplicate.rs:266:44 - | -LL | type TADyn2 = Box<dyn Iterator<Item: Copy, Item: Copy>>; - | ---------- ^^^^^^^^^^ re-bound here - | | - | `Item` bound here first - -error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified - --> $DIR/duplicate.rs:268:43 - | -LL | type TADyn3 = dyn Iterator<Item: 'static, Item: 'static>; - | ------------- ^^^^^^^^^^^^^ re-bound here - | | - | `Item` bound here first - -error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:11:36 | LL | struct SI2<T: Iterator<Item: Copy, Item: Copy>> { @@ -631,7 +607,7 @@ LL | Self: Iterator<Item: 'static, Item: 'static>, | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: aborting due to 75 previous errors +error: aborting due to 72 previous errors Some errors have detailed explanations: E0282, E0719. For more information about an error, try `rustc --explain E0282`. diff --git a/tests/ui/associated-type-bounds/dyn-impl-trait-type.rs b/tests/ui/associated-type-bounds/dyn-impl-trait-type.rs deleted file mode 100644 index 079c44b3a59..00000000000 --- a/tests/ui/associated-type-bounds/dyn-impl-trait-type.rs +++ /dev/null @@ -1,66 +0,0 @@ -// run-pass - -#![feature(associated_type_bounds)] - -use std::ops::Add; - -trait Tr1 { type As1; fn mk(&self) -> Self::As1; } -trait Tr2<'a> { fn tr2(self) -> &'a Self; } //~ WARN method `tr2` is never used - -fn assert_copy<T: Copy>(x: T) { let _x = x; let _x = x; } -fn assert_static<T: 'static>(_: T) {} -fn assert_forall_tr2<T: for<'a> Tr2<'a>>(_: T) {} - -struct S1; -#[derive(Copy, Clone)] -struct S2; -impl Tr1 for S1 { type As1 = S2; fn mk(&self) -> Self::As1 { S2 } } - -type Et1 = Box<dyn Tr1<As1: Copy>>; -fn def_et1() -> Et1 { Box::new(S1) } -pub fn use_et1() { assert_copy(def_et1().mk()); } - -type Et2 = Box<dyn Tr1<As1: 'static>>; -fn def_et2() -> Et2 { Box::new(S1) } -pub fn use_et2() { assert_static(def_et2().mk()); } - -type Et3 = Box<dyn Tr1<As1: Clone + Iterator<Item: Add<u8, Output: Into<u8>>>>>; -fn def_et3() -> Et3 { - struct A; - impl Tr1 for A { - type As1 = core::ops::Range<u8>; - fn mk(&self) -> Self::As1 { 0..10 } - } - Box::new(A) -} -pub fn use_et3() { - let _0 = def_et3().mk().clone(); - let mut s = 0u8; - for _1 in _0 { - let _2 = _1 + 1u8; - s += _2.into(); - } - assert_eq!(s, (0..10).map(|x| x + 1).sum()); -} - -type Et4 = Box<dyn Tr1<As1: for<'a> Tr2<'a>>>; -fn def_et4() -> Et4 { - #[derive(Copy, Clone)] - struct A; - impl Tr1 for A { - type As1 = A; - fn mk(&self) -> A { A } - } - impl<'a> Tr2<'a> for A { - fn tr2(self) -> &'a Self { &A } - } - Box::new(A) -} -pub fn use_et4() { assert_forall_tr2(def_et4().mk()); } - -fn main() { - use_et1(); - use_et2(); - use_et3(); - use_et4(); -} diff --git a/tests/ui/associated-type-bounds/dyn-impl-trait-type.stderr b/tests/ui/associated-type-bounds/dyn-impl-trait-type.stderr deleted file mode 100644 index 2e26a434f5d..00000000000 --- a/tests/ui/associated-type-bounds/dyn-impl-trait-type.stderr +++ /dev/null @@ -1,12 +0,0 @@ -warning: method `tr2` is never used - --> $DIR/dyn-impl-trait-type.rs:8:20 - | -LL | trait Tr2<'a> { fn tr2(self) -> &'a Self; } - | --- ^^^ - | | - | method in this trait - | - = note: `#[warn(dead_code)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/associated-type-bounds/dyn-rpit-and-let.rs b/tests/ui/associated-type-bounds/dyn-rpit-and-let.rs deleted file mode 100644 index 49e5e72f225..00000000000 --- a/tests/ui/associated-type-bounds/dyn-rpit-and-let.rs +++ /dev/null @@ -1,73 +0,0 @@ -// run-pass - -// FIXME: uncomment let binding types below when `impl_trait_in_bindings` feature is fixed. - -#![feature(associated_type_bounds)] - -use std::ops::Add; - -trait Tr1 { type As1; fn mk(&self) -> Self::As1; } -trait Tr2<'a> { fn tr2(self) -> &'a Self; } //~ WARN method `tr2` is never used - -fn assert_copy<T: Copy>(x: T) { let _x = x; let _x = x; } -fn assert_static<T: 'static>(_: T) {} -fn assert_forall_tr2<T: for<'a> Tr2<'a>>(_: T) {} - -struct S1; -#[derive(Copy, Clone)] -struct S2; -impl Tr1 for S1 { type As1 = S2; fn mk(&self) -> Self::As1 { S2 } } - -fn def_et1() -> Box<dyn Tr1<As1: Copy>> { - let x /* : Box<dyn Tr1<As1: Copy>> */ = Box::new(S1); - x -} -pub fn use_et1() { assert_copy(def_et1().mk()); } - -fn def_et2() -> Box<dyn Tr1<As1: Send + 'static>> { - let x /* : Box<dyn Tr1<As1: Send + 'static>> */ = Box::new(S1); - x -} -pub fn use_et2() { assert_static(def_et2().mk()); } - -fn def_et3() -> Box<dyn Tr1<As1: Clone + Iterator<Item: Add<u8, Output: Into<u8>>>>> { - struct A; - impl Tr1 for A { - type As1 = core::ops::Range<u8>; - fn mk(&self) -> Self::As1 { 0..10 } - } - let x /* : Box<dyn Tr1<As1: Clone + Iterator<Item: Add<u8, Output: Into<u8>>>>> */ - = Box::new(A); - x -} -pub fn use_et3() { - let _0 = def_et3().mk().clone(); - let mut s = 0u8; - for _1 in _0 { - let _2 = _1 + 1u8; - s += _2.into(); - } - assert_eq!(s, (0..10).map(|x| x + 1).sum()); -} - -fn def_et4() -> Box<dyn Tr1<As1: for<'a> Tr2<'a>>> { - #[derive(Copy, Clone)] - struct A; - impl Tr1 for A { - type As1 = A; - fn mk(&self) -> A { A } - } - impl<'a> Tr2<'a> for A { - fn tr2(self) -> &'a Self { &A } - } - let x /* : Box<dyn Tr1<As1: for<'a> Tr2<'a>>> */ = Box::new(A); - x -} -pub fn use_et4() { assert_forall_tr2(def_et4().mk()); } - -fn main() { - use_et1(); - use_et2(); - use_et3(); - use_et4(); -} diff --git a/tests/ui/associated-type-bounds/dyn-rpit-and-let.stderr b/tests/ui/associated-type-bounds/dyn-rpit-and-let.stderr deleted file mode 100644 index 9eddbe46284..00000000000 --- a/tests/ui/associated-type-bounds/dyn-rpit-and-let.stderr +++ /dev/null @@ -1,12 +0,0 @@ -warning: method `tr2` is never used - --> $DIR/dyn-rpit-and-let.rs:10:20 - | -LL | trait Tr2<'a> { fn tr2(self) -> &'a Self; } - | --- ^^^ - | | - | method in this trait - | - = note: `#[warn(dead_code)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/associated-type-bounds/elision.rs b/tests/ui/associated-type-bounds/elision.rs index d00def57166..5d7ed940ac6 100644 --- a/tests/ui/associated-type-bounds/elision.rs +++ b/tests/ui/associated-type-bounds/elision.rs @@ -3,7 +3,7 @@ // The same thing should happen for constraints in dyn trait. fn f(x: &mut dyn Iterator<Item: Iterator<Item = &'_ ()>>) -> Option<&'_ ()> { x.next() } -//~^ ERROR missing lifetime specifier -//~| ERROR mismatched types +//~^ ERROR associated type bounds are not allowed in `dyn` types +//~| ERROR missing lifetime specifier fn main() {} diff --git a/tests/ui/associated-type-bounds/elision.stderr b/tests/ui/associated-type-bounds/elision.stderr index a29e32a784f..749dffdc4d3 100644 --- a/tests/ui/associated-type-bounds/elision.stderr +++ b/tests/ui/associated-type-bounds/elision.stderr @@ -10,19 +10,17 @@ help: consider introducing a named lifetime parameter LL | fn f<'a>(x: &'a mut dyn Iterator<Item: Iterator<Item = &'a ()>>) -> Option<&'a ()> { x.next() } | ++++ ++ ~~ ~~ -error[E0308]: mismatched types - --> $DIR/elision.rs:5:79 +error: associated type bounds are not allowed in `dyn` types + --> $DIR/elision.rs:5:27 | LL | fn f(x: &mut dyn Iterator<Item: Iterator<Item = &'_ ()>>) -> Option<&'_ ()> { x.next() } - | ----------------------------- -------------- ^^^^^^^^ expected `Option<&()>`, found `Option<impl Iterator<Item = &'_ ()>>` - | | | - | | expected `Option<&()>` because of return type - | found this type parameter + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: expected enum `Option<&()>` - found enum `Option<impl Iterator<Item = &'_ ()>>` +help: use `impl Trait` to introduce a type instead + | +LL | fn f(x: &mut dyn Iterator<Item = impl Iterator<Item = &'_ ()>>) -> Option<&'_ ()> { x.next() } + | ~~~~~~ error: aborting due to 2 previous errors -Some errors have detailed explanations: E0106, E0308. -For more information about an error, try `rustc --explain E0106`. +For more information about this error, try `rustc --explain E0106`. diff --git a/tests/ui/associated-type-bounds/fn-dyn-apit.rs b/tests/ui/associated-type-bounds/fn-dyn-apit.rs deleted file mode 100644 index c4e8092c211..00000000000 --- a/tests/ui/associated-type-bounds/fn-dyn-apit.rs +++ /dev/null @@ -1,61 +0,0 @@ -// run-pass -// aux-build:fn-dyn-aux.rs - -#![allow(unused)] -#![feature(associated_type_bounds)] - -extern crate fn_dyn_aux; - -use fn_dyn_aux::*; - -// ATB, APIT (dyn trait): - -fn dyn_apit_bound(beta: &dyn Beta<Gamma: Alpha>) -> usize { - desugared_bound(beta) -} - -fn dyn_apit_bound_region(beta: &dyn Beta<Gamma: 'static>) -> usize { - desugared_bound_region(beta) -} - -fn dyn_apit_bound_multi( - beta: &(dyn Beta<Gamma: Alpha + 'static + Delta> + Send) -) -> usize { - desugared_bound_multi(beta) -} - -fn dyn_apit_bound_region_forall( - beta: &dyn Beta<Gamma: Copy + for<'a> Epsilon<'a>> -) -> usize { - desugared_bound_region_forall(beta) -} - -fn dyn_apit_bound_region_forall2( - beta: &dyn Beta<Gamma: Copy + for<'a> Epsilon<'a, Zeta: Eta>> -) -> usize { - desugared_bound_region_forall2(beta) -} - -fn dyn_apit_bound_nested( - beta: &dyn Beta<Gamma: Copy + Alpha + Beta<Gamma: Delta>> -) -> usize { - desugared_bound_nested(beta) -} - -fn dyn_apit_bound_nested2( - beta: &dyn Beta<Gamma = impl Copy + Alpha + Beta<Gamma: Delta>> -) -> usize { - desugared_bound_nested(beta) -} - -fn main() { - let beta = BetaType; - let _gamma = beta.gamma(); - - assert_eq!(42, dyn_apit_bound(&beta)); - assert_eq!(24, dyn_apit_bound_region(&beta)); - assert_eq!(42 + 24 + 1337, dyn_apit_bound_multi(&beta)); - assert_eq!(7331 * 2, dyn_apit_bound_region_forall(&beta)); - assert_eq!(42 + 1337, dyn_apit_bound_nested(&beta)); - assert_eq!(42 + 1337, dyn_apit_bound_nested2(&beta)); -} diff --git a/tests/ui/associated-type-bounds/inside-adt.rs b/tests/ui/associated-type-bounds/inside-adt.rs index 057966941dc..2b4b060983e 100644 --- a/tests/ui/associated-type-bounds/inside-adt.rs +++ b/tests/ui/associated-type-bounds/inside-adt.rs @@ -3,24 +3,24 @@ use std::mem::ManuallyDrop; struct S1 { f: dyn Iterator<Item: Copy> } -//~^ ERROR associated type bounds are only allowed in where clauses and function signatures +//~^ ERROR associated type bounds are not allowed in `dyn` types struct S2 { f: Box<dyn Iterator<Item: Copy>> } -//~^ ERROR associated type bounds are only allowed in where clauses and function signatures +//~^ ERROR associated type bounds are not allowed in `dyn` types struct S3 { f: dyn Iterator<Item: 'static> } -//~^ ERROR associated type bounds are only allowed in where clauses and function signatures +//~^ ERROR associated type bounds are not allowed in `dyn` types enum E1 { V(dyn Iterator<Item: Copy>) } -//~^ ERROR associated type bounds are only allowed in where clauses and function signatures +//~^ ERROR associated type bounds are not allowed in `dyn` types enum E2 { V(Box<dyn Iterator<Item: Copy>>) } -//~^ ERROR associated type bounds are only allowed in where clauses and function signatures +//~^ ERROR associated type bounds are not allowed in `dyn` types enum E3 { V(dyn Iterator<Item: 'static>) } -//~^ ERROR associated type bounds are only allowed in where clauses and function signatures +//~^ ERROR associated type bounds are not allowed in `dyn` types union U1 { f: ManuallyDrop<dyn Iterator<Item: Copy>> } -//~^ ERROR associated type bounds are only allowed in where clauses and function signatures +//~^ ERROR associated type bounds are not allowed in `dyn` types union U2 { f: ManuallyDrop<Box<dyn Iterator<Item: Copy>>> } -//~^ ERROR associated type bounds are only allowed in where clauses and function signatures +//~^ ERROR associated type bounds are not allowed in `dyn` types union U3 { f: ManuallyDrop<dyn Iterator<Item: 'static>> } -//~^ ERROR associated type bounds are only allowed in where clauses and function signatures +//~^ ERROR associated type bounds are not allowed in `dyn` types fn main() {} diff --git a/tests/ui/associated-type-bounds/inside-adt.stderr b/tests/ui/associated-type-bounds/inside-adt.stderr index f848bd798ee..ef45fae8f2a 100644 --- a/tests/ui/associated-type-bounds/inside-adt.stderr +++ b/tests/ui/associated-type-bounds/inside-adt.stderr @@ -1,52 +1,52 @@ -error: associated type bounds are only allowed in where clauses and function signatures, not in field types +error: associated type bounds are not allowed in `dyn` types --> $DIR/inside-adt.rs:5:29 | LL | struct S1 { f: dyn Iterator<Item: Copy> } | ^^^^^^^^^^ -error: associated type bounds are only allowed in where clauses and function signatures, not in field types +error: associated type bounds are not allowed in `dyn` types --> $DIR/inside-adt.rs:7:33 | LL | struct S2 { f: Box<dyn Iterator<Item: Copy>> } | ^^^^^^^^^^ -error: associated type bounds are only allowed in where clauses and function signatures, not in field types +error: associated type bounds are not allowed in `dyn` types --> $DIR/inside-adt.rs:9:29 | LL | struct S3 { f: dyn Iterator<Item: 'static> } | ^^^^^^^^^^^^^ -error: associated type bounds are only allowed in where clauses and function signatures, not in field types +error: associated type bounds are not allowed in `dyn` types --> $DIR/inside-adt.rs:12:26 | LL | enum E1 { V(dyn Iterator<Item: Copy>) } | ^^^^^^^^^^ -error: associated type bounds are only allowed in where clauses and function signatures, not in field types +error: associated type bounds are not allowed in `dyn` types --> $DIR/inside-adt.rs:14:30 | LL | enum E2 { V(Box<dyn Iterator<Item: Copy>>) } | ^^^^^^^^^^ -error: associated type bounds are only allowed in where clauses and function signatures, not in field types +error: associated type bounds are not allowed in `dyn` types --> $DIR/inside-adt.rs:16:26 | LL | enum E3 { V(dyn Iterator<Item: 'static>) } | ^^^^^^^^^^^^^ -error: associated type bounds are only allowed in where clauses and function signatures, not in field types +error: associated type bounds are not allowed in `dyn` types --> $DIR/inside-adt.rs:19:41 | LL | union U1 { f: ManuallyDrop<dyn Iterator<Item: Copy>> } | ^^^^^^^^^^ -error: associated type bounds are only allowed in where clauses and function signatures, not in field types +error: associated type bounds are not allowed in `dyn` types --> $DIR/inside-adt.rs:21:45 | LL | union U2 { f: ManuallyDrop<Box<dyn Iterator<Item: Copy>>> } | ^^^^^^^^^^ -error: associated type bounds are only allowed in where clauses and function signatures, not in field types +error: associated type bounds are not allowed in `dyn` types --> $DIR/inside-adt.rs:23:41 | LL | union U3 { f: ManuallyDrop<dyn Iterator<Item: 'static>> } diff --git a/tests/ui/associated-type-bounds/issue-104916.rs b/tests/ui/associated-type-bounds/issue-104916.rs index 3361fa011ed..ee29a0a2fc4 100644 --- a/tests/ui/associated-type-bounds/issue-104916.rs +++ b/tests/ui/associated-type-bounds/issue-104916.rs @@ -7,7 +7,7 @@ trait B { fn f() where dyn for<'j> B<AssocType: 'j>:, - //~^ ERROR: associated type bounds are only allowed in where clauses and function signatures + //~^ ERROR: associated type bounds are not allowed in `dyn` types { } diff --git a/tests/ui/associated-type-bounds/issue-104916.stderr b/tests/ui/associated-type-bounds/issue-104916.stderr index 65c89735c5d..e8618b72103 100644 --- a/tests/ui/associated-type-bounds/issue-104916.stderr +++ b/tests/ui/associated-type-bounds/issue-104916.stderr @@ -1,4 +1,4 @@ -error: associated type bounds are only allowed in where clauses and function signatures, not in bounds +error: associated type bounds are not allowed in `dyn` types --> $DIR/issue-104916.rs:9:19 | LL | dyn for<'j> B<AssocType: 'j>:, diff --git a/tests/ui/async-await/async-closures/auxiliary/foreign.rs b/tests/ui/async-await/async-closures/auxiliary/foreign.rs new file mode 100644 index 00000000000..e11dfc22213 --- /dev/null +++ b/tests/ui/async-await/async-closures/auxiliary/foreign.rs @@ -0,0 +1,7 @@ +// edition:2021 + +#![feature(async_closure)] + +pub fn closure() -> impl async Fn() { + async || { /* Don't really need to do anything here. */ } +} diff --git a/tests/ui/async-await/async-closures/foreign.rs b/tests/ui/async-await/async-closures/foreign.rs new file mode 100644 index 00000000000..60fea909801 --- /dev/null +++ b/tests/ui/async-await/async-closures/foreign.rs @@ -0,0 +1,19 @@ +// aux-build:block-on.rs +// aux-build:foreign.rs +// edition:2021 +// build-pass + +#![feature(async_closure)] + +use std::future::Future; + +extern crate block_on; +extern crate foreign; + +struct NoCopy; + +fn main() { + block_on::block_on(async { + foreign::closure()().await; + }); +} diff --git a/tests/ui/async-await/async-closures/is-not-fn.rs b/tests/ui/async-await/async-closures/is-not-fn.rs index 94c8e8563bd..81666cada31 100644 --- a/tests/ui/async-await/async-closures/is-not-fn.rs +++ b/tests/ui/async-await/async-closures/is-not-fn.rs @@ -5,8 +5,5 @@ fn main() { fn needs_fn(x: impl FnOnce()) {} needs_fn(async || {}); - //~^ ERROR expected a `FnOnce()` closure, found `{coroutine-closure@ - // FIXME(async_closures): This should explain in more detail how async fns don't - // implement the regular `Fn` traits. Or maybe we should just fix it and make them - // when there are no upvars or whatever. + //~^ ERROR expected `{async closure@is-not-fn.rs:7:14}` to be a closure that returns `()` } diff --git a/tests/ui/async-await/async-closures/is-not-fn.stderr b/tests/ui/async-await/async-closures/is-not-fn.stderr index 12da4b1fc6f..130746ece67 100644 --- a/tests/ui/async-await/async-closures/is-not-fn.stderr +++ b/tests/ui/async-await/async-closures/is-not-fn.stderr @@ -1,13 +1,13 @@ -error[E0277]: expected a `FnOnce()` closure, found `{coroutine-closure@$DIR/is-not-fn.rs:7:14: 7:22}` +error[E0271]: expected `{async closure@is-not-fn.rs:7:14}` to be a closure that returns `()`, but it returns `{async closure body@$DIR/is-not-fn.rs:7:23: 7:25}` --> $DIR/is-not-fn.rs:7:14 | LL | needs_fn(async || {}); - | -------- ^^^^^^^^^^^ expected an `FnOnce()` closure, found `{coroutine-closure@$DIR/is-not-fn.rs:7:14: 7:22}` + | -------- ^^^^^^^^^^^ expected `()`, found `async` closure body | | | required by a bound introduced by this call | - = help: the trait `FnOnce<()>` is not implemented for `{coroutine-closure@$DIR/is-not-fn.rs:7:14: 7:22}` - = note: wrap the `{coroutine-closure@$DIR/is-not-fn.rs:7:14: 7:22}` in a closure with no arguments: `|| { /* code */ }` + = note: expected unit type `()` + found `async` closure body `{async closure body@$DIR/is-not-fn.rs:7:23: 7:25}` note: required by a bound in `needs_fn` --> $DIR/is-not-fn.rs:6:25 | @@ -16,4 +16,4 @@ LL | fn needs_fn(x: impl FnOnce()) {} error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0271`. diff --git a/tests/ui/async-await/async-closures/move-consuming-capture.stderr b/tests/ui/async-await/async-closures/move-consuming-capture.stderr index 2c2a0d1162d..45c1eac8f8f 100644 --- a/tests/ui/async-await/async-closures/move-consuming-capture.stderr +++ b/tests/ui/async-await/async-closures/move-consuming-capture.stderr @@ -2,7 +2,7 @@ error[E0382]: use of moved value: `x` --> $DIR/move-consuming-capture.rs:17:9 | LL | let x = async move || { - | - move occurs because `x` has type `{coroutine-closure@$DIR/move-consuming-capture.rs:13:17: 13:30}`, which does not implement the `Copy` trait + | - move occurs because `x` has type `{async closure@$DIR/move-consuming-capture.rs:13:17: 13:30}`, which does not implement the `Copy` trait ... LL | x().await; | --- `x` moved due to this method call diff --git a/tests/ui/async-await/async-closures/once.rs b/tests/ui/async-await/async-closures/once.rs new file mode 100644 index 00000000000..a1c56c5de6a --- /dev/null +++ b/tests/ui/async-await/async-closures/once.rs @@ -0,0 +1,22 @@ +// aux-build:block-on.rs +// edition:2021 +// build-pass + +#![feature(async_closure)] + +use std::future::Future; + +extern crate block_on; + +struct NoCopy; + +fn main() { + block_on::block_on(async { + async fn call_once<F: Future>(x: impl Fn(&'static str) -> F) -> F::Output { + x("hello, world").await + } + call_once(async |x: &'static str| { + println!("hello, {x}"); + }).await + }); +} diff --git a/tests/ui/async-await/async-closures/refd.rs b/tests/ui/async-await/async-closures/refd.rs new file mode 100644 index 00000000000..7c61ff2d9bd --- /dev/null +++ b/tests/ui/async-await/async-closures/refd.rs @@ -0,0 +1,18 @@ +// aux-build:block-on.rs +// edition:2021 +// build-pass + +// check that `&{async-closure}` implements `AsyncFn`. + +#![feature(async_closure)] + +extern crate block_on; + +struct NoCopy; + +fn main() { + block_on::block_on(async { + async fn call_once(x: impl async Fn()) { x().await } + call_once(&async || {}).await + }); +} diff --git a/tests/ui/async-await/async-fn/dyn-pos.stderr b/tests/ui/async-await/async-fn/dyn-pos.stderr index c9323526516..488c5d06938 100644 --- a/tests/ui/async-await/async-fn/dyn-pos.stderr +++ b/tests/ui/async-await/async-fn/dyn-pos.stderr @@ -8,6 +8,9 @@ note: for a trait to be "object safe" it needs to allow building a vtable to all --> $SRC_DIR/core/src/ops/async_function.rs:LL:COL | = note: the trait cannot be made into an object because it contains the generic associated type `CallFuture` + = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `AsyncFn` for this new enum and using it instead: + &F + std::boxed::Box<F, A> error[E0038]: the trait `AsyncFnMut` cannot be made into an object --> $DIR/dyn-pos.rs:5:16 @@ -19,6 +22,10 @@ note: for a trait to be "object safe" it needs to allow building a vtable to all --> $SRC_DIR/core/src/ops/async_function.rs:LL:COL | = note: the trait cannot be made into an object because it contains the generic associated type `CallMutFuture` + = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `AsyncFnMut` for this new enum and using it instead: + &F + &mut F + std::boxed::Box<F, A> error[E0038]: the trait `AsyncFn` cannot be made into an object --> $DIR/dyn-pos.rs:5:16 @@ -30,6 +37,9 @@ note: for a trait to be "object safe" it needs to allow building a vtable to all --> $SRC_DIR/core/src/ops/async_function.rs:LL:COL | = note: the trait cannot be made into an object because it contains the generic associated type `CallFuture` + = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `AsyncFn` for this new enum and using it instead: + &F + std::boxed::Box<F, A> = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0038]: the trait `AsyncFnMut` cannot be made into an object @@ -42,6 +52,10 @@ note: for a trait to be "object safe" it needs to allow building a vtable to all --> $SRC_DIR/core/src/ops/async_function.rs:LL:COL | = note: the trait cannot be made into an object because it contains the generic associated type `CallMutFuture` + = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `AsyncFnMut` for this new enum and using it instead: + &F + &mut F + std::boxed::Box<F, A> = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0038]: the trait `AsyncFn` cannot be made into an object @@ -54,6 +68,9 @@ note: for a trait to be "object safe" it needs to allow building a vtable to all --> $SRC_DIR/core/src/ops/async_function.rs:LL:COL | = note: the trait cannot be made into an object because it contains the generic associated type `CallFuture` + = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `AsyncFn` for this new enum and using it instead: + &F + std::boxed::Box<F, A> = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0038]: the trait `AsyncFnMut` cannot be made into an object @@ -66,6 +83,10 @@ note: for a trait to be "object safe" it needs to allow building a vtable to all --> $SRC_DIR/core/src/ops/async_function.rs:LL:COL | = note: the trait cannot be made into an object because it contains the generic associated type `CallMutFuture` + = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `AsyncFnMut` for this new enum and using it instead: + &F + &mut F + std::boxed::Box<F, A> = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0038]: the trait `AsyncFn` cannot be made into an object @@ -81,6 +102,9 @@ note: for a trait to be "object safe" it needs to allow building a vtable to all ::: $SRC_DIR/core/src/ops/async_function.rs:LL:COL | = note: the trait cannot be made into an object because it contains the generic associated type `CallMutFuture` + = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `AsyncFn` for this new enum and using it instead: + &F + std::boxed::Box<F, A> error: aborting due to 7 previous errors diff --git a/tests/ui/async-await/async-fn/simple.rs b/tests/ui/async-await/async-fn/simple.rs index 99a5d56a309..172ede7098a 100644 --- a/tests/ui/async-await/async-fn/simple.rs +++ b/tests/ui/async-await/async-fn/simple.rs @@ -1,5 +1,5 @@ // edition: 2021 -// check-pass +// build-pass #![feature(async_fn_traits)] diff --git a/tests/ui/async-await/missing-return-in-async-block.fixed b/tests/ui/async-await/missing-return-in-async-block.fixed new file mode 100644 index 00000000000..3dbac7945b6 --- /dev/null +++ b/tests/ui/async-await/missing-return-in-async-block.fixed @@ -0,0 +1,22 @@ +// run-rustfix +// edition:2021 +use std::future::Future; +use std::pin::Pin; +pub struct S; +pub fn foo() { + let _ = Box::pin(async move { + if true { + return Ok(S); //~ ERROR mismatched types + } + Err(()) + }); +} +pub fn bar() -> Pin<Box<dyn Future<Output = Result<S, ()>> + 'static>> { + Box::pin(async move { + if true { + return Ok(S); //~ ERROR mismatched types + } + Err(()) + }) +} +fn main() {} diff --git a/tests/ui/async-await/missing-return-in-async-block.rs b/tests/ui/async-await/missing-return-in-async-block.rs new file mode 100644 index 00000000000..7d04e0e0fad --- /dev/null +++ b/tests/ui/async-await/missing-return-in-async-block.rs @@ -0,0 +1,22 @@ +// run-rustfix +// edition:2021 +use std::future::Future; +use std::pin::Pin; +pub struct S; +pub fn foo() { + let _ = Box::pin(async move { + if true { + Ok(S) //~ ERROR mismatched types + } + Err(()) + }); +} +pub fn bar() -> Pin<Box<dyn Future<Output = Result<S, ()>> + 'static>> { + Box::pin(async move { + if true { + Ok(S) //~ ERROR mismatched types + } + Err(()) + }) +} +fn main() {} diff --git a/tests/ui/async-await/missing-return-in-async-block.stderr b/tests/ui/async-await/missing-return-in-async-block.stderr new file mode 100644 index 00000000000..5ea76e5f7bf --- /dev/null +++ b/tests/ui/async-await/missing-return-in-async-block.stderr @@ -0,0 +1,35 @@ +error[E0308]: mismatched types + --> $DIR/missing-return-in-async-block.rs:9:13 + | +LL | / if true { +LL | | Ok(S) + | | ^^^^^ expected `()`, found `Result<S, _>` +LL | | } + | |_________- expected this to be `()` + | + = note: expected unit type `()` + found enum `Result<S, _>` +help: you might have meant to return this value + | +LL | return Ok(S); + | ++++++ + + +error[E0308]: mismatched types + --> $DIR/missing-return-in-async-block.rs:17:13 + | +LL | / if true { +LL | | Ok(S) + | | ^^^^^ expected `()`, found `Result<S, _>` +LL | | } + | |_________- expected this to be `()` + | + = note: expected unit type `()` + found enum `Result<S, _>` +help: you might have meant to return this value + | +LL | return Ok(S); + | ++++++ + + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/cast/cast-rfc0401.rs b/tests/ui/cast/cast-rfc0401.rs index 9a987541615..424feeba0c4 100644 --- a/tests/ui/cast/cast-rfc0401.rs +++ b/tests/ui/cast/cast-rfc0401.rs @@ -81,14 +81,14 @@ fn main() assert_eq!(u as *const u16, p as *const u16); // ptr-ptr-cast (Length vtables) - let mut l : [u8; 2] = [0,1]; - let w: *mut [u16; 2] = &mut l as *mut [u8; 2] as *mut _; - let w: *mut [u16] = unsafe {&mut *w}; - let w_u8 : *const [u8] = w as *const [u8]; - assert_eq!(unsafe{&*w_u8}, &l); + let mut l : [u16; 2] = [0,1]; + let w: *mut [u8; 2] = &mut l as *mut [u16; 2] as *mut _; + let w: *mut [u8] = unsafe {&mut *w}; + let w_u16 : *const [u16] = w as *const [u16]; + assert_eq!(unsafe{&*w_u16}, &l); let s: *mut str = w as *mut str; - let l_via_str = unsafe{&*(s as *const [u8])}; + let l_via_str = unsafe{&*(s as *const [u16])}; assert_eq!(&l, l_via_str); // ptr-ptr-cast (Length vtables, check length is preserved) diff --git a/tests/ui/check-cfg/well-known-values.stderr b/tests/ui/check-cfg/well-known-values.stderr index 652e573d6ef..7eeaa31cbb6 100644 --- a/tests/ui/check-cfg/well-known-values.stderr +++ b/tests/ui/check-cfg/well-known-values.stderr @@ -143,7 +143,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` LL | target_feature = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512er`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512pf`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, `avx512vpopcntdq`, `bf16`, `bmi1`, `bmi2`, `bti`, `bulk-memory`, `c`, `cache`, `cmpxchg16b`, `crc`, `crt-static`, `d`, `d32`, `dit`, `doloop`, `dotprod`, `dpb`, `dpb2`, `dsp`, `dsp1e2`, `dspe60`, `e`, `e1`, `e2`, `edsp`, `elrw`, `ermsb`, `exception-handling`, `f`, `f16c`, `f32mm`, `f64mm`, `fast-unaligned-access`, `fcma`, `fdivdu`, `fhm`, `flagm`, `float1e2`, `float1e3`, `float3e4`, `float7e60`, `floate1`, `fma`, `fp-armv8`, `fp16`, `fp64`, `fpuv2_df`, `fpuv2_sf`, `fpuv3_df`, `fpuv3_hf`, `fpuv3_hi`, `fpuv3_sf`, `frintts`, `fxsr`, `gfni`, `hard-float`, `hard-float-abi`, `hard-tp`, `high-registers`, `hvx`, `hvx-length128b`, `hwdiv`, `i8mm`, `jsconv`, `lasx`, `lbt`, `lor`, `lse`, `lsx`, `lvz`, `lzcnt`, `m`, `mclass`, `movbe`, `mp`, `mp1e2`, `msa`, `mte`, `multivalue`, `mutable-globals`, `neon`, `nontrapping-fptoint`, `nvic`, `paca`, `pacg`, `pan`, `pclmulqdq`, `pmuv3`, `popcnt`, `power10-vector`, `power8-altivec`, `power8-vector`, `power9-altivec`, `power9-vector`, `rand`, `ras`, `rclass`, `rcpc`, `rcpc2`, `rdm`, `rdrand`, `rdseed`, `reference-types`, `relax`, `relaxed-simd`, `rtm`, `sb`, `sha`, `sha2`, `sha3`, `sign-ext`, `simd128`, `sm4`, `spe`, `ssbs`, `sse`, `sse2`, `sse3`, `sse4.1`, `sse4.2`, `sse4a`, `ssse3`, `sve`, `sve2`, `sve2-aes`, `sve2-bitperm`, `sve2-sha3`, `sve2-sm4`, `tbm`, `thumb-mode`, `thumb2`, `tme`, `trust`, `trustzone`, `ual`, `v`, `v5te`, `v6`, `v6k`, `v6t2`, `v7`, `v8`, `v8.1a`, `v8.2a`, `v8.3a`, `v8.4a`, `v8.5a`, `v8.6a`, `v8.7a`, `vaes`, `vdsp2e60f`, `vdspv1`, `vdspv2`, `vfp2`, `vfp3`, `vfp4`, `vh`, `virt`, `virtualization`, `vpclmulqdq`, `vsx`, `xsave`, `xsavec`, `xsaveopt`, `xsaves`, `zba`, `zbb`, `zbc`, `zbkb`, `zbkc`, `zbkx`, `zbs`, `zdinx`, `zfh`, `zfhmin`, `zfinx`, `zhinx`, `zhinxmin`, `zk`, `zkn`, `zknd`, `zkne`, `zknh`, `zkr`, `zks`, `zksed`, `zksh`, `zkt` + = note: expected values for `target_feature` are: `10e60`, `2e3`, `3e3r1`, `3e3r2`, `3e3r3`, `3e7`, `7e10`, `a`, `aclass`, `adx`, `aes`, `altivec`, `alu32`, `atomics`, `avx`, `avx2`, `avx512bf16`, `avx512bitalg`, `avx512bw`, `avx512cd`, `avx512dq`, `avx512er`, `avx512f`, `avx512fp16`, `avx512ifma`, `avx512pf`, `avx512vbmi`, `avx512vbmi2`, `avx512vl`, `avx512vnni`, `avx512vp2intersect`, `avx512vpopcntdq`, `bf16`, `bmi1`, `bmi2`, `bti`, `bulk-memory`, `c`, `cache`, `cmpxchg16b`, `crc`, `crt-static`, `d`, `d32`, `dit`, `doloop`, `dotprod`, `dpb`, `dpb2`, `dsp`, `dsp1e2`, `dspe60`, `e`, `e1`, `e2`, `edsp`, `elrw`, `ermsb`, `exception-handling`, `f`, `f16c`, `f32mm`, `f64mm`, `fast-unaligned-access`, `fcma`, `fdivdu`, `fhm`, `flagm`, `float1e2`, `float1e3`, `float3e4`, `float7e60`, `floate1`, `fma`, `fp-armv8`, `fp16`, `fp64`, `fpuv2_df`, `fpuv2_sf`, `fpuv3_df`, `fpuv3_hf`, `fpuv3_hi`, `fpuv3_sf`, `frintts`, `fxsr`, `gfni`, `hard-float`, `hard-float-abi`, `hard-tp`, `high-registers`, `hvx`, `hvx-length128b`, `hwdiv`, `i8mm`, `jsconv`, `lahfsahf`, `lasx`, `lbt`, `lor`, `lse`, `lsx`, `lvz`, `lzcnt`, `m`, `mclass`, `movbe`, `mp`, `mp1e2`, `msa`, `mte`, `multivalue`, `mutable-globals`, `neon`, `nontrapping-fptoint`, `nvic`, `paca`, `pacg`, `pan`, `pclmulqdq`, `pmuv3`, `popcnt`, `power10-vector`, `power8-altivec`, `power8-vector`, `power9-altivec`, `power9-vector`, `prfchw`, `rand`, `ras`, `rclass`, `rcpc`, `rcpc2`, `rdm`, `rdrand`, `rdseed`, `reference-types`, `relax`, `relaxed-simd`, `rtm`, `sb`, `sha`, `sha2`, `sha3`, `sign-ext`, `simd128`, `sm4`, `spe`, `ssbs`, `sse`, `sse2`, `sse3`, `sse4.1`, `sse4.2`, `sse4a`, `ssse3`, `sve`, `sve2`, `sve2-aes`, `sve2-bitperm`, `sve2-sha3`, `sve2-sm4`, `tbm`, `thumb-mode`, `thumb2`, `tme`, `trust`, `trustzone`, `ual`, `v`, `v5te`, `v6`, `v6k`, `v6t2`, `v7`, `v8`, `v8.1a`, `v8.2a`, `v8.3a`, `v8.4a`, `v8.5a`, `v8.6a`, `v8.7a`, `vaes`, `vdsp2e60f`, `vdspv1`, `vdspv2`, `vfp2`, `vfp3`, `vfp4`, `vh`, `virt`, `virtualization`, `vpclmulqdq`, `vsx`, `xsave`, `xsavec`, `xsaveopt`, `xsaves`, `zba`, `zbb`, `zbc`, `zbkb`, `zbkc`, `zbkx`, `zbs`, `zdinx`, `zfh`, `zfhmin`, `zfinx`, `zhinx`, `zhinxmin`, `zk`, `zkn`, `zknd`, `zkne`, `zknh`, `zkr`, `zks`, `zksed`, `zksh`, `zkt` = note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` diff --git a/tests/ui/closure-expected-type/expect-infer-var-appearing-twice.stderr b/tests/ui/closure-expected-type/expect-infer-var-appearing-twice.stderr index e2a2db7c3f0..c0f222b016d 100644 --- a/tests/ui/closure-expected-type/expect-infer-var-appearing-twice.stderr +++ b/tests/ui/closure-expected-type/expect-infer-var-appearing-twice.stderr @@ -9,8 +9,8 @@ LL | | LL | | }); | |______^ expected due to this | - = note: expected closure signature `fn(_, _) -> _` - found closure signature `fn(u32, i32) -> _` + = note: expected closure signature `fn(_, u32) -> _` + found closure signature `fn(_, i32) -> _` note: required by a bound in `with_closure` --> $DIR/expect-infer-var-appearing-twice.rs:2:14 | diff --git a/tests/ui/coercion/type-errors.rs b/tests/ui/coercion/type-errors.rs new file mode 100644 index 00000000000..a86789907a0 --- /dev/null +++ b/tests/ui/coercion/type-errors.rs @@ -0,0 +1,26 @@ +// Test that we don't ICE for coercions with type errors. +// We still need to properly go through coercions between types with errors instead of +// shortcutting and returning success, because we need the adjustments for building the MIR. + +pub fn has_error() -> TypeError {} +//~^ ERROR cannot find type `TypeError` in this scope + +// https://github.com/rust-lang/rust/issues/120884 +// Casting a function item to a data pointer in valid in HIR, but invalid in MIR. +// We need an adjustment (ReifyFnPointer) to insert a cast from the function item +// to a function pointer as a separate MIR statement. +pub fn cast() -> *const u8 { + has_error as *const u8 +} + +// https://github.com/rust-lang/rust/issues/120945 +// This one ICEd, because we skipped the builtin deref from `&TypeError` to `TypeError`. +pub fn autoderef_source(e: &TypeError) { + //~^ ERROR cannot find type `TypeError` in this scope + autoderef_target(e) +} + +pub fn autoderef_target(_: &TypeError) {} +//~^ ERROR cannot find type `TypeError` in this scope + +fn main() {} diff --git a/tests/ui/coercion/type-errors.stderr b/tests/ui/coercion/type-errors.stderr new file mode 100644 index 00000000000..14deb785f75 --- /dev/null +++ b/tests/ui/coercion/type-errors.stderr @@ -0,0 +1,21 @@ +error[E0412]: cannot find type `TypeError` in this scope + --> $DIR/type-errors.rs:5:23 + | +LL | pub fn has_error() -> TypeError {} + | ^^^^^^^^^ not found in this scope + +error[E0412]: cannot find type `TypeError` in this scope + --> $DIR/type-errors.rs:18:29 + | +LL | pub fn autoderef_source(e: &TypeError) { + | ^^^^^^^^^ not found in this scope + +error[E0412]: cannot find type `TypeError` in this scope + --> $DIR/type-errors.rs:23:29 + | +LL | pub fn autoderef_target(_: &TypeError) {} + | ^^^^^^^^^ not found in this scope + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0412`. diff --git a/tests/ui/coherence/coherence-impls-copy.stderr b/tests/ui/coherence/coherence-impls-copy.stderr index 21dbc606321..2d2c5064043 100644 --- a/tests/ui/coherence/coherence-impls-copy.stderr +++ b/tests/ui/coherence/coherence-impls-copy.stderr @@ -30,6 +30,12 @@ LL | impl Copy for &'static [NotSync] {} | = note: define and implement a trait or new type instead +error[E0206]: the trait `Copy` cannot be implemented for this type + --> $DIR/coherence-impls-copy.rs:21:15 + | +LL | impl Copy for &'static mut MyType {} + | ^^^^^^^^^^^^^^^^^^^ type is not a structure or enumeration + error[E0117]: only traits defined in the current crate can be implemented for arbitrary types --> $DIR/coherence-impls-copy.rs:25:1 | @@ -41,6 +47,12 @@ LL | impl Copy for (MyType, MyType) {} | = note: define and implement a trait or new type instead +error[E0206]: the trait `Copy` cannot be implemented for this type + --> $DIR/coherence-impls-copy.rs:25:15 + | +LL | impl Copy for (MyType, MyType) {} + | ^^^^^^^^^^^^^^^^ type is not a structure or enumeration + error[E0117]: only traits defined in the current crate can be implemented for arbitrary types --> $DIR/coherence-impls-copy.rs:30:1 | @@ -53,18 +65,6 @@ LL | impl Copy for [MyType] {} = note: define and implement a trait or new type instead error[E0206]: the trait `Copy` cannot be implemented for this type - --> $DIR/coherence-impls-copy.rs:21:15 - | -LL | impl Copy for &'static mut MyType {} - | ^^^^^^^^^^^^^^^^^^^ type is not a structure or enumeration - -error[E0206]: the trait `Copy` cannot be implemented for this type - --> $DIR/coherence-impls-copy.rs:25:15 - | -LL | impl Copy for (MyType, MyType) {} - | ^^^^^^^^^^^^^^^^ type is not a structure or enumeration - -error[E0206]: the trait `Copy` cannot be implemented for this type --> $DIR/coherence-impls-copy.rs:30:15 | LL | impl Copy for [MyType] {} diff --git a/tests/ui/const_prop/const-prop-read-static-in-const.rs b/tests/ui/const_prop/const-prop-read-static-in-const.rs deleted file mode 100644 index 21426205955..00000000000 --- a/tests/ui/const_prop/const-prop-read-static-in-const.rs +++ /dev/null @@ -1,10 +0,0 @@ -// compile-flags: -Zunleash-the-miri-inside-of-you - -#![allow(dead_code)] - -const TEST: u8 = MY_STATIC; //~ ERROR constant - -static MY_STATIC: u8 = 4; - -fn main() { -} diff --git a/tests/ui/const_prop/const-prop-read-static-in-const.stderr b/tests/ui/const_prop/const-prop-read-static-in-const.stderr deleted file mode 100644 index 9af1f7e3a24..00000000000 --- a/tests/ui/const_prop/const-prop-read-static-in-const.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/const-prop-read-static-in-const.rs:5:18 - | -LL | const TEST: u8 = MY_STATIC; - | ^^^^^^^^^ constant accesses static - -warning: skipping const checks - | -help: skipping check that does not even have a feature gate - --> $DIR/const-prop-read-static-in-const.rs:5:18 - | -LL | const TEST: u8 = MY_STATIC; - | ^^^^^^^^^ - -error: aborting due to 1 previous error; 1 warning emitted - -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-address-of-mut.rs b/tests/ui/consts/const-address-of-mut.rs index 5f0c76d6285..0018bf18e41 100644 --- a/tests/ui/consts/const-address-of-mut.rs +++ b/tests/ui/consts/const-address-of-mut.rs @@ -4,8 +4,6 @@ const A: () = { let mut x = 2; &raw mut x; }; //~ mutable pointer static B: () = { let mut x = 2; &raw mut x; }; //~ mutable pointer -static mut C: () = { let mut x = 2; &raw mut x; }; //~ mutable pointer - const fn foo() { let mut x = 0; let y = &raw mut x; //~ mutable pointer diff --git a/tests/ui/consts/const-address-of-mut.stderr b/tests/ui/consts/const-address-of-mut.stderr index 1b371fcee98..95a91ff463f 100644 --- a/tests/ui/consts/const-address-of-mut.stderr +++ b/tests/ui/consts/const-address-of-mut.stderr @@ -18,18 +18,8 @@ LL | static B: () = { let mut x = 2; &raw mut x; }; = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0658]: raw mutable pointers are not allowed in statics - --> $DIR/const-address-of-mut.rs:7:37 - | -LL | static mut C: () = { let mut x = 2; &raw mut x; }; - | ^^^^^^^^^^ - | - = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information - = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - error[E0658]: raw mutable pointers are not allowed in constant functions - --> $DIR/const-address-of-mut.rs:11:13 + --> $DIR/const-address-of-mut.rs:9:13 | LL | let y = &raw mut x; | ^^^^^^^^^^ @@ -38,6 +28,6 @@ LL | let y = &raw mut x; = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/consts/const-fn-not-safe-for-const.rs b/tests/ui/consts/const-fn-not-safe-for-const.rs index b2fe73ae930..6d8404880ca 100644 --- a/tests/ui/consts/const-fn-not-safe-for-const.rs +++ b/tests/ui/consts/const-fn-not-safe-for-const.rs @@ -18,12 +18,12 @@ static Y: u32 = 0; const fn get_Y() -> u32 { Y - //~^ ERROR E0013 + //~^ ERROR referencing statics in constant functions } const fn get_Y_addr() -> &'static u32 { &Y - //~^ ERROR E0013 + //~^ ERROR referencing statics in constant functions } const fn get() -> u32 { diff --git a/tests/ui/consts/const-fn-not-safe-for-const.stderr b/tests/ui/consts/const-fn-not-safe-for-const.stderr index 4c7effc0d15..7d7e94da86f 100644 --- a/tests/ui/consts/const-fn-not-safe-for-const.stderr +++ b/tests/ui/consts/const-fn-not-safe-for-const.stderr @@ -6,23 +6,31 @@ LL | random() | = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants -error[E0013]: constant functions cannot refer to statics +error[E0658]: referencing statics in constant functions is unstable --> $DIR/const-fn-not-safe-for-const.rs:20:5 | LL | Y | ^ | - = help: consider extracting the value of the `static` to a `const`, and referring to that + = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information + = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable. + = help: to fix this, the value can be extracted to a `const` and then used. -error[E0013]: constant functions cannot refer to statics +error[E0658]: referencing statics in constant functions is unstable --> $DIR/const-fn-not-safe-for-const.rs:25:6 | LL | &Y | ^ | - = help: consider extracting the value of the `static` to a `const`, and referring to that + = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information + = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable. + = help: to fix this, the value can be extracted to a `const` and then used. error: aborting due to 3 previous errors -Some errors have detailed explanations: E0013, E0015. -For more information about an error, try `rustc --explain E0013`. +Some errors have detailed explanations: E0015, E0658. +For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/const_refs_to_static.rs b/tests/ui/consts/const_refs_to_static.rs new file mode 100644 index 00000000000..f5e5ef5f699 --- /dev/null +++ b/tests/ui/consts/const_refs_to_static.rs @@ -0,0 +1,19 @@ +// run-pass +#![feature(const_refs_to_static)] + +static S: i32 = 0; +static mut S_MUT: i32 = 0; + +const C1: &i32 = &S; +#[allow(unused)] +const C1_READ: () = { + assert!(*C1 == 0); +}; +const C2: *const i32 = unsafe { std::ptr::addr_of!(S_MUT) }; + +fn main() { + assert_eq!(*C1, 0); + assert_eq!(unsafe { *C2 }, 0); + // Computing this pattern will read from an immutable static. That's fine. + assert!(matches!(&0, C1)); +} diff --git a/tests/ui/consts/const_refs_to_static_fail.rs b/tests/ui/consts/const_refs_to_static_fail.rs new file mode 100644 index 00000000000..d5bcccf82d5 --- /dev/null +++ b/tests/ui/consts/const_refs_to_static_fail.rs @@ -0,0 +1,21 @@ +// normalize-stderr-test "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" +// normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP" +#![feature(const_refs_to_static, const_mut_refs, sync_unsafe_cell)] +use std::cell::SyncUnsafeCell; + +static S: SyncUnsafeCell<i32> = SyncUnsafeCell::new(0); +static mut S_MUT: i32 = 0; + +const C1: &SyncUnsafeCell<i32> = &S; //~ERROR undefined behavior +//~| encountered reference to mutable memory +const C1_READ: () = unsafe { + assert!(*C1.get() == 0); +}; +const C2: *const i32 = unsafe { std::ptr::addr_of!(S_MUT) }; +const C2_READ: () = unsafe { + assert!(*C2 == 0); //~ERROR evaluation of constant value failed + //~^ constant accesses mutable global memory +}; + +fn main() { +} diff --git a/tests/ui/consts/const_refs_to_static_fail.stderr b/tests/ui/consts/const_refs_to_static_fail.stderr new file mode 100644 index 00000000000..cdabd86b183 --- /dev/null +++ b/tests/ui/consts/const_refs_to_static_fail.stderr @@ -0,0 +1,26 @@ +error[E0080]: it is undefined behavior to use this value + --> $DIR/const_refs_to_static_fail.rs:9:1 + | +LL | const C1: &SyncUnsafeCell<i32> = &S; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { + HEX_DUMP + } + +note: erroneous constant encountered + --> $DIR/const_refs_to_static_fail.rs:12:14 + | +LL | assert!(*C1.get() == 0); + | ^^ + +error[E0080]: evaluation of constant value failed + --> $DIR/const_refs_to_static_fail.rs:16:13 + | +LL | assert!(*C2 == 0); + | ^^^ constant accesses mutable global memory + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const_refs_to_static_fail_invalid.rs b/tests/ui/consts/const_refs_to_static_fail_invalid.rs new file mode 100644 index 00000000000..665b876c43e --- /dev/null +++ b/tests/ui/consts/const_refs_to_static_fail_invalid.rs @@ -0,0 +1,51 @@ +// normalize-stderr-test "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" +// normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*ALLOC[0-9]+(\+[a-z0-9]+)?(<imm>)?─*╼ )+ *│.*" -> "HEX_DUMP" +#![feature(const_refs_to_static)] +#![allow(static_mut_ref)] + +fn invalid() { + static S: i8 = 10; + + const C: &bool = unsafe { std::mem::transmute(&S) }; + //~^ERROR: undefined behavior + //~| expected a boolean + + // This must be rejected here (or earlier), since it's not a valid `&bool`. + match &true { + C => {} //~ERROR: could not evaluate constant pattern + _ => {} + } +} + +fn extern_() { + extern "C" { + static S: i8; + } + + const C: &i8 = unsafe { &S }; + //~^ERROR: undefined behavior + //~| `extern` static + + // This must be rejected here (or earlier), since the pattern cannot be read. + match &0 { + C => {} //~ERROR: could not evaluate constant pattern + _ => {} + } +} + +fn mutable() { + static mut S_MUT: i32 = 0; + + const C: &i32 = unsafe { &S_MUT }; + //~^ERROR: undefined behavior + //~| encountered reference to mutable memory + + // This *must not build*, the constant we are matching against + // could change its value! + match &42 { + C => {}, //~ERROR: could not evaluate constant pattern + _ => {}, + } +} + +fn main() {} diff --git a/tests/ui/consts/const_refs_to_static_fail_invalid.stderr b/tests/ui/consts/const_refs_to_static_fail_invalid.stderr new file mode 100644 index 00000000000..082f8532444 --- /dev/null +++ b/tests/ui/consts/const_refs_to_static_fail_invalid.stderr @@ -0,0 +1,54 @@ +error[E0080]: it is undefined behavior to use this value + --> $DIR/const_refs_to_static_fail_invalid.rs:9:5 + | +LL | const C: &bool = unsafe { std::mem::transmute(&S) }; + | ^^^^^^^^^^^^^^ constructing invalid value at .<deref>: encountered 0x0a, but expected a boolean + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { + HEX_DUMP + } + +error: could not evaluate constant pattern + --> $DIR/const_refs_to_static_fail_invalid.rs:15:9 + | +LL | C => {} + | ^ + +error[E0080]: it is undefined behavior to use this value + --> $DIR/const_refs_to_static_fail_invalid.rs:25:5 + | +LL | const C: &i8 = unsafe { &S }; + | ^^^^^^^^^^^^ constructing invalid value: encountered reference to `extern` static in `const` + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { + HEX_DUMP + } + +error: could not evaluate constant pattern + --> $DIR/const_refs_to_static_fail_invalid.rs:31:9 + | +LL | C => {} + | ^ + +error[E0080]: it is undefined behavior to use this value + --> $DIR/const_refs_to_static_fail_invalid.rs:39:5 + | +LL | const C: &i32 = unsafe { &S_MUT }; + | ^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { + HEX_DUMP + } + +error: could not evaluate constant pattern + --> $DIR/const_refs_to_static_fail_invalid.rs:46:9 + | +LL | C => {}, + | ^ + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/cycle-static-promoted.rs b/tests/ui/consts/cycle-static-promoted.rs new file mode 100644 index 00000000000..5838dc58a3a --- /dev/null +++ b/tests/ui/consts/cycle-static-promoted.rs @@ -0,0 +1,12 @@ +// check-pass + +struct Value { + values: &'static [&'static Value], +} + +// This `static` recursively points to itself through a promoted (the slice). +static VALUE: Value = Value { + values: &[&VALUE], +}; + +fn main() {} diff --git a/tests/ui/consts/issue-17718-const-bad-values.rs b/tests/ui/consts/issue-17718-const-bad-values.rs index 4fedc48452b..0299bfef1b4 100644 --- a/tests/ui/consts/issue-17718-const-bad-values.rs +++ b/tests/ui/consts/issue-17718-const-bad-values.rs @@ -1,10 +1,10 @@ +#![allow(static_mut_ref)] + const C1: &'static mut [usize] = &mut []; //~^ ERROR: mutable references are not allowed static mut S: usize = 3; const C2: &'static mut usize = unsafe { &mut S }; -//~^ WARN mutable reference of mutable static is discouraged [static_mut_ref] -//~^^ ERROR: constants cannot refer to statics -//~| ERROR: constants cannot refer to statics +//~^ ERROR: referencing statics in constants fn main() {} diff --git a/tests/ui/consts/issue-17718-const-bad-values.stderr b/tests/ui/consts/issue-17718-const-bad-values.stderr index 2dc91f52669..57fcb1c7e9a 100644 --- a/tests/ui/consts/issue-17718-const-bad-values.stderr +++ b/tests/ui/consts/issue-17718-const-bad-values.stderr @@ -1,42 +1,22 @@ -warning: mutable reference of mutable static is discouraged - --> $DIR/issue-17718-const-bad-values.rs:5:41 - | -LL | const C2: &'static mut usize = unsafe { &mut S }; - | ^^^^^^ mutable reference of mutable static - | - = note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447> - = note: reference of mutable static is a hard error from 2024 edition - = note: mutable statics can be written to by multiple threads: aliasing violations or data races will cause undefined behavior - = note: `#[warn(static_mut_ref)]` on by default -help: mutable references are dangerous since if there's any other pointer or reference used for that static while the reference lives, that's UB; use `addr_of_mut!` instead to create a raw pointer - | -LL | const C2: &'static mut usize = unsafe { addr_of_mut!(S) }; - | ~~~~~~~~~~~~~~~ - error[E0764]: mutable references are not allowed in the final value of constants - --> $DIR/issue-17718-const-bad-values.rs:1:34 + --> $DIR/issue-17718-const-bad-values.rs:3:34 | LL | const C1: &'static mut [usize] = &mut []; | ^^^^^^^ -error[E0013]: constants cannot refer to statics - --> $DIR/issue-17718-const-bad-values.rs:5:46 - | -LL | const C2: &'static mut usize = unsafe { &mut S }; - | ^ - | - = help: consider extracting the value of the `static` to a `const`, and referring to that - -error[E0013]: constants cannot refer to statics - --> $DIR/issue-17718-const-bad-values.rs:5:46 +error[E0658]: referencing statics in constants is unstable + --> $DIR/issue-17718-const-bad-values.rs:7:46 | LL | const C2: &'static mut usize = unsafe { &mut S }; | ^ | - = help: consider extracting the value of the `static` to a `const`, and referring to that - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information + = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable. + = help: to fix this, the value can be extracted to a `const` and then used. -error: aborting due to 3 previous errors; 1 warning emitted +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0013, E0764. -For more information about an error, try `rustc --explain E0013`. +Some errors have detailed explanations: E0658, E0764. +For more information about an error, try `rustc --explain E0658`. diff --git a/tests/ui/consts/issue-17718-references.rs b/tests/ui/consts/issue-17718-references.rs index 03d5f8bb3f1..6a8955f4634 100644 --- a/tests/ui/consts/issue-17718-references.rs +++ b/tests/ui/consts/issue-17718-references.rs @@ -6,18 +6,18 @@ const C: usize = 1; static S: usize = 1; const T1: &'static usize = &C; -const T2: &'static usize = &S; //~ ERROR: constants cannot refer to statics +const T2: &'static usize = &S; //~ ERROR: referencing statics in constants static T3: &'static usize = &C; static T4: &'static usize = &S; const T5: usize = C; -const T6: usize = S; //~ ERROR: constants cannot refer to statics +const T6: usize = S; //~ ERROR: referencing statics in constants static T7: usize = C; static T8: usize = S; const T9: Struct = Struct { a: C }; const T10: Struct = Struct { a: S }; -//~^ ERROR: constants cannot refer to statics +//~^ ERROR: referencing statics in constants static T11: Struct = Struct { a: C }; static T12: Struct = Struct { a: S }; diff --git a/tests/ui/consts/issue-17718-references.stderr b/tests/ui/consts/issue-17718-references.stderr index e3c3b369ffb..8b572203781 100644 --- a/tests/ui/consts/issue-17718-references.stderr +++ b/tests/ui/consts/issue-17718-references.stderr @@ -1,27 +1,39 @@ -error[E0013]: constants cannot refer to statics +error[E0658]: referencing statics in constants is unstable --> $DIR/issue-17718-references.rs:9:29 | LL | const T2: &'static usize = &S; | ^ | - = help: consider extracting the value of the `static` to a `const`, and referring to that + = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information + = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable. + = help: to fix this, the value can be extracted to a `const` and then used. -error[E0013]: constants cannot refer to statics +error[E0658]: referencing statics in constants is unstable --> $DIR/issue-17718-references.rs:14:19 | LL | const T6: usize = S; | ^ | - = help: consider extracting the value of the `static` to a `const`, and referring to that + = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information + = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable. + = help: to fix this, the value can be extracted to a `const` and then used. -error[E0013]: constants cannot refer to statics +error[E0658]: referencing statics in constants is unstable --> $DIR/issue-17718-references.rs:19:33 | LL | const T10: Struct = Struct { a: S }; | ^ | - = help: consider extracting the value of the `static` to a `const`, and referring to that + = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information + = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable. + = help: to fix this, the value can be extracted to a `const` and then used. error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0013`. +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/consts/issue-52060.rs b/tests/ui/consts/issue-52060.rs index 13b914c0331..0f16ede0400 100644 --- a/tests/ui/consts/issue-52060.rs +++ b/tests/ui/consts/issue-52060.rs @@ -2,6 +2,6 @@ // The compiler shouldn't ICE in this case static A: &'static [u32] = &[1]; static B: [u32; 1] = [0; A.len()]; -//~^ ERROR [E0013] +//~^ ERROR referencing statics in constants fn main() {} diff --git a/tests/ui/consts/issue-52060.stderr b/tests/ui/consts/issue-52060.stderr index 27d00ad0442..644a5314622 100644 --- a/tests/ui/consts/issue-52060.stderr +++ b/tests/ui/consts/issue-52060.stderr @@ -1,11 +1,15 @@ -error[E0013]: constants cannot refer to statics +error[E0658]: referencing statics in constants is unstable --> $DIR/issue-52060.rs:4:26 | LL | static B: [u32; 1] = [0; A.len()]; | ^ | - = help: consider extracting the value of the `static` to a `const`, and referring to that + = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information + = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable. + = help: to fix this, the value can be extracted to a `const` and then used. error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0013`. +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/consts/min_const_fn/min_const_fn.rs b/tests/ui/consts/min_const_fn/min_const_fn.rs index c2891488c7f..76245c08ffc 100644 --- a/tests/ui/consts/min_const_fn/min_const_fn.rs +++ b/tests/ui/consts/min_const_fn/min_const_fn.rs @@ -86,8 +86,8 @@ const fn foo11_2<T: Send>(t: T) -> T { t } // not ok static BAR: u32 = 42; -const fn foo25() -> u32 { BAR } //~ ERROR cannot refer to statics -const fn foo26() -> &'static u32 { &BAR } //~ ERROR cannot refer to statics +const fn foo25() -> u32 { BAR } //~ ERROR referencing statics in constant functions +const fn foo26() -> &'static u32 { &BAR } //~ ERROR referencing statics in constant functions const fn foo30(x: *const u32) -> usize { x as usize } //~^ ERROR pointers cannot be cast to integers const fn foo30_with_unsafe(x: *const u32) -> usize { unsafe { x as usize } } diff --git a/tests/ui/consts/min_const_fn/min_const_fn.stderr b/tests/ui/consts/min_const_fn/min_const_fn.stderr index d646c7de8da..daa0ab2614f 100644 --- a/tests/ui/consts/min_const_fn/min_const_fn.stderr +++ b/tests/ui/consts/min_const_fn/min_const_fn.stderr @@ -142,21 +142,29 @@ LL | const fn get_mut_sq(&mut self) -> &mut T { &mut self.0 } = help: add `#![feature(const_mut_refs)]` 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[E0013]: constant functions cannot refer to statics +error[E0658]: referencing statics in constant functions is unstable --> $DIR/min_const_fn.rs:89:27 | LL | const fn foo25() -> u32 { BAR } | ^^^ | - = help: consider extracting the value of the `static` to a `const`, and referring to that + = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information + = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable. + = help: to fix this, the value can be extracted to a `const` and then used. -error[E0013]: constant functions cannot refer to statics +error[E0658]: referencing statics in constant functions is unstable --> $DIR/min_const_fn.rs:90:37 | LL | const fn foo26() -> &'static u32 { &BAR } | ^^^ | - = help: consider extracting the value of the `static` to a `const`, and referring to that + = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information + = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable. + = help: to fix this, the value can be extracted to a `const` and then used. error: pointers cannot be cast to integers during const eval --> $DIR/min_const_fn.rs:91:42 @@ -222,5 +230,5 @@ LL | const fn no_apit(_x: impl std::fmt::Debug) {} error: aborting due to 24 previous errors -Some errors have detailed explanations: E0013, E0493, E0658. -For more information about an error, try `rustc --explain E0013`. +Some errors have detailed explanations: E0493, E0658. +For more information about an error, try `rustc --explain E0493`. diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static.32bit.stderr b/tests/ui/consts/miri_unleashed/const_refers_to_static.32bit.stderr index 5fe8e250df9..9e76b873858 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static.32bit.stderr +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static.32bit.stderr @@ -8,50 +8,28 @@ error[E0080]: evaluation of constant value failed --> $DIR/const_refers_to_static.rs:14:14 | LL | unsafe { *(&FOO as *const _ as *const usize) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses mutable global memory error[E0080]: evaluation of constant value failed --> $DIR/const_refers_to_static.rs:18:32 | LL | const READ_MUT: u32 = unsafe { MUTABLE }; - | ^^^^^^^ constant accesses static + | ^^^^^^^ constant accesses mutable global memory error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refers_to_static.rs:20:1 + --> $DIR/const_refers_to_static.rs:21:1 | LL | const REF_INTERIOR_MUT: &usize = { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { ╾ALLOC0<imm>╼ │ ╾──╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refers_to_static.rs:27:1 - | -LL | const READ_IMMUT: &usize = { - | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 4, align: 4) { - ╾ALLOC1<imm>╼ │ ╾──╼ - } - -error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refers_to_static.rs:34:1 - | -LL | const REF_IMMUT: &u8 = &MY_STATIC; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 4, align: 4) { - ╾ALLOC2<imm>╼ │ ╾──╼ - } - warning: skipping const checks | -help: skipping check that does not even have a feature gate +help: skipping check for `const_refs_to_static` feature --> $DIR/const_refers_to_static.rs:9:5 | LL | FOO.fetch_add(1, Ordering::Relaxed) @@ -61,37 +39,27 @@ help: skipping check that does not even have a feature gate | LL | FOO.fetch_add(1, Ordering::Relaxed) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: skipping check that does not even have a feature gate +help: skipping check for `const_refs_to_static` feature --> $DIR/const_refers_to_static.rs:14:17 | LL | unsafe { *(&FOO as *const _ as *const usize) } | ^^^ -help: skipping check that does not even have a feature gate +help: skipping check for `const_refs_to_static` feature --> $DIR/const_refers_to_static.rs:18:32 | LL | const READ_MUT: u32 = unsafe { MUTABLE }; | ^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static.rs:18:32 - | -LL | const READ_MUT: u32 = unsafe { MUTABLE }; - | ^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static.rs:23:18 +help: skipping check for `const_refs_to_static` feature + --> $DIR/const_refers_to_static.rs:24:18 | LL | unsafe { &*(&FOO as *const _ as *const usize) } | ^^^ -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static.rs:30:6 - | -LL | &FOO - | ^^^ -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static.rs:34:25 +help: skipping check for `const_refs_to_static` feature + --> $DIR/const_refers_to_static.rs:29:25 | LL | const REF_IMMUT: &u8 = &MY_STATIC; | ^^^^^^^^^ -error: aborting due to 6 previous errors; 1 warning emitted +error: aborting due to 4 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static.64bit.stderr b/tests/ui/consts/miri_unleashed/const_refers_to_static.64bit.stderr index a80b07056a3..989d3c75cd6 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static.64bit.stderr +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static.64bit.stderr @@ -8,50 +8,28 @@ error[E0080]: evaluation of constant value failed --> $DIR/const_refers_to_static.rs:14:14 | LL | unsafe { *(&FOO as *const _ as *const usize) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses mutable global memory error[E0080]: evaluation of constant value failed --> $DIR/const_refers_to_static.rs:18:32 | LL | const READ_MUT: u32 = unsafe { MUTABLE }; - | ^^^^^^^ constant accesses static + | ^^^^^^^ constant accesses mutable global memory error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refers_to_static.rs:20:1 + --> $DIR/const_refers_to_static.rs:21:1 | LL | const REF_INTERIOR_MUT: &usize = { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { ╾ALLOC0<imm>╼ │ ╾──────╼ } -error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refers_to_static.rs:27:1 - | -LL | const READ_IMMUT: &usize = { - | ^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 8, align: 8) { - ╾ALLOC1<imm>╼ │ ╾──────╼ - } - -error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refers_to_static.rs:34:1 - | -LL | const REF_IMMUT: &u8 = &MY_STATIC; - | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 8, align: 8) { - ╾ALLOC2<imm>╼ │ ╾──────╼ - } - warning: skipping const checks | -help: skipping check that does not even have a feature gate +help: skipping check for `const_refs_to_static` feature --> $DIR/const_refers_to_static.rs:9:5 | LL | FOO.fetch_add(1, Ordering::Relaxed) @@ -61,37 +39,27 @@ help: skipping check that does not even have a feature gate | LL | FOO.fetch_add(1, Ordering::Relaxed) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: skipping check that does not even have a feature gate +help: skipping check for `const_refs_to_static` feature --> $DIR/const_refers_to_static.rs:14:17 | LL | unsafe { *(&FOO as *const _ as *const usize) } | ^^^ -help: skipping check that does not even have a feature gate +help: skipping check for `const_refs_to_static` feature --> $DIR/const_refers_to_static.rs:18:32 | LL | const READ_MUT: u32 = unsafe { MUTABLE }; | ^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static.rs:18:32 - | -LL | const READ_MUT: u32 = unsafe { MUTABLE }; - | ^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static.rs:23:18 +help: skipping check for `const_refs_to_static` feature + --> $DIR/const_refers_to_static.rs:24:18 | LL | unsafe { &*(&FOO as *const _ as *const usize) } | ^^^ -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static.rs:30:6 - | -LL | &FOO - | ^^^ -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static.rs:34:25 +help: skipping check for `const_refs_to_static` feature + --> $DIR/const_refers_to_static.rs:29:25 | LL | const REF_IMMUT: &u8 = &MY_STATIC; | ^^^^^^^^^ -error: aborting due to 6 previous errors; 1 warning emitted +error: aborting due to 4 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static.rs b/tests/ui/consts/miri_unleashed/const_refers_to_static.rs index df2563d8d7f..f8d956b3dd8 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static.rs +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static.rs @@ -17,22 +17,16 @@ const READ_INTERIOR_MUT: usize = { static mut MUTABLE: u32 = 0; const READ_MUT: u32 = unsafe { MUTABLE }; //~ERROR evaluation of constant value failed -const REF_INTERIOR_MUT: &usize = { //~ ERROR undefined behavior to use this value -//~| encountered a reference pointing to a static variable +// Evaluating this does not read anything mutable, but validation does, so this should error. +const REF_INTERIOR_MUT: &usize = { //~ ERROR undefined behavior + //~| encountered reference to mutable memory static FOO: AtomicUsize = AtomicUsize::new(0); unsafe { &*(&FOO as *const _ as *const usize) } }; -// ok some day perhaps -const READ_IMMUT: &usize = { //~ ERROR it is undefined behavior to use this value -//~| encountered a reference pointing to a static variable - static FOO: usize = 0; - &FOO -}; - +// Not actually reading from anything mutable, so these are fine. static MY_STATIC: u8 = 4; const REF_IMMUT: &u8 = &MY_STATIC; -//~^ ERROR it is undefined behavior to use this value -//~| encountered a reference pointing to a static variable +const READ_IMMUT: u8 = *REF_IMMUT; fn main() {} diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.32bit.stderr b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.32bit.stderr index ed9db675426..db7e8b6847a 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.32bit.stderr +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.32bit.stderr @@ -1,23 +1,8 @@ -warning: shared reference of mutable static is discouraged - --> $DIR/const_refers_to_static_cross_crate.rs:13:14 - | -LL | unsafe { &static_cross_crate::ZERO } - | ^^^^^^^^^^^^^^^^^^^^^^^^^ shared reference of mutable static - | - = note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447> - = note: reference of mutable static is a hard error from 2024 edition - = note: mutable statics can be written to by multiple threads: aliasing violations or data races will cause undefined behavior - = note: `#[warn(static_mut_ref)]` on by default -help: shared references are dangerous since if there's any kind of mutation of that static while the reference lives, that's UB; use `addr_of!` instead to create a raw pointer - | -LL | unsafe { addr_of!(static_cross_crate::ZERO) } - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refers_to_static_cross_crate.rs:10:1 + --> $DIR/const_refers_to_static_cross_crate.rs:11:1 | LL | const SLICE_MUT: &[u8; 1] = { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant + | ^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { @@ -25,16 +10,16 @@ LL | const SLICE_MUT: &[u8; 1] = { } error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:42:9 + --> $DIR/const_refers_to_static_cross_crate.rs:39:9 | LL | SLICE_MUT => true, | ^^^^^^^^^ error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refers_to_static_cross_crate.rs:17:1 + --> $DIR/const_refers_to_static_cross_crate.rs:16:1 | LL | const U8_MUT: &u8 = { - | ^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant + | ^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { @@ -42,93 +27,63 @@ LL | const U8_MUT: &u8 = { } error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:50:9 + --> $DIR/const_refers_to_static_cross_crate.rs:47:9 | LL | U8_MUT => true, | ^^^^^^ -error[E0080]: evaluation of constant value failed - --> $DIR/const_refers_to_static_cross_crate.rs:25:15 +error[E0080]: it is undefined behavior to use this value + --> $DIR/const_refers_to_static_cross_crate.rs:22:1 | -LL | unsafe { &(*static_cross_crate::ZERO_REF)[0] } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static +LL | const U8_MUT2: &u8 = { + | ^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: 4, align: 4) { + ╾ALLOC0<imm>╼ │ ╾──╼ + } error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:60:9 + --> $DIR/const_refers_to_static_cross_crate.rs:57:9 | LL | U8_MUT2 => true, | ^^^^^^^ error[E0080]: evaluation of constant value failed - --> $DIR/const_refers_to_static_cross_crate.rs:31:15 + --> $DIR/const_refers_to_static_cross_crate.rs:28:15 | LL | match static_cross_crate::OPT_ZERO { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses mutable global memory error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:67:9 + --> $DIR/const_refers_to_static_cross_crate.rs:64:9 | LL | U8_MUT3 => true, | ^^^^^^^ warning: skipping const checks | -help: skipping check that does not even have a feature gate +help: skipping check for `const_refs_to_static` feature --> $DIR/const_refers_to_static_cross_crate.rs:13:15 | LL | unsafe { &static_cross_crate::ZERO } | ^^^^^^^^^^^^^^^^^^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:13:15 - | -LL | unsafe { &static_cross_crate::ZERO } - | ^^^^^^^^^^^^^^^^^^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:20:15 +help: skipping check for `const_refs_to_static` feature + --> $DIR/const_refers_to_static_cross_crate.rs:18:15 | LL | unsafe { &static_cross_crate::ZERO[0] } | ^^^^^^^^^^^^^^^^^^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:20:15 - | -LL | unsafe { &static_cross_crate::ZERO[0] } - | ^^^^^^^^^^^^^^^^^^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:20:15 - | -LL | unsafe { &static_cross_crate::ZERO[0] } - | ^^^^^^^^^^^^^^^^^^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:25:17 +help: skipping check for `const_refs_to_static` feature + --> $DIR/const_refers_to_static_cross_crate.rs:24:17 | LL | unsafe { &(*static_cross_crate::ZERO_REF)[0] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:31:15 - | -LL | match static_cross_crate::OPT_ZERO { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:31:15 - | -LL | match static_cross_crate::OPT_ZERO { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:31:15 - | -LL | match static_cross_crate::OPT_ZERO { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:31:15 - | -LL | match static_cross_crate::OPT_ZERO { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:31:15 +help: skipping check for `const_refs_to_static` feature + --> $DIR/const_refers_to_static_cross_crate.rs:28:15 | LL | match static_cross_crate::OPT_ZERO { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 8 previous errors; 2 warnings emitted +error: aborting due to 8 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.64bit.stderr b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.64bit.stderr index 275323bc286..200faf35587 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.64bit.stderr +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.64bit.stderr @@ -1,23 +1,8 @@ -warning: shared reference of mutable static is discouraged - --> $DIR/const_refers_to_static_cross_crate.rs:13:14 - | -LL | unsafe { &static_cross_crate::ZERO } - | ^^^^^^^^^^^^^^^^^^^^^^^^^ shared reference of mutable static - | - = note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447> - = note: reference of mutable static is a hard error from 2024 edition - = note: mutable statics can be written to by multiple threads: aliasing violations or data races will cause undefined behavior - = note: `#[warn(static_mut_ref)]` on by default -help: shared references are dangerous since if there's any kind of mutation of that static while the reference lives, that's UB; use `addr_of!` instead to create a raw pointer - | -LL | unsafe { addr_of!(static_cross_crate::ZERO) } - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refers_to_static_cross_crate.rs:10:1 + --> $DIR/const_refers_to_static_cross_crate.rs:11:1 | LL | const SLICE_MUT: &[u8; 1] = { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant + | ^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { @@ -25,16 +10,16 @@ LL | const SLICE_MUT: &[u8; 1] = { } error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:42:9 + --> $DIR/const_refers_to_static_cross_crate.rs:39:9 | LL | SLICE_MUT => true, | ^^^^^^^^^ error[E0080]: it is undefined behavior to use this value - --> $DIR/const_refers_to_static_cross_crate.rs:17:1 + --> $DIR/const_refers_to_static_cross_crate.rs:16:1 | LL | const U8_MUT: &u8 = { - | ^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant + | ^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { @@ -42,93 +27,63 @@ LL | const U8_MUT: &u8 = { } error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:50:9 + --> $DIR/const_refers_to_static_cross_crate.rs:47:9 | LL | U8_MUT => true, | ^^^^^^ -error[E0080]: evaluation of constant value failed - --> $DIR/const_refers_to_static_cross_crate.rs:25:15 +error[E0080]: it is undefined behavior to use this value + --> $DIR/const_refers_to_static_cross_crate.rs:22:1 | -LL | unsafe { &(*static_cross_crate::ZERO_REF)[0] } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static +LL | const U8_MUT2: &u8 = { + | ^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: 8, align: 8) { + ╾ALLOC0<imm>╼ │ ╾──────╼ + } error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:60:9 + --> $DIR/const_refers_to_static_cross_crate.rs:57:9 | LL | U8_MUT2 => true, | ^^^^^^^ error[E0080]: evaluation of constant value failed - --> $DIR/const_refers_to_static_cross_crate.rs:31:15 + --> $DIR/const_refers_to_static_cross_crate.rs:28:15 | LL | match static_cross_crate::OPT_ZERO { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses mutable global memory error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:67:9 + --> $DIR/const_refers_to_static_cross_crate.rs:64:9 | LL | U8_MUT3 => true, | ^^^^^^^ warning: skipping const checks | -help: skipping check that does not even have a feature gate +help: skipping check for `const_refs_to_static` feature --> $DIR/const_refers_to_static_cross_crate.rs:13:15 | LL | unsafe { &static_cross_crate::ZERO } | ^^^^^^^^^^^^^^^^^^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:13:15 - | -LL | unsafe { &static_cross_crate::ZERO } - | ^^^^^^^^^^^^^^^^^^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:20:15 +help: skipping check for `const_refs_to_static` feature + --> $DIR/const_refers_to_static_cross_crate.rs:18:15 | LL | unsafe { &static_cross_crate::ZERO[0] } | ^^^^^^^^^^^^^^^^^^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:20:15 - | -LL | unsafe { &static_cross_crate::ZERO[0] } - | ^^^^^^^^^^^^^^^^^^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:20:15 - | -LL | unsafe { &static_cross_crate::ZERO[0] } - | ^^^^^^^^^^^^^^^^^^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:25:17 +help: skipping check for `const_refs_to_static` feature + --> $DIR/const_refers_to_static_cross_crate.rs:24:17 | LL | unsafe { &(*static_cross_crate::ZERO_REF)[0] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:31:15 - | -LL | match static_cross_crate::OPT_ZERO { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:31:15 - | -LL | match static_cross_crate::OPT_ZERO { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:31:15 - | -LL | match static_cross_crate::OPT_ZERO { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:31:15 - | -LL | match static_cross_crate::OPT_ZERO { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:31:15 +help: skipping check for `const_refs_to_static` feature + --> $DIR/const_refers_to_static_cross_crate.rs:28:15 | LL | match static_cross_crate::OPT_ZERO { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 8 previous errors; 2 warnings emitted +error: aborting due to 8 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs index 3eafa58d9f9..bcd29f8b034 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs @@ -2,35 +2,32 @@ // aux-build:static_cross_crate.rs // stderr-per-bitwidth #![feature(exclusive_range_pattern, half_open_range_patterns_in_slices)] +#![allow(static_mut_ref)] extern crate static_cross_crate; // Sneaky: reference to a mutable static. // Allowing this would be a disaster for pattern matching, we could violate exhaustiveness checking! -const SLICE_MUT: &[u8; 1] = { - //~^ ERROR undefined behavior to use this value - //~| encountered a reference pointing to a static variable +const SLICE_MUT: &[u8; 1] = { //~ ERROR undefined behavior + //~| encountered reference to mutable memory unsafe { &static_cross_crate::ZERO } - //~^ WARN shared reference of mutable static is discouraged [static_mut_ref] }; -const U8_MUT: &u8 = { - //~^ ERROR undefined behavior to use this value - //~| encountered a reference pointing to a static variable +const U8_MUT: &u8 = { //~ ERROR undefined behavior + //~| encountered reference to mutable memory unsafe { &static_cross_crate::ZERO[0] } }; // Also test indirection that reads from other static. -const U8_MUT2: &u8 = { +const U8_MUT2: &u8 = { //~ ERROR undefined behavior + //~| encountered reference to mutable memory unsafe { &(*static_cross_crate::ZERO_REF)[0] } - //~^ ERROR evaluation of constant value failed - //~| constant accesses static }; const U8_MUT3: &u8 = { unsafe { match static_cross_crate::OPT_ZERO { //~^ ERROR evaluation of constant value failed - //~| constant accesses static + //~| constant accesses mutable global memory Some(ref u) => u, None => panic!(), } diff --git a/tests/ui/consts/miri_unleashed/extern-static.rs b/tests/ui/consts/miri_unleashed/extern-static.rs new file mode 100644 index 00000000000..81176b3d4e9 --- /dev/null +++ b/tests/ui/consts/miri_unleashed/extern-static.rs @@ -0,0 +1,24 @@ +// compile-flags: -Zunleash-the-miri-inside-of-you +#![feature(thread_local)] +#![allow(static_mut_ref)] + +extern "C" { + static mut DATA: u8; +} + +// Make sure we catch accessing extern static. +static TEST_READ: () = { + unsafe { let _val = DATA; } + //~^ ERROR could not evaluate static initializer + //~| NOTE cannot access extern static +}; +static TEST_WRITE: () = { + unsafe { DATA = 0; } + //~^ ERROR could not evaluate static initializer + //~| NOTE cannot access extern static +}; + +// Just creating a reference is fine, as long as we are not reading or writing. +static TEST_REF: &u8 = unsafe { &DATA }; + +fn main() {} diff --git a/tests/ui/consts/miri_unleashed/extern-static.stderr b/tests/ui/consts/miri_unleashed/extern-static.stderr new file mode 100644 index 00000000000..0979a5e4fb1 --- /dev/null +++ b/tests/ui/consts/miri_unleashed/extern-static.stderr @@ -0,0 +1,15 @@ +error[E0080]: could not evaluate static initializer + --> $DIR/extern-static.rs:11:25 + | +LL | unsafe { let _val = DATA; } + | ^^^^ cannot access extern static (DefId(0:4 ~ extern_static[c41e]::{extern#0}::DATA)) + +error[E0080]: could not evaluate static initializer + --> $DIR/extern-static.rs:16:14 + | +LL | unsafe { DATA = 0; } + | ^^^^^^^^ cannot access extern static (DefId(0:4 ~ extern_static[c41e]::{extern#0}::DATA)) + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/miri_unleashed/mutable_references_err.32bit.stderr b/tests/ui/consts/miri_unleashed/mutable_references_err.32bit.stderr index 2df80020fdc..401cf46710a 100644 --- a/tests/ui/consts/miri_unleashed/mutable_references_err.32bit.stderr +++ b/tests/ui/consts/miri_unleashed/mutable_references_err.32bit.stderr @@ -42,18 +42,24 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/mutable_references_err.rs:47:1 | LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 4, align: 4) { ╾ALLOC2<imm>╼ │ ╾──╼ } +note: erroneous constant encountered + --> $DIR/mutable_references_err.rs:49:34 + | +LL | const READS_FROM_MUTABLE: i32 = *POINTS_TO_MUTABLE1; + | ^^^^^^^^^^^^^^^^^^ + error[E0080]: evaluation of constant value failed --> $DIR/mutable_references_err.rs:51:43 | LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF }; - | ^^^^^^^^^^^^^ constant accesses static + | ^^^^^^^^^^^^^ constant accesses mutable global memory error: encountered mutable pointer in final value of constant --> $DIR/mutable_references_err.rs:55:1 @@ -103,12 +109,7 @@ help: skipping check that does not even have a feature gate | LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:32:40 - | -LL | const SUBTLE: &mut i32 = unsafe { &mut FOO }; - | ^^^ -help: skipping check that does not even have a feature gate +help: skipping check for `const_refs_to_static` feature --> $DIR/mutable_references_err.rs:32:40 | LL | const SUBTLE: &mut i32 = unsafe { &mut FOO }; @@ -133,32 +134,12 @@ help: skipping check for `const_mut_refs` feature | LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:40:49 - | -LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: skipping check that does not even have a feature gate +help: skipping check for `const_refs_to_static` feature --> $DIR/mutable_references_err.rs:47:44 | LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE }; | ^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:47:44 - | -LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE }; - | ^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:50:36 - | -LL | static mut MUTABLE_REF: &mut i32 = &mut 42; - | ^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:51:45 - | -LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF }; - | ^^^^^^^^^^^ -help: skipping check that does not even have a feature gate +help: skipping check for `const_refs_to_static` feature --> $DIR/mutable_references_err.rs:51:45 | LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF }; diff --git a/tests/ui/consts/miri_unleashed/mutable_references_err.64bit.stderr b/tests/ui/consts/miri_unleashed/mutable_references_err.64bit.stderr index 3ff6811ea61..0eb01f5b773 100644 --- a/tests/ui/consts/miri_unleashed/mutable_references_err.64bit.stderr +++ b/tests/ui/consts/miri_unleashed/mutable_references_err.64bit.stderr @@ -42,18 +42,24 @@ error[E0080]: it is undefined behavior to use this value --> $DIR/mutable_references_err.rs:47:1 | LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered reference to mutable memory in `const` | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 8, align: 8) { ╾ALLOC2<imm>╼ │ ╾──────╼ } +note: erroneous constant encountered + --> $DIR/mutable_references_err.rs:49:34 + | +LL | const READS_FROM_MUTABLE: i32 = *POINTS_TO_MUTABLE1; + | ^^^^^^^^^^^^^^^^^^ + error[E0080]: evaluation of constant value failed --> $DIR/mutable_references_err.rs:51:43 | LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF }; - | ^^^^^^^^^^^^^ constant accesses static + | ^^^^^^^^^^^^^ constant accesses mutable global memory error: encountered mutable pointer in final value of constant --> $DIR/mutable_references_err.rs:55:1 @@ -103,12 +109,7 @@ help: skipping check that does not even have a feature gate | LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:32:40 - | -LL | const SUBTLE: &mut i32 = unsafe { &mut FOO }; - | ^^^ -help: skipping check that does not even have a feature gate +help: skipping check for `const_refs_to_static` feature --> $DIR/mutable_references_err.rs:32:40 | LL | const SUBTLE: &mut i32 = unsafe { &mut FOO }; @@ -133,32 +134,12 @@ help: skipping check for `const_mut_refs` feature | LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:40:49 - | -LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -help: skipping check that does not even have a feature gate +help: skipping check for `const_refs_to_static` feature --> $DIR/mutable_references_err.rs:47:44 | LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE }; | ^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:47:44 - | -LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE }; - | ^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:50:36 - | -LL | static mut MUTABLE_REF: &mut i32 = &mut 42; - | ^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:51:45 - | -LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF }; - | ^^^^^^^^^^^ -help: skipping check that does not even have a feature gate +help: skipping check for `const_refs_to_static` feature --> $DIR/mutable_references_err.rs:51:45 | LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF }; diff --git a/tests/ui/consts/miri_unleashed/mutable_references_err.rs b/tests/ui/consts/miri_unleashed/mutable_references_err.rs index 83a460dadd0..43b65f459a1 100644 --- a/tests/ui/consts/miri_unleashed/mutable_references_err.rs +++ b/tests/ui/consts/miri_unleashed/mutable_references_err.rs @@ -42,15 +42,15 @@ static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as //~| pointing to read-only memory // Check for consts pointing to mutable memory. -// Currently it's not even possible to create such a const. +// These are fine as long as they are not being read. static mut MUTABLE: i32 = 42; -const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE }; -//~^ ERROR: undefined behavior to use this value -//~| pointing to a static +const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE }; //~ERROR: undefined behavior +//~| encountered reference to mutable memory +const READS_FROM_MUTABLE: i32 = *POINTS_TO_MUTABLE1; static mut MUTABLE_REF: &mut i32 = &mut 42; const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF }; //~^ ERROR: evaluation of constant value failed -//~| accesses static +//~| accesses mutable global memory const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _; //~^ ERROR: mutable pointer in final value diff --git a/tests/ui/consts/miri_unleashed/tls.rs b/tests/ui/consts/miri_unleashed/tls.rs index d06d7cf19f7..7319a5135d3 100644 --- a/tests/ui/consts/miri_unleashed/tls.rs +++ b/tests/ui/consts/miri_unleashed/tls.rs @@ -14,6 +14,8 @@ static TEST_BAD: () = { }; // Make sure we catch taking a reference to thread-local storage. +// The actual pointer depends on the thread, so even just taking a reference already does not make +// sense at compile-time. static TEST_BAD_REF: () = { unsafe { let _val = &A; } //~^ ERROR could not evaluate static initializer diff --git a/tests/ui/consts/miri_unleashed/tls.stderr b/tests/ui/consts/miri_unleashed/tls.stderr index ec24527d6c0..a00b7eb1312 100644 --- a/tests/ui/consts/miri_unleashed/tls.stderr +++ b/tests/ui/consts/miri_unleashed/tls.stderr @@ -5,7 +5,7 @@ LL | unsafe { let _val = A; } | ^ cannot access thread local static (DefId(0:4 ~ tls[ca29]::A)) error[E0080]: could not evaluate static initializer - --> $DIR/tls.rs:18:26 + --> $DIR/tls.rs:20:26 | LL | unsafe { let _val = &A; } | ^ cannot access thread local static (DefId(0:4 ~ tls[ca29]::A)) @@ -18,7 +18,7 @@ help: skipping check that does not even have a feature gate LL | unsafe { let _val = A; } | ^ help: skipping check that does not even have a feature gate - --> $DIR/tls.rs:18:26 + --> $DIR/tls.rs:20:26 | LL | unsafe { let _val = &A; } | ^ diff --git a/tests/ui/consts/static-mut-refs.rs b/tests/ui/consts/static-mut-refs.rs new file mode 100644 index 00000000000..ff865da5aa8 --- /dev/null +++ b/tests/ui/consts/static-mut-refs.rs @@ -0,0 +1,24 @@ +// run-pass +#![allow(dead_code)] + +// Checks that mutable static items can have mutable slices and other references + + +static mut TEST: &'static mut [isize] = &mut [1]; +static mut EMPTY: &'static mut [isize] = &mut []; +static mut INT: &'static mut isize = &mut 1; + +// And the same for raw pointers. + +static mut TEST_RAW: *mut [isize] = &mut [1isize] as *mut _; +static mut EMPTY_RAW: *mut [isize] = &mut [] as *mut _; +static mut INT_RAW: *mut isize = &mut 1isize as *mut _; + +pub fn main() { + unsafe { + TEST[0] += 1; + assert_eq!(TEST[0], 2); + *INT_RAW += 1; + assert_eq!(*INT_RAW, 2); + } +} diff --git a/tests/ui/consts/static-promoted-to-mutable-static.rs b/tests/ui/consts/static-promoted-to-mutable-static.rs new file mode 100644 index 00000000000..d49ba478dbc --- /dev/null +++ b/tests/ui/consts/static-promoted-to-mutable-static.rs @@ -0,0 +1,33 @@ +// check-pass +#![allow(non_camel_case_types, non_upper_case_globals, static_mut_ref)] + +pub struct wl_interface { + pub version: i32 +} + +pub struct Interface { + pub other_interfaces: &'static [&'static Interface], + pub c_ptr: Option<&'static wl_interface>, +} + +pub static mut wl_callback_interface: wl_interface = wl_interface { + version: 0, +}; + +pub static WL_CALLBACK_INTERFACE: Interface = Interface { + other_interfaces: &[], + c_ptr: Some(unsafe { &wl_callback_interface }), +}; + +// This static contains a promoted that points to a static that points to a mutable static. +pub static WL_SURFACE_INTERFACE: Interface = Interface { + other_interfaces: &[&WL_CALLBACK_INTERFACE], + c_ptr: None, +}; + +// And another variant of the same thing, this time with interior mutability. +use std::sync::OnceLock; +static LAZY_INIT: OnceLock<u32> = OnceLock::new(); +static LAZY_INIT_REF: &[&OnceLock<u32>] = &[&LAZY_INIT]; + +fn main() {} diff --git a/tests/ui/consts/static_mut_containing_mut_ref.rs b/tests/ui/consts/static_mut_containing_mut_ref.rs index 874aa59df0b..495804649b1 100644 --- a/tests/ui/consts/static_mut_containing_mut_ref.rs +++ b/tests/ui/consts/static_mut_containing_mut_ref.rs @@ -1,8 +1,8 @@ // build-pass (FIXME(62277): could be check-pass?) +#![allow(static_mut_ref)] static mut STDERR_BUFFER_SPACE: [u8; 42] = [0u8; 42]; pub static mut STDERR_BUFFER: *mut [u8] = unsafe { &mut STDERR_BUFFER_SPACE }; -//~^ WARN mutable reference of mutable static is discouraged [static_mut_ref] fn main() {} diff --git a/tests/ui/consts/static_mut_containing_mut_ref.stderr b/tests/ui/consts/static_mut_containing_mut_ref.stderr deleted file mode 100644 index 56ceba41cf8..00000000000 --- a/tests/ui/consts/static_mut_containing_mut_ref.stderr +++ /dev/null @@ -1,17 +0,0 @@ -warning: mutable reference of mutable static is discouraged - --> $DIR/static_mut_containing_mut_ref.rs:5:52 - | -LL | pub static mut STDERR_BUFFER: *mut [u8] = unsafe { &mut STDERR_BUFFER_SPACE }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ mutable reference of mutable static - | - = note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447> - = note: reference of mutable static is a hard error from 2024 edition - = note: mutable statics can be written to by multiple threads: aliasing violations or data races will cause undefined behavior - = note: `#[warn(static_mut_ref)]` on by default -help: mutable references are dangerous since if there's any other pointer or reference used for that static while the reference lives, that's UB; use `addr_of_mut!` instead to create a raw pointer - | -LL | pub static mut STDERR_BUFFER: *mut [u8] = unsafe { addr_of_mut!(STDERR_BUFFER_SPACE) }; - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -warning: 1 warning emitted - diff --git a/tests/ui/consts/static_mut_containing_mut_ref2.mut_refs.stderr b/tests/ui/consts/static_mut_containing_mut_ref2.mut_refs.stderr index bc32ecc2c35..42cb119d2ae 100644 --- a/tests/ui/consts/static_mut_containing_mut_ref2.mut_refs.stderr +++ b/tests/ui/consts/static_mut_containing_mut_ref2.mut_refs.stderr @@ -1,24 +1,9 @@ -warning: mutable reference of mutable static is discouraged - --> $DIR/static_mut_containing_mut_ref2.rs:8:6 - | -LL | *(&mut STDERR_BUFFER_SPACE) = 42; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ mutable reference of mutable static - | - = note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447> - = note: reference of mutable static is a hard error from 2024 edition - = note: mutable statics can be written to by multiple threads: aliasing violations or data races will cause undefined behavior - = note: `#[warn(static_mut_ref)]` on by default -help: mutable references are dangerous since if there's any other pointer or reference used for that static while the reference lives, that's UB; use `addr_of_mut!` instead to create a raw pointer - | -LL | *addr_of_mut!(STDERR_BUFFER_SPACE) = 42; - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - error[E0080]: could not evaluate static initializer --> $DIR/static_mut_containing_mut_ref2.rs:8:5 | LL | *(&mut STDERR_BUFFER_SPACE) = 42; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ modifying a static's initial value from another static's initializer -error: aborting due to 1 previous error; 1 warning emitted +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/static_mut_containing_mut_ref2.rs b/tests/ui/consts/static_mut_containing_mut_ref2.rs index fa79a78eab4..e60a17922fd 100644 --- a/tests/ui/consts/static_mut_containing_mut_ref2.rs +++ b/tests/ui/consts/static_mut_containing_mut_ref2.rs @@ -1,5 +1,5 @@ // revisions: stock mut_refs - +#![allow(static_mut_ref)] #![cfg_attr(mut_refs, feature(const_mut_refs))] static mut STDERR_BUFFER_SPACE: u8 = 0; @@ -7,9 +7,7 @@ static mut STDERR_BUFFER_SPACE: u8 = 0; pub static mut STDERR_BUFFER: () = unsafe { *(&mut STDERR_BUFFER_SPACE) = 42; //[mut_refs]~^ ERROR could not evaluate static initializer - //[stock]~^^ ERROR mutable references are not allowed in statics - //[mut_refs]~^^^ WARN mutable reference of mutable static is discouraged [static_mut_ref] - //[stock]~^^^^ WARN mutable reference of mutable static is discouraged [static_mut_ref] + //[stock]~^^ ERROR mutation through a reference is not allowed in statics }; fn main() {} diff --git a/tests/ui/consts/static_mut_containing_mut_ref2.stock.stderr b/tests/ui/consts/static_mut_containing_mut_ref2.stock.stderr index e9fe82d2f87..5ff9c0b6e2b 100644 --- a/tests/ui/consts/static_mut_containing_mut_ref2.stock.stderr +++ b/tests/ui/consts/static_mut_containing_mut_ref2.stock.stderr @@ -1,28 +1,13 @@ -warning: mutable reference of mutable static is discouraged - --> $DIR/static_mut_containing_mut_ref2.rs:8:6 +error[E0658]: mutation through a reference is not allowed in statics + --> $DIR/static_mut_containing_mut_ref2.rs:8:5 | LL | *(&mut STDERR_BUFFER_SPACE) = 42; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ mutable reference of mutable static - | - = note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447> - = note: reference of mutable static is a hard error from 2024 edition - = note: mutable statics can be written to by multiple threads: aliasing violations or data races will cause undefined behavior - = note: `#[warn(static_mut_ref)]` on by default -help: mutable references are dangerous since if there's any other pointer or reference used for that static while the reference lives, that's UB; use `addr_of_mut!` instead to create a raw pointer - | -LL | *addr_of_mut!(STDERR_BUFFER_SPACE) = 42; - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -error[E0658]: mutable references are not allowed in statics - --> $DIR/static_mut_containing_mut_ref2.rs:8:6 - | -LL | *(&mut STDERR_BUFFER_SPACE) = 42; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information = help: add `#![feature(const_mut_refs)]` 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; 1 warning emitted +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/did_you_mean/bad-assoc-ty.stderr b/tests/ui/did_you_mean/bad-assoc-ty.stderr index d5754bdc664..4a119f673c8 100644 --- a/tests/ui/did_you_mean/bad-assoc-ty.stderr +++ b/tests/ui/did_you_mean/bad-assoc-ty.stderr @@ -191,14 +191,7 @@ error[E0223]: ambiguous associated type --> $DIR/bad-assoc-ty.rs:33:10 | LL | type H = Fn(u8) -> (u8)::Output; - | ^^^^^^^^^^^^^^^^^^^^^^ - | -help: use fully-qualified syntax - | -LL | type H = <(dyn Fn(u8) -> u8 + 'static) as AsyncFnOnce>::Output; - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -LL | type H = <(dyn Fn(u8) -> u8 + 'static) as IntoFuture>::Output; - | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + | ^^^^^^^^^^^^^^^^^^^^^^ help: use fully-qualified syntax: `<(dyn Fn(u8) -> u8 + 'static) as IntoFuture>::Output` error[E0223]: ambiguous associated type --> $DIR/bad-assoc-ty.rs:39:19 diff --git a/tests/ui/drop/drop_elaboration_with_errors.rs b/tests/ui/drop/drop_elaboration_with_errors.rs new file mode 100644 index 00000000000..77862762e87 --- /dev/null +++ b/tests/ui/drop/drop_elaboration_with_errors.rs @@ -0,0 +1,20 @@ +// can't use build-fail, because this also fails check-fail, but +// the ICE from #120787 only reproduces on build-fail. +// compile-flags: --emit=mir + +#![feature(type_alias_impl_trait)] + +struct Foo { + field: String, +} + +type Tait = impl Sized; + +fn ice_cold(beverage: Tait) { + let Foo { field } = beverage; + _ = field; +} + +fn main() { + Ok(()) //~ ERROR mismatched types +} diff --git a/tests/ui/drop/drop_elaboration_with_errors.stderr b/tests/ui/drop/drop_elaboration_with_errors.stderr new file mode 100644 index 00000000000..bec229631e1 --- /dev/null +++ b/tests/ui/drop/drop_elaboration_with_errors.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/drop_elaboration_with_errors.rs:19:5 + | +LL | fn main() { + | - expected `()` because of default return type +LL | Ok(()) + | ^^^^^^ expected `()`, found `Result<(), _>` + | + = note: expected unit type `()` + found enum `Result<(), _>` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/error-codes/E0013.rs b/tests/ui/error-codes/E0013.rs deleted file mode 100644 index 9b3982a785b..00000000000 --- a/tests/ui/error-codes/E0013.rs +++ /dev/null @@ -1,4 +0,0 @@ -static X: i32 = 42; -const Y: i32 = X; //~ ERROR constants cannot refer to statics [E0013] - -fn main() {} diff --git a/tests/ui/error-codes/E0013.stderr b/tests/ui/error-codes/E0013.stderr deleted file mode 100644 index b07c8bdb700..00000000000 --- a/tests/ui/error-codes/E0013.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0013]: constants cannot refer to statics - --> $DIR/E0013.rs:2:16 - | -LL | const Y: i32 = X; - | ^ - | - = help: consider extracting the value of the `static` to a `const`, and referring to that - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0013`. diff --git a/tests/ui/error-codes/E0401.rs b/tests/ui/error-codes/E0401.rs index 8f8d6b87ef2..a120198b728 100644 --- a/tests/ui/error-codes/E0401.rs +++ b/tests/ui/error-codes/E0401.rs @@ -9,8 +9,6 @@ fn foo<T>(x: T) { (y: T) { //~ ERROR E0401 } bfnr(x); - //~^ ERROR type annotations needed - //~| ERROR type annotations needed } diff --git a/tests/ui/error-codes/E0401.stderr b/tests/ui/error-codes/E0401.stderr index 754867061c7..5d6878620c8 100644 --- a/tests/ui/error-codes/E0401.stderr +++ b/tests/ui/error-codes/E0401.stderr @@ -21,7 +21,7 @@ LL | (y: T) { | ^ use of generic parameter from outer item error[E0401]: can't use `Self` from outer item - --> $DIR/E0401.rs:24:25 + --> $DIR/E0401.rs:22:25 | LL | impl<T> Iterator for A<T> { | ---- `Self` type implicitly declared here, by this `impl` @@ -32,45 +32,6 @@ LL | fn helper(sel: &Self) -> u8 { | use of `Self` from outer item | refer to the type directly here instead -error[E0283]: type annotations needed - --> $DIR/E0401.rs:11:5 - | -LL | bfnr(x); - | ^^^^ cannot infer type of the type parameter `V` declared on the function `bfnr` - | - = note: cannot satisfy `_: Baz<_>` -note: required by a bound in `bfnr` - --> $DIR/E0401.rs:4:19 - | -LL | fn bfnr<U, V: Baz<U>, W: Fn()>(y: T) { - | ^^^^^^ required by this bound in `bfnr` -help: consider specifying the generic arguments - | -LL | bfnr::<U, V, W>(x); - | +++++++++++ - -error[E0283]: type annotations needed - --> $DIR/E0401.rs:11:5 - | -LL | bfnr(x); - | ^^^^ cannot infer type of the type parameter `W` declared on the function `bfnr` - | - = note: multiple `impl`s satisfying `_: Fn()` found in the following crates: `alloc`, `core`: - - impl<A, F> Fn<A> for &F - where A: Tuple, F: Fn<A>, F: ?Sized; - - impl<Args, F, A> Fn<Args> for Box<F, A> - where Args: Tuple, F: Fn<Args>, A: Allocator, F: ?Sized; -note: required by a bound in `bfnr` - --> $DIR/E0401.rs:4:30 - | -LL | fn bfnr<U, V: Baz<U>, W: Fn()>(y: T) { - | ^^^^ required by this bound in `bfnr` -help: consider specifying the generic arguments - | -LL | bfnr::<U, V, W>(x); - | +++++++++++ - -error: aborting due to 5 previous errors +error: aborting due to 3 previous errors -Some errors have detailed explanations: E0283, E0401. -For more information about an error, try `rustc --explain E0283`. +For more information about this error, try `rustc --explain E0401`. diff --git a/tests/ui/feature-gates/feature-gate-associated_type_bounds.rs b/tests/ui/feature-gates/feature-gate-associated_type_bounds.rs index f87d3aab635..717da41f871 100644 --- a/tests/ui/feature-gates/feature-gate-associated_type_bounds.rs +++ b/tests/ui/feature-gates/feature-gate-associated_type_bounds.rs @@ -42,31 +42,20 @@ type _TaWhere1<T> where T: Iterator<Item: Copy> = T; fn _apit(_: impl Tr1<As1: Copy>) {} //~^ ERROR associated type bounds are unstable -fn _apit_dyn(_: &dyn Tr1<As1: Copy>) {} -//~^ ERROR associated type bounds are unstable fn _rpit() -> impl Tr1<As1: Copy> { S1 } //~^ ERROR associated type bounds are unstable -fn _rpit_dyn() -> Box<dyn Tr1<As1: Copy>> { Box::new(S1) } -//~^ ERROR associated type bounds are unstable - const _cdef: impl Tr1<As1: Copy> = S1; //~^ ERROR associated type bounds are unstable //~| ERROR `impl Trait` is not allowed in const types -// FIXME: uncomment when `impl_trait_in_bindings` feature is fixed. -// const _cdef_dyn: &dyn Tr1<As1: Copy> = &S1; static _sdef: impl Tr1<As1: Copy> = S1; //~^ ERROR associated type bounds are unstable //~| ERROR `impl Trait` is not allowed in static types -// FIXME: uncomment when `impl_trait_in_bindings` feature is fixed. -// static _sdef_dyn: &dyn Tr1<As1: Copy> = &S1; fn main() { let _: impl Tr1<As1: Copy> = S1; //~^ ERROR associated type bounds are unstable //~| ERROR `impl Trait` is not allowed in the type of variable bindings - // FIXME: uncomment when `impl_trait_in_bindings` feature is fixed. - // let _: &dyn Tr1<As1: Copy> = &S1; } diff --git a/tests/ui/feature-gates/feature-gate-associated_type_bounds.stderr b/tests/ui/feature-gates/feature-gate-associated_type_bounds.stderr index 855a29953f1..1838eab5cda 100644 --- a/tests/ui/feature-gates/feature-gate-associated_type_bounds.stderr +++ b/tests/ui/feature-gates/feature-gate-associated_type_bounds.stderr @@ -69,17 +69,7 @@ LL | fn _apit(_: impl Tr1<As1: Copy>) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:45:26 - | -LL | fn _apit_dyn(_: &dyn Tr1<As1: Copy>) {} - | ^^^^^^^^^ - | - = note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information - = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:48:24 + --> $DIR/feature-gate-associated_type_bounds.rs:46:24 | LL | fn _rpit() -> impl Tr1<As1: Copy> { S1 } | ^^^^^^^^^ @@ -89,17 +79,7 @@ LL | fn _rpit() -> impl Tr1<As1: Copy> { S1 } = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:51:31 - | -LL | fn _rpit_dyn() -> Box<dyn Tr1<As1: Copy>> { Box::new(S1) } - | ^^^^^^^^^ - | - = note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information - = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:54:23 + --> $DIR/feature-gate-associated_type_bounds.rs:49:23 | LL | const _cdef: impl Tr1<As1: Copy> = S1; | ^^^^^^^^^ @@ -109,7 +89,7 @@ LL | const _cdef: impl Tr1<As1: Copy> = S1; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:60:24 + --> $DIR/feature-gate-associated_type_bounds.rs:53:24 | LL | static _sdef: impl Tr1<As1: Copy> = S1; | ^^^^^^^^^ @@ -119,7 +99,7 @@ LL | static _sdef: impl Tr1<As1: Copy> = S1; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: associated type bounds are unstable - --> $DIR/feature-gate-associated_type_bounds.rs:67:21 + --> $DIR/feature-gate-associated_type_bounds.rs:58:21 | LL | let _: impl Tr1<As1: Copy> = S1; | ^^^^^^^^^ @@ -129,7 +109,7 @@ LL | let _: impl Tr1<As1: Copy> = S1; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0562]: `impl Trait` is not allowed in const types - --> $DIR/feature-gate-associated_type_bounds.rs:54:14 + --> $DIR/feature-gate-associated_type_bounds.rs:49:14 | LL | const _cdef: impl Tr1<As1: Copy> = S1; | ^^^^^^^^^^^^^^^^^^^ @@ -137,7 +117,7 @@ LL | const _cdef: impl Tr1<As1: Copy> = S1; = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in static types - --> $DIR/feature-gate-associated_type_bounds.rs:60:15 + --> $DIR/feature-gate-associated_type_bounds.rs:53:15 | LL | static _sdef: impl Tr1<As1: Copy> = S1; | ^^^^^^^^^^^^^^^^^^^ @@ -145,14 +125,14 @@ LL | static _sdef: impl Tr1<As1: Copy> = S1; = note: `impl Trait` is only allowed in arguments and return types of functions and methods error[E0562]: `impl Trait` is not allowed in the type of variable bindings - --> $DIR/feature-gate-associated_type_bounds.rs:67:12 + --> $DIR/feature-gate-associated_type_bounds.rs:58:12 | LL | let _: impl Tr1<As1: Copy> = S1; | ^^^^^^^^^^^^^^^^^^^ | = note: `impl Trait` is only allowed in arguments and return types of functions and methods -error: aborting due to 16 previous errors +error: aborting due to 14 previous errors Some errors have detailed explanations: E0562, E0658. For more information about an error, try `rustc --explain E0562`. diff --git a/tests/ui/feature-gates/feature-gate-const-refs-to-static.rs b/tests/ui/feature-gates/feature-gate-const-refs-to-static.rs new file mode 100644 index 00000000000..008b754dc6c --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-const-refs-to-static.rs @@ -0,0 +1,11 @@ +static S: i32 = 0; +static mut S_MUT: i32 = 0; + +const C1: &i32 = &S; //~ERROR: referencing statics in constants is unstable +const C1_READ: () = { + assert!(*C1 == 0); +}; +const C2: *const i32 = unsafe { std::ptr::addr_of!(S_MUT) }; //~ERROR: referencing statics in constants is unstable + +fn main() { +} diff --git a/tests/ui/feature-gates/feature-gate-const-refs-to-static.stderr b/tests/ui/feature-gates/feature-gate-const-refs-to-static.stderr new file mode 100644 index 00000000000..5af48471250 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-const-refs-to-static.stderr @@ -0,0 +1,27 @@ +error[E0658]: referencing statics in constants is unstable + --> $DIR/feature-gate-const-refs-to-static.rs:4:19 + | +LL | const C1: &i32 = &S; + | ^ + | + = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information + = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable. + = help: to fix this, the value can be extracted to a `const` and then used. + +error[E0658]: referencing statics in constants is unstable + --> $DIR/feature-gate-const-refs-to-static.rs:8:52 + | +LL | const C2: *const i32 = unsafe { std::ptr::addr_of!(S_MUT) }; + | ^^^^^ + | + = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information + = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable. + = help: to fix this, the value can be extracted to a `const` and then used. + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-unnamed_fields.rs b/tests/ui/feature-gates/feature-gate-unnamed_fields.rs index 4bbd0c83bfb..302a9bbeb45 100644 --- a/tests/ui/feature-gates/feature-gate-unnamed_fields.rs +++ b/tests/ui/feature-gates/feature-gate-unnamed_fields.rs @@ -1,24 +1,27 @@ +#[repr(C)] struct Foo { foo: u8, _: union { //~ ERROR unnamed fields are not yet fully implemented [E0658] //~^ ERROR unnamed fields are not yet fully implemented [E0658] - //~| ERROR anonymous unions are unimplemented bar: u8, baz: u16 } } +#[repr(C)] union Bar { foobar: u8, _: struct { //~ ERROR unnamed fields are not yet fully implemented [E0658] //~^ ERROR unnamed fields are not yet fully implemented [E0658] - //~| ERROR anonymous structs are unimplemented foobaz: u8, barbaz: u16 } } +#[repr(C)] struct S; + +#[repr(C)] struct Baz { _: S //~ ERROR unnamed fields are not yet fully implemented [E0658] } diff --git a/tests/ui/feature-gates/feature-gate-unnamed_fields.stderr b/tests/ui/feature-gates/feature-gate-unnamed_fields.stderr index 82f08912bc8..bc9e95bab98 100644 --- a/tests/ui/feature-gates/feature-gate-unnamed_fields.stderr +++ b/tests/ui/feature-gates/feature-gate-unnamed_fields.stderr @@ -1,5 +1,5 @@ error[E0658]: unnamed fields are not yet fully implemented - --> $DIR/feature-gate-unnamed_fields.rs:3:5 + --> $DIR/feature-gate-unnamed_fields.rs:4:5 | LL | _: union { | ^ @@ -9,12 +9,11 @@ LL | _: union { = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: unnamed fields are not yet fully implemented - --> $DIR/feature-gate-unnamed_fields.rs:3:8 + --> $DIR/feature-gate-unnamed_fields.rs:4:8 | LL | _: union { | ________^ LL | | -LL | | LL | | bar: u8, LL | | baz: u16 LL | | } @@ -25,7 +24,7 @@ LL | | } = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: unnamed fields are not yet fully implemented - --> $DIR/feature-gate-unnamed_fields.rs:13:5 + --> $DIR/feature-gate-unnamed_fields.rs:14:5 | LL | _: struct { | ^ @@ -35,12 +34,11 @@ LL | _: struct { = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: unnamed fields are not yet fully implemented - --> $DIR/feature-gate-unnamed_fields.rs:13:8 + --> $DIR/feature-gate-unnamed_fields.rs:14:8 | LL | _: struct { | ________^ LL | | -LL | | LL | | foobaz: u8, LL | | barbaz: u16 LL | | } @@ -51,7 +49,7 @@ LL | | } = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: unnamed fields are not yet fully implemented - --> $DIR/feature-gate-unnamed_fields.rs:23:5 + --> $DIR/feature-gate-unnamed_fields.rs:26:5 | LL | _: S | ^ @@ -60,30 +58,6 @@ LL | _: S = help: add `#![feature(unnamed_fields)]` 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: anonymous unions are unimplemented - --> $DIR/feature-gate-unnamed_fields.rs:3:8 - | -LL | _: union { - | ________^ -LL | | -LL | | -LL | | bar: u8, -LL | | baz: u16 -LL | | } - | |_____^ - -error: anonymous structs are unimplemented - --> $DIR/feature-gate-unnamed_fields.rs:13:8 - | -LL | _: struct { - | ________^ -LL | | -LL | | -LL | | foobaz: u8, -LL | | barbaz: u16 -LL | | } - | |_____^ - -error: aborting due to 7 previous errors +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/generic-associated-types/equality-bound.rs b/tests/ui/generic-associated-types/equality-bound.rs index fcc2da8014f..be05181f5d0 100644 --- a/tests/ui/generic-associated-types/equality-bound.rs +++ b/tests/ui/generic-associated-types/equality-bound.rs @@ -12,4 +12,71 @@ fn sum3<J: Iterator>(i: J) -> i32 where I::Item = i32 { panic!() } +use std::iter::FromIterator; + +struct X {} + +impl FromIterator<bool> for X { + fn from_iter<T>(_: T) -> Self where T: IntoIterator, IntoIterator::Item = A, + //~^ ERROR equality constraints are not yet supported in `where` clauses + //~| ERROR cannot find type `A` in this scope + { + todo!() + } +} + +struct Y {} + +impl FromIterator<bool> for Y { + fn from_iter<T>(_: T) -> Self where T: IntoIterator, T::Item = A, + //~^ ERROR equality constraints are not yet supported in `where` clauses + //~| ERROR cannot find type `A` in this scope + { + todo!() + } +} + +struct Z {} + +impl FromIterator<bool> for Z { + fn from_iter<T: IntoIterator>(_: T) -> Self where IntoIterator::Item = A, + //~^ ERROR equality constraints are not yet supported in `where` clauses + //~| ERROR cannot find type `A` in this scope + { + todo!() + } +} + +struct K {} + +impl FromIterator<bool> for K { + fn from_iter<T: IntoIterator>(_: T) -> Self where T::Item = A, + //~^ ERROR equality constraints are not yet supported in `where` clauses + //~| ERROR cannot find type `A` in this scope + { + todo!() + } +} + +struct L {} + +impl FromIterator<bool> for L { + fn from_iter<T>(_: T) -> Self where IntoIterator::Item = A, T: IntoIterator, + //~^ ERROR equality constraints are not yet supported in `where` clauses + //~| ERROR cannot find type `A` in this scope + { + todo!() + } +} + +struct M {} + +impl FromIterator<bool> for M { + fn from_iter<T>(_: T) -> Self where T::Item = A, T: IntoIterator, + //~^ ERROR equality constraints are not yet supported in `where` clauses + //~| ERROR cannot find type `A` in this scope + { + todo!() + } +} fn main() {} diff --git a/tests/ui/generic-associated-types/equality-bound.stderr b/tests/ui/generic-associated-types/equality-bound.stderr index b21ff30a27d..a054c06caeb 100644 --- a/tests/ui/generic-associated-types/equality-bound.stderr +++ b/tests/ui/generic-associated-types/equality-bound.stderr @@ -8,7 +8,7 @@ LL | fn sum<I: Iterator<Item = ()>>(i: I) -> i32 where I::Item = i32 { help: if `Iterator::Item` is an associated type you're trying to set, use the associated type binding syntax | LL - fn sum<I: Iterator<Item = ()>>(i: I) -> i32 where I::Item = i32 { -LL + fn sum<I: Iterator<Item = (), Item = i32>>(i: I) -> i32 where { +LL + fn sum<I: Iterator<Item = (), Item = i32>>(i: I) -> i32 { | error: equality constraints are not yet supported in `where` clauses @@ -21,7 +21,7 @@ LL | fn sum2<I: Iterator>(i: I) -> i32 where I::Item = i32 { help: if `Iterator::Item` is an associated type you're trying to set, use the associated type binding syntax | LL - fn sum2<I: Iterator>(i: I) -> i32 where I::Item = i32 { -LL + fn sum2<I: Iterator<Item = i32>>(i: I) -> i32 where { +LL + fn sum2<I: Iterator<Item = i32>>(i: I) -> i32 { | error: equality constraints are not yet supported in `where` clauses @@ -32,6 +32,138 @@ LL | fn sum3<J: Iterator>(i: J) -> i32 where I::Item = i32 { | = note: see issue #20041 <https://github.com/rust-lang/rust/issues/20041> for more information +error: equality constraints are not yet supported in `where` clauses + --> $DIR/equality-bound.rs:20:58 + | +LL | fn from_iter<T>(_: T) -> Self where T: IntoIterator, IntoIterator::Item = A, + | ^^^^^^^^^^^^^^^^^^^^^^ not supported + | + = note: see issue #20041 <https://github.com/rust-lang/rust/issues/20041> for more information +help: if `IntoIterator::Item` is an associated type you're trying to set, use the associated type binding syntax + | +LL - fn from_iter<T>(_: T) -> Self where T: IntoIterator, IntoIterator::Item = A, +LL + fn from_iter<T>(_: T) -> Self where T: IntoIterator<Item = A>, + | + +error: equality constraints are not yet supported in `where` clauses + --> $DIR/equality-bound.rs:31:58 + | +LL | fn from_iter<T>(_: T) -> Self where T: IntoIterator, T::Item = A, + | ^^^^^^^^^^^ not supported + | + = note: see issue #20041 <https://github.com/rust-lang/rust/issues/20041> for more information +help: if `IntoIterator::Item` is an associated type you're trying to set, use the associated type binding syntax + | +LL - fn from_iter<T>(_: T) -> Self where T: IntoIterator, T::Item = A, +LL + fn from_iter<T>(_: T) -> Self where T: IntoIterator<Item = A>, + | + +error: equality constraints are not yet supported in `where` clauses + --> $DIR/equality-bound.rs:42:55 + | +LL | fn from_iter<T: IntoIterator>(_: T) -> Self where IntoIterator::Item = A, + | ^^^^^^^^^^^^^^^^^^^^^^ not supported + | + = note: see issue #20041 <https://github.com/rust-lang/rust/issues/20041> for more information +help: if `IntoIterator::Item` is an associated type you're trying to set, use the associated type binding syntax + | +LL - fn from_iter<T: IntoIterator>(_: T) -> Self where IntoIterator::Item = A, +LL + fn from_iter<T: IntoIterator<Item = A>>(_: T) -> Self + | + +error: equality constraints are not yet supported in `where` clauses + --> $DIR/equality-bound.rs:53:55 + | +LL | fn from_iter<T: IntoIterator>(_: T) -> Self where T::Item = A, + | ^^^^^^^^^^^ not supported + | + = note: see issue #20041 <https://github.com/rust-lang/rust/issues/20041> for more information +help: if `IntoIterator::Item` is an associated type you're trying to set, use the associated type binding syntax + | +LL - fn from_iter<T: IntoIterator>(_: T) -> Self where T::Item = A, +LL + fn from_iter<T: IntoIterator<Item = A>>(_: T) -> Self + | + +error: equality constraints are not yet supported in `where` clauses + --> $DIR/equality-bound.rs:64:41 + | +LL | fn from_iter<T>(_: T) -> Self where IntoIterator::Item = A, T: IntoIterator, + | ^^^^^^^^^^^^^^^^^^^^^^ not supported + | + = note: see issue #20041 <https://github.com/rust-lang/rust/issues/20041> for more information +help: if `IntoIterator::Item` is an associated type you're trying to set, use the associated type binding syntax + | +LL - fn from_iter<T>(_: T) -> Self where IntoIterator::Item = A, T: IntoIterator, +LL + fn from_iter<T>(_: T) -> Self where T: IntoIterator<Item = A>, + | + +error: equality constraints are not yet supported in `where` clauses + --> $DIR/equality-bound.rs:75:41 + | +LL | fn from_iter<T>(_: T) -> Self where T::Item = A, T: IntoIterator, + | ^^^^^^^^^^^ not supported + | + = note: see issue #20041 <https://github.com/rust-lang/rust/issues/20041> for more information +help: if `IntoIterator::Item` is an associated type you're trying to set, use the associated type binding syntax + | +LL - fn from_iter<T>(_: T) -> Self where T::Item = A, T: IntoIterator, +LL + fn from_iter<T>(_: T) -> Self where T: IntoIterator<Item = A>, + | + +error[E0412]: cannot find type `A` in this scope + --> $DIR/equality-bound.rs:20:79 + | +LL | fn from_iter<T>(_: T) -> Self where T: IntoIterator, IntoIterator::Item = A, + | ^ help: a struct with a similar name exists: `K` +... +LL | struct K {} + | -------- similarly named struct `K` defined here + +error[E0412]: cannot find type `A` in this scope + --> $DIR/equality-bound.rs:31:68 + | +LL | fn from_iter<T>(_: T) -> Self where T: IntoIterator, T::Item = A, + | ^ help: a struct with a similar name exists: `K` +... +LL | struct K {} + | -------- similarly named struct `K` defined here + +error[E0412]: cannot find type `A` in this scope + --> $DIR/equality-bound.rs:42:76 + | +LL | fn from_iter<T: IntoIterator>(_: T) -> Self where IntoIterator::Item = A, + | ^ help: a struct with a similar name exists: `K` +... +LL | struct K {} + | -------- similarly named struct `K` defined here + +error[E0412]: cannot find type `A` in this scope + --> $DIR/equality-bound.rs:53:65 + | +LL | struct K {} + | -------- similarly named struct `K` defined here +... +LL | fn from_iter<T: IntoIterator>(_: T) -> Self where T::Item = A, + | ^ help: a struct with a similar name exists: `K` + +error[E0412]: cannot find type `A` in this scope + --> $DIR/equality-bound.rs:64:62 + | +LL | struct K {} + | -------- similarly named struct `K` defined here +... +LL | fn from_iter<T>(_: T) -> Self where IntoIterator::Item = A, T: IntoIterator, + | ^ help: a struct with a similar name exists: `K` + +error[E0412]: cannot find type `A` in this scope + --> $DIR/equality-bound.rs:75:51 + | +LL | struct K {} + | -------- similarly named struct `K` defined here +... +LL | fn from_iter<T>(_: T) -> Self where T::Item = A, T: IntoIterator, + | ^ help: a struct with a similar name exists: `K` + error[E0433]: failed to resolve: use of undeclared type `I` --> $DIR/equality-bound.rs:9:41 | @@ -41,6 +173,7 @@ LL | fn sum3<J: Iterator>(i: J) -> i32 where I::Item = i32 { | use of undeclared type `I` | help: a type parameter with a similar name exists: `J` -error: aborting due to 4 previous errors +error: aborting due to 16 previous errors -For more information about this error, try `rustc --explain E0433`. +Some errors have detailed explanations: E0412, E0433. +For more information about an error, try `rustc --explain E0412`. diff --git a/tests/ui/generic-associated-types/gat-in-trait-path.base.stderr b/tests/ui/generic-associated-types/gat-in-trait-path.base.stderr index bd3728cec8c..e05c83ebc76 100644 --- a/tests/ui/generic-associated-types/gat-in-trait-path.base.stderr +++ b/tests/ui/generic-associated-types/gat-in-trait-path.base.stderr @@ -13,8 +13,8 @@ LL | type A<'a> where Self: 'a; | ^ ...because it contains the generic associated type `A` = help: consider moving `A` to another trait = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `Foo` for this new enum and using it instead: - Fooy Fooer<T> + Fooy error: aborting due to 1 previous error diff --git a/tests/ui/generic-associated-types/issue-79422.base.stderr b/tests/ui/generic-associated-types/issue-79422.base.stderr index bcc6382cf7c..7f58f825702 100644 --- a/tests/ui/generic-associated-types/issue-79422.base.stderr +++ b/tests/ui/generic-associated-types/issue-79422.base.stderr @@ -29,8 +29,8 @@ LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a; | ^^^^^^^^ ...because it contains the generic associated type `VRefCont` = help: consider moving `VRefCont` to another trait = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `MapLike` for this new enum and using it instead: - std::collections::BTreeMap<K, V> Source + std::collections::BTreeMap<K, V> error[E0038]: the trait `MapLike` cannot be made into an object --> $DIR/issue-79422.rs:44:13 @@ -47,8 +47,8 @@ LL | type VRefCont<'a>: RefCont<'a, V> where Self: 'a; | ^^^^^^^^ ...because it contains the generic associated type `VRefCont` = help: consider moving `VRefCont` to another trait = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `MapLike` for this new enum and using it instead: - std::collections::BTreeMap<K, V> Source + std::collections::BTreeMap<K, V> = note: required for the cast from `Box<BTreeMap<u8, u8>>` to `Box<dyn MapLike<u8, u8, VRefCont = (dyn RefCont<'_, u8> + 'static)>>` error: aborting due to 3 previous errors diff --git a/tests/ui/impl-trait/in-trait/alias-bounds-when-not-wf.rs b/tests/ui/impl-trait/in-trait/alias-bounds-when-not-wf.rs new file mode 100644 index 00000000000..229a918cdd2 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/alias-bounds-when-not-wf.rs @@ -0,0 +1,19 @@ +// compile-flags: -Znext-solver + +#![feature(lazy_type_alias)] +//~^ WARN the feature `lazy_type_alias` is incomplete + +trait Foo {} + +type A<T: Foo> = T; + +struct W<T>(T); + +// For `W<A<usize>>` to be WF, `A<usize>: Sized` must hold. However, when assembling +// alias bounds for `A<usize>`, we try to normalize it, but it doesn't hold because +// `usize: Foo` doesn't hold. Therefore we ICE, because we don't expect to still +// encounter weak types in `assemble_alias_bound_candidates_recur`. +fn hello(_: W<A<usize>>) {} +//~^ ERROR the type `W<A<usize>>` is not well-formed + +fn main() {} diff --git a/tests/ui/impl-trait/in-trait/alias-bounds-when-not-wf.stderr b/tests/ui/impl-trait/in-trait/alias-bounds-when-not-wf.stderr new file mode 100644 index 00000000000..5df27ac3bc6 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/alias-bounds-when-not-wf.stderr @@ -0,0 +1,17 @@ +warning: the feature `lazy_type_alias` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/alias-bounds-when-not-wf.rs:3:12 + | +LL | #![feature(lazy_type_alias)] + | ^^^^^^^^^^^^^^^ + | + = note: see issue #112792 <https://github.com/rust-lang/rust/issues/112792> for more information + = note: `#[warn(incomplete_features)]` on by default + +error: the type `W<A<usize>>` is not well-formed + --> $DIR/alias-bounds-when-not-wf.rs:16:13 + | +LL | fn hello(_: W<A<usize>>) {} + | ^^^^^^^^^^^ + +error: aborting due to 1 previous error; 1 warning emitted + diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err-2.stderr b/tests/ui/impl-trait/in-trait/default-body-type-err-2.stderr index 77f6945f064..9fa73d817ca 100644 --- a/tests/ui/impl-trait/in-trait/default-body-type-err-2.stderr +++ b/tests/ui/impl-trait/in-trait/default-body-type-err-2.stderr @@ -1,6 +1,8 @@ error[E0308]: mismatched types --> $DIR/default-body-type-err-2.rs:7:9 | +LL | async fn woopsie_async(&self) -> String { + | ------ expected `String` because of return type LL | 42 | ^^- help: try using a conversion method: `.to_string()` | | diff --git a/tests/ui/impl-trait/recursive-coroutine-boxed.next.stderr b/tests/ui/impl-trait/recursive-coroutine-boxed.next.stderr new file mode 100644 index 00000000000..fee3b86034a --- /dev/null +++ b/tests/ui/impl-trait/recursive-coroutine-boxed.next.stderr @@ -0,0 +1,23 @@ +error[E0282]: type annotations needed + --> $DIR/recursive-coroutine-boxed.rs:10:23 + | +LL | let mut gen = Box::pin(foo()); + | ^^^^^^^^ cannot infer type of the type parameter `T` declared on the struct `Box` +... +LL | let mut r = gen.as_mut().resume(()); + | ------ type must be known at this point + | +help: consider specifying the generic argument + | +LL | let mut gen = Box::<T>::pin(foo()); + | +++++ + +error[E0282]: type annotations needed + --> $DIR/recursive-coroutine-boxed.rs:10:32 + | +LL | let mut gen = Box::pin(foo()); + | ^^^^^ cannot infer type for opaque type `impl Coroutine<Yield = (), Return = ()>` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/impl-trait/recursive-coroutine-boxed.rs b/tests/ui/impl-trait/recursive-coroutine-boxed.rs index b9291f07e21..3f677986c13 100644 --- a/tests/ui/impl-trait/recursive-coroutine-boxed.rs +++ b/tests/ui/impl-trait/recursive-coroutine-boxed.rs @@ -1,5 +1,5 @@ -// check-pass // revisions: current next +//[current] check-pass //[next] compile-flags: -Znext-solver #![feature(coroutines, coroutine_trait)] @@ -8,6 +8,8 @@ use std::ops::{Coroutine, CoroutineState}; fn foo() -> impl Coroutine<Yield = (), Return = ()> { || { let mut gen = Box::pin(foo()); + //[next]~^ ERROR type annotations needed + //[next]~| ERROR type annotations needed let mut r = gen.as_mut().resume(()); while let CoroutineState::Yielded(v) = r { yield v; diff --git a/tests/ui/impl-trait/two_tait_defining_each_other2.next.stderr b/tests/ui/impl-trait/two_tait_defining_each_other2.next.stderr index e49d1d18b0c..69328e20583 100644 --- a/tests/ui/impl-trait/two_tait_defining_each_other2.next.stderr +++ b/tests/ui/impl-trait/two_tait_defining_each_other2.next.stderr @@ -1,8 +1,8 @@ -error[E0284]: type annotations needed: cannot satisfy `A <: B` +error[E0284]: type annotations needed: cannot satisfy `A == B` --> $DIR/two_tait_defining_each_other2.rs:11:5 | LL | x // B's hidden type is A (opaquely) - | ^ cannot satisfy `A <: B` + | ^ cannot satisfy `A == B` error: aborting due to 1 previous error diff --git a/tests/ui/impl-trait/two_tait_defining_each_other2.rs b/tests/ui/impl-trait/two_tait_defining_each_other2.rs index 8a79af19776..b2f768f4dcd 100644 --- a/tests/ui/impl-trait/two_tait_defining_each_other2.rs +++ b/tests/ui/impl-trait/two_tait_defining_each_other2.rs @@ -10,7 +10,7 @@ trait Foo {} fn muh(x: A) -> B { x // B's hidden type is A (opaquely) //[current]~^ ERROR opaque type's hidden type cannot be another opaque type - //[next]~^^ ERROR type annotations needed: cannot satisfy `A <: B` + //[next]~^^ ERROR type annotations needed: cannot satisfy `A == B` } struct Bar; diff --git a/tests/ui/lint/large_assignments/box_rc_arc_allowed.rs b/tests/ui/lint/large_assignments/box_rc_arc_allowed.rs deleted file mode 100644 index 33113642023..00000000000 --- a/tests/ui/lint/large_assignments/box_rc_arc_allowed.rs +++ /dev/null @@ -1,29 +0,0 @@ -#![deny(large_assignments)] -#![feature(large_assignments)] -#![move_size_limit = "1000"] -// build-fail -// only-x86_64 - -// edition:2018 -// compile-flags: -Zmir-opt-level=0 - -use std::{sync::Arc, rc::Rc}; - -fn main() { - let _ = Arc::new([0; 9999]); // OK! - let _ = Box::new([0; 9999]); // OK! - let _ = Rc::new([0; 9999]); // OK! - let _ = NotBox::new([0; 9999]); //~ ERROR large_assignments -} - -struct NotBox { - data: [u8; 9999], -} - -impl NotBox { - fn new(data: [u8; 9999]) -> Self { - Self { - data, //~ ERROR large_assignments - } - } -} diff --git a/tests/ui/lint/large_assignments/copy_into_box_rc_arc.rs b/tests/ui/lint/large_assignments/copy_into_box_rc_arc.rs new file mode 100644 index 00000000000..866a4d10ff5 --- /dev/null +++ b/tests/ui/lint/large_assignments/copy_into_box_rc_arc.rs @@ -0,0 +1,38 @@ +#![deny(large_assignments)] +#![feature(large_assignments)] +#![move_size_limit = "1000"] +// build-fail +// only-64bit + +// edition:2018 +// compile-flags: -Zmir-opt-level=1 + +use std::{sync::Arc, rc::Rc}; + +fn main() { + let data = [0; 9999]; + + // Looking at --emit mir, we can see that all parameters below are passed by + // copy. But it requires at least mir-opt-level=1. + let _ = Arc::new(data); // OK! + let _ = Box::new(data); // OK! + let _ = Rc::new(data); // OK! + + // Looking at --emit llvm-ir, we can see that a memcpy is involved in the + // parameter passing. So we want the lint to trigger here. + let _ = NotBox::new(data); //~ ERROR large_assignments +} + +struct NotBox { + data: [u8; 9999], +} + +impl NotBox { + fn new(data: [u8; 9999]) -> Self { + // Looking at --emit llvm-ir, we can see that a memcpy is involved. + // So we want the lint to trigger here. + Self { //~ ERROR large_assignments + data, + } + } +} diff --git a/tests/ui/lint/large_assignments/box_rc_arc_allowed.stderr b/tests/ui/lint/large_assignments/copy_into_box_rc_arc.stderr index fefb3a9621b..6e42328a111 100644 --- a/tests/ui/lint/large_assignments/box_rc_arc_allowed.stderr +++ b/tests/ui/lint/large_assignments/copy_into_box_rc_arc.stderr @@ -1,21 +1,23 @@ error: moving 9999 bytes - --> $DIR/box_rc_arc_allowed.rs:16:25 + --> $DIR/copy_into_box_rc_arc.rs:23:25 | -LL | let _ = NotBox::new([0; 9999]); - | ^^^^^^^^^ value moved from here +LL | let _ = NotBox::new(data); + | ^^^^ 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/box_rc_arc_allowed.rs:1:9 + --> $DIR/copy_into_box_rc_arc.rs:1:9 | LL | #![deny(large_assignments)] | ^^^^^^^^^^^^^^^^^ error: moving 9999 bytes - --> $DIR/box_rc_arc_allowed.rs:26:13 + --> $DIR/copy_into_box_rc_arc.rs:34:9 | -LL | data, - | ^^^^ value moved from here +LL | / Self { +LL | | data, +LL | | } + | |_________^ 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 = "..."]` diff --git a/tests/ui/lint/large_assignments/large_future.rs b/tests/ui/lint/large_assignments/large_future.rs index 834746fa97e..a69ff356c6b 100644 --- a/tests/ui/lint/large_assignments/large_future.rs +++ b/tests/ui/lint/large_assignments/large_future.rs @@ -2,7 +2,7 @@ #![cfg_attr(attribute, feature(large_assignments))] #![cfg_attr(attribute, move_size_limit = "1000")] // build-fail -// only-x86_64 +// only-64bit // revisions: attribute option // [option]compile-flags: -Zmove-size-limit=1000 diff --git a/tests/ui/lint/large_assignments/move_into_box_rc_arc.rs b/tests/ui/lint/large_assignments/move_into_box_rc_arc.rs new file mode 100644 index 00000000000..b7a70dfdda0 --- /dev/null +++ b/tests/ui/lint/large_assignments/move_into_box_rc_arc.rs @@ -0,0 +1,38 @@ +#![deny(large_assignments)] +#![feature(large_assignments)] +#![move_size_limit = "1000"] +// build-fail +// only-64bit + +// edition:2018 +// compile-flags: -Zmir-opt-level=0 + +use std::{sync::Arc, rc::Rc}; + +fn main() { + // Looking at --emit mir, we can see that all parameters below are passed + // by move. + let _ = Arc::new([0; 9999]); // OK! + let _ = Box::new([0; 9999]); // OK! + let _ = Rc::new([0; 9999]); // OK! + + // Looking at --emit llvm-ir, we can see that no memcpy is involved in the + // parameter passing. Instead, a pointer is passed. This is typically what + // we get when moving parameter into functions. So we don't want the lint to + // trigger here. + let _ = NotBox::new([0; 9999]); // OK (compare with copy_into_box_rc_arc.rs) +} + +struct NotBox { + data: [u8; 9999], +} + +impl NotBox { + fn new(data: [u8; 9999]) -> Self { + Self { + // Looking at --emit llvm-ir, we can see that a memcpy is involved. + // So we want the lint to trigger here. + data, //~ ERROR large_assignments + } + } +} diff --git a/tests/ui/lint/large_assignments/move_into_box_rc_arc.stderr b/tests/ui/lint/large_assignments/move_into_box_rc_arc.stderr new file mode 100644 index 00000000000..a386de5e5e8 --- /dev/null +++ b/tests/ui/lint/large_assignments/move_into_box_rc_arc.stderr @@ -0,0 +1,15 @@ +error: moving 9999 bytes + --> $DIR/move_into_box_rc_arc.rs:35:13 + | +LL | data, + | ^^^^ 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/move_into_box_rc_arc.rs:1:9 + | +LL | #![deny(large_assignments)] + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/lint/large_assignments/move_into_fn.rs b/tests/ui/lint/large_assignments/move_into_fn.rs new file mode 100644 index 00000000000..359705bfc03 --- /dev/null +++ b/tests/ui/lint/large_assignments/move_into_fn.rs @@ -0,0 +1,22 @@ +// build-fail + +#![feature(large_assignments)] +#![move_size_limit = "1000"] +#![deny(large_assignments)] +#![allow(unused)] + +// Note: This type does not implement Copy. +struct Data([u8; 9999]); + +fn main() { + // Looking at llvm-ir output, we can see a memcpy'd into Data, so we want + // the lint to trigger here. + let data = Data([100; 9999]); //~ ERROR large_assignments + + // Looking at llvm-ir output, we can see that there is no memcpy involved in + // this function call. Instead, just a pointer is passed to the function. So + // the lint shall not trigger here. + take_data(data); +} + +fn take_data(data: Data) {} diff --git a/tests/ui/lint/large_assignments/move_into_fn.stderr b/tests/ui/lint/large_assignments/move_into_fn.stderr new file mode 100644 index 00000000000..92a0489e472 --- /dev/null +++ b/tests/ui/lint/large_assignments/move_into_fn.stderr @@ -0,0 +1,15 @@ +error: moving 9999 bytes + --> $DIR/move_into_fn.rs:14:16 + | +LL | let data = Data([100; 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/move_into_fn.rs:5:9 + | +LL | #![deny(large_assignments)] + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/lint/reference_casting.rs b/tests/ui/lint/reference_casting.rs index 84267c0af03..63541943d65 100644 --- a/tests/ui/lint/reference_casting.rs +++ b/tests/ui/lint/reference_casting.rs @@ -30,7 +30,7 @@ unsafe fn ref_to_mut() { //~^ ERROR casting `&T` to `&mut T` is undefined behavior let _num = &mut *(num as *const i32).cast::<i32>().cast_mut().cast_const().cast_mut(); //~^ ERROR casting `&T` to `&mut T` is undefined behavior - let _num = &mut *(std::ptr::from_ref(static_u8()) as *mut i32); + let _num = &mut *(std::ptr::from_ref(static_u8()) as *mut i8); //~^ ERROR casting `&T` to `&mut T` is undefined behavior let _num = &mut *std::mem::transmute::<_, *mut i32>(num); //~^ ERROR casting `&T` to `&mut T` is undefined behavior @@ -141,6 +141,109 @@ unsafe fn assign_to_ref() { } } +#[repr(align(16))] +struct I64(i64); + +#[repr(C)] +struct Mat3<T> { + a: Vec3<T>, + b: Vec3<T>, + c: Vec3<T>, +} + +#[repr(C)] +struct Vec3<T>(T, T, T); + +unsafe fn bigger_layout() { + { + let num = &mut 3i32; + + let _num = &*(num as *const i32 as *const i64); + //~^ ERROR casting references to a bigger memory layout + let _num = &mut *(num as *mut i32 as *mut i64); + //~^ ERROR casting references to a bigger memory layout + let _num = &mut *(num as *mut i32 as *mut I64); + //~^ ERROR casting references to a bigger memory layout + std::ptr::write(num as *mut i32 as *mut i64, 2); + //~^ ERROR casting references to a bigger memory layout + + let _num = &mut *(num as *mut i32); + } + + { + let num = &mut [0i32; 3]; + + let _num = &mut *(num as *mut _ as *mut [i64; 2]); + //~^ ERROR casting references to a bigger memory layout + std::ptr::write_unaligned(num as *mut _ as *mut [i32; 4], [0, 0, 1, 1]); + //~^ ERROR casting references to a bigger memory layout + + let _num = &mut *(num as *mut _ as *mut [u32; 3]); + let _num = &mut *(num as *mut _ as *mut [u32; 2]); + } + + { + let num = &mut [0i32; 3] as &mut [i32]; + + let _num = &mut *(num as *mut _ as *mut i128); + //~^ ERROR casting references to a bigger memory layout + let _num = &mut *(num as *mut _ as *mut [i64; 4]); + //~^ ERROR casting references to a bigger memory layout + + let _num = &mut *(num as *mut _ as *mut [u32]); + let _num = &mut *(num as *mut _ as *mut [i16]); + } + + { + let mat3 = Mat3 { a: Vec3(0i32, 0, 0), b: Vec3(0, 0, 0), c: Vec3(0, 0, 0) }; + + let _num = &mut *(&mat3 as *const _ as *mut [[i64; 3]; 3]); + //~^ ERROR casting `&T` to `&mut T` + //~^^ ERROR casting references to a bigger memory layout + let _num = &*(&mat3 as *const _ as *mut [[i64; 3]; 3]); + //~^ ERROR casting references to a bigger memory layout + + let _num = &*(&mat3 as *const _ as *mut [[i32; 3]; 3]); + } + + { + let mut l: [u8; 2] = [0,1]; + let w: *mut [u16; 2] = &mut l as *mut [u8; 2] as *mut _; + let w: *mut [u16] = unsafe {&mut *w}; + //~^ ERROR casting references to a bigger memory layout + } + + { + fn foo() -> [i32; 1] { todo!() } + + let num = foo(); + let _num = &*(&num as *const i32 as *const i64); + //~^ ERROR casting references to a bigger memory layout + let _num = &*(&foo() as *const i32 as *const i64); + //~^ ERROR casting references to a bigger memory layout + } + + { + fn bar(_a: &[i32; 2]) -> &[i32; 1] { todo!() } + + let num = bar(&[0, 0]); + let _num = &*(num as *const i32 as *const i64); + let _num = &*(bar(&[0, 0]) as *const i32 as *const i64); + } + + { + fn foi<T>() -> T { todo!() } + + let num = foi::<i32>(); + let _num = &*(&num as *const i32 as *const i64); + //~^ ERROR casting references to a bigger memory layout + } + + unsafe fn from_ref(this: &i32) -> &i64 { + &*(this as *const i32 as *const i64) + } +} + const RAW_PTR: *mut u8 = 1 as *mut u8; unsafe fn no_warn() { let num = &3i32; diff --git a/tests/ui/lint/reference_casting.stderr b/tests/ui/lint/reference_casting.stderr index 374a58d7b7b..26af60b6bc5 100644 --- a/tests/ui/lint/reference_casting.stderr +++ b/tests/ui/lint/reference_casting.stderr @@ -66,8 +66,8 @@ LL | let _num = &mut *(num as *const i32).cast::<i32>().cast_mut().cast_cons error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` --> $DIR/reference_casting.rs:33:16 | -LL | let _num = &mut *(std::ptr::from_ref(static_u8()) as *mut i32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | let _num = &mut *(std::ptr::from_ref(static_u8()) as *mut i8); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> @@ -373,5 +373,164 @@ LL | *(this as *const _ as *mut _) = a; | = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> -error: aborting due to 42 previous errors +error: casting references to a bigger memory layout than the backing allocation is undefined behavior, even if the reference is unused + --> $DIR/reference_casting.rs:161:20 + | +LL | let num = &mut 3i32; + | ---- backing allocation comes from here +LL | +LL | let _num = &*(num as *const i32 as *const i64); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: casting from `i32` (4 bytes) to `i64` (8 bytes) + +error: casting references to a bigger memory layout than the backing allocation is undefined behavior, even if the reference is unused + --> $DIR/reference_casting.rs:163:20 + | +LL | let num = &mut 3i32; + | ---- backing allocation comes from here +... +LL | let _num = &mut *(num as *mut i32 as *mut i64); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: casting from `i32` (4 bytes) to `i64` (8 bytes) + +error: casting references to a bigger memory layout than the backing allocation is undefined behavior, even if the reference is unused + --> $DIR/reference_casting.rs:165:20 + | +LL | let num = &mut 3i32; + | ---- backing allocation comes from here +... +LL | let _num = &mut *(num as *mut i32 as *mut I64); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: casting from `i32` (4 bytes) to `I64` (16 bytes) + +error: casting references to a bigger memory layout than the backing allocation is undefined behavior, even if the reference is unused + --> $DIR/reference_casting.rs:167:9 + | +LL | let num = &mut 3i32; + | ---- backing allocation comes from here +... +LL | std::ptr::write(num as *mut i32 as *mut i64, 2); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: casting from `i32` (4 bytes) to `i64` (8 bytes) + +error: casting references to a bigger memory layout than the backing allocation is undefined behavior, even if the reference is unused + --> $DIR/reference_casting.rs:176:20 + | +LL | let num = &mut [0i32; 3]; + | --------- backing allocation comes from here +LL | +LL | let _num = &mut *(num as *mut _ as *mut [i64; 2]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: casting from `[i32; 3]` (12 bytes) to `[i64; 2]` (16 bytes) + +error: casting references to a bigger memory layout than the backing allocation is undefined behavior, even if the reference is unused + --> $DIR/reference_casting.rs:178:9 + | +LL | let num = &mut [0i32; 3]; + | --------- backing allocation comes from here +... +LL | std::ptr::write_unaligned(num as *mut _ as *mut [i32; 4], [0, 0, 1, 1]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: casting from `[i32; 3]` (12 bytes) to `[i32; 4]` (16 bytes) + +error: casting references to a bigger memory layout than the backing allocation is undefined behavior, even if the reference is unused + --> $DIR/reference_casting.rs:188:20 + | +LL | let num = &mut [0i32; 3] as &mut [i32]; + | --------- backing allocation comes from here +LL | +LL | let _num = &mut *(num as *mut _ as *mut i128); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: casting from `[i32; 3]` (12 bytes) to `i128` (16 bytes) + +error: casting references to a bigger memory layout than the backing allocation is undefined behavior, even if the reference is unused + --> $DIR/reference_casting.rs:190:20 + | +LL | let num = &mut [0i32; 3] as &mut [i32]; + | --------- backing allocation comes from here +... +LL | let _num = &mut *(num as *mut _ as *mut [i64; 4]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: casting from `[i32; 3]` (12 bytes) to `[i64; 4]` (32 bytes) + +error: casting `&T` to `&mut T` is undefined behavior, even if the reference is unused, consider instead using an `UnsafeCell` + --> $DIR/reference_casting.rs:200:20 + | +LL | let _num = &mut *(&mat3 as *const _ as *mut [[i64; 3]; 3]); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/book/ch15-05-interior-mutability.html> + +error: casting references to a bigger memory layout than the backing allocation is undefined behavior, even if the reference is unused + --> $DIR/reference_casting.rs:200:20 + | +LL | let _num = &mut *(&mat3 as *const _ as *mut [[i64; 3]; 3]); + | ^^^^^^^^----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | backing allocation comes from here + | + = note: casting from `Mat3<i32>` (36 bytes) to `[[i64; 3]; 3]` (72 bytes) + +error: casting references to a bigger memory layout than the backing allocation is undefined behavior, even if the reference is unused + --> $DIR/reference_casting.rs:203:20 + | +LL | let _num = &*(&mat3 as *const _ as *mut [[i64; 3]; 3]); + | ^^^^----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | backing allocation comes from here + | + = note: casting from `Mat3<i32>` (36 bytes) to `[[i64; 3]; 3]` (72 bytes) + +error: casting references to a bigger memory layout than the backing allocation is undefined behavior, even if the reference is unused + --> $DIR/reference_casting.rs:212:37 + | +LL | let w: *mut [u16; 2] = &mut l as *mut [u8; 2] as *mut _; + | -------------------------------- + | | | + | | backing allocation comes from here + | casting happend here +LL | let w: *mut [u16] = unsafe {&mut *w}; + | ^^^^^^^ + | + = note: casting from `[u8; 2]` (2 bytes) to `[u16; 2]` (4 bytes) + +error: casting references to a bigger memory layout than the backing allocation is undefined behavior, even if the reference is unused + --> $DIR/reference_casting.rs:220:20 + | +LL | let _num = &*(&num as *const i32 as *const i64); + | ^^^^---^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | backing allocation comes from here + | + = note: casting from `[i32; 1]` (4 bytes) to `i64` (8 bytes) + +error: casting references to a bigger memory layout than the backing allocation is undefined behavior, even if the reference is unused + --> $DIR/reference_casting.rs:222:20 + | +LL | let _num = &*(&foo() as *const i32 as *const i64); + | ^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | backing allocation comes from here + | + = note: casting from `[i32; 1]` (4 bytes) to `i64` (8 bytes) + +error: casting references to a bigger memory layout than the backing allocation is undefined behavior, even if the reference is unused + --> $DIR/reference_casting.rs:238:20 + | +LL | let _num = &*(&num as *const i32 as *const i64); + | ^^^^---^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | backing allocation comes from here + | + = note: casting from `i32` (4 bytes) to `i64` (8 bytes) + +error: aborting due to 57 previous errors diff --git a/tests/ui/loops/dont-suggest-break-thru-item.rs b/tests/ui/loops/dont-suggest-break-thru-item.rs index b46ba89e81d..308101115e5 100644 --- a/tests/ui/loops/dont-suggest-break-thru-item.rs +++ b/tests/ui/loops/dont-suggest-break-thru-item.rs @@ -8,6 +8,7 @@ fn closure() { if true { Err(1) //~^ ERROR mismatched types + //~| HELP you might have meant to return this value } Ok(()) @@ -21,6 +22,7 @@ fn async_block() { if true { Err(1) //~^ ERROR mismatched types + //~| HELP you might have meant to return this value } Ok(()) diff --git a/tests/ui/loops/dont-suggest-break-thru-item.stderr b/tests/ui/loops/dont-suggest-break-thru-item.stderr index 4fce4715119..c84a98198f5 100644 --- a/tests/ui/loops/dont-suggest-break-thru-item.stderr +++ b/tests/ui/loops/dont-suggest-break-thru-item.stderr @@ -5,27 +5,37 @@ LL | / if true { LL | | Err(1) | | ^^^^^^ expected `()`, found `Result<_, {integer}>` LL | | +LL | | LL | | } | |_____________- expected this to be `()` | = note: expected unit type `()` found enum `Result<_, {integer}>` +help: you might have meant to return this value + | +LL | return Err(1); + | ++++++ + error[E0308]: mismatched types - --> $DIR/dont-suggest-break-thru-item.rs:22:17 + --> $DIR/dont-suggest-break-thru-item.rs:23:17 | LL | / if true { LL | | Err(1) | | ^^^^^^ expected `()`, found `Result<_, {integer}>` LL | | +LL | | LL | | } | |_____________- expected this to be `()` | = note: expected unit type `()` found enum `Result<_, {integer}>` +help: you might have meant to return this value + | +LL | return Err(1); + | ++++++ + error[E0308]: mismatched types - --> $DIR/dont-suggest-break-thru-item.rs:35:17 + --> $DIR/dont-suggest-break-thru-item.rs:37:17 | LL | / if true { LL | | Err(1) @@ -38,7 +48,7 @@ LL | | } found enum `Result<_, {integer}>` error[E0308]: mismatched types - --> $DIR/dont-suggest-break-thru-item.rs:47:17 + --> $DIR/dont-suggest-break-thru-item.rs:49:17 | LL | / if true { LL | | Err(1) diff --git a/tests/ui/mir/inline-wrong-abi.rs b/tests/ui/mir/inline-wrong-abi.rs new file mode 100644 index 00000000000..1f61a5dcfbe --- /dev/null +++ b/tests/ui/mir/inline-wrong-abi.rs @@ -0,0 +1,32 @@ +// compile-flags: -Zpolymorphize=on -Zinline-mir=yes -Zmir-opt-level=0 + +#![feature(fn_traits, unboxed_closures)] +struct Foo<T>(T); + +impl<T: Copy> Fn<()> for Foo<T> { + extern "C" fn call(&self, _: ()) -> T { + //~^ ERROR method `call` has an incompatible type for trait + match *self { + Foo(t) => t, + } + } +} + +impl<T: Copy> FnMut<()> for Foo<T> { + extern "rust-call" fn call_mut(&mut self, _: ()) -> T { + self.call(()) + } +} + +impl<T: Copy> FnOnce<()> for Foo<T> { + type Output = T; + + extern "rust-call" fn call_once(self, _: ()) -> T { + self.call(()) + } +} + +fn main() { + let t: u8 = 1; + println!("{}", Foo(t)()); +} diff --git a/tests/ui/mir/inline-wrong-abi.stderr b/tests/ui/mir/inline-wrong-abi.stderr new file mode 100644 index 00000000000..e44899eb92a --- /dev/null +++ b/tests/ui/mir/inline-wrong-abi.stderr @@ -0,0 +1,12 @@ +error[E0053]: method `call` has an incompatible type for trait + --> $DIR/inline-wrong-abi.rs:7:5 + | +LL | extern "C" fn call(&self, _: ()) -> T { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected "rust-call" fn, found "C" fn + | + = note: expected signature `extern "rust-call" fn(&Foo<_>, ()) -> _` + found signature `extern "C" fn(&Foo<_>, ()) -> _` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/nll/check-normalized-sig-for-wf.rs b/tests/ui/nll/check-normalized-sig-for-wf.rs new file mode 100644 index 00000000000..cb0f34ce02f --- /dev/null +++ b/tests/ui/nll/check-normalized-sig-for-wf.rs @@ -0,0 +1,27 @@ +// <https://github.com/rust-lang/rust/issues/114936> +fn whoops( + s: String, + f: impl for<'s> FnOnce(&'s str) -> (&'static str, [&'static &'s (); 0]), +) -> &'static str +{ + f(&s).0 + //~^ ERROR `s` does not live long enough +} + +// <https://github.com/rust-lang/rust/issues/118876> +fn extend<T>(input: &T) -> &'static T { + struct Bounded<'a, 'b: 'static, T>(&'a T, [&'b (); 0]); + let n: Box<dyn FnOnce(&T) -> Bounded<'static, '_, T>> = Box::new(|x| Bounded(x, [])); + n(input).0 + //~^ ERROR borrowed data escapes outside of function +} + +// <https://github.com/rust-lang/rust/issues/118876> +fn extend_mut<'a, T>(input: &'a mut T) -> &'static mut T { + struct Bounded<'a, 'b: 'static, T>(&'a mut T, [&'b (); 0]); + let mut n: Box<dyn FnMut(&mut T) -> Bounded<'static, '_, T>> = Box::new(|x| Bounded(x, [])); + n(input).0 + //~^ ERROR borrowed data escapes outside of function +} + +fn main() {} diff --git a/tests/ui/nll/check-normalized-sig-for-wf.stderr b/tests/ui/nll/check-normalized-sig-for-wf.stderr new file mode 100644 index 00000000000..5c96b0c6561 --- /dev/null +++ b/tests/ui/nll/check-normalized-sig-for-wf.stderr @@ -0,0 +1,47 @@ +error[E0597]: `s` does not live long enough + --> $DIR/check-normalized-sig-for-wf.rs:7:7 + | +LL | s: String, + | - binding `s` declared here +... +LL | f(&s).0 + | --^^- + | | | + | | borrowed value does not live long enough + | argument requires that `s` is borrowed for `'static` +LL | +LL | } + | - `s` dropped here while still borrowed + +error[E0521]: borrowed data escapes outside of function + --> $DIR/check-normalized-sig-for-wf.rs:15:5 + | +LL | fn extend<T>(input: &T) -> &'static T { + | ----- - let's call the lifetime of this reference `'1` + | | + | `input` is a reference that is only valid in the function body +... +LL | n(input).0 + | ^^^^^^^^ + | | + | `input` escapes the function body here + | argument requires that `'1` must outlive `'static` + +error[E0521]: borrowed data escapes outside of function + --> $DIR/check-normalized-sig-for-wf.rs:23:5 + | +LL | fn extend_mut<'a, T>(input: &'a mut T) -> &'static mut T { + | -- ----- `input` is a reference that is only valid in the function body + | | + | lifetime `'a` defined here +... +LL | n(input).0 + | ^^^^^^^^ + | | + | `input` escapes the function body here + | argument requires that `'a` must outlive `'static` + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0521, E0597. +For more information about an error, try `rustc --explain E0521`. diff --git a/tests/ui/on-unimplemented/bad-annotation.rs b/tests/ui/on-unimplemented/bad-annotation.rs index f05436b8c04..4c6610f8864 100644 --- a/tests/ui/on-unimplemented/bad-annotation.rs +++ b/tests/ui/on-unimplemented/bad-annotation.rs @@ -25,7 +25,7 @@ trait BadAnnotation2<A,B> {} #[rustc_on_unimplemented = "Unimplemented trait error on `{Self}` with params `<{A},{B},{}>`"] -//~^ only named substitution parameters are allowed +//~^ only named generic parameters are allowed trait BadAnnotation3<A,B> {} diff --git a/tests/ui/on-unimplemented/bad-annotation.stderr b/tests/ui/on-unimplemented/bad-annotation.stderr index a8d3c8680fa..9bb9423788c 100644 --- a/tests/ui/on-unimplemented/bad-annotation.stderr +++ b/tests/ui/on-unimplemented/bad-annotation.stderr @@ -17,7 +17,7 @@ error[E0230]: there is no parameter `C` on trait `BadAnnotation2` LL | #[rustc_on_unimplemented = "Unimplemented trait error on `{Self}` with params `<{A},{B},{C}>`"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0231]: only named substitution parameters are allowed +error[E0231]: only named generic parameters are allowed --> $DIR/bad-annotation.rs:27:1 | LL | #[rustc_on_unimplemented = "Unimplemented trait error on `{Self}` with params `<{A},{B},{}>`"] diff --git a/tests/ui/proc-macro/auxiliary/issue-118809.rs b/tests/ui/proc-macro/auxiliary/issue-118809.rs new file mode 100644 index 00000000000..029b58c6d0c --- /dev/null +++ b/tests/ui/proc-macro/auxiliary/issue-118809.rs @@ -0,0 +1,20 @@ +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; +use proc_macro::TokenStream; + +#[proc_macro_derive(Deserialize)] +pub fn deserialize_derive(input: TokenStream) -> TokenStream { + "impl Build { + fn deserialize() -> Option<u64> { + let x: Option<u32> = Some(0); + Some(x? + 1) + } + } + " + .parse() + .unwrap() +} diff --git a/tests/ui/proc-macro/issue-118809.rs b/tests/ui/proc-macro/issue-118809.rs new file mode 100644 index 00000000000..732bf19c173 --- /dev/null +++ b/tests/ui/proc-macro/issue-118809.rs @@ -0,0 +1,10 @@ +// aux-build: issue-118809.rs + +#[macro_use] +extern crate issue_118809; + +#[derive(Deserialize)] //~ ERROR mismatched types [E0308] +pub struct Build { +} + +fn main() {} diff --git a/tests/ui/proc-macro/issue-118809.stderr b/tests/ui/proc-macro/issue-118809.stderr new file mode 100644 index 00000000000..30b09fd4006 --- /dev/null +++ b/tests/ui/proc-macro/issue-118809.stderr @@ -0,0 +1,21 @@ +error[E0308]: mismatched types + --> $DIR/issue-118809.rs:6:10 + | +LL | #[derive(Deserialize)] + | ^^^^^^^^^^^ + | | + | expected `u64`, found `u32` + | arguments to this enum variant are incorrect + | +help: the type constructed contains `u32` due to the type of the argument passed + --> $DIR/issue-118809.rs:6:10 + | +LL | #[derive(Deserialize)] + | ^^^^^^^^^^^ this argument influences the type of `Some` +note: tuple variant defined here + --> $SRC_DIR/core/src/option.rs:LL:COL + = note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/specialization/defaultimpl/specialization-trait-not-implemented.rs b/tests/ui/specialization/defaultimpl/specialization-trait-not-implemented.rs index 6834d573629..344dd7bb288 100644 --- a/tests/ui/specialization/defaultimpl/specialization-trait-not-implemented.rs +++ b/tests/ui/specialization/defaultimpl/specialization-trait-not-implemented.rs @@ -20,5 +20,5 @@ default impl<T> Foo for T { fn main() { println!("{}", MyStruct.foo_one()); - //~^ ERROR the method + //~^ ERROR no method named `foo_one` found for struct `MyStruct` in the current scope } diff --git a/tests/ui/specialization/defaultimpl/specialization-trait-not-implemented.stderr b/tests/ui/specialization/defaultimpl/specialization-trait-not-implemented.stderr index e9b0845ccf7..74f81bb023e 100644 --- a/tests/ui/specialization/defaultimpl/specialization-trait-not-implemented.stderr +++ b/tests/ui/specialization/defaultimpl/specialization-trait-not-implemented.stderr @@ -8,27 +8,15 @@ LL | #![feature(specialization)] = help: consider using `min_specialization` instead, which is more stable and complete = note: `#[warn(incomplete_features)]` on by default -error[E0599]: the method `foo_one` exists for struct `MyStruct`, but its trait bounds were not satisfied +error[E0599]: no method named `foo_one` found for struct `MyStruct` in the current scope --> $DIR/specialization-trait-not-implemented.rs:22:29 | LL | struct MyStruct; - | --------------- method `foo_one` not found for this struct because it doesn't satisfy `MyStruct: Foo` + | --------------- method `foo_one` not found for this struct ... LL | println!("{}", MyStruct.foo_one()); - | ^^^^^^^ method cannot be called on `MyStruct` due to unsatisfied trait bounds + | ^^^^^^^ method not found in `MyStruct` | -note: trait bound `MyStruct: Foo` was not satisfied - --> $DIR/specialization-trait-not-implemented.rs:14:1 - | -LL | default impl<T> Foo for T { - | ^^^^^^^^^^^^^^^^---^^^^^- - | | - | unsatisfied trait bound introduced here -note: the trait `Foo` must be implemented - --> $DIR/specialization-trait-not-implemented.rs:7:1 - | -LL | trait Foo { - | ^^^^^^^^^ = help: items from traits can only be used if the trait is implemented and in scope note: `Foo` defines an item `foo_one`, perhaps you need to implement it --> $DIR/specialization-trait-not-implemented.rs:7:1 diff --git a/tests/ui/specialization/defaultimpl/validation.rs b/tests/ui/specialization/defaultimpl/validation.rs index 8558a1efb82..4049c4ea14c 100644 --- a/tests/ui/specialization/defaultimpl/validation.rs +++ b/tests/ui/specialization/defaultimpl/validation.rs @@ -7,6 +7,7 @@ struct Z; default impl S {} //~ ERROR inherent impls cannot be `default` default unsafe impl Send for S {} //~ ERROR impls of auto traits cannot be default +//~^ ERROR `S` cannot be sent between threads safely default impl !Send for Z {} //~ ERROR impls of auto traits cannot be default //~^ ERROR negative impls cannot be default impls diff --git a/tests/ui/specialization/defaultimpl/validation.stderr b/tests/ui/specialization/defaultimpl/validation.stderr index eb6dc9355a3..5f62e8dce17 100644 --- a/tests/ui/specialization/defaultimpl/validation.stderr +++ b/tests/ui/specialization/defaultimpl/validation.stderr @@ -26,8 +26,19 @@ LL | default unsafe impl Send for S {} | | | default because of this +error[E0277]: `S` cannot be sent between threads safely + --> $DIR/validation.rs:9:1 + | +LL | default unsafe impl Send for S {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `S` cannot be sent between threads safely + | + = help: the trait `Send` is not implemented for `S` + = help: the trait `Send` is implemented for `S` + = help: see issue #48214 + = help: add `#![feature(trivial_bounds)]` to the crate attributes to enable + error: impls of auto traits cannot be default - --> $DIR/validation.rs:10:15 + --> $DIR/validation.rs:11:15 | LL | default impl !Send for Z {} | ------- ^^^^ auto trait @@ -35,17 +46,18 @@ LL | default impl !Send for Z {} | default because of this error[E0750]: negative impls cannot be default impls - --> $DIR/validation.rs:10:1 + --> $DIR/validation.rs:11:1 | LL | default impl !Send for Z {} | ^^^^^^^ ^ error[E0750]: negative impls cannot be default impls - --> $DIR/validation.rs:14:1 + --> $DIR/validation.rs:15:1 | LL | default impl !Tr for S {} | ^^^^^^^ ^ -error: aborting due to 5 previous errors; 1 warning emitted +error: aborting due to 6 previous errors; 1 warning emitted -For more information about this error, try `rustc --explain E0750`. +Some errors have detailed explanations: E0277, E0750. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/specialization/issue-45814.current.stderr b/tests/ui/specialization/issue-45814.current.stderr index da0dff78e26..b89d3073a8f 100644 --- a/tests/ui/specialization/issue-45814.current.stderr +++ b/tests/ui/specialization/issue-45814.current.stderr @@ -1,14 +1,12 @@ -error[E0275]: overflow evaluating the requirement `T: Trait<_>` - | - = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_45814`) -note: required for `T` to implement `Trait<_>` - --> $DIR/issue-45814.rs:9:20 +error[E0119]: conflicting implementations of trait `Trait<_>` + --> $DIR/issue-45814.rs:10:1 | LL | default impl<T, U> Trait<T> for U {} - | ^^^^^^^^ ^ - = note: 128 redundant requirements hidden - = note: required for `T` to implement `Trait<_>` + | --------------------------------- first implementation here +LL | +LL | impl<T> Trait<<T as Iterator>::Item> for T {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0275`. +For more information about this error, try `rustc --explain E0119`. diff --git a/tests/ui/specialization/issue-45814.negative.stderr b/tests/ui/specialization/issue-45814.negative.stderr index da0dff78e26..b89d3073a8f 100644 --- a/tests/ui/specialization/issue-45814.negative.stderr +++ b/tests/ui/specialization/issue-45814.negative.stderr @@ -1,14 +1,12 @@ -error[E0275]: overflow evaluating the requirement `T: Trait<_>` - | - = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_45814`) -note: required for `T` to implement `Trait<_>` - --> $DIR/issue-45814.rs:9:20 +error[E0119]: conflicting implementations of trait `Trait<_>` + --> $DIR/issue-45814.rs:10:1 | LL | default impl<T, U> Trait<T> for U {} - | ^^^^^^^^ ^ - = note: 128 redundant requirements hidden - = note: required for `T` to implement `Trait<_>` + | --------------------------------- first implementation here +LL | +LL | impl<T> Trait<<T as Iterator>::Item> for T {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0275`. +For more information about this error, try `rustc --explain E0119`. diff --git a/tests/ui/specialization/issue-45814.rs b/tests/ui/specialization/issue-45814.rs index fce236390c2..832d734d945 100644 --- a/tests/ui/specialization/issue-45814.rs +++ b/tests/ui/specialization/issue-45814.rs @@ -1,4 +1,3 @@ -//~ ERROR overflow evaluating the requirement `T: Trait<_>` // revisions: current negative #![feature(specialization)] #![cfg_attr(negative, feature(with_negative_coherence))] @@ -9,5 +8,6 @@ pub trait Trait<T> {} default impl<T, U> Trait<T> for U {} impl<T> Trait<<T as Iterator>::Item> for T {} +//~^ ERROR conflicting implementations of trait `Trait<_>` fn main() {} diff --git a/tests/ui/specialization/allow_internal_unstable.rs b/tests/ui/specialization/min_specialization/allow_internal_unstable.rs index 317782b7b72..8f3677d9769 100644 --- a/tests/ui/specialization/allow_internal_unstable.rs +++ b/tests/ui/specialization/min_specialization/allow_internal_unstable.rs @@ -5,6 +5,9 @@ #![allow(internal_features)] #![feature(allow_internal_unstable)] +// aux-build:specialization-trait.rs +extern crate specialization_trait; + #[allow_internal_unstable(min_specialization)] macro_rules! test { () => { @@ -12,7 +15,11 @@ macro_rules! test { trait Tr {} impl<U> Tr for T<U> {} impl Tr for T<u8> {} - } + + impl<U> specialization_trait::SpecTrait for T<U> { + fn method(&self) {} + } + }; } test! {} diff --git a/tests/ui/static/issue-18118-2.rs b/tests/ui/static/issue-18118-2.rs index f712a2eedb7..6c81eec7d7e 100644 --- a/tests/ui/static/issue-18118-2.rs +++ b/tests/ui/static/issue-18118-2.rs @@ -1,6 +1,6 @@ pub fn main() { const z: &'static isize = { static p: isize = 3; - &p //~ ERROR constants cannot refer to statics + &p //~ ERROR referencing statics }; } diff --git a/tests/ui/static/issue-18118-2.stderr b/tests/ui/static/issue-18118-2.stderr index 6231a276f99..f084f2b9fdf 100644 --- a/tests/ui/static/issue-18118-2.stderr +++ b/tests/ui/static/issue-18118-2.stderr @@ -1,11 +1,15 @@ -error[E0013]: constants cannot refer to statics +error[E0658]: referencing statics in constants is unstable --> $DIR/issue-18118-2.rs:4:10 | LL | &p | ^ | - = help: consider extracting the value of the `static` to a `const`, and referring to that + = note: see issue #119618 <https://github.com/rust-lang/rust/issues/119618> for more information + = help: add `#![feature(const_refs_to_static)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + = note: `static` and `const` variables can refer to other `const` variables. A `const` variable, however, cannot refer to a `static` variable. + = help: to fix this, the value can be extracted to a `const` and then used. error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0013`. +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr b/tests/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr index dc4ec5d3ee2..ec9826819c0 100644 --- a/tests/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr +++ b/tests/ui/suggestions/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.stderr @@ -18,16 +18,16 @@ help: use parentheses to call this function LL | bar(foo()); | ++ -error[E0277]: `{coroutine-closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33}` is not a future +error[E0277]: `{async closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33}` is not a future --> $DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:12:9 | LL | bar(async_closure); - | --- ^^^^^^^^^^^^^ `{coroutine-closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33}` is not a future + | --- ^^^^^^^^^^^^^ `{async closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33}` is not a future | | | required by a bound introduced by this call | - = help: the trait `Future` is not implemented for `{coroutine-closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33}` - = note: {coroutine-closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33} must be a future or must implement `IntoFuture` to be awaited + = help: the trait `Future` is not implemented for `{async closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33}` + = note: {async closure@$DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:11:25: 11:33} must be a future or must implement `IntoFuture` to be awaited note: required by a bound in `bar` --> $DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:7:16 | diff --git a/tests/ui/target-feature/gate.rs b/tests/ui/target-feature/gate.rs index 971a4654b4c..d6a191d7850 100644 --- a/tests/ui/target-feature/gate.rs +++ b/tests/ui/target-feature/gate.rs @@ -19,6 +19,8 @@ // gate-test-aarch64_ver_target_feature // gate-test-csky_target_feature // gate-test-loongarch_target_feature +// gate-test-lahfsahf_target_feature +// gate-test-prfchw_target_feature #[target_feature(enable = "avx512bw")] //~^ ERROR: currently unstable diff --git a/tests/ui/target-feature/gate.stderr b/tests/ui/target-feature/gate.stderr index d281f0a6ab9..31198f73c20 100644 --- a/tests/ui/target-feature/gate.stderr +++ b/tests/ui/target-feature/gate.stderr @@ -1,5 +1,5 @@ error[E0658]: the target feature `avx512bw` is currently unstable - --> $DIR/gate.rs:23:18 + --> $DIR/gate.rs:25:18 | LL | #[target_feature(enable = "avx512bw")] | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/thread-local/thread-local-static.rs b/tests/ui/thread-local/thread-local-static.rs index f5fb0984897..a2c1954881f 100644 --- a/tests/ui/thread-local/thread-local-static.rs +++ b/tests/ui/thread-local/thread-local-static.rs @@ -2,17 +2,16 @@ #![feature(thread_local)] #![feature(const_swap)] +#![allow(static_mut_ref)] #[thread_local] static mut STATIC_VAR_2: [u32; 8] = [4; 8]; const fn g(x: &mut [u32; 8]) { //~^ ERROR mutable references are not allowed std::mem::swap(x, &mut STATIC_VAR_2) - //~^ WARN mutable reference of mutable static is discouraged [static_mut_ref] - //~^^ ERROR thread-local statics cannot be accessed + //~^ ERROR thread-local statics cannot be accessed //~| ERROR mutable references are not allowed //~| ERROR use of mutable static is unsafe - //~| constant functions cannot refer to statics } fn main() {} diff --git a/tests/ui/thread-local/thread-local-static.stderr b/tests/ui/thread-local/thread-local-static.stderr index 59bd17b39d8..a6499fd15ec 100644 --- a/tests/ui/thread-local/thread-local-static.stderr +++ b/tests/ui/thread-local/thread-local-static.stderr @@ -1,20 +1,5 @@ -warning: mutable reference of mutable static is discouraged - --> $DIR/thread-local-static.rs:10:23 - | -LL | std::mem::swap(x, &mut STATIC_VAR_2) - | ^^^^^^^^^^^^^^^^^ mutable reference of mutable static - | - = note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447> - = note: reference of mutable static is a hard error from 2024 edition - = note: mutable statics can be written to by multiple threads: aliasing violations or data races will cause undefined behavior - = note: `#[warn(static_mut_ref)]` on by default -help: mutable references are dangerous since if there's any other pointer or reference used for that static while the reference lives, that's UB; use `addr_of_mut!` instead to create a raw pointer - | -LL | std::mem::swap(x, addr_of_mut!(STATIC_VAR_2)) - | ~~~~~~~~~~~~~~~~~~~~~~~~~~ - error[E0133]: use of mutable static is unsafe and requires unsafe function or block - --> $DIR/thread-local-static.rs:10:28 + --> $DIR/thread-local-static.rs:11:28 | LL | std::mem::swap(x, &mut STATIC_VAR_2) | ^^^^^^^^^^^^ use of mutable static @@ -22,7 +7,7 @@ LL | std::mem::swap(x, &mut STATIC_VAR_2) = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior error[E0658]: mutable references are not allowed in constant functions - --> $DIR/thread-local-static.rs:8:12 + --> $DIR/thread-local-static.rs:9:12 | LL | const fn g(x: &mut [u32; 8]) { | ^ @@ -32,21 +17,13 @@ LL | const fn g(x: &mut [u32; 8]) { = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0625]: thread-local statics cannot be accessed at compile-time - --> $DIR/thread-local-static.rs:10:28 + --> $DIR/thread-local-static.rs:11:28 | LL | std::mem::swap(x, &mut STATIC_VAR_2) | ^^^^^^^^^^^^ -error[E0013]: constant functions cannot refer to statics - --> $DIR/thread-local-static.rs:10:28 - | -LL | std::mem::swap(x, &mut STATIC_VAR_2) - | ^^^^^^^^^^^^ - | - = help: consider extracting the value of the `static` to a `const`, and referring to that - error[E0658]: mutable references are not allowed in constant functions - --> $DIR/thread-local-static.rs:10:23 + --> $DIR/thread-local-static.rs:11:23 | LL | std::mem::swap(x, &mut STATIC_VAR_2) | ^^^^^^^^^^^^^^^^^ @@ -55,7 +32,7 @@ LL | std::mem::swap(x, &mut STATIC_VAR_2) = help: add `#![feature(const_mut_refs)]` 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 5 previous errors; 1 warning emitted +error: aborting due to 4 previous errors -Some errors have detailed explanations: E0013, E0133, E0625, E0658. -For more information about an error, try `rustc --explain E0013`. +Some errors have detailed explanations: E0133, E0625, E0658. +For more information about an error, try `rustc --explain E0133`. diff --git a/tests/ui/thread-local/thread-local-static.thir.stderr b/tests/ui/thread-local/thread-local-static.thir.stderr deleted file mode 100644 index 2043b268c09..00000000000 --- a/tests/ui/thread-local/thread-local-static.thir.stderr +++ /dev/null @@ -1,59 +0,0 @@ -warning: mutable reference of mutable static is discouraged - --> $DIR/thread-local-static.rs:12:23 - | -LL | std::mem::swap(x, &mut STATIC_VAR_2) - | ^^^^^^^^^^^^^^^^^ mutable reference of mutable static - | - = note: for more information, see issue #114447 <https://github.com/rust-lang/rust/issues/114447> - = note: reference of mutable static is a hard error from 2024 edition - = note: mutable statics can be written to by multiple threads: aliasing violations or data races will cause undefined behavior - = note: `#[warn(static_mut_ref)]` on by default -help: mutable references are dangerous since if there's any other pointer or reference used for that static while the reference lives, that's UB; use `addr_of_mut!` instead to create a raw pointer - | -LL | std::mem::swap(x, addr_of_mut!(STATIC_VAR_2)) - | ~~~~~~~~~~~~~~~~~~~~~~~~~~ - -error[E0658]: mutable references are not allowed in constant functions - --> $DIR/thread-local-static.rs:10:12 - | -LL | const fn g(x: &mut [u32; 8]) { - | ^ - | - = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information - = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable - -error[E0625]: thread-local statics cannot be accessed at compile-time - --> $DIR/thread-local-static.rs:12:28 - | -LL | std::mem::swap(x, &mut STATIC_VAR_2) - | ^^^^^^^^^^^^ - -error[E0013]: constant functions cannot refer to statics - --> $DIR/thread-local-static.rs:12:28 - | -LL | std::mem::swap(x, &mut STATIC_VAR_2) - | ^^^^^^^^^^^^ - | - = help: consider extracting the value of the `static` to a `const`, and referring to that - -error[E0658]: mutable references are not allowed in constant functions - --> $DIR/thread-local-static.rs:12:23 - | -LL | std::mem::swap(x, &mut STATIC_VAR_2) - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information - = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable - -error[E0133]: use of mutable static is unsafe and requires unsafe function or block - --> $DIR/thread-local-static.rs:12:23 - | -LL | std::mem::swap(x, &mut STATIC_VAR_2) - | ^^^^^^^^^^^^^^^^^ use of mutable static - | - = note: mutable statics can be mutated by multiple threads: aliasing violations or data races will cause undefined behavior - -error: aborting due to 5 previous errors; 1 warning emitted - -Some errors have detailed explanations: E0013, E0133, E0625, E0658. -For more information about an error, try `rustc --explain E0013`. diff --git a/tests/ui/trait-impl-bound-suggestions.fixed b/tests/ui/trait-impl-bound-suggestions.fixed index 744e7bef04e..fb11286a175 100644 --- a/tests/ui/trait-impl-bound-suggestions.fixed +++ b/tests/ui/trait-impl-bound-suggestions.fixed @@ -17,4 +17,13 @@ trait InsufficientlyConstrainedGeneric<X=()> where X: std::marker::Copy { } } +// Regression test for #120838 +#[allow(dead_code)] +trait InsufficientlyConstrainedGenericWithEmptyWhere<X=()> where X: std::marker::Copy { + fn return_the_constrained_type(&self, x: X) -> ConstrainedStruct<X> { + //~^ ERROR the trait bound `X: Copy` is not satisfied + ConstrainedStruct { x } + } +} + pub fn main() { } diff --git a/tests/ui/trait-impl-bound-suggestions.rs b/tests/ui/trait-impl-bound-suggestions.rs index bf75175179e..46130a5e766 100644 --- a/tests/ui/trait-impl-bound-suggestions.rs +++ b/tests/ui/trait-impl-bound-suggestions.rs @@ -17,4 +17,13 @@ trait InsufficientlyConstrainedGeneric<X=()> { } } +// Regression test for #120838 +#[allow(dead_code)] +trait InsufficientlyConstrainedGenericWithEmptyWhere<X=()> where { + fn return_the_constrained_type(&self, x: X) -> ConstrainedStruct<X> { + //~^ ERROR the trait bound `X: Copy` is not satisfied + ConstrainedStruct { x } + } +} + pub fn main() { } diff --git a/tests/ui/trait-impl-bound-suggestions.stderr b/tests/ui/trait-impl-bound-suggestions.stderr index c1f31e2b32e..9883c5bda01 100644 --- a/tests/ui/trait-impl-bound-suggestions.stderr +++ b/tests/ui/trait-impl-bound-suggestions.stderr @@ -14,6 +14,22 @@ help: consider further restricting type parameter `X` LL | trait InsufficientlyConstrainedGeneric<X=()> where X: std::marker::Copy { | ++++++++++++++++++++++++++ -error: aborting due to 1 previous error +error[E0277]: the trait bound `X: Copy` is not satisfied + --> $DIR/trait-impl-bound-suggestions.rs:23:52 + | +LL | fn return_the_constrained_type(&self, x: X) -> ConstrainedStruct<X> { + | ^^^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `X` + | +note: required by a bound in `ConstrainedStruct` + --> $DIR/trait-impl-bound-suggestions.rs:8:29 + | +LL | struct ConstrainedStruct<X: Copy> { + | ^^^^ required by this bound in `ConstrainedStruct` +help: consider further restricting type parameter `X` + | +LL | trait InsufficientlyConstrainedGenericWithEmptyWhere<X=()> where X: std::marker::Copy { + | ++++++++++++++++++++ + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/next-solver/deduce-closure-signature-after-normalization.rs b/tests/ui/traits/next-solver/deduce-closure-signature-after-normalization.rs index 08f26686b2f..f9f5a1dc24d 100644 --- a/tests/ui/traits/next-solver/deduce-closure-signature-after-normalization.rs +++ b/tests/ui/traits/next-solver/deduce-closure-signature-after-normalization.rs @@ -1,9 +1,10 @@ // compile-flags: -Znext-solver -// check-pass - +// FIXME(-Znext-solver): This test is currently broken because the `deduce_closure_signature` +// is unable to look at nested obligations. trait Foo { fn test() -> impl Fn(u32) -> u32 { |x| x.count_ones() + //~^ ERROR type annotations needed } } diff --git a/tests/ui/traits/next-solver/deduce-closure-signature-after-normalization.stderr b/tests/ui/traits/next-solver/deduce-closure-signature-after-normalization.stderr new file mode 100644 index 00000000000..3d7cd1af467 --- /dev/null +++ b/tests/ui/traits/next-solver/deduce-closure-signature-after-normalization.stderr @@ -0,0 +1,14 @@ +error[E0282]: type annotations needed + --> $DIR/deduce-closure-signature-after-normalization.rs:6:10 + | +LL | |x| x.count_ones() + | ^ - type must be known at this point + | +help: consider giving this closure parameter an explicit type + | +LL | |x: /* Type */| x.count_ones() + | ++++++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/traits/next-solver/dont-type_of-tait-in-defining-scope.is_send.stderr b/tests/ui/traits/next-solver/dont-type_of-tait-in-defining-scope.is_send.stderr index bafc4ba18a7..158fefd1538 100644 --- a/tests/ui/traits/next-solver/dont-type_of-tait-in-defining-scope.is_send.stderr +++ b/tests/ui/traits/next-solver/dont-type_of-tait-in-defining-scope.is_send.stderr @@ -1,16 +1,9 @@ -error[E0283]: type annotations needed: cannot satisfy `Foo: Send` +error[E0284]: type annotations needed: cannot satisfy `Foo == _` --> $DIR/dont-type_of-tait-in-defining-scope.rs:15:18 | LL | needs_send::<Foo>(); - | ^^^ - | - = note: cannot satisfy `Foo: Send` -note: required by a bound in `needs_send` - --> $DIR/dont-type_of-tait-in-defining-scope.rs:12:18 - | -LL | fn needs_send<T: Send>() {} - | ^^^^ required by this bound in `needs_send` + | ^^^ cannot satisfy `Foo == _` error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0283`. +For more information about this error, try `rustc --explain E0284`. diff --git a/tests/ui/traits/next-solver/dont-type_of-tait-in-defining-scope.not_send.stderr b/tests/ui/traits/next-solver/dont-type_of-tait-in-defining-scope.not_send.stderr index bafc4ba18a7..158fefd1538 100644 --- a/tests/ui/traits/next-solver/dont-type_of-tait-in-defining-scope.not_send.stderr +++ b/tests/ui/traits/next-solver/dont-type_of-tait-in-defining-scope.not_send.stderr @@ -1,16 +1,9 @@ -error[E0283]: type annotations needed: cannot satisfy `Foo: Send` +error[E0284]: type annotations needed: cannot satisfy `Foo == _` --> $DIR/dont-type_of-tait-in-defining-scope.rs:15:18 | LL | needs_send::<Foo>(); - | ^^^ - | - = note: cannot satisfy `Foo: Send` -note: required by a bound in `needs_send` - --> $DIR/dont-type_of-tait-in-defining-scope.rs:12:18 - | -LL | fn needs_send<T: Send>() {} - | ^^^^ required by this bound in `needs_send` + | ^^^ cannot satisfy `Foo == _` error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0283`. +For more information about this error, try `rustc --explain E0284`. diff --git a/tests/ui/traits/next-solver/dont-type_of-tait-in-defining-scope.rs b/tests/ui/traits/next-solver/dont-type_of-tait-in-defining-scope.rs index ef0360248b5..9720a653e2b 100644 --- a/tests/ui/traits/next-solver/dont-type_of-tait-in-defining-scope.rs +++ b/tests/ui/traits/next-solver/dont-type_of-tait-in-defining-scope.rs @@ -13,7 +13,7 @@ fn needs_send<T: Send>() {} fn test(_: Foo) { needs_send::<Foo>(); - //~^ ERROR type annotations needed: cannot satisfy `Foo: Send` + //~^ ERROR type annotations needed: cannot satisfy `Foo == _` } fn defines(_: Foo) { diff --git a/tests/ui/treat-err-as-bug/eagerly-emit.rs b/tests/ui/treat-err-as-bug/eagerly-emit.rs deleted file mode 100644 index ede190575d5..00000000000 --- a/tests/ui/treat-err-as-bug/eagerly-emit.rs +++ /dev/null @@ -1,10 +0,0 @@ -// compile-flags: -Zeagerly-emit-delayed-bugs - -trait Foo {} - -fn main() {} - -fn f() -> impl Foo { - //~^ ERROR the trait bound `i32: Foo` is not satisfied - 1i32 -} diff --git a/tests/ui/treat-err-as-bug/eagerly-emit.stderr b/tests/ui/treat-err-as-bug/eagerly-emit.stderr deleted file mode 100644 index 4ae596435aa..00000000000 --- a/tests/ui/treat-err-as-bug/eagerly-emit.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: trimmed_def_paths constructed but no error emitted; use `DelayDm` for lints or `with_no_trimmed_paths` for debugging - -error[E0277]: the trait bound `i32: Foo` is not satisfied - --> $DIR/eagerly-emit.rs:7:11 - | -LL | fn f() -> impl Foo { - | ^^^^^^^^ the trait `Foo` is not implemented for `i32` -LL | -LL | 1i32 - | ---- return type was inferred to be `i32` here - | -help: this trait has no implementations, consider adding one - --> $DIR/eagerly-emit.rs:3:1 - | -LL | trait Foo {} - | ^^^^^^^^^ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/treat-err-as-bug/span_delayed_bug.rs b/tests/ui/treat-err-as-bug/span_delayed_bug.rs index 8b9526bf3f9..1ea14aee6c4 100644 --- a/tests/ui/treat-err-as-bug/span_delayed_bug.rs +++ b/tests/ui/treat-err-as-bug/span_delayed_bug.rs @@ -1,12 +1,12 @@ // compile-flags: -Ztreat-err-as-bug -Zeagerly-emit-delayed-bugs // failure-status: 101 // error-pattern: aborting due to `-Z treat-err-as-bug=1` -// error-pattern: [trigger_span_delayed_bug] triggering a span delayed bug for testing incremental +// error-pattern: [trigger_delayed_bug] triggering a delayed bug for testing incremental // normalize-stderr-test "note: .*\n\n" -> "" // normalize-stderr-test "thread 'rustc' panicked.*:\n.*\n" -> "" // rustc-env:RUST_BACKTRACE=0 #![feature(rustc_attrs)] -#[rustc_error(span_delayed_bug_from_inside_query)] +#[rustc_error(delayed_bug_from_inside_query)] fn main() {} diff --git a/tests/ui/treat-err-as-bug/span_delayed_bug.stderr b/tests/ui/treat-err-as-bug/span_delayed_bug.stderr index a61ffaea8c2..f0e8cd0ddb9 100644 --- a/tests/ui/treat-err-as-bug/span_delayed_bug.stderr +++ b/tests/ui/treat-err-as-bug/span_delayed_bug.stderr @@ -1,4 +1,4 @@ -error: internal compiler error: delayed span bug triggered by #[rustc_error(span_delayed_bug_from_inside_query)] +error: internal compiler error: delayed bug triggered by #[rustc_error(delayed_bug_from_inside_query)] --> $DIR/span_delayed_bug.rs:12:1 | LL | fn main() {} @@ -7,5 +7,5 @@ LL | fn main() {} error: the compiler unexpectedly panicked. this is a bug. query stack during panic: -#0 [trigger_span_delayed_bug] triggering a span delayed bug for testing incremental +#0 [trigger_delayed_bug] triggering a delayed bug for testing incremental end of query stack diff --git a/tests/ui/type-alias-impl-trait/self-referential-2.stderr b/tests/ui/type-alias-impl-trait/self-referential-2.current.stderr index ab57812ba9b..019e01a07d3 100644 --- a/tests/ui/type-alias-impl-trait/self-referential-2.stderr +++ b/tests/ui/type-alias-impl-trait/self-referential-2.current.stderr @@ -1,5 +1,5 @@ error[E0277]: can't compare `i32` with `Foo` - --> $DIR/self-referential-2.rs:6:13 + --> $DIR/self-referential-2.rs:9:13 | LL | fn bar() -> Bar { | ^^^ no implementation for `i32 == Foo` diff --git a/tests/ui/type-alias-impl-trait/self-referential-2.rs b/tests/ui/type-alias-impl-trait/self-referential-2.rs index 8781196c39f..3a765a2e3ef 100644 --- a/tests/ui/type-alias-impl-trait/self-referential-2.rs +++ b/tests/ui/type-alias-impl-trait/self-referential-2.rs @@ -1,10 +1,13 @@ +// revisions: current next +//[next] compile-flags: -Znext-solver +//[next] check-pass #![feature(type_alias_impl_trait)] type Foo = impl std::fmt::Debug; type Bar = impl PartialEq<Foo>; fn bar() -> Bar { - 42_i32 //~^ ERROR can't compare `i32` with `Foo` + 42_i32 //[current]~^ ERROR can't compare `i32` with `Foo` } fn main() {} diff --git a/tests/ui/type-alias-impl-trait/type-alias-impl-trait-tuple.next.stderr b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-tuple.next.stderr new file mode 100644 index 00000000000..b380dc66f03 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-tuple.next.stderr @@ -0,0 +1,15 @@ +error[E0284]: type annotations needed: cannot satisfy `Foo == _` + --> $DIR/type-alias-impl-trait-tuple.rs:21:24 + | +LL | Blah { my_foo: make_foo(), my_u8: 12 } + | ^^^^^^^^^^ cannot satisfy `Foo == _` + +error[E0284]: type annotations needed: cannot satisfy `Foo == _` + --> $DIR/type-alias-impl-trait-tuple.rs:25:10 + | +LL | (self.my_foo, self.my_u8, make_foo()) + | ^^^^^^^^^^^ cannot satisfy `Foo == _` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0284`. diff --git a/tests/ui/type-alias-impl-trait/type-alias-impl-trait-tuple.rs b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-tuple.rs index 1f2d0e47ea3..7bf899a96be 100644 --- a/tests/ui/type-alias-impl-trait/type-alias-impl-trait-tuple.rs +++ b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-tuple.rs @@ -1,4 +1,6 @@ -// check-pass +// revisions: current next +//[next] compile-flags: -Znext-solver +//[current] check-pass #![feature(type_alias_impl_trait)] #![allow(dead_code)] @@ -17,9 +19,11 @@ struct Blah { impl Blah { fn new() -> Blah { Blah { my_foo: make_foo(), my_u8: 12 } + //[next]~^ ERROR type annotations needed: cannot satisfy `Foo == _` } fn into_inner(self) -> (Foo, u8, Foo) { (self.my_foo, self.my_u8, make_foo()) + //[next]~^ ERROR type annotations needed: cannot satisfy `Foo == _` } } diff --git a/tests/ui/type-alias-impl-trait/type_of_a_let.stderr b/tests/ui/type-alias-impl-trait/type_of_a_let.current.stderr index 7d7cad874fa..22a3d7bd32f 100644 --- a/tests/ui/type-alias-impl-trait/type_of_a_let.stderr +++ b/tests/ui/type-alias-impl-trait/type_of_a_let.current.stderr @@ -1,5 +1,5 @@ error[E0382]: use of moved value: `x` - --> $DIR/type_of_a_let.rs:16:16 + --> $DIR/type_of_a_let.rs:20:16 | LL | let x: Foo = 22_u32; | - move occurs because `x` has type `Foo`, which does not implement the `Copy` trait @@ -9,7 +9,7 @@ LL | same_type((x, y)); | ^ value used here after move error[E0382]: use of moved value: `y` - --> $DIR/type_of_a_let.rs:17:6 + --> $DIR/type_of_a_let.rs:21:6 | LL | let y: Foo = x; | - move occurs because `y` has type `Foo`, which does not implement the `Copy` trait diff --git a/tests/ui/type-alias-impl-trait/type_of_a_let.rs b/tests/ui/type-alias-impl-trait/type_of_a_let.rs index 36161171555..0f4dac6c683 100644 --- a/tests/ui/type-alias-impl-trait/type_of_a_let.rs +++ b/tests/ui/type-alias-impl-trait/type_of_a_let.rs @@ -1,3 +1,7 @@ +// revisions: current next +//[next] compile-flags: -Znext-solver +//[next] check-pass + #![feature(type_alias_impl_trait)] #![allow(dead_code)] @@ -13,8 +17,8 @@ fn foo1() -> (u32, Foo) { fn foo2() -> (u32, Foo) { let x: Foo = 22_u32; let y: Foo = x; - same_type((x, y)); //~ ERROR use of moved value - (y, todo!()) //~ ERROR use of moved value + same_type((x, y)); //[current]~ ERROR use of moved value + (y, todo!()) //[current]~ ERROR use of moved value } fn same_type<T>(x: (T, T)) {} diff --git a/tests/ui/typeck/issue-104510-ice.rs b/tests/ui/typeck/issue-104510-ice.rs index 635cc8fad66..157bdf07e38 100644 --- a/tests/ui/typeck/issue-104510-ice.rs +++ b/tests/ui/typeck/issue-104510-ice.rs @@ -6,7 +6,7 @@ struct W<T: ?Sized>(Oops); unsafe fn test() { let j = W(()); - let pointer = &j as *const _; //~ ERROR type annotations needed + let pointer = &j as *const _; core::arch::asm!( "nop", in("eax") pointer, diff --git a/tests/ui/typeck/issue-104510-ice.stderr b/tests/ui/typeck/issue-104510-ice.stderr index 774e5268184..143139b2c08 100644 --- a/tests/ui/typeck/issue-104510-ice.stderr +++ b/tests/ui/typeck/issue-104510-ice.stderr @@ -4,18 +4,6 @@ error[E0412]: cannot find type `Oops` in this scope LL | struct W<T: ?Sized>(Oops); | ^^^^ not found in this scope -error[E0282]: type annotations needed for `*const W<T>` - --> $DIR/issue-104510-ice.rs:9:9 - | -LL | let pointer = &j as *const _; - | ^^^^^^^ - | -help: consider giving `pointer` an explicit type, where the type for type parameter `T` is specified - | -LL | let pointer: *const W<T> = &j as *const _; - | +++++++++++++ - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0282, E0412. -For more information about an error, try `rustc --explain E0282`. +For more information about this error, try `rustc --explain E0412`. diff --git a/tests/ui/typeck/issue-116864.rs b/tests/ui/typeck/issue-116864.rs new file mode 100644 index 00000000000..88c3f786608 --- /dev/null +++ b/tests/ui/typeck/issue-116864.rs @@ -0,0 +1,31 @@ +// compile-flags: -Znext-solver +// check-pass +// edition: 2021 + +use std::future::Future; + +trait Baz { + type Param; +} + +trait FnMutFut<P, R>: FnMut(P) -> Self::Future { + type Future: Future<Output = R>; +} + +impl<P, F, FUT, R> FnMutFut<P, R> for F +where + F: FnMut(P) -> FUT, + FUT: Future<Output = R>, +{ + type Future = FUT; +} + +async fn foo<BAZ>(_: BAZ, mut cb: impl for<'any> FnMutFut<&'any BAZ::Param, ()>) +where + BAZ: Baz<Param = i32>, +{ + cb(&1i32).await; +} + +fn main() { +} diff --git a/tests/ui/typeck/issue-120856.rs b/tests/ui/typeck/issue-120856.rs new file mode 100644 index 00000000000..e435a0f9d8e --- /dev/null +++ b/tests/ui/typeck/issue-120856.rs @@ -0,0 +1,5 @@ +pub type Archived<T> = <m::Alias as n::Trait>::Archived; +//~^ ERROR failed to resolve: use of undeclared crate or module `m` +//~| ERROR failed to resolve: use of undeclared crate or module `n` + +fn main() {} diff --git a/tests/ui/typeck/issue-120856.stderr b/tests/ui/typeck/issue-120856.stderr new file mode 100644 index 00000000000..1fc8b200473 --- /dev/null +++ b/tests/ui/typeck/issue-120856.stderr @@ -0,0 +1,21 @@ +error[E0433]: failed to resolve: use of undeclared crate or module `n` + --> $DIR/issue-120856.rs:1:37 + | +LL | pub type Archived<T> = <m::Alias as n::Trait>::Archived; + | ^ + | | + | use of undeclared crate or module `n` + | help: a trait with a similar name exists: `Fn` + +error[E0433]: failed to resolve: use of undeclared crate or module `m` + --> $DIR/issue-120856.rs:1:25 + | +LL | pub type Archived<T> = <m::Alias as n::Trait>::Archived; + | ^ + | | + | use of undeclared crate or module `m` + | help: a type parameter with a similar name exists: `T` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0433`. diff --git a/tests/ui/union/unnamed-fields/field_uniqueness_check.rs b/tests/ui/union/unnamed-fields/field_uniqueness_check.rs new file mode 100644 index 00000000000..ddb951aa06c --- /dev/null +++ b/tests/ui/union/unnamed-fields/field_uniqueness_check.rs @@ -0,0 +1,337 @@ +#![allow(incomplete_features)] +#![feature(unnamed_fields)] + +#[derive(Clone, Copy)] +#[repr(C)] +struct Foo { + a: u8, +} + +#[derive(Clone, Copy)] +#[repr(C)] +struct Bar { + _: union { + a: u8, + }, +} + + +// duplicated with a normal field +#[derive(Clone, Copy)] +#[repr(C)] +union A { + // referent field + a: u8, + + // normal field + a: u8, //~ ERROR field `a` is already declared [E0124] + // nested field + _: struct { + a: u8, //~ ERROR field `a` is already declared [E0124] + a: u8, //~ ERROR field `a` is already declared [E0124] + }, + // more nested field + _: union { + _: struct { + a: u8, //~ ERROR field `a` is already declared [E0124] + }, + }, + // nested field in a named adt + _: Foo, //~ ERROR field `a` is already declared + _: Bar, //~ ERROR field `a` is already declared + // nested field in a named adt in an anoymous adt + _: struct { + _: Foo, //~ ERROR field `a` is already declared + _: Bar, //~ ERROR field `a` is already declared + }, +} + +// duplicated with a nested field +#[derive(Clone, Copy)] +#[repr(C)] +struct B { + _: union { + // referent field + a: u8, + + // normal field (within the same anonymous adt) + a: u8, //~ ERROR field `a` is already declared [E0124] + // nested field (within the same anonymous adt) + _: struct { + a: u8, //~ ERROR field `a` is already declared [E0124] + }, + // more nested field (within the same anonymous adt) + _: union { + _: struct { + a: u8, //~ ERROR field `a` is already declared [E0124] + }, + }, + // nested field in a named adt (within the same anonymous adt) + _: Foo, //~ ERROR field `a` is already declared + _: Bar, //~ ERROR field `a` is already declared + // nested field in a named adt in an anoymous adt (within the same anonymous adt) + _: struct { + _: Foo, //~ ERROR field `a` is already declared + _: Bar, //~ ERROR field `a` is already declared + }, + }, + + // normal field + a: u8, //~ ERROR field `a` is already declared [E0124] + // nested field + _: struct { + a: u8, //~ ERROR field `a` is already declared [E0124] + }, + // more nested field + _: union { + _: struct { + a: u8, //~ ERROR field `a` is already declared [E0124] + }, + }, + // nested field in a named adt + _: Foo, //~ ERROR field `a` is already declared + _: Bar, //~ ERROR field `a` is already declared + // nested field in a named adt in an anoymous adt + _: struct { + _: Foo, //~ ERROR field `a` is already declared + _: Bar, //~ ERROR field `a` is already declared + }, +} + +// duplicated with a more nested field +#[derive(Clone, Copy)] +#[repr(C)] +union C { + _: struct { + _: union { + // referent field + a: u8, + + // normal field (within the same anonymous adt) + a: u8, //~ ERROR field `a` is already declared [E0124] + // nested field (within the same anonymous adt) + _: struct { + a: u8, //~ ERROR field `a` is already declared [E0124] + }, + // more nested field (within the same anonymous adt) + _: union { + _: struct { + a: u8, //~ ERROR field `a` is already declared [E0124] + }, + }, + // nested field in a named adt (within the same anonymous adt) + _: Foo, //~ ERROR field `a` is already declared + _: Bar, //~ ERROR field `a` is already declared + // nested field in a named adt in an anoymous adt (within the same anonymous adt) + _: struct { + _: Foo, //~ ERROR field `a` is already declared + _: Bar, //~ ERROR field `a` is already declared + }, + }, + + // normal field (within the direct outer anonymous adt) + a: u8, //~ ERROR field `a` is already declared [E0124] + // nested field (within the direct outer anonymous adt) + _: struct { + a: u8, //~ ERROR field `a` is already declared [E0124] + }, + // more nested field (within the direct outer anonymous adt) + _: union { + _: struct { + a: u8, //~ ERROR field `a` is already declared [E0124] + }, + }, + // nested field in a named adt (within the direct outer anonymous adt) + _: Foo, //~ ERROR field `a` is already declared + _: Bar, //~ ERROR field `a` is already declared + // nested field in a named adt in an anoymous adt (within the direct outer anonymous adt) + _: struct { + _: Foo, //~ ERROR field `a` is already declared + _: Bar, //~ ERROR field `a` is already declared + }, + }, + // normal field + a: u8, //~ ERROR field `a` is already declared [E0124] + // nested field + _: union { + a: u8, //~ ERROR field `a` is already declared [E0124] + }, + // more nested field + _: struct { + _: union { + a: u8, //~ ERROR field `a` is already declared [E0124] + }, + }, + // nested field in a named adt + _: Foo, //~ ERROR field `a` is already declared + _: Bar, //~ ERROR field `a` is already declared + // nested field in a named adt in an anoymous adt + _: union { + _: Foo, //~ ERROR field `a` is already declared + _: Bar, //~ ERROR field `a` is already declared + }, +} + +// duplicated with a nested field in a named adt +#[derive(Clone, Copy)] +#[repr(C)] +struct D { + // referent field `a` + _: Foo, + + // normal field + a: u8, //~ ERROR field `a` is already declared + // nested field + _: union { + a: u8, //~ ERROR field `a` is already declared + }, + // more nested field + _: struct { + _: union { + a: u8, //~ ERROR field `a` is already declared + }, + }, + // nested field in another named adt + _: Foo, //~ ERROR field `a` is already declared + _: Bar, //~ ERROR field `a` is already declared + // nested field in a named adt in an anoymous adt + _: union { + _: Foo, //~ ERROR field `a` is already declared + _: Bar, //~ ERROR field `a` is already declared + }, +} + +// duplicated with a nested field in a nested field of a named adt +#[derive(Clone, Copy)] +#[repr(C)] +union D2 { + // referent field `a` + _: Bar, + + // normal field + a: u8, //~ ERROR field `a` is already declared + // nested field + _: union { + a: u8, //~ ERROR field `a` is already declared + }, + // more nested field + _: struct { + _: union { + a: u8, //~ ERROR field `a` is already declared + }, + }, + // nested field in another named adt + _: Foo, //~ ERROR field `a` is already declared + _: Bar, //~ ERROR field `a` is already declared + // nested field in a named adt in an anoymous adt + _: union { + _: Foo, //~ ERROR field `a` is already declared + _: Bar, //~ ERROR field `a` is already declared + }, +} + +// duplicated with a nested field in a named adt in an anonymous adt +#[derive(Clone, Copy)] +#[repr(C)] +struct E { + _: struct { + // referent field `a` + _: Foo, + + // normal field (within the same anonymous adt) + a: u8, //~ ERROR field `a` is already declared + // nested field (within the same anonymous adt) + _: struct { + a: u8, //~ ERROR field `a` is already declared + }, + // more nested field (within the same anonymous adt) + _: union { + _: struct { + a: u8, //~ ERROR field `a` is already declared + }, + }, + // nested field in a named adt (within the same anonymous adt) + _: Foo, //~ ERROR field `a` is already declared + _: Bar, //~ ERROR field `a` is already declared + // nested field in a named adt in an anoymous adt (within the same anonymous adt) + _: struct { + _: Foo, //~ ERROR field `a` is already declared + _: Bar, //~ ERROR field `a` is already declared + }, + }, + + // normal field + a: u8, //~ ERROR field `a` is already declared + // nested field + _: union { + a: u8, //~ ERROR field `a` is already declared + }, + // more nested field + _: struct { + _: union { + a: u8, //~ ERROR field `a` is already declared + }, + }, + // nested field in another named adt + _: Foo, //~ ERROR field `a` is already declared + _: Bar, //~ ERROR field `a` is already declared + // nested field in a named adt in an anoymous adt + _: union { + _: Foo, //~ ERROR field `a` is already declared + _: Bar, //~ ERROR field `a` is already declared + }, +} + +// duplicated with a nested field in a named adt in an anonymous adt +#[repr(C)] +#[derive(Clone, Copy)] +union E2 { + _: struct { + // referent field `a` + _: Bar, + + // normal field (within the same anonymous adt) + a: u8, //~ ERROR field `a` is already declared + // nested field (within the same anonymous adt) + _: struct { + a: u8, //~ ERROR field `a` is already declared + }, + // more nested field (within the same anonymous adt) + _: union { + _: struct { + a: u8, //~ ERROR field `a` is already declared + }, + }, + // nested field in a named adt (within the same anonymous adt) + _: Foo, //~ ERROR field `a` is already declared + _: Bar, //~ ERROR field `a` is already declared + // nested field in a named adt in an anoymous adt (within the same anonymous adt) + _: struct { + _: Foo, //~ ERROR field `a` is already declared + _: Bar, //~ ERROR field `a` is already declared + }, + }, + + // normal field + a: u8, //~ ERROR field `a` is already declared + // nested field + _: union { + a: u8, //~ ERROR field `a` is already declared + }, + // more nested field + _: struct { + _: union { + a: u8, //~ ERROR field `a` is already declared + }, + }, + // nested field in another named adt + _: Foo, //~ ERROR field `a` is already declared + _: Bar, //~ ERROR field `a` is already declared + // nested field in a named adt in an anoymous adt + _: union { + _: Foo, //~ ERROR field `a` is already declared + _: Bar, //~ ERROR field `a` is already declared + }, +} + +fn main() {} diff --git a/tests/ui/union/unnamed-fields/field_uniqueness_check.stderr b/tests/ui/union/unnamed-fields/field_uniqueness_check.stderr new file mode 100644 index 00000000000..11978386843 --- /dev/null +++ b/tests/ui/union/unnamed-fields/field_uniqueness_check.stderr @@ -0,0 +1,1734 @@ +error[E0124]: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:27:5 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | a: u8, + | ^^^^^ field already declared + +error[E0124]: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:30:9 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | a: u8, + | ^^^^^ field already declared + +error[E0124]: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:31:9 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | a: u8, + | ^^^^^ field already declared + +error[E0124]: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:36:13 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | a: u8, + | ^^^^^ field already declared + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:40:5 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | _: Foo, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:40:5 + | +LL | _: Foo, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:41:5 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | _: Bar, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:41:5 + | +LL | _: Bar, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:44:9 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | _: Foo, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:44:9 + | +LL | _: Foo, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:45:9 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | _: Bar, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:45:9 + | +LL | _: Bar, + | ^^^^^^ + +error[E0124]: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:58:9 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | a: u8, + | ^^^^^ field already declared + +error[E0124]: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:61:13 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | a: u8, + | ^^^^^ field already declared + +error[E0124]: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:66:17 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | a: u8, + | ^^^^^ field already declared + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:70:9 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | _: Foo, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:70:9 + | +LL | _: Foo, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:71:9 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | _: Bar, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:71:9 + | +LL | _: Bar, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:74:13 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | _: Foo, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:74:13 + | +LL | _: Foo, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:75:13 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | _: Bar, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:75:13 + | +LL | _: Bar, + | ^^^^^^ + +error[E0124]: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:80:5 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | a: u8, + | ^^^^^ field already declared + +error[E0124]: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:83:9 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | a: u8, + | ^^^^^ field already declared + +error[E0124]: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:88:13 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | a: u8, + | ^^^^^ field already declared + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:92:5 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | _: Foo, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:92:5 + | +LL | _: Foo, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:93:5 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | _: Bar, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:93:5 + | +LL | _: Bar, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:96:9 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | _: Foo, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:96:9 + | +LL | _: Foo, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:97:9 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | _: Bar, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:97:9 + | +LL | _: Bar, + | ^^^^^^ + +error[E0124]: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:111:13 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | a: u8, + | ^^^^^ field already declared + +error[E0124]: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:114:17 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | a: u8, + | ^^^^^ field already declared + +error[E0124]: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:119:21 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | a: u8, + | ^^^^^ field already declared + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:123:13 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | _: Foo, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:123:13 + | +LL | _: Foo, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:124:13 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | _: Bar, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:124:13 + | +LL | _: Bar, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:127:17 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | _: Foo, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:127:17 + | +LL | _: Foo, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:128:17 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | _: Bar, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:128:17 + | +LL | _: Bar, + | ^^^^^^ + +error[E0124]: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:133:9 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | a: u8, + | ^^^^^ field already declared + +error[E0124]: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:136:13 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | a: u8, + | ^^^^^ field already declared + +error[E0124]: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:141:17 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | a: u8, + | ^^^^^ field already declared + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:145:9 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | _: Foo, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:145:9 + | +LL | _: Foo, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:146:9 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | _: Bar, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:146:9 + | +LL | _: Bar, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:149:13 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | _: Foo, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:149:13 + | +LL | _: Foo, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:150:13 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | _: Bar, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:150:13 + | +LL | _: Bar, + | ^^^^^^ + +error[E0124]: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:154:5 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | a: u8, + | ^^^^^ field already declared + +error[E0124]: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:157:9 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | a: u8, + | ^^^^^ field already declared + +error[E0124]: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:162:13 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | a: u8, + | ^^^^^ field already declared + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:166:5 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | _: Foo, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:166:5 + | +LL | _: Foo, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:167:5 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | _: Bar, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:167:5 + | +LL | _: Bar, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:170:9 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | _: Foo, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:170:9 + | +LL | _: Foo, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:171:9 + | +LL | a: u8, + | ----- `a` first declared here +... +LL | _: Bar, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:171:9 + | +LL | _: Bar, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:183:5 + | +LL | _: Foo, + | ------ `a` first declared here in this unnamed field +... +LL | a: u8, + | ^^^^^ field already declared + | +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:180:5 + | +LL | _: Foo, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:186:9 + | +LL | _: Foo, + | ------ `a` first declared here in this unnamed field +... +LL | a: u8, + | ^^^^^ field already declared + | +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:180:5 + | +LL | _: Foo, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:191:13 + | +LL | _: Foo, + | ------ `a` first declared here in this unnamed field +... +LL | a: u8, + | ^^^^^ field already declared + | +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:180:5 + | +LL | _: Foo, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:195:5 + | +LL | _: Foo, + | ------ `a` first declared here in this unnamed field +... +LL | _: Foo, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:195:5 + | +LL | _: Foo, + | ^^^^^^ +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:180:5 + | +LL | _: Foo, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:196:5 + | +LL | _: Foo, + | ------ `a` first declared here in this unnamed field +... +LL | _: Bar, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:196:5 + | +LL | _: Bar, + | ^^^^^^ +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:180:5 + | +LL | _: Foo, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:199:9 + | +LL | _: Foo, + | ------ `a` first declared here in this unnamed field +... +LL | _: Foo, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:199:9 + | +LL | _: Foo, + | ^^^^^^ +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:180:5 + | +LL | _: Foo, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:200:9 + | +LL | _: Foo, + | ------ `a` first declared here in this unnamed field +... +LL | _: Bar, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:200:9 + | +LL | _: Bar, + | ^^^^^^ +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:180:5 + | +LL | _: Foo, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:212:5 + | +LL | _: Bar, + | ------ `a` first declared here in this unnamed field +... +LL | a: u8, + | ^^^^^ field already declared + | +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:209:5 + | +LL | _: Bar, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:215:9 + | +LL | _: Bar, + | ------ `a` first declared here in this unnamed field +... +LL | a: u8, + | ^^^^^ field already declared + | +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:209:5 + | +LL | _: Bar, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:220:13 + | +LL | _: Bar, + | ------ `a` first declared here in this unnamed field +... +LL | a: u8, + | ^^^^^ field already declared + | +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:209:5 + | +LL | _: Bar, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:224:5 + | +LL | _: Bar, + | ------ `a` first declared here in this unnamed field +... +LL | _: Foo, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:224:5 + | +LL | _: Foo, + | ^^^^^^ +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:209:5 + | +LL | _: Bar, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:225:5 + | +LL | _: Bar, + | ------ `a` first declared here in this unnamed field +... +LL | _: Bar, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:225:5 + | +LL | _: Bar, + | ^^^^^^ +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:209:5 + | +LL | _: Bar, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:228:9 + | +LL | _: Bar, + | ------ `a` first declared here in this unnamed field +... +LL | _: Foo, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:228:9 + | +LL | _: Foo, + | ^^^^^^ +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:209:5 + | +LL | _: Bar, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:229:9 + | +LL | _: Bar, + | ------ `a` first declared here in this unnamed field +... +LL | _: Bar, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:229:9 + | +LL | _: Bar, + | ^^^^^^ +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:209:5 + | +LL | _: Bar, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:242:9 + | +LL | _: Foo, + | ------ `a` first declared here in this unnamed field +... +LL | a: u8, + | ^^^^^ field already declared + | +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:239:9 + | +LL | _: Foo, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:245:13 + | +LL | _: Foo, + | ------ `a` first declared here in this unnamed field +... +LL | a: u8, + | ^^^^^ field already declared + | +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:239:9 + | +LL | _: Foo, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:250:17 + | +LL | _: Foo, + | ------ `a` first declared here in this unnamed field +... +LL | a: u8, + | ^^^^^ field already declared + | +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:239:9 + | +LL | _: Foo, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:254:9 + | +LL | _: Foo, + | ------ `a` first declared here in this unnamed field +... +LL | _: Foo, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:254:9 + | +LL | _: Foo, + | ^^^^^^ +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:239:9 + | +LL | _: Foo, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:255:9 + | +LL | _: Foo, + | ------ `a` first declared here in this unnamed field +... +LL | _: Bar, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:255:9 + | +LL | _: Bar, + | ^^^^^^ +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:239:9 + | +LL | _: Foo, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:258:13 + | +LL | _: Foo, + | ------ `a` first declared here in this unnamed field +... +LL | _: Foo, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:258:13 + | +LL | _: Foo, + | ^^^^^^ +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:239:9 + | +LL | _: Foo, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:259:13 + | +LL | _: Foo, + | ------ `a` first declared here in this unnamed field +... +LL | _: Bar, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:259:13 + | +LL | _: Bar, + | ^^^^^^ +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:239:9 + | +LL | _: Foo, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:264:5 + | +LL | _: Foo, + | ------ `a` first declared here in this unnamed field +... +LL | a: u8, + | ^^^^^ field already declared + | +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:239:9 + | +LL | _: Foo, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:267:9 + | +LL | _: Foo, + | ------ `a` first declared here in this unnamed field +... +LL | a: u8, + | ^^^^^ field already declared + | +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:239:9 + | +LL | _: Foo, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:272:13 + | +LL | _: Foo, + | ------ `a` first declared here in this unnamed field +... +LL | a: u8, + | ^^^^^ field already declared + | +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:239:9 + | +LL | _: Foo, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:276:5 + | +LL | _: Foo, + | ------ `a` first declared here in this unnamed field +... +LL | _: Foo, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:276:5 + | +LL | _: Foo, + | ^^^^^^ +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:239:9 + | +LL | _: Foo, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:277:5 + | +LL | _: Foo, + | ------ `a` first declared here in this unnamed field +... +LL | _: Bar, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:277:5 + | +LL | _: Bar, + | ^^^^^^ +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:239:9 + | +LL | _: Foo, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:280:9 + | +LL | _: Foo, + | ------ `a` first declared here in this unnamed field +... +LL | _: Foo, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:280:9 + | +LL | _: Foo, + | ^^^^^^ +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:239:9 + | +LL | _: Foo, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:281:9 + | +LL | _: Foo, + | ------ `a` first declared here in this unnamed field +... +LL | _: Bar, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:281:9 + | +LL | _: Bar, + | ^^^^^^ +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:239:9 + | +LL | _: Foo, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:294:9 + | +LL | _: Bar, + | ------ `a` first declared here in this unnamed field +... +LL | a: u8, + | ^^^^^ field already declared + | +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:291:9 + | +LL | _: Bar, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:297:13 + | +LL | _: Bar, + | ------ `a` first declared here in this unnamed field +... +LL | a: u8, + | ^^^^^ field already declared + | +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:291:9 + | +LL | _: Bar, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:302:17 + | +LL | _: Bar, + | ------ `a` first declared here in this unnamed field +... +LL | a: u8, + | ^^^^^ field already declared + | +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:291:9 + | +LL | _: Bar, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:306:9 + | +LL | _: Bar, + | ------ `a` first declared here in this unnamed field +... +LL | _: Foo, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:306:9 + | +LL | _: Foo, + | ^^^^^^ +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:291:9 + | +LL | _: Bar, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:307:9 + | +LL | _: Bar, + | ------ `a` first declared here in this unnamed field +... +LL | _: Bar, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:307:9 + | +LL | _: Bar, + | ^^^^^^ +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:291:9 + | +LL | _: Bar, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:310:13 + | +LL | _: Bar, + | ------ `a` first declared here in this unnamed field +... +LL | _: Foo, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:310:13 + | +LL | _: Foo, + | ^^^^^^ +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:291:9 + | +LL | _: Bar, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:311:13 + | +LL | _: Bar, + | ------ `a` first declared here in this unnamed field +... +LL | _: Bar, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:311:13 + | +LL | _: Bar, + | ^^^^^^ +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:291:9 + | +LL | _: Bar, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:316:5 + | +LL | _: Bar, + | ------ `a` first declared here in this unnamed field +... +LL | a: u8, + | ^^^^^ field already declared + | +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:291:9 + | +LL | _: Bar, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:319:9 + | +LL | _: Bar, + | ------ `a` first declared here in this unnamed field +... +LL | a: u8, + | ^^^^^ field already declared + | +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:291:9 + | +LL | _: Bar, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:324:13 + | +LL | _: Bar, + | ------ `a` first declared here in this unnamed field +... +LL | a: u8, + | ^^^^^ field already declared + | +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:291:9 + | +LL | _: Bar, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:328:5 + | +LL | _: Bar, + | ------ `a` first declared here in this unnamed field +... +LL | _: Foo, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:328:5 + | +LL | _: Foo, + | ^^^^^^ +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:291:9 + | +LL | _: Bar, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:329:5 + | +LL | _: Bar, + | ------ `a` first declared here in this unnamed field +... +LL | _: Bar, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:329:5 + | +LL | _: Bar, + | ^^^^^^ +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:291:9 + | +LL | _: Bar, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:332:9 + | +LL | _: Bar, + | ------ `a` first declared here in this unnamed field +... +LL | _: Foo, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:7:5 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:332:9 + | +LL | _: Foo, + | ^^^^^^ +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:291:9 + | +LL | _: Bar, + | ^^^^^^ + +error: field `a` is already declared + --> $DIR/field_uniqueness_check.rs:333:9 + | +LL | _: Bar, + | ------ `a` first declared here in this unnamed field +... +LL | _: Bar, + | ^^^^^^ field `a` declared in this unnamed field + | +note: field `a` declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:333:9 + | +LL | _: Bar, + | ^^^^^^ +note: field `a` first declared here + --> $DIR/field_uniqueness_check.rs:14:9 + | +LL | a: u8, + | ^^^^^ +help: fields from the type of this unnamed field are considered fields of the outer type + --> $DIR/field_uniqueness_check.rs:291:9 + | +LL | _: Bar, + | ^^^^^^ + +error: aborting due to 85 previous errors + +For more information about this error, try `rustc --explain E0124`. diff --git a/tests/ui/union/unnamed-fields/repr_check.rs b/tests/ui/union/unnamed-fields/repr_check.rs new file mode 100644 index 00000000000..b50b54b20af --- /dev/null +++ b/tests/ui/union/unnamed-fields/repr_check.rs @@ -0,0 +1,69 @@ +#![allow(incomplete_features)] +#![feature(unnamed_fields)] + +struct A { //~ ERROR struct with unnamed fields must have `#[repr(C)]` representation + //~^ NOTE struct `A` defined here + _: struct { //~ NOTE unnamed field defined here + a: i32, + }, + _: struct { //~ NOTE unnamed field defined here + _: struct { + b: i32, + }, + }, +} + +union B { //~ ERROR union with unnamed fields must have `#[repr(C)]` representation + //~^ NOTE union `B` defined here + _: union { //~ NOTE unnamed field defined here + a: i32, + }, + _: union { //~ NOTE unnamed field defined here + _: union { + b: i32, + }, + }, +} + +#[derive(Clone, Copy)] +#[repr(C)] +struct Foo {} + +#[derive(Clone, Copy)] +struct Bar {} +//~^ `Bar` defined here +//~| `Bar` defined here +//~| `Bar` defined here +//~| `Bar` defined here + +struct C { //~ ERROR struct with unnamed fields must have `#[repr(C)]` representation + //~^ NOTE struct `C` defined here + _: Foo, //~ NOTE unnamed field defined here +} + +union D { //~ ERROR union with unnamed fields must have `#[repr(C)]` representation + //~^ NOTE union `D` defined here + _: Foo, //~ NOTE unnamed field defined here +} + +#[repr(C)] +struct E { + _: Bar, //~ ERROR named type of unnamed field must have `#[repr(C)]` representation + //~^ NOTE unnamed field defined here + _: struct { + _: Bar, //~ ERROR named type of unnamed field must have `#[repr(C)]` representation + //~^ NOTE unnamed field defined here + }, +} + +#[repr(C)] +union F { + _: Bar, //~ ERROR named type of unnamed field must have `#[repr(C)]` representation + //~^ NOTE unnamed field defined here + _: union { + _: Bar, //~ ERROR named type of unnamed field must have `#[repr(C)]` representation + //~^ NOTE unnamed field defined here + }, +} + +fn main() {} diff --git a/tests/ui/union/unnamed-fields/repr_check.stderr b/tests/ui/union/unnamed-fields/repr_check.stderr new file mode 100644 index 00000000000..324968b1264 --- /dev/null +++ b/tests/ui/union/unnamed-fields/repr_check.stderr @@ -0,0 +1,152 @@ +error: struct with unnamed fields must have `#[repr(C)]` representation + --> $DIR/repr_check.rs:4:1 + | +LL | struct A { + | ^^^^^^^^ struct `A` defined here + | +note: unnamed field defined here + --> $DIR/repr_check.rs:6:5 + | +LL | / _: struct { +LL | | a: i32, +LL | | }, + | |_____^ +note: unnamed field defined here + --> $DIR/repr_check.rs:9:5 + | +LL | / _: struct { +LL | | _: struct { +LL | | b: i32, +LL | | }, +LL | | }, + | |_____^ +help: add `#[repr(C)]` to this struct + | +LL + #[repr(C)] +LL | struct A { + | + +error: union with unnamed fields must have `#[repr(C)]` representation + --> $DIR/repr_check.rs:16:1 + | +LL | union B { + | ^^^^^^^ union `B` defined here + | +note: unnamed field defined here + --> $DIR/repr_check.rs:18:5 + | +LL | / _: union { +LL | | a: i32, +LL | | }, + | |_____^ +note: unnamed field defined here + --> $DIR/repr_check.rs:21:5 + | +LL | / _: union { +LL | | _: union { +LL | | b: i32, +LL | | }, +LL | | }, + | |_____^ +help: add `#[repr(C)]` to this union + | +LL + #[repr(C)] +LL | union B { + | + +error: struct with unnamed fields must have `#[repr(C)]` representation + --> $DIR/repr_check.rs:39:1 + | +LL | struct C { + | ^^^^^^^^ struct `C` defined here + | +note: unnamed field defined here + --> $DIR/repr_check.rs:41:5 + | +LL | _: Foo, + | ^^^^^^ +help: add `#[repr(C)]` to this struct + | +LL + #[repr(C)] +LL | struct C { + | + +error: union with unnamed fields must have `#[repr(C)]` representation + --> $DIR/repr_check.rs:44:1 + | +LL | union D { + | ^^^^^^^ union `D` defined here + | +note: unnamed field defined here + --> $DIR/repr_check.rs:46:5 + | +LL | _: Foo, + | ^^^^^^ +help: add `#[repr(C)]` to this union + | +LL + #[repr(C)] +LL | union D { + | + +error: named type of unnamed field must have `#[repr(C)]` representation + --> $DIR/repr_check.rs:51:5 + | +LL | struct Bar {} + | ---------- `Bar` defined here +... +LL | _: Bar, + | ^^^^^^ unnamed field defined here + | +help: add `#[repr(C)]` to this struct + | +LL + #[repr(C)] +LL | struct Bar {} + | + +error: named type of unnamed field must have `#[repr(C)]` representation + --> $DIR/repr_check.rs:54:9 + | +LL | struct Bar {} + | ---------- `Bar` defined here +... +LL | _: Bar, + | ^^^^^^ unnamed field defined here + | +help: add `#[repr(C)]` to this struct + | +LL + #[repr(C)] +LL | struct Bar {} + | + +error: named type of unnamed field must have `#[repr(C)]` representation + --> $DIR/repr_check.rs:61:5 + | +LL | struct Bar {} + | ---------- `Bar` defined here +... +LL | _: Bar, + | ^^^^^^ unnamed field defined here + | +help: add `#[repr(C)]` to this struct + | +LL + #[repr(C)] +LL | struct Bar {} + | + +error: named type of unnamed field must have `#[repr(C)]` representation + --> $DIR/repr_check.rs:64:9 + | +LL | struct Bar {} + | ---------- `Bar` defined here +... +LL | _: Bar, + | ^^^^^^ unnamed field defined here + | +help: add `#[repr(C)]` to this struct + | +LL + #[repr(C)] +LL | struct Bar {} + | + +error: aborting due to 8 previous errors + diff --git a/tests/ui/union/unnamed-fields/restrict_anonymous_structs.rs b/tests/ui/union/unnamed-fields/restrict_anonymous_structs.rs index 192bbba5a5b..03545ed7b18 100644 --- a/tests/ui/union/unnamed-fields/restrict_anonymous_structs.rs +++ b/tests/ui/union/unnamed-fields/restrict_anonymous_structs.rs @@ -2,10 +2,8 @@ #![feature(unnamed_fields)] struct F { - field: struct { field: u8 }, //~ ERROR anonymous structs are not allowed outside of unnamed struct or union fields - //~^ ERROR anonymous structs are unimplemented - _: struct { field: u8 }, - //~^ ERROR anonymous structs are unimplemented + field1: struct { field2: u8 }, //~ ERROR anonymous structs are not allowed outside of unnamed struct or union fields + _: struct { field3: u8 }, } struct G { @@ -13,10 +11,8 @@ struct G { } union H { - field: struct { field: u8 }, //~ ERROR anonymous structs are not allowed outside of unnamed struct or union fields - //~^ ERROR anonymous structs are unimplemented - _: struct { field: u8 }, - //~^ ERROR anonymous structs are unimplemented + field1: struct { field2: u8 }, //~ ERROR anonymous structs are not allowed outside of unnamed struct or union fields + _: struct { field3: u8 }, } union I { @@ -27,7 +23,6 @@ enum K { M { _ : struct { field: u8 }, //~ ERROR anonymous structs are not allowed outside of unnamed struct or union fields //~^ ERROR unnamed fields are not allowed outside of structs or unions - //~| ERROR anonymous structs are unimplemented }, N { _ : u8, //~ ERROR unnamed fields are not allowed outside of structs or unions diff --git a/tests/ui/union/unnamed-fields/restrict_anonymous_structs.stderr b/tests/ui/union/unnamed-fields/restrict_anonymous_structs.stderr index fd731766c01..3b3890af771 100644 --- a/tests/ui/union/unnamed-fields/restrict_anonymous_structs.stderr +++ b/tests/ui/union/unnamed-fields/restrict_anonymous_structs.stderr @@ -1,29 +1,29 @@ error: anonymous structs are not allowed outside of unnamed struct or union fields - --> $DIR/restrict_anonymous_structs.rs:5:12 + --> $DIR/restrict_anonymous_structs.rs:5:13 | -LL | field: struct { field: u8 }, - | ^^^^^^^^^^^^^^^^^^^^ anonymous struct declared here +LL | field1: struct { field2: u8 }, + | ^^^^^^^^^^^^^^^^^^^^^ anonymous struct declared here error: unnamed fields can only have struct or union types - --> $DIR/restrict_anonymous_structs.rs:12:5 + --> $DIR/restrict_anonymous_structs.rs:10:5 | LL | _: (u8, u8), | ^ -------- not a struct or union error: anonymous structs are not allowed outside of unnamed struct or union fields - --> $DIR/restrict_anonymous_structs.rs:16:12 + --> $DIR/restrict_anonymous_structs.rs:14:13 | -LL | field: struct { field: u8 }, - | ^^^^^^^^^^^^^^^^^^^^ anonymous struct declared here +LL | field1: struct { field2: u8 }, + | ^^^^^^^^^^^^^^^^^^^^^ anonymous struct declared here error: unnamed fields can only have struct or union types - --> $DIR/restrict_anonymous_structs.rs:23:5 + --> $DIR/restrict_anonymous_structs.rs:19:5 | LL | _: (u8, u8), | ^ -------- not a struct or union error: unnamed fields are not allowed outside of structs or unions - --> $DIR/restrict_anonymous_structs.rs:28:9 + --> $DIR/restrict_anonymous_structs.rs:24:9 | LL | _ : struct { field: u8 }, | -^^^^^^^^^^^^^^^^^^^^^^^ @@ -31,48 +31,18 @@ LL | _ : struct { field: u8 }, | unnamed field declared here error: anonymous structs are not allowed outside of unnamed struct or union fields - --> $DIR/restrict_anonymous_structs.rs:28:13 + --> $DIR/restrict_anonymous_structs.rs:24:13 | LL | _ : struct { field: u8 }, | ^^^^^^^^^^^^^^^^^^^^ anonymous struct declared here error: unnamed fields are not allowed outside of structs or unions - --> $DIR/restrict_anonymous_structs.rs:33:9 + --> $DIR/restrict_anonymous_structs.rs:28:9 | LL | _ : u8, | -^^^^^ | | | unnamed field declared here -error: anonymous structs are unimplemented - --> $DIR/restrict_anonymous_structs.rs:5:12 - | -LL | field: struct { field: u8 }, - | ^^^^^^^^^^^^^^^^^^^^ - -error: anonymous structs are unimplemented - --> $DIR/restrict_anonymous_structs.rs:7:8 - | -LL | _: struct { field: u8 }, - | ^^^^^^^^^^^^^^^^^^^^ - -error: anonymous structs are unimplemented - --> $DIR/restrict_anonymous_structs.rs:16:12 - | -LL | field: struct { field: u8 }, - | ^^^^^^^^^^^^^^^^^^^^ - -error: anonymous structs are unimplemented - --> $DIR/restrict_anonymous_structs.rs:18:8 - | -LL | _: struct { field: u8 }, - | ^^^^^^^^^^^^^^^^^^^^ - -error: anonymous structs are unimplemented - --> $DIR/restrict_anonymous_structs.rs:28:13 - | -LL | _ : struct { field: u8 }, - | ^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 12 previous errors +error: aborting due to 7 previous errors diff --git a/tests/ui/union/unnamed-fields/restrict_anonymous_unions.rs b/tests/ui/union/unnamed-fields/restrict_anonymous_unions.rs index c69266089bb..9ffe71b28c2 100644 --- a/tests/ui/union/unnamed-fields/restrict_anonymous_unions.rs +++ b/tests/ui/union/unnamed-fields/restrict_anonymous_unions.rs @@ -2,10 +2,8 @@ #![feature(unnamed_fields)] struct F { - field: union { field: u8 }, //~ ERROR anonymous unions are not allowed outside of unnamed struct or union fields - //~^ ERROR anonymous unions are unimplemented - _: union { field: u8 }, - //~^ ERROR anonymous unions are unimplemented + field1: union { field2: u8 }, //~ ERROR anonymous unions are not allowed outside of unnamed struct or union fields + _: union { field3: u8 }, } struct G { @@ -13,10 +11,8 @@ struct G { } union H { - field: union { field: u8 }, //~ ERROR anonymous unions are not allowed outside of unnamed struct or union fields - //~^ ERROR anonymous unions are unimplemented - _: union { field: u8 }, - //~^ ERROR anonymous unions are unimplemented + field1: union { field2: u8 }, //~ ERROR anonymous unions are not allowed outside of unnamed struct or union fields + _: union { field3: u8 }, } union I { @@ -27,7 +23,6 @@ enum K { M { _ : union { field: u8 }, //~ ERROR anonymous unions are not allowed outside of unnamed struct or union fields //~^ ERROR unnamed fields are not allowed outside of structs or unions - //~| ERROR anonymous unions are unimplemented }, N { _ : u8, //~ ERROR unnamed fields are not allowed outside of structs or unions diff --git a/tests/ui/union/unnamed-fields/restrict_anonymous_unions.stderr b/tests/ui/union/unnamed-fields/restrict_anonymous_unions.stderr index c65cad775a9..f8679aad2d7 100644 --- a/tests/ui/union/unnamed-fields/restrict_anonymous_unions.stderr +++ b/tests/ui/union/unnamed-fields/restrict_anonymous_unions.stderr @@ -1,29 +1,29 @@ error: anonymous unions are not allowed outside of unnamed struct or union fields - --> $DIR/restrict_anonymous_unions.rs:5:12 + --> $DIR/restrict_anonymous_unions.rs:5:13 | -LL | field: union { field: u8 }, - | ^^^^^^^^^^^^^^^^^^^ anonymous union declared here +LL | field1: union { field2: u8 }, + | ^^^^^^^^^^^^^^^^^^^^ anonymous union declared here error: unnamed fields can only have struct or union types - --> $DIR/restrict_anonymous_unions.rs:12:5 + --> $DIR/restrict_anonymous_unions.rs:10:5 | LL | _: (u8, u8), | ^ -------- not a struct or union error: anonymous unions are not allowed outside of unnamed struct or union fields - --> $DIR/restrict_anonymous_unions.rs:16:12 + --> $DIR/restrict_anonymous_unions.rs:14:13 | -LL | field: union { field: u8 }, - | ^^^^^^^^^^^^^^^^^^^ anonymous union declared here +LL | field1: union { field2: u8 }, + | ^^^^^^^^^^^^^^^^^^^^ anonymous union declared here error: unnamed fields can only have struct or union types - --> $DIR/restrict_anonymous_unions.rs:23:5 + --> $DIR/restrict_anonymous_unions.rs:19:5 | LL | _: (u8, u8), | ^ -------- not a struct or union error: unnamed fields are not allowed outside of structs or unions - --> $DIR/restrict_anonymous_unions.rs:28:9 + --> $DIR/restrict_anonymous_unions.rs:24:9 | LL | _ : union { field: u8 }, | -^^^^^^^^^^^^^^^^^^^^^^ @@ -31,48 +31,18 @@ LL | _ : union { field: u8 }, | unnamed field declared here error: anonymous unions are not allowed outside of unnamed struct or union fields - --> $DIR/restrict_anonymous_unions.rs:28:13 + --> $DIR/restrict_anonymous_unions.rs:24:13 | LL | _ : union { field: u8 }, | ^^^^^^^^^^^^^^^^^^^ anonymous union declared here error: unnamed fields are not allowed outside of structs or unions - --> $DIR/restrict_anonymous_unions.rs:33:9 + --> $DIR/restrict_anonymous_unions.rs:28:9 | LL | _ : u8, | -^^^^^ | | | unnamed field declared here -error: anonymous unions are unimplemented - --> $DIR/restrict_anonymous_unions.rs:5:12 - | -LL | field: union { field: u8 }, - | ^^^^^^^^^^^^^^^^^^^ - -error: anonymous unions are unimplemented - --> $DIR/restrict_anonymous_unions.rs:7:8 - | -LL | _: union { field: u8 }, - | ^^^^^^^^^^^^^^^^^^^ - -error: anonymous unions are unimplemented - --> $DIR/restrict_anonymous_unions.rs:16:12 - | -LL | field: union { field: u8 }, - | ^^^^^^^^^^^^^^^^^^^ - -error: anonymous unions are unimplemented - --> $DIR/restrict_anonymous_unions.rs:18:8 - | -LL | _: union { field: u8 }, - | ^^^^^^^^^^^^^^^^^^^ - -error: anonymous unions are unimplemented - --> $DIR/restrict_anonymous_unions.rs:28:13 - | -LL | _ : union { field: u8 }, - | ^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 12 previous errors +error: aborting due to 7 previous errors diff --git a/tests/ui/wf/wf-unsafe-trait-obj-match.stderr b/tests/ui/wf/wf-unsafe-trait-obj-match.stderr index a0279774abe..3b53f55ffdc 100644 --- a/tests/ui/wf/wf-unsafe-trait-obj-match.stderr +++ b/tests/ui/wf/wf-unsafe-trait-obj-match.stderr @@ -30,8 +30,8 @@ LL | trait Trait: Sized {} | | | this trait cannot be made into an object... = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `Trait` for this new enum and using it instead: - S R + S = note: required for the cast from `&S` to `&dyn Trait` error[E0038]: the trait `Trait` cannot be made into an object @@ -52,8 +52,8 @@ LL | trait Trait: Sized {} | | | this trait cannot be made into an object... = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `Trait` for this new enum and using it instead: - S R + S = note: required for the cast from `&R` to `&dyn Trait` error: aborting due to 3 previous errors |
