diff options
| author | bors <bors@rust-lang.org> | 2023-11-02 06:25:50 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-11-02 06:25:50 +0000 |
| commit | 1a08886b782c25387c4c864597dd4a64a0ce98f9 (patch) | |
| tree | 9f784af107e7583dbe6d8962afab16cf1cb01513 /tests | |
| parent | de09bf55e3752dd2e87d74ba0ffc62718e0ef118 (diff) | |
| parent | 869827fd86c6c9a15793a690227ceaf6de2dc45e (diff) | |
| download | rust-1a08886b782c25387c4c864597dd4a64a0ce98f9.tar.gz rust-1a08886b782c25387c4c864597dd4a64a0ce98f9.zip | |
Auto merge of #3153 - rust-lang:rustup-2023-11-02, r=RalfJung
Automatic Rustup
Diffstat (limited to 'tests')
331 files changed, 7716 insertions, 3647 deletions
diff --git a/tests/assembly/closure-inherit-target-feature.rs b/tests/assembly/closure-inherit-target-feature.rs index 24802603452..7acda76e25f 100644 --- a/tests/assembly/closure-inherit-target-feature.rs +++ b/tests/assembly/closure-inherit-target-feature.rs @@ -1,4 +1,5 @@ // only-x86_64 +// ignore-sgx Tests incompatible with LVI mitigations // assembly-output: emit-asm // make sure the feature is not enabled at compile-time // compile-flags: -C opt-level=3 -C target-feature=-sse4.1 -C llvm-args=-x86-asm-syntax=intel diff --git a/tests/codegen/unchecked_shifts.rs b/tests/codegen/unchecked_shifts.rs index d5f53bedd54..aca9bec77df 100644 --- a/tests/codegen/unchecked_shifts.rs +++ b/tests/codegen/unchecked_shifts.rs @@ -2,7 +2,7 @@ // ignore-debug (because unchecked is checked in debug) #![crate_type = "lib"] -#![feature(unchecked_math)] +#![feature(unchecked_shifts)] // CHECK-LABEL: @unchecked_shl_unsigned_same #[no_mangle] diff --git a/tests/coverage-map/fn_sig_into_try.cov-map b/tests/coverage-map/fn_sig_into_try.cov-map index 4672e7c1ce9..6e26c61aac9 100644 --- a/tests/coverage-map/fn_sig_into_try.cov-map +++ b/tests/coverage-map/fn_sig_into_try.cov-map @@ -7,47 +7,47 @@ Number of file 0 mappings: 1 - Code(Counter(0)) at (prev + 10, 1) to (start + 4, 2) Function name: fn_sig_into_try::b -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 10, 01, 02, 0f, 00, 02, 0f, 00, 10, 02, 01, 05, 00, 0c, 07, 01, 01, 00, 02] +Raw bytes (28): 0x[01, 01, 02, 01, 00, 00, 02, 04, 01, 10, 01, 02, 0f, 00, 02, 0f, 00, 10, 02, 01, 05, 00, 0c, 07, 01, 01, 00, 02] 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) +- expression 0 operands: lhs = Counter(0), rhs = Zero +- expression 1 operands: lhs = Zero, rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 16, 1) to (start + 2, 15) - Code(Zero) at (prev + 2, 15) to (start + 0, 16) - Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 0, 12) - = (c0 - c1) + = (c0 - Zero) - Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2) - = (c1 + (c0 - c1)) + = (Zero + (c0 - Zero)) Function name: fn_sig_into_try::c -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 16, 01, 02, 17, 00, 02, 17, 00, 18, 02, 01, 05, 00, 0c, 07, 01, 01, 00, 02] +Raw bytes (28): 0x[01, 01, 02, 01, 00, 00, 02, 04, 01, 16, 01, 02, 17, 00, 02, 17, 00, 18, 02, 01, 05, 00, 0c, 07, 01, 01, 00, 02] 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) +- expression 0 operands: lhs = Counter(0), rhs = Zero +- expression 1 operands: lhs = Zero, rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 22, 1) to (start + 2, 23) - Code(Zero) at (prev + 2, 23) to (start + 0, 24) - Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 0, 12) - = (c0 - c1) + = (c0 - Zero) - Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2) - = (c1 + (c0 - c1)) + = (Zero + (c0 - Zero)) Function name: fn_sig_into_try::d -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 1c, 01, 03, 0f, 00, 03, 0f, 00, 10, 02, 01, 05, 00, 0c, 07, 01, 01, 00, 02] +Raw bytes (28): 0x[01, 01, 02, 01, 00, 00, 02, 04, 01, 1c, 01, 03, 0f, 00, 03, 0f, 00, 10, 02, 01, 05, 00, 0c, 07, 01, 01, 00, 02] 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) +- expression 0 operands: lhs = Counter(0), rhs = Zero +- expression 1 operands: lhs = Zero, rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 28, 1) to (start + 3, 15) - Code(Zero) at (prev + 3, 15) to (start + 0, 16) - Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 0, 12) - = (c0 - c1) + = (c0 - Zero) - Code(Expression(1, Add)) at (prev + 1, 1) to (start + 0, 2) - = (c1 + (c0 - c1)) + = (Zero + (c0 - Zero)) diff --git a/tests/coverage-map/status-quo/bad_counter_ids.cov-map b/tests/coverage-map/status-quo/bad_counter_ids.cov-map new file mode 100644 index 00000000000..0b8081acfa6 --- /dev/null +++ b/tests/coverage-map/status-quo/bad_counter_ids.cov-map @@ -0,0 +1,98 @@ +Function name: <bad_counter_ids::Foo as core::cmp::PartialEq>::eq +Raw bytes (9): 0x[01, 01, 00, 01, 01, 0c, 11, 00, 1a] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 12, 17) to (start + 0, 26) + +Function name: <bad_counter_ids::Foo as core::fmt::Debug>::fmt +Raw bytes (9): 0x[01, 01, 00, 01, 01, 0c, 0a, 00, 0f] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 1 +- Code(Counter(0)) at (prev + 12, 10) to (start + 0, 15) + +Function name: bad_counter_ids::eq_bad +Raw bytes (14): 0x[01, 01, 00, 02, 01, 23, 01, 02, 1f, 00, 03, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 2 +- Code(Counter(0)) at (prev + 35, 1) to (start + 2, 31) +- Code(Zero) at (prev + 3, 1) to (start + 0, 2) + +Function name: bad_counter_ids::eq_bad_message +Raw bytes (21): 0x[01, 01, 01, 01, 00, 03, 01, 28, 01, 02, 0f, 02, 02, 20, 00, 2b, 00, 01, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 1 +- expression 0 operands: lhs = Counter(0), rhs = Zero +Number of file 0 mappings: 3 +- Code(Counter(0)) at (prev + 40, 1) to (start + 2, 15) +- Code(Expression(0, Sub)) at (prev + 2, 32) to (start + 0, 43) + = (c0 - Zero) +- Code(Zero) at (prev + 1, 1) to (start + 0, 2) + +Function name: bad_counter_ids::eq_good +Raw bytes (14): 0x[01, 01, 00, 02, 01, 0f, 01, 02, 1f, 05, 03, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 2 +- Code(Counter(0)) at (prev + 15, 1) to (start + 2, 31) +- Code(Counter(1)) at (prev + 3, 1) to (start + 0, 2) + +Function name: bad_counter_ids::eq_good_message +Raw bytes (19): 0x[01, 01, 00, 03, 01, 14, 01, 02, 0f, 00, 02, 20, 00, 2b, 05, 01, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 3 +- Code(Counter(0)) at (prev + 20, 1) to (start + 2, 15) +- Code(Zero) at (prev + 2, 32) to (start + 0, 43) +- Code(Counter(1)) at (prev + 1, 1) to (start + 0, 2) + +Function name: bad_counter_ids::ne_bad +Raw bytes (14): 0x[01, 01, 00, 02, 01, 2d, 01, 02, 1f, 00, 03, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 2 +- Code(Counter(0)) at (prev + 45, 1) to (start + 2, 31) +- Code(Zero) at (prev + 3, 1) to (start + 0, 2) + +Function name: bad_counter_ids::ne_bad_message +Raw bytes (19): 0x[01, 01, 00, 03, 01, 32, 01, 02, 0f, 05, 02, 20, 00, 2b, 00, 01, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 0 +Number of file 0 mappings: 3 +- Code(Counter(0)) at (prev + 50, 1) to (start + 2, 15) +- Code(Counter(1)) at (prev + 2, 32) to (start + 0, 43) +- Code(Zero) at (prev + 1, 1) to (start + 0, 2) + +Function name: bad_counter_ids::ne_good +Raw bytes (16): 0x[01, 01, 01, 01, 00, 02, 01, 19, 01, 02, 1f, 02, 03, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 1 +- expression 0 operands: lhs = Counter(0), rhs = Zero +Number of file 0 mappings: 2 +- Code(Counter(0)) at (prev + 25, 1) to (start + 2, 31) +- Code(Expression(0, Sub)) at (prev + 3, 1) to (start + 0, 2) + = (c0 - Zero) + +Function name: bad_counter_ids::ne_good_message +Raw bytes (21): 0x[01, 01, 01, 01, 00, 03, 01, 1e, 01, 02, 0f, 00, 02, 20, 00, 2b, 02, 01, 01, 00, 02] +Number of files: 1 +- file 0 => global file 1 +Number of expressions: 1 +- expression 0 operands: lhs = Counter(0), rhs = Zero +Number of file 0 mappings: 3 +- Code(Counter(0)) at (prev + 30, 1) to (start + 2, 15) +- Code(Zero) at (prev + 2, 32) to (start + 0, 43) +- Code(Expression(0, Sub)) at (prev + 1, 1) to (start + 0, 2) + = (c0 - Zero) + diff --git a/tests/coverage-map/status-quo/bad_counter_ids.rs b/tests/coverage-map/status-quo/bad_counter_ids.rs new file mode 100644 index 00000000000..ef5460102b7 --- /dev/null +++ b/tests/coverage-map/status-quo/bad_counter_ids.rs @@ -0,0 +1,66 @@ +#![feature(coverage_attribute)] +// compile-flags: --edition=2021 -Copt-level=0 -Zmir-opt-level=3 + +// Regression test for <https://github.com/rust-lang/rust/issues/117012>. +// +// If some coverage counters were removed by MIR optimizations, we need to take +// care not to refer to those counter IDs in coverage mappings, and instead +// replace them with a constant zero value. If we don't, `llvm-cov` might see +// a too-large counter ID and silently discard the entire function from its +// coverage reports. + +#[derive(Debug, PartialEq, Eq)] +struct Foo(u32); + +fn eq_good() { + println!("a"); + assert_eq!(Foo(1), Foo(1)); +} + +fn eq_good_message() { + println!("b"); + assert_eq!(Foo(1), Foo(1), "message b"); +} + +fn ne_good() { + println!("c"); + assert_ne!(Foo(1), Foo(3)); +} + +fn ne_good_message() { + println!("d"); + assert_ne!(Foo(1), Foo(3), "message d"); +} + +fn eq_bad() { + println!("e"); + assert_eq!(Foo(1), Foo(3)); +} + +fn eq_bad_message() { + println!("f"); + assert_eq!(Foo(1), Foo(3), "message f"); +} + +fn ne_bad() { + println!("g"); + assert_ne!(Foo(1), Foo(1)); +} + +fn ne_bad_message() { + println!("h"); + assert_ne!(Foo(1), Foo(1), "message h"); +} + +#[coverage(off)] +fn main() { + eq_good(); + eq_good_message(); + ne_good(); + ne_good_message(); + + assert!(std::panic::catch_unwind(eq_bad).is_err()); + assert!(std::panic::catch_unwind(eq_bad_message).is_err()); + assert!(std::panic::catch_unwind(ne_bad).is_err()); + assert!(std::panic::catch_unwind(ne_bad_message).is_err()); +} diff --git a/tests/coverage-map/status-quo/inline-dead.cov-map b/tests/coverage-map/status-quo/inline-dead.cov-map index 06b64da5723..958b423f24c 100644 --- a/tests/coverage-map/status-quo/inline-dead.cov-map +++ b/tests/coverage-map/status-quo/inline-dead.cov-map @@ -7,19 +7,19 @@ Number of file 0 mappings: 1 - Code(Zero) at (prev + 25, 1) to (start + 2, 2) Function name: inline_dead::live::<false> -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 10, 01, 01, 09, 00, 02, 09, 00, 0f, 02, 02, 09, 00, 0a, 07, 02, 01, 00, 02] +Raw bytes (28): 0x[01, 01, 02, 01, 00, 00, 02, 04, 01, 10, 01, 01, 09, 00, 02, 09, 00, 0f, 02, 02, 09, 00, 0a, 07, 02, 01, 00, 02] 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) +- expression 0 operands: lhs = Counter(0), rhs = Zero +- expression 1 operands: lhs = Zero, rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 16, 1) to (start + 1, 9) - Code(Zero) at (prev + 2, 9) to (start + 0, 15) - Code(Expression(0, Sub)) at (prev + 2, 9) to (start + 0, 10) - = (c0 - c1) + = (c0 - Zero) - Code(Expression(1, Add)) at (prev + 2, 1) to (start + 0, 2) - = (c1 + (c0 - c1)) + = (Zero + (c0 - Zero)) Function name: inline_dead::main Raw bytes (14): 0x[01, 01, 00, 02, 01, 04, 01, 03, 0d, 01, 07, 06, 02, 02] @@ -31,15 +31,15 @@ Number of file 0 mappings: 2 - Code(Counter(0)) at (prev + 7, 6) to (start + 2, 2) Function name: inline_dead::main::{closure#0} -Raw bytes (23): 0x[01, 01, 02, 09, 06, 01, 05, 03, 01, 07, 17, 00, 18, 00, 02, 0d, 00, 0e, 03, 02, 05, 00, 06] +Raw bytes (23): 0x[01, 01, 02, 00, 06, 01, 00, 03, 01, 07, 17, 00, 18, 00, 02, 0d, 00, 0e, 03, 02, 05, 00, 06] Number of files: 1 - file 0 => global file 1 Number of expressions: 2 -- expression 0 operands: lhs = Counter(2), rhs = Expression(1, Sub) -- expression 1 operands: lhs = Counter(0), rhs = Counter(1) +- expression 0 operands: lhs = Zero, rhs = Expression(1, Sub) +- expression 1 operands: lhs = Counter(0), rhs = Zero Number of file 0 mappings: 3 - Code(Counter(0)) at (prev + 7, 23) to (start + 0, 24) - Code(Zero) at (prev + 2, 13) to (start + 0, 14) - Code(Expression(0, Add)) at (prev + 2, 5) to (start + 0, 6) - = (c2 + (c0 - c1)) + = (Zero + (c0 - Zero)) diff --git a/tests/coverage-map/status-quo/issue-84561.cov-map b/tests/coverage-map/status-quo/issue-84561.cov-map index 76340b1a78c..82582b309bf 100644 --- a/tests/coverage-map/status-quo/issue-84561.cov-map +++ b/tests/coverage-map/status-quo/issue-84561.cov-map @@ -85,47 +85,47 @@ Number of file 0 mappings: 1 - Code(Counter(0)) at (prev + 165, 9) to (start + 2, 10) Function name: issue_84561::test3 -Raw bytes (437): 0x[01, 01, 41, 05, 09, 0d, 11, 15, 19, 12, 1d, 15, 19, 21, 25, 1e, 29, 21, 25, 31, 39, 3d, 41, 2e, 45, 3d, 41, 42, 49, 45, 4d, 3f, 51, 42, 49, 45, 4d, 5d, 8a, 01, 8f, 01, 5d, 92, 01, 55, 51, 59, 92, 01, 55, 51, 59, 8f, 01, 5d, 92, 01, 55, 51, 59, 87, 01, 61, 5d, 8a, 01, 8f, 01, 5d, 92, 01, 55, 51, 59, 82, 01, 65, 87, 01, 61, 5d, 8a, 01, 8f, 01, 5d, 92, 01, 55, 51, 59, 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, 81, 01, f3, 01, 7d, 75, f6, 01, fb, 01, 79, 71, fe, 01, 82, 02, 71, 69, 6d, 33, 01, 06, 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, 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, 06, 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] Number of files: 1 - file 0 => global file 1 Number of expressions: 65 - expression 0 operands: lhs = Counter(1), rhs = Counter(2) -- expression 1 operands: lhs = Counter(3), rhs = Counter(4) +- expression 1 operands: lhs = Counter(3), rhs = Zero - expression 2 operands: lhs = Counter(5), rhs = Counter(6) -- expression 3 operands: lhs = Expression(4, Sub), rhs = Counter(7) +- expression 3 operands: lhs = Expression(4, Sub), rhs = Zero - expression 4 operands: lhs = Counter(5), rhs = Counter(6) -- expression 5 operands: lhs = Counter(8), rhs = Counter(9) -- expression 6 operands: lhs = Expression(7, Sub), rhs = Counter(10) -- expression 7 operands: lhs = Counter(8), rhs = Counter(9) -- expression 8 operands: lhs = Counter(12), rhs = Counter(14) +- expression 5 operands: lhs = Counter(8), rhs = Zero +- expression 6 operands: lhs = Expression(7, Sub), rhs = Zero +- expression 7 operands: lhs = Counter(8), rhs = Zero +- expression 8 operands: lhs = Counter(12), rhs = Zero - expression 9 operands: lhs = Counter(15), rhs = Counter(16) - expression 10 operands: lhs = Expression(11, Sub), rhs = Counter(17) - expression 11 operands: lhs = Counter(15), rhs = Counter(16) - expression 12 operands: lhs = Expression(16, Sub), rhs = Counter(18) -- expression 13 operands: lhs = Counter(17), rhs = Counter(19) +- expression 13 operands: lhs = Counter(17), rhs = Zero - expression 14 operands: lhs = Expression(15, Add), rhs = Counter(20) - expression 15 operands: lhs = Expression(16, Sub), rhs = Counter(18) -- expression 16 operands: lhs = Counter(17), rhs = Counter(19) +- expression 16 operands: lhs = Counter(17), rhs = Zero - expression 17 operands: lhs = Counter(23), rhs = Expression(34, Sub) - expression 18 operands: lhs = Expression(35, Add), rhs = Counter(23) - expression 19 operands: lhs = Expression(36, Sub), rhs = Counter(21) -- expression 20 operands: lhs = Counter(20), rhs = Counter(22) +- expression 20 operands: lhs = Counter(20), rhs = Zero - expression 21 operands: lhs = Expression(36, Sub), rhs = Counter(21) -- expression 22 operands: lhs = Counter(20), rhs = Counter(22) +- expression 22 operands: lhs = Counter(20), rhs = Zero - expression 23 operands: lhs = Expression(35, Add), rhs = Counter(23) - expression 24 operands: lhs = Expression(36, Sub), rhs = Counter(21) -- expression 25 operands: lhs = Counter(20), rhs = Counter(22) +- expression 25 operands: lhs = Counter(20), rhs = Zero - expression 26 operands: lhs = Expression(33, Add), rhs = Counter(24) - expression 27 operands: lhs = Counter(23), rhs = Expression(34, Sub) - expression 28 operands: lhs = Expression(35, Add), rhs = Counter(23) - expression 29 operands: lhs = Expression(36, Sub), rhs = Counter(21) -- expression 30 operands: lhs = Counter(20), rhs = Counter(22) +- expression 30 operands: lhs = Counter(20), rhs = Zero - expression 31 operands: lhs = Expression(32, Sub), rhs = Counter(25) - expression 32 operands: lhs = Expression(33, Add), rhs = Counter(24) - expression 33 operands: lhs = Counter(23), rhs = Expression(34, Sub) - expression 34 operands: lhs = Expression(35, Add), rhs = Counter(23) - expression 35 operands: lhs = Expression(36, Sub), rhs = Counter(21) -- expression 36 operands: lhs = Counter(20), rhs = Counter(22) +- 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) @@ -147,7 +147,7 @@ Number of expressions: 65 - expression 55 operands: lhs = Counter(28), rhs = Expression(63, Sub) - expression 56 operands: lhs = Expression(64, Sub), rhs = Counter(28) - expression 57 operands: lhs = Counter(26), rhs = Counter(27) -- expression 58 operands: lhs = Expression(59, Sub), rhs = Counter(32) +- 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) @@ -161,27 +161,27 @@ Number of file 0 mappings: 51 = (c1 - c2) - Code(Counter(3)) at (prev + 5, 5) to (start + 0, 31) - Code(Expression(1, Sub)) at (prev + 1, 5) to (start + 0, 31) - = (c3 - c4) + = (c3 - Zero) - Code(Counter(5)) at (prev + 1, 9) to (start + 1, 28) - Code(Expression(4, Sub)) at (prev + 2, 5) to (start + 0, 31) = (c5 - c6) - Code(Expression(3, Sub)) at (prev + 1, 5) to (start + 0, 15) - = ((c5 - c6) - c7) + = ((c5 - c6) - Zero) - Code(Zero) at (prev + 0, 32) to (start + 0, 48) - Code(Counter(8)) at (prev + 1, 5) to (start + 3, 15) - Code(Zero) at (prev + 3, 32) to (start + 0, 48) - Code(Zero) at (prev + 0, 51) to (start + 0, 65) - Code(Zero) at (prev + 0, 75) to (start + 0, 90) - Code(Expression(7, Sub)) at (prev + 1, 5) to (start + 0, 15) - = (c8 - c9) + = (c8 - Zero) - Code(Zero) at (prev + 5, 9) to (start + 3, 16) - Code(Zero) at (prev + 5, 13) to (start + 0, 27) - Code(Zero) at (prev + 2, 13) to (start + 0, 28) - Code(Expression(6, Sub)) at (prev + 4, 9) to (start + 5, 6) - = ((c8 - c9) - c10) + = ((c8 - Zero) - Zero) - Code(Counter(12)) at (prev + 6, 5) to (start + 3, 6) - Code(Expression(8, Sub)) at (prev + 4, 5) to (start + 3, 6) - = (c12 - c14) + = (c12 - Zero) - Code(Counter(15)) at (prev + 4, 9) to (start + 4, 6) - Code(Expression(11, Sub)) at (prev + 5, 8) to (start + 0, 15) = (c15 - c16) @@ -189,24 +189,24 @@ Number of file 0 mappings: 51 - Code(Expression(10, Sub)) at (prev + 5, 9) to (start + 3, 10) = ((c15 - c16) - c17) - Code(Expression(15, Add)) at (prev + 5, 8) to (start + 0, 15) - = ((c17 - c19) + c18) + = ((c17 - Zero) + c18) - Code(Counter(20)) at (prev + 1, 9) to (start + 0, 19) - Code(Zero) at (prev + 3, 13) to (start + 0, 29) - Code(Expression(14, Sub)) at (prev + 3, 9) to (start + 0, 19) - = (((c17 - c19) + c18) - c20) + = (((c17 - Zero) + c18) - c20) - Code(Zero) at (prev + 3, 13) to (start + 0, 29) - Code(Expression(33, Add)) at (prev + 3, 5) to (start + 0, 15) - = (c23 + (((c20 - c22) + c21) - c23)) + = (c23 + (((c20 - Zero) + c21) - c23)) - Code(Expression(35, Add)) at (prev + 1, 12) to (start + 0, 19) - = ((c20 - c22) + c21) + = ((c20 - Zero) + c21) - Code(Counter(23)) at (prev + 1, 13) to (start + 0, 19) - Code(Expression(34, Sub)) at (prev + 2, 13) to (start + 0, 19) - = (((c20 - c22) + c21) - c23) + = (((c20 - Zero) + c21) - c23) - Code(Expression(32, Sub)) at (prev + 4, 5) to (start + 2, 19) - = ((c23 + (((c20 - c22) + c21) - c23)) - c24) + = ((c23 + (((c20 - Zero) + c21) - c23)) - c24) - Code(Counter(25)) at (prev + 3, 13) to (start + 0, 19) - Code(Expression(31, Sub)) at (prev + 2, 13) to (start + 0, 19) - = (((c23 + (((c20 - c22) + c21) - c23)) - c24) - c25) + = (((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)) - Code(Counter(26)) at (prev + 1, 12) to (start + 0, 19) @@ -225,7 +225,7 @@ Number of file 0 mappings: 51 - Code(Expression(59, Sub)) at (prev + 2, 5) to (start + 0, 15) = ((c29 + ((c28 + ((c26 - c27) - c28)) - c30)) - c31) - Code(Expression(58, Sub)) at (prev + 3, 9) to (start + 0, 34) - = (((c29 + ((c28 + ((c26 - c27) - c28)) - c30)) - c31) - c32) + = (((c29 + ((c28 + ((c26 - c27) - c28)) - 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-map/status-quo/loops_branches.cov-map b/tests/coverage-map/status-quo/loops_branches.cov-map index ebace8cbd71..813583a9de7 100644 --- a/tests/coverage-map/status-quo/loops_branches.cov-map +++ b/tests/coverage-map/status-quo/loops_branches.cov-map @@ -1,177 +1,177 @@ Function name: <loops_branches::DebugTest as core::fmt::Debug>::fmt -Raw bytes (249): 0x[01, 01, 31, 05, 09, 00, 02, bb, 01, 19, bf, 01, c3, 01, 0d, 00, 11, 15, bf, 01, c3, 01, 0d, 00, 11, 15, bb, 01, 19, bf, 01, c3, 01, 0d, 00, 11, 15, b6, 01, 15, bb, 01, 19, bf, 01, c3, 01, 0d, 00, 11, 15, b2, 01, 1d, b6, 01, 15, bb, 01, 19, bf, 01, c3, 01, 0d, 00, 11, 15, 00, ae, 01, b2, 01, 1d, b6, 01, 15, bb, 01, 19, bf, 01, c3, 01, 0d, 00, 11, 15, ab, 01, 11, 00, ae, 01, b2, 01, 1d, b6, 01, 15, bb, 01, 19, bf, 01, c3, 01, 0d, 00, 11, 15, 25, a3, 01, a6, 01, 19, ab, 01, 11, 00, ae, 01, b2, 01, 1d, b6, 01, 15, bb, 01, 19, bf, 01, c3, 01, 0d, 00, 11, 15, 14, 01, 09, 05, 01, 10, 05, 02, 10, 00, 15, 00, 01, 17, 00, 1b, 00, 00, 1c, 00, 1e, 02, 01, 0e, 00, 0f, 07, 01, 0d, 00, 1e, 25, 00, 1e, 00, 1f, 00, 01, 10, 01, 0a, b6, 01, 03, 0d, 00, 0e, bb, 01, 00, 12, 00, 17, b6, 01, 01, 10, 00, 14, b2, 01, 01, 14, 00, 19, 00, 01, 1b, 00, 1f, 00, 00, 20, 00, 22, ae, 01, 01, 12, 00, 13, ab, 01, 01, 11, 00, 22, a6, 01, 00, 22, 00, 23, 00, 01, 14, 01, 0e, 19, 03, 09, 00, 0f, 9f, 01, 01, 05, 00, 06] +Raw bytes (249): 0x[01, 01, 31, 05, 00, 00, 02, bb, 01, 19, bf, 01, c3, 01, 0d, 00, 11, 00, bf, 01, c3, 01, 0d, 00, 11, 00, bb, 01, 19, bf, 01, c3, 01, 0d, 00, 11, 00, b6, 01, 00, bb, 01, 19, bf, 01, c3, 01, 0d, 00, 11, 00, b2, 01, 00, b6, 01, 00, bb, 01, 19, bf, 01, c3, 01, 0d, 00, 11, 00, 00, ae, 01, b2, 01, 00, b6, 01, 00, bb, 01, 19, bf, 01, c3, 01, 0d, 00, 11, 00, ab, 01, 11, 00, ae, 01, b2, 01, 00, b6, 01, 00, bb, 01, 19, bf, 01, c3, 01, 0d, 00, 11, 00, 25, a3, 01, a6, 01, 19, ab, 01, 11, 00, ae, 01, b2, 01, 00, b6, 01, 00, bb, 01, 19, bf, 01, c3, 01, 0d, 00, 11, 00, 14, 01, 09, 05, 01, 10, 05, 02, 10, 00, 15, 00, 01, 17, 00, 1b, 00, 00, 1c, 00, 1e, 02, 01, 0e, 00, 0f, 07, 01, 0d, 00, 1e, 25, 00, 1e, 00, 1f, 00, 01, 10, 01, 0a, b6, 01, 03, 0d, 00, 0e, bb, 01, 00, 12, 00, 17, b6, 01, 01, 10, 00, 14, b2, 01, 01, 14, 00, 19, 00, 01, 1b, 00, 1f, 00, 00, 20, 00, 22, ae, 01, 01, 12, 00, 13, ab, 01, 01, 11, 00, 22, a6, 01, 00, 22, 00, 23, 00, 01, 14, 01, 0e, 19, 03, 09, 00, 0f, 9f, 01, 01, 05, 00, 06] Number of files: 1 - file 0 => global file 1 Number of expressions: 49 -- expression 0 operands: lhs = Counter(1), rhs = Counter(2) +- expression 0 operands: lhs = Counter(1), rhs = Zero - expression 1 operands: lhs = Zero, rhs = Expression(0, Sub) - expression 2 operands: lhs = Expression(46, Add), rhs = Counter(6) - expression 3 operands: lhs = Expression(47, Add), rhs = Expression(48, Add) - expression 4 operands: lhs = Counter(3), rhs = Zero -- expression 5 operands: lhs = Counter(4), rhs = Counter(5) +- expression 5 operands: lhs = Counter(4), rhs = Zero - expression 6 operands: lhs = Expression(47, Add), rhs = Expression(48, Add) - expression 7 operands: lhs = Counter(3), rhs = Zero -- expression 8 operands: lhs = Counter(4), rhs = Counter(5) +- expression 8 operands: lhs = Counter(4), rhs = Zero - expression 9 operands: lhs = Expression(46, Add), rhs = Counter(6) - expression 10 operands: lhs = Expression(47, Add), rhs = Expression(48, Add) - expression 11 operands: lhs = Counter(3), rhs = Zero -- expression 12 operands: lhs = Counter(4), rhs = Counter(5) -- expression 13 operands: lhs = Expression(45, Sub), rhs = Counter(5) +- expression 12 operands: lhs = Counter(4), rhs = Zero +- expression 13 operands: lhs = Expression(45, Sub), rhs = Zero - expression 14 operands: lhs = Expression(46, Add), rhs = Counter(6) - expression 15 operands: lhs = Expression(47, Add), rhs = Expression(48, Add) - expression 16 operands: lhs = Counter(3), rhs = Zero -- expression 17 operands: lhs = Counter(4), rhs = Counter(5) -- expression 18 operands: lhs = Expression(44, Sub), rhs = Counter(7) -- expression 19 operands: lhs = Expression(45, Sub), rhs = Counter(5) +- expression 17 operands: lhs = Counter(4), rhs = Zero +- expression 18 operands: lhs = Expression(44, Sub), rhs = Zero +- expression 19 operands: lhs = Expression(45, Sub), rhs = Zero - expression 20 operands: lhs = Expression(46, Add), rhs = Counter(6) - expression 21 operands: lhs = Expression(47, Add), rhs = Expression(48, Add) - expression 22 operands: lhs = Counter(3), rhs = Zero -- expression 23 operands: lhs = Counter(4), rhs = Counter(5) +- expression 23 operands: lhs = Counter(4), rhs = Zero - expression 24 operands: lhs = Zero, rhs = Expression(43, Sub) -- expression 25 operands: lhs = Expression(44, Sub), rhs = Counter(7) -- expression 26 operands: lhs = Expression(45, Sub), rhs = Counter(5) +- expression 25 operands: lhs = Expression(44, Sub), rhs = Zero +- expression 26 operands: lhs = Expression(45, Sub), rhs = Zero - expression 27 operands: lhs = Expression(46, Add), rhs = Counter(6) - expression 28 operands: lhs = Expression(47, Add), rhs = Expression(48, Add) - expression 29 operands: lhs = Counter(3), rhs = Zero -- expression 30 operands: lhs = Counter(4), rhs = Counter(5) +- expression 30 operands: lhs = Counter(4), rhs = Zero - expression 31 operands: lhs = Expression(42, Add), rhs = Counter(4) - expression 32 operands: lhs = Zero, rhs = Expression(43, Sub) -- expression 33 operands: lhs = Expression(44, Sub), rhs = Counter(7) -- expression 34 operands: lhs = Expression(45, Sub), rhs = Counter(5) +- expression 33 operands: lhs = Expression(44, Sub), rhs = Zero +- expression 34 operands: lhs = Expression(45, Sub), rhs = Zero - expression 35 operands: lhs = Expression(46, Add), rhs = Counter(6) - expression 36 operands: lhs = Expression(47, Add), rhs = Expression(48, Add) - expression 37 operands: lhs = Counter(3), rhs = Zero -- expression 38 operands: lhs = Counter(4), rhs = Counter(5) +- expression 38 operands: lhs = Counter(4), rhs = Zero - expression 39 operands: lhs = Counter(9), rhs = Expression(40, Add) - expression 40 operands: lhs = Expression(41, Sub), rhs = Counter(6) - expression 41 operands: lhs = Expression(42, Add), rhs = Counter(4) - expression 42 operands: lhs = Zero, rhs = Expression(43, Sub) -- expression 43 operands: lhs = Expression(44, Sub), rhs = Counter(7) -- expression 44 operands: lhs = Expression(45, Sub), rhs = Counter(5) +- expression 43 operands: lhs = Expression(44, Sub), rhs = Zero +- expression 44 operands: lhs = Expression(45, Sub), rhs = Zero - expression 45 operands: lhs = Expression(46, Add), rhs = Counter(6) - expression 46 operands: lhs = Expression(47, Add), rhs = Expression(48, Add) - expression 47 operands: lhs = Counter(3), rhs = Zero -- expression 48 operands: lhs = Counter(4), rhs = Counter(5) +- expression 48 operands: lhs = Counter(4), rhs = Zero Number of file 0 mappings: 20 - Code(Counter(0)) at (prev + 9, 5) to (start + 1, 16) - Code(Counter(1)) at (prev + 2, 16) to (start + 0, 21) - Code(Zero) at (prev + 1, 23) to (start + 0, 27) - Code(Zero) at (prev + 0, 28) to (start + 0, 30) - Code(Expression(0, Sub)) at (prev + 1, 14) to (start + 0, 15) - = (c1 - c2) + = (c1 - Zero) - Code(Expression(1, Add)) at (prev + 1, 13) to (start + 0, 30) - = (Zero + (c1 - c2)) + = (Zero + (c1 - Zero)) - Code(Counter(9)) at (prev + 0, 30) to (start + 0, 31) - Code(Zero) at (prev + 1, 16) to (start + 1, 10) - Code(Expression(45, Sub)) at (prev + 3, 13) to (start + 0, 14) - = (((c3 + Zero) + (c4 + c5)) - c6) + = (((c3 + Zero) + (c4 + Zero)) - c6) - Code(Expression(46, Add)) at (prev + 0, 18) to (start + 0, 23) - = ((c3 + Zero) + (c4 + c5)) + = ((c3 + Zero) + (c4 + Zero)) - Code(Expression(45, Sub)) at (prev + 1, 16) to (start + 0, 20) - = (((c3 + Zero) + (c4 + c5)) - c6) + = (((c3 + Zero) + (c4 + Zero)) - c6) - Code(Expression(44, Sub)) at (prev + 1, 20) to (start + 0, 25) - = ((((c3 + Zero) + (c4 + c5)) - c6) - c5) + = ((((c3 + Zero) + (c4 + Zero)) - c6) - Zero) - Code(Zero) at (prev + 1, 27) to (start + 0, 31) - Code(Zero) at (prev + 0, 32) to (start + 0, 34) - Code(Expression(43, Sub)) at (prev + 1, 18) to (start + 0, 19) - = (((((c3 + Zero) + (c4 + c5)) - c6) - c5) - c7) + = (((((c3 + Zero) + (c4 + Zero)) - c6) - Zero) - Zero) - Code(Expression(42, Add)) at (prev + 1, 17) to (start + 0, 34) - = (Zero + (((((c3 + Zero) + (c4 + c5)) - c6) - c5) - c7)) + = (Zero + (((((c3 + Zero) + (c4 + Zero)) - c6) - Zero) - Zero)) - Code(Expression(41, Sub)) at (prev + 0, 34) to (start + 0, 35) - = ((Zero + (((((c3 + Zero) + (c4 + c5)) - c6) - c5) - c7)) - c4) + = ((Zero + (((((c3 + Zero) + (c4 + Zero)) - c6) - Zero) - Zero)) - c4) - Code(Zero) at (prev + 1, 20) to (start + 1, 14) - Code(Counter(6)) at (prev + 3, 9) to (start + 0, 15) - Code(Expression(39, Add)) at (prev + 1, 5) to (start + 0, 6) - = (c9 + (((Zero + (((((c3 + Zero) + (c4 + c5)) - c6) - c5) - c7)) - c4) + c6)) + = (c9 + (((Zero + (((((c3 + Zero) + (c4 + Zero)) - c6) - Zero) - Zero)) - c4) + c6)) Function name: <loops_branches::DisplayTest as core::fmt::Display>::fmt -Raw bytes (253): 0x[01, 01, 33, 01, 05, 02, 09, 00, 0e, 02, 09, bf, 01, 19, c3, 01, c7, 01, 05, 0d, 11, 15, c3, 01, c7, 01, 05, 0d, 11, 15, bf, 01, 19, c3, 01, c7, 01, 05, 0d, 11, 15, ba, 01, 11, bf, 01, 19, c3, 01, c7, 01, 05, 0d, 11, 15, b6, 01, 1d, ba, 01, 11, bf, 01, 19, c3, 01, c7, 01, 05, 0d, 11, 15, 00, b2, 01, b6, 01, 1d, ba, 01, 11, bf, 01, 19, c3, 01, c7, 01, 05, 0d, 11, 15, af, 01, 15, 00, b2, 01, b6, 01, 1d, ba, 01, 11, bf, 01, 19, c3, 01, c7, 01, 05, 0d, 11, 15, aa, 01, cb, 01, af, 01, 15, 00, b2, 01, b6, 01, 1d, ba, 01, 11, bf, 01, 19, c3, 01, c7, 01, 05, 0d, 11, 15, 19, 25, 14, 01, 22, 05, 01, 11, 00, 01, 12, 01, 0a, 02, 02, 10, 00, 15, 00, 01, 17, 00, 1b, 00, 00, 1c, 00, 1e, 0e, 01, 0e, 00, 0f, 0b, 01, 0d, 00, 1e, 25, 00, 1e, 00, 1f, ba, 01, 02, 0d, 00, 0e, bf, 01, 00, 12, 00, 17, ba, 01, 01, 10, 00, 15, 00, 00, 16, 01, 0e, b6, 01, 02, 14, 00, 19, 00, 01, 1b, 00, 1f, 00, 00, 20, 00, 22, b2, 01, 01, 12, 00, 13, af, 01, 01, 11, 00, 22, aa, 01, 00, 22, 00, 23, 19, 03, 09, 00, 0f, a7, 01, 01, 05, 00, 06] +Raw bytes (253): 0x[01, 01, 33, 01, 00, 02, 00, 00, 0e, 02, 00, bf, 01, 19, c3, 01, c7, 01, 00, 0d, 00, 15, c3, 01, c7, 01, 00, 0d, 00, 15, bf, 01, 19, c3, 01, c7, 01, 00, 0d, 00, 15, ba, 01, 00, bf, 01, 19, c3, 01, c7, 01, 00, 0d, 00, 15, b6, 01, 00, ba, 01, 00, bf, 01, 19, c3, 01, c7, 01, 00, 0d, 00, 15, 00, b2, 01, b6, 01, 00, ba, 01, 00, bf, 01, 19, c3, 01, c7, 01, 00, 0d, 00, 15, af, 01, 15, 00, b2, 01, b6, 01, 00, ba, 01, 00, bf, 01, 19, c3, 01, c7, 01, 00, 0d, 00, 15, aa, 01, cb, 01, af, 01, 15, 00, b2, 01, b6, 01, 00, ba, 01, 00, bf, 01, 19, c3, 01, c7, 01, 00, 0d, 00, 15, 19, 25, 14, 01, 22, 05, 01, 11, 00, 01, 12, 01, 0a, 02, 02, 10, 00, 15, 00, 01, 17, 00, 1b, 00, 00, 1c, 00, 1e, 0e, 01, 0e, 00, 0f, 0b, 01, 0d, 00, 1e, 25, 00, 1e, 00, 1f, ba, 01, 02, 0d, 00, 0e, bf, 01, 00, 12, 00, 17, ba, 01, 01, 10, 00, 15, 00, 00, 16, 01, 0e, b6, 01, 02, 14, 00, 19, 00, 01, 1b, 00, 1f, 00, 00, 20, 00, 22, b2, 01, 01, 12, 00, 13, af, 01, 01, 11, 00, 22, aa, 01, 00, 22, 00, 23, 19, 03, 09, 00, 0f, a7, 01, 01, 05, 00, 06] Number of files: 1 - file 0 => global file 1 Number of expressions: 51 -- expression 0 operands: lhs = Counter(0), rhs = Counter(1) -- expression 1 operands: lhs = Expression(0, Sub), rhs = Counter(2) +- expression 0 operands: lhs = Counter(0), rhs = Zero +- expression 1 operands: lhs = Expression(0, Sub), rhs = Zero - expression 2 operands: lhs = Zero, rhs = Expression(3, Sub) -- expression 3 operands: lhs = Expression(0, Sub), rhs = Counter(2) +- expression 3 operands: lhs = Expression(0, Sub), rhs = Zero - expression 4 operands: lhs = Expression(47, Add), rhs = Counter(6) - expression 5 operands: lhs = Expression(48, Add), rhs = Expression(49, Add) -- expression 6 operands: lhs = Counter(1), rhs = Counter(3) -- expression 7 operands: lhs = Counter(4), rhs = Counter(5) +- expression 6 operands: lhs = Zero, rhs = Counter(3) +- expression 7 operands: lhs = Zero, rhs = Counter(5) - expression 8 operands: lhs = Expression(48, Add), rhs = Expression(49, Add) -- expression 9 operands: lhs = Counter(1), rhs = Counter(3) -- expression 10 operands: lhs = Counter(4), rhs = Counter(5) +- expression 9 operands: lhs = Zero, rhs = Counter(3) +- expression 10 operands: lhs = Zero, rhs = Counter(5) - expression 11 operands: lhs = Expression(47, Add), rhs = Counter(6) - expression 12 operands: lhs = Expression(48, Add), rhs = Expression(49, Add) -- expression 13 operands: lhs = Counter(1), rhs = Counter(3) -- expression 14 operands: lhs = Counter(4), rhs = Counter(5) -- expression 15 operands: lhs = Expression(46, Sub), rhs = Counter(4) +- expression 13 operands: lhs = Zero, rhs = Counter(3) +- expression 14 operands: lhs = Zero, rhs = Counter(5) +- expression 15 operands: lhs = Expression(46, Sub), rhs = Zero - expression 16 operands: lhs = Expression(47, Add), rhs = Counter(6) - expression 17 operands: lhs = Expression(48, Add), rhs = Expression(49, Add) -- expression 18 operands: lhs = Counter(1), rhs = Counter(3) -- expression 19 operands: lhs = Counter(4), rhs = Counter(5) -- expression 20 operands: lhs = Expression(45, Sub), rhs = Counter(7) -- expression 21 operands: lhs = Expression(46, Sub), rhs = Counter(4) +- expression 18 operands: lhs = Zero, rhs = Counter(3) +- expression 19 operands: lhs = Zero, rhs = Counter(5) +- expression 20 operands: lhs = Expression(45, Sub), rhs = Zero +- expression 21 operands: lhs = Expression(46, Sub), rhs = Zero - expression 22 operands: lhs = Expression(47, Add), rhs = Counter(6) - expression 23 operands: lhs = Expression(48, Add), rhs = Expression(49, Add) -- expression 24 operands: lhs = Counter(1), rhs = Counter(3) -- expression 25 operands: lhs = Counter(4), rhs = Counter(5) +- expression 24 operands: lhs = Zero, rhs = Counter(3) +- expression 25 operands: lhs = Zero, rhs = Counter(5) - expression 26 operands: lhs = Zero, rhs = Expression(44, Sub) -- expression 27 operands: lhs = Expression(45, Sub), rhs = Counter(7) -- expression 28 operands: lhs = Expression(46, Sub), rhs = Counter(4) +- expression 27 operands: lhs = Expression(45, Sub), rhs = Zero +- expression 28 operands: lhs = Expression(46, Sub), rhs = Zero - expression 29 operands: lhs = Expression(47, Add), rhs = Counter(6) - expression 30 operands: lhs = Expression(48, Add), rhs = Expression(49, Add) -- expression 31 operands: lhs = Counter(1), rhs = Counter(3) -- expression 32 operands: lhs = Counter(4), rhs = Counter(5) +- expression 31 operands: lhs = Zero, rhs = Counter(3) +- expression 32 operands: lhs = Zero, rhs = Counter(5) - expression 33 operands: lhs = Expression(43, Add), rhs = Counter(5) - expression 34 operands: lhs = Zero, rhs = Expression(44, Sub) -- expression 35 operands: lhs = Expression(45, Sub), rhs = Counter(7) -- expression 36 operands: lhs = Expression(46, Sub), rhs = Counter(4) +- expression 35 operands: lhs = Expression(45, Sub), rhs = Zero +- expression 36 operands: lhs = Expression(46, Sub), rhs = Zero - expression 37 operands: lhs = Expression(47, Add), rhs = Counter(6) - expression 38 operands: lhs = Expression(48, Add), rhs = Expression(49, Add) -- expression 39 operands: lhs = Counter(1), rhs = Counter(3) -- expression 40 operands: lhs = Counter(4), rhs = Counter(5) +- expression 39 operands: lhs = Zero, rhs = Counter(3) +- expression 40 operands: lhs = Zero, rhs = Counter(5) - expression 41 operands: lhs = Expression(42, Sub), rhs = Expression(50, Add) - expression 42 operands: lhs = Expression(43, Add), rhs = Counter(5) - expression 43 operands: lhs = Zero, rhs = Expression(44, Sub) -- expression 44 operands: lhs = Expression(45, Sub), rhs = Counter(7) -- expression 45 operands: lhs = Expression(46, Sub), rhs = Counter(4) +- expression 44 operands: lhs = Expression(45, Sub), rhs = Zero +- expression 45 operands: lhs = Expression(46, Sub), rhs = Zero - expression 46 operands: lhs = Expression(47, Add), rhs = Counter(6) - expression 47 operands: lhs = Expression(48, Add), rhs = Expression(49, Add) -- expression 48 operands: lhs = Counter(1), rhs = Counter(3) -- expression 49 operands: lhs = Counter(4), rhs = Counter(5) +- expression 48 operands: lhs = Zero, rhs = Counter(3) +- expression 49 operands: lhs = Zero, rhs = Counter(5) - expression 50 operands: lhs = Counter(6), rhs = Counter(9) Number of file 0 mappings: 20 - Code(Counter(0)) at (prev + 34, 5) to (start + 1, 17) - Code(Zero) at (prev + 1, 18) to (start + 1, 10) - Code(Expression(0, Sub)) at (prev + 2, 16) to (start + 0, 21) - = (c0 - c1) + = (c0 - Zero) - Code(Zero) at (prev + 1, 23) to (start + 0, 27) - Code(Zero) at (prev + 0, 28) to (start + 0, 30) - Code(Expression(3, Sub)) at (prev + 1, 14) to (start + 0, 15) - = ((c0 - c1) - c2) + = ((c0 - Zero) - Zero) - Code(Expression(2, Add)) at (prev + 1, 13) to (start + 0, 30) - = (Zero + ((c0 - c1) - c2)) + = (Zero + ((c0 - Zero) - Zero)) - Code(Counter(9)) at (prev + 0, 30) to (start + 0, 31) - Code(Expression(46, Sub)) at (prev + 2, 13) to (start + 0, 14) - = (((c1 + c3) + (c4 + c5)) - c6) + = (((Zero + c3) + (Zero + c5)) - c6) - Code(Expression(47, Add)) at (prev + 0, 18) to (start + 0, 23) - = ((c1 + c3) + (c4 + c5)) + = ((Zero + c3) + (Zero + c5)) - Code(Expression(46, Sub)) at (prev + 1, 16) to (start + 0, 21) - = (((c1 + c3) + (c4 + c5)) - c6) + = (((Zero + c3) + (Zero + c5)) - c6) - Code(Zero) at (prev + 0, 22) to (start + 1, 14) - Code(Expression(45, Sub)) at (prev + 2, 20) to (start + 0, 25) - = ((((c1 + c3) + (c4 + c5)) - c6) - c4) + = ((((Zero + c3) + (Zero + c5)) - c6) - Zero) - Code(Zero) at (prev + 1, 27) to (start + 0, 31) - Code(Zero) at (prev + 0, 32) to (start + 0, 34) - Code(Expression(44, Sub)) at (prev + 1, 18) to (start + 0, 19) - = (((((c1 + c3) + (c4 + c5)) - c6) - c4) - c7) + = (((((Zero + c3) + (Zero + c5)) - c6) - Zero) - Zero) - Code(Expression(43, Add)) at (prev + 1, 17) to (start + 0, 34) - = (Zero + (((((c1 + c3) + (c4 + c5)) - c6) - c4) - c7)) + = (Zero + (((((Zero + c3) + (Zero + c5)) - c6) - Zero) - Zero)) - Code(Expression(42, Sub)) at (prev + 0, 34) to (start + 0, 35) - = ((Zero + (((((c1 + c3) + (c4 + c5)) - c6) - c4) - c7)) - c5) + = ((Zero + (((((Zero + c3) + (Zero + c5)) - c6) - Zero) - Zero)) - c5) - Code(Counter(6)) at (prev + 3, 9) to (start + 0, 15) - Code(Expression(41, Add)) at (prev + 1, 5) to (start + 0, 6) - = (((Zero + (((((c1 + c3) + (c4 + c5)) - c6) - c4) - c7)) - c5) + (c6 + c9)) + = (((Zero + (((((Zero + c3) + (Zero + c5)) - c6) - Zero) - Zero)) - c5) + (c6 + c9)) Function name: loops_branches::main Raw bytes (9): 0x[01, 01, 00, 01, 01, 37, 01, 05, 02] diff --git a/tests/coverage-map/status-quo/sort_groups.cov-map b/tests/coverage-map/status-quo/sort_groups.cov-map index 7156a66cf89..db027f3dc32 100644 --- a/tests/coverage-map/status-quo/sort_groups.cov-map +++ b/tests/coverage-map/status-quo/sort_groups.cov-map @@ -44,19 +44,19 @@ Number of file 0 mappings: 4 = (c1 + (c0 - c1)) Function name: sort_groups::main -Raw bytes (28): 0x[01, 01, 02, 01, 05, 05, 02, 04, 01, 06, 01, 04, 0d, 00, 04, 0e, 02, 06, 02, 02, 06, 00, 07, 07, 01, 05, 02, 02] +Raw bytes (28): 0x[01, 01, 02, 01, 00, 00, 02, 04, 01, 06, 01, 04, 0d, 00, 04, 0e, 02, 06, 02, 02, 06, 00, 07, 07, 01, 05, 02, 02] 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) +- expression 0 operands: lhs = Counter(0), rhs = Zero +- expression 1 operands: lhs = Zero, rhs = Expression(0, Sub) Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 6, 1) to (start + 4, 13) - Code(Zero) at (prev + 4, 14) to (start + 2, 6) - Code(Expression(0, Sub)) at (prev + 2, 6) to (start + 0, 7) - = (c0 - c1) + = (c0 - Zero) - Code(Expression(1, Add)) at (prev + 1, 5) to (start + 2, 2) - = (c1 + (c0 - c1)) + = (Zero + (c0 - Zero)) Function name: sort_groups::other_fn Raw bytes (9): 0x[01, 01, 00, 01, 01, 17, 01, 00, 11] diff --git a/tests/coverage-map/status-quo/tight_inf_loop.cov-map b/tests/coverage-map/status-quo/tight_inf_loop.cov-map index 76884212c14..7fe3146b080 100644 --- a/tests/coverage-map/status-quo/tight_inf_loop.cov-map +++ b/tests/coverage-map/status-quo/tight_inf_loop.cov-map @@ -1,12 +1,12 @@ Function name: tight_inf_loop::main -Raw bytes (21): 0x[01, 01, 01, 01, 05, 03, 01, 01, 01, 01, 0d, 00, 02, 09, 00, 10, 02, 01, 06, 01, 02] +Raw bytes (21): 0x[01, 01, 01, 01, 00, 03, 01, 01, 01, 01, 0d, 00, 02, 09, 00, 10, 02, 01, 06, 01, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 1 -- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 0 operands: lhs = Counter(0), rhs = Zero Number of file 0 mappings: 3 - Code(Counter(0)) at (prev + 1, 1) to (start + 1, 13) - Code(Zero) at (prev + 2, 9) to (start + 0, 16) - Code(Expression(0, Sub)) at (prev + 1, 6) to (start + 1, 2) - = (c0 - c1) + = (c0 - Zero) diff --git a/tests/coverage-map/status-quo/while.cov-map b/tests/coverage-map/status-quo/while.cov-map index cfd2be96a0d..af250f3fb71 100644 --- a/tests/coverage-map/status-quo/while.cov-map +++ b/tests/coverage-map/status-quo/while.cov-map @@ -1,15 +1,15 @@ Function name: while::main -Raw bytes (28): 0x[01, 01, 02, 01, 05, 03, 05, 04, 01, 01, 01, 01, 10, 03, 02, 0b, 00, 14, 00, 00, 15, 01, 06, 06, 02, 01, 00, 02] +Raw bytes (28): 0x[01, 01, 02, 01, 00, 03, 00, 04, 01, 01, 01, 01, 10, 03, 02, 0b, 00, 14, 00, 00, 15, 01, 06, 06, 02, 01, 00, 02] 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 = Expression(0, Add), rhs = Counter(1) +- expression 0 operands: lhs = Counter(0), rhs = Zero +- expression 1 operands: lhs = Expression(0, Add), rhs = Zero Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 1, 1) to (start + 1, 16) - Code(Expression(0, Add)) at (prev + 2, 11) to (start + 0, 20) - = (c0 + c1) + = (c0 + Zero) - Code(Zero) at (prev + 0, 21) to (start + 1, 6) - Code(Expression(1, Sub)) at (prev + 2, 1) to (start + 0, 2) - = ((c0 + c1) - c1) + = ((c0 + Zero) - Zero) diff --git a/tests/mir-opt/const_debuginfo.main.ConstDebugInfo.diff b/tests/mir-opt/const_debuginfo.main.ConstDebugInfo.diff index 313e5dddbbb..f5d822520a7 100644 --- a/tests/mir-opt/const_debuginfo.main.ConstDebugInfo.diff +++ b/tests/mir-opt/const_debuginfo.main.ConstDebugInfo.diff @@ -4,12 +4,6 @@ fn main() -> () { let mut _0: (); let _1: u8; - let mut _5: u8; - let mut _6: u8; - let mut _7: u8; - let mut _8: u8; - let mut _12: u32; - let mut _13: u32; scope 1 { - debug x => _1; + debug x => const 1_u8; @@ -25,34 +19,34 @@ scope 4 { - debug sum => _4; + debug sum => const 6_u8; - let _9: &str; + let _5: &str; scope 5 { -- debug s => _9; +- debug s => _5; + debug s => const "hello, world!"; - let _14: bool; - let _15: bool; - let _16: u32; + let _8: bool; + let _9: bool; + let _10: u32; scope 6 { -- debug ((f: (bool, bool, u32)).0: bool) => _14; -- debug ((f: (bool, bool, u32)).1: bool) => _15; -- debug ((f: (bool, bool, u32)).2: u32) => _16; +- debug ((f: (bool, bool, u32)).0: bool) => _8; +- debug ((f: (bool, bool, u32)).1: bool) => _9; +- debug ((f: (bool, bool, u32)).2: u32) => _10; + debug ((f: (bool, bool, u32)).0: bool) => const true; + debug ((f: (bool, bool, u32)).1: bool) => const false; + debug ((f: (bool, bool, u32)).2: u32) => const 123_u32; - let _10: std::option::Option<u16>; + let _6: std::option::Option<u16>; scope 7 { -- debug o => _10; +- debug o => _6; + debug o => const Option::<u16>::Some(99_u16); - let _17: u32; - let _18: u32; + let _11: u32; + let _12: u32; scope 8 { -- debug ((p: Point).0: u32) => _17; -- debug ((p: Point).1: u32) => _18; +- debug ((p: Point).0: u32) => _11; +- debug ((p: Point).1: u32) => _12; + debug ((p: Point).0: u32) => const 32_u32; + debug ((p: Point).1: u32) => const 32_u32; - let _11: u32; + let _7: u32; scope 9 { -- debug a => _11; +- debug a => _7; + debug a => const 64_u32; } } @@ -69,30 +63,27 @@ _2 = const 2_u8; _3 = const 3_u8; StorageLive(_4); - StorageLive(_5); - _5 = const 3_u8; _4 = const 6_u8; - StorageDead(_5); + StorageLive(_5); + _5 = const "hello, world!"; + StorageLive(_8); StorageLive(_9); - _9 = const "hello, world!"; - StorageLive(_14); - StorageLive(_15); - StorageLive(_16); - _14 = const true; - _15 = const false; - _16 = const 123_u32; StorageLive(_10); - _10 = const Option::<u16>::Some(99_u16); - _17 = const 32_u32; - _18 = const 32_u32; - StorageLive(_11); - _11 = const 64_u32; - StorageDead(_11); - StorageDead(_10); - StorageDead(_14); - StorageDead(_15); - StorageDead(_16); + _8 = const true; + _9 = const false; + _10 = const 123_u32; + StorageLive(_6); + _6 = const Option::<u16>::Some(99_u16); + _11 = const 32_u32; + _12 = const 32_u32; + StorageLive(_7); + _7 = const 64_u32; + StorageDead(_7); + StorageDead(_6); + StorageDead(_8); StorageDead(_9); + StorageDead(_10); + StorageDead(_5); StorageDead(_4); return; } diff --git a/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-abort.diff index c73d217aeec..711db3d21dd 100644 --- a/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-abort.diff @@ -8,6 +8,9 @@ let mut _4: usize; let mut _6: usize; let mut _8: usize; + let mut _10: usize; + let mut _12: usize; + let mut _14: usize; scope 1 { debug x => _1; let _3: usize; @@ -19,6 +22,18 @@ let _7: usize; scope 4 { debug z1 => _7; + let _9: usize; + scope 5 { + debug eA0 => _9; + let _11: usize; + scope 6 { + debug eA1 => _11; + let _13: usize; + scope 7 { + debug eC => _13; + } + } + } } } } @@ -27,7 +42,7 @@ bb0: { StorageLive(_1); StorageLive(_2); -- _2 = OffsetOf(Alpha, [0]); +- _2 = OffsetOf(Alpha, [(0, 0)]); - _1 = must_use::<usize>(move _2) -> [return: bb1, unwind unreachable]; + _2 = const 4_usize; + _1 = must_use::<usize>(const 4_usize) -> [return: bb1, unwind unreachable]; @@ -37,7 +52,7 @@ StorageDead(_2); StorageLive(_3); StorageLive(_4); -- _4 = OffsetOf(Alpha, [1]); +- _4 = OffsetOf(Alpha, [(0, 1)]); - _3 = must_use::<usize>(move _4) -> [return: bb2, unwind unreachable]; + _4 = const 0_usize; + _3 = must_use::<usize>(const 0_usize) -> [return: bb2, unwind unreachable]; @@ -47,7 +62,7 @@ StorageDead(_4); StorageLive(_5); StorageLive(_6); -- _6 = OffsetOf(Alpha, [2, 0]); +- _6 = OffsetOf(Alpha, [(0, 2), (0, 0)]); - _5 = must_use::<usize>(move _6) -> [return: bb3, unwind unreachable]; + _6 = const 2_usize; + _5 = must_use::<usize>(const 2_usize) -> [return: bb3, unwind unreachable]; @@ -57,7 +72,7 @@ StorageDead(_6); StorageLive(_7); StorageLive(_8); -- _8 = OffsetOf(Alpha, [2, 1]); +- _8 = OffsetOf(Alpha, [(0, 2), (0, 1)]); - _7 = must_use::<usize>(move _8) -> [return: bb4, unwind unreachable]; + _8 = const 3_usize; + _7 = must_use::<usize>(const 3_usize) -> [return: bb4, unwind unreachable]; @@ -65,7 +80,40 @@ bb4: { StorageDead(_8); + StorageLive(_9); + StorageLive(_10); +- _10 = OffsetOf(Epsilon, [(0, 0)]); +- _9 = must_use::<usize>(move _10) -> [return: bb5, unwind unreachable]; ++ _10 = const 1_usize; ++ _9 = must_use::<usize>(const 1_usize) -> [return: bb5, unwind unreachable]; + } + + bb5: { + StorageDead(_10); + StorageLive(_11); + StorageLive(_12); +- _12 = OffsetOf(Epsilon, [(0, 1)]); +- _11 = must_use::<usize>(move _12) -> [return: bb6, unwind unreachable]; ++ _12 = const 2_usize; ++ _11 = must_use::<usize>(const 2_usize) -> [return: bb6, unwind unreachable]; + } + + bb6: { + StorageDead(_12); + StorageLive(_13); + StorageLive(_14); +- _14 = OffsetOf(Epsilon, [(2, 0)]); +- _13 = must_use::<usize>(move _14) -> [return: bb7, unwind unreachable]; ++ _14 = const 4_usize; ++ _13 = must_use::<usize>(const 4_usize) -> [return: bb7, unwind unreachable]; + } + + bb7: { + StorageDead(_14); _0 = const (); + StorageDead(_13); + StorageDead(_11); + StorageDead(_9); StorageDead(_7); StorageDead(_5); StorageDead(_3); diff --git a/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-unwind.diff index 913ffca4ae9..49458145415 100644 --- a/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-unwind.diff @@ -8,6 +8,9 @@ let mut _4: usize; let mut _6: usize; let mut _8: usize; + let mut _10: usize; + let mut _12: usize; + let mut _14: usize; scope 1 { debug x => _1; let _3: usize; @@ -19,6 +22,18 @@ let _7: usize; scope 4 { debug z1 => _7; + let _9: usize; + scope 5 { + debug eA0 => _9; + let _11: usize; + scope 6 { + debug eA1 => _11; + let _13: usize; + scope 7 { + debug eC => _13; + } + } + } } } } @@ -27,7 +42,7 @@ bb0: { StorageLive(_1); StorageLive(_2); -- _2 = OffsetOf(Alpha, [0]); +- _2 = OffsetOf(Alpha, [(0, 0)]); - _1 = must_use::<usize>(move _2) -> [return: bb1, unwind continue]; + _2 = const 4_usize; + _1 = must_use::<usize>(const 4_usize) -> [return: bb1, unwind continue]; @@ -37,7 +52,7 @@ StorageDead(_2); StorageLive(_3); StorageLive(_4); -- _4 = OffsetOf(Alpha, [1]); +- _4 = OffsetOf(Alpha, [(0, 1)]); - _3 = must_use::<usize>(move _4) -> [return: bb2, unwind continue]; + _4 = const 0_usize; + _3 = must_use::<usize>(const 0_usize) -> [return: bb2, unwind continue]; @@ -47,7 +62,7 @@ StorageDead(_4); StorageLive(_5); StorageLive(_6); -- _6 = OffsetOf(Alpha, [2, 0]); +- _6 = OffsetOf(Alpha, [(0, 2), (0, 0)]); - _5 = must_use::<usize>(move _6) -> [return: bb3, unwind continue]; + _6 = const 2_usize; + _5 = must_use::<usize>(const 2_usize) -> [return: bb3, unwind continue]; @@ -57,7 +72,7 @@ StorageDead(_6); StorageLive(_7); StorageLive(_8); -- _8 = OffsetOf(Alpha, [2, 1]); +- _8 = OffsetOf(Alpha, [(0, 2), (0, 1)]); - _7 = must_use::<usize>(move _8) -> [return: bb4, unwind continue]; + _8 = const 3_usize; + _7 = must_use::<usize>(const 3_usize) -> [return: bb4, unwind continue]; @@ -65,7 +80,40 @@ bb4: { StorageDead(_8); + StorageLive(_9); + StorageLive(_10); +- _10 = OffsetOf(Epsilon, [(0, 0)]); +- _9 = must_use::<usize>(move _10) -> [return: bb5, unwind continue]; ++ _10 = const 1_usize; ++ _9 = must_use::<usize>(const 1_usize) -> [return: bb5, unwind continue]; + } + + bb5: { + StorageDead(_10); + StorageLive(_11); + StorageLive(_12); +- _12 = OffsetOf(Epsilon, [(0, 1)]); +- _11 = must_use::<usize>(move _12) -> [return: bb6, unwind continue]; ++ _12 = const 2_usize; ++ _11 = must_use::<usize>(const 2_usize) -> [return: bb6, unwind continue]; + } + + bb6: { + StorageDead(_12); + StorageLive(_13); + StorageLive(_14); +- _14 = OffsetOf(Epsilon, [(2, 0)]); +- _13 = must_use::<usize>(move _14) -> [return: bb7, unwind continue]; ++ _14 = const 4_usize; ++ _13 = must_use::<usize>(const 4_usize) -> [return: bb7, unwind continue]; + } + + bb7: { + StorageDead(_14); _0 = const (); + StorageDead(_13); + StorageDead(_11); + StorageDead(_9); StorageDead(_7); StorageDead(_5); StorageDead(_3); diff --git a/tests/mir-opt/const_prop/offset_of.generic.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/offset_of.generic.ConstProp.panic-abort.diff index 7519331f6d7..768970a7250 100644 --- a/tests/mir-opt/const_prop/offset_of.generic.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/offset_of.generic.ConstProp.panic-abort.diff @@ -8,6 +8,9 @@ let mut _4: usize; let mut _6: usize; let mut _8: usize; + let mut _10: usize; + let mut _12: usize; + let mut _14: usize; scope 1 { debug gx => _1; let _3: usize; @@ -19,6 +22,18 @@ let _7: usize; scope 4 { debug dy => _7; + let _9: usize; + scope 5 { + debug zA0 => _9; + let _11: usize; + scope 6 { + debug zA1 => _11; + let _13: usize; + scope 7 { + debug zB => _13; + } + } + } } } } @@ -27,7 +42,7 @@ bb0: { StorageLive(_1); StorageLive(_2); - _2 = OffsetOf(Gamma<T>, [0]); + _2 = OffsetOf(Gamma<T>, [(0, 0)]); _1 = must_use::<usize>(move _2) -> [return: bb1, unwind unreachable]; } @@ -35,7 +50,7 @@ StorageDead(_2); StorageLive(_3); StorageLive(_4); - _4 = OffsetOf(Gamma<T>, [1]); + _4 = OffsetOf(Gamma<T>, [(0, 1)]); _3 = must_use::<usize>(move _4) -> [return: bb2, unwind unreachable]; } @@ -43,7 +58,7 @@ StorageDead(_4); StorageLive(_5); StorageLive(_6); - _6 = OffsetOf(Delta<T>, [1]); + _6 = OffsetOf(Delta<T>, [(0, 1)]); _5 = must_use::<usize>(move _6) -> [return: bb3, unwind unreachable]; } @@ -51,13 +66,40 @@ StorageDead(_6); StorageLive(_7); StorageLive(_8); - _8 = OffsetOf(Delta<T>, [2]); + _8 = OffsetOf(Delta<T>, [(0, 2)]); _7 = must_use::<usize>(move _8) -> [return: bb4, unwind unreachable]; } bb4: { StorageDead(_8); + StorageLive(_9); + StorageLive(_10); + _10 = OffsetOf(Zeta<T>, [(0, 0)]); + _9 = must_use::<usize>(move _10) -> [return: bb5, unwind unreachable]; + } + + bb5: { + StorageDead(_10); + StorageLive(_11); + StorageLive(_12); + _12 = OffsetOf(Zeta<T>, [(0, 1)]); + _11 = must_use::<usize>(move _12) -> [return: bb6, unwind unreachable]; + } + + bb6: { + StorageDead(_12); + StorageLive(_13); + StorageLive(_14); + _14 = OffsetOf(Zeta<T>, [(1, 0)]); + _13 = must_use::<usize>(move _14) -> [return: bb7, unwind unreachable]; + } + + bb7: { + StorageDead(_14); _0 = const (); + StorageDead(_13); + StorageDead(_11); + StorageDead(_9); StorageDead(_7); StorageDead(_5); StorageDead(_3); diff --git a/tests/mir-opt/const_prop/offset_of.generic.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/offset_of.generic.ConstProp.panic-unwind.diff index fd5206e460c..04ccd2b36e0 100644 --- a/tests/mir-opt/const_prop/offset_of.generic.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/offset_of.generic.ConstProp.panic-unwind.diff @@ -8,6 +8,9 @@ let mut _4: usize; let mut _6: usize; let mut _8: usize; + let mut _10: usize; + let mut _12: usize; + let mut _14: usize; scope 1 { debug gx => _1; let _3: usize; @@ -19,6 +22,18 @@ let _7: usize; scope 4 { debug dy => _7; + let _9: usize; + scope 5 { + debug zA0 => _9; + let _11: usize; + scope 6 { + debug zA1 => _11; + let _13: usize; + scope 7 { + debug zB => _13; + } + } + } } } } @@ -27,7 +42,7 @@ bb0: { StorageLive(_1); StorageLive(_2); - _2 = OffsetOf(Gamma<T>, [0]); + _2 = OffsetOf(Gamma<T>, [(0, 0)]); _1 = must_use::<usize>(move _2) -> [return: bb1, unwind continue]; } @@ -35,7 +50,7 @@ StorageDead(_2); StorageLive(_3); StorageLive(_4); - _4 = OffsetOf(Gamma<T>, [1]); + _4 = OffsetOf(Gamma<T>, [(0, 1)]); _3 = must_use::<usize>(move _4) -> [return: bb2, unwind continue]; } @@ -43,7 +58,7 @@ StorageDead(_4); StorageLive(_5); StorageLive(_6); - _6 = OffsetOf(Delta<T>, [1]); + _6 = OffsetOf(Delta<T>, [(0, 1)]); _5 = must_use::<usize>(move _6) -> [return: bb3, unwind continue]; } @@ -51,13 +66,40 @@ StorageDead(_6); StorageLive(_7); StorageLive(_8); - _8 = OffsetOf(Delta<T>, [2]); + _8 = OffsetOf(Delta<T>, [(0, 2)]); _7 = must_use::<usize>(move _8) -> [return: bb4, unwind continue]; } bb4: { StorageDead(_8); + StorageLive(_9); + StorageLive(_10); + _10 = OffsetOf(Zeta<T>, [(0, 0)]); + _9 = must_use::<usize>(move _10) -> [return: bb5, unwind continue]; + } + + bb5: { + StorageDead(_10); + StorageLive(_11); + StorageLive(_12); + _12 = OffsetOf(Zeta<T>, [(0, 1)]); + _11 = must_use::<usize>(move _12) -> [return: bb6, unwind continue]; + } + + bb6: { + StorageDead(_12); + StorageLive(_13); + StorageLive(_14); + _14 = OffsetOf(Zeta<T>, [(1, 0)]); + _13 = must_use::<usize>(move _14) -> [return: bb7, unwind continue]; + } + + bb7: { + StorageDead(_14); _0 = const (); + StorageDead(_13); + StorageDead(_11); + StorageDead(_9); StorageDead(_7); StorageDead(_5); StorageDead(_3); diff --git a/tests/mir-opt/const_prop/offset_of.rs b/tests/mir-opt/const_prop/offset_of.rs index 21911f8dbb5..8a5289d5899 100644 --- a/tests/mir-opt/const_prop/offset_of.rs +++ b/tests/mir-opt/const_prop/offset_of.rs @@ -28,12 +28,26 @@ struct Delta<T> { y: u16, } +enum Epsilon { + A(u8, u16), + B, + C { c: u32 } +} + +enum Zeta<T> { + A(T, bool), + B(char), +} + // EMIT_MIR offset_of.concrete.ConstProp.diff fn concrete() { let x = offset_of!(Alpha, x); let y = offset_of!(Alpha, y); let z0 = offset_of!(Alpha, z.0); let z1 = offset_of!(Alpha, z.1); + let eA0 = offset_of!(Epsilon, A.0); + let eA1 = offset_of!(Epsilon, A.1); + let eC = offset_of!(Epsilon, C.c); } // EMIT_MIR offset_of.generic.ConstProp.diff @@ -42,6 +56,9 @@ fn generic<T>() { let gy = offset_of!(Gamma<T>, y); let dx = offset_of!(Delta<T>, x); let dy = offset_of!(Delta<T>, y); + let zA0 = offset_of!(Zeta<T>, A.0); + let zA1 = offset_of!(Zeta<T>, A.1); + let zB = offset_of!(Zeta<T>, B.0); } fn main() { diff --git a/tests/mir-opt/dataflow-const-prop/offset_of.concrete.DataflowConstProp.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/offset_of.concrete.DataflowConstProp.panic-abort.diff index c61414b6541..f8f89175033 100644 --- a/tests/mir-opt/dataflow-const-prop/offset_of.concrete.DataflowConstProp.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/offset_of.concrete.DataflowConstProp.panic-abort.diff @@ -27,7 +27,7 @@ bb0: { StorageLive(_1); StorageLive(_2); -- _2 = OffsetOf(Alpha, [0]); +- _2 = OffsetOf(Alpha, [(0, 0)]); - _1 = must_use::<usize>(move _2) -> [return: bb1, unwind unreachable]; + _2 = const 4_usize; + _1 = must_use::<usize>(const 4_usize) -> [return: bb1, unwind unreachable]; @@ -37,7 +37,7 @@ StorageDead(_2); StorageLive(_3); StorageLive(_4); -- _4 = OffsetOf(Alpha, [1]); +- _4 = OffsetOf(Alpha, [(0, 1)]); - _3 = must_use::<usize>(move _4) -> [return: bb2, unwind unreachable]; + _4 = const 0_usize; + _3 = must_use::<usize>(const 0_usize) -> [return: bb2, unwind unreachable]; @@ -47,7 +47,7 @@ StorageDead(_4); StorageLive(_5); StorageLive(_6); -- _6 = OffsetOf(Alpha, [2, 0]); +- _6 = OffsetOf(Alpha, [(0, 2), (0, 0)]); - _5 = must_use::<usize>(move _6) -> [return: bb3, unwind unreachable]; + _6 = const 2_usize; + _5 = must_use::<usize>(const 2_usize) -> [return: bb3, unwind unreachable]; @@ -57,7 +57,7 @@ StorageDead(_6); StorageLive(_7); StorageLive(_8); -- _8 = OffsetOf(Alpha, [2, 1]); +- _8 = OffsetOf(Alpha, [(0, 2), (0, 1)]); - _7 = must_use::<usize>(move _8) -> [return: bb4, unwind unreachable]; + _8 = const 3_usize; + _7 = must_use::<usize>(const 3_usize) -> [return: bb4, unwind unreachable]; diff --git a/tests/mir-opt/dataflow-const-prop/offset_of.concrete.DataflowConstProp.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/offset_of.concrete.DataflowConstProp.panic-unwind.diff index 0c3939a3456..d4f8cb66704 100644 --- a/tests/mir-opt/dataflow-const-prop/offset_of.concrete.DataflowConstProp.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/offset_of.concrete.DataflowConstProp.panic-unwind.diff @@ -27,7 +27,7 @@ bb0: { StorageLive(_1); StorageLive(_2); -- _2 = OffsetOf(Alpha, [0]); +- _2 = OffsetOf(Alpha, [(0, 0)]); - _1 = must_use::<usize>(move _2) -> [return: bb1, unwind continue]; + _2 = const 4_usize; + _1 = must_use::<usize>(const 4_usize) -> [return: bb1, unwind continue]; @@ -37,7 +37,7 @@ StorageDead(_2); StorageLive(_3); StorageLive(_4); -- _4 = OffsetOf(Alpha, [1]); +- _4 = OffsetOf(Alpha, [(0, 1)]); - _3 = must_use::<usize>(move _4) -> [return: bb2, unwind continue]; + _4 = const 0_usize; + _3 = must_use::<usize>(const 0_usize) -> [return: bb2, unwind continue]; @@ -47,7 +47,7 @@ StorageDead(_4); StorageLive(_5); StorageLive(_6); -- _6 = OffsetOf(Alpha, [2, 0]); +- _6 = OffsetOf(Alpha, [(0, 2), (0, 0)]); - _5 = must_use::<usize>(move _6) -> [return: bb3, unwind continue]; + _6 = const 2_usize; + _5 = must_use::<usize>(const 2_usize) -> [return: bb3, unwind continue]; @@ -57,7 +57,7 @@ StorageDead(_6); StorageLive(_7); StorageLive(_8); -- _8 = OffsetOf(Alpha, [2, 1]); +- _8 = OffsetOf(Alpha, [(0, 2), (0, 1)]); - _7 = must_use::<usize>(move _8) -> [return: bb4, unwind continue]; + _8 = const 3_usize; + _7 = must_use::<usize>(const 3_usize) -> [return: bb4, unwind continue]; diff --git a/tests/mir-opt/dataflow-const-prop/offset_of.generic.DataflowConstProp.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/offset_of.generic.DataflowConstProp.panic-abort.diff index d54d4687060..7f166e4fa35 100644 --- a/tests/mir-opt/dataflow-const-prop/offset_of.generic.DataflowConstProp.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/offset_of.generic.DataflowConstProp.panic-abort.diff @@ -27,7 +27,7 @@ bb0: { StorageLive(_1); StorageLive(_2); - _2 = OffsetOf(Gamma<T>, [0]); + _2 = OffsetOf(Gamma<T>, [(0, 0)]); _1 = must_use::<usize>(move _2) -> [return: bb1, unwind unreachable]; } @@ -35,7 +35,7 @@ StorageDead(_2); StorageLive(_3); StorageLive(_4); - _4 = OffsetOf(Gamma<T>, [1]); + _4 = OffsetOf(Gamma<T>, [(0, 1)]); _3 = must_use::<usize>(move _4) -> [return: bb2, unwind unreachable]; } @@ -43,7 +43,7 @@ StorageDead(_4); StorageLive(_5); StorageLive(_6); -- _6 = OffsetOf(Delta<T>, [1]); +- _6 = OffsetOf(Delta<T>, [(0, 1)]); - _5 = must_use::<usize>(move _6) -> [return: bb3, unwind unreachable]; + _6 = const 0_usize; + _5 = must_use::<usize>(const 0_usize) -> [return: bb3, unwind unreachable]; @@ -53,7 +53,7 @@ StorageDead(_6); StorageLive(_7); StorageLive(_8); -- _8 = OffsetOf(Delta<T>, [2]); +- _8 = OffsetOf(Delta<T>, [(0, 2)]); - _7 = must_use::<usize>(move _8) -> [return: bb4, unwind unreachable]; + _8 = const 2_usize; + _7 = must_use::<usize>(const 2_usize) -> [return: bb4, unwind unreachable]; diff --git a/tests/mir-opt/dataflow-const-prop/offset_of.generic.DataflowConstProp.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/offset_of.generic.DataflowConstProp.panic-unwind.diff index 6032a2274ef..38ad6f79801 100644 --- a/tests/mir-opt/dataflow-const-prop/offset_of.generic.DataflowConstProp.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/offset_of.generic.DataflowConstProp.panic-unwind.diff @@ -27,7 +27,7 @@ bb0: { StorageLive(_1); StorageLive(_2); - _2 = OffsetOf(Gamma<T>, [0]); + _2 = OffsetOf(Gamma<T>, [(0, 0)]); _1 = must_use::<usize>(move _2) -> [return: bb1, unwind continue]; } @@ -35,7 +35,7 @@ StorageDead(_2); StorageLive(_3); StorageLive(_4); - _4 = OffsetOf(Gamma<T>, [1]); + _4 = OffsetOf(Gamma<T>, [(0, 1)]); _3 = must_use::<usize>(move _4) -> [return: bb2, unwind continue]; } @@ -43,7 +43,7 @@ StorageDead(_4); StorageLive(_5); StorageLive(_6); -- _6 = OffsetOf(Delta<T>, [1]); +- _6 = OffsetOf(Delta<T>, [(0, 1)]); - _5 = must_use::<usize>(move _6) -> [return: bb3, unwind continue]; + _6 = const 0_usize; + _5 = must_use::<usize>(const 0_usize) -> [return: bb3, unwind continue]; @@ -53,7 +53,7 @@ StorageDead(_6); StorageLive(_7); StorageLive(_8); -- _8 = OffsetOf(Delta<T>, [2]); +- _8 = OffsetOf(Delta<T>, [(0, 2)]); - _7 = must_use::<usize>(move _8) -> [return: bb4, unwind continue]; + _8 = const 2_usize; + _7 = must_use::<usize>(const 2_usize) -> [return: bb4, unwind continue]; diff --git a/tests/mir-opt/gvn.arithmetic.GVN.panic-abort.diff b/tests/mir-opt/gvn.arithmetic.GVN.panic-abort.diff index 3f5173c189e..d524ad242fe 100644 --- a/tests/mir-opt/gvn.arithmetic.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.arithmetic.GVN.panic-abort.diff @@ -67,11 +67,11 @@ bb0: { StorageLive(_2); StorageLive(_3); -- StorageLive(_4); -- _4 = _1; + StorageLive(_4); + _4 = _1; - _3 = Add(move _4, const 0_u64); -- StorageDead(_4); + _3 = Add(_1, const 0_u64); + StorageDead(_4); _2 = opaque::<u64>(move _3) -> [return: bb1, unwind unreachable]; } @@ -80,11 +80,11 @@ StorageDead(_2); StorageLive(_5); StorageLive(_6); -- StorageLive(_7); -- _7 = _1; + StorageLive(_7); + _7 = _1; - _6 = Sub(move _7, const 0_u64); -- StorageDead(_7); + _6 = Sub(_1, const 0_u64); + StorageDead(_7); _5 = opaque::<u64>(move _6) -> [return: bb2, unwind unreachable]; } @@ -93,11 +93,11 @@ StorageDead(_5); StorageLive(_8); StorageLive(_9); -- StorageLive(_10); -- _10 = _1; + StorageLive(_10); + _10 = _1; - _9 = Mul(move _10, const 0_u64); -- StorageDead(_10); + _9 = Mul(_1, const 0_u64); + StorageDead(_10); _8 = opaque::<u64>(move _9) -> [return: bb3, unwind unreachable]; } @@ -106,11 +106,11 @@ StorageDead(_8); StorageLive(_11); StorageLive(_12); -- StorageLive(_13); -- _13 = _1; + StorageLive(_13); + _13 = _1; - _12 = Mul(move _13, const 1_u64); -- StorageDead(_13); + _12 = Mul(_1, const 1_u64); + StorageDead(_13); _11 = opaque::<u64>(move _12) -> [return: bb4, unwind unreachable]; } @@ -119,17 +119,18 @@ StorageDead(_11); StorageLive(_14); StorageLive(_15); -- StorageLive(_16); -- _16 = _1; - _17 = Eq(const 0_u64, const 0_u64); + StorageLive(_16); + _16 = _1; +- _17 = Eq(const 0_u64, const 0_u64); - assert(!move _17, "attempt to divide `{}` by zero", _16) -> [success: bb5, unwind unreachable]; -+ assert(!_17, "attempt to divide `{}` by zero", _1) -> [success: bb5, unwind unreachable]; ++ _17 = const true; ++ assert(!const true, "attempt to divide `{}` by zero", _1) -> [success: bb5, unwind unreachable]; } bb5: { - _15 = Div(move _16, const 0_u64); -- StorageDead(_16); + _15 = Div(_1, const 0_u64); + StorageDead(_16); _14 = opaque::<u64>(move _15) -> [return: bb6, unwind unreachable]; } @@ -138,17 +139,18 @@ StorageDead(_14); StorageLive(_18); StorageLive(_19); -- StorageLive(_20); -- _20 = _1; - _21 = Eq(const 1_u64, const 0_u64); + StorageLive(_20); + _20 = _1; +- _21 = Eq(const 1_u64, const 0_u64); - assert(!move _21, "attempt to divide `{}` by zero", _20) -> [success: bb7, unwind unreachable]; -+ assert(!_21, "attempt to divide `{}` by zero", _1) -> [success: bb7, unwind unreachable]; ++ _21 = const false; ++ assert(!const false, "attempt to divide `{}` by zero", _1) -> [success: bb7, unwind unreachable]; } bb7: { - _19 = Div(move _20, const 1_u64); -- StorageDead(_20); + _19 = Div(_1, const 1_u64); + StorageDead(_20); _18 = opaque::<u64>(move _19) -> [return: bb8, unwind unreachable]; } @@ -157,8 +159,8 @@ StorageDead(_18); StorageLive(_22); StorageLive(_23); -- StorageLive(_24); -- _24 = _1; + StorageLive(_24); + _24 = _1; - _25 = Eq(_24, const 0_u64); - assert(!move _25, "attempt to divide `{}` by zero", const 0_u64) -> [success: bb9, unwind unreachable]; + _25 = Eq(_1, const 0_u64); @@ -167,8 +169,8 @@ bb9: { - _23 = Div(const 0_u64, move _24); -- StorageDead(_24); + _23 = Div(const 0_u64, _1); + StorageDead(_24); _22 = opaque::<u64>(move _23) -> [return: bb10, unwind unreachable]; } @@ -177,17 +179,18 @@ StorageDead(_22); StorageLive(_26); StorageLive(_27); -- StorageLive(_28); -- _28 = _1; + StorageLive(_28); + _28 = _1; - _29 = Eq(_28, const 0_u64); - assert(!move _29, "attempt to divide `{}` by zero", const 1_u64) -> [success: bb11, unwind unreachable]; ++ _29 = _25; + assert(!_25, "attempt to divide `{}` by zero", const 1_u64) -> [success: bb11, unwind unreachable]; } bb11: { - _27 = Div(const 1_u64, move _28); -- StorageDead(_28); + _27 = Div(const 1_u64, _1); + StorageDead(_28); _26 = opaque::<u64>(move _27) -> [return: bb12, unwind unreachable]; } @@ -196,17 +199,18 @@ StorageDead(_26); StorageLive(_30); StorageLive(_31); -- StorageLive(_32); -- _32 = _1; + StorageLive(_32); + _32 = _1; - _33 = Eq(const 0_u64, const 0_u64); - assert(!move _33, "attempt to calculate the remainder of `{}` with a divisor of zero", _32) -> [success: bb13, unwind unreachable]; -+ assert(!_17, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb13, unwind unreachable]; ++ _33 = const true; ++ assert(!const true, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb13, unwind unreachable]; } bb13: { - _31 = Rem(move _32, const 0_u64); -- StorageDead(_32); + _31 = Rem(_1, const 0_u64); + StorageDead(_32); _30 = opaque::<u64>(move _31) -> [return: bb14, unwind unreachable]; } @@ -215,17 +219,18 @@ StorageDead(_30); StorageLive(_34); StorageLive(_35); -- StorageLive(_36); -- _36 = _1; + StorageLive(_36); + _36 = _1; - _37 = Eq(const 1_u64, const 0_u64); - assert(!move _37, "attempt to calculate the remainder of `{}` with a divisor of zero", _36) -> [success: bb15, unwind unreachable]; -+ assert(!_21, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb15, unwind unreachable]; ++ _37 = const false; ++ assert(!const false, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb15, unwind unreachable]; } bb15: { - _35 = Rem(move _36, const 1_u64); -- StorageDead(_36); + _35 = Rem(_1, const 1_u64); + StorageDead(_36); _34 = opaque::<u64>(move _35) -> [return: bb16, unwind unreachable]; } @@ -234,17 +239,18 @@ StorageDead(_34); StorageLive(_38); StorageLive(_39); -- StorageLive(_40); -- _40 = _1; + StorageLive(_40); + _40 = _1; - _41 = Eq(_40, const 0_u64); - assert(!move _41, "attempt to calculate the remainder of `{}` with a divisor of zero", const 0_u64) -> [success: bb17, unwind unreachable]; ++ _41 = _25; + assert(!_25, "attempt to calculate the remainder of `{}` with a divisor of zero", const 0_u64) -> [success: bb17, unwind unreachable]; } bb17: { - _39 = Rem(const 0_u64, move _40); -- StorageDead(_40); + _39 = Rem(const 0_u64, _1); + StorageDead(_40); _38 = opaque::<u64>(move _39) -> [return: bb18, unwind unreachable]; } @@ -253,17 +259,18 @@ StorageDead(_38); StorageLive(_42); StorageLive(_43); -- StorageLive(_44); -- _44 = _1; + StorageLive(_44); + _44 = _1; - _45 = Eq(_44, const 0_u64); - assert(!move _45, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_u64) -> [success: bb19, unwind unreachable]; ++ _45 = _25; + assert(!_25, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_u64) -> [success: bb19, unwind unreachable]; } bb19: { - _43 = Rem(const 1_u64, move _44); -- StorageDead(_44); + _43 = Rem(const 1_u64, _1); + StorageDead(_44); _42 = opaque::<u64>(move _43) -> [return: bb20, unwind unreachable]; } @@ -272,11 +279,11 @@ StorageDead(_42); StorageLive(_46); StorageLive(_47); -- StorageLive(_48); -- _48 = _1; + StorageLive(_48); + _48 = _1; - _47 = BitAnd(move _48, const 0_u64); -- StorageDead(_48); + _47 = BitAnd(_1, const 0_u64); + StorageDead(_48); _46 = opaque::<u64>(move _47) -> [return: bb21, unwind unreachable]; } @@ -285,11 +292,11 @@ StorageDead(_46); StorageLive(_49); StorageLive(_50); -- StorageLive(_51); -- _51 = _1; + StorageLive(_51); + _51 = _1; - _50 = BitOr(move _51, const 0_u64); -- StorageDead(_51); + _50 = BitOr(_1, const 0_u64); + StorageDead(_51); _49 = opaque::<u64>(move _50) -> [return: bb22, unwind unreachable]; } @@ -298,11 +305,11 @@ StorageDead(_49); StorageLive(_52); StorageLive(_53); -- StorageLive(_54); -- _54 = _1; + StorageLive(_54); + _54 = _1; - _53 = BitXor(move _54, const 0_u64); -- StorageDead(_54); + _53 = BitXor(_1, const 0_u64); + StorageDead(_54); _52 = opaque::<u64>(move _53) -> [return: bb23, unwind unreachable]; } @@ -311,11 +318,11 @@ StorageDead(_52); StorageLive(_55); StorageLive(_56); -- StorageLive(_57); -- _57 = _1; + StorageLive(_57); + _57 = _1; - _56 = Shr(move _57, const 0_i32); -- StorageDead(_57); + _56 = Shr(_1, const 0_i32); + StorageDead(_57); _55 = opaque::<u64>(move _56) -> [return: bb24, unwind unreachable]; } @@ -324,11 +331,11 @@ StorageDead(_55); StorageLive(_58); StorageLive(_59); -- StorageLive(_60); -- _60 = _1; + StorageLive(_60); + _60 = _1; - _59 = Shl(move _60, const 0_i32); -- StorageDead(_60); + _59 = Shl(_1, const 0_i32); + StorageDead(_60); _58 = opaque::<u64>(move _59) -> [return: bb25, unwind unreachable]; } diff --git a/tests/mir-opt/gvn.arithmetic.GVN.panic-unwind.diff b/tests/mir-opt/gvn.arithmetic.GVN.panic-unwind.diff index 38da21d91d4..9d69353934c 100644 --- a/tests/mir-opt/gvn.arithmetic.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.arithmetic.GVN.panic-unwind.diff @@ -67,11 +67,11 @@ bb0: { StorageLive(_2); StorageLive(_3); -- StorageLive(_4); -- _4 = _1; + StorageLive(_4); + _4 = _1; - _3 = Add(move _4, const 0_u64); -- StorageDead(_4); + _3 = Add(_1, const 0_u64); + StorageDead(_4); _2 = opaque::<u64>(move _3) -> [return: bb1, unwind continue]; } @@ -80,11 +80,11 @@ StorageDead(_2); StorageLive(_5); StorageLive(_6); -- StorageLive(_7); -- _7 = _1; + StorageLive(_7); + _7 = _1; - _6 = Sub(move _7, const 0_u64); -- StorageDead(_7); + _6 = Sub(_1, const 0_u64); + StorageDead(_7); _5 = opaque::<u64>(move _6) -> [return: bb2, unwind continue]; } @@ -93,11 +93,11 @@ StorageDead(_5); StorageLive(_8); StorageLive(_9); -- StorageLive(_10); -- _10 = _1; + StorageLive(_10); + _10 = _1; - _9 = Mul(move _10, const 0_u64); -- StorageDead(_10); + _9 = Mul(_1, const 0_u64); + StorageDead(_10); _8 = opaque::<u64>(move _9) -> [return: bb3, unwind continue]; } @@ -106,11 +106,11 @@ StorageDead(_8); StorageLive(_11); StorageLive(_12); -- StorageLive(_13); -- _13 = _1; + StorageLive(_13); + _13 = _1; - _12 = Mul(move _13, const 1_u64); -- StorageDead(_13); + _12 = Mul(_1, const 1_u64); + StorageDead(_13); _11 = opaque::<u64>(move _12) -> [return: bb4, unwind continue]; } @@ -119,17 +119,18 @@ StorageDead(_11); StorageLive(_14); StorageLive(_15); -- StorageLive(_16); -- _16 = _1; - _17 = Eq(const 0_u64, const 0_u64); + StorageLive(_16); + _16 = _1; +- _17 = Eq(const 0_u64, const 0_u64); - assert(!move _17, "attempt to divide `{}` by zero", _16) -> [success: bb5, unwind continue]; -+ assert(!_17, "attempt to divide `{}` by zero", _1) -> [success: bb5, unwind continue]; ++ _17 = const true; ++ assert(!const true, "attempt to divide `{}` by zero", _1) -> [success: bb5, unwind continue]; } bb5: { - _15 = Div(move _16, const 0_u64); -- StorageDead(_16); + _15 = Div(_1, const 0_u64); + StorageDead(_16); _14 = opaque::<u64>(move _15) -> [return: bb6, unwind continue]; } @@ -138,17 +139,18 @@ StorageDead(_14); StorageLive(_18); StorageLive(_19); -- StorageLive(_20); -- _20 = _1; - _21 = Eq(const 1_u64, const 0_u64); + StorageLive(_20); + _20 = _1; +- _21 = Eq(const 1_u64, const 0_u64); - assert(!move _21, "attempt to divide `{}` by zero", _20) -> [success: bb7, unwind continue]; -+ assert(!_21, "attempt to divide `{}` by zero", _1) -> [success: bb7, unwind continue]; ++ _21 = const false; ++ assert(!const false, "attempt to divide `{}` by zero", _1) -> [success: bb7, unwind continue]; } bb7: { - _19 = Div(move _20, const 1_u64); -- StorageDead(_20); + _19 = Div(_1, const 1_u64); + StorageDead(_20); _18 = opaque::<u64>(move _19) -> [return: bb8, unwind continue]; } @@ -157,8 +159,8 @@ StorageDead(_18); StorageLive(_22); StorageLive(_23); -- StorageLive(_24); -- _24 = _1; + StorageLive(_24); + _24 = _1; - _25 = Eq(_24, const 0_u64); - assert(!move _25, "attempt to divide `{}` by zero", const 0_u64) -> [success: bb9, unwind continue]; + _25 = Eq(_1, const 0_u64); @@ -167,8 +169,8 @@ bb9: { - _23 = Div(const 0_u64, move _24); -- StorageDead(_24); + _23 = Div(const 0_u64, _1); + StorageDead(_24); _22 = opaque::<u64>(move _23) -> [return: bb10, unwind continue]; } @@ -177,17 +179,18 @@ StorageDead(_22); StorageLive(_26); StorageLive(_27); -- StorageLive(_28); -- _28 = _1; + StorageLive(_28); + _28 = _1; - _29 = Eq(_28, const 0_u64); - assert(!move _29, "attempt to divide `{}` by zero", const 1_u64) -> [success: bb11, unwind continue]; ++ _29 = _25; + assert(!_25, "attempt to divide `{}` by zero", const 1_u64) -> [success: bb11, unwind continue]; } bb11: { - _27 = Div(const 1_u64, move _28); -- StorageDead(_28); + _27 = Div(const 1_u64, _1); + StorageDead(_28); _26 = opaque::<u64>(move _27) -> [return: bb12, unwind continue]; } @@ -196,17 +199,18 @@ StorageDead(_26); StorageLive(_30); StorageLive(_31); -- StorageLive(_32); -- _32 = _1; + StorageLive(_32); + _32 = _1; - _33 = Eq(const 0_u64, const 0_u64); - assert(!move _33, "attempt to calculate the remainder of `{}` with a divisor of zero", _32) -> [success: bb13, unwind continue]; -+ assert(!_17, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb13, unwind continue]; ++ _33 = const true; ++ assert(!const true, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb13, unwind continue]; } bb13: { - _31 = Rem(move _32, const 0_u64); -- StorageDead(_32); + _31 = Rem(_1, const 0_u64); + StorageDead(_32); _30 = opaque::<u64>(move _31) -> [return: bb14, unwind continue]; } @@ -215,17 +219,18 @@ StorageDead(_30); StorageLive(_34); StorageLive(_35); -- StorageLive(_36); -- _36 = _1; + StorageLive(_36); + _36 = _1; - _37 = Eq(const 1_u64, const 0_u64); - assert(!move _37, "attempt to calculate the remainder of `{}` with a divisor of zero", _36) -> [success: bb15, unwind continue]; -+ assert(!_21, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb15, unwind continue]; ++ _37 = const false; ++ assert(!const false, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb15, unwind continue]; } bb15: { - _35 = Rem(move _36, const 1_u64); -- StorageDead(_36); + _35 = Rem(_1, const 1_u64); + StorageDead(_36); _34 = opaque::<u64>(move _35) -> [return: bb16, unwind continue]; } @@ -234,17 +239,18 @@ StorageDead(_34); StorageLive(_38); StorageLive(_39); -- StorageLive(_40); -- _40 = _1; + StorageLive(_40); + _40 = _1; - _41 = Eq(_40, const 0_u64); - assert(!move _41, "attempt to calculate the remainder of `{}` with a divisor of zero", const 0_u64) -> [success: bb17, unwind continue]; ++ _41 = _25; + assert(!_25, "attempt to calculate the remainder of `{}` with a divisor of zero", const 0_u64) -> [success: bb17, unwind continue]; } bb17: { - _39 = Rem(const 0_u64, move _40); -- StorageDead(_40); + _39 = Rem(const 0_u64, _1); + StorageDead(_40); _38 = opaque::<u64>(move _39) -> [return: bb18, unwind continue]; } @@ -253,17 +259,18 @@ StorageDead(_38); StorageLive(_42); StorageLive(_43); -- StorageLive(_44); -- _44 = _1; + StorageLive(_44); + _44 = _1; - _45 = Eq(_44, const 0_u64); - assert(!move _45, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_u64) -> [success: bb19, unwind continue]; ++ _45 = _25; + assert(!_25, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_u64) -> [success: bb19, unwind continue]; } bb19: { - _43 = Rem(const 1_u64, move _44); -- StorageDead(_44); + _43 = Rem(const 1_u64, _1); + StorageDead(_44); _42 = opaque::<u64>(move _43) -> [return: bb20, unwind continue]; } @@ -272,11 +279,11 @@ StorageDead(_42); StorageLive(_46); StorageLive(_47); -- StorageLive(_48); -- _48 = _1; + StorageLive(_48); + _48 = _1; - _47 = BitAnd(move _48, const 0_u64); -- StorageDead(_48); + _47 = BitAnd(_1, const 0_u64); + StorageDead(_48); _46 = opaque::<u64>(move _47) -> [return: bb21, unwind continue]; } @@ -285,11 +292,11 @@ StorageDead(_46); StorageLive(_49); StorageLive(_50); -- StorageLive(_51); -- _51 = _1; + StorageLive(_51); + _51 = _1; - _50 = BitOr(move _51, const 0_u64); -- StorageDead(_51); + _50 = BitOr(_1, const 0_u64); + StorageDead(_51); _49 = opaque::<u64>(move _50) -> [return: bb22, unwind continue]; } @@ -298,11 +305,11 @@ StorageDead(_49); StorageLive(_52); StorageLive(_53); -- StorageLive(_54); -- _54 = _1; + StorageLive(_54); + _54 = _1; - _53 = BitXor(move _54, const 0_u64); -- StorageDead(_54); + _53 = BitXor(_1, const 0_u64); + StorageDead(_54); _52 = opaque::<u64>(move _53) -> [return: bb23, unwind continue]; } @@ -311,11 +318,11 @@ StorageDead(_52); StorageLive(_55); StorageLive(_56); -- StorageLive(_57); -- _57 = _1; + StorageLive(_57); + _57 = _1; - _56 = Shr(move _57, const 0_i32); -- StorageDead(_57); + _56 = Shr(_1, const 0_i32); + StorageDead(_57); _55 = opaque::<u64>(move _56) -> [return: bb24, unwind continue]; } @@ -324,11 +331,11 @@ StorageDead(_55); StorageLive(_58); StorageLive(_59); -- StorageLive(_60); -- _60 = _1; + StorageLive(_60); + _60 = _1; - _59 = Shl(move _60, const 0_i32); -- StorageDead(_60); + _59 = Shl(_1, const 0_i32); + StorageDead(_60); _58 = opaque::<u64>(move _59) -> [return: bb25, unwind continue]; } diff --git a/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-abort.diff b/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-abort.diff index 0c342799e07..6633df3ae70 100644 --- a/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-abort.diff @@ -20,63 +20,12 @@ let mut _15: u64; let mut _16: u64; let mut _17: (u64, bool); - let _18: (); - let mut _19: u64; - let mut _20: u64; - let mut _21: bool; - let _22: (); - let mut _23: u64; - let mut _24: u64; - let mut _25: bool; - let _26: (); - let mut _27: u64; - let mut _28: u64; - let mut _29: bool; - let _30: (); - let mut _31: u64; - let mut _32: u64; - let mut _33: bool; - let _34: (); - let mut _35: u64; - let mut _36: u64; - let mut _37: bool; - let _38: (); - let mut _39: u64; - let mut _40: u64; - let mut _41: bool; - let _42: (); - let mut _43: u64; - let mut _44: u64; - let mut _45: bool; - let _46: (); - let mut _47: u64; - let mut _48: u64; - let mut _49: bool; - let _50: (); - let mut _51: u64; - let mut _52: u64; - let _53: (); - let mut _54: u64; - let mut _55: u64; - let _56: (); - let mut _57: u64; - let mut _58: u64; - let _59: (); - let mut _60: u64; - let mut _61: u64; - let mut _62: u32; - let mut _63: bool; - let _64: (); - let mut _65: u64; - let mut _66: u64; - let mut _67: u32; - let mut _68: bool; bb0: { StorageLive(_2); StorageLive(_3); -- StorageLive(_4); -- _4 = _1; + StorageLive(_4); + _4 = _1; - _5 = CheckedAdd(_4, const 0_u64); - assert(!move (_5.1: bool), "attempt to compute `{} + {}`, which would overflow", move _4, const 0_u64) -> [success: bb1, unwind unreachable]; + _5 = CheckedAdd(_1, const 0_u64); @@ -85,7 +34,7 @@ bb1: { _3 = move (_5.0: u64); -- StorageDead(_4); + StorageDead(_4); _2 = opaque::<u64>(move _3) -> [return: bb2, unwind unreachable]; } @@ -94,8 +43,8 @@ StorageDead(_2); StorageLive(_6); StorageLive(_7); -- StorageLive(_8); -- _8 = _1; + StorageLive(_8); + _8 = _1; - _9 = CheckedSub(_8, const 0_u64); - assert(!move (_9.1: bool), "attempt to compute `{} - {}`, which would overflow", move _8, const 0_u64) -> [success: bb3, unwind unreachable]; + _9 = CheckedSub(_1, const 0_u64); @@ -104,7 +53,7 @@ bb3: { _7 = move (_9.0: u64); -- StorageDead(_8); + StorageDead(_8); _6 = opaque::<u64>(move _7) -> [return: bb4, unwind unreachable]; } @@ -113,8 +62,8 @@ StorageDead(_6); StorageLive(_10); StorageLive(_11); -- StorageLive(_12); -- _12 = _1; + StorageLive(_12); + _12 = _1; - _13 = CheckedMul(_12, const 0_u64); - assert(!move (_13.1: bool), "attempt to compute `{} * {}`, which would overflow", move _12, const 0_u64) -> [success: bb5, unwind unreachable]; + _13 = CheckedMul(_1, const 0_u64); @@ -123,7 +72,7 @@ bb5: { _11 = move (_13.0: u64); -- StorageDead(_12); + StorageDead(_12); _10 = opaque::<u64>(move _11) -> [return: bb6, unwind unreachable]; } @@ -132,8 +81,8 @@ StorageDead(_10); StorageLive(_14); StorageLive(_15); -- StorageLive(_16); -- _16 = _1; + StorageLive(_16); + _16 = _1; - _17 = CheckedMul(_16, const 1_u64); - assert(!move (_17.1: bool), "attempt to compute `{} * {}`, which would overflow", move _16, const 1_u64) -> [success: bb7, unwind unreachable]; + _17 = CheckedMul(_1, const 1_u64); @@ -142,246 +91,13 @@ bb7: { _15 = move (_17.0: u64); -- StorageDead(_16); + StorageDead(_16); _14 = opaque::<u64>(move _15) -> [return: bb8, unwind unreachable]; } bb8: { StorageDead(_15); StorageDead(_14); - StorageLive(_18); - StorageLive(_19); -- StorageLive(_20); -- _20 = _1; - _21 = Eq(const 0_u64, const 0_u64); -- assert(!move _21, "attempt to divide `{}` by zero", _20) -> [success: bb9, unwind unreachable]; -+ assert(!_21, "attempt to divide `{}` by zero", _1) -> [success: bb9, unwind unreachable]; - } - - bb9: { -- _19 = Div(move _20, const 0_u64); -- StorageDead(_20); -+ _19 = Div(_1, const 0_u64); - _18 = opaque::<u64>(move _19) -> [return: bb10, unwind unreachable]; - } - - bb10: { - StorageDead(_19); - StorageDead(_18); - StorageLive(_22); - StorageLive(_23); -- StorageLive(_24); -- _24 = _1; - _25 = Eq(const 1_u64, const 0_u64); -- assert(!move _25, "attempt to divide `{}` by zero", _24) -> [success: bb11, unwind unreachable]; -+ assert(!_25, "attempt to divide `{}` by zero", _1) -> [success: bb11, unwind unreachable]; - } - - bb11: { -- _23 = Div(move _24, const 1_u64); -- StorageDead(_24); -+ _23 = Div(_1, const 1_u64); - _22 = opaque::<u64>(move _23) -> [return: bb12, unwind unreachable]; - } - - bb12: { - StorageDead(_23); - StorageDead(_22); - StorageLive(_26); - StorageLive(_27); -- StorageLive(_28); -- _28 = _1; -- _29 = Eq(_28, const 0_u64); -- assert(!move _29, "attempt to divide `{}` by zero", const 0_u64) -> [success: bb13, unwind unreachable]; -+ _29 = Eq(_1, const 0_u64); -+ assert(!_29, "attempt to divide `{}` by zero", const 0_u64) -> [success: bb13, unwind unreachable]; - } - - bb13: { -- _27 = Div(const 0_u64, move _28); -- StorageDead(_28); -+ _27 = Div(const 0_u64, _1); - _26 = opaque::<u64>(move _27) -> [return: bb14, unwind unreachable]; - } - - bb14: { - StorageDead(_27); - StorageDead(_26); - StorageLive(_30); - StorageLive(_31); -- StorageLive(_32); -- _32 = _1; -- _33 = Eq(_32, const 0_u64); -- assert(!move _33, "attempt to divide `{}` by zero", const 1_u64) -> [success: bb15, unwind unreachable]; -+ assert(!_29, "attempt to divide `{}` by zero", const 1_u64) -> [success: bb15, unwind unreachable]; - } - - bb15: { -- _31 = Div(const 1_u64, move _32); -- StorageDead(_32); -+ _31 = Div(const 1_u64, _1); - _30 = opaque::<u64>(move _31) -> [return: bb16, unwind unreachable]; - } - - bb16: { - StorageDead(_31); - StorageDead(_30); - StorageLive(_34); - StorageLive(_35); -- StorageLive(_36); -- _36 = _1; -- _37 = Eq(const 0_u64, const 0_u64); -- assert(!move _37, "attempt to calculate the remainder of `{}` with a divisor of zero", _36) -> [success: bb17, unwind unreachable]; -+ assert(!_21, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb17, unwind unreachable]; - } - - bb17: { -- _35 = Rem(move _36, const 0_u64); -- StorageDead(_36); -+ _35 = Rem(_1, const 0_u64); - _34 = opaque::<u64>(move _35) -> [return: bb18, unwind unreachable]; - } - - bb18: { - StorageDead(_35); - StorageDead(_34); - StorageLive(_38); - StorageLive(_39); -- StorageLive(_40); -- _40 = _1; -- _41 = Eq(const 1_u64, const 0_u64); -- assert(!move _41, "attempt to calculate the remainder of `{}` with a divisor of zero", _40) -> [success: bb19, unwind unreachable]; -+ assert(!_25, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb19, unwind unreachable]; - } - - bb19: { -- _39 = Rem(move _40, const 1_u64); -- StorageDead(_40); -+ _39 = Rem(_1, const 1_u64); - _38 = opaque::<u64>(move _39) -> [return: bb20, unwind unreachable]; - } - - bb20: { - StorageDead(_39); - StorageDead(_38); - StorageLive(_42); - StorageLive(_43); -- StorageLive(_44); -- _44 = _1; -- _45 = Eq(_44, const 0_u64); -- assert(!move _45, "attempt to calculate the remainder of `{}` with a divisor of zero", const 0_u64) -> [success: bb21, unwind unreachable]; -+ assert(!_29, "attempt to calculate the remainder of `{}` with a divisor of zero", const 0_u64) -> [success: bb21, unwind unreachable]; - } - - bb21: { -- _43 = Rem(const 0_u64, move _44); -- StorageDead(_44); -+ _43 = Rem(const 0_u64, _1); - _42 = opaque::<u64>(move _43) -> [return: bb22, unwind unreachable]; - } - - bb22: { - StorageDead(_43); - StorageDead(_42); - StorageLive(_46); - StorageLive(_47); -- StorageLive(_48); -- _48 = _1; -- _49 = Eq(_48, const 0_u64); -- assert(!move _49, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_u64) -> [success: bb23, unwind unreachable]; -+ assert(!_29, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_u64) -> [success: bb23, unwind unreachable]; - } - - bb23: { -- _47 = Rem(const 1_u64, move _48); -- StorageDead(_48); -+ _47 = Rem(const 1_u64, _1); - _46 = opaque::<u64>(move _47) -> [return: bb24, unwind unreachable]; - } - - bb24: { - StorageDead(_47); - StorageDead(_46); - StorageLive(_50); - StorageLive(_51); -- StorageLive(_52); -- _52 = _1; -- _51 = BitAnd(move _52, const 0_u64); -- StorageDead(_52); -+ _51 = BitAnd(_1, const 0_u64); - _50 = opaque::<u64>(move _51) -> [return: bb25, unwind unreachable]; - } - - bb25: { - StorageDead(_51); - StorageDead(_50); - StorageLive(_53); - StorageLive(_54); -- StorageLive(_55); -- _55 = _1; -- _54 = BitOr(move _55, const 0_u64); -- StorageDead(_55); -+ _54 = BitOr(_1, const 0_u64); - _53 = opaque::<u64>(move _54) -> [return: bb26, unwind unreachable]; - } - - bb26: { - StorageDead(_54); - StorageDead(_53); - StorageLive(_56); - StorageLive(_57); -- StorageLive(_58); -- _58 = _1; -- _57 = BitXor(move _58, const 0_u64); -- StorageDead(_58); -+ _57 = BitXor(_1, const 0_u64); - _56 = opaque::<u64>(move _57) -> [return: bb27, unwind unreachable]; - } - - bb27: { - StorageDead(_57); - StorageDead(_56); - StorageLive(_59); - StorageLive(_60); -- StorageLive(_61); -- _61 = _1; - _62 = const 0_i32 as u32 (IntToInt); -- _63 = Lt(move _62, const 64_u32); -- assert(move _63, "attempt to shift right by `{}`, which would overflow", const 0_i32) -> [success: bb28, unwind unreachable]; -+ _63 = Lt(_62, const 64_u32); -+ assert(_63, "attempt to shift right by `{}`, which would overflow", const 0_i32) -> [success: bb28, unwind unreachable]; - } - - bb28: { -- _60 = Shr(move _61, const 0_i32); -- StorageDead(_61); -+ _60 = Shr(_1, const 0_i32); - _59 = opaque::<u64>(move _60) -> [return: bb29, unwind unreachable]; - } - - bb29: { - StorageDead(_60); - StorageDead(_59); - StorageLive(_64); - StorageLive(_65); -- StorageLive(_66); -- _66 = _1; -- _67 = const 0_i32 as u32 (IntToInt); -- _68 = Lt(move _67, const 64_u32); -- assert(move _68, "attempt to shift left by `{}`, which would overflow", const 0_i32) -> [success: bb30, unwind unreachable]; -+ assert(_63, "attempt to shift left by `{}`, which would overflow", const 0_i32) -> [success: bb30, unwind unreachable]; - } - - bb30: { -- _65 = Shl(move _66, const 0_i32); -- StorageDead(_66); -+ _65 = Shl(_1, const 0_i32); - _64 = opaque::<u64>(move _65) -> [return: bb31, unwind unreachable]; - } - - bb31: { - StorageDead(_65); - StorageDead(_64); _0 = const (); return; } diff --git a/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-unwind.diff b/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-unwind.diff index 7813c29b962..d100a77fee5 100644 --- a/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.arithmetic_checked.GVN.panic-unwind.diff @@ -20,63 +20,12 @@ let mut _15: u64; let mut _16: u64; let mut _17: (u64, bool); - let _18: (); - let mut _19: u64; - let mut _20: u64; - let mut _21: bool; - let _22: (); - let mut _23: u64; - let mut _24: u64; - let mut _25: bool; - let _26: (); - let mut _27: u64; - let mut _28: u64; - let mut _29: bool; - let _30: (); - let mut _31: u64; - let mut _32: u64; - let mut _33: bool; - let _34: (); - let mut _35: u64; - let mut _36: u64; - let mut _37: bool; - let _38: (); - let mut _39: u64; - let mut _40: u64; - let mut _41: bool; - let _42: (); - let mut _43: u64; - let mut _44: u64; - let mut _45: bool; - let _46: (); - let mut _47: u64; - let mut _48: u64; - let mut _49: bool; - let _50: (); - let mut _51: u64; - let mut _52: u64; - let _53: (); - let mut _54: u64; - let mut _55: u64; - let _56: (); - let mut _57: u64; - let mut _58: u64; - let _59: (); - let mut _60: u64; - let mut _61: u64; - let mut _62: u32; - let mut _63: bool; - let _64: (); - let mut _65: u64; - let mut _66: u64; - let mut _67: u32; - let mut _68: bool; bb0: { StorageLive(_2); StorageLive(_3); -- StorageLive(_4); -- _4 = _1; + StorageLive(_4); + _4 = _1; - _5 = CheckedAdd(_4, const 0_u64); - assert(!move (_5.1: bool), "attempt to compute `{} + {}`, which would overflow", move _4, const 0_u64) -> [success: bb1, unwind continue]; + _5 = CheckedAdd(_1, const 0_u64); @@ -85,7 +34,7 @@ bb1: { _3 = move (_5.0: u64); -- StorageDead(_4); + StorageDead(_4); _2 = opaque::<u64>(move _3) -> [return: bb2, unwind continue]; } @@ -94,8 +43,8 @@ StorageDead(_2); StorageLive(_6); StorageLive(_7); -- StorageLive(_8); -- _8 = _1; + StorageLive(_8); + _8 = _1; - _9 = CheckedSub(_8, const 0_u64); - assert(!move (_9.1: bool), "attempt to compute `{} - {}`, which would overflow", move _8, const 0_u64) -> [success: bb3, unwind continue]; + _9 = CheckedSub(_1, const 0_u64); @@ -104,7 +53,7 @@ bb3: { _7 = move (_9.0: u64); -- StorageDead(_8); + StorageDead(_8); _6 = opaque::<u64>(move _7) -> [return: bb4, unwind continue]; } @@ -113,8 +62,8 @@ StorageDead(_6); StorageLive(_10); StorageLive(_11); -- StorageLive(_12); -- _12 = _1; + StorageLive(_12); + _12 = _1; - _13 = CheckedMul(_12, const 0_u64); - assert(!move (_13.1: bool), "attempt to compute `{} * {}`, which would overflow", move _12, const 0_u64) -> [success: bb5, unwind continue]; + _13 = CheckedMul(_1, const 0_u64); @@ -123,7 +72,7 @@ bb5: { _11 = move (_13.0: u64); -- StorageDead(_12); + StorageDead(_12); _10 = opaque::<u64>(move _11) -> [return: bb6, unwind continue]; } @@ -132,8 +81,8 @@ StorageDead(_10); StorageLive(_14); StorageLive(_15); -- StorageLive(_16); -- _16 = _1; + StorageLive(_16); + _16 = _1; - _17 = CheckedMul(_16, const 1_u64); - assert(!move (_17.1: bool), "attempt to compute `{} * {}`, which would overflow", move _16, const 1_u64) -> [success: bb7, unwind continue]; + _17 = CheckedMul(_1, const 1_u64); @@ -142,246 +91,13 @@ bb7: { _15 = move (_17.0: u64); -- StorageDead(_16); + StorageDead(_16); _14 = opaque::<u64>(move _15) -> [return: bb8, unwind continue]; } bb8: { StorageDead(_15); StorageDead(_14); - StorageLive(_18); - StorageLive(_19); -- StorageLive(_20); -- _20 = _1; - _21 = Eq(const 0_u64, const 0_u64); -- assert(!move _21, "attempt to divide `{}` by zero", _20) -> [success: bb9, unwind continue]; -+ assert(!_21, "attempt to divide `{}` by zero", _1) -> [success: bb9, unwind continue]; - } - - bb9: { -- _19 = Div(move _20, const 0_u64); -- StorageDead(_20); -+ _19 = Div(_1, const 0_u64); - _18 = opaque::<u64>(move _19) -> [return: bb10, unwind continue]; - } - - bb10: { - StorageDead(_19); - StorageDead(_18); - StorageLive(_22); - StorageLive(_23); -- StorageLive(_24); -- _24 = _1; - _25 = Eq(const 1_u64, const 0_u64); -- assert(!move _25, "attempt to divide `{}` by zero", _24) -> [success: bb11, unwind continue]; -+ assert(!_25, "attempt to divide `{}` by zero", _1) -> [success: bb11, unwind continue]; - } - - bb11: { -- _23 = Div(move _24, const 1_u64); -- StorageDead(_24); -+ _23 = Div(_1, const 1_u64); - _22 = opaque::<u64>(move _23) -> [return: bb12, unwind continue]; - } - - bb12: { - StorageDead(_23); - StorageDead(_22); - StorageLive(_26); - StorageLive(_27); -- StorageLive(_28); -- _28 = _1; -- _29 = Eq(_28, const 0_u64); -- assert(!move _29, "attempt to divide `{}` by zero", const 0_u64) -> [success: bb13, unwind continue]; -+ _29 = Eq(_1, const 0_u64); -+ assert(!_29, "attempt to divide `{}` by zero", const 0_u64) -> [success: bb13, unwind continue]; - } - - bb13: { -- _27 = Div(const 0_u64, move _28); -- StorageDead(_28); -+ _27 = Div(const 0_u64, _1); - _26 = opaque::<u64>(move _27) -> [return: bb14, unwind continue]; - } - - bb14: { - StorageDead(_27); - StorageDead(_26); - StorageLive(_30); - StorageLive(_31); -- StorageLive(_32); -- _32 = _1; -- _33 = Eq(_32, const 0_u64); -- assert(!move _33, "attempt to divide `{}` by zero", const 1_u64) -> [success: bb15, unwind continue]; -+ assert(!_29, "attempt to divide `{}` by zero", const 1_u64) -> [success: bb15, unwind continue]; - } - - bb15: { -- _31 = Div(const 1_u64, move _32); -- StorageDead(_32); -+ _31 = Div(const 1_u64, _1); - _30 = opaque::<u64>(move _31) -> [return: bb16, unwind continue]; - } - - bb16: { - StorageDead(_31); - StorageDead(_30); - StorageLive(_34); - StorageLive(_35); -- StorageLive(_36); -- _36 = _1; -- _37 = Eq(const 0_u64, const 0_u64); -- assert(!move _37, "attempt to calculate the remainder of `{}` with a divisor of zero", _36) -> [success: bb17, unwind continue]; -+ assert(!_21, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb17, unwind continue]; - } - - bb17: { -- _35 = Rem(move _36, const 0_u64); -- StorageDead(_36); -+ _35 = Rem(_1, const 0_u64); - _34 = opaque::<u64>(move _35) -> [return: bb18, unwind continue]; - } - - bb18: { - StorageDead(_35); - StorageDead(_34); - StorageLive(_38); - StorageLive(_39); -- StorageLive(_40); -- _40 = _1; -- _41 = Eq(const 1_u64, const 0_u64); -- assert(!move _41, "attempt to calculate the remainder of `{}` with a divisor of zero", _40) -> [success: bb19, unwind continue]; -+ assert(!_25, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb19, unwind continue]; - } - - bb19: { -- _39 = Rem(move _40, const 1_u64); -- StorageDead(_40); -+ _39 = Rem(_1, const 1_u64); - _38 = opaque::<u64>(move _39) -> [return: bb20, unwind continue]; - } - - bb20: { - StorageDead(_39); - StorageDead(_38); - StorageLive(_42); - StorageLive(_43); -- StorageLive(_44); -- _44 = _1; -- _45 = Eq(_44, const 0_u64); -- assert(!move _45, "attempt to calculate the remainder of `{}` with a divisor of zero", const 0_u64) -> [success: bb21, unwind continue]; -+ assert(!_29, "attempt to calculate the remainder of `{}` with a divisor of zero", const 0_u64) -> [success: bb21, unwind continue]; - } - - bb21: { -- _43 = Rem(const 0_u64, move _44); -- StorageDead(_44); -+ _43 = Rem(const 0_u64, _1); - _42 = opaque::<u64>(move _43) -> [return: bb22, unwind continue]; - } - - bb22: { - StorageDead(_43); - StorageDead(_42); - StorageLive(_46); - StorageLive(_47); -- StorageLive(_48); -- _48 = _1; -- _49 = Eq(_48, const 0_u64); -- assert(!move _49, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_u64) -> [success: bb23, unwind continue]; -+ assert(!_29, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_u64) -> [success: bb23, unwind continue]; - } - - bb23: { -- _47 = Rem(const 1_u64, move _48); -- StorageDead(_48); -+ _47 = Rem(const 1_u64, _1); - _46 = opaque::<u64>(move _47) -> [return: bb24, unwind continue]; - } - - bb24: { - StorageDead(_47); - StorageDead(_46); - StorageLive(_50); - StorageLive(_51); -- StorageLive(_52); -- _52 = _1; -- _51 = BitAnd(move _52, const 0_u64); -- StorageDead(_52); -+ _51 = BitAnd(_1, const 0_u64); - _50 = opaque::<u64>(move _51) -> [return: bb25, unwind continue]; - } - - bb25: { - StorageDead(_51); - StorageDead(_50); - StorageLive(_53); - StorageLive(_54); -- StorageLive(_55); -- _55 = _1; -- _54 = BitOr(move _55, const 0_u64); -- StorageDead(_55); -+ _54 = BitOr(_1, const 0_u64); - _53 = opaque::<u64>(move _54) -> [return: bb26, unwind continue]; - } - - bb26: { - StorageDead(_54); - StorageDead(_53); - StorageLive(_56); - StorageLive(_57); -- StorageLive(_58); -- _58 = _1; -- _57 = BitXor(move _58, const 0_u64); -- StorageDead(_58); -+ _57 = BitXor(_1, const 0_u64); - _56 = opaque::<u64>(move _57) -> [return: bb27, unwind continue]; - } - - bb27: { - StorageDead(_57); - StorageDead(_56); - StorageLive(_59); - StorageLive(_60); -- StorageLive(_61); -- _61 = _1; - _62 = const 0_i32 as u32 (IntToInt); -- _63 = Lt(move _62, const 64_u32); -- assert(move _63, "attempt to shift right by `{}`, which would overflow", const 0_i32) -> [success: bb28, unwind continue]; -+ _63 = Lt(_62, const 64_u32); -+ assert(_63, "attempt to shift right by `{}`, which would overflow", const 0_i32) -> [success: bb28, unwind continue]; - } - - bb28: { -- _60 = Shr(move _61, const 0_i32); -- StorageDead(_61); -+ _60 = Shr(_1, const 0_i32); - _59 = opaque::<u64>(move _60) -> [return: bb29, unwind continue]; - } - - bb29: { - StorageDead(_60); - StorageDead(_59); - StorageLive(_64); - StorageLive(_65); -- StorageLive(_66); -- _66 = _1; -- _67 = const 0_i32 as u32 (IntToInt); -- _68 = Lt(move _67, const 64_u32); -- assert(move _68, "attempt to shift left by `{}`, which would overflow", const 0_i32) -> [success: bb30, unwind continue]; -+ assert(_63, "attempt to shift left by `{}`, which would overflow", const 0_i32) -> [success: bb30, unwind continue]; - } - - bb30: { -- _65 = Shl(move _66, const 0_i32); -- StorageDead(_66); -+ _65 = Shl(_1, const 0_i32); - _64 = opaque::<u64>(move _65) -> [return: bb31, unwind continue]; - } - - bb31: { - StorageDead(_65); - StorageDead(_64); _0 = const (); return; } diff --git a/tests/mir-opt/gvn.arithmetic_float.GVN.panic-abort.diff b/tests/mir-opt/gvn.arithmetic_float.GVN.panic-abort.diff index 7d5ac8353fe..b332100eaf0 100644 --- a/tests/mir-opt/gvn.arithmetic_float.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.arithmetic_float.GVN.panic-abort.diff @@ -37,11 +37,11 @@ bb0: { StorageLive(_2); StorageLive(_3); -- StorageLive(_4); -- _4 = _1; + StorageLive(_4); + _4 = _1; - _3 = Add(move _4, const 0f64); -- StorageDead(_4); + _3 = Add(_1, const 0f64); + StorageDead(_4); _2 = opaque::<f64>(move _3) -> [return: bb1, unwind unreachable]; } @@ -50,11 +50,11 @@ StorageDead(_2); StorageLive(_5); StorageLive(_6); -- StorageLive(_7); -- _7 = _1; + StorageLive(_7); + _7 = _1; - _6 = Sub(move _7, const 0f64); -- StorageDead(_7); + _6 = Sub(_1, const 0f64); + StorageDead(_7); _5 = opaque::<f64>(move _6) -> [return: bb2, unwind unreachable]; } @@ -63,11 +63,11 @@ StorageDead(_5); StorageLive(_8); StorageLive(_9); -- StorageLive(_10); -- _10 = _1; + StorageLive(_10); + _10 = _1; - _9 = Mul(move _10, const 0f64); -- StorageDead(_10); + _9 = Mul(_1, const 0f64); + StorageDead(_10); _8 = opaque::<f64>(move _9) -> [return: bb3, unwind unreachable]; } @@ -76,11 +76,11 @@ StorageDead(_8); StorageLive(_11); StorageLive(_12); -- StorageLive(_13); -- _13 = _1; + StorageLive(_13); + _13 = _1; - _12 = Div(move _13, const 0f64); -- StorageDead(_13); + _12 = Div(_1, const 0f64); + StorageDead(_13); _11 = opaque::<f64>(move _12) -> [return: bb4, unwind unreachable]; } @@ -89,11 +89,11 @@ StorageDead(_11); StorageLive(_14); StorageLive(_15); -- StorageLive(_16); -- _16 = _1; + StorageLive(_16); + _16 = _1; - _15 = Div(const 0f64, move _16); -- StorageDead(_16); + _15 = Div(const 0f64, _1); + StorageDead(_16); _14 = opaque::<f64>(move _15) -> [return: bb5, unwind unreachable]; } @@ -102,11 +102,11 @@ StorageDead(_14); StorageLive(_17); StorageLive(_18); -- StorageLive(_19); -- _19 = _1; + StorageLive(_19); + _19 = _1; - _18 = Rem(move _19, const 0f64); -- StorageDead(_19); + _18 = Rem(_1, const 0f64); + StorageDead(_19); _17 = opaque::<f64>(move _18) -> [return: bb6, unwind unreachable]; } @@ -115,11 +115,11 @@ StorageDead(_17); StorageLive(_20); StorageLive(_21); -- StorageLive(_22); -- _22 = _1; + StorageLive(_22); + _22 = _1; - _21 = Rem(const 0f64, move _22); -- StorageDead(_22); + _21 = Rem(const 0f64, _1); + StorageDead(_22); _20 = opaque::<f64>(move _21) -> [return: bb7, unwind unreachable]; } @@ -128,14 +128,14 @@ StorageDead(_20); StorageLive(_23); StorageLive(_24); -- StorageLive(_25); -- _25 = _1; -- StorageLive(_26); -- _26 = _1; + StorageLive(_25); + _25 = _1; + StorageLive(_26); + _26 = _1; - _24 = Eq(move _25, move _26); -- StorageDead(_26); -- StorageDead(_25); + _24 = Eq(_1, _1); + StorageDead(_26); + StorageDead(_25); _23 = opaque::<bool>(move _24) -> [return: bb8, unwind unreachable]; } @@ -144,14 +144,14 @@ StorageDead(_23); StorageLive(_27); StorageLive(_28); -- StorageLive(_29); -- _29 = _1; -- StorageLive(_30); -- _30 = _1; + StorageLive(_29); + _29 = _1; + StorageLive(_30); + _30 = _1; - _28 = Ne(move _29, move _30); -- StorageDead(_30); -- StorageDead(_29); + _28 = Ne(_1, _1); + StorageDead(_30); + StorageDead(_29); _27 = opaque::<bool>(move _28) -> [return: bb9, unwind unreachable]; } diff --git a/tests/mir-opt/gvn.arithmetic_float.GVN.panic-unwind.diff b/tests/mir-opt/gvn.arithmetic_float.GVN.panic-unwind.diff index 36c26dc6605..28664cb0ac8 100644 --- a/tests/mir-opt/gvn.arithmetic_float.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.arithmetic_float.GVN.panic-unwind.diff @@ -37,11 +37,11 @@ bb0: { StorageLive(_2); StorageLive(_3); -- StorageLive(_4); -- _4 = _1; + StorageLive(_4); + _4 = _1; - _3 = Add(move _4, const 0f64); -- StorageDead(_4); + _3 = Add(_1, const 0f64); + StorageDead(_4); _2 = opaque::<f64>(move _3) -> [return: bb1, unwind continue]; } @@ -50,11 +50,11 @@ StorageDead(_2); StorageLive(_5); StorageLive(_6); -- StorageLive(_7); -- _7 = _1; + StorageLive(_7); + _7 = _1; - _6 = Sub(move _7, const 0f64); -- StorageDead(_7); + _6 = Sub(_1, const 0f64); + StorageDead(_7); _5 = opaque::<f64>(move _6) -> [return: bb2, unwind continue]; } @@ -63,11 +63,11 @@ StorageDead(_5); StorageLive(_8); StorageLive(_9); -- StorageLive(_10); -- _10 = _1; + StorageLive(_10); + _10 = _1; - _9 = Mul(move _10, const 0f64); -- StorageDead(_10); + _9 = Mul(_1, const 0f64); + StorageDead(_10); _8 = opaque::<f64>(move _9) -> [return: bb3, unwind continue]; } @@ -76,11 +76,11 @@ StorageDead(_8); StorageLive(_11); StorageLive(_12); -- StorageLive(_13); -- _13 = _1; + StorageLive(_13); + _13 = _1; - _12 = Div(move _13, const 0f64); -- StorageDead(_13); + _12 = Div(_1, const 0f64); + StorageDead(_13); _11 = opaque::<f64>(move _12) -> [return: bb4, unwind continue]; } @@ -89,11 +89,11 @@ StorageDead(_11); StorageLive(_14); StorageLive(_15); -- StorageLive(_16); -- _16 = _1; + StorageLive(_16); + _16 = _1; - _15 = Div(const 0f64, move _16); -- StorageDead(_16); + _15 = Div(const 0f64, _1); + StorageDead(_16); _14 = opaque::<f64>(move _15) -> [return: bb5, unwind continue]; } @@ -102,11 +102,11 @@ StorageDead(_14); StorageLive(_17); StorageLive(_18); -- StorageLive(_19); -- _19 = _1; + StorageLive(_19); + _19 = _1; - _18 = Rem(move _19, const 0f64); -- StorageDead(_19); + _18 = Rem(_1, const 0f64); + StorageDead(_19); _17 = opaque::<f64>(move _18) -> [return: bb6, unwind continue]; } @@ -115,11 +115,11 @@ StorageDead(_17); StorageLive(_20); StorageLive(_21); -- StorageLive(_22); -- _22 = _1; + StorageLive(_22); + _22 = _1; - _21 = Rem(const 0f64, move _22); -- StorageDead(_22); + _21 = Rem(const 0f64, _1); + StorageDead(_22); _20 = opaque::<f64>(move _21) -> [return: bb7, unwind continue]; } @@ -128,14 +128,14 @@ StorageDead(_20); StorageLive(_23); StorageLive(_24); -- StorageLive(_25); -- _25 = _1; -- StorageLive(_26); -- _26 = _1; + StorageLive(_25); + _25 = _1; + StorageLive(_26); + _26 = _1; - _24 = Eq(move _25, move _26); -- StorageDead(_26); -- StorageDead(_25); + _24 = Eq(_1, _1); + StorageDead(_26); + StorageDead(_25); _23 = opaque::<bool>(move _24) -> [return: bb8, unwind continue]; } @@ -144,14 +144,14 @@ StorageDead(_23); StorageLive(_27); StorageLive(_28); -- StorageLive(_29); -- _29 = _1; -- StorageLive(_30); -- _30 = _1; + StorageLive(_29); + _29 = _1; + StorageLive(_30); + _30 = _1; - _28 = Ne(move _29, move _30); -- StorageDead(_30); -- StorageDead(_29); + _28 = Ne(_1, _1); + StorageDead(_30); + StorageDead(_29); _27 = opaque::<bool>(move _28) -> [return: bb9, unwind continue]; } diff --git a/tests/mir-opt/gvn.cast.GVN.panic-abort.diff b/tests/mir-opt/gvn.cast.GVN.panic-abort.diff index 513fe60b65d..d43198c9911 100644 --- a/tests/mir-opt/gvn.cast.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.cast.GVN.panic-abort.diff @@ -105,19 +105,24 @@ bb0: { - StorageLive(_1); ++ nop; _1 = const 1_i64; - StorageLive(_2); ++ nop; _2 = const 1_u64; - StorageLive(_3); ++ nop; _3 = const 1f64; StorageLive(_4); StorageLive(_5); -- StorageLive(_6); + StorageLive(_6); - _6 = _1; - _5 = move _6 as u8 (IntToInt); -- StorageDead(_6); -+ _5 = const 1_i64 as u8 (IntToInt); - _4 = opaque::<u8>(move _5) -> [return: bb1, unwind unreachable]; ++ _6 = const 1_i64; ++ _5 = const 1_u8; + StorageDead(_6); +- _4 = opaque::<u8>(move _5) -> [return: bb1, unwind unreachable]; ++ _4 = opaque::<u8>(const 1_u8) -> [return: bb1, unwind unreachable]; } bb1: { @@ -125,12 +130,14 @@ StorageDead(_4); StorageLive(_7); StorageLive(_8); -- StorageLive(_9); + StorageLive(_9); - _9 = _1; - _8 = move _9 as u16 (IntToInt); -- StorageDead(_9); -+ _8 = const 1_i64 as u16 (IntToInt); - _7 = opaque::<u16>(move _8) -> [return: bb2, unwind unreachable]; ++ _9 = const 1_i64; ++ _8 = const 1_u16; + StorageDead(_9); +- _7 = opaque::<u16>(move _8) -> [return: bb2, unwind unreachable]; ++ _7 = opaque::<u16>(const 1_u16) -> [return: bb2, unwind unreachable]; } bb2: { @@ -138,12 +145,14 @@ StorageDead(_7); StorageLive(_10); StorageLive(_11); -- StorageLive(_12); + StorageLive(_12); - _12 = _1; - _11 = move _12 as u32 (IntToInt); -- StorageDead(_12); -+ _11 = const 1_i64 as u32 (IntToInt); - _10 = opaque::<u32>(move _11) -> [return: bb3, unwind unreachable]; ++ _12 = const 1_i64; ++ _11 = const 1_u32; + StorageDead(_12); +- _10 = opaque::<u32>(move _11) -> [return: bb3, unwind unreachable]; ++ _10 = opaque::<u32>(const 1_u32) -> [return: bb3, unwind unreachable]; } bb3: { @@ -151,12 +160,14 @@ StorageDead(_10); StorageLive(_13); StorageLive(_14); -- StorageLive(_15); + StorageLive(_15); - _15 = _1; - _14 = move _15 as u64 (IntToInt); -- StorageDead(_15); -+ _14 = const 1_i64 as u64 (IntToInt); - _13 = opaque::<u64>(move _14) -> [return: bb4, unwind unreachable]; ++ _15 = const 1_i64; ++ _14 = const 1_u64; + StorageDead(_15); +- _13 = opaque::<u64>(move _14) -> [return: bb4, unwind unreachable]; ++ _13 = opaque::<u64>(const 1_u64) -> [return: bb4, unwind unreachable]; } bb4: { @@ -164,12 +175,14 @@ StorageDead(_13); StorageLive(_16); StorageLive(_17); -- StorageLive(_18); + StorageLive(_18); - _18 = _1; - _17 = move _18 as i8 (IntToInt); -- StorageDead(_18); -+ _17 = const 1_i64 as i8 (IntToInt); - _16 = opaque::<i8>(move _17) -> [return: bb5, unwind unreachable]; ++ _18 = const 1_i64; ++ _17 = const 1_i8; + StorageDead(_18); +- _16 = opaque::<i8>(move _17) -> [return: bb5, unwind unreachable]; ++ _16 = opaque::<i8>(const 1_i8) -> [return: bb5, unwind unreachable]; } bb5: { @@ -177,12 +190,14 @@ StorageDead(_16); StorageLive(_19); StorageLive(_20); -- StorageLive(_21); + StorageLive(_21); - _21 = _1; - _20 = move _21 as i16 (IntToInt); -- StorageDead(_21); -+ _20 = const 1_i64 as i16 (IntToInt); - _19 = opaque::<i16>(move _20) -> [return: bb6, unwind unreachable]; ++ _21 = const 1_i64; ++ _20 = const 1_i16; + StorageDead(_21); +- _19 = opaque::<i16>(move _20) -> [return: bb6, unwind unreachable]; ++ _19 = opaque::<i16>(const 1_i16) -> [return: bb6, unwind unreachable]; } bb6: { @@ -190,35 +205,40 @@ StorageDead(_19); StorageLive(_22); StorageLive(_23); -- StorageLive(_24); + StorageLive(_24); - _24 = _1; - _23 = move _24 as i32 (IntToInt); -- StorageDead(_24); -+ _23 = const 1_i64 as i32 (IntToInt); - _22 = opaque::<i32>(move _23) -> [return: bb7, unwind unreachable]; ++ _24 = const 1_i64; ++ _23 = const 1_i32; + StorageDead(_24); +- _22 = opaque::<i32>(move _23) -> [return: bb7, unwind unreachable]; ++ _22 = opaque::<i32>(const 1_i32) -> [return: bb7, unwind unreachable]; } bb7: { StorageDead(_23); StorageDead(_22); StorageLive(_25); -- StorageLive(_26); + StorageLive(_26); - _26 = _1; - _25 = opaque::<i64>(move _26) -> [return: bb8, unwind unreachable]; ++ _26 = const 1_i64; + _25 = opaque::<i64>(const 1_i64) -> [return: bb8, unwind unreachable]; } bb8: { -- StorageDead(_26); + StorageDead(_26); StorageDead(_25); StorageLive(_27); StorageLive(_28); -- StorageLive(_29); + StorageLive(_29); - _29 = _1; - _28 = move _29 as f32 (IntToFloat); -- StorageDead(_29); -+ _28 = const 1_i64 as f32 (IntToFloat); - _27 = opaque::<f32>(move _28) -> [return: bb9, unwind unreachable]; ++ _29 = const 1_i64; ++ _28 = const 1f32; + StorageDead(_29); +- _27 = opaque::<f32>(move _28) -> [return: bb9, unwind unreachable]; ++ _27 = opaque::<f32>(const 1f32) -> [return: bb9, unwind unreachable]; } bb9: { @@ -226,12 +246,14 @@ StorageDead(_27); StorageLive(_30); StorageLive(_31); -- StorageLive(_32); + StorageLive(_32); - _32 = _1; - _31 = move _32 as f64 (IntToFloat); -- StorageDead(_32); -+ _31 = const 1_i64 as f64 (IntToFloat); - _30 = opaque::<f64>(move _31) -> [return: bb10, unwind unreachable]; ++ _32 = const 1_i64; ++ _31 = const 1f64; + StorageDead(_32); +- _30 = opaque::<f64>(move _31) -> [return: bb10, unwind unreachable]; ++ _30 = opaque::<f64>(const 1f64) -> [return: bb10, unwind unreachable]; } bb10: { @@ -239,12 +261,14 @@ StorageDead(_30); StorageLive(_33); StorageLive(_34); -- StorageLive(_35); + StorageLive(_35); - _35 = _2; - _34 = move _35 as u8 (IntToInt); -- StorageDead(_35); -+ _34 = const 1_u64 as u8 (IntToInt); - _33 = opaque::<u8>(move _34) -> [return: bb11, unwind unreachable]; ++ _35 = const 1_u64; ++ _34 = const 1_u8; + StorageDead(_35); +- _33 = opaque::<u8>(move _34) -> [return: bb11, unwind unreachable]; ++ _33 = opaque::<u8>(const 1_u8) -> [return: bb11, unwind unreachable]; } bb11: { @@ -252,12 +276,14 @@ StorageDead(_33); StorageLive(_36); StorageLive(_37); -- StorageLive(_38); + StorageLive(_38); - _38 = _2; - _37 = move _38 as u16 (IntToInt); -- StorageDead(_38); -+ _37 = const 1_u64 as u16 (IntToInt); - _36 = opaque::<u16>(move _37) -> [return: bb12, unwind unreachable]; ++ _38 = const 1_u64; ++ _37 = const 1_u16; + StorageDead(_38); +- _36 = opaque::<u16>(move _37) -> [return: bb12, unwind unreachable]; ++ _36 = opaque::<u16>(const 1_u16) -> [return: bb12, unwind unreachable]; } bb12: { @@ -265,35 +291,40 @@ StorageDead(_36); StorageLive(_39); StorageLive(_40); -- StorageLive(_41); + StorageLive(_41); - _41 = _2; - _40 = move _41 as u32 (IntToInt); -- StorageDead(_41); -+ _40 = const 1_u64 as u32 (IntToInt); - _39 = opaque::<u32>(move _40) -> [return: bb13, unwind unreachable]; ++ _41 = const 1_u64; ++ _40 = const 1_u32; + StorageDead(_41); +- _39 = opaque::<u32>(move _40) -> [return: bb13, unwind unreachable]; ++ _39 = opaque::<u32>(const 1_u32) -> [return: bb13, unwind unreachable]; } bb13: { StorageDead(_40); StorageDead(_39); StorageLive(_42); -- StorageLive(_43); + StorageLive(_43); - _43 = _2; - _42 = opaque::<u64>(move _43) -> [return: bb14, unwind unreachable]; ++ _43 = const 1_u64; + _42 = opaque::<u64>(const 1_u64) -> [return: bb14, unwind unreachable]; } bb14: { -- StorageDead(_43); + StorageDead(_43); StorageDead(_42); StorageLive(_44); StorageLive(_45); -- StorageLive(_46); + StorageLive(_46); - _46 = _2; - _45 = move _46 as i8 (IntToInt); -- StorageDead(_46); -+ _45 = const 1_u64 as i8 (IntToInt); - _44 = opaque::<i8>(move _45) -> [return: bb15, unwind unreachable]; ++ _46 = const 1_u64; ++ _45 = const 1_i8; + StorageDead(_46); +- _44 = opaque::<i8>(move _45) -> [return: bb15, unwind unreachable]; ++ _44 = opaque::<i8>(const 1_i8) -> [return: bb15, unwind unreachable]; } bb15: { @@ -301,12 +332,14 @@ StorageDead(_44); StorageLive(_47); StorageLive(_48); -- StorageLive(_49); + StorageLive(_49); - _49 = _2; - _48 = move _49 as i16 (IntToInt); -- StorageDead(_49); -+ _48 = const 1_u64 as i16 (IntToInt); - _47 = opaque::<i16>(move _48) -> [return: bb16, unwind unreachable]; ++ _49 = const 1_u64; ++ _48 = const 1_i16; + StorageDead(_49); +- _47 = opaque::<i16>(move _48) -> [return: bb16, unwind unreachable]; ++ _47 = opaque::<i16>(const 1_i16) -> [return: bb16, unwind unreachable]; } bb16: { @@ -314,12 +347,14 @@ StorageDead(_47); StorageLive(_50); StorageLive(_51); -- StorageLive(_52); + StorageLive(_52); - _52 = _2; - _51 = move _52 as i32 (IntToInt); -- StorageDead(_52); -+ _51 = const 1_u64 as i32 (IntToInt); - _50 = opaque::<i32>(move _51) -> [return: bb17, unwind unreachable]; ++ _52 = const 1_u64; ++ _51 = const 1_i32; + StorageDead(_52); +- _50 = opaque::<i32>(move _51) -> [return: bb17, unwind unreachable]; ++ _50 = opaque::<i32>(const 1_i32) -> [return: bb17, unwind unreachable]; } bb17: { @@ -327,12 +362,14 @@ StorageDead(_50); StorageLive(_53); StorageLive(_54); -- StorageLive(_55); + StorageLive(_55); - _55 = _2; - _54 = move _55 as i64 (IntToInt); -- StorageDead(_55); -+ _54 = const 1_u64 as i64 (IntToInt); - _53 = opaque::<i64>(move _54) -> [return: bb18, unwind unreachable]; ++ _55 = const 1_u64; ++ _54 = const 1_i64; + StorageDead(_55); +- _53 = opaque::<i64>(move _54) -> [return: bb18, unwind unreachable]; ++ _53 = opaque::<i64>(const 1_i64) -> [return: bb18, unwind unreachable]; } bb18: { @@ -340,12 +377,14 @@ StorageDead(_53); StorageLive(_56); StorageLive(_57); -- StorageLive(_58); + StorageLive(_58); - _58 = _2; - _57 = move _58 as f32 (IntToFloat); -- StorageDead(_58); -+ _57 = const 1_u64 as f32 (IntToFloat); - _56 = opaque::<f32>(move _57) -> [return: bb19, unwind unreachable]; ++ _58 = const 1_u64; ++ _57 = const 1f32; + StorageDead(_58); +- _56 = opaque::<f32>(move _57) -> [return: bb19, unwind unreachable]; ++ _56 = opaque::<f32>(const 1f32) -> [return: bb19, unwind unreachable]; } bb19: { @@ -353,12 +392,14 @@ StorageDead(_56); StorageLive(_59); StorageLive(_60); -- StorageLive(_61); + StorageLive(_61); - _61 = _2; - _60 = move _61 as f64 (IntToFloat); -- StorageDead(_61); -+ _60 = const 1_u64 as f64 (IntToFloat); - _59 = opaque::<f64>(move _60) -> [return: bb20, unwind unreachable]; ++ _61 = const 1_u64; ++ _60 = const 1f64; + StorageDead(_61); +- _59 = opaque::<f64>(move _60) -> [return: bb20, unwind unreachable]; ++ _59 = opaque::<f64>(const 1f64) -> [return: bb20, unwind unreachable]; } bb20: { @@ -366,12 +407,14 @@ StorageDead(_59); StorageLive(_62); StorageLive(_63); -- StorageLive(_64); + StorageLive(_64); - _64 = _3; - _63 = move _64 as u8 (FloatToInt); -- StorageDead(_64); -+ _63 = const 1f64 as u8 (FloatToInt); - _62 = opaque::<u8>(move _63) -> [return: bb21, unwind unreachable]; ++ _64 = const 1f64; ++ _63 = const 1_u8; + StorageDead(_64); +- _62 = opaque::<u8>(move _63) -> [return: bb21, unwind unreachable]; ++ _62 = opaque::<u8>(const 1_u8) -> [return: bb21, unwind unreachable]; } bb21: { @@ -379,12 +422,14 @@ StorageDead(_62); StorageLive(_65); StorageLive(_66); -- StorageLive(_67); + StorageLive(_67); - _67 = _3; - _66 = move _67 as u16 (FloatToInt); -- StorageDead(_67); -+ _66 = const 1f64 as u16 (FloatToInt); - _65 = opaque::<u16>(move _66) -> [return: bb22, unwind unreachable]; ++ _67 = const 1f64; ++ _66 = const 1_u16; + StorageDead(_67); +- _65 = opaque::<u16>(move _66) -> [return: bb22, unwind unreachable]; ++ _65 = opaque::<u16>(const 1_u16) -> [return: bb22, unwind unreachable]; } bb22: { @@ -392,12 +437,14 @@ StorageDead(_65); StorageLive(_68); StorageLive(_69); -- StorageLive(_70); + StorageLive(_70); - _70 = _3; - _69 = move _70 as u32 (FloatToInt); -- StorageDead(_70); -+ _69 = const 1f64 as u32 (FloatToInt); - _68 = opaque::<u32>(move _69) -> [return: bb23, unwind unreachable]; ++ _70 = const 1f64; ++ _69 = const 1_u32; + StorageDead(_70); +- _68 = opaque::<u32>(move _69) -> [return: bb23, unwind unreachable]; ++ _68 = opaque::<u32>(const 1_u32) -> [return: bb23, unwind unreachable]; } bb23: { @@ -405,12 +452,14 @@ StorageDead(_68); StorageLive(_71); StorageLive(_72); -- StorageLive(_73); + StorageLive(_73); - _73 = _3; - _72 = move _73 as u64 (FloatToInt); -- StorageDead(_73); -+ _72 = const 1f64 as u64 (FloatToInt); - _71 = opaque::<u64>(move _72) -> [return: bb24, unwind unreachable]; ++ _73 = const 1f64; ++ _72 = const 1_u64; + StorageDead(_73); +- _71 = opaque::<u64>(move _72) -> [return: bb24, unwind unreachable]; ++ _71 = opaque::<u64>(const 1_u64) -> [return: bb24, unwind unreachable]; } bb24: { @@ -418,12 +467,14 @@ StorageDead(_71); StorageLive(_74); StorageLive(_75); -- StorageLive(_76); + StorageLive(_76); - _76 = _3; - _75 = move _76 as i8 (FloatToInt); -- StorageDead(_76); -+ _75 = const 1f64 as i8 (FloatToInt); - _74 = opaque::<i8>(move _75) -> [return: bb25, unwind unreachable]; ++ _76 = const 1f64; ++ _75 = const 1_i8; + StorageDead(_76); +- _74 = opaque::<i8>(move _75) -> [return: bb25, unwind unreachable]; ++ _74 = opaque::<i8>(const 1_i8) -> [return: bb25, unwind unreachable]; } bb25: { @@ -431,12 +482,14 @@ StorageDead(_74); StorageLive(_77); StorageLive(_78); -- StorageLive(_79); + StorageLive(_79); - _79 = _3; - _78 = move _79 as i16 (FloatToInt); -- StorageDead(_79); -+ _78 = const 1f64 as i16 (FloatToInt); - _77 = opaque::<i16>(move _78) -> [return: bb26, unwind unreachable]; ++ _79 = const 1f64; ++ _78 = const 1_i16; + StorageDead(_79); +- _77 = opaque::<i16>(move _78) -> [return: bb26, unwind unreachable]; ++ _77 = opaque::<i16>(const 1_i16) -> [return: bb26, unwind unreachable]; } bb26: { @@ -444,12 +497,14 @@ StorageDead(_77); StorageLive(_80); StorageLive(_81); -- StorageLive(_82); + StorageLive(_82); - _82 = _3; - _81 = move _82 as i32 (FloatToInt); -- StorageDead(_82); -+ _81 = const 1f64 as i32 (FloatToInt); - _80 = opaque::<i32>(move _81) -> [return: bb27, unwind unreachable]; ++ _82 = const 1f64; ++ _81 = const 1_i32; + StorageDead(_82); +- _80 = opaque::<i32>(move _81) -> [return: bb27, unwind unreachable]; ++ _80 = opaque::<i32>(const 1_i32) -> [return: bb27, unwind unreachable]; } bb27: { @@ -457,12 +512,14 @@ StorageDead(_80); StorageLive(_83); StorageLive(_84); -- StorageLive(_85); + StorageLive(_85); - _85 = _3; - _84 = move _85 as i64 (FloatToInt); -- StorageDead(_85); -+ _84 = const 1f64 as i64 (FloatToInt); - _83 = opaque::<i64>(move _84) -> [return: bb28, unwind unreachable]; ++ _85 = const 1f64; ++ _84 = const 1_i64; + StorageDead(_85); +- _83 = opaque::<i64>(move _84) -> [return: bb28, unwind unreachable]; ++ _83 = opaque::<i64>(const 1_i64) -> [return: bb28, unwind unreachable]; } bb28: { @@ -470,31 +527,37 @@ StorageDead(_83); StorageLive(_86); StorageLive(_87); -- StorageLive(_88); + StorageLive(_88); - _88 = _3; - _87 = move _88 as f32 (FloatToFloat); -- StorageDead(_88); -+ _87 = const 1f64 as f32 (FloatToFloat); - _86 = opaque::<f32>(move _87) -> [return: bb29, unwind unreachable]; ++ _88 = const 1f64; ++ _87 = const 1f32; + StorageDead(_88); +- _86 = opaque::<f32>(move _87) -> [return: bb29, unwind unreachable]; ++ _86 = opaque::<f32>(const 1f32) -> [return: bb29, unwind unreachable]; } bb29: { StorageDead(_87); StorageDead(_86); StorageLive(_89); -- StorageLive(_90); + StorageLive(_90); - _90 = _3; - _89 = opaque::<f64>(move _90) -> [return: bb30, unwind unreachable]; ++ _90 = const 1f64; + _89 = opaque::<f64>(const 1f64) -> [return: bb30, unwind unreachable]; } bb30: { -- StorageDead(_90); + StorageDead(_90); StorageDead(_89); _0 = const (); - StorageDead(_3); - StorageDead(_2); - StorageDead(_1); ++ nop; ++ nop; ++ nop; return; } } diff --git a/tests/mir-opt/gvn.cast.GVN.panic-unwind.diff b/tests/mir-opt/gvn.cast.GVN.panic-unwind.diff index 33192ed8de0..08b97e13aa0 100644 --- a/tests/mir-opt/gvn.cast.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.cast.GVN.panic-unwind.diff @@ -105,19 +105,24 @@ bb0: { - StorageLive(_1); ++ nop; _1 = const 1_i64; - StorageLive(_2); ++ nop; _2 = const 1_u64; - StorageLive(_3); ++ nop; _3 = const 1f64; StorageLive(_4); StorageLive(_5); -- StorageLive(_6); + StorageLive(_6); - _6 = _1; - _5 = move _6 as u8 (IntToInt); -- StorageDead(_6); -+ _5 = const 1_i64 as u8 (IntToInt); - _4 = opaque::<u8>(move _5) -> [return: bb1, unwind continue]; ++ _6 = const 1_i64; ++ _5 = const 1_u8; + StorageDead(_6); +- _4 = opaque::<u8>(move _5) -> [return: bb1, unwind continue]; ++ _4 = opaque::<u8>(const 1_u8) -> [return: bb1, unwind continue]; } bb1: { @@ -125,12 +130,14 @@ StorageDead(_4); StorageLive(_7); StorageLive(_8); -- StorageLive(_9); + StorageLive(_9); - _9 = _1; - _8 = move _9 as u16 (IntToInt); -- StorageDead(_9); -+ _8 = const 1_i64 as u16 (IntToInt); - _7 = opaque::<u16>(move _8) -> [return: bb2, unwind continue]; ++ _9 = const 1_i64; ++ _8 = const 1_u16; + StorageDead(_9); +- _7 = opaque::<u16>(move _8) -> [return: bb2, unwind continue]; ++ _7 = opaque::<u16>(const 1_u16) -> [return: bb2, unwind continue]; } bb2: { @@ -138,12 +145,14 @@ StorageDead(_7); StorageLive(_10); StorageLive(_11); -- StorageLive(_12); + StorageLive(_12); - _12 = _1; - _11 = move _12 as u32 (IntToInt); -- StorageDead(_12); -+ _11 = const 1_i64 as u32 (IntToInt); - _10 = opaque::<u32>(move _11) -> [return: bb3, unwind continue]; ++ _12 = const 1_i64; ++ _11 = const 1_u32; + StorageDead(_12); +- _10 = opaque::<u32>(move _11) -> [return: bb3, unwind continue]; ++ _10 = opaque::<u32>(const 1_u32) -> [return: bb3, unwind continue]; } bb3: { @@ -151,12 +160,14 @@ StorageDead(_10); StorageLive(_13); StorageLive(_14); -- StorageLive(_15); + StorageLive(_15); - _15 = _1; - _14 = move _15 as u64 (IntToInt); -- StorageDead(_15); -+ _14 = const 1_i64 as u64 (IntToInt); - _13 = opaque::<u64>(move _14) -> [return: bb4, unwind continue]; ++ _15 = const 1_i64; ++ _14 = const 1_u64; + StorageDead(_15); +- _13 = opaque::<u64>(move _14) -> [return: bb4, unwind continue]; ++ _13 = opaque::<u64>(const 1_u64) -> [return: bb4, unwind continue]; } bb4: { @@ -164,12 +175,14 @@ StorageDead(_13); StorageLive(_16); StorageLive(_17); -- StorageLive(_18); + StorageLive(_18); - _18 = _1; - _17 = move _18 as i8 (IntToInt); -- StorageDead(_18); -+ _17 = const 1_i64 as i8 (IntToInt); - _16 = opaque::<i8>(move _17) -> [return: bb5, unwind continue]; ++ _18 = const 1_i64; ++ _17 = const 1_i8; + StorageDead(_18); +- _16 = opaque::<i8>(move _17) -> [return: bb5, unwind continue]; ++ _16 = opaque::<i8>(const 1_i8) -> [return: bb5, unwind continue]; } bb5: { @@ -177,12 +190,14 @@ StorageDead(_16); StorageLive(_19); StorageLive(_20); -- StorageLive(_21); + StorageLive(_21); - _21 = _1; - _20 = move _21 as i16 (IntToInt); -- StorageDead(_21); -+ _20 = const 1_i64 as i16 (IntToInt); - _19 = opaque::<i16>(move _20) -> [return: bb6, unwind continue]; ++ _21 = const 1_i64; ++ _20 = const 1_i16; + StorageDead(_21); +- _19 = opaque::<i16>(move _20) -> [return: bb6, unwind continue]; ++ _19 = opaque::<i16>(const 1_i16) -> [return: bb6, unwind continue]; } bb6: { @@ -190,35 +205,40 @@ StorageDead(_19); StorageLive(_22); StorageLive(_23); -- StorageLive(_24); + StorageLive(_24); - _24 = _1; - _23 = move _24 as i32 (IntToInt); -- StorageDead(_24); -+ _23 = const 1_i64 as i32 (IntToInt); - _22 = opaque::<i32>(move _23) -> [return: bb7, unwind continue]; ++ _24 = const 1_i64; ++ _23 = const 1_i32; + StorageDead(_24); +- _22 = opaque::<i32>(move _23) -> [return: bb7, unwind continue]; ++ _22 = opaque::<i32>(const 1_i32) -> [return: bb7, unwind continue]; } bb7: { StorageDead(_23); StorageDead(_22); StorageLive(_25); -- StorageLive(_26); + StorageLive(_26); - _26 = _1; - _25 = opaque::<i64>(move _26) -> [return: bb8, unwind continue]; ++ _26 = const 1_i64; + _25 = opaque::<i64>(const 1_i64) -> [return: bb8, unwind continue]; } bb8: { -- StorageDead(_26); + StorageDead(_26); StorageDead(_25); StorageLive(_27); StorageLive(_28); -- StorageLive(_29); + StorageLive(_29); - _29 = _1; - _28 = move _29 as f32 (IntToFloat); -- StorageDead(_29); -+ _28 = const 1_i64 as f32 (IntToFloat); - _27 = opaque::<f32>(move _28) -> [return: bb9, unwind continue]; ++ _29 = const 1_i64; ++ _28 = const 1f32; + StorageDead(_29); +- _27 = opaque::<f32>(move _28) -> [return: bb9, unwind continue]; ++ _27 = opaque::<f32>(const 1f32) -> [return: bb9, unwind continue]; } bb9: { @@ -226,12 +246,14 @@ StorageDead(_27); StorageLive(_30); StorageLive(_31); -- StorageLive(_32); + StorageLive(_32); - _32 = _1; - _31 = move _32 as f64 (IntToFloat); -- StorageDead(_32); -+ _31 = const 1_i64 as f64 (IntToFloat); - _30 = opaque::<f64>(move _31) -> [return: bb10, unwind continue]; ++ _32 = const 1_i64; ++ _31 = const 1f64; + StorageDead(_32); +- _30 = opaque::<f64>(move _31) -> [return: bb10, unwind continue]; ++ _30 = opaque::<f64>(const 1f64) -> [return: bb10, unwind continue]; } bb10: { @@ -239,12 +261,14 @@ StorageDead(_30); StorageLive(_33); StorageLive(_34); -- StorageLive(_35); + StorageLive(_35); - _35 = _2; - _34 = move _35 as u8 (IntToInt); -- StorageDead(_35); -+ _34 = const 1_u64 as u8 (IntToInt); - _33 = opaque::<u8>(move _34) -> [return: bb11, unwind continue]; ++ _35 = const 1_u64; ++ _34 = const 1_u8; + StorageDead(_35); +- _33 = opaque::<u8>(move _34) -> [return: bb11, unwind continue]; ++ _33 = opaque::<u8>(const 1_u8) -> [return: bb11, unwind continue]; } bb11: { @@ -252,12 +276,14 @@ StorageDead(_33); StorageLive(_36); StorageLive(_37); -- StorageLive(_38); + StorageLive(_38); - _38 = _2; - _37 = move _38 as u16 (IntToInt); -- StorageDead(_38); -+ _37 = const 1_u64 as u16 (IntToInt); - _36 = opaque::<u16>(move _37) -> [return: bb12, unwind continue]; ++ _38 = const 1_u64; ++ _37 = const 1_u16; + StorageDead(_38); +- _36 = opaque::<u16>(move _37) -> [return: bb12, unwind continue]; ++ _36 = opaque::<u16>(const 1_u16) -> [return: bb12, unwind continue]; } bb12: { @@ -265,35 +291,40 @@ StorageDead(_36); StorageLive(_39); StorageLive(_40); -- StorageLive(_41); + StorageLive(_41); - _41 = _2; - _40 = move _41 as u32 (IntToInt); -- StorageDead(_41); -+ _40 = const 1_u64 as u32 (IntToInt); - _39 = opaque::<u32>(move _40) -> [return: bb13, unwind continue]; ++ _41 = const 1_u64; ++ _40 = const 1_u32; + StorageDead(_41); +- _39 = opaque::<u32>(move _40) -> [return: bb13, unwind continue]; ++ _39 = opaque::<u32>(const 1_u32) -> [return: bb13, unwind continue]; } bb13: { StorageDead(_40); StorageDead(_39); StorageLive(_42); -- StorageLive(_43); + StorageLive(_43); - _43 = _2; - _42 = opaque::<u64>(move _43) -> [return: bb14, unwind continue]; ++ _43 = const 1_u64; + _42 = opaque::<u64>(const 1_u64) -> [return: bb14, unwind continue]; } bb14: { -- StorageDead(_43); + StorageDead(_43); StorageDead(_42); StorageLive(_44); StorageLive(_45); -- StorageLive(_46); + StorageLive(_46); - _46 = _2; - _45 = move _46 as i8 (IntToInt); -- StorageDead(_46); -+ _45 = const 1_u64 as i8 (IntToInt); - _44 = opaque::<i8>(move _45) -> [return: bb15, unwind continue]; ++ _46 = const 1_u64; ++ _45 = const 1_i8; + StorageDead(_46); +- _44 = opaque::<i8>(move _45) -> [return: bb15, unwind continue]; ++ _44 = opaque::<i8>(const 1_i8) -> [return: bb15, unwind continue]; } bb15: { @@ -301,12 +332,14 @@ StorageDead(_44); StorageLive(_47); StorageLive(_48); -- StorageLive(_49); + StorageLive(_49); - _49 = _2; - _48 = move _49 as i16 (IntToInt); -- StorageDead(_49); -+ _48 = const 1_u64 as i16 (IntToInt); - _47 = opaque::<i16>(move _48) -> [return: bb16, unwind continue]; ++ _49 = const 1_u64; ++ _48 = const 1_i16; + StorageDead(_49); +- _47 = opaque::<i16>(move _48) -> [return: bb16, unwind continue]; ++ _47 = opaque::<i16>(const 1_i16) -> [return: bb16, unwind continue]; } bb16: { @@ -314,12 +347,14 @@ StorageDead(_47); StorageLive(_50); StorageLive(_51); -- StorageLive(_52); + StorageLive(_52); - _52 = _2; - _51 = move _52 as i32 (IntToInt); -- StorageDead(_52); -+ _51 = const 1_u64 as i32 (IntToInt); - _50 = opaque::<i32>(move _51) -> [return: bb17, unwind continue]; ++ _52 = const 1_u64; ++ _51 = const 1_i32; + StorageDead(_52); +- _50 = opaque::<i32>(move _51) -> [return: bb17, unwind continue]; ++ _50 = opaque::<i32>(const 1_i32) -> [return: bb17, unwind continue]; } bb17: { @@ -327,12 +362,14 @@ StorageDead(_50); StorageLive(_53); StorageLive(_54); -- StorageLive(_55); + StorageLive(_55); - _55 = _2; - _54 = move _55 as i64 (IntToInt); -- StorageDead(_55); -+ _54 = const 1_u64 as i64 (IntToInt); - _53 = opaque::<i64>(move _54) -> [return: bb18, unwind continue]; ++ _55 = const 1_u64; ++ _54 = const 1_i64; + StorageDead(_55); +- _53 = opaque::<i64>(move _54) -> [return: bb18, unwind continue]; ++ _53 = opaque::<i64>(const 1_i64) -> [return: bb18, unwind continue]; } bb18: { @@ -340,12 +377,14 @@ StorageDead(_53); StorageLive(_56); StorageLive(_57); -- StorageLive(_58); + StorageLive(_58); - _58 = _2; - _57 = move _58 as f32 (IntToFloat); -- StorageDead(_58); -+ _57 = const 1_u64 as f32 (IntToFloat); - _56 = opaque::<f32>(move _57) -> [return: bb19, unwind continue]; ++ _58 = const 1_u64; ++ _57 = const 1f32; + StorageDead(_58); +- _56 = opaque::<f32>(move _57) -> [return: bb19, unwind continue]; ++ _56 = opaque::<f32>(const 1f32) -> [return: bb19, unwind continue]; } bb19: { @@ -353,12 +392,14 @@ StorageDead(_56); StorageLive(_59); StorageLive(_60); -- StorageLive(_61); + StorageLive(_61); - _61 = _2; - _60 = move _61 as f64 (IntToFloat); -- StorageDead(_61); -+ _60 = const 1_u64 as f64 (IntToFloat); - _59 = opaque::<f64>(move _60) -> [return: bb20, unwind continue]; ++ _61 = const 1_u64; ++ _60 = const 1f64; + StorageDead(_61); +- _59 = opaque::<f64>(move _60) -> [return: bb20, unwind continue]; ++ _59 = opaque::<f64>(const 1f64) -> [return: bb20, unwind continue]; } bb20: { @@ -366,12 +407,14 @@ StorageDead(_59); StorageLive(_62); StorageLive(_63); -- StorageLive(_64); + StorageLive(_64); - _64 = _3; - _63 = move _64 as u8 (FloatToInt); -- StorageDead(_64); -+ _63 = const 1f64 as u8 (FloatToInt); - _62 = opaque::<u8>(move _63) -> [return: bb21, unwind continue]; ++ _64 = const 1f64; ++ _63 = const 1_u8; + StorageDead(_64); +- _62 = opaque::<u8>(move _63) -> [return: bb21, unwind continue]; ++ _62 = opaque::<u8>(const 1_u8) -> [return: bb21, unwind continue]; } bb21: { @@ -379,12 +422,14 @@ StorageDead(_62); StorageLive(_65); StorageLive(_66); -- StorageLive(_67); + StorageLive(_67); - _67 = _3; - _66 = move _67 as u16 (FloatToInt); -- StorageDead(_67); -+ _66 = const 1f64 as u16 (FloatToInt); - _65 = opaque::<u16>(move _66) -> [return: bb22, unwind continue]; ++ _67 = const 1f64; ++ _66 = const 1_u16; + StorageDead(_67); +- _65 = opaque::<u16>(move _66) -> [return: bb22, unwind continue]; ++ _65 = opaque::<u16>(const 1_u16) -> [return: bb22, unwind continue]; } bb22: { @@ -392,12 +437,14 @@ StorageDead(_65); StorageLive(_68); StorageLive(_69); -- StorageLive(_70); + StorageLive(_70); - _70 = _3; - _69 = move _70 as u32 (FloatToInt); -- StorageDead(_70); -+ _69 = const 1f64 as u32 (FloatToInt); - _68 = opaque::<u32>(move _69) -> [return: bb23, unwind continue]; ++ _70 = const 1f64; ++ _69 = const 1_u32; + StorageDead(_70); +- _68 = opaque::<u32>(move _69) -> [return: bb23, unwind continue]; ++ _68 = opaque::<u32>(const 1_u32) -> [return: bb23, unwind continue]; } bb23: { @@ -405,12 +452,14 @@ StorageDead(_68); StorageLive(_71); StorageLive(_72); -- StorageLive(_73); + StorageLive(_73); - _73 = _3; - _72 = move _73 as u64 (FloatToInt); -- StorageDead(_73); -+ _72 = const 1f64 as u64 (FloatToInt); - _71 = opaque::<u64>(move _72) -> [return: bb24, unwind continue]; ++ _73 = const 1f64; ++ _72 = const 1_u64; + StorageDead(_73); +- _71 = opaque::<u64>(move _72) -> [return: bb24, unwind continue]; ++ _71 = opaque::<u64>(const 1_u64) -> [return: bb24, unwind continue]; } bb24: { @@ -418,12 +467,14 @@ StorageDead(_71); StorageLive(_74); StorageLive(_75); -- StorageLive(_76); + StorageLive(_76); - _76 = _3; - _75 = move _76 as i8 (FloatToInt); -- StorageDead(_76); -+ _75 = const 1f64 as i8 (FloatToInt); - _74 = opaque::<i8>(move _75) -> [return: bb25, unwind continue]; ++ _76 = const 1f64; ++ _75 = const 1_i8; + StorageDead(_76); +- _74 = opaque::<i8>(move _75) -> [return: bb25, unwind continue]; ++ _74 = opaque::<i8>(const 1_i8) -> [return: bb25, unwind continue]; } bb25: { @@ -431,12 +482,14 @@ StorageDead(_74); StorageLive(_77); StorageLive(_78); -- StorageLive(_79); + StorageLive(_79); - _79 = _3; - _78 = move _79 as i16 (FloatToInt); -- StorageDead(_79); -+ _78 = const 1f64 as i16 (FloatToInt); - _77 = opaque::<i16>(move _78) -> [return: bb26, unwind continue]; ++ _79 = const 1f64; ++ _78 = const 1_i16; + StorageDead(_79); +- _77 = opaque::<i16>(move _78) -> [return: bb26, unwind continue]; ++ _77 = opaque::<i16>(const 1_i16) -> [return: bb26, unwind continue]; } bb26: { @@ -444,12 +497,14 @@ StorageDead(_77); StorageLive(_80); StorageLive(_81); -- StorageLive(_82); + StorageLive(_82); - _82 = _3; - _81 = move _82 as i32 (FloatToInt); -- StorageDead(_82); -+ _81 = const 1f64 as i32 (FloatToInt); - _80 = opaque::<i32>(move _81) -> [return: bb27, unwind continue]; ++ _82 = const 1f64; ++ _81 = const 1_i32; + StorageDead(_82); +- _80 = opaque::<i32>(move _81) -> [return: bb27, unwind continue]; ++ _80 = opaque::<i32>(const 1_i32) -> [return: bb27, unwind continue]; } bb27: { @@ -457,12 +512,14 @@ StorageDead(_80); StorageLive(_83); StorageLive(_84); -- StorageLive(_85); + StorageLive(_85); - _85 = _3; - _84 = move _85 as i64 (FloatToInt); -- StorageDead(_85); -+ _84 = const 1f64 as i64 (FloatToInt); - _83 = opaque::<i64>(move _84) -> [return: bb28, unwind continue]; ++ _85 = const 1f64; ++ _84 = const 1_i64; + StorageDead(_85); +- _83 = opaque::<i64>(move _84) -> [return: bb28, unwind continue]; ++ _83 = opaque::<i64>(const 1_i64) -> [return: bb28, unwind continue]; } bb28: { @@ -470,31 +527,37 @@ StorageDead(_83); StorageLive(_86); StorageLive(_87); -- StorageLive(_88); + StorageLive(_88); - _88 = _3; - _87 = move _88 as f32 (FloatToFloat); -- StorageDead(_88); -+ _87 = const 1f64 as f32 (FloatToFloat); - _86 = opaque::<f32>(move _87) -> [return: bb29, unwind continue]; ++ _88 = const 1f64; ++ _87 = const 1f32; + StorageDead(_88); +- _86 = opaque::<f32>(move _87) -> [return: bb29, unwind continue]; ++ _86 = opaque::<f32>(const 1f32) -> [return: bb29, unwind continue]; } bb29: { StorageDead(_87); StorageDead(_86); StorageLive(_89); -- StorageLive(_90); + StorageLive(_90); - _90 = _3; - _89 = opaque::<f64>(move _90) -> [return: bb30, unwind continue]; ++ _90 = const 1f64; + _89 = opaque::<f64>(const 1f64) -> [return: bb30, unwind continue]; } bb30: { -- StorageDead(_90); + StorageDead(_90); StorageDead(_89); _0 = const (); - StorageDead(_3); - StorageDead(_2); - StorageDead(_1); ++ nop; ++ nop; ++ nop; return; } } diff --git a/tests/mir-opt/gvn.comparison.GVN.panic-abort.diff b/tests/mir-opt/gvn.comparison.GVN.panic-abort.diff new file mode 100644 index 00000000000..ee3b9da2122 --- /dev/null +++ b/tests/mir-opt/gvn.comparison.GVN.panic-abort.diff @@ -0,0 +1,94 @@ +- // MIR for `comparison` before GVN ++ // MIR for `comparison` after GVN + + fn comparison(_1: u64, _2: u64) -> () { + debug x => _1; + debug y => _2; + let mut _0: (); + let _3: (); + let mut _4: bool; + let mut _5: u64; + let mut _6: u64; + let _7: (); + let mut _8: bool; + let mut _9: u64; + let mut _10: u64; + let _11: (); + let mut _12: bool; + let mut _13: u64; + let mut _14: u64; + let _15: (); + let mut _16: bool; + let mut _17: u64; + let mut _18: u64; + + bb0: { + StorageLive(_3); + StorageLive(_4); + StorageLive(_5); + _5 = _1; + StorageLive(_6); + _6 = _1; +- _4 = Eq(move _5, move _6); ++ _4 = Eq(_1, _1); + StorageDead(_6); + StorageDead(_5); + _3 = opaque::<bool>(move _4) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_4); + StorageDead(_3); + StorageLive(_7); + StorageLive(_8); + StorageLive(_9); + _9 = _1; + StorageLive(_10); + _10 = _1; +- _8 = Ne(move _9, move _10); ++ _8 = Ne(_1, _1); + StorageDead(_10); + StorageDead(_9); + _7 = opaque::<bool>(move _8) -> [return: bb2, unwind unreachable]; + } + + bb2: { + StorageDead(_8); + StorageDead(_7); + StorageLive(_11); + StorageLive(_12); + StorageLive(_13); + _13 = _1; + StorageLive(_14); + _14 = _2; +- _12 = Eq(move _13, move _14); ++ _12 = Eq(_1, _2); + StorageDead(_14); + StorageDead(_13); + _11 = opaque::<bool>(move _12) -> [return: bb3, unwind unreachable]; + } + + bb3: { + StorageDead(_12); + StorageDead(_11); + StorageLive(_15); + StorageLive(_16); + StorageLive(_17); + _17 = _1; + StorageLive(_18); + _18 = _2; +- _16 = Ne(move _17, move _18); ++ _16 = Ne(_1, _2); + StorageDead(_18); + StorageDead(_17); + _15 = opaque::<bool>(move _16) -> [return: bb4, unwind unreachable]; + } + + bb4: { + StorageDead(_16); + StorageDead(_15); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/gvn.comparison.GVN.panic-unwind.diff b/tests/mir-opt/gvn.comparison.GVN.panic-unwind.diff new file mode 100644 index 00000000000..a1408fe3434 --- /dev/null +++ b/tests/mir-opt/gvn.comparison.GVN.panic-unwind.diff @@ -0,0 +1,94 @@ +- // MIR for `comparison` before GVN ++ // MIR for `comparison` after GVN + + fn comparison(_1: u64, _2: u64) -> () { + debug x => _1; + debug y => _2; + let mut _0: (); + let _3: (); + let mut _4: bool; + let mut _5: u64; + let mut _6: u64; + let _7: (); + let mut _8: bool; + let mut _9: u64; + let mut _10: u64; + let _11: (); + let mut _12: bool; + let mut _13: u64; + let mut _14: u64; + let _15: (); + let mut _16: bool; + let mut _17: u64; + let mut _18: u64; + + bb0: { + StorageLive(_3); + StorageLive(_4); + StorageLive(_5); + _5 = _1; + StorageLive(_6); + _6 = _1; +- _4 = Eq(move _5, move _6); ++ _4 = Eq(_1, _1); + StorageDead(_6); + StorageDead(_5); + _3 = opaque::<bool>(move _4) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_4); + StorageDead(_3); + StorageLive(_7); + StorageLive(_8); + StorageLive(_9); + _9 = _1; + StorageLive(_10); + _10 = _1; +- _8 = Ne(move _9, move _10); ++ _8 = Ne(_1, _1); + StorageDead(_10); + StorageDead(_9); + _7 = opaque::<bool>(move _8) -> [return: bb2, unwind continue]; + } + + bb2: { + StorageDead(_8); + StorageDead(_7); + StorageLive(_11); + StorageLive(_12); + StorageLive(_13); + _13 = _1; + StorageLive(_14); + _14 = _2; +- _12 = Eq(move _13, move _14); ++ _12 = Eq(_1, _2); + StorageDead(_14); + StorageDead(_13); + _11 = opaque::<bool>(move _12) -> [return: bb3, unwind continue]; + } + + bb3: { + StorageDead(_12); + StorageDead(_11); + StorageLive(_15); + StorageLive(_16); + StorageLive(_17); + _17 = _1; + StorageLive(_18); + _18 = _2; +- _16 = Ne(move _17, move _18); ++ _16 = Ne(_1, _2); + StorageDead(_18); + StorageDead(_17); + _15 = opaque::<bool>(move _16) -> [return: bb4, unwind continue]; + } + + bb4: { + StorageDead(_16); + StorageDead(_15); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/gvn.dereferences.GVN.panic-abort.diff b/tests/mir-opt/gvn.dereferences.GVN.panic-abort.diff index ee320cf6787..a587b1e6b1d 100644 --- a/tests/mir-opt/gvn.dereferences.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.dereferences.GVN.panic-abort.diff @@ -72,7 +72,8 @@ bb2: { StorageDead(_7); StorageDead(_6); - StorageLive(_8); +- StorageLive(_8); ++ nop; _8 = &raw const (*_1); StorageLive(_9); StorageLive(_10); @@ -92,7 +93,8 @@ bb4: { StorageDead(_12); StorageDead(_11); - StorageLive(_13); +- StorageLive(_13); ++ nop; _13 = &raw mut (*_1); StorageLive(_14); StorageLive(_15); @@ -112,10 +114,12 @@ bb6: { StorageDead(_17); StorageDead(_16); - StorageLive(_18); +- StorageLive(_18); ++ nop; _18 = &(*_1); StorageLive(_19); - StorageLive(_20); ++ nop; _20 = (*_18); - _19 = opaque::<u32>(move _20) -> [return: bb7, unwind unreachable]; + _19 = opaque::<u32>(_20) -> [return: bb7, unwind unreachable]; @@ -123,16 +127,18 @@ bb7: { - StorageDead(_20); ++ nop; StorageDead(_19); StorageLive(_21); -- StorageLive(_22); + StorageLive(_22); - _22 = (*_18); - _21 = opaque::<u32>(move _22) -> [return: bb8, unwind unreachable]; ++ _22 = _20; + _21 = opaque::<u32>(_20) -> [return: bb8, unwind unreachable]; } bb8: { -- StorageDead(_22); + StorageDead(_22); StorageDead(_21); StorageLive(_23); StorageLive(_24); @@ -163,6 +169,7 @@ StorageDead(_27); StorageLive(_29); - StorageLive(_30); ++ nop; _30 = ((*_3).0: u32); - _29 = opaque::<u32>(move _30) -> [return: bb12, unwind unreachable]; + _29 = opaque::<u32>(_30) -> [return: bb12, unwind unreachable]; @@ -170,21 +177,26 @@ bb12: { - StorageDead(_30); ++ nop; StorageDead(_29); StorageLive(_31); -- StorageLive(_32); + StorageLive(_32); - _32 = ((*_3).0: u32); - _31 = opaque::<u32>(move _32) -> [return: bb13, unwind unreachable]; ++ _32 = _30; + _31 = opaque::<u32>(_30) -> [return: bb13, unwind unreachable]; } bb13: { -- StorageDead(_32); + StorageDead(_32); StorageDead(_31); _0 = const (); - StorageDead(_18); - StorageDead(_13); - StorageDead(_8); +- StorageDead(_18); +- StorageDead(_13); +- StorageDead(_8); ++ nop; ++ nop; ++ nop; return; } } diff --git a/tests/mir-opt/gvn.dereferences.GVN.panic-unwind.diff b/tests/mir-opt/gvn.dereferences.GVN.panic-unwind.diff index f627b4d5988..6fdda5e9988 100644 --- a/tests/mir-opt/gvn.dereferences.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.dereferences.GVN.panic-unwind.diff @@ -72,7 +72,8 @@ bb2: { StorageDead(_7); StorageDead(_6); - StorageLive(_8); +- StorageLive(_8); ++ nop; _8 = &raw const (*_1); StorageLive(_9); StorageLive(_10); @@ -92,7 +93,8 @@ bb4: { StorageDead(_12); StorageDead(_11); - StorageLive(_13); +- StorageLive(_13); ++ nop; _13 = &raw mut (*_1); StorageLive(_14); StorageLive(_15); @@ -112,10 +114,12 @@ bb6: { StorageDead(_17); StorageDead(_16); - StorageLive(_18); +- StorageLive(_18); ++ nop; _18 = &(*_1); StorageLive(_19); - StorageLive(_20); ++ nop; _20 = (*_18); - _19 = opaque::<u32>(move _20) -> [return: bb7, unwind continue]; + _19 = opaque::<u32>(_20) -> [return: bb7, unwind continue]; @@ -123,16 +127,18 @@ bb7: { - StorageDead(_20); ++ nop; StorageDead(_19); StorageLive(_21); -- StorageLive(_22); + StorageLive(_22); - _22 = (*_18); - _21 = opaque::<u32>(move _22) -> [return: bb8, unwind continue]; ++ _22 = _20; + _21 = opaque::<u32>(_20) -> [return: bb8, unwind continue]; } bb8: { -- StorageDead(_22); + StorageDead(_22); StorageDead(_21); StorageLive(_23); StorageLive(_24); @@ -163,6 +169,7 @@ StorageDead(_27); StorageLive(_29); - StorageLive(_30); ++ nop; _30 = ((*_3).0: u32); - _29 = opaque::<u32>(move _30) -> [return: bb12, unwind continue]; + _29 = opaque::<u32>(_30) -> [return: bb12, unwind continue]; @@ -170,21 +177,26 @@ bb12: { - StorageDead(_30); ++ nop; StorageDead(_29); StorageLive(_31); -- StorageLive(_32); + StorageLive(_32); - _32 = ((*_3).0: u32); - _31 = opaque::<u32>(move _32) -> [return: bb13, unwind continue]; ++ _32 = _30; + _31 = opaque::<u32>(_30) -> [return: bb13, unwind continue]; } bb13: { -- StorageDead(_32); + StorageDead(_32); StorageDead(_31); _0 = const (); - StorageDead(_18); - StorageDead(_13); - StorageDead(_8); +- StorageDead(_18); +- StorageDead(_13); +- StorageDead(_8); ++ nop; ++ nop; ++ nop; return; } } diff --git a/tests/mir-opt/gvn.duplicate_slice.GVN.panic-abort.diff b/tests/mir-opt/gvn.duplicate_slice.GVN.panic-abort.diff new file mode 100644 index 00000000000..7ae1fae68e8 --- /dev/null +++ b/tests/mir-opt/gvn.duplicate_slice.GVN.panic-abort.diff @@ -0,0 +1,38 @@ +- // MIR for `duplicate_slice` before GVN ++ // MIR for `duplicate_slice` after GVN + + fn duplicate_slice() -> (bool, bool) { + let mut _0: (bool, bool); + let mut _1: u128; + let mut _2: u128; + let mut _3: u128; + let mut _4: u128; + let mut _5: &str; + let mut _6: &str; + let mut _7: (&str,); + let mut _8: &str; + let mut _9: bool; + let mut _10: bool; + + bb0: { + _7 = (const "a",); + _1 = (_7.0: &str) as u128 (Transmute); + _5 = identity::<&str>((_7.0: &str)) -> [return: bb1, unwind unreachable]; + } + + bb1: { + _3 = _5 as u128 (Transmute); + _8 = const "a"; + _2 = _8 as u128 (Transmute); + _6 = identity::<&str>(_8) -> [return: bb2, unwind unreachable]; + } + + bb2: { + _4 = _6 as u128 (Transmute); + _9 = Eq(_1, _2); + _10 = Eq(_3, _4); + _0 = (_9, _10); + return; + } + } + diff --git a/tests/mir-opt/gvn.duplicate_slice.GVN.panic-unwind.diff b/tests/mir-opt/gvn.duplicate_slice.GVN.panic-unwind.diff new file mode 100644 index 00000000000..8c96edaa280 --- /dev/null +++ b/tests/mir-opt/gvn.duplicate_slice.GVN.panic-unwind.diff @@ -0,0 +1,38 @@ +- // MIR for `duplicate_slice` before GVN ++ // MIR for `duplicate_slice` after GVN + + fn duplicate_slice() -> (bool, bool) { + let mut _0: (bool, bool); + let mut _1: u128; + let mut _2: u128; + let mut _3: u128; + let mut _4: u128; + let mut _5: &str; + let mut _6: &str; + let mut _7: (&str,); + let mut _8: &str; + let mut _9: bool; + let mut _10: bool; + + bb0: { + _7 = (const "a",); + _1 = (_7.0: &str) as u128 (Transmute); + _5 = identity::<&str>((_7.0: &str)) -> [return: bb1, unwind continue]; + } + + bb1: { + _3 = _5 as u128 (Transmute); + _8 = const "a"; + _2 = _8 as u128 (Transmute); + _6 = identity::<&str>(_8) -> [return: bb2, unwind continue]; + } + + bb2: { + _4 = _6 as u128 (Transmute); + _9 = Eq(_1, _2); + _10 = Eq(_3, _4); + _0 = (_9, _10); + return; + } + } + diff --git a/tests/mir-opt/gvn.fn_pointers.GVN.panic-abort.diff b/tests/mir-opt/gvn.fn_pointers.GVN.panic-abort.diff new file mode 100644 index 00000000000..d8248d22d38 --- /dev/null +++ b/tests/mir-opt/gvn.fn_pointers.GVN.panic-abort.diff @@ -0,0 +1,118 @@ +- // MIR for `fn_pointers` before GVN ++ // MIR for `fn_pointers` after GVN + + fn fn_pointers() -> () { + let mut _0: (); + let _1: fn(u8) -> u8; + let _2: (); + let mut _3: fn(u8) -> u8; + let _5: (); + let mut _6: fn(u8) -> u8; + let mut _9: {closure@$DIR/gvn.rs:591:19: 591:21}; + let _10: (); + let mut _11: fn(); + let mut _13: {closure@$DIR/gvn.rs:591:19: 591:21}; + let _14: (); + let mut _15: fn(); + scope 1 { + debug f => _1; + let _4: fn(u8) -> u8; + scope 2 { + debug g => _4; + let _7: {closure@$DIR/gvn.rs:591:19: 591:21}; + scope 3 { + debug closure => _7; + let _8: fn(); + scope 4 { + debug cf => _8; + let _12: fn(); + scope 5 { + debug cg => _12; + } + } + } + } + } + + bb0: { +- StorageLive(_1); ++ nop; + _1 = identity::<u8> as fn(u8) -> u8 (PointerCoercion(ReifyFnPointer)); + StorageLive(_2); + StorageLive(_3); + _3 = _1; +- _2 = opaque::<fn(u8) -> u8>(move _3) -> [return: bb1, unwind unreachable]; ++ _2 = opaque::<fn(u8) -> u8>(_1) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_3); + StorageDead(_2); +- StorageLive(_4); ++ nop; + _4 = identity::<u8> as fn(u8) -> u8 (PointerCoercion(ReifyFnPointer)); + StorageLive(_5); + StorageLive(_6); + _6 = _4; +- _5 = opaque::<fn(u8) -> u8>(move _6) -> [return: bb2, unwind unreachable]; ++ _5 = opaque::<fn(u8) -> u8>(_4) -> [return: bb2, unwind unreachable]; + } + + bb2: { + StorageDead(_6); + StorageDead(_5); +- StorageLive(_7); +- _7 = {closure@$DIR/gvn.rs:591:19: 591:21}; +- StorageLive(_8); ++ nop; ++ _7 = const ZeroSized: {closure@$DIR/gvn.rs:591:19: 591:21}; ++ nop; + StorageLive(_9); +- _9 = _7; +- _8 = move _9 as fn() (PointerCoercion(ClosureFnPointer(Normal))); ++ _9 = const ZeroSized: {closure@$DIR/gvn.rs:591:19: 591:21}; ++ _8 = const ZeroSized: {closure@$DIR/gvn.rs:591:19: 591:21} as fn() (PointerCoercion(ClosureFnPointer(Normal))); + StorageDead(_9); + StorageLive(_10); + StorageLive(_11); + _11 = _8; +- _10 = opaque::<fn()>(move _11) -> [return: bb3, unwind unreachable]; ++ _10 = opaque::<fn()>(_8) -> [return: bb3, unwind unreachable]; + } + + bb3: { + StorageDead(_11); + StorageDead(_10); +- StorageLive(_12); ++ nop; + StorageLive(_13); +- _13 = _7; +- _12 = move _13 as fn() (PointerCoercion(ClosureFnPointer(Normal))); ++ _13 = const ZeroSized: {closure@$DIR/gvn.rs:591:19: 591:21}; ++ _12 = const ZeroSized: {closure@$DIR/gvn.rs:591:19: 591:21} as fn() (PointerCoercion(ClosureFnPointer(Normal))); + StorageDead(_13); + StorageLive(_14); + StorageLive(_15); + _15 = _12; +- _14 = opaque::<fn()>(move _15) -> [return: bb4, unwind unreachable]; ++ _14 = opaque::<fn()>(_12) -> [return: bb4, unwind unreachable]; + } + + bb4: { + StorageDead(_15); + StorageDead(_14); + _0 = const (); +- StorageDead(_12); +- StorageDead(_8); +- StorageDead(_7); +- StorageDead(_4); +- StorageDead(_1); ++ nop; ++ nop; ++ nop; ++ nop; ++ nop; + return; + } + } + diff --git a/tests/mir-opt/gvn.fn_pointers.GVN.panic-unwind.diff b/tests/mir-opt/gvn.fn_pointers.GVN.panic-unwind.diff new file mode 100644 index 00000000000..e38a3d85209 --- /dev/null +++ b/tests/mir-opt/gvn.fn_pointers.GVN.panic-unwind.diff @@ -0,0 +1,118 @@ +- // MIR for `fn_pointers` before GVN ++ // MIR for `fn_pointers` after GVN + + fn fn_pointers() -> () { + let mut _0: (); + let _1: fn(u8) -> u8; + let _2: (); + let mut _3: fn(u8) -> u8; + let _5: (); + let mut _6: fn(u8) -> u8; + let mut _9: {closure@$DIR/gvn.rs:591:19: 591:21}; + let _10: (); + let mut _11: fn(); + let mut _13: {closure@$DIR/gvn.rs:591:19: 591:21}; + let _14: (); + let mut _15: fn(); + scope 1 { + debug f => _1; + let _4: fn(u8) -> u8; + scope 2 { + debug g => _4; + let _7: {closure@$DIR/gvn.rs:591:19: 591:21}; + scope 3 { + debug closure => _7; + let _8: fn(); + scope 4 { + debug cf => _8; + let _12: fn(); + scope 5 { + debug cg => _12; + } + } + } + } + } + + bb0: { +- StorageLive(_1); ++ nop; + _1 = identity::<u8> as fn(u8) -> u8 (PointerCoercion(ReifyFnPointer)); + StorageLive(_2); + StorageLive(_3); + _3 = _1; +- _2 = opaque::<fn(u8) -> u8>(move _3) -> [return: bb1, unwind continue]; ++ _2 = opaque::<fn(u8) -> u8>(_1) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_3); + StorageDead(_2); +- StorageLive(_4); ++ nop; + _4 = identity::<u8> as fn(u8) -> u8 (PointerCoercion(ReifyFnPointer)); + StorageLive(_5); + StorageLive(_6); + _6 = _4; +- _5 = opaque::<fn(u8) -> u8>(move _6) -> [return: bb2, unwind continue]; ++ _5 = opaque::<fn(u8) -> u8>(_4) -> [return: bb2, unwind continue]; + } + + bb2: { + StorageDead(_6); + StorageDead(_5); +- StorageLive(_7); +- _7 = {closure@$DIR/gvn.rs:591:19: 591:21}; +- StorageLive(_8); ++ nop; ++ _7 = const ZeroSized: {closure@$DIR/gvn.rs:591:19: 591:21}; ++ nop; + StorageLive(_9); +- _9 = _7; +- _8 = move _9 as fn() (PointerCoercion(ClosureFnPointer(Normal))); ++ _9 = const ZeroSized: {closure@$DIR/gvn.rs:591:19: 591:21}; ++ _8 = const ZeroSized: {closure@$DIR/gvn.rs:591:19: 591:21} as fn() (PointerCoercion(ClosureFnPointer(Normal))); + StorageDead(_9); + StorageLive(_10); + StorageLive(_11); + _11 = _8; +- _10 = opaque::<fn()>(move _11) -> [return: bb3, unwind continue]; ++ _10 = opaque::<fn()>(_8) -> [return: bb3, unwind continue]; + } + + bb3: { + StorageDead(_11); + StorageDead(_10); +- StorageLive(_12); ++ nop; + StorageLive(_13); +- _13 = _7; +- _12 = move _13 as fn() (PointerCoercion(ClosureFnPointer(Normal))); ++ _13 = const ZeroSized: {closure@$DIR/gvn.rs:591:19: 591:21}; ++ _12 = const ZeroSized: {closure@$DIR/gvn.rs:591:19: 591:21} as fn() (PointerCoercion(ClosureFnPointer(Normal))); + StorageDead(_13); + StorageLive(_14); + StorageLive(_15); + _15 = _12; +- _14 = opaque::<fn()>(move _15) -> [return: bb4, unwind continue]; ++ _14 = opaque::<fn()>(_12) -> [return: bb4, unwind continue]; + } + + bb4: { + StorageDead(_15); + StorageDead(_14); + _0 = const (); +- StorageDead(_12); +- StorageDead(_8); +- StorageDead(_7); +- StorageDead(_4); +- StorageDead(_1); ++ nop; ++ nop; ++ nop; ++ nop; ++ nop; + return; + } + } + diff --git a/tests/mir-opt/gvn.indirect_static.GVN.panic-abort.diff b/tests/mir-opt/gvn.indirect_static.GVN.panic-abort.diff new file mode 100644 index 00000000000..f853942bbb6 --- /dev/null +++ b/tests/mir-opt/gvn.indirect_static.GVN.panic-abort.diff @@ -0,0 +1,19 @@ +- // MIR for `indirect_static` before GVN ++ // MIR for `indirect_static` after GVN + + fn indirect_static() -> () { + let mut _0: (); + let mut _1: &std::option::Option<u8>; + let mut _2: u8; + + bb0: { + _1 = const {ALLOC0: &Option<u8>}; + _2 = (((*_1) as variant#1).0: u8); + return; + } + } + + ALLOC0 (static: A, size: 2, align: 1) { + 00 __ │ .░ + } + diff --git a/tests/mir-opt/gvn.indirect_static.GVN.panic-unwind.diff b/tests/mir-opt/gvn.indirect_static.GVN.panic-unwind.diff new file mode 100644 index 00000000000..f853942bbb6 --- /dev/null +++ b/tests/mir-opt/gvn.indirect_static.GVN.panic-unwind.diff @@ -0,0 +1,19 @@ +- // MIR for `indirect_static` before GVN ++ // MIR for `indirect_static` after GVN + + fn indirect_static() -> () { + let mut _0: (); + let mut _1: &std::option::Option<u8>; + let mut _2: u8; + + bb0: { + _1 = const {ALLOC0: &Option<u8>}; + _2 = (((*_1) as variant#1).0: u8); + return; + } + } + + ALLOC0 (static: A, size: 2, align: 1) { + 00 __ │ .░ + } + diff --git a/tests/mir-opt/gvn.multiple_branches.GVN.panic-abort.diff b/tests/mir-opt/gvn.multiple_branches.GVN.panic-abort.diff index 0a66900283b..29ca1ba5902 100644 --- a/tests/mir-opt/gvn.multiple_branches.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.multiple_branches.GVN.panic-abort.diff @@ -39,9 +39,9 @@ let mut _34: u8; bb0: { -- StorageLive(_4); -- StorageLive(_5); -- _5 = _1; + StorageLive(_4); + StorageLive(_5); + _5 = _1; - switchInt(move _5) -> [0: bb4, otherwise: bb1]; + switchInt(_1) -> [0: bb4, otherwise: bb1]; } @@ -49,121 +49,130 @@ bb1: { StorageLive(_6); - StorageLive(_7); -- StorageLive(_8); -- _8 = _2; -- StorageLive(_9); -- _9 = _3; ++ nop; + StorageLive(_8); + _8 = _2; + StorageLive(_9); + _9 = _3; - _7 = Add(move _8, move _9); -- StorageDead(_9); -- StorageDead(_8); -- _6 = opaque::<u8>(move _7) -> [return: bb2, unwind unreachable]; + _7 = Add(_2, _3); + StorageDead(_9); + StorageDead(_8); +- _6 = opaque::<u8>(move _7) -> [return: bb2, unwind unreachable]; + _6 = opaque::<u8>(_7) -> [return: bb2, unwind unreachable]; } bb2: { - StorageDead(_7); ++ nop; StorageDead(_6); StorageLive(_10); -- StorageLive(_11); -- StorageLive(_12); -- _12 = _2; -- StorageLive(_13); -- _13 = _3; + StorageLive(_11); + StorageLive(_12); + _12 = _2; + StorageLive(_13); + _13 = _3; - _11 = Add(move _12, move _13); -- StorageDead(_13); -- StorageDead(_12); ++ _11 = _7; + StorageDead(_13); + StorageDead(_12); - _10 = opaque::<u8>(move _11) -> [return: bb3, unwind unreachable]; + _10 = opaque::<u8>(_7) -> [return: bb3, unwind unreachable]; } bb3: { -- StorageDead(_11); + StorageDead(_11); StorageDead(_10); -- _4 = const (); + _4 = const (); goto -> bb7; } bb4: { StorageLive(_14); - StorageLive(_15); -- StorageLive(_16); -- _16 = _2; -- StorageLive(_17); -- _17 = _3; ++ nop; + StorageLive(_16); + _16 = _2; + StorageLive(_17); + _17 = _3; - _15 = Add(move _16, move _17); -- StorageDead(_17); -- StorageDead(_16); -- _14 = opaque::<u8>(move _15) -> [return: bb5, unwind unreachable]; + _15 = Add(_2, _3); + StorageDead(_17); + StorageDead(_16); +- _14 = opaque::<u8>(move _15) -> [return: bb5, unwind unreachable]; + _14 = opaque::<u8>(_15) -> [return: bb5, unwind unreachable]; } bb5: { - StorageDead(_15); ++ nop; StorageDead(_14); StorageLive(_18); -- StorageLive(_19); -- StorageLive(_20); -- _20 = _2; -- StorageLive(_21); -- _21 = _3; + StorageLive(_19); + StorageLive(_20); + _20 = _2; + StorageLive(_21); + _21 = _3; - _19 = Add(move _20, move _21); -- StorageDead(_21); -- StorageDead(_20); ++ _19 = _15; + StorageDead(_21); + StorageDead(_20); - _18 = opaque::<u8>(move _19) -> [return: bb6, unwind unreachable]; + _18 = opaque::<u8>(_15) -> [return: bb6, unwind unreachable]; } bb6: { -- StorageDead(_19); + StorageDead(_19); StorageDead(_18); -- _4 = const (); + _4 = const (); goto -> bb7; } bb7: { -- StorageDead(_5); -- StorageDead(_4); + StorageDead(_5); + StorageDead(_4); StorageLive(_22); - StorageLive(_23); -- StorageLive(_24); -- _24 = _2; -- StorageLive(_25); -- _25 = _3; ++ nop; + StorageLive(_24); + _24 = _2; + StorageLive(_25); + _25 = _3; - _23 = Add(move _24, move _25); -- StorageDead(_25); -- StorageDead(_24); -- _22 = opaque::<u8>(move _23) -> [return: bb8, unwind unreachable]; + _23 = Add(_2, _3); + StorageDead(_25); + StorageDead(_24); +- _22 = opaque::<u8>(move _23) -> [return: bb8, unwind unreachable]; + _22 = opaque::<u8>(_23) -> [return: bb8, unwind unreachable]; } bb8: { - StorageDead(_23); ++ nop; StorageDead(_22); -- StorageLive(_26); -- _26 = _1; + StorageLive(_26); + _26 = _1; - switchInt(move _26) -> [0: bb11, otherwise: bb9]; + switchInt(_1) -> [0: bb11, otherwise: bb9]; } bb9: { StorageLive(_27); -- StorageLive(_28); -- StorageLive(_29); -- _29 = _2; -- StorageLive(_30); -- _30 = _3; + StorageLive(_28); + StorageLive(_29); + _29 = _2; + StorageLive(_30); + _30 = _3; - _28 = Add(move _29, move _30); -- StorageDead(_30); -- StorageDead(_29); ++ _28 = _23; + StorageDead(_30); + StorageDead(_29); - _27 = opaque::<u8>(move _28) -> [return: bb10, unwind unreachable]; + _27 = opaque::<u8>(_23) -> [return: bb10, unwind unreachable]; } bb10: { -- StorageDead(_28); + StorageDead(_28); StorageDead(_27); _0 = const (); goto -> bb13; @@ -171,27 +180,28 @@ bb11: { StorageLive(_31); -- StorageLive(_32); -- StorageLive(_33); -- _33 = _2; -- StorageLive(_34); -- _34 = _3; + StorageLive(_32); + StorageLive(_33); + _33 = _2; + StorageLive(_34); + _34 = _3; - _32 = Add(move _33, move _34); -- StorageDead(_34); -- StorageDead(_33); ++ _32 = _23; + StorageDead(_34); + StorageDead(_33); - _31 = opaque::<u8>(move _32) -> [return: bb12, unwind unreachable]; + _31 = opaque::<u8>(_23) -> [return: bb12, unwind unreachable]; } bb12: { -- StorageDead(_32); + StorageDead(_32); StorageDead(_31); _0 = const (); goto -> bb13; } bb13: { -- StorageDead(_26); + StorageDead(_26); return; } } diff --git a/tests/mir-opt/gvn.multiple_branches.GVN.panic-unwind.diff b/tests/mir-opt/gvn.multiple_branches.GVN.panic-unwind.diff index 0199f2720a9..5394dc8be8a 100644 --- a/tests/mir-opt/gvn.multiple_branches.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.multiple_branches.GVN.panic-unwind.diff @@ -39,9 +39,9 @@ let mut _34: u8; bb0: { -- StorageLive(_4); -- StorageLive(_5); -- _5 = _1; + StorageLive(_4); + StorageLive(_5); + _5 = _1; - switchInt(move _5) -> [0: bb4, otherwise: bb1]; + switchInt(_1) -> [0: bb4, otherwise: bb1]; } @@ -49,121 +49,130 @@ bb1: { StorageLive(_6); - StorageLive(_7); -- StorageLive(_8); -- _8 = _2; -- StorageLive(_9); -- _9 = _3; ++ nop; + StorageLive(_8); + _8 = _2; + StorageLive(_9); + _9 = _3; - _7 = Add(move _8, move _9); -- StorageDead(_9); -- StorageDead(_8); -- _6 = opaque::<u8>(move _7) -> [return: bb2, unwind continue]; + _7 = Add(_2, _3); + StorageDead(_9); + StorageDead(_8); +- _6 = opaque::<u8>(move _7) -> [return: bb2, unwind continue]; + _6 = opaque::<u8>(_7) -> [return: bb2, unwind continue]; } bb2: { - StorageDead(_7); ++ nop; StorageDead(_6); StorageLive(_10); -- StorageLive(_11); -- StorageLive(_12); -- _12 = _2; -- StorageLive(_13); -- _13 = _3; + StorageLive(_11); + StorageLive(_12); + _12 = _2; + StorageLive(_13); + _13 = _3; - _11 = Add(move _12, move _13); -- StorageDead(_13); -- StorageDead(_12); ++ _11 = _7; + StorageDead(_13); + StorageDead(_12); - _10 = opaque::<u8>(move _11) -> [return: bb3, unwind continue]; + _10 = opaque::<u8>(_7) -> [return: bb3, unwind continue]; } bb3: { -- StorageDead(_11); + StorageDead(_11); StorageDead(_10); -- _4 = const (); + _4 = const (); goto -> bb7; } bb4: { StorageLive(_14); - StorageLive(_15); -- StorageLive(_16); -- _16 = _2; -- StorageLive(_17); -- _17 = _3; ++ nop; + StorageLive(_16); + _16 = _2; + StorageLive(_17); + _17 = _3; - _15 = Add(move _16, move _17); -- StorageDead(_17); -- StorageDead(_16); -- _14 = opaque::<u8>(move _15) -> [return: bb5, unwind continue]; + _15 = Add(_2, _3); + StorageDead(_17); + StorageDead(_16); +- _14 = opaque::<u8>(move _15) -> [return: bb5, unwind continue]; + _14 = opaque::<u8>(_15) -> [return: bb5, unwind continue]; } bb5: { - StorageDead(_15); ++ nop; StorageDead(_14); StorageLive(_18); -- StorageLive(_19); -- StorageLive(_20); -- _20 = _2; -- StorageLive(_21); -- _21 = _3; + StorageLive(_19); + StorageLive(_20); + _20 = _2; + StorageLive(_21); + _21 = _3; - _19 = Add(move _20, move _21); -- StorageDead(_21); -- StorageDead(_20); ++ _19 = _15; + StorageDead(_21); + StorageDead(_20); - _18 = opaque::<u8>(move _19) -> [return: bb6, unwind continue]; + _18 = opaque::<u8>(_15) -> [return: bb6, unwind continue]; } bb6: { -- StorageDead(_19); + StorageDead(_19); StorageDead(_18); -- _4 = const (); + _4 = const (); goto -> bb7; } bb7: { -- StorageDead(_5); -- StorageDead(_4); + StorageDead(_5); + StorageDead(_4); StorageLive(_22); - StorageLive(_23); -- StorageLive(_24); -- _24 = _2; -- StorageLive(_25); -- _25 = _3; ++ nop; + StorageLive(_24); + _24 = _2; + StorageLive(_25); + _25 = _3; - _23 = Add(move _24, move _25); -- StorageDead(_25); -- StorageDead(_24); -- _22 = opaque::<u8>(move _23) -> [return: bb8, unwind continue]; + _23 = Add(_2, _3); + StorageDead(_25); + StorageDead(_24); +- _22 = opaque::<u8>(move _23) -> [return: bb8, unwind continue]; + _22 = opaque::<u8>(_23) -> [return: bb8, unwind continue]; } bb8: { - StorageDead(_23); ++ nop; StorageDead(_22); -- StorageLive(_26); -- _26 = _1; + StorageLive(_26); + _26 = _1; - switchInt(move _26) -> [0: bb11, otherwise: bb9]; + switchInt(_1) -> [0: bb11, otherwise: bb9]; } bb9: { StorageLive(_27); -- StorageLive(_28); -- StorageLive(_29); -- _29 = _2; -- StorageLive(_30); -- _30 = _3; + StorageLive(_28); + StorageLive(_29); + _29 = _2; + StorageLive(_30); + _30 = _3; - _28 = Add(move _29, move _30); -- StorageDead(_30); -- StorageDead(_29); ++ _28 = _23; + StorageDead(_30); + StorageDead(_29); - _27 = opaque::<u8>(move _28) -> [return: bb10, unwind continue]; + _27 = opaque::<u8>(_23) -> [return: bb10, unwind continue]; } bb10: { -- StorageDead(_28); + StorageDead(_28); StorageDead(_27); _0 = const (); goto -> bb13; @@ -171,27 +180,28 @@ bb11: { StorageLive(_31); -- StorageLive(_32); -- StorageLive(_33); -- _33 = _2; -- StorageLive(_34); -- _34 = _3; + StorageLive(_32); + StorageLive(_33); + _33 = _2; + StorageLive(_34); + _34 = _3; - _32 = Add(move _33, move _34); -- StorageDead(_34); -- StorageDead(_33); ++ _32 = _23; + StorageDead(_34); + StorageDead(_33); - _31 = opaque::<u8>(move _32) -> [return: bb12, unwind continue]; + _31 = opaque::<u8>(_23) -> [return: bb12, unwind continue]; } bb12: { -- StorageDead(_32); + StorageDead(_32); StorageDead(_31); _0 = const (); goto -> bb13; } bb13: { -- StorageDead(_26); + StorageDead(_26); return; } } diff --git a/tests/mir-opt/gvn.references.GVN.panic-abort.diff b/tests/mir-opt/gvn.references.GVN.panic-abort.diff index b7ad4ab1fd3..7799c611445 100644 --- a/tests/mir-opt/gvn.references.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.references.GVN.panic-abort.diff @@ -20,6 +20,24 @@ let mut _15: *mut impl Sized; let _16: (); let mut _17: *mut impl Sized; + let _18: &mut impl Sized; + let mut _20: S<&mut impl Sized>; + let mut _21: &mut impl Sized; + let _22: (); + let mut _23: &impl Sized; + let _24: (); + let mut _25: &mut impl Sized; + let _26: (); + let mut _27: *const impl Sized; + let _28: (); + let mut _29: *mut impl Sized; + scope 1 { + debug r => _18; + let _19: &mut impl Sized; + scope 2 { + debug s => _19; + } + } bb0: { StorageLive(_2); @@ -94,11 +112,68 @@ bb8: { StorageDead(_17); StorageDead(_16); - _0 = const (); - drop(_1) -> [return: bb9, unwind unreachable]; +- StorageLive(_18); ++ nop; + _18 = &mut _1; + StorageLive(_19); + StorageLive(_20); + StorageLive(_21); +- _21 = move _18; +- _20 = S::<&mut impl Sized>(move _21); ++ _21 = _18; ++ _20 = S::<&mut impl Sized>(_18); + StorageDead(_21); +- _19 = move (_20.0: &mut impl Sized); ++ _19 = _18; + StorageDead(_20); + StorageLive(_22); + StorageLive(_23); +- _23 = &(*_19); ++ _23 = &(*_18); + _22 = opaque::<&impl Sized>(move _23) -> [return: bb9, unwind unreachable]; } bb9: { + StorageDead(_23); + StorageDead(_22); + StorageLive(_24); + StorageLive(_25); +- _25 = &mut (*_19); ++ _25 = &mut (*_18); + _24 = opaque::<&mut impl Sized>(move _25) -> [return: bb10, unwind unreachable]; + } + + bb10: { + StorageDead(_25); + StorageDead(_24); + StorageLive(_26); + StorageLive(_27); +- _27 = &raw const (*_19); ++ _27 = &raw const (*_18); + _26 = opaque::<*const impl Sized>(move _27) -> [return: bb11, unwind unreachable]; + } + + bb11: { + StorageDead(_27); + StorageDead(_26); + StorageLive(_28); + StorageLive(_29); +- _29 = &raw mut (*_19); ++ _29 = &raw mut (*_18); + _28 = opaque::<*mut impl Sized>(move _29) -> [return: bb12, unwind unreachable]; + } + + bb12: { + StorageDead(_29); + StorageDead(_28); + _0 = const (); + StorageDead(_19); +- StorageDead(_18); ++ nop; + drop(_1) -> [return: bb13, unwind unreachable]; + } + + bb13: { return; } } diff --git a/tests/mir-opt/gvn.references.GVN.panic-unwind.diff b/tests/mir-opt/gvn.references.GVN.panic-unwind.diff index 08ed4c629a6..880e7913fa9 100644 --- a/tests/mir-opt/gvn.references.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.references.GVN.panic-unwind.diff @@ -20,12 +20,30 @@ let mut _15: *mut impl Sized; let _16: (); let mut _17: *mut impl Sized; + let _18: &mut impl Sized; + let mut _20: S<&mut impl Sized>; + let mut _21: &mut impl Sized; + let _22: (); + let mut _23: &impl Sized; + let _24: (); + let mut _25: &mut impl Sized; + let _26: (); + let mut _27: *const impl Sized; + let _28: (); + let mut _29: *mut impl Sized; + scope 1 { + debug r => _18; + let _19: &mut impl Sized; + scope 2 { + debug s => _19; + } + } bb0: { StorageLive(_2); StorageLive(_3); _3 = &_1; - _2 = opaque::<&impl Sized>(move _3) -> [return: bb1, unwind: bb10]; + _2 = opaque::<&impl Sized>(move _3) -> [return: bb1, unwind: bb14]; } bb1: { @@ -34,7 +52,7 @@ StorageLive(_4); StorageLive(_5); _5 = &_1; - _4 = opaque::<&impl Sized>(move _5) -> [return: bb2, unwind: bb10]; + _4 = opaque::<&impl Sized>(move _5) -> [return: bb2, unwind: bb14]; } bb2: { @@ -43,7 +61,7 @@ StorageLive(_6); StorageLive(_7); _7 = &mut _1; - _6 = opaque::<&mut impl Sized>(move _7) -> [return: bb3, unwind: bb10]; + _6 = opaque::<&mut impl Sized>(move _7) -> [return: bb3, unwind: bb14]; } bb3: { @@ -52,7 +70,7 @@ StorageLive(_8); StorageLive(_9); _9 = &mut _1; - _8 = opaque::<&mut impl Sized>(move _9) -> [return: bb4, unwind: bb10]; + _8 = opaque::<&mut impl Sized>(move _9) -> [return: bb4, unwind: bb14]; } bb4: { @@ -61,7 +79,7 @@ StorageLive(_10); StorageLive(_11); _11 = &raw const _1; - _10 = opaque::<*const impl Sized>(move _11) -> [return: bb5, unwind: bb10]; + _10 = opaque::<*const impl Sized>(move _11) -> [return: bb5, unwind: bb14]; } bb5: { @@ -70,7 +88,7 @@ StorageLive(_12); StorageLive(_13); _13 = &raw const _1; - _12 = opaque::<*const impl Sized>(move _13) -> [return: bb6, unwind: bb10]; + _12 = opaque::<*const impl Sized>(move _13) -> [return: bb6, unwind: bb14]; } bb6: { @@ -79,7 +97,7 @@ StorageLive(_14); StorageLive(_15); _15 = &raw mut _1; - _14 = opaque::<*mut impl Sized>(move _15) -> [return: bb7, unwind: bb10]; + _14 = opaque::<*mut impl Sized>(move _15) -> [return: bb7, unwind: bb14]; } bb7: { @@ -88,25 +106,82 @@ StorageLive(_16); StorageLive(_17); _17 = &raw mut _1; - _16 = opaque::<*mut impl Sized>(move _17) -> [return: bb8, unwind: bb10]; + _16 = opaque::<*mut impl Sized>(move _17) -> [return: bb8, unwind: bb14]; } bb8: { StorageDead(_17); StorageDead(_16); - _0 = const (); - drop(_1) -> [return: bb9, unwind: bb11]; +- StorageLive(_18); ++ nop; + _18 = &mut _1; + StorageLive(_19); + StorageLive(_20); + StorageLive(_21); +- _21 = move _18; +- _20 = S::<&mut impl Sized>(move _21); ++ _21 = _18; ++ _20 = S::<&mut impl Sized>(_18); + StorageDead(_21); +- _19 = move (_20.0: &mut impl Sized); ++ _19 = _18; + StorageDead(_20); + StorageLive(_22); + StorageLive(_23); +- _23 = &(*_19); ++ _23 = &(*_18); + _22 = opaque::<&impl Sized>(move _23) -> [return: bb9, unwind: bb14]; } bb9: { + StorageDead(_23); + StorageDead(_22); + StorageLive(_24); + StorageLive(_25); +- _25 = &mut (*_19); ++ _25 = &mut (*_18); + _24 = opaque::<&mut impl Sized>(move _25) -> [return: bb10, unwind: bb14]; + } + + bb10: { + StorageDead(_25); + StorageDead(_24); + StorageLive(_26); + StorageLive(_27); +- _27 = &raw const (*_19); ++ _27 = &raw const (*_18); + _26 = opaque::<*const impl Sized>(move _27) -> [return: bb11, unwind: bb14]; + } + + bb11: { + StorageDead(_27); + StorageDead(_26); + StorageLive(_28); + StorageLive(_29); +- _29 = &raw mut (*_19); ++ _29 = &raw mut (*_18); + _28 = opaque::<*mut impl Sized>(move _29) -> [return: bb12, unwind: bb14]; + } + + bb12: { + StorageDead(_29); + StorageDead(_28); + _0 = const (); + StorageDead(_19); +- StorageDead(_18); ++ nop; + drop(_1) -> [return: bb13, unwind: bb15]; + } + + bb13: { return; } - bb10 (cleanup): { - drop(_1) -> [return: bb11, unwind terminate(cleanup)]; + bb14 (cleanup): { + drop(_1) -> [return: bb15, unwind terminate(cleanup)]; } - bb11 (cleanup): { + bb15 (cleanup): { resume; } } diff --git a/tests/mir-opt/gvn.repeat.GVN.panic-abort.diff b/tests/mir-opt/gvn.repeat.GVN.panic-abort.diff new file mode 100644 index 00000000000..37915f8578d --- /dev/null +++ b/tests/mir-opt/gvn.repeat.GVN.panic-abort.diff @@ -0,0 +1,79 @@ +- // MIR for `repeat` before GVN ++ // MIR for `repeat` after GVN + + fn repeat() -> () { + let mut _0: (); + let _1: i32; + let mut _3: i32; + let mut _4: i32; + let mut _5: i32; + let mut _6: i32; + let mut _7: i32; + let mut _8: i32; + let mut _9: i32; + let mut _10: i32; + let mut _11: i32; + let mut _12: i32; + scope 1 { + debug val => _1; + let _2: [i32; 10]; + scope 2 { + debug array => _2; + } + } + + bb0: { +- StorageLive(_1); ++ nop; + _1 = const 5_i32; + StorageLive(_2); + StorageLive(_3); +- _3 = _1; ++ _3 = const 5_i32; + StorageLive(_4); +- _4 = _1; ++ _4 = const 5_i32; + StorageLive(_5); +- _5 = _1; ++ _5 = const 5_i32; + StorageLive(_6); +- _6 = _1; ++ _6 = const 5_i32; + StorageLive(_7); +- _7 = _1; ++ _7 = const 5_i32; + StorageLive(_8); +- _8 = _1; ++ _8 = const 5_i32; + StorageLive(_9); +- _9 = _1; ++ _9 = const 5_i32; + StorageLive(_10); +- _10 = _1; ++ _10 = const 5_i32; + StorageLive(_11); +- _11 = _1; ++ _11 = const 5_i32; + StorageLive(_12); +- _12 = _1; +- _2 = [move _3, move _4, move _5, move _6, move _7, move _8, move _9, move _10, move _11, move _12]; ++ _12 = const 5_i32; ++ _2 = [const 5_i32; 10]; + StorageDead(_12); + StorageDead(_11); + StorageDead(_10); + StorageDead(_9); + StorageDead(_8); + StorageDead(_7); + StorageDead(_6); + StorageDead(_5); + StorageDead(_4); + StorageDead(_3); + _0 = const (); + StorageDead(_2); +- StorageDead(_1); ++ nop; + return; + } + } + diff --git a/tests/mir-opt/gvn.repeat.GVN.panic-unwind.diff b/tests/mir-opt/gvn.repeat.GVN.panic-unwind.diff new file mode 100644 index 00000000000..37915f8578d --- /dev/null +++ b/tests/mir-opt/gvn.repeat.GVN.panic-unwind.diff @@ -0,0 +1,79 @@ +- // MIR for `repeat` before GVN ++ // MIR for `repeat` after GVN + + fn repeat() -> () { + let mut _0: (); + let _1: i32; + let mut _3: i32; + let mut _4: i32; + let mut _5: i32; + let mut _6: i32; + let mut _7: i32; + let mut _8: i32; + let mut _9: i32; + let mut _10: i32; + let mut _11: i32; + let mut _12: i32; + scope 1 { + debug val => _1; + let _2: [i32; 10]; + scope 2 { + debug array => _2; + } + } + + bb0: { +- StorageLive(_1); ++ nop; + _1 = const 5_i32; + StorageLive(_2); + StorageLive(_3); +- _3 = _1; ++ _3 = const 5_i32; + StorageLive(_4); +- _4 = _1; ++ _4 = const 5_i32; + StorageLive(_5); +- _5 = _1; ++ _5 = const 5_i32; + StorageLive(_6); +- _6 = _1; ++ _6 = const 5_i32; + StorageLive(_7); +- _7 = _1; ++ _7 = const 5_i32; + StorageLive(_8); +- _8 = _1; ++ _8 = const 5_i32; + StorageLive(_9); +- _9 = _1; ++ _9 = const 5_i32; + StorageLive(_10); +- _10 = _1; ++ _10 = const 5_i32; + StorageLive(_11); +- _11 = _1; ++ _11 = const 5_i32; + StorageLive(_12); +- _12 = _1; +- _2 = [move _3, move _4, move _5, move _6, move _7, move _8, move _9, move _10, move _11, move _12]; ++ _12 = const 5_i32; ++ _2 = [const 5_i32; 10]; + StorageDead(_12); + StorageDead(_11); + StorageDead(_10); + StorageDead(_9); + StorageDead(_8); + StorageDead(_7); + StorageDead(_6); + StorageDead(_5); + StorageDead(_4); + StorageDead(_3); + _0 = const (); + StorageDead(_2); +- StorageDead(_1); ++ nop; + return; + } + } + diff --git a/tests/mir-opt/gvn.repeated_index.GVN.panic-abort.diff b/tests/mir-opt/gvn.repeated_index.GVN.panic-abort.diff index 4c29523d6b2..d937902e891 100644 --- a/tests/mir-opt/gvn.repeated_index.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.repeated_index.GVN.panic-abort.diff @@ -23,11 +23,11 @@ bb0: { StorageLive(_3); -- StorageLive(_4); -- _4 = _1; + StorageLive(_4); + _4 = _1; - _3 = [move _4; N]; -- StorageDead(_4); + _3 = [_1; N]; + StorageDead(_4); StorageLive(_5); StorageLive(_6); StorageLive(_7); @@ -40,8 +40,10 @@ } bb1: { - _6 = _3[_7]; - _5 = opaque::<T>(move _6) -> [return: bb2, unwind unreachable]; +- _6 = _3[_7]; +- _5 = opaque::<T>(move _6) -> [return: bb2, unwind unreachable]; ++ _6 = _1; ++ _5 = opaque::<T>(_1) -> [return: bb2, unwind unreachable]; } bb2: { @@ -55,13 +57,16 @@ - _13 = Len(_3); - _14 = Lt(_12, _13); - assert(move _14, "index out of bounds: the length is {} but the index is {}", move _13, _12) -> [success: bb3, unwind unreachable]; ++ _13 = _8; + _14 = Lt(_2, _8); + assert(move _14, "index out of bounds: the length is {} but the index is {}", _8, _2) -> [success: bb3, unwind unreachable]; } bb3: { - _11 = _3[_12]; - _10 = opaque::<T>(move _11) -> [return: bb4, unwind unreachable]; +- _11 = _3[_12]; +- _10 = opaque::<T>(move _11) -> [return: bb4, unwind unreachable]; ++ _11 = _1; ++ _10 = opaque::<T>(_1) -> [return: bb4, unwind unreachable]; } bb4: { diff --git a/tests/mir-opt/gvn.repeated_index.GVN.panic-unwind.diff b/tests/mir-opt/gvn.repeated_index.GVN.panic-unwind.diff index e44f54cf3cf..dd4d24b12ea 100644 --- a/tests/mir-opt/gvn.repeated_index.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.repeated_index.GVN.panic-unwind.diff @@ -23,11 +23,11 @@ bb0: { StorageLive(_3); -- StorageLive(_4); -- _4 = _1; + StorageLive(_4); + _4 = _1; - _3 = [move _4; N]; -- StorageDead(_4); + _3 = [_1; N]; + StorageDead(_4); StorageLive(_5); StorageLive(_6); StorageLive(_7); @@ -40,8 +40,10 @@ } bb1: { - _6 = _3[_7]; - _5 = opaque::<T>(move _6) -> [return: bb2, unwind continue]; +- _6 = _3[_7]; +- _5 = opaque::<T>(move _6) -> [return: bb2, unwind continue]; ++ _6 = _1; ++ _5 = opaque::<T>(_1) -> [return: bb2, unwind continue]; } bb2: { @@ -55,13 +57,16 @@ - _13 = Len(_3); - _14 = Lt(_12, _13); - assert(move _14, "index out of bounds: the length is {} but the index is {}", move _13, _12) -> [success: bb3, unwind continue]; ++ _13 = _8; + _14 = Lt(_2, _8); + assert(move _14, "index out of bounds: the length is {} but the index is {}", _8, _2) -> [success: bb3, unwind continue]; } bb3: { - _11 = _3[_12]; - _10 = opaque::<T>(move _11) -> [return: bb4, unwind continue]; +- _11 = _3[_12]; +- _10 = opaque::<T>(move _11) -> [return: bb4, unwind continue]; ++ _11 = _1; ++ _10 = opaque::<T>(_1) -> [return: bb4, unwind continue]; } bb4: { diff --git a/tests/mir-opt/gvn.rs b/tests/mir-opt/gvn.rs index fd24edc676c..10a66ced026 100644 --- a/tests/mir-opt/gvn.rs +++ b/tests/mir-opt/gvn.rs @@ -1,56 +1,133 @@ -// skip-filecheck // unit-test: GVN // EMIT_MIR_FOR_EACH_PANIC_STRATEGY +// only-64bit #![feature(raw_ref_op)] #![feature(rustc_attrs)] +#![feature(custom_mir)] +#![feature(core_intrinsics)] #![allow(unconditional_panic)] +use std::intrinsics::mir::*; +use std::mem::transmute; + struct S<T>(T); fn subexpression_elimination(x: u64, y: u64, mut z: u64) { + // CHECK-LABEL: fn subexpression_elimination( + + // CHECK: [[add:_.*]] = Add(_1, _2); + // CHECK: opaque::<u64>([[add]]) opaque(x + y); + // CHECK: [[mul:_.*]] = Mul(_1, _2); + // CHECK: opaque::<u64>([[mul]]) opaque(x * y); + // CHECK: [[sub:_.*]] = Sub(_1, _2); + // CHECK: opaque::<u64>([[sub]]) opaque(x - y); + // CHECK: [[div:_.*]] = Div(_1, _2); + // CHECK: opaque::<u64>([[div]]) opaque(x / y); + // CHECK: [[rem:_.*]] = Rem(_1, _2); + // CHECK: opaque::<u64>([[rem]]) opaque(x % y); + // CHECK: [[and:_.*]] = BitAnd(_1, _2); + // CHECK: opaque::<u64>([[and]]) opaque(x & y); + // CHECK: [[or:_.*]] = BitOr(_1, _2); + // CHECK: opaque::<u64>([[or]]) opaque(x | y); + // CHECK: [[xor:_.*]] = BitXor(_1, _2); + // CHECK: opaque::<u64>([[xor]]) opaque(x ^ y); + // CHECK: [[shl:_.*]] = Shl(_1, _2); + // CHECK: opaque::<u64>([[shl]]) opaque(x << y); + // CHECK: [[shr:_.*]] = Shr(_1, _2); + // CHECK: opaque::<u64>([[shr]]) opaque(x >> y); + // CHECK: [[int:_.*]] = _1 as u32 (IntToInt); + // CHECK: opaque::<u32>([[int]]) opaque(x as u32); + // CHECK: [[float:_.*]] = _1 as f32 (IntToFloat); + // CHECK: opaque::<f32>([[float]]) opaque(x as f32); + // CHECK: [[wrap:_.*]] = S::<u64>(_1); + // CHECK: opaque::<S<u64>>([[wrap]]) opaque(S(x)); + // CHECK: opaque::<u64>(_1) opaque(S(x).0); // Those are duplicates to substitute somehow. - opaque((x + y) + z); - opaque((x * y) + z); - opaque((x - y) + z); - opaque((x / y) + z); - opaque((x % y) + z); - opaque((x & y) + z); - opaque((x | y) + z); - opaque((x ^ y) + z); - opaque((x << y) + z); - opaque((x >> y) + z); + // CHECK: opaque::<u64>([[add]]) + opaque(x + y); + // CHECK: opaque::<u64>([[mul]]) + opaque(x * y); + // CHECK: opaque::<u64>([[sub]]) + opaque(x - y); + // CHECK: opaque::<u64>([[div]]) + opaque(x / y); + // CHECK: opaque::<u64>([[rem]]) + opaque(x % y); + // CHECK: opaque::<u64>([[and]]) + opaque(x & y); + // CHECK: opaque::<u64>([[or]]) + opaque(x | y); + // CHECK: opaque::<u64>([[xor]]) + opaque(x ^ y); + // CHECK: opaque::<u64>([[shl]]) + opaque(x << y); + // CHECK: opaque::<u64>([[shr]]) + opaque(x >> y); + // CHECK: opaque::<u32>([[int]]) + opaque(x as u32); + // CHECK: opaque::<f32>([[float]]) + opaque(x as f32); + // CHECK: opaque::<S<u64>>([[wrap]]) opaque(S(x)); + // CHECK: opaque::<u64>(_1) opaque(S(x).0); + // We can substitute through a complex expression. + // CHECK: [[compound:_.*]] = Sub([[mul]], _2); + // CHECK: opaque::<u64>([[compound]]) + // CHECK: opaque::<u64>([[compound]]) + opaque((x * y) - y); + opaque((x * y) - y); + // We can substitute through an immutable reference too. + // CHECK: [[ref:_.*]] = &_3; + // CHECK: [[deref:_.*]] = (*[[ref]]); + // CHECK: [[addref:_.*]] = Add([[deref]], _1); + // CHECK: opaque::<u64>([[addref]]) + // CHECK: opaque::<u64>([[addref]]) let a = &z; opaque(*a + x); opaque(*a + x); // But not through a mutable reference or a pointer. + // CHECK: [[mut:_.*]] = &mut _3; + // CHECK: [[addmut:_.*]] = Add( + // CHECK: opaque::<u64>(move [[addmut]]) + // CHECK: [[addmut2:_.*]] = Add( + // CHECK: opaque::<u64>(move [[addmut2]]) let b = &mut z; opaque(*b + x); opaque(*b + x); unsafe { + // CHECK: [[raw:_.*]] = &raw const _3; + // CHECK: [[addraw:_.*]] = Add( + // CHECK: opaque::<u64>(move [[addraw]]) + // CHECK: [[addraw2:_.*]] = Add( + // CHECK: opaque::<u64>(move [[addraw2]]) let c = &raw const z; opaque(*c + x); opaque(*c + x); + // CHECK: [[ptr:_.*]] = &raw mut _3; + // CHECK: [[addptr:_.*]] = Add( + // CHECK: opaque::<u64>(move [[addptr]]) + // CHECK: [[addptr2:_.*]] = Add( + // CHECK: opaque::<u64>(move [[addptr2]]) let d = &raw mut z; opaque(*d + x); opaque(*d + x); @@ -58,13 +135,21 @@ fn subexpression_elimination(x: u64, y: u64, mut z: u64) { // We can substitute again, but not with the earlier computations. // Important: `e` is not `a`! + // CHECK: [[ref2:_.*]] = &_3; + // CHECK: [[deref2:_.*]] = (*[[ref2]]); + // CHECK: [[addref2:_.*]] = Add([[deref2]], _1); + // CHECK: opaque::<u64>([[addref2]]) + // CHECK: opaque::<u64>([[addref2]]) let e = &z; opaque(*e + x); opaque(*e + x); - } fn wrap_unwrap<T: Copy>(x: T) -> T { + // CHECK-LABEL: fn wrap_unwrap( + // CHECK: [[some:_.*]] = Option::<T>::Some(_1); + // CHECK: switchInt(const 1_isize) + // CHECK: _0 = _1; match Some(x) { Some(y) => y, None => panic!(), @@ -72,163 +157,464 @@ fn wrap_unwrap<T: Copy>(x: T) -> T { } fn repeated_index<T: Copy, const N: usize>(x: T, idx: usize) { + // CHECK-LABEL: fn repeated_index( + // CHECK: [[a:_.*]] = [_1; N]; let a = [x; N]; + // CHECK: opaque::<T>(_1) opaque(a[0]); + // CHECK: opaque::<T>(_1) opaque(a[idx]); } +/// Verify symbolic integer arithmetic simplifications. fn arithmetic(x: u64) { + // CHECK-LABEL: fn arithmetic( + // CHECK: [[add:_.*]] = Add(_1, const 0_u64); + // CHECK: opaque::<u64>(move [[add]]) opaque(x + 0); + // CHECK: [[sub:_.*]] = Sub(_1, const 0_u64); + // CHECK: opaque::<u64>(move [[sub]]) opaque(x - 0); + // CHECK: [[mul0:_.*]] = Mul(_1, const 0_u64); + // CHECK: opaque::<u64>(move [[mul0]]) opaque(x * 0); + // CHECK: [[mul1:_.*]] = Mul(_1, const 1_u64); + // CHECK: opaque::<u64>(move [[mul1]]) opaque(x * 1); + // CHECK: [[div0:_.*]] = Div(_1, const 0_u64); + // CHECK: opaque::<u64>(move [[div0]]) opaque(x / 0); + // CHECK: [[div1:_.*]] = Div(_1, const 1_u64); + // CHECK: opaque::<u64>(move [[div1]]) opaque(x / 1); + // CHECK: [[zdiv:_.*]] = Div(const 0_u64, _1); + // CHECK: opaque::<u64>(move [[zdiv]]) opaque(0 / x); + // CHECK: [[odiv:_.*]] = Div(const 1_u64, _1); + // CHECK: opaque::<u64>(move [[odiv]]) opaque(1 / x); + // CHECK: [[rem0:_.*]] = Rem(_1, const 0_u64); + // CHECK: opaque::<u64>(move [[rem0]]) opaque(x % 0); + // CHECK: [[rem1:_.*]] = Rem(_1, const 1_u64); + // CHECK: opaque::<u64>(move [[rem1]]) opaque(x % 1); + // CHECK: [[zrem:_.*]] = Rem(const 0_u64, _1); + // CHECK: opaque::<u64>(move [[zrem]]) opaque(0 % x); + // CHECK: [[orem:_.*]] = Rem(const 1_u64, _1); + // CHECK: opaque::<u64>(move [[orem]]) opaque(1 % x); + // CHECK: [[and:_.*]] = BitAnd(_1, const 0_u64); + // CHECK: opaque::<u64>(move [[and]]) opaque(x & 0); + // CHECK: [[or:_.*]] = BitOr(_1, const 0_u64); + // CHECK: opaque::<u64>(move [[or]]) opaque(x | 0); + // CHECK: [[xor:_.*]] = BitXor(_1, const 0_u64); + // CHECK: opaque::<u64>(move [[xor]]) opaque(x ^ 0); + // CHECK: [[shr:_.*]] = Shr(_1, const 0_i32); + // CHECK: opaque::<u64>(move [[shr]]) opaque(x >> 0); + // CHECK: [[shl:_.*]] = Shl(_1, const 0_i32); + // CHECK: opaque::<u64>(move [[shl]]) opaque(x << 0); } +fn comparison(x: u64, y: u64) { + // CHECK-LABEL: fn comparison( + // CHECK: [[eqxx:_.*]] = Eq(_1, _1); + // CHECK: opaque::<bool>(move [[eqxx]]) + opaque(x == x); + // CHECK: [[nexx:_.*]] = Ne(_1, _1); + // CHECK: opaque::<bool>(move [[nexx]]) + opaque(x != x); + // CHECK: [[eqxy:_.*]] = Eq(_1, _2); + // CHECK: opaque::<bool>(move [[eqxy]]) + opaque(x == y); + // CHECK: [[nexy:_.*]] = Ne(_1, _2); + // CHECK: opaque::<bool>(move [[nexy]]) + opaque(x != y); +} + +/// Verify symbolic integer arithmetic simplifications on checked ops. #[rustc_inherit_overflow_checks] fn arithmetic_checked(x: u64) { + // CHECK-LABEL: fn arithmetic_checked( + // CHECK: [[cadd:_.*]] = CheckedAdd(_1, const 0_u64); + // CHECK: [[add:_.*]] = move ([[cadd]].0: u64); + // CHECK: opaque::<u64>(move [[add]]) opaque(x + 0); + // CHECK: [[csub:_.*]] = CheckedSub(_1, const 0_u64); + // CHECK: [[sub:_.*]] = move ([[csub]].0: u64); + // CHECK: opaque::<u64>(move [[sub]]) opaque(x - 0); + // CHECK: [[cmul0:_.*]] = CheckedMul(_1, const 0_u64); + // CHECK: [[mul0:_.*]] = move ([[cmul0]].0: u64); + // CHECK: opaque::<u64>(move [[mul0]]) opaque(x * 0); + // CHECK: [[cmul1:_.*]] = CheckedMul(_1, const 1_u64); + // CHECK: [[mul1:_.*]] = move ([[cmul1]].0: u64); + // CHECK: opaque::<u64>(move [[mul1]]) opaque(x * 1); - opaque(x / 0); - opaque(x / 1); - opaque(0 / x); - opaque(1 / x); - opaque(x % 0); - opaque(x % 1); - opaque(0 % x); - opaque(1 % x); - opaque(x & 0); - opaque(x | 0); - opaque(x ^ 0); - opaque(x >> 0); - opaque(x << 0); } +/// Verify that we do not apply arithmetic simplifications on floats. fn arithmetic_float(x: f64) { + // CHECK-LABEL: fn arithmetic_float( + // CHECK: [[add:_.*]] = Add(_1, const 0f64); + // CHECK: opaque::<f64>(move [[add]]) opaque(x + 0.); + // CHECK: [[sub:_.*]] = Sub(_1, const 0f64); + // CHECK: opaque::<f64>(move [[sub]]) opaque(x - 0.); + // CHECK: [[mul:_.*]] = Mul(_1, const 0f64); + // CHECK: opaque::<f64>(move [[mul]]) opaque(x * 0.); + // CHECK: [[div0:_.*]] = Div(_1, const 0f64); + // CHECK: opaque::<f64>(move [[div0]]) opaque(x / 0.); + // CHECK: [[zdiv:_.*]] = Div(const 0f64, _1); + // CHECK: opaque::<f64>(move [[zdiv]]) opaque(0. / x); + // CHECK: [[rem0:_.*]] = Rem(_1, const 0f64); + // CHECK: opaque::<f64>(move [[rem0]]) opaque(x % 0.); + // CHECK: [[zrem:_.*]] = Rem(const 0f64, _1); + // CHECK: opaque::<f64>(move [[zrem]]) opaque(0. % x); // Those are not simplifiable to `true`/`false`, thanks to NaNs. + // CHECK: [[eq:_.*]] = Eq(_1, _1); + // CHECK: opaque::<bool>(move [[eq]]) opaque(x == x); + // CHECK: [[ne:_.*]] = Ne(_1, _1); + // CHECK: opaque::<bool>(move [[ne]]) opaque(x != x); } fn cast() { + // CHECK-LABEL: fn cast( let i = 1_i64; let u = 1_u64; let f = 1_f64; + // CHECK: opaque::<u8>(const 1_u8) opaque(i as u8); + // CHECK: opaque::<u16>(const 1_u16) opaque(i as u16); + // CHECK: opaque::<u32>(const 1_u32) opaque(i as u32); + // CHECK: opaque::<u64>(const 1_u64) opaque(i as u64); + // CHECK: opaque::<i8>(const 1_i8) opaque(i as i8); + // CHECK: opaque::<i16>(const 1_i16) opaque(i as i16); + // CHECK: opaque::<i32>(const 1_i32) opaque(i as i32); + // CHECK: opaque::<i64>(const 1_i64) opaque(i as i64); + // CHECK: opaque::<f32>(const 1f32) opaque(i as f32); + // CHECK: opaque::<f64>(const 1f64) opaque(i as f64); + // CHECK: opaque::<u8>(const 1_u8) opaque(u as u8); + // CHECK: opaque::<u16>(const 1_u16) opaque(u as u16); + // CHECK: opaque::<u32>(const 1_u32) opaque(u as u32); + // CHECK: opaque::<u64>(const 1_u64) opaque(u as u64); + // CHECK: opaque::<i8>(const 1_i8) opaque(u as i8); + // CHECK: opaque::<i16>(const 1_i16) opaque(u as i16); + // CHECK: opaque::<i32>(const 1_i32) opaque(u as i32); + // CHECK: opaque::<i64>(const 1_i64) opaque(u as i64); + // CHECK: opaque::<f32>(const 1f32) opaque(u as f32); + // CHECK: opaque::<f64>(const 1f64) opaque(u as f64); + // CHECK: opaque::<u8>(const 1_u8) opaque(f as u8); + // CHECK: opaque::<u16>(const 1_u16) opaque(f as u16); + // CHECK: opaque::<u32>(const 1_u32) opaque(f as u32); + // CHECK: opaque::<u64>(const 1_u64) opaque(f as u64); + // CHECK: opaque::<i8>(const 1_i8) opaque(f as i8); + // CHECK: opaque::<i16>(const 1_i16) opaque(f as i16); + // CHECK: opaque::<i32>(const 1_i32) opaque(f as i32); + // CHECK: opaque::<i64>(const 1_i64) opaque(f as i64); + // CHECK: opaque::<f32>(const 1f32) opaque(f as f32); + // CHECK: opaque::<f64>(const 1f64) opaque(f as f64); } fn multiple_branches(t: bool, x: u8, y: u8) { + // CHECK-LABEL: fn multiple_branches( + // CHECK: switchInt(_1) -> [0: [[bbf:bb.*]], otherwise: [[bbt:bb.*]]]; if t { - opaque(x + y); // a - opaque(x + y); // should reuse a + // CHECK: [[bbt]]: { + // CHECK: [[a:_.*]] = Add(_2, _3); + // CHECK: opaque::<u8>([[a]]) + // CHECK: opaque::<u8>([[a]]) + // CHECK: goto -> [[bbc:bb.*]]; + opaque(x + y); + opaque(x + y); } else { - opaque(x + y); // b - opaque(x + y); // shoud reuse b + // CHECK: [[bbf]]: { + // CHECK: [[b:_.*]] = Add(_2, _3); + // CHECK: opaque::<u8>([[b]]) + // CHECK: opaque::<u8>([[b]]) + // CHECK: goto -> [[bbc:bb.*]]; + opaque(x + y); + opaque(x + y); } - opaque(x + y); // c + // Neither `a` nor `b` dominate `c`, so we cannot reuse any of them. + // CHECK: [[bbc]]: { + // CHECK: [[c:_.*]] = Add(_2, _3); + // CHECK: opaque::<u8>([[c]]) + opaque(x + y); + + // `c` dominates both calls, so we can reuse it. if t { - opaque(x + y); // should reuse c + // CHECK: opaque::<u8>([[c]]) + opaque(x + y); } else { - opaque(x + y); // should reuse c + // CHECK: opaque::<u8>([[c]]) + opaque(x + y); } } +/// Verify that we do not reuse a `&raw? mut?` rvalue. fn references(mut x: impl Sized) { + // CHECK-LABEL: fn references( + // CHECK: [[ref1:_.*]] = &_1; + // CHECK: opaque::<&impl Sized>(move [[ref1]]) opaque(&x); - opaque(&x); // should not reuse a + // CHECK: [[ref2:_.*]] = &_1; + // CHECK: opaque::<&impl Sized>(move [[ref2]]) + opaque(&x); + // CHECK: [[ref3:_.*]] = &mut _1; + // CHECK: opaque::<&mut impl Sized>(move [[ref3]]) + opaque(&mut x); + // CHECK: [[ref4:_.*]] = &mut _1; + // CHECK: opaque::<&mut impl Sized>(move [[ref4]]) opaque(&mut x); - opaque(&mut x); // should not reuse a + // CHECK: [[ref5:_.*]] = &raw const _1; + // CHECK: opaque::<*const impl Sized>(move [[ref5]]) opaque(&raw const x); - opaque(&raw const x); // should not reuse a + // CHECK: [[ref6:_.*]] = &raw const _1; + // CHECK: opaque::<*const impl Sized>(move [[ref6]]) + opaque(&raw const x); + // CHECK: [[ref7:_.*]] = &raw mut _1; + // CHECK: opaque::<*mut impl Sized>(move [[ref7]]) + opaque(&raw mut x); + // CHECK: [[ref8:_.*]] = &raw mut _1; + // CHECK: opaque::<*mut impl Sized>(move [[ref8]]) opaque(&raw mut x); - opaque(&raw mut x); // should not reuse a + + let r = &mut x; + let s = S(r).0; // Obfuscate `r`. Following lines should still reborrow `r`. + // CHECK: [[ref9:_.*]] = &mut _1; + // CHECK: [[ref10:_.*]] = &(*[[ref9]]); + // CHECK: opaque::<&impl Sized>(move [[ref10]]) + opaque(&*s); + // CHECK: [[ref11:_.*]] = &mut (*[[ref9]]); + // CHECK: opaque::<&mut impl Sized>(move [[ref11]]) + opaque(&mut *s); + // CHECK: [[ref12:_.*]] = &raw const (*[[ref9]]); + // CHECK: opaque::<*const impl Sized>(move [[ref12]]) + opaque(&raw const *s); + // CHECK: [[ref12:_.*]] = &raw mut (*[[ref9]]); + // CHECK: opaque::<*mut impl Sized>(move [[ref12]]) + opaque(&raw mut *s); } fn dereferences(t: &mut u32, u: &impl Copy, s: &S<u32>) { + // CHECK-LABEL: fn dereferences( + + // Do not reuse dereferences of `&mut`. + // CHECK: [[st1:_.*]] = (*_1); + // CHECK: opaque::<u32>(move [[st1]]) + // CHECK: [[st2:_.*]] = (*_1); + // CHECK: opaque::<u32>(move [[st2]]) opaque(*t); - opaque(*t); // this cannot reuse a, as x is &mut. + opaque(*t); + + // Do not reuse dereferences of `*const`. + // CHECK: [[raw:_.*]] = &raw const (*_1); + // CHECK: [[st3:_.*]] = (*[[raw]]); + // CHECK: opaque::<u32>(move [[st3]]) + // CHECK: [[st4:_.*]] = (*[[raw]]); + // CHECK: opaque::<u32>(move [[st4]]) let z = &raw const *t; unsafe { opaque(*z) }; - unsafe { opaque(*z) }; // this cannot reuse a, as x is *const. + unsafe { opaque(*z) }; + + // Do not reuse dereferences of `*mut`. + // CHECK: [[ptr:_.*]] = &raw mut (*_1); + // CHECK: [[st5:_.*]] = (*[[ptr]]); + // CHECK: opaque::<u32>(move [[st5]]) + // CHECK: [[st6:_.*]] = (*[[ptr]]); + // CHECK: opaque::<u32>(move [[st6]]) let z = &raw mut *t; unsafe { opaque(*z) }; - unsafe { opaque(*z) }; // this cannot reuse a, as x is *mut. + unsafe { opaque(*z) }; + + // We can reuse dereferences of `&Freeze`. + // CHECK: [[ref:_.*]] = &(*_1); + // CHECK: [[st7:_.*]] = (*[[ref]]); + // CHECK: opaque::<u32>([[st7]]) + // CHECK: opaque::<u32>([[st7]]) let z = &*t; opaque(*z); - opaque(*z); // this can reuse, as `z` is immutable ref, Freeze and Copy. - opaque(&*z); // but not for a reborrow. + opaque(*z); + // But not in reborrows. + // CHECK: [[reborrow:_.*]] = &(*[[ref]]); + // CHECK: opaque::<&u32>(move [[reborrow]]) + opaque(&*z); + + // `*u` is not Freeze, so we cannot reuse. + // CHECK: [[st8:_.*]] = (*_2); + // CHECK: opaque::<impl Copy>(move [[st8]]) + // CHECK: [[st9:_.*]] = (*_2); + // CHECK: opaque::<impl Copy>(move [[st9]]) opaque(*u); - opaque(*u); // this cannot reuse, as `z` is not Freeze. + opaque(*u); + + // `*s` is not Copy, by `(*s).0` is, so we can reuse. + // CHECK: [[st10:_.*]] = ((*_3).0: u32); + // CHECK: opaque::<u32>([[st10]]) + // CHECK: opaque::<u32>([[st10]]) + opaque(s.0); opaque(s.0); - opaque(s.0); // *s is not Copy, by (*s).0 is, so we can reuse. } fn slices() { + // CHECK-LABEL: fn slices( + // CHECK: {{_.*}} = const " + // CHECK-NOT: {{_.*}} = const " let s = "my favourite slice"; // This is a `Const::Slice` in MIR. opaque(s); let t = s; // This should be the same pointer, so cannot be a `Const::Slice`. opaque(t); assert_eq!(s.as_ptr(), t.as_ptr()); - let u = unsafe { std::mem::transmute::<&str, &[u8]>(s) }; + let u = unsafe { transmute::<&str, &[u8]>(s) }; opaque(u); assert_eq!(s.as_ptr(), u.as_ptr()); } +#[custom_mir(dialect = "analysis")] +fn duplicate_slice() -> (bool, bool) { + // CHECK-LABEL: fn duplicate_slice( + mir!( + let au: u128; + let bu: u128; + let cu: u128; + let du: u128; + let c: &str; + let d: &str; + { + // CHECK: [[a:_.*]] = (const "a",); + // CHECK: [[au:_.*]] = ([[a]].0: &str) as u128 (Transmute); + let a = ("a",); + Call(au = transmute::<_, u128>(a.0), bb1) + } + bb1 = { + // CHECK: [[c:_.*]] = identity::<&str>(([[a]].0: &str)) + Call(c = identity(a.0), bb2) + } + bb2 = { + // CHECK: [[cu:_.*]] = [[c]] as u128 (Transmute); + Call(cu = transmute::<_, u128>(c), bb3) + } + bb3 = { + // This slice is different from `a.0`. Hence `bu` is not `au`. + // CHECK: [[b:_.*]] = const "a"; + // CHECK: [[bu:_.*]] = [[b]] as u128 (Transmute); + let b = "a"; + Call(bu = transmute::<_, u128>(b), bb4) + } + bb4 = { + // This returns a copy of `b`, which is not `a`. + // CHECK: [[d:_.*]] = identity::<&str>([[b]]) + Call(d = identity(b), bb5) + } + bb5 = { + // CHECK: [[du:_.*]] = [[d]] as u128 (Transmute); + Call(du = transmute::<_, u128>(d), bb6) + } + bb6 = { + // `direct` must not fold to `true`, as `indirect` will not. + // CHECK: = Eq([[au]], [[bu]]); + // CHECK: = Eq([[cu]], [[du]]); + let direct = au == bu; + let indirect = cu == du; + RET = (direct, indirect); + Return() + } + ) +} + +fn repeat() { + // CHECK-LABEL: fn repeat( + // CHECK: = [const 5_i32; 10]; + let val = 5; + let array = [val, val, val, val, val, val, val, val, val, val]; +} + +/// Verify that we do not merge fn pointers created by casts. +fn fn_pointers() { + // CHECK-LABEL: fn fn_pointers( + // CHECK: [[f:_.*]] = identity::<u8> as fn(u8) -> u8 (PointerCoercion(ReifyFnPointer + // CHECK: opaque::<fn(u8) -> u8>([[f]]) + let f = identity as fn(u8) -> u8; + opaque(f); + // CHECK: [[g:_.*]] = identity::<u8> as fn(u8) -> u8 (PointerCoercion(ReifyFnPointer + // CHECK: opaque::<fn(u8) -> u8>([[g]]) + let g = identity as fn(u8) -> u8; + opaque(g); + + // CHECK: [[cf:_.*]] = const {{.*}} as fn() (PointerCoercion(ClosureFnPointer + // CHECK: opaque::<fn()>([[cf]]) + let closure = || {}; + let cf = closure as fn(); + opaque(cf); + // CHECK: [[cg:_.*]] = const {{.*}} as fn() (PointerCoercion(ClosureFnPointer + // CHECK: opaque::<fn()>([[cg]]) + let cg = closure as fn(); + opaque(cg); +} + +/// Verify that we do not create a `ConstValue::Indirect` backed by a static's AllocId. +#[custom_mir(dialect = "analysis")] +fn indirect_static() { + static A: Option<u8> = None; + + mir!({ + let ptr = Static(A); + let out = Field::<u8>(Variant(*ptr, 1), 0); + Return() + }) +} + fn main() { subexpression_elimination(2, 4, 5); wrap_unwrap(5); repeated_index::<u32, 7>(5, 3); arithmetic(5); + comparison(5, 6); arithmetic_checked(5); arithmetic_float(5.); cast(); @@ -236,15 +622,26 @@ fn main() { references(5); dereferences(&mut 5, &6, &S(7)); slices(); + let (direct, indirect) = duplicate_slice(); + assert_eq!(direct, indirect); + repeat(); + fn_pointers(); + indirect_static(); } #[inline(never)] fn opaque(_: impl Sized) {} +#[inline(never)] +fn identity<T>(x: T) -> T { + x +} + // EMIT_MIR gvn.subexpression_elimination.GVN.diff // EMIT_MIR gvn.wrap_unwrap.GVN.diff // EMIT_MIR gvn.repeated_index.GVN.diff // EMIT_MIR gvn.arithmetic.GVN.diff +// EMIT_MIR gvn.comparison.GVN.diff // EMIT_MIR gvn.arithmetic_checked.GVN.diff // EMIT_MIR gvn.arithmetic_float.GVN.diff // EMIT_MIR gvn.cast.GVN.diff @@ -252,3 +649,7 @@ fn opaque(_: impl Sized) {} // EMIT_MIR gvn.references.GVN.diff // EMIT_MIR gvn.dereferences.GVN.diff // EMIT_MIR gvn.slices.GVN.diff +// EMIT_MIR gvn.duplicate_slice.GVN.diff +// EMIT_MIR gvn.repeat.GVN.diff +// EMIT_MIR gvn.fn_pointers.GVN.diff +// EMIT_MIR gvn.indirect_static.GVN.diff diff --git a/tests/mir-opt/gvn.slices.GVN.panic-abort.diff b/tests/mir-opt/gvn.slices.GVN.panic-abort.diff index de3d28d0575..ec449980312 100644 --- a/tests/mir-opt/gvn.slices.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.slices.GVN.panic-abort.diff @@ -85,32 +85,35 @@ bb0: { - StorageLive(_1); ++ nop; _1 = const "my favourite slice"; StorageLive(_2); -- StorageLive(_3); -- _3 = _1; + StorageLive(_3); + _3 = _1; - _2 = opaque::<&str>(move _3) -> [return: bb1, unwind unreachable]; + _2 = opaque::<&str>(_1) -> [return: bb1, unwind unreachable]; } bb1: { -- StorageDead(_3); + StorageDead(_3); StorageDead(_2); StorageLive(_4); _4 = _1; StorageLive(_5); -- StorageLive(_6); + StorageLive(_6); - _6 = _4; - _5 = opaque::<&str>(move _6) -> [return: bb2, unwind unreachable]; ++ _6 = _1; + _5 = opaque::<&str>(_1) -> [return: bb2, unwind unreachable]; } bb2: { -- StorageDead(_6); + StorageDead(_6); StorageDead(_5); -- StorageLive(_7); + StorageLive(_7); StorageLive(_8); - StorageLive(_9); +- StorageLive(_9); ++ nop; StorageLive(_10); StorageLive(_11); _11 = &(*_1); @@ -120,28 +123,37 @@ bb3: { StorageDead(_11); _9 = &_10; - StorageLive(_12); +- StorageLive(_12); ++ nop; StorageLive(_13); StorageLive(_14); - _14 = &(*_4); +- _14 = &(*_4); ++ _14 = &(*_1); _13 = core::str::<impl str>::as_ptr(move _14) -> [return: bb4, unwind unreachable]; } bb4: { StorageDead(_14); _12 = &_13; - _8 = (move _9, move _12); - StorageDead(_12); - StorageDead(_9); +- _8 = (move _9, move _12); +- StorageDead(_12); +- StorageDead(_9); ++ _8 = (_9, _12); ++ nop; ++ nop; StorageLive(_15); - _15 = (_8.0: &*const u8); +- _15 = (_8.0: &*const u8); ++ _15 = _9; StorageLive(_16); - _16 = (_8.1: &*const u8); +- _16 = (_8.1: &*const u8); ++ _16 = _12; StorageLive(_17); StorageLive(_18); - _18 = (*_15); +- _18 = (*_15); ++ _18 = (*_9); StorageLive(_19); - _19 = (*_16); +- _19 = (*_16); ++ _19 = (*_12); _17 = Eq(move _18, move _19); switchInt(move _17) -> [0: bb6, otherwise: bb5]; } @@ -149,22 +161,23 @@ bb5: { StorageDead(_19); StorageDead(_18); -- _7 = const (); + _7 = const (); StorageDead(_17); StorageDead(_16); StorageDead(_15); StorageDead(_13); StorageDead(_10); StorageDead(_8); -- StorageDead(_7); + StorageDead(_7); - StorageLive(_29); ++ nop; StorageLive(_30); _30 = &(*_1); _29 = move _30 as &[u8] (Transmute); StorageDead(_30); StorageLive(_31); -- StorageLive(_32); -- _32 = _29; + StorageLive(_32); + _32 = _29; - _31 = opaque::<&[u8]>(move _32) -> [return: bb7, unwind unreachable]; + _31 = opaque::<&[u8]>(_29) -> [return: bb7, unwind unreachable]; } @@ -173,30 +186,38 @@ StorageDead(_19); StorageDead(_18); - StorageLive(_21); - _21 = core::panicking::AssertKind::Eq; +- _21 = core::panicking::AssertKind::Eq; ++ nop; ++ _21 = const core::panicking::AssertKind::Eq; StorageLive(_22); -- StorageLive(_23); + StorageLive(_23); - _23 = move _21; ++ _23 = const core::panicking::AssertKind::Eq; StorageLive(_24); - StorageLive(_25); - _25 = &(*_15); +- StorageLive(_25); +- _25 = &(*_15); ++ nop; ++ _25 = &(*_9); _24 = &(*_25); StorageLive(_26); - StorageLive(_27); - _27 = &(*_16); +- StorageLive(_27); +- _27 = &(*_16); ++ nop; ++ _27 = &(*_12); _26 = &(*_27); StorageLive(_28); _28 = Option::<Arguments<'_>>::None; -- _22 = core::panicking::assert_failed::<*const u8, *const u8>(move _23, move _24, move _26, move _28) -> unwind unreachable; -+ _22 = core::panicking::assert_failed::<*const u8, *const u8>(_21, move _24, move _26, move _28) -> unwind unreachable; +- _22 = assert_failed::<*const u8, *const u8>(move _23, move _24, move _26, move _28) -> unwind unreachable; ++ _22 = assert_failed::<*const u8, *const u8>(const core::panicking::AssertKind::Eq, move _24, move _26, move _28) -> unwind unreachable; } bb7: { -- StorageDead(_32); + StorageDead(_32); StorageDead(_31); -- StorageLive(_33); + StorageLive(_33); StorageLive(_34); - StorageLive(_35); +- StorageLive(_35); ++ nop; StorageLive(_36); StorageLive(_37); _37 = &(*_1); @@ -206,7 +227,8 @@ bb8: { StorageDead(_37); _35 = &_36; - StorageLive(_38); +- StorageLive(_38); ++ nop; StorageLive(_39); StorageLive(_40); _40 = &(*_29); @@ -216,18 +238,25 @@ bb9: { StorageDead(_40); _38 = &_39; - _34 = (move _35, move _38); - StorageDead(_38); - StorageDead(_35); +- _34 = (move _35, move _38); +- StorageDead(_38); +- StorageDead(_35); ++ _34 = (_35, _38); ++ nop; ++ nop; StorageLive(_41); - _41 = (_34.0: &*const u8); +- _41 = (_34.0: &*const u8); ++ _41 = _35; StorageLive(_42); - _42 = (_34.1: &*const u8); +- _42 = (_34.1: &*const u8); ++ _42 = _38; StorageLive(_43); StorageLive(_44); - _44 = (*_41); +- _44 = (*_41); ++ _44 = (*_35); StorageLive(_45); - _45 = (*_42); +- _45 = (*_42); ++ _45 = (*_38); _43 = Eq(move _44, move _45); switchInt(move _43) -> [0: bb11, otherwise: bb10]; } @@ -235,18 +264,20 @@ bb10: { StorageDead(_45); StorageDead(_44); -- _33 = const (); + _33 = const (); StorageDead(_43); StorageDead(_42); StorageDead(_41); StorageDead(_39); StorageDead(_36); StorageDead(_34); -- StorageDead(_33); + StorageDead(_33); _0 = const (); - StorageDead(_29); ++ nop; StorageDead(_4); - StorageDead(_1); ++ nop; return; } @@ -254,22 +285,29 @@ StorageDead(_45); StorageDead(_44); - StorageLive(_47); - _47 = core::panicking::AssertKind::Eq; +- _47 = core::panicking::AssertKind::Eq; ++ nop; ++ _47 = const core::panicking::AssertKind::Eq; StorageLive(_48); -- StorageLive(_49); + StorageLive(_49); - _49 = move _47; ++ _49 = const core::panicking::AssertKind::Eq; StorageLive(_50); - StorageLive(_51); - _51 = &(*_41); +- StorageLive(_51); +- _51 = &(*_41); ++ nop; ++ _51 = &(*_35); _50 = &(*_51); StorageLive(_52); - StorageLive(_53); - _53 = &(*_42); +- StorageLive(_53); +- _53 = &(*_42); ++ nop; ++ _53 = &(*_38); _52 = &(*_53); StorageLive(_54); _54 = Option::<Arguments<'_>>::None; -- _48 = core::panicking::assert_failed::<*const u8, *const u8>(move _49, move _50, move _52, move _54) -> unwind unreachable; -+ _48 = core::panicking::assert_failed::<*const u8, *const u8>(_47, move _50, move _52, move _54) -> unwind unreachable; +- _48 = assert_failed::<*const u8, *const u8>(move _49, move _50, move _52, move _54) -> unwind unreachable; ++ _48 = assert_failed::<*const u8, *const u8>(const core::panicking::AssertKind::Eq, move _50, move _52, move _54) -> unwind unreachable; } } diff --git a/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff b/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff index f22bb25436f..56a78ca8694 100644 --- a/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff @@ -85,32 +85,35 @@ bb0: { - StorageLive(_1); ++ nop; _1 = const "my favourite slice"; StorageLive(_2); -- StorageLive(_3); -- _3 = _1; + StorageLive(_3); + _3 = _1; - _2 = opaque::<&str>(move _3) -> [return: bb1, unwind continue]; + _2 = opaque::<&str>(_1) -> [return: bb1, unwind continue]; } bb1: { -- StorageDead(_3); + StorageDead(_3); StorageDead(_2); StorageLive(_4); _4 = _1; StorageLive(_5); -- StorageLive(_6); + StorageLive(_6); - _6 = _4; - _5 = opaque::<&str>(move _6) -> [return: bb2, unwind continue]; ++ _6 = _1; + _5 = opaque::<&str>(_1) -> [return: bb2, unwind continue]; } bb2: { -- StorageDead(_6); + StorageDead(_6); StorageDead(_5); -- StorageLive(_7); + StorageLive(_7); StorageLive(_8); - StorageLive(_9); +- StorageLive(_9); ++ nop; StorageLive(_10); StorageLive(_11); _11 = &(*_1); @@ -120,28 +123,37 @@ bb3: { StorageDead(_11); _9 = &_10; - StorageLive(_12); +- StorageLive(_12); ++ nop; StorageLive(_13); StorageLive(_14); - _14 = &(*_4); +- _14 = &(*_4); ++ _14 = &(*_1); _13 = core::str::<impl str>::as_ptr(move _14) -> [return: bb4, unwind continue]; } bb4: { StorageDead(_14); _12 = &_13; - _8 = (move _9, move _12); - StorageDead(_12); - StorageDead(_9); +- _8 = (move _9, move _12); +- StorageDead(_12); +- StorageDead(_9); ++ _8 = (_9, _12); ++ nop; ++ nop; StorageLive(_15); - _15 = (_8.0: &*const u8); +- _15 = (_8.0: &*const u8); ++ _15 = _9; StorageLive(_16); - _16 = (_8.1: &*const u8); +- _16 = (_8.1: &*const u8); ++ _16 = _12; StorageLive(_17); StorageLive(_18); - _18 = (*_15); +- _18 = (*_15); ++ _18 = (*_9); StorageLive(_19); - _19 = (*_16); +- _19 = (*_16); ++ _19 = (*_12); _17 = Eq(move _18, move _19); switchInt(move _17) -> [0: bb6, otherwise: bb5]; } @@ -149,22 +161,23 @@ bb5: { StorageDead(_19); StorageDead(_18); -- _7 = const (); + _7 = const (); StorageDead(_17); StorageDead(_16); StorageDead(_15); StorageDead(_13); StorageDead(_10); StorageDead(_8); -- StorageDead(_7); + StorageDead(_7); - StorageLive(_29); ++ nop; StorageLive(_30); _30 = &(*_1); _29 = move _30 as &[u8] (Transmute); StorageDead(_30); StorageLive(_31); -- StorageLive(_32); -- _32 = _29; + StorageLive(_32); + _32 = _29; - _31 = opaque::<&[u8]>(move _32) -> [return: bb7, unwind continue]; + _31 = opaque::<&[u8]>(_29) -> [return: bb7, unwind continue]; } @@ -173,30 +186,38 @@ StorageDead(_19); StorageDead(_18); - StorageLive(_21); - _21 = core::panicking::AssertKind::Eq; +- _21 = core::panicking::AssertKind::Eq; ++ nop; ++ _21 = const core::panicking::AssertKind::Eq; StorageLive(_22); -- StorageLive(_23); + StorageLive(_23); - _23 = move _21; ++ _23 = const core::panicking::AssertKind::Eq; StorageLive(_24); - StorageLive(_25); - _25 = &(*_15); +- StorageLive(_25); +- _25 = &(*_15); ++ nop; ++ _25 = &(*_9); _24 = &(*_25); StorageLive(_26); - StorageLive(_27); - _27 = &(*_16); +- StorageLive(_27); +- _27 = &(*_16); ++ nop; ++ _27 = &(*_12); _26 = &(*_27); StorageLive(_28); _28 = Option::<Arguments<'_>>::None; -- _22 = core::panicking::assert_failed::<*const u8, *const u8>(move _23, move _24, move _26, move _28) -> unwind continue; -+ _22 = core::panicking::assert_failed::<*const u8, *const u8>(_21, move _24, move _26, move _28) -> unwind continue; +- _22 = assert_failed::<*const u8, *const u8>(move _23, move _24, move _26, move _28) -> unwind continue; ++ _22 = assert_failed::<*const u8, *const u8>(const core::panicking::AssertKind::Eq, move _24, move _26, move _28) -> unwind continue; } bb7: { -- StorageDead(_32); + StorageDead(_32); StorageDead(_31); -- StorageLive(_33); + StorageLive(_33); StorageLive(_34); - StorageLive(_35); +- StorageLive(_35); ++ nop; StorageLive(_36); StorageLive(_37); _37 = &(*_1); @@ -206,7 +227,8 @@ bb8: { StorageDead(_37); _35 = &_36; - StorageLive(_38); +- StorageLive(_38); ++ nop; StorageLive(_39); StorageLive(_40); _40 = &(*_29); @@ -216,18 +238,25 @@ bb9: { StorageDead(_40); _38 = &_39; - _34 = (move _35, move _38); - StorageDead(_38); - StorageDead(_35); +- _34 = (move _35, move _38); +- StorageDead(_38); +- StorageDead(_35); ++ _34 = (_35, _38); ++ nop; ++ nop; StorageLive(_41); - _41 = (_34.0: &*const u8); +- _41 = (_34.0: &*const u8); ++ _41 = _35; StorageLive(_42); - _42 = (_34.1: &*const u8); +- _42 = (_34.1: &*const u8); ++ _42 = _38; StorageLive(_43); StorageLive(_44); - _44 = (*_41); +- _44 = (*_41); ++ _44 = (*_35); StorageLive(_45); - _45 = (*_42); +- _45 = (*_42); ++ _45 = (*_38); _43 = Eq(move _44, move _45); switchInt(move _43) -> [0: bb11, otherwise: bb10]; } @@ -235,18 +264,20 @@ bb10: { StorageDead(_45); StorageDead(_44); -- _33 = const (); + _33 = const (); StorageDead(_43); StorageDead(_42); StorageDead(_41); StorageDead(_39); StorageDead(_36); StorageDead(_34); -- StorageDead(_33); + StorageDead(_33); _0 = const (); - StorageDead(_29); ++ nop; StorageDead(_4); - StorageDead(_1); ++ nop; return; } @@ -254,22 +285,29 @@ StorageDead(_45); StorageDead(_44); - StorageLive(_47); - _47 = core::panicking::AssertKind::Eq; +- _47 = core::panicking::AssertKind::Eq; ++ nop; ++ _47 = const core::panicking::AssertKind::Eq; StorageLive(_48); -- StorageLive(_49); + StorageLive(_49); - _49 = move _47; ++ _49 = const core::panicking::AssertKind::Eq; StorageLive(_50); - StorageLive(_51); - _51 = &(*_41); +- StorageLive(_51); +- _51 = &(*_41); ++ nop; ++ _51 = &(*_35); _50 = &(*_51); StorageLive(_52); - StorageLive(_53); - _53 = &(*_42); +- StorageLive(_53); +- _53 = &(*_42); ++ nop; ++ _53 = &(*_38); _52 = &(*_53); StorageLive(_54); _54 = Option::<Arguments<'_>>::None; -- _48 = core::panicking::assert_failed::<*const u8, *const u8>(move _49, move _50, move _52, move _54) -> unwind continue; -+ _48 = core::panicking::assert_failed::<*const u8, *const u8>(_47, move _50, move _52, move _54) -> unwind continue; +- _48 = assert_failed::<*const u8, *const u8>(move _49, move _50, move _52, move _54) -> unwind continue; ++ _48 = assert_failed::<*const u8, *const u8>(const core::panicking::AssertKind::Eq, move _50, move _52, move _54) -> unwind continue; } } diff --git a/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-abort.diff b/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-abort.diff index bf866e2f4d2..0a747d3aef0 100644 --- a/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-abort.diff @@ -65,11 +65,11 @@ let mut _60: u64; let mut _61: u64; let mut _62: u64; - let mut _63: u64; + let _63: (); let mut _64: u64; - let _65: (); + let mut _65: u64; let mut _66: u64; - let mut _67: u64; + let _67: (); let mut _68: u64; let mut _69: u64; let mut _70: u64; @@ -77,25 +77,25 @@ let mut _72: u64; let mut _73: u64; let mut _74: u64; - let mut _75: u64; - let mut _76: u64; - let _77: (); + let mut _75: bool; + let _76: (); + let mut _77: u64; let mut _78: u64; let mut _79: u64; - let mut _80: u64; - let mut _81: u64; - let mut _82: bool; + let mut _80: bool; + let _81: (); + let mut _82: u64; let mut _83: u64; - let _84: (); - let mut _85: u64; + let mut _84: u64; + let _85: (); let mut _86: u64; let mut _87: u64; let mut _88: u64; - let mut _89: bool; + let _89: (); let mut _90: u64; - let _91: (); + let mut _91: u64; let mut _92: u64; - let mut _93: u64; + let _93: (); let mut _94: u64; let mut _95: u64; let mut _96: u64; @@ -103,93 +103,91 @@ let mut _98: u64; let mut _99: u64; let mut _100: u64; - let mut _101: u64; - let mut _102: u64; - let _103: (); - let mut _104: u64; - let mut _105: u64; + let _101: (); + let mut _102: u32; + let mut _103: u64; + let _104: (); + let mut _105: f32; let mut _106: u64; - let mut _107: u64; - let mut _108: u64; - let _109: (); - let mut _110: u64; + let _107: (); + let mut _108: S<u64>; + let mut _109: u64; + let _110: (); let mut _111: u64; - let mut _112: u64; + let mut _112: S<u64>; let mut _113: u64; - let mut _114: u64; - let _115: (); + let _114: (); + let mut _115: u64; let mut _116: u64; let mut _117: u64; let mut _118: u64; let mut _119: u64; - let mut _120: u64; - let _121: (); - let mut _122: S<u64>; + let _120: (); + let mut _121: u64; + let mut _122: u64; let mut _123: u64; - let _124: (); + let mut _124: u64; let mut _125: u64; - let mut _126: S<u64>; - let mut _127: u64; - let _128: &u64; - let _129: (); + let _126: &u64; + let _127: (); + let mut _128: u64; + let mut _129: u64; let mut _130: u64; - let mut _131: u64; + let _131: (); let mut _132: u64; - let _133: (); + let mut _133: u64; let mut _134: u64; - let mut _135: u64; - let mut _136: u64; - let _138: (); + let _136: (); + let mut _137: u64; + let mut _138: u64; let mut _139: u64; - let mut _140: u64; + let _140: (); let mut _141: u64; - let _142: (); + let mut _142: u64; let mut _143: u64; - let mut _144: u64; - let mut _145: u64; + let _144: (); let _146: (); - let _148: (); + let mut _147: u64; + let mut _148: u64; let mut _149: u64; - let mut _150: u64; + let _150: (); let mut _151: u64; - let _152: (); + let mut _152: u64; let mut _153: u64; - let mut _154: u64; - let mut _155: u64; - let _157: (); + let _155: (); + let mut _156: u64; + let mut _157: u64; let mut _158: u64; - let mut _159: u64; + let _159: (); let mut _160: u64; - let _161: (); + let mut _161: u64; let mut _162: u64; - let mut _163: u64; - let mut _164: u64; - let _166: (); + let _164: (); + let mut _165: u64; + let mut _166: u64; let mut _167: u64; - let mut _168: u64; + let _168: (); let mut _169: u64; - let _170: (); + let mut _170: u64; let mut _171: u64; - let mut _172: u64; - let mut _173: u64; scope 1 { - debug a => _128; - let _137: &mut u64; + debug a => _126; + let _135: &mut u64; scope 2 { - debug b => _137; - let _165: &u64; + debug b => _135; + let _163: &u64; scope 3 { - let _147: *const u64; + let _145: *const u64; scope 4 { - debug c => _147; - let _156: *mut u64; + debug c => _145; + let _154: *mut u64; scope 5 { - debug d => _156; + debug d => _154; } } } scope 6 { - debug e => _165; + debug e => _163; } } } @@ -197,61 +195,68 @@ bb0: { StorageLive(_4); - StorageLive(_5); -- StorageLive(_6); -- _6 = _1; -- StorageLive(_7); -- _7 = _2; ++ nop; + StorageLive(_6); + _6 = _1; + StorageLive(_7); + _7 = _2; - _5 = Add(move _6, move _7); -- StorageDead(_7); -- StorageDead(_6); -- _4 = opaque::<u64>(move _5) -> [return: bb1, unwind unreachable]; + _5 = Add(_1, _2); + StorageDead(_7); + StorageDead(_6); +- _4 = opaque::<u64>(move _5) -> [return: bb1, unwind unreachable]; + _4 = opaque::<u64>(_5) -> [return: bb1, unwind unreachable]; } bb1: { - StorageDead(_5); ++ nop; StorageDead(_4); StorageLive(_8); - StorageLive(_9); -- StorageLive(_10); -- _10 = _1; -- StorageLive(_11); -- _11 = _2; ++ nop; + StorageLive(_10); + _10 = _1; + StorageLive(_11); + _11 = _2; - _9 = Mul(move _10, move _11); -- StorageDead(_11); -- StorageDead(_10); -- _8 = opaque::<u64>(move _9) -> [return: bb2, unwind unreachable]; + _9 = Mul(_1, _2); + StorageDead(_11); + StorageDead(_10); +- _8 = opaque::<u64>(move _9) -> [return: bb2, unwind unreachable]; + _8 = opaque::<u64>(_9) -> [return: bb2, unwind unreachable]; } bb2: { - StorageDead(_9); ++ nop; StorageDead(_8); StorageLive(_12); - StorageLive(_13); -- StorageLive(_14); -- _14 = _1; -- StorageLive(_15); -- _15 = _2; ++ nop; + StorageLive(_14); + _14 = _1; + StorageLive(_15); + _15 = _2; - _13 = Sub(move _14, move _15); -- StorageDead(_15); -- StorageDead(_14); -- _12 = opaque::<u64>(move _13) -> [return: bb3, unwind unreachable]; + _13 = Sub(_1, _2); + StorageDead(_15); + StorageDead(_14); +- _12 = opaque::<u64>(move _13) -> [return: bb3, unwind unreachable]; + _12 = opaque::<u64>(_13) -> [return: bb3, unwind unreachable]; } bb3: { - StorageDead(_13); ++ nop; StorageDead(_12); StorageLive(_16); - StorageLive(_17); -- StorageLive(_18); -- _18 = _1; -- StorageLive(_19); -- _19 = _2; ++ nop; + StorageLive(_18); + _18 = _1; + StorageLive(_19); + _19 = _2; - _20 = Eq(_19, const 0_u64); - assert(!move _20, "attempt to divide `{}` by zero", _18) -> [success: bb4, unwind unreachable]; + _20 = Eq(_2, const 0_u64); @@ -260,623 +265,701 @@ bb4: { - _17 = Div(move _18, move _19); -- StorageDead(_19); -- StorageDead(_18); -- _16 = opaque::<u64>(move _17) -> [return: bb5, unwind unreachable]; + _17 = Div(_1, _2); + StorageDead(_19); + StorageDead(_18); +- _16 = opaque::<u64>(move _17) -> [return: bb5, unwind unreachable]; + _16 = opaque::<u64>(_17) -> [return: bb5, unwind unreachable]; } bb5: { - StorageDead(_17); ++ nop; StorageDead(_16); StorageLive(_21); - StorageLive(_22); -- StorageLive(_23); -- _23 = _1; -- StorageLive(_24); -- _24 = _2; ++ nop; + StorageLive(_23); + _23 = _1; + StorageLive(_24); + _24 = _2; - _25 = Eq(_24, const 0_u64); - assert(!move _25, "attempt to calculate the remainder of `{}` with a divisor of zero", _23) -> [success: bb6, unwind unreachable]; ++ _25 = _20; + assert(!_20, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb6, unwind unreachable]; } bb6: { - _22 = Rem(move _23, move _24); -- StorageDead(_24); -- StorageDead(_23); -- _21 = opaque::<u64>(move _22) -> [return: bb7, unwind unreachable]; + _22 = Rem(_1, _2); + StorageDead(_24); + StorageDead(_23); +- _21 = opaque::<u64>(move _22) -> [return: bb7, unwind unreachable]; + _21 = opaque::<u64>(_22) -> [return: bb7, unwind unreachable]; } bb7: { - StorageDead(_22); ++ nop; StorageDead(_21); StorageLive(_26); - StorageLive(_27); -- StorageLive(_28); -- _28 = _1; -- StorageLive(_29); -- _29 = _2; ++ nop; + StorageLive(_28); + _28 = _1; + StorageLive(_29); + _29 = _2; - _27 = BitAnd(move _28, move _29); -- StorageDead(_29); -- StorageDead(_28); -- _26 = opaque::<u64>(move _27) -> [return: bb8, unwind unreachable]; + _27 = BitAnd(_1, _2); + StorageDead(_29); + StorageDead(_28); +- _26 = opaque::<u64>(move _27) -> [return: bb8, unwind unreachable]; + _26 = opaque::<u64>(_27) -> [return: bb8, unwind unreachable]; } bb8: { - StorageDead(_27); ++ nop; StorageDead(_26); StorageLive(_30); - StorageLive(_31); -- StorageLive(_32); -- _32 = _1; -- StorageLive(_33); -- _33 = _2; ++ nop; + StorageLive(_32); + _32 = _1; + StorageLive(_33); + _33 = _2; - _31 = BitOr(move _32, move _33); -- StorageDead(_33); -- StorageDead(_32); -- _30 = opaque::<u64>(move _31) -> [return: bb9, unwind unreachable]; + _31 = BitOr(_1, _2); + StorageDead(_33); + StorageDead(_32); +- _30 = opaque::<u64>(move _31) -> [return: bb9, unwind unreachable]; + _30 = opaque::<u64>(_31) -> [return: bb9, unwind unreachable]; } bb9: { - StorageDead(_31); ++ nop; StorageDead(_30); StorageLive(_34); - StorageLive(_35); -- StorageLive(_36); -- _36 = _1; -- StorageLive(_37); -- _37 = _2; ++ nop; + StorageLive(_36); + _36 = _1; + StorageLive(_37); + _37 = _2; - _35 = BitXor(move _36, move _37); -- StorageDead(_37); -- StorageDead(_36); -- _34 = opaque::<u64>(move _35) -> [return: bb10, unwind unreachable]; + _35 = BitXor(_1, _2); + StorageDead(_37); + StorageDead(_36); +- _34 = opaque::<u64>(move _35) -> [return: bb10, unwind unreachable]; + _34 = opaque::<u64>(_35) -> [return: bb10, unwind unreachable]; } bb10: { - StorageDead(_35); ++ nop; StorageDead(_34); StorageLive(_38); - StorageLive(_39); -- StorageLive(_40); -- _40 = _1; -- StorageLive(_41); -- _41 = _2; ++ nop; + StorageLive(_40); + _40 = _1; + StorageLive(_41); + _41 = _2; - _39 = Shl(move _40, move _41); -- StorageDead(_41); -- StorageDead(_40); -- _38 = opaque::<u64>(move _39) -> [return: bb11, unwind unreachable]; + _39 = Shl(_1, _2); + StorageDead(_41); + StorageDead(_40); +- _38 = opaque::<u64>(move _39) -> [return: bb11, unwind unreachable]; + _38 = opaque::<u64>(_39) -> [return: bb11, unwind unreachable]; } bb11: { - StorageDead(_39); ++ nop; StorageDead(_38); StorageLive(_42); - StorageLive(_43); -- StorageLive(_44); -- _44 = _1; -- StorageLive(_45); -- _45 = _2; ++ nop; + StorageLive(_44); + _44 = _1; + StorageLive(_45); + _45 = _2; - _43 = Shr(move _44, move _45); -- StorageDead(_45); -- StorageDead(_44); -- _42 = opaque::<u64>(move _43) -> [return: bb12, unwind unreachable]; + _43 = Shr(_1, _2); + StorageDead(_45); + StorageDead(_44); +- _42 = opaque::<u64>(move _43) -> [return: bb12, unwind unreachable]; + _42 = opaque::<u64>(_43) -> [return: bb12, unwind unreachable]; } bb12: { - StorageDead(_43); ++ nop; StorageDead(_42); StorageLive(_46); - StorageLive(_47); -- StorageLive(_48); -- _48 = _1; +- StorageLive(_47); ++ nop; + StorageLive(_48); + _48 = _1; - _47 = move _48 as u32 (IntToInt); -- StorageDead(_48); + _47 = _1 as u32 (IntToInt); - _46 = opaque::<u32>(move _47) -> [return: bb13, unwind unreachable]; + StorageDead(_48); +- _46 = opaque::<u32>(move _47) -> [return: bb13, unwind unreachable]; ++ _46 = opaque::<u32>(_47) -> [return: bb13, unwind unreachable]; } bb13: { - StorageDead(_47); +- StorageDead(_47); ++ nop; StorageDead(_46); StorageLive(_49); - StorageLive(_50); -- StorageLive(_51); -- _51 = _1; +- StorageLive(_50); ++ nop; + StorageLive(_51); + _51 = _1; - _50 = move _51 as f32 (IntToFloat); -- StorageDead(_51); + _50 = _1 as f32 (IntToFloat); - _49 = opaque::<f32>(move _50) -> [return: bb14, unwind unreachable]; + StorageDead(_51); +- _49 = opaque::<f32>(move _50) -> [return: bb14, unwind unreachable]; ++ _49 = opaque::<f32>(_50) -> [return: bb14, unwind unreachable]; } bb14: { - StorageDead(_50); +- StorageDead(_50); ++ nop; StorageDead(_49); StorageLive(_52); - StorageLive(_53); -- StorageLive(_54); -- _54 = _1; ++ nop; + StorageLive(_54); + _54 = _1; - _53 = S::<u64>(move _54); -- StorageDead(_54); -- _52 = opaque::<S<u64>>(move _53) -> [return: bb15, unwind unreachable]; + _53 = S::<u64>(_1); + StorageDead(_54); +- _52 = opaque::<S<u64>>(move _53) -> [return: bb15, unwind unreachable]; + _52 = opaque::<S<u64>>(_53) -> [return: bb15, unwind unreachable]; } bb15: { - StorageDead(_53); ++ nop; StorageDead(_52); StorageLive(_55); -- StorageLive(_56); -- StorageLive(_57); -- StorageLive(_58); -- _58 = _1; + StorageLive(_56); + StorageLive(_57); + StorageLive(_58); + _58 = _1; - _57 = S::<u64>(move _58); -- StorageDead(_58); ++ _57 = _53; + StorageDead(_58); - _56 = (_57.0: u64); - _55 = opaque::<u64>(move _56) -> [return: bb16, unwind unreachable]; -+ _56 = (_53.0: u64); -+ _55 = opaque::<u64>(_56) -> [return: bb16, unwind unreachable]; ++ _56 = _1; ++ _55 = opaque::<u64>(_1) -> [return: bb16, unwind unreachable]; } bb16: { -- StorageDead(_56); -- StorageDead(_57); + StorageDead(_56); + StorageDead(_57); StorageDead(_55); StorageLive(_59); StorageLive(_60); -- StorageLive(_61); -- StorageLive(_62); -- _62 = _1; -- StorageLive(_63); -- _63 = _2; -- _61 = Add(move _62, move _63); -- StorageDead(_63); -- StorageDead(_62); - StorageLive(_64); - _64 = _3; -- _60 = Add(move _61, move _64); -+ _60 = Add(_5, move _64); - StorageDead(_64); -- StorageDead(_61); - _59 = opaque::<u64>(move _60) -> [return: bb17, unwind unreachable]; + StorageLive(_61); + _61 = _1; + StorageLive(_62); + _62 = _2; +- _60 = Add(move _61, move _62); ++ _60 = _5; + StorageDead(_62); + StorageDead(_61); +- _59 = opaque::<u64>(move _60) -> [return: bb17, unwind unreachable]; ++ _59 = opaque::<u64>(_5) -> [return: bb17, unwind unreachable]; } bb17: { StorageDead(_60); StorageDead(_59); + StorageLive(_63); + StorageLive(_64); StorageLive(_65); + _65 = _1; StorageLive(_66); -- StorageLive(_67); -- StorageLive(_68); -- _68 = _1; -- StorageLive(_69); -- _69 = _2; -- _67 = Mul(move _68, move _69); -- StorageDead(_69); -- StorageDead(_68); + _66 = _2; +- _64 = Mul(move _65, move _66); ++ _64 = _9; + StorageDead(_66); + StorageDead(_65); +- _63 = opaque::<u64>(move _64) -> [return: bb18, unwind unreachable]; ++ _63 = opaque::<u64>(_9) -> [return: bb18, unwind unreachable]; + } + + bb18: { + StorageDead(_64); + StorageDead(_63); + StorageLive(_67); + StorageLive(_68); + StorageLive(_69); + _69 = _1; StorageLive(_70); - _70 = _3; -- _66 = Add(move _67, move _70); -+ _66 = Add(_9, move _70); + _70 = _2; +- _68 = Sub(move _69, move _70); ++ _68 = _13; StorageDead(_70); -- StorageDead(_67); - _65 = opaque::<u64>(move _66) -> [return: bb18, unwind unreachable]; + StorageDead(_69); +- _67 = opaque::<u64>(move _68) -> [return: bb19, unwind unreachable]; ++ _67 = opaque::<u64>(_13) -> [return: bb19, unwind unreachable]; } - bb18: { - StorageDead(_66); - StorageDead(_65); + bb19: { + StorageDead(_68); + StorageDead(_67); StorageLive(_71); StorageLive(_72); -- StorageLive(_73); -- StorageLive(_74); -- _74 = _1; -- StorageLive(_75); -- _75 = _2; -- _73 = Sub(move _74, move _75); -- StorageDead(_75); -- StorageDead(_74); - StorageLive(_76); - _76 = _3; -- _72 = Add(move _73, move _76); -+ _72 = Add(_13, move _76); - StorageDead(_76); -- StorageDead(_73); - _71 = opaque::<u64>(move _72) -> [return: bb19, unwind unreachable]; + StorageLive(_73); + _73 = _1; + StorageLive(_74); + _74 = _2; +- _75 = Eq(_74, const 0_u64); +- assert(!move _75, "attempt to divide `{}` by zero", _73) -> [success: bb20, unwind unreachable]; ++ _75 = _20; ++ assert(!_20, "attempt to divide `{}` by zero", _1) -> [success: bb20, unwind unreachable]; } - bb19: { + bb20: { +- _72 = Div(move _73, move _74); ++ _72 = _17; + StorageDead(_74); + StorageDead(_73); +- _71 = opaque::<u64>(move _72) -> [return: bb21, unwind unreachable]; ++ _71 = opaque::<u64>(_17) -> [return: bb21, unwind unreachable]; + } + + bb21: { StorageDead(_72); StorageDead(_71); + StorageLive(_76); StorageLive(_77); StorageLive(_78); -- StorageLive(_79); -- StorageLive(_80); -- _80 = _1; -- StorageLive(_81); -- _81 = _2; -- _82 = Eq(_81, const 0_u64); -- assert(!move _82, "attempt to divide `{}` by zero", _80) -> [success: bb20, unwind unreachable]; -+ assert(!_20, "attempt to divide `{}` by zero", _1) -> [success: bb20, unwind unreachable]; + _78 = _1; + StorageLive(_79); + _79 = _2; +- _80 = Eq(_79, const 0_u64); +- assert(!move _80, "attempt to calculate the remainder of `{}` with a divisor of zero", _78) -> [success: bb22, unwind unreachable]; ++ _80 = _20; ++ assert(!_20, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb22, unwind unreachable]; } - bb20: { -- _79 = Div(move _80, move _81); -- StorageDead(_81); -- StorageDead(_80); - StorageLive(_83); - _83 = _3; -- _78 = Add(move _79, move _83); -+ _78 = Add(_17, move _83); - StorageDead(_83); -- StorageDead(_79); - _77 = opaque::<u64>(move _78) -> [return: bb21, unwind unreachable]; + bb22: { +- _77 = Rem(move _78, move _79); ++ _77 = _22; + StorageDead(_79); + StorageDead(_78); +- _76 = opaque::<u64>(move _77) -> [return: bb23, unwind unreachable]; ++ _76 = opaque::<u64>(_22) -> [return: bb23, unwind unreachable]; } - bb21: { - StorageDead(_78); + bb23: { StorageDead(_77); + StorageDead(_76); + StorageLive(_81); + StorageLive(_82); + StorageLive(_83); + _83 = _1; StorageLive(_84); - StorageLive(_85); -- StorageLive(_86); -- StorageLive(_87); -- _87 = _1; -- StorageLive(_88); -- _88 = _2; -- _89 = Eq(_88, const 0_u64); -- assert(!move _89, "attempt to calculate the remainder of `{}` with a divisor of zero", _87) -> [success: bb22, unwind unreachable]; -+ assert(!_20, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb22, unwind unreachable]; + _84 = _2; +- _82 = BitAnd(move _83, move _84); ++ _82 = _27; + StorageDead(_84); + StorageDead(_83); +- _81 = opaque::<u64>(move _82) -> [return: bb24, unwind unreachable]; ++ _81 = opaque::<u64>(_27) -> [return: bb24, unwind unreachable]; } - bb22: { -- _86 = Rem(move _87, move _88); -- StorageDead(_88); -- StorageDead(_87); - StorageLive(_90); - _90 = _3; -- _85 = Add(move _86, move _90); -+ _85 = Add(_22, move _90); - StorageDead(_90); -- StorageDead(_86); - _84 = opaque::<u64>(move _85) -> [return: bb23, unwind unreachable]; + bb24: { + StorageDead(_82); + StorageDead(_81); + StorageLive(_85); + StorageLive(_86); + StorageLive(_87); + _87 = _1; + StorageLive(_88); + _88 = _2; +- _86 = BitOr(move _87, move _88); ++ _86 = _31; + StorageDead(_88); + StorageDead(_87); +- _85 = opaque::<u64>(move _86) -> [return: bb25, unwind unreachable]; ++ _85 = opaque::<u64>(_31) -> [return: bb25, unwind unreachable]; } - bb23: { + bb25: { + StorageDead(_86); StorageDead(_85); - StorageDead(_84); + StorageLive(_89); + StorageLive(_90); StorageLive(_91); + _91 = _1; StorageLive(_92); -- StorageLive(_93); -- StorageLive(_94); -- _94 = _1; -- StorageLive(_95); -- _95 = _2; -- _93 = BitAnd(move _94, move _95); -- StorageDead(_95); -- StorageDead(_94); + _92 = _2; +- _90 = BitXor(move _91, move _92); ++ _90 = _35; + StorageDead(_92); + StorageDead(_91); +- _89 = opaque::<u64>(move _90) -> [return: bb26, unwind unreachable]; ++ _89 = opaque::<u64>(_35) -> [return: bb26, unwind unreachable]; + } + + bb26: { + StorageDead(_90); + StorageDead(_89); + StorageLive(_93); + StorageLive(_94); + StorageLive(_95); + _95 = _1; StorageLive(_96); - _96 = _3; -- _92 = Add(move _93, move _96); -+ _92 = Add(_27, move _96); + _96 = _2; +- _94 = Shl(move _95, move _96); ++ _94 = _39; StorageDead(_96); -- StorageDead(_93); - _91 = opaque::<u64>(move _92) -> [return: bb24, unwind unreachable]; + StorageDead(_95); +- _93 = opaque::<u64>(move _94) -> [return: bb27, unwind unreachable]; ++ _93 = opaque::<u64>(_39) -> [return: bb27, unwind unreachable]; } - bb24: { - StorageDead(_92); - StorageDead(_91); + bb27: { + StorageDead(_94); + StorageDead(_93); StorageLive(_97); StorageLive(_98); -- StorageLive(_99); -- StorageLive(_100); -- _100 = _1; -- StorageLive(_101); -- _101 = _2; -- _99 = BitOr(move _100, move _101); -- StorageDead(_101); -- StorageDead(_100); - StorageLive(_102); - _102 = _3; -- _98 = Add(move _99, move _102); -+ _98 = Add(_31, move _102); - StorageDead(_102); -- StorageDead(_99); - _97 = opaque::<u64>(move _98) -> [return: bb25, unwind unreachable]; + StorageLive(_99); + _99 = _1; + StorageLive(_100); + _100 = _2; +- _98 = Shr(move _99, move _100); ++ _98 = _43; + StorageDead(_100); + StorageDead(_99); +- _97 = opaque::<u64>(move _98) -> [return: bb28, unwind unreachable]; ++ _97 = opaque::<u64>(_43) -> [return: bb28, unwind unreachable]; } - bb25: { + bb28: { StorageDead(_98); StorageDead(_97); + StorageLive(_101); + StorageLive(_102); StorageLive(_103); + _103 = _1; +- _102 = move _103 as u32 (IntToInt); ++ _102 = _47; + StorageDead(_103); +- _101 = opaque::<u32>(move _102) -> [return: bb29, unwind unreachable]; ++ _101 = opaque::<u32>(_47) -> [return: bb29, unwind unreachable]; + } + + bb29: { + StorageDead(_102); + StorageDead(_101); StorageLive(_104); -- StorageLive(_105); -- StorageLive(_106); -- _106 = _1; -- StorageLive(_107); -- _107 = _2; -- _105 = BitXor(move _106, move _107); -- StorageDead(_107); -- StorageDead(_106); - StorageLive(_108); - _108 = _3; -- _104 = Add(move _105, move _108); -+ _104 = Add(_35, move _108); - StorageDead(_108); -- StorageDead(_105); - _103 = opaque::<u64>(move _104) -> [return: bb26, unwind unreachable]; + StorageLive(_105); + StorageLive(_106); + _106 = _1; +- _105 = move _106 as f32 (IntToFloat); ++ _105 = _50; + StorageDead(_106); +- _104 = opaque::<f32>(move _105) -> [return: bb30, unwind unreachable]; ++ _104 = opaque::<f32>(_50) -> [return: bb30, unwind unreachable]; } - bb26: { + bb30: { + StorageDead(_105); StorageDead(_104); - StorageDead(_103); + StorageLive(_107); + StorageLive(_108); StorageLive(_109); + _109 = _1; +- _108 = S::<u64>(move _109); ++ _108 = _53; + StorageDead(_109); +- _107 = opaque::<S<u64>>(move _108) -> [return: bb31, unwind unreachable]; ++ _107 = opaque::<S<u64>>(_53) -> [return: bb31, unwind unreachable]; + } + + bb31: { + StorageDead(_108); + StorageDead(_107); StorageLive(_110); -- StorageLive(_111); -- StorageLive(_112); -- _112 = _1; -- StorageLive(_113); -- _113 = _2; -- _111 = Shl(move _112, move _113); -- StorageDead(_113); -- StorageDead(_112); - StorageLive(_114); - _114 = _3; -- _110 = Add(move _111, move _114); -+ _110 = Add(_39, move _114); - StorageDead(_114); -- StorageDead(_111); - _109 = opaque::<u64>(move _110) -> [return: bb27, unwind unreachable]; + StorageLive(_111); + StorageLive(_112); + StorageLive(_113); + _113 = _1; +- _112 = S::<u64>(move _113); ++ _112 = _53; + StorageDead(_113); +- _111 = (_112.0: u64); +- _110 = opaque::<u64>(move _111) -> [return: bb32, unwind unreachable]; ++ _111 = _1; ++ _110 = opaque::<u64>(_1) -> [return: bb32, unwind unreachable]; } - bb27: { + bb32: { + StorageDead(_111); + StorageDead(_112); StorageDead(_110); - StorageDead(_109); - StorageLive(_115); + StorageLive(_114); +- StorageLive(_115); ++ nop; StorageLive(_116); -- StorageLive(_117); -- StorageLive(_118); -- _118 = _1; -- StorageLive(_119); -- _119 = _2; -- _117 = Shr(move _118, move _119); -- StorageDead(_119); -- StorageDead(_118); - StorageLive(_120); - _120 = _3; -- _116 = Add(move _117, move _120); -+ _116 = Add(_43, move _120); - StorageDead(_120); -- StorageDead(_117); - _115 = opaque::<u64>(move _116) -> [return: bb28, unwind unreachable]; + StorageLive(_117); + _117 = _1; + StorageLive(_118); + _118 = _2; +- _116 = Mul(move _117, move _118); ++ _116 = _9; + StorageDead(_118); + StorageDead(_117); + StorageLive(_119); + _119 = _2; +- _115 = Sub(move _116, move _119); ++ _115 = Sub(_9, _2); + StorageDead(_119); + StorageDead(_116); +- _114 = opaque::<u64>(move _115) -> [return: bb33, unwind unreachable]; ++ _114 = opaque::<u64>(_115) -> [return: bb33, unwind unreachable]; } - bb28: { - StorageDead(_116); - StorageDead(_115); + bb33: { +- StorageDead(_115); ++ nop; + StorageDead(_114); + StorageLive(_120); StorageLive(_121); -- StorageLive(_122); -- StorageLive(_123); -- _123 = _1; -- _122 = S::<u64>(move _123); -- StorageDead(_123); -- _121 = opaque::<S<u64>>(move _122) -> [return: bb29, unwind unreachable]; -+ _121 = opaque::<S<u64>>(_53) -> [return: bb29, unwind unreachable]; + StorageLive(_122); + StorageLive(_123); + _123 = _1; + StorageLive(_124); + _124 = _2; +- _122 = Mul(move _123, move _124); ++ _122 = _9; + StorageDead(_124); + StorageDead(_123); + StorageLive(_125); + _125 = _2; +- _121 = Sub(move _122, move _125); ++ _121 = _115; + StorageDead(_125); + StorageDead(_122); +- _120 = opaque::<u64>(move _121) -> [return: bb34, unwind unreachable]; ++ _120 = opaque::<u64>(_115) -> [return: bb34, unwind unreachable]; } - bb29: { -- StorageDead(_122); + bb34: { StorageDead(_121); - StorageLive(_124); -- StorageLive(_125); + StorageDead(_120); - StorageLive(_126); -- StorageLive(_127); -- _127 = _1; -- _126 = S::<u64>(move _127); -- StorageDead(_127); -- _125 = (_126.0: u64); -- _124 = opaque::<u64>(move _125) -> [return: bb30, unwind unreachable]; -+ _124 = opaque::<u64>(_56) -> [return: bb30, unwind unreachable]; - } - - bb30: { -- StorageDead(_125); -- StorageDead(_126); - StorageDead(_124); - StorageLive(_128); - _128 = &_3; - StorageLive(_129); -- StorageLive(_130); -- StorageLive(_131); - _131 = (*_128); -- StorageLive(_132); -- _132 = _1; -- _130 = Add(move _131, move _132); -- StorageDead(_132); -- StorageDead(_131); -- _129 = opaque::<u64>(move _130) -> [return: bb31, unwind unreachable]; -+ _130 = Add(_131, _1); -+ _129 = opaque::<u64>(_130) -> [return: bb31, unwind unreachable]; ++ nop; + _126 = &_3; + StorageLive(_127); +- StorageLive(_128); +- StorageLive(_129); ++ nop; ++ nop; + _129 = (*_126); + StorageLive(_130); + _130 = _1; +- _128 = Add(move _129, move _130); ++ _128 = Add(_129, _1); + StorageDead(_130); +- StorageDead(_129); +- _127 = opaque::<u64>(move _128) -> [return: bb35, unwind unreachable]; ++ nop; ++ _127 = opaque::<u64>(_128) -> [return: bb35, unwind unreachable]; } - bb31: { -- StorageDead(_130); - StorageDead(_129); + bb35: { +- StorageDead(_128); ++ nop; + StorageDead(_127); + StorageLive(_131); + StorageLive(_132); StorageLive(_133); -- StorageLive(_134); -- StorageLive(_135); -- _135 = (*_128); -- StorageLive(_136); -- _136 = _1; -- _134 = Add(move _135, move _136); -- StorageDead(_136); -- StorageDead(_135); -- _133 = opaque::<u64>(move _134) -> [return: bb32, unwind unreachable]; -+ _133 = opaque::<u64>(_130) -> [return: bb32, unwind unreachable]; +- _133 = (*_126); ++ _133 = _129; + StorageLive(_134); + _134 = _1; +- _132 = Add(move _133, move _134); ++ _132 = _128; + StorageDead(_134); + StorageDead(_133); +- _131 = opaque::<u64>(move _132) -> [return: bb36, unwind unreachable]; ++ _131 = opaque::<u64>(_128) -> [return: bb36, unwind unreachable]; } - bb32: { -- StorageDead(_134); - StorageDead(_133); + bb36: { + StorageDead(_132); + StorageDead(_131); +- StorageLive(_135); ++ nop; + _135 = &mut _3; + StorageLive(_136); StorageLive(_137); - _137 = &mut _3; StorageLive(_138); + _138 = (*_135); StorageLive(_139); - StorageLive(_140); - _140 = (*_137); -- StorageLive(_141); -- _141 = _1; -- _139 = Add(move _140, move _141); -- StorageDead(_141); -+ _139 = Add(move _140, _1); - StorageDead(_140); - _138 = opaque::<u64>(move _139) -> [return: bb33, unwind unreachable]; - } - - bb33: { + _139 = _1; +- _137 = Add(move _138, move _139); ++ _137 = Add(move _138, _1); StorageDead(_139); StorageDead(_138); - StorageLive(_142); - StorageLive(_143); - StorageLive(_144); - _144 = (*_137); -- StorageLive(_145); -- _145 = _1; -- _143 = Add(move _144, move _145); -- StorageDead(_145); -+ _143 = Add(move _144, _1); - StorageDead(_144); - _142 = opaque::<u64>(move _143) -> [return: bb34, unwind unreachable]; + _136 = opaque::<u64>(move _137) -> [return: bb37, unwind unreachable]; } - bb34: { + bb37: { + StorageDead(_137); + StorageDead(_136); + StorageLive(_140); + StorageLive(_141); + StorageLive(_142); + _142 = (*_135); + StorageLive(_143); + _143 = _1; +- _141 = Add(move _142, move _143); ++ _141 = Add(move _142, _1); StorageDead(_143); StorageDead(_142); -- StorageLive(_146); + _140 = opaque::<u64>(move _141) -> [return: bb38, unwind unreachable]; + } + + bb38: { + StorageDead(_141); + StorageDead(_140); + StorageLive(_144); +- StorageLive(_145); ++ nop; + _145 = &raw const _3; + StorageLive(_146); StorageLive(_147); - _147 = &raw const _3; StorageLive(_148); + _148 = (*_145); StorageLive(_149); - StorageLive(_150); - _150 = (*_147); -- StorageLive(_151); -- _151 = _1; -- _149 = Add(move _150, move _151); -- StorageDead(_151); -+ _149 = Add(move _150, _1); - StorageDead(_150); - _148 = opaque::<u64>(move _149) -> [return: bb35, unwind unreachable]; - } - - bb35: { + _149 = _1; +- _147 = Add(move _148, move _149); ++ _147 = Add(move _148, _1); StorageDead(_149); StorageDead(_148); - StorageLive(_152); - StorageLive(_153); - StorageLive(_154); - _154 = (*_147); -- StorageLive(_155); -- _155 = _1; -- _153 = Add(move _154, move _155); -- StorageDead(_155); -+ _153 = Add(move _154, _1); - StorageDead(_154); - _152 = opaque::<u64>(move _153) -> [return: bb36, unwind unreachable]; + _146 = opaque::<u64>(move _147) -> [return: bb39, unwind unreachable]; } - bb36: { + bb39: { + StorageDead(_147); + StorageDead(_146); + StorageLive(_150); + StorageLive(_151); + StorageLive(_152); + _152 = (*_145); + StorageLive(_153); + _153 = _1; +- _151 = Add(move _152, move _153); ++ _151 = Add(move _152, _1); StorageDead(_153); StorageDead(_152); + _150 = opaque::<u64>(move _151) -> [return: bb40, unwind unreachable]; + } + + bb40: { + StorageDead(_151); + StorageDead(_150); +- StorageLive(_154); ++ nop; + _154 = &raw mut _3; + StorageLive(_155); StorageLive(_156); - _156 = &raw mut _3; StorageLive(_157); + _157 = (*_154); StorageLive(_158); - StorageLive(_159); - _159 = (*_156); -- StorageLive(_160); -- _160 = _1; -- _158 = Add(move _159, move _160); -- StorageDead(_160); -+ _158 = Add(move _159, _1); - StorageDead(_159); - _157 = opaque::<u64>(move _158) -> [return: bb37, unwind unreachable]; - } - - bb37: { + _158 = _1; +- _156 = Add(move _157, move _158); ++ _156 = Add(move _157, _1); StorageDead(_158); StorageDead(_157); - StorageLive(_161); - StorageLive(_162); - StorageLive(_163); - _163 = (*_156); -- StorageLive(_164); -- _164 = _1; -- _162 = Add(move _163, move _164); -- StorageDead(_164); -+ _162 = Add(move _163, _1); - StorageDead(_163); - _161 = opaque::<u64>(move _162) -> [return: bb38, unwind unreachable]; + _155 = opaque::<u64>(move _156) -> [return: bb41, unwind unreachable]; } - bb38: { + bb41: { + StorageDead(_156); + StorageDead(_155); + StorageLive(_159); + StorageLive(_160); + StorageLive(_161); + _161 = (*_154); + StorageLive(_162); + _162 = _1; +- _160 = Add(move _161, move _162); ++ _160 = Add(move _161, _1); StorageDead(_162); StorageDead(_161); -- _146 = const (); - StorageDead(_156); - StorageDead(_147); -- StorageDead(_146); - StorageLive(_165); - _165 = &_3; - StorageLive(_166); -- StorageLive(_167); -- StorageLive(_168); - _168 = (*_165); -- StorageLive(_169); -- _169 = _1; -- _167 = Add(move _168, move _169); -- StorageDead(_169); -- StorageDead(_168); -- _166 = opaque::<u64>(move _167) -> [return: bb39, unwind unreachable]; -+ _167 = Add(_168, _1); -+ _166 = opaque::<u64>(_167) -> [return: bb39, unwind unreachable]; + _159 = opaque::<u64>(move _160) -> [return: bb42, unwind unreachable]; } - bb39: { -- StorageDead(_167); - StorageDead(_166); + bb42: { + StorageDead(_160); + StorageDead(_159); + _144 = const (); +- StorageDead(_154); +- StorageDead(_145); ++ nop; ++ nop; + StorageDead(_144); +- StorageLive(_163); ++ nop; + _163 = &_3; + StorageLive(_164); +- StorageLive(_165); +- StorageLive(_166); ++ nop; ++ nop; + _166 = (*_163); + StorageLive(_167); + _167 = _1; +- _165 = Add(move _166, move _167); ++ _165 = Add(_166, _1); + StorageDead(_167); +- StorageDead(_166); +- _164 = opaque::<u64>(move _165) -> [return: bb43, unwind unreachable]; ++ nop; ++ _164 = opaque::<u64>(_165) -> [return: bb43, unwind unreachable]; + } + + bb43: { +- StorageDead(_165); ++ nop; + StorageDead(_164); + StorageLive(_168); + StorageLive(_169); StorageLive(_170); -- StorageLive(_171); -- StorageLive(_172); -- _172 = (*_165); -- StorageLive(_173); -- _173 = _1; -- _171 = Add(move _172, move _173); -- StorageDead(_173); -- StorageDead(_172); -- _170 = opaque::<u64>(move _171) -> [return: bb40, unwind unreachable]; -+ _170 = opaque::<u64>(_167) -> [return: bb40, unwind unreachable]; +- _170 = (*_163); ++ _170 = _166; + StorageLive(_171); + _171 = _1; +- _169 = Add(move _170, move _171); ++ _169 = _165; + StorageDead(_171); + StorageDead(_170); +- _168 = opaque::<u64>(move _169) -> [return: bb44, unwind unreachable]; ++ _168 = opaque::<u64>(_165) -> [return: bb44, unwind unreachable]; } - bb40: { -- StorageDead(_171); - StorageDead(_170); + bb44: { + StorageDead(_169); + StorageDead(_168); _0 = const (); - StorageDead(_165); - StorageDead(_137); - StorageDead(_128); +- StorageDead(_163); +- StorageDead(_135); +- StorageDead(_126); ++ nop; ++ nop; ++ nop; return; } } diff --git a/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-unwind.diff b/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-unwind.diff index 68b05290719..119a4d9bbe9 100644 --- a/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-unwind.diff @@ -65,11 +65,11 @@ let mut _60: u64; let mut _61: u64; let mut _62: u64; - let mut _63: u64; + let _63: (); let mut _64: u64; - let _65: (); + let mut _65: u64; let mut _66: u64; - let mut _67: u64; + let _67: (); let mut _68: u64; let mut _69: u64; let mut _70: u64; @@ -77,25 +77,25 @@ let mut _72: u64; let mut _73: u64; let mut _74: u64; - let mut _75: u64; - let mut _76: u64; - let _77: (); + let mut _75: bool; + let _76: (); + let mut _77: u64; let mut _78: u64; let mut _79: u64; - let mut _80: u64; - let mut _81: u64; - let mut _82: bool; + let mut _80: bool; + let _81: (); + let mut _82: u64; let mut _83: u64; - let _84: (); - let mut _85: u64; + let mut _84: u64; + let _85: (); let mut _86: u64; let mut _87: u64; let mut _88: u64; - let mut _89: bool; + let _89: (); let mut _90: u64; - let _91: (); + let mut _91: u64; let mut _92: u64; - let mut _93: u64; + let _93: (); let mut _94: u64; let mut _95: u64; let mut _96: u64; @@ -103,93 +103,91 @@ let mut _98: u64; let mut _99: u64; let mut _100: u64; - let mut _101: u64; - let mut _102: u64; - let _103: (); - let mut _104: u64; - let mut _105: u64; + let _101: (); + let mut _102: u32; + let mut _103: u64; + let _104: (); + let mut _105: f32; let mut _106: u64; - let mut _107: u64; - let mut _108: u64; - let _109: (); - let mut _110: u64; + let _107: (); + let mut _108: S<u64>; + let mut _109: u64; + let _110: (); let mut _111: u64; - let mut _112: u64; + let mut _112: S<u64>; let mut _113: u64; - let mut _114: u64; - let _115: (); + let _114: (); + let mut _115: u64; let mut _116: u64; let mut _117: u64; let mut _118: u64; let mut _119: u64; - let mut _120: u64; - let _121: (); - let mut _122: S<u64>; + let _120: (); + let mut _121: u64; + let mut _122: u64; let mut _123: u64; - let _124: (); + let mut _124: u64; let mut _125: u64; - let mut _126: S<u64>; - let mut _127: u64; - let _128: &u64; - let _129: (); + let _126: &u64; + let _127: (); + let mut _128: u64; + let mut _129: u64; let mut _130: u64; - let mut _131: u64; + let _131: (); let mut _132: u64; - let _133: (); + let mut _133: u64; let mut _134: u64; - let mut _135: u64; - let mut _136: u64; - let _138: (); + let _136: (); + let mut _137: u64; + let mut _138: u64; let mut _139: u64; - let mut _140: u64; + let _140: (); let mut _141: u64; - let _142: (); + let mut _142: u64; let mut _143: u64; - let mut _144: u64; - let mut _145: u64; + let _144: (); let _146: (); - let _148: (); + let mut _147: u64; + let mut _148: u64; let mut _149: u64; - let mut _150: u64; + let _150: (); let mut _151: u64; - let _152: (); + let mut _152: u64; let mut _153: u64; - let mut _154: u64; - let mut _155: u64; - let _157: (); + let _155: (); + let mut _156: u64; + let mut _157: u64; let mut _158: u64; - let mut _159: u64; + let _159: (); let mut _160: u64; - let _161: (); + let mut _161: u64; let mut _162: u64; - let mut _163: u64; - let mut _164: u64; - let _166: (); + let _164: (); + let mut _165: u64; + let mut _166: u64; let mut _167: u64; - let mut _168: u64; + let _168: (); let mut _169: u64; - let _170: (); + let mut _170: u64; let mut _171: u64; - let mut _172: u64; - let mut _173: u64; scope 1 { - debug a => _128; - let _137: &mut u64; + debug a => _126; + let _135: &mut u64; scope 2 { - debug b => _137; - let _165: &u64; + debug b => _135; + let _163: &u64; scope 3 { - let _147: *const u64; + let _145: *const u64; scope 4 { - debug c => _147; - let _156: *mut u64; + debug c => _145; + let _154: *mut u64; scope 5 { - debug d => _156; + debug d => _154; } } } scope 6 { - debug e => _165; + debug e => _163; } } } @@ -197,61 +195,68 @@ bb0: { StorageLive(_4); - StorageLive(_5); -- StorageLive(_6); -- _6 = _1; -- StorageLive(_7); -- _7 = _2; ++ nop; + StorageLive(_6); + _6 = _1; + StorageLive(_7); + _7 = _2; - _5 = Add(move _6, move _7); -- StorageDead(_7); -- StorageDead(_6); -- _4 = opaque::<u64>(move _5) -> [return: bb1, unwind continue]; + _5 = Add(_1, _2); + StorageDead(_7); + StorageDead(_6); +- _4 = opaque::<u64>(move _5) -> [return: bb1, unwind continue]; + _4 = opaque::<u64>(_5) -> [return: bb1, unwind continue]; } bb1: { - StorageDead(_5); ++ nop; StorageDead(_4); StorageLive(_8); - StorageLive(_9); -- StorageLive(_10); -- _10 = _1; -- StorageLive(_11); -- _11 = _2; ++ nop; + StorageLive(_10); + _10 = _1; + StorageLive(_11); + _11 = _2; - _9 = Mul(move _10, move _11); -- StorageDead(_11); -- StorageDead(_10); -- _8 = opaque::<u64>(move _9) -> [return: bb2, unwind continue]; + _9 = Mul(_1, _2); + StorageDead(_11); + StorageDead(_10); +- _8 = opaque::<u64>(move _9) -> [return: bb2, unwind continue]; + _8 = opaque::<u64>(_9) -> [return: bb2, unwind continue]; } bb2: { - StorageDead(_9); ++ nop; StorageDead(_8); StorageLive(_12); - StorageLive(_13); -- StorageLive(_14); -- _14 = _1; -- StorageLive(_15); -- _15 = _2; ++ nop; + StorageLive(_14); + _14 = _1; + StorageLive(_15); + _15 = _2; - _13 = Sub(move _14, move _15); -- StorageDead(_15); -- StorageDead(_14); -- _12 = opaque::<u64>(move _13) -> [return: bb3, unwind continue]; + _13 = Sub(_1, _2); + StorageDead(_15); + StorageDead(_14); +- _12 = opaque::<u64>(move _13) -> [return: bb3, unwind continue]; + _12 = opaque::<u64>(_13) -> [return: bb3, unwind continue]; } bb3: { - StorageDead(_13); ++ nop; StorageDead(_12); StorageLive(_16); - StorageLive(_17); -- StorageLive(_18); -- _18 = _1; -- StorageLive(_19); -- _19 = _2; ++ nop; + StorageLive(_18); + _18 = _1; + StorageLive(_19); + _19 = _2; - _20 = Eq(_19, const 0_u64); - assert(!move _20, "attempt to divide `{}` by zero", _18) -> [success: bb4, unwind continue]; + _20 = Eq(_2, const 0_u64); @@ -260,623 +265,701 @@ bb4: { - _17 = Div(move _18, move _19); -- StorageDead(_19); -- StorageDead(_18); -- _16 = opaque::<u64>(move _17) -> [return: bb5, unwind continue]; + _17 = Div(_1, _2); + StorageDead(_19); + StorageDead(_18); +- _16 = opaque::<u64>(move _17) -> [return: bb5, unwind continue]; + _16 = opaque::<u64>(_17) -> [return: bb5, unwind continue]; } bb5: { - StorageDead(_17); ++ nop; StorageDead(_16); StorageLive(_21); - StorageLive(_22); -- StorageLive(_23); -- _23 = _1; -- StorageLive(_24); -- _24 = _2; ++ nop; + StorageLive(_23); + _23 = _1; + StorageLive(_24); + _24 = _2; - _25 = Eq(_24, const 0_u64); - assert(!move _25, "attempt to calculate the remainder of `{}` with a divisor of zero", _23) -> [success: bb6, unwind continue]; ++ _25 = _20; + assert(!_20, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb6, unwind continue]; } bb6: { - _22 = Rem(move _23, move _24); -- StorageDead(_24); -- StorageDead(_23); -- _21 = opaque::<u64>(move _22) -> [return: bb7, unwind continue]; + _22 = Rem(_1, _2); + StorageDead(_24); + StorageDead(_23); +- _21 = opaque::<u64>(move _22) -> [return: bb7, unwind continue]; + _21 = opaque::<u64>(_22) -> [return: bb7, unwind continue]; } bb7: { - StorageDead(_22); ++ nop; StorageDead(_21); StorageLive(_26); - StorageLive(_27); -- StorageLive(_28); -- _28 = _1; -- StorageLive(_29); -- _29 = _2; ++ nop; + StorageLive(_28); + _28 = _1; + StorageLive(_29); + _29 = _2; - _27 = BitAnd(move _28, move _29); -- StorageDead(_29); -- StorageDead(_28); -- _26 = opaque::<u64>(move _27) -> [return: bb8, unwind continue]; + _27 = BitAnd(_1, _2); + StorageDead(_29); + StorageDead(_28); +- _26 = opaque::<u64>(move _27) -> [return: bb8, unwind continue]; + _26 = opaque::<u64>(_27) -> [return: bb8, unwind continue]; } bb8: { - StorageDead(_27); ++ nop; StorageDead(_26); StorageLive(_30); - StorageLive(_31); -- StorageLive(_32); -- _32 = _1; -- StorageLive(_33); -- _33 = _2; ++ nop; + StorageLive(_32); + _32 = _1; + StorageLive(_33); + _33 = _2; - _31 = BitOr(move _32, move _33); -- StorageDead(_33); -- StorageDead(_32); -- _30 = opaque::<u64>(move _31) -> [return: bb9, unwind continue]; + _31 = BitOr(_1, _2); + StorageDead(_33); + StorageDead(_32); +- _30 = opaque::<u64>(move _31) -> [return: bb9, unwind continue]; + _30 = opaque::<u64>(_31) -> [return: bb9, unwind continue]; } bb9: { - StorageDead(_31); ++ nop; StorageDead(_30); StorageLive(_34); - StorageLive(_35); -- StorageLive(_36); -- _36 = _1; -- StorageLive(_37); -- _37 = _2; ++ nop; + StorageLive(_36); + _36 = _1; + StorageLive(_37); + _37 = _2; - _35 = BitXor(move _36, move _37); -- StorageDead(_37); -- StorageDead(_36); -- _34 = opaque::<u64>(move _35) -> [return: bb10, unwind continue]; + _35 = BitXor(_1, _2); + StorageDead(_37); + StorageDead(_36); +- _34 = opaque::<u64>(move _35) -> [return: bb10, unwind continue]; + _34 = opaque::<u64>(_35) -> [return: bb10, unwind continue]; } bb10: { - StorageDead(_35); ++ nop; StorageDead(_34); StorageLive(_38); - StorageLive(_39); -- StorageLive(_40); -- _40 = _1; -- StorageLive(_41); -- _41 = _2; ++ nop; + StorageLive(_40); + _40 = _1; + StorageLive(_41); + _41 = _2; - _39 = Shl(move _40, move _41); -- StorageDead(_41); -- StorageDead(_40); -- _38 = opaque::<u64>(move _39) -> [return: bb11, unwind continue]; + _39 = Shl(_1, _2); + StorageDead(_41); + StorageDead(_40); +- _38 = opaque::<u64>(move _39) -> [return: bb11, unwind continue]; + _38 = opaque::<u64>(_39) -> [return: bb11, unwind continue]; } bb11: { - StorageDead(_39); ++ nop; StorageDead(_38); StorageLive(_42); - StorageLive(_43); -- StorageLive(_44); -- _44 = _1; -- StorageLive(_45); -- _45 = _2; ++ nop; + StorageLive(_44); + _44 = _1; + StorageLive(_45); + _45 = _2; - _43 = Shr(move _44, move _45); -- StorageDead(_45); -- StorageDead(_44); -- _42 = opaque::<u64>(move _43) -> [return: bb12, unwind continue]; + _43 = Shr(_1, _2); + StorageDead(_45); + StorageDead(_44); +- _42 = opaque::<u64>(move _43) -> [return: bb12, unwind continue]; + _42 = opaque::<u64>(_43) -> [return: bb12, unwind continue]; } bb12: { - StorageDead(_43); ++ nop; StorageDead(_42); StorageLive(_46); - StorageLive(_47); -- StorageLive(_48); -- _48 = _1; +- StorageLive(_47); ++ nop; + StorageLive(_48); + _48 = _1; - _47 = move _48 as u32 (IntToInt); -- StorageDead(_48); + _47 = _1 as u32 (IntToInt); - _46 = opaque::<u32>(move _47) -> [return: bb13, unwind continue]; + StorageDead(_48); +- _46 = opaque::<u32>(move _47) -> [return: bb13, unwind continue]; ++ _46 = opaque::<u32>(_47) -> [return: bb13, unwind continue]; } bb13: { - StorageDead(_47); +- StorageDead(_47); ++ nop; StorageDead(_46); StorageLive(_49); - StorageLive(_50); -- StorageLive(_51); -- _51 = _1; +- StorageLive(_50); ++ nop; + StorageLive(_51); + _51 = _1; - _50 = move _51 as f32 (IntToFloat); -- StorageDead(_51); + _50 = _1 as f32 (IntToFloat); - _49 = opaque::<f32>(move _50) -> [return: bb14, unwind continue]; + StorageDead(_51); +- _49 = opaque::<f32>(move _50) -> [return: bb14, unwind continue]; ++ _49 = opaque::<f32>(_50) -> [return: bb14, unwind continue]; } bb14: { - StorageDead(_50); +- StorageDead(_50); ++ nop; StorageDead(_49); StorageLive(_52); - StorageLive(_53); -- StorageLive(_54); -- _54 = _1; ++ nop; + StorageLive(_54); + _54 = _1; - _53 = S::<u64>(move _54); -- StorageDead(_54); -- _52 = opaque::<S<u64>>(move _53) -> [return: bb15, unwind continue]; + _53 = S::<u64>(_1); + StorageDead(_54); +- _52 = opaque::<S<u64>>(move _53) -> [return: bb15, unwind continue]; + _52 = opaque::<S<u64>>(_53) -> [return: bb15, unwind continue]; } bb15: { - StorageDead(_53); ++ nop; StorageDead(_52); StorageLive(_55); -- StorageLive(_56); -- StorageLive(_57); -- StorageLive(_58); -- _58 = _1; + StorageLive(_56); + StorageLive(_57); + StorageLive(_58); + _58 = _1; - _57 = S::<u64>(move _58); -- StorageDead(_58); ++ _57 = _53; + StorageDead(_58); - _56 = (_57.0: u64); - _55 = opaque::<u64>(move _56) -> [return: bb16, unwind continue]; -+ _56 = (_53.0: u64); -+ _55 = opaque::<u64>(_56) -> [return: bb16, unwind continue]; ++ _56 = _1; ++ _55 = opaque::<u64>(_1) -> [return: bb16, unwind continue]; } bb16: { -- StorageDead(_56); -- StorageDead(_57); + StorageDead(_56); + StorageDead(_57); StorageDead(_55); StorageLive(_59); StorageLive(_60); -- StorageLive(_61); -- StorageLive(_62); -- _62 = _1; -- StorageLive(_63); -- _63 = _2; -- _61 = Add(move _62, move _63); -- StorageDead(_63); -- StorageDead(_62); - StorageLive(_64); - _64 = _3; -- _60 = Add(move _61, move _64); -+ _60 = Add(_5, move _64); - StorageDead(_64); -- StorageDead(_61); - _59 = opaque::<u64>(move _60) -> [return: bb17, unwind continue]; + StorageLive(_61); + _61 = _1; + StorageLive(_62); + _62 = _2; +- _60 = Add(move _61, move _62); ++ _60 = _5; + StorageDead(_62); + StorageDead(_61); +- _59 = opaque::<u64>(move _60) -> [return: bb17, unwind continue]; ++ _59 = opaque::<u64>(_5) -> [return: bb17, unwind continue]; } bb17: { StorageDead(_60); StorageDead(_59); + StorageLive(_63); + StorageLive(_64); StorageLive(_65); + _65 = _1; StorageLive(_66); -- StorageLive(_67); -- StorageLive(_68); -- _68 = _1; -- StorageLive(_69); -- _69 = _2; -- _67 = Mul(move _68, move _69); -- StorageDead(_69); -- StorageDead(_68); + _66 = _2; +- _64 = Mul(move _65, move _66); ++ _64 = _9; + StorageDead(_66); + StorageDead(_65); +- _63 = opaque::<u64>(move _64) -> [return: bb18, unwind continue]; ++ _63 = opaque::<u64>(_9) -> [return: bb18, unwind continue]; + } + + bb18: { + StorageDead(_64); + StorageDead(_63); + StorageLive(_67); + StorageLive(_68); + StorageLive(_69); + _69 = _1; StorageLive(_70); - _70 = _3; -- _66 = Add(move _67, move _70); -+ _66 = Add(_9, move _70); + _70 = _2; +- _68 = Sub(move _69, move _70); ++ _68 = _13; StorageDead(_70); -- StorageDead(_67); - _65 = opaque::<u64>(move _66) -> [return: bb18, unwind continue]; + StorageDead(_69); +- _67 = opaque::<u64>(move _68) -> [return: bb19, unwind continue]; ++ _67 = opaque::<u64>(_13) -> [return: bb19, unwind continue]; } - bb18: { - StorageDead(_66); - StorageDead(_65); + bb19: { + StorageDead(_68); + StorageDead(_67); StorageLive(_71); StorageLive(_72); -- StorageLive(_73); -- StorageLive(_74); -- _74 = _1; -- StorageLive(_75); -- _75 = _2; -- _73 = Sub(move _74, move _75); -- StorageDead(_75); -- StorageDead(_74); - StorageLive(_76); - _76 = _3; -- _72 = Add(move _73, move _76); -+ _72 = Add(_13, move _76); - StorageDead(_76); -- StorageDead(_73); - _71 = opaque::<u64>(move _72) -> [return: bb19, unwind continue]; + StorageLive(_73); + _73 = _1; + StorageLive(_74); + _74 = _2; +- _75 = Eq(_74, const 0_u64); +- assert(!move _75, "attempt to divide `{}` by zero", _73) -> [success: bb20, unwind continue]; ++ _75 = _20; ++ assert(!_20, "attempt to divide `{}` by zero", _1) -> [success: bb20, unwind continue]; } - bb19: { + bb20: { +- _72 = Div(move _73, move _74); ++ _72 = _17; + StorageDead(_74); + StorageDead(_73); +- _71 = opaque::<u64>(move _72) -> [return: bb21, unwind continue]; ++ _71 = opaque::<u64>(_17) -> [return: bb21, unwind continue]; + } + + bb21: { StorageDead(_72); StorageDead(_71); + StorageLive(_76); StorageLive(_77); StorageLive(_78); -- StorageLive(_79); -- StorageLive(_80); -- _80 = _1; -- StorageLive(_81); -- _81 = _2; -- _82 = Eq(_81, const 0_u64); -- assert(!move _82, "attempt to divide `{}` by zero", _80) -> [success: bb20, unwind continue]; -+ assert(!_20, "attempt to divide `{}` by zero", _1) -> [success: bb20, unwind continue]; + _78 = _1; + StorageLive(_79); + _79 = _2; +- _80 = Eq(_79, const 0_u64); +- assert(!move _80, "attempt to calculate the remainder of `{}` with a divisor of zero", _78) -> [success: bb22, unwind continue]; ++ _80 = _20; ++ assert(!_20, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb22, unwind continue]; } - bb20: { -- _79 = Div(move _80, move _81); -- StorageDead(_81); -- StorageDead(_80); - StorageLive(_83); - _83 = _3; -- _78 = Add(move _79, move _83); -+ _78 = Add(_17, move _83); - StorageDead(_83); -- StorageDead(_79); - _77 = opaque::<u64>(move _78) -> [return: bb21, unwind continue]; + bb22: { +- _77 = Rem(move _78, move _79); ++ _77 = _22; + StorageDead(_79); + StorageDead(_78); +- _76 = opaque::<u64>(move _77) -> [return: bb23, unwind continue]; ++ _76 = opaque::<u64>(_22) -> [return: bb23, unwind continue]; } - bb21: { - StorageDead(_78); + bb23: { StorageDead(_77); + StorageDead(_76); + StorageLive(_81); + StorageLive(_82); + StorageLive(_83); + _83 = _1; StorageLive(_84); - StorageLive(_85); -- StorageLive(_86); -- StorageLive(_87); -- _87 = _1; -- StorageLive(_88); -- _88 = _2; -- _89 = Eq(_88, const 0_u64); -- assert(!move _89, "attempt to calculate the remainder of `{}` with a divisor of zero", _87) -> [success: bb22, unwind continue]; -+ assert(!_20, "attempt to calculate the remainder of `{}` with a divisor of zero", _1) -> [success: bb22, unwind continue]; + _84 = _2; +- _82 = BitAnd(move _83, move _84); ++ _82 = _27; + StorageDead(_84); + StorageDead(_83); +- _81 = opaque::<u64>(move _82) -> [return: bb24, unwind continue]; ++ _81 = opaque::<u64>(_27) -> [return: bb24, unwind continue]; } - bb22: { -- _86 = Rem(move _87, move _88); -- StorageDead(_88); -- StorageDead(_87); - StorageLive(_90); - _90 = _3; -- _85 = Add(move _86, move _90); -+ _85 = Add(_22, move _90); - StorageDead(_90); -- StorageDead(_86); - _84 = opaque::<u64>(move _85) -> [return: bb23, unwind continue]; + bb24: { + StorageDead(_82); + StorageDead(_81); + StorageLive(_85); + StorageLive(_86); + StorageLive(_87); + _87 = _1; + StorageLive(_88); + _88 = _2; +- _86 = BitOr(move _87, move _88); ++ _86 = _31; + StorageDead(_88); + StorageDead(_87); +- _85 = opaque::<u64>(move _86) -> [return: bb25, unwind continue]; ++ _85 = opaque::<u64>(_31) -> [return: bb25, unwind continue]; } - bb23: { + bb25: { + StorageDead(_86); StorageDead(_85); - StorageDead(_84); + StorageLive(_89); + StorageLive(_90); StorageLive(_91); + _91 = _1; StorageLive(_92); -- StorageLive(_93); -- StorageLive(_94); -- _94 = _1; -- StorageLive(_95); -- _95 = _2; -- _93 = BitAnd(move _94, move _95); -- StorageDead(_95); -- StorageDead(_94); + _92 = _2; +- _90 = BitXor(move _91, move _92); ++ _90 = _35; + StorageDead(_92); + StorageDead(_91); +- _89 = opaque::<u64>(move _90) -> [return: bb26, unwind continue]; ++ _89 = opaque::<u64>(_35) -> [return: bb26, unwind continue]; + } + + bb26: { + StorageDead(_90); + StorageDead(_89); + StorageLive(_93); + StorageLive(_94); + StorageLive(_95); + _95 = _1; StorageLive(_96); - _96 = _3; -- _92 = Add(move _93, move _96); -+ _92 = Add(_27, move _96); + _96 = _2; +- _94 = Shl(move _95, move _96); ++ _94 = _39; StorageDead(_96); -- StorageDead(_93); - _91 = opaque::<u64>(move _92) -> [return: bb24, unwind continue]; + StorageDead(_95); +- _93 = opaque::<u64>(move _94) -> [return: bb27, unwind continue]; ++ _93 = opaque::<u64>(_39) -> [return: bb27, unwind continue]; } - bb24: { - StorageDead(_92); - StorageDead(_91); + bb27: { + StorageDead(_94); + StorageDead(_93); StorageLive(_97); StorageLive(_98); -- StorageLive(_99); -- StorageLive(_100); -- _100 = _1; -- StorageLive(_101); -- _101 = _2; -- _99 = BitOr(move _100, move _101); -- StorageDead(_101); -- StorageDead(_100); - StorageLive(_102); - _102 = _3; -- _98 = Add(move _99, move _102); -+ _98 = Add(_31, move _102); - StorageDead(_102); -- StorageDead(_99); - _97 = opaque::<u64>(move _98) -> [return: bb25, unwind continue]; + StorageLive(_99); + _99 = _1; + StorageLive(_100); + _100 = _2; +- _98 = Shr(move _99, move _100); ++ _98 = _43; + StorageDead(_100); + StorageDead(_99); +- _97 = opaque::<u64>(move _98) -> [return: bb28, unwind continue]; ++ _97 = opaque::<u64>(_43) -> [return: bb28, unwind continue]; } - bb25: { + bb28: { StorageDead(_98); StorageDead(_97); + StorageLive(_101); + StorageLive(_102); StorageLive(_103); + _103 = _1; +- _102 = move _103 as u32 (IntToInt); ++ _102 = _47; + StorageDead(_103); +- _101 = opaque::<u32>(move _102) -> [return: bb29, unwind continue]; ++ _101 = opaque::<u32>(_47) -> [return: bb29, unwind continue]; + } + + bb29: { + StorageDead(_102); + StorageDead(_101); StorageLive(_104); -- StorageLive(_105); -- StorageLive(_106); -- _106 = _1; -- StorageLive(_107); -- _107 = _2; -- _105 = BitXor(move _106, move _107); -- StorageDead(_107); -- StorageDead(_106); - StorageLive(_108); - _108 = _3; -- _104 = Add(move _105, move _108); -+ _104 = Add(_35, move _108); - StorageDead(_108); -- StorageDead(_105); - _103 = opaque::<u64>(move _104) -> [return: bb26, unwind continue]; + StorageLive(_105); + StorageLive(_106); + _106 = _1; +- _105 = move _106 as f32 (IntToFloat); ++ _105 = _50; + StorageDead(_106); +- _104 = opaque::<f32>(move _105) -> [return: bb30, unwind continue]; ++ _104 = opaque::<f32>(_50) -> [return: bb30, unwind continue]; } - bb26: { + bb30: { + StorageDead(_105); StorageDead(_104); - StorageDead(_103); + StorageLive(_107); + StorageLive(_108); StorageLive(_109); + _109 = _1; +- _108 = S::<u64>(move _109); ++ _108 = _53; + StorageDead(_109); +- _107 = opaque::<S<u64>>(move _108) -> [return: bb31, unwind continue]; ++ _107 = opaque::<S<u64>>(_53) -> [return: bb31, unwind continue]; + } + + bb31: { + StorageDead(_108); + StorageDead(_107); StorageLive(_110); -- StorageLive(_111); -- StorageLive(_112); -- _112 = _1; -- StorageLive(_113); -- _113 = _2; -- _111 = Shl(move _112, move _113); -- StorageDead(_113); -- StorageDead(_112); - StorageLive(_114); - _114 = _3; -- _110 = Add(move _111, move _114); -+ _110 = Add(_39, move _114); - StorageDead(_114); -- StorageDead(_111); - _109 = opaque::<u64>(move _110) -> [return: bb27, unwind continue]; + StorageLive(_111); + StorageLive(_112); + StorageLive(_113); + _113 = _1; +- _112 = S::<u64>(move _113); ++ _112 = _53; + StorageDead(_113); +- _111 = (_112.0: u64); +- _110 = opaque::<u64>(move _111) -> [return: bb32, unwind continue]; ++ _111 = _1; ++ _110 = opaque::<u64>(_1) -> [return: bb32, unwind continue]; } - bb27: { + bb32: { + StorageDead(_111); + StorageDead(_112); StorageDead(_110); - StorageDead(_109); - StorageLive(_115); + StorageLive(_114); +- StorageLive(_115); ++ nop; StorageLive(_116); -- StorageLive(_117); -- StorageLive(_118); -- _118 = _1; -- StorageLive(_119); -- _119 = _2; -- _117 = Shr(move _118, move _119); -- StorageDead(_119); -- StorageDead(_118); - StorageLive(_120); - _120 = _3; -- _116 = Add(move _117, move _120); -+ _116 = Add(_43, move _120); - StorageDead(_120); -- StorageDead(_117); - _115 = opaque::<u64>(move _116) -> [return: bb28, unwind continue]; + StorageLive(_117); + _117 = _1; + StorageLive(_118); + _118 = _2; +- _116 = Mul(move _117, move _118); ++ _116 = _9; + StorageDead(_118); + StorageDead(_117); + StorageLive(_119); + _119 = _2; +- _115 = Sub(move _116, move _119); ++ _115 = Sub(_9, _2); + StorageDead(_119); + StorageDead(_116); +- _114 = opaque::<u64>(move _115) -> [return: bb33, unwind continue]; ++ _114 = opaque::<u64>(_115) -> [return: bb33, unwind continue]; } - bb28: { - StorageDead(_116); - StorageDead(_115); + bb33: { +- StorageDead(_115); ++ nop; + StorageDead(_114); + StorageLive(_120); StorageLive(_121); -- StorageLive(_122); -- StorageLive(_123); -- _123 = _1; -- _122 = S::<u64>(move _123); -- StorageDead(_123); -- _121 = opaque::<S<u64>>(move _122) -> [return: bb29, unwind continue]; -+ _121 = opaque::<S<u64>>(_53) -> [return: bb29, unwind continue]; + StorageLive(_122); + StorageLive(_123); + _123 = _1; + StorageLive(_124); + _124 = _2; +- _122 = Mul(move _123, move _124); ++ _122 = _9; + StorageDead(_124); + StorageDead(_123); + StorageLive(_125); + _125 = _2; +- _121 = Sub(move _122, move _125); ++ _121 = _115; + StorageDead(_125); + StorageDead(_122); +- _120 = opaque::<u64>(move _121) -> [return: bb34, unwind continue]; ++ _120 = opaque::<u64>(_115) -> [return: bb34, unwind continue]; } - bb29: { -- StorageDead(_122); + bb34: { StorageDead(_121); - StorageLive(_124); -- StorageLive(_125); + StorageDead(_120); - StorageLive(_126); -- StorageLive(_127); -- _127 = _1; -- _126 = S::<u64>(move _127); -- StorageDead(_127); -- _125 = (_126.0: u64); -- _124 = opaque::<u64>(move _125) -> [return: bb30, unwind continue]; -+ _124 = opaque::<u64>(_56) -> [return: bb30, unwind continue]; - } - - bb30: { -- StorageDead(_125); -- StorageDead(_126); - StorageDead(_124); - StorageLive(_128); - _128 = &_3; - StorageLive(_129); -- StorageLive(_130); -- StorageLive(_131); - _131 = (*_128); -- StorageLive(_132); -- _132 = _1; -- _130 = Add(move _131, move _132); -- StorageDead(_132); -- StorageDead(_131); -- _129 = opaque::<u64>(move _130) -> [return: bb31, unwind continue]; -+ _130 = Add(_131, _1); -+ _129 = opaque::<u64>(_130) -> [return: bb31, unwind continue]; ++ nop; + _126 = &_3; + StorageLive(_127); +- StorageLive(_128); +- StorageLive(_129); ++ nop; ++ nop; + _129 = (*_126); + StorageLive(_130); + _130 = _1; +- _128 = Add(move _129, move _130); ++ _128 = Add(_129, _1); + StorageDead(_130); +- StorageDead(_129); +- _127 = opaque::<u64>(move _128) -> [return: bb35, unwind continue]; ++ nop; ++ _127 = opaque::<u64>(_128) -> [return: bb35, unwind continue]; } - bb31: { -- StorageDead(_130); - StorageDead(_129); + bb35: { +- StorageDead(_128); ++ nop; + StorageDead(_127); + StorageLive(_131); + StorageLive(_132); StorageLive(_133); -- StorageLive(_134); -- StorageLive(_135); -- _135 = (*_128); -- StorageLive(_136); -- _136 = _1; -- _134 = Add(move _135, move _136); -- StorageDead(_136); -- StorageDead(_135); -- _133 = opaque::<u64>(move _134) -> [return: bb32, unwind continue]; -+ _133 = opaque::<u64>(_130) -> [return: bb32, unwind continue]; +- _133 = (*_126); ++ _133 = _129; + StorageLive(_134); + _134 = _1; +- _132 = Add(move _133, move _134); ++ _132 = _128; + StorageDead(_134); + StorageDead(_133); +- _131 = opaque::<u64>(move _132) -> [return: bb36, unwind continue]; ++ _131 = opaque::<u64>(_128) -> [return: bb36, unwind continue]; } - bb32: { -- StorageDead(_134); - StorageDead(_133); + bb36: { + StorageDead(_132); + StorageDead(_131); +- StorageLive(_135); ++ nop; + _135 = &mut _3; + StorageLive(_136); StorageLive(_137); - _137 = &mut _3; StorageLive(_138); + _138 = (*_135); StorageLive(_139); - StorageLive(_140); - _140 = (*_137); -- StorageLive(_141); -- _141 = _1; -- _139 = Add(move _140, move _141); -- StorageDead(_141); -+ _139 = Add(move _140, _1); - StorageDead(_140); - _138 = opaque::<u64>(move _139) -> [return: bb33, unwind continue]; - } - - bb33: { + _139 = _1; +- _137 = Add(move _138, move _139); ++ _137 = Add(move _138, _1); StorageDead(_139); StorageDead(_138); - StorageLive(_142); - StorageLive(_143); - StorageLive(_144); - _144 = (*_137); -- StorageLive(_145); -- _145 = _1; -- _143 = Add(move _144, move _145); -- StorageDead(_145); -+ _143 = Add(move _144, _1); - StorageDead(_144); - _142 = opaque::<u64>(move _143) -> [return: bb34, unwind continue]; + _136 = opaque::<u64>(move _137) -> [return: bb37, unwind continue]; } - bb34: { + bb37: { + StorageDead(_137); + StorageDead(_136); + StorageLive(_140); + StorageLive(_141); + StorageLive(_142); + _142 = (*_135); + StorageLive(_143); + _143 = _1; +- _141 = Add(move _142, move _143); ++ _141 = Add(move _142, _1); StorageDead(_143); StorageDead(_142); -- StorageLive(_146); + _140 = opaque::<u64>(move _141) -> [return: bb38, unwind continue]; + } + + bb38: { + StorageDead(_141); + StorageDead(_140); + StorageLive(_144); +- StorageLive(_145); ++ nop; + _145 = &raw const _3; + StorageLive(_146); StorageLive(_147); - _147 = &raw const _3; StorageLive(_148); + _148 = (*_145); StorageLive(_149); - StorageLive(_150); - _150 = (*_147); -- StorageLive(_151); -- _151 = _1; -- _149 = Add(move _150, move _151); -- StorageDead(_151); -+ _149 = Add(move _150, _1); - StorageDead(_150); - _148 = opaque::<u64>(move _149) -> [return: bb35, unwind continue]; - } - - bb35: { + _149 = _1; +- _147 = Add(move _148, move _149); ++ _147 = Add(move _148, _1); StorageDead(_149); StorageDead(_148); - StorageLive(_152); - StorageLive(_153); - StorageLive(_154); - _154 = (*_147); -- StorageLive(_155); -- _155 = _1; -- _153 = Add(move _154, move _155); -- StorageDead(_155); -+ _153 = Add(move _154, _1); - StorageDead(_154); - _152 = opaque::<u64>(move _153) -> [return: bb36, unwind continue]; + _146 = opaque::<u64>(move _147) -> [return: bb39, unwind continue]; } - bb36: { + bb39: { + StorageDead(_147); + StorageDead(_146); + StorageLive(_150); + StorageLive(_151); + StorageLive(_152); + _152 = (*_145); + StorageLive(_153); + _153 = _1; +- _151 = Add(move _152, move _153); ++ _151 = Add(move _152, _1); StorageDead(_153); StorageDead(_152); + _150 = opaque::<u64>(move _151) -> [return: bb40, unwind continue]; + } + + bb40: { + StorageDead(_151); + StorageDead(_150); +- StorageLive(_154); ++ nop; + _154 = &raw mut _3; + StorageLive(_155); StorageLive(_156); - _156 = &raw mut _3; StorageLive(_157); + _157 = (*_154); StorageLive(_158); - StorageLive(_159); - _159 = (*_156); -- StorageLive(_160); -- _160 = _1; -- _158 = Add(move _159, move _160); -- StorageDead(_160); -+ _158 = Add(move _159, _1); - StorageDead(_159); - _157 = opaque::<u64>(move _158) -> [return: bb37, unwind continue]; - } - - bb37: { + _158 = _1; +- _156 = Add(move _157, move _158); ++ _156 = Add(move _157, _1); StorageDead(_158); StorageDead(_157); - StorageLive(_161); - StorageLive(_162); - StorageLive(_163); - _163 = (*_156); -- StorageLive(_164); -- _164 = _1; -- _162 = Add(move _163, move _164); -- StorageDead(_164); -+ _162 = Add(move _163, _1); - StorageDead(_163); - _161 = opaque::<u64>(move _162) -> [return: bb38, unwind continue]; + _155 = opaque::<u64>(move _156) -> [return: bb41, unwind continue]; } - bb38: { + bb41: { + StorageDead(_156); + StorageDead(_155); + StorageLive(_159); + StorageLive(_160); + StorageLive(_161); + _161 = (*_154); + StorageLive(_162); + _162 = _1; +- _160 = Add(move _161, move _162); ++ _160 = Add(move _161, _1); StorageDead(_162); StorageDead(_161); -- _146 = const (); - StorageDead(_156); - StorageDead(_147); -- StorageDead(_146); - StorageLive(_165); - _165 = &_3; - StorageLive(_166); -- StorageLive(_167); -- StorageLive(_168); - _168 = (*_165); -- StorageLive(_169); -- _169 = _1; -- _167 = Add(move _168, move _169); -- StorageDead(_169); -- StorageDead(_168); -- _166 = opaque::<u64>(move _167) -> [return: bb39, unwind continue]; -+ _167 = Add(_168, _1); -+ _166 = opaque::<u64>(_167) -> [return: bb39, unwind continue]; + _159 = opaque::<u64>(move _160) -> [return: bb42, unwind continue]; } - bb39: { -- StorageDead(_167); - StorageDead(_166); + bb42: { + StorageDead(_160); + StorageDead(_159); + _144 = const (); +- StorageDead(_154); +- StorageDead(_145); ++ nop; ++ nop; + StorageDead(_144); +- StorageLive(_163); ++ nop; + _163 = &_3; + StorageLive(_164); +- StorageLive(_165); +- StorageLive(_166); ++ nop; ++ nop; + _166 = (*_163); + StorageLive(_167); + _167 = _1; +- _165 = Add(move _166, move _167); ++ _165 = Add(_166, _1); + StorageDead(_167); +- StorageDead(_166); +- _164 = opaque::<u64>(move _165) -> [return: bb43, unwind continue]; ++ nop; ++ _164 = opaque::<u64>(_165) -> [return: bb43, unwind continue]; + } + + bb43: { +- StorageDead(_165); ++ nop; + StorageDead(_164); + StorageLive(_168); + StorageLive(_169); StorageLive(_170); -- StorageLive(_171); -- StorageLive(_172); -- _172 = (*_165); -- StorageLive(_173); -- _173 = _1; -- _171 = Add(move _172, move _173); -- StorageDead(_173); -- StorageDead(_172); -- _170 = opaque::<u64>(move _171) -> [return: bb40, unwind continue]; -+ _170 = opaque::<u64>(_167) -> [return: bb40, unwind continue]; +- _170 = (*_163); ++ _170 = _166; + StorageLive(_171); + _171 = _1; +- _169 = Add(move _170, move _171); ++ _169 = _165; + StorageDead(_171); + StorageDead(_170); +- _168 = opaque::<u64>(move _169) -> [return: bb44, unwind continue]; ++ _168 = opaque::<u64>(_165) -> [return: bb44, unwind continue]; } - bb40: { -- StorageDead(_171); - StorageDead(_170); + bb44: { + StorageDead(_169); + StorageDead(_168); _0 = const (); - StorageDead(_165); - StorageDead(_137); - StorageDead(_128); +- StorageDead(_163); +- StorageDead(_135); +- StorageDead(_126); ++ nop; ++ nop; ++ nop; 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 f33845502ad..62710ba8fbf 100644 --- a/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-abort.diff @@ -15,13 +15,15 @@ bb0: { StorageLive(_2); -- StorageLive(_3); -- _3 = _1; + StorageLive(_3); + _3 = _1; - _2 = Option::<T>::Some(move _3); -- StorageDead(_3); + _2 = Option::<T>::Some(_1); - _4 = discriminant(_2); - switchInt(move _4) -> [0: bb1, 1: bb3, otherwise: bb2]; + StorageDead(_3); +- _4 = discriminant(_2); +- switchInt(move _4) -> [0: bb1, 1: bb3, otherwise: bb2]; ++ _4 = const 1_isize; ++ switchInt(const 1_isize) -> [0: bb1, 1: bb3, otherwise: bb2]; } bb1: { @@ -34,10 +36,12 @@ } bb3: { -- StorageLive(_5); - _5 = ((_2 as Some).0: T); - _0 = _5; -- StorageDead(_5); + StorageLive(_5); +- _5 = ((_2 as Some).0: T); +- _0 = _5; ++ _5 = _1; ++ _0 = _1; + StorageDead(_5); StorageDead(_2); return; } diff --git a/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-unwind.diff b/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-unwind.diff index edc05f99fe2..ad46a065b1e 100644 --- a/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.wrap_unwrap.GVN.panic-unwind.diff @@ -15,13 +15,15 @@ bb0: { StorageLive(_2); -- StorageLive(_3); -- _3 = _1; + StorageLive(_3); + _3 = _1; - _2 = Option::<T>::Some(move _3); -- StorageDead(_3); + _2 = Option::<T>::Some(_1); - _4 = discriminant(_2); - switchInt(move _4) -> [0: bb1, 1: bb3, otherwise: bb2]; + StorageDead(_3); +- _4 = discriminant(_2); +- switchInt(move _4) -> [0: bb1, 1: bb3, otherwise: bb2]; ++ _4 = const 1_isize; ++ switchInt(const 1_isize) -> [0: bb1, 1: bb3, otherwise: bb2]; } bb1: { @@ -34,10 +36,12 @@ } bb3: { -- StorageLive(_5); - _5 = ((_2 as Some).0: T); - _0 = _5; -- StorageDead(_5); + StorageLive(_5); +- _5 = ((_2 as Some).0: T); +- _0 = _5; ++ _5 = _1; ++ _0 = _1; + StorageDead(_5); StorageDead(_2); return; } diff --git a/tests/mir-opt/inline/asm_unwind.rs b/tests/mir-opt/inline/asm_unwind.rs index 0cf21fda72f..0ae20e52211 100644 --- a/tests/mir-opt/inline/asm_unwind.rs +++ b/tests/mir-opt/inline/asm_unwind.rs @@ -1,8 +1,8 @@ -// skip-filecheck // Tests inlining of `may_unwind` inline assembly. // // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // needs-asm-support +// needs-unwind // compile-flags: -Zinline-mir-hint-threshold=1000 #![feature(asm_unwind)] @@ -20,5 +20,9 @@ fn foo() { // EMIT_MIR asm_unwind.main.Inline.diff pub fn main() { + // CHECK-LABEL: fn main( + // CHECK: (inlined foo) + // CHECK: asm!("", options(MAY_UNWIND)) -> [return: {{bb.*}}, unwind: [[unwind:bb.*]]]; + // CHECK: [[unwind]] (cleanup) foo(); } diff --git a/tests/mir-opt/inline/caller_with_trivial_bound.rs b/tests/mir-opt/inline/caller_with_trivial_bound.rs index 3829cbdd302..40f7f4bbab2 100644 --- a/tests/mir-opt/inline/caller_with_trivial_bound.rs +++ b/tests/mir-opt/inline/caller_with_trivial_bound.rs @@ -1,4 +1,3 @@ -// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // needs-unwind @@ -16,8 +15,13 @@ impl<T> Factory<T> for IntFactory { // EMIT_MIR caller_with_trivial_bound.foo.Inline.diff pub fn foo<T>() where + // Because of this trivial bound, the inliner fails to normalize + // `<IntFactory as Factory<T>>::Item`. + // Verify that we do not inline anything, which would cause validation ICEs. IntFactory: Factory<T>, { + // CHECK-LABEL: fn foo( + // CHECK-NOT: (inlined bar::<T>) let mut x: <IntFactory as Factory<T>>::Item = bar::<T>(); } diff --git a/tests/mir-opt/inline/cycle.rs b/tests/mir-opt/inline/cycle.rs index 3e4f0683435..350724235ba 100644 --- a/tests/mir-opt/inline/cycle.rs +++ b/tests/mir-opt/inline/cycle.rs @@ -1,20 +1,29 @@ -// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // compile-flags: -Zinline-mir-hint-threshold=1000 // EMIT_MIR cycle.f.Inline.diff #[inline(always)] fn f(g: impl Fn()) { + // CHECK-LABEL: fn f( + // CHECK-NOT: inlined g(); } // EMIT_MIR cycle.g.Inline.diff #[inline(always)] fn g() { + // CHECK-LABEL: fn g( + // CHECK-NOT: inlined + // CHECK: (inlined f::<fn() {main}>) + // CHECK-NOT: inlined f(main); } // EMIT_MIR cycle.main.Inline.diff fn main() { + // CHECK-LABEL: fn main( + // CHECK-NOT: inlined + // CHECK: (inlined f::<fn() {g}>) + // CHECK-NOT: inlined f(g); } diff --git a/tests/mir-opt/inline/dont_ice_on_generic_rust_call.rs b/tests/mir-opt/inline/dont_ice_on_generic_rust_call.rs index 4147325ec44..ce5e1855a71 100644 --- a/tests/mir-opt/inline/dont_ice_on_generic_rust_call.rs +++ b/tests/mir-opt/inline/dont_ice_on_generic_rust_call.rs @@ -1,4 +1,3 @@ -// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // compile-flags: -Zmir-enable-passes=+Inline --crate-type=lib @@ -8,5 +7,7 @@ use std::marker::Tuple; // EMIT_MIR dont_ice_on_generic_rust_call.call.Inline.diff pub fn call<I: Tuple>(mut mock: Box<dyn FnMut<I, Output = ()>>, input: I) { + // CHECK-LABEL: fn call( + // CHECK-NOT: inlined mock.call_mut(input) } diff --git a/tests/mir-opt/inline/dyn_trait.rs b/tests/mir-opt/inline/dyn_trait.rs index 7b41b1e1171..ecf220a85e6 100644 --- a/tests/mir-opt/inline/dyn_trait.rs +++ b/tests/mir-opt/inline/dyn_trait.rs @@ -1,4 +1,3 @@ -// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY #![crate_type = "lib"] @@ -20,18 +19,26 @@ pub trait Query { // EMIT_MIR dyn_trait.mk_cycle.Inline.diff #[inline(always)] pub fn mk_cycle<V: Debug>(c: &dyn Cache<V = V>) { + // CHECK-LABEL: fn mk_cycle( + // CHECK-NOT: inlined c.store_nocache() } // EMIT_MIR dyn_trait.try_execute_query.Inline.diff #[inline(always)] pub fn try_execute_query<C: Cache>(c: &C) { + // CHECK-LABEL: fn try_execute_query( + // CHECK: (inlined mk_cycle::<<C as Cache>::V>) mk_cycle(c) } // EMIT_MIR dyn_trait.get_query.Inline.diff #[inline(always)] pub fn get_query<Q: Query, T>(t: &T) { + // CHECK-LABEL: fn get_query( + // CHECK-NOT: inlined let c = Q::cache(t); + // CHECK: (inlined try_execute_query::<<Q as Query>::C>) + // CHECK: (inlined mk_cycle::<<Q as Query>::V>) try_execute_query(c) } diff --git a/tests/mir-opt/inline/exponential_runtime.rs b/tests/mir-opt/inline/exponential_runtime.rs index 6d3af8b9c57..1199ce4e558 100644 --- a/tests/mir-opt/inline/exponential_runtime.rs +++ b/tests/mir-opt/inline/exponential_runtime.rs @@ -1,4 +1,3 @@ -// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // Checks that code with exponential runtime does not have exponential behavior in inlining. @@ -85,5 +84,14 @@ impl A for () { // EMIT_MIR exponential_runtime.main.Inline.diff fn main() { + // CHECK-LABEL: fn main( + // CHECK-NOT: inlined + // CHECK: (inlined <() as G>::call) + // CHECK: (inlined <() as F>::call) + // CHECK: (inlined <() as E>::call) + // CHECK: (inlined <() as D>::call) + // CHECK: (inlined <() as C>::call) + // CHECK: (inlined <() as B>::call) + // CHECK-NOT: inlined <() as G>::call(); } diff --git a/tests/mir-opt/inline/inline_any_operand.rs b/tests/mir-opt/inline/inline_any_operand.rs index e131cd6ef7e..659b7c3a0a1 100644 --- a/tests/mir-opt/inline/inline_any_operand.rs +++ b/tests/mir-opt/inline/inline_any_operand.rs @@ -1,4 +1,3 @@ -// skip-filecheck // compile-flags: -Z span_free_formats // Tests that MIR inliner works for any operand @@ -9,6 +8,8 @@ fn main() { // EMIT_MIR inline_any_operand.bar.Inline.after.mir fn bar() -> bool { + // CHECK-LABEL: fn bar( + // CHECK: (inlined foo) let f = foo; f(1, -1) } diff --git a/tests/mir-opt/inline/inline_box_fn.rs b/tests/mir-opt/inline/inline_box_fn.rs index f6a90b92c91..d2da2393992 100644 --- a/tests/mir-opt/inline/inline_box_fn.rs +++ b/tests/mir-opt/inline/inline_box_fn.rs @@ -1,9 +1,10 @@ -// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // unit-test: Inline // compile-flags: --crate-type=lib // EMIT_MIR inline_box_fn.call.Inline.diff fn call(x: Box<dyn Fn(i32)>) { + // CHECK-LABEL: fn call( + // CHECK-NOT: inlined x(1); } diff --git a/tests/mir-opt/inline/inline_closure.rs b/tests/mir-opt/inline/inline_closure.rs index bd4c84ff0ca..65f55d49a80 100644 --- a/tests/mir-opt/inline/inline_closure.rs +++ b/tests/mir-opt/inline/inline_closure.rs @@ -1,4 +1,3 @@ -// skip-filecheck // compile-flags: -Z span_free_formats // Tests that MIR inliner can handle closure arguments. (#45894) @@ -10,5 +9,8 @@ fn main() { // EMIT_MIR inline_closure.foo.Inline.after.mir fn foo<T: Copy>(_t: T, q: i32) -> i32 { let x = |_t, _q| _t; + + // CHECK-LABEL: fn foo( + // CHECK: (inlined foo::<T>::{closure#0}) x(q, q) } diff --git a/tests/mir-opt/inline/inline_closure_borrows_arg.rs b/tests/mir-opt/inline/inline_closure_borrows_arg.rs index a5cc7d10365..1570ab057c7 100644 --- a/tests/mir-opt/inline/inline_closure_borrows_arg.rs +++ b/tests/mir-opt/inline/inline_closure_borrows_arg.rs @@ -1,4 +1,3 @@ -// skip-filecheck // compile-flags: -Z span_free_formats -Zunsound-mir-opts // Tests that MIR inliner can handle closure arguments, @@ -14,5 +13,8 @@ fn foo<T: Copy>(_t: T, q: &i32) -> i32 { let variable = &*r; *variable }; + + // CHECK-LABEL: fn foo( + // CHECK: (inlined foo::<T>::{closure#0}) x(q, q) } diff --git a/tests/mir-opt/inline/inline_closure_captures.rs b/tests/mir-opt/inline/inline_closure_captures.rs index 0d95564e5dd..2b08b106887 100644 --- a/tests/mir-opt/inline/inline_closure_captures.rs +++ b/tests/mir-opt/inline/inline_closure_captures.rs @@ -1,4 +1,3 @@ -// skip-filecheck // compile-flags: -Z span_free_formats // Tests that MIR inliner can handle closure captures. @@ -10,5 +9,8 @@ fn main() { // EMIT_MIR inline_closure_captures.foo.Inline.after.mir fn foo<T: Copy>(t: T, q: i32) -> (i32, T) { let x = |_q| (q, t); + + // CHECK-LABEL: fn foo( + // CHECK: (inlined foo::<T>::{closure#0}) x(q) } diff --git a/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff index 357d95f7c22..40eeda53908 100644 --- a/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-abort.diff @@ -4,26 +4,26 @@ fn main() -> () { let mut _0: (); let _1: std::ops::CoroutineState<i32, bool>; - let mut _2: std::pin::Pin<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}>; - let mut _3: &mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}; - let mut _4: {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}; + let mut _2: std::pin::Pin<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>; + let mut _3: &mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}; + let mut _4: {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}; + let mut _5: bool; scope 1 { debug _r => _1; } + scope 2 (inlined g) { + } -+ scope 3 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}>::new) { ++ scope 3 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new) { + debug pointer => _3; + scope 4 { -+ scope 5 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}>::new_unchecked) { ++ scope 5 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new_unchecked) { + debug pointer => _3; + } + } + } + scope 6 (inlined g::{closure#0}) { + debug a => _5; -+ let mut _6: &mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}; ++ let mut _6: &mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}; + let mut _7: u32; + let mut _8: i32; + } @@ -34,22 +34,22 @@ StorageLive(_3); StorageLive(_4); - _4 = g() -> [return: bb1, unwind unreachable]; -+ _4 = {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8 (#0)}; ++ _4 = {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8 (#0)}; + _3 = &mut _4; -+ _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}> { pointer: move _3 }; ++ _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}> { pointer: move _3 }; + StorageDead(_3); + StorageLive(_5); + _5 = const false; + StorageLive(_6); + StorageLive(_7); -+ _6 = (_2.0: &mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}); ++ _6 = (_2.0: &mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}); + _7 = discriminant((*_6)); + switchInt(move _7) -> [0: bb3, 1: bb7, 3: bb8, otherwise: bb9]; } bb1: { - _3 = &mut _4; -- _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}>::new(move _3) -> [return: bb2, unwind unreachable]; +- _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new(move _3) -> [return: bb2, unwind unreachable]; + StorageDead(_7); + StorageDead(_6); + StorageDead(_5); @@ -59,7 +59,7 @@ bb2: { - StorageDead(_3); -- _1 = <{coroutine@$DIR/inline_coroutine.rs:17:5: 17:8} as Coroutine<bool>>::resume(move _2, const false) -> [return: bb3, unwind unreachable]; +- _1 = <{coroutine@$DIR/inline_coroutine.rs:19:5: 19:8} as Coroutine<bool>>::resume(move _2, const false) -> [return: bb3, unwind unreachable]; + StorageDead(_4); + _0 = const (); + StorageDead(_1); diff --git a/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff index e7d02096838..fdb42bf3d8a 100644 --- a/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_coroutine.main.Inline.panic-unwind.diff @@ -4,26 +4,26 @@ fn main() -> () { let mut _0: (); let _1: std::ops::CoroutineState<i32, bool>; - let mut _2: std::pin::Pin<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}>; - let mut _3: &mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}; - let mut _4: {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}; + let mut _2: std::pin::Pin<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>; + let mut _3: &mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}; + let mut _4: {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}; + let mut _5: bool; scope 1 { debug _r => _1; } + scope 2 (inlined g) { + } -+ scope 3 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}>::new) { ++ scope 3 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new) { + debug pointer => _3; + scope 4 { -+ scope 5 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}>::new_unchecked) { ++ scope 5 (inlined Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new_unchecked) { + debug pointer => _3; + } + } + } + scope 6 (inlined g::{closure#0}) { + debug a => _5; -+ let mut _6: &mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}; ++ let mut _6: &mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}; + let mut _7: u32; + let mut _8: i32; + } @@ -37,20 +37,20 @@ - } - - bb1: { -+ _4 = {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8 (#0)}; ++ _4 = {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8 (#0)}; _3 = &mut _4; -- _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}>::new(move _3) -> [return: bb2, unwind: bb5]; +- _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}>::new(move _3) -> [return: bb2, unwind: bb5]; - } - - bb2: { -+ _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}> { pointer: move _3 }; ++ _2 = Pin::<&mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}> { pointer: move _3 }; StorageDead(_3); -- _1 = <{coroutine@$DIR/inline_coroutine.rs:17:5: 17:8} as Coroutine<bool>>::resume(move _2, const false) -> [return: bb3, unwind: bb5]; +- _1 = <{coroutine@$DIR/inline_coroutine.rs:19:5: 19:8} as Coroutine<bool>>::resume(move _2, const false) -> [return: bb3, unwind: bb5]; + StorageLive(_5); + _5 = const false; + StorageLive(_6); + StorageLive(_7); -+ _6 = (_2.0: &mut {coroutine@$DIR/inline_coroutine.rs:17:5: 17:8}); ++ _6 = (_2.0: &mut {coroutine@$DIR/inline_coroutine.rs:19:5: 19:8}); + _7 = discriminant((*_6)); + switchInt(move _7) -> [0: bb5, 1: bb9, 3: bb10, otherwise: bb11]; } diff --git a/tests/mir-opt/inline/inline_coroutine.rs b/tests/mir-opt/inline/inline_coroutine.rs index d021cdac28e..a82586bf2bf 100644 --- a/tests/mir-opt/inline/inline_coroutine.rs +++ b/tests/mir-opt/inline/inline_coroutine.rs @@ -1,4 +1,3 @@ -// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // compile-flags: -Zinline-mir-hint-threshold=1000 #![feature(coroutines, coroutine_trait)] @@ -8,6 +7,9 @@ use std::pin::Pin; // EMIT_MIR inline_coroutine.main.Inline.diff fn main() { + // CHECK-LABEL: fn main( + // CHECK: (inlined g) + // CHECK: (inlined g::{closure#0}) let _r = Pin::new(&mut g()).resume(false); } diff --git a/tests/mir-opt/inline/inline_diverging.rs b/tests/mir-opt/inline/inline_diverging.rs index 9e50b1ead2b..25a5b9c5c5e 100644 --- a/tests/mir-opt/inline/inline_diverging.rs +++ b/tests/mir-opt/inline/inline_diverging.rs @@ -1,4 +1,3 @@ -// skip-filecheck // Tests inlining of diverging calls. // // EMIT_MIR_FOR_EACH_PANIC_STRATEGY @@ -7,6 +6,8 @@ // EMIT_MIR inline_diverging.f.Inline.diff pub fn f() { + // CHECK-LABEL: fn f( + // CHECK: (inlined sleep) sleep(); } @@ -15,12 +16,17 @@ pub fn g(i: i32) -> u32 { if i > 0 { i as u32 } else { + // CHECK-LABEL: fn g( + // CHECK: (inlined panic) panic(); } } // EMIT_MIR inline_diverging.h.Inline.diff pub fn h() { + // CHECK-LABEL: fn h( + // CHECK: (inlined call_twice::<!, fn() -> ! {sleep}>) + // CHECK-NOT: inlined call_twice(sleep); } diff --git a/tests/mir-opt/inline/inline_instruction_set.rs b/tests/mir-opt/inline/inline_instruction_set.rs index 4ac4d462f82..7cb59645587 100644 --- a/tests/mir-opt/inline/inline_instruction_set.rs +++ b/tests/mir-opt/inline/inline_instruction_set.rs @@ -1,4 +1,3 @@ -// skip-filecheck // Checks that only functions with the compatible instruction_set attributes are inlined. // // A function is "compatible" when the *callee* has the same attribute or no attribute. @@ -47,16 +46,26 @@ fn inline_always_and_using_inline_asm() { // EMIT_MIR inline_instruction_set.t32.Inline.diff #[instruction_set(arm::t32)] pub fn t32() { + // CHECK-LABEL: fn t32( + // CHECK-NOT: (inlined instruction_set_a32) instruction_set_a32(); + // CHECK: (inlined instruction_set_t32) instruction_set_t32(); + // CHECK: (inlined instruction_set_default) instruction_set_default(); + // CHECK-NOT: (inlined inline_always_and_using_inline_asm) inline_always_and_using_inline_asm(); } // EMIT_MIR inline_instruction_set.default.Inline.diff pub fn default() { + // CHECK-LABEL: fn default( + // CHECK-NOT: (inlined instruction_set_a32) instruction_set_a32(); + // CHECK-NOT: (inlined instruction_set_t32) instruction_set_t32(); + // CHECK: (inlined instruction_set_default) instruction_set_default(); + // CHECK: (inlined inline_always_and_using_inline_asm) inline_always_and_using_inline_asm(); } diff --git a/tests/mir-opt/inline/inline_into_box_place.rs b/tests/mir-opt/inline/inline_into_box_place.rs index b755692afc2..65f8e2916b6 100644 --- a/tests/mir-opt/inline/inline_into_box_place.rs +++ b/tests/mir-opt/inline/inline_into_box_place.rs @@ -1,4 +1,3 @@ -// skip-filecheck // ignore-endian-big // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // ignore-debug MIR alignment checks in std alter the diff, breaking the test @@ -6,5 +5,7 @@ // EMIT_MIR inline_into_box_place.main.Inline.diff fn main() { + // CHECK-LABEL: fn main( + // CHECK: (inlined Box::<Vec<u32>>::new) let _x: Box<Vec<u32>> = Box::new(Vec::new()); } diff --git a/tests/mir-opt/inline/inline_options.rs b/tests/mir-opt/inline/inline_options.rs index 394a8c4945c..b940c64f0b8 100644 --- a/tests/mir-opt/inline/inline_options.rs +++ b/tests/mir-opt/inline/inline_options.rs @@ -1,4 +1,3 @@ -// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // Checks that inlining threshold can be controlled with // inline-mir-threshold and inline-hint-threshold options. @@ -8,7 +7,10 @@ // EMIT_MIR inline_options.main.Inline.after.mir fn main() { + // CHECK-LABEL: fn main( + // CHECK-NOT: (inlined not_inlined) not_inlined(); + // CHECK: (inlined inlined::<u32>) inlined::<u32>(); } diff --git a/tests/mir-opt/inline/inline_retag.rs b/tests/mir-opt/inline/inline_retag.rs index f695b9f22e6..9fb6f709223 100644 --- a/tests/mir-opt/inline/inline_retag.rs +++ b/tests/mir-opt/inline/inline_retag.rs @@ -1,4 +1,3 @@ -// skip-filecheck // compile-flags: -Z span_free_formats -Z mir-emit-retag // Tests that MIR inliner fixes up `Retag`'s `fn_entry` flag @@ -9,6 +8,17 @@ fn main() { // EMIT_MIR inline_retag.bar.Inline.after.mir fn bar() -> bool { + // CHECK-LABEL: fn bar( + // CHECK: (inlined foo) + // CHECK: debug x => [[x:_.*]]; + // CHECK: debug y => [[y:_.*]]; + // CHECK: bb0: { + // CHECK: Retag + // CHECK: Retag + // CHECK: Retag([[x]]); + // CHECK: Retag([[y]]); + // CHECK: return; + // CHECK-NEXT: } let f = foo; f(&1, &-1) } diff --git a/tests/mir-opt/inline/inline_specialization.rs b/tests/mir-opt/inline/inline_specialization.rs index eb0cf891dad..6453abc0081 100644 --- a/tests/mir-opt/inline/inline_specialization.rs +++ b/tests/mir-opt/inline/inline_specialization.rs @@ -1,9 +1,10 @@ -// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY #![feature(specialization)] // EMIT_MIR inline_specialization.main.Inline.diff fn main() { + // CHECK-LABEL: fn main( + // CHECK: (inlined <Vec<()> as Foo>::bar) let x = <Vec::<()> as Foo>::bar(); } diff --git a/tests/mir-opt/inline/inline_trait_method.rs b/tests/mir-opt/inline/inline_trait_method.rs index 8a95adf3713..b39355637a1 100644 --- a/tests/mir-opt/inline/inline_trait_method.rs +++ b/tests/mir-opt/inline/inline_trait_method.rs @@ -1,4 +1,4 @@ -// skip-filecheck +// Verify that we do not inline the default impl in a trait object. // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // compile-flags: -Z span_free_formats @@ -8,6 +8,8 @@ fn main() { // EMIT_MIR inline_trait_method.test.Inline.after.mir fn test(x: &dyn X) -> u32 { + // CHECK-LABEL: fn test( + // CHECK-NOT: inlined x.y() } diff --git a/tests/mir-opt/inline/inline_trait_method_2.rs b/tests/mir-opt/inline/inline_trait_method_2.rs index e87609a8c7e..b0b6a7b9b01 100644 --- a/tests/mir-opt/inline/inline_trait_method_2.rs +++ b/tests/mir-opt/inline/inline_trait_method_2.rs @@ -1,9 +1,11 @@ -// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // compile-flags: -Z span_free_formats -Z mir-opt-level=4 // EMIT_MIR inline_trait_method_2.test2.Inline.after.mir fn test2(x: &dyn X) -> bool { + // CHECK-LABEL: fn test2( + // CHECK: (inlined test) + // CHECK-NOT: (inlined <dyn X as X>::y) test(x) } diff --git a/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.rs b/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.rs index da779fed76f..4517c88d713 100644 --- a/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.rs +++ b/tests/mir-opt/inline/issue_58867_inline_as_ref_as_mut.rs @@ -1,21 +1,28 @@ -// skip-filecheck // EMIT_MIR issue_58867_inline_as_ref_as_mut.a.Inline.after.mir pub fn a<T>(x: &mut [T]) -> &mut [T] { + // CHECK-LABEL: fn a( + // CHECK: (inlined <[T] as AsMut<[T]>>::as_mut) x.as_mut() } // EMIT_MIR issue_58867_inline_as_ref_as_mut.b.Inline.after.mir pub fn b<T>(x: &mut Box<T>) -> &mut T { + // CHECK-LABEL: fn b( + // CHECK: (inlined <Box<T> as AsMut<T>>::as_mut) x.as_mut() } // EMIT_MIR issue_58867_inline_as_ref_as_mut.c.Inline.after.mir pub fn c<T>(x: &[T]) -> &[T] { + // CHECK-LABEL: fn c( + // CHECK: (inlined <[T] as AsRef<[T]>>::as_ref) x.as_ref() } // EMIT_MIR issue_58867_inline_as_ref_as_mut.d.Inline.after.mir pub fn d<T>(x: &Box<T>) -> &T { + // CHECK-LABEL: fn d( + // CHECK: (inlined <Box<T> as AsRef<T>>::as_ref) x.as_ref() } diff --git a/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir b/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir index d28c0441f63..ba4f91b28d5 100644 --- a/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir +++ b/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.main.Inline.after.mir @@ -2,8 +2,8 @@ fn main() -> () { let mut _0: (); - let _1: {closure@$DIR/issue_76997_inline_scopes_parenting.rs:6:13: 6:16}; - let mut _2: &{closure@$DIR/issue_76997_inline_scopes_parenting.rs:6:13: 6:16}; + let _1: {closure@$DIR/issue_76997_inline_scopes_parenting.rs:15:13: 15:16}; + let mut _2: &{closure@$DIR/issue_76997_inline_scopes_parenting.rs:15:13: 15:16}; let mut _3: ((),); let mut _4: (); let mut _5: (); @@ -19,7 +19,7 @@ fn main() -> () { bb0: { StorageLive(_1); - _1 = {closure@$DIR/issue_76997_inline_scopes_parenting.rs:6:13: 6:16}; + _1 = {closure@$DIR/issue_76997_inline_scopes_parenting.rs:15:13: 15:16}; StorageLive(_2); _2 = &_1; StorageLive(_3); diff --git a/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.rs b/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.rs index c7147d42df9..2fb363c1904 100644 --- a/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.rs +++ b/tests/mir-opt/inline/issue_76997_inline_scopes_parenting.rs @@ -1,8 +1,17 @@ -// skip-filecheck // Tests that MIR inliner can handle `SourceScopeData` parenting correctly. (#76997) // EMIT_MIR issue_76997_inline_scopes_parenting.main.Inline.after.mir fn main() { + // CHECK-LABEL: fn main( + // CHECK: scope 1 { + // CHECK-NEXT: debug f + // CHECK-NEXT: scope 2 (inlined main::{closure#0}) { + // CHECK-NEXT: debug x + // CHECK-NEXT: scope 3 { + // CHECK-NEXT: debug y + // CHECK-NEXT: } + // CHECK-NEXT: } + // CHECK-NEXT: } let f = |x| { let y = x; y }; f(()) } diff --git a/tests/mir-opt/inline/issue_78442.rs b/tests/mir-opt/inline/issue_78442.rs index f83ed70d0db..f9a5234283a 100644 --- a/tests/mir-opt/inline/issue_78442.rs +++ b/tests/mir-opt/inline/issue_78442.rs @@ -1,4 +1,3 @@ -// skip-filecheck // compile-flags: -Z mir-opt-level=3 -Z inline-mir // EMIT_MIR_FOR_EACH_PANIC_STRATEGY #![crate_type = "lib"] @@ -9,6 +8,11 @@ pub fn bar<P>( // Error won't happen if "bar" is not generic _baz: P, ) { + // CHECK-LABEL: fn bar( + // CHECK: let mut {{.*}}: &fn() {foo}; + // CHECK: let {{.*}}: fn() {foo}; + // CHECK: (inlined hide_foo) + // CHECK-NOT: inlined hide_foo()(); } diff --git a/tests/mir-opt/inline/unchecked_shifts.rs b/tests/mir-opt/inline/unchecked_shifts.rs index 67666f2f713..0de80641c9c 100644 --- a/tests/mir-opt/inline/unchecked_shifts.rs +++ b/tests/mir-opt/inline/unchecked_shifts.rs @@ -1,7 +1,6 @@ -// skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY #![crate_type = "lib"] -#![feature(unchecked_math)] +#![feature(unchecked_shifts)] // ignore-debug: the debug assertions prevent the inlining we are testing for // compile-flags: -Zmir-opt-level=2 -Zinline-mir @@ -9,23 +8,31 @@ // EMIT_MIR unchecked_shifts.unchecked_shl_unsigned_smaller.Inline.diff // EMIT_MIR unchecked_shifts.unchecked_shl_unsigned_smaller.PreCodegen.after.mir pub unsafe fn unchecked_shl_unsigned_smaller(a: u16, b: u32) -> u16 { + // CHECK-LABEL: fn unchecked_shl_unsigned_smaller( + // CHECK: (inlined core::num::<impl u16>::unchecked_shl) a.unchecked_shl(b) } // EMIT_MIR unchecked_shifts.unchecked_shr_signed_smaller.Inline.diff // EMIT_MIR unchecked_shifts.unchecked_shr_signed_smaller.PreCodegen.after.mir pub unsafe fn unchecked_shr_signed_smaller(a: i16, b: u32) -> i16 { + // CHECK-LABEL: fn unchecked_shr_signed_smaller( + // CHECK: (inlined core::num::<impl i16>::unchecked_shr) a.unchecked_shr(b) } // EMIT_MIR unchecked_shifts.unchecked_shl_unsigned_bigger.Inline.diff // EMIT_MIR unchecked_shifts.unchecked_shl_unsigned_bigger.PreCodegen.after.mir pub unsafe fn unchecked_shl_unsigned_bigger(a: u64, b: u32) -> u64 { + // CHECK-LABEL: fn unchecked_shl_unsigned_bigger( + // CHECK: (inlined core::num::<impl u64>::unchecked_shl) a.unchecked_shl(b) } // EMIT_MIR unchecked_shifts.unchecked_shr_signed_bigger.Inline.diff // EMIT_MIR unchecked_shifts.unchecked_shr_signed_bigger.PreCodegen.after.mir pub unsafe fn unchecked_shr_signed_bigger(a: i64, b: u32) -> i64 { + // CHECK-LABEL: fn unchecked_shr_signed_bigger( + // CHECK: (inlined core::num::<impl i64>::unchecked_shr) a.unchecked_shr(b) } diff --git a/tests/mir-opt/inline/unsized_argument.rs b/tests/mir-opt/inline/unsized_argument.rs index 22c88b83f9b..e8c2bc10be2 100644 --- a/tests/mir-opt/inline/unsized_argument.rs +++ b/tests/mir-opt/inline/unsized_argument.rs @@ -1,4 +1,3 @@ -// skip-filecheck // needs-unwind #![feature(unsized_fn_params)] @@ -7,6 +6,8 @@ fn callee(y: [i32]) {} // EMIT_MIR unsized_argument.caller.Inline.diff fn caller(x: Box<[i32]>) { + // CHECK-LABEL: fn caller( + // CHECK-NOT: (inlined callee) callee(*x); } diff --git a/tests/mir-opt/inline/unwrap_unchecked.rs b/tests/mir-opt/inline/unwrap_unchecked.rs index f8964eba227..be133706e5c 100644 --- a/tests/mir-opt/inline/unwrap_unchecked.rs +++ b/tests/mir-opt/inline/unwrap_unchecked.rs @@ -1,4 +1,3 @@ -// skip-filecheck #![crate_type = "lib"] // EMIT_MIR_FOR_EACH_PANIC_STRATEGY @@ -8,5 +7,7 @@ // EMIT_MIR unwrap_unchecked.unwrap_unchecked.Inline.diff // EMIT_MIR unwrap_unchecked.unwrap_unchecked.PreCodegen.after.mir pub unsafe fn unwrap_unchecked<T>(slf: Option<T>) -> T { + // CHECK-LABEL: fn unwrap_unchecked( + // CHECK: (inlined #[track_caller] Option::<T>::unwrap_unchecked) slf.unwrap_unchecked() } 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 018b6c1ee95..2a36ad9230e 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 @@ -9,6 +9,7 @@ + debug self => _2; + let mut _3: &std::option::Option<T>; + let mut _4: isize; ++ let mut _5: bool; + scope 2 { + debug val => _0; + } @@ -29,18 +30,17 @@ StorageLive(_2); _2 = move _1; - _0 = Option::<T>::unwrap_unchecked(move _2) -> [return: bb1, unwind unreachable]; +- } +- +- bb1: { + StorageLive(_3); + StorageLive(_4); ++ StorageLive(_5); + _4 = discriminant(_2); -+ switchInt(move _4) -> [1: bb2, otherwise: bb1]; - } - - bb1: { -+ unreachable; -+ } -+ -+ bb2: { ++ _5 = Eq(_4, const 1_isize); ++ assume(move _5); + _0 = move ((_2 as Some).0: T); ++ StorageDead(_5); + StorageDead(_4); + StorageDead(_3); StorageDead(_2); 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 47845758a3f..14c8c671d3f 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 @@ -9,6 +9,7 @@ + debug self => _2; + let mut _3: &std::option::Option<T>; + let mut _4: isize; ++ let mut _5: bool; + scope 2 { + debug val => _0; + } @@ -29,26 +30,25 @@ StorageLive(_2); _2 = move _1; - _0 = Option::<T>::unwrap_unchecked(move _2) -> [return: bb1, unwind: bb2]; +- } +- +- bb1: { + StorageLive(_3); + StorageLive(_4); ++ StorageLive(_5); + _4 = discriminant(_2); -+ switchInt(move _4) -> [1: bb2, otherwise: bb1]; - } - - bb1: { -- StorageDead(_2); -- return; -+ unreachable; - } - -- bb2 (cleanup): { -- resume; -+ bb2: { ++ _5 = Eq(_4, const 1_isize); ++ assume(move _5); + _0 = move ((_2 as Some).0: T); ++ StorageDead(_5); + StorageDead(_4); + StorageDead(_3); -+ StorageDead(_2); -+ return; + StorageDead(_2); + return; +- } +- +- bb2 (cleanup): { +- resume; } } diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-abort.mir b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-abort.mir index 392f085bd4d..aeb93bd334f 100644 --- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-abort.mir @@ -6,7 +6,8 @@ fn unwrap_unchecked(_1: Option<T>) -> T { scope 1 (inlined #[track_caller] Option::<T>::unwrap_unchecked) { debug self => _1; let mut _2: isize; - let mut _3: &std::option::Option<T>; + let mut _3: bool; + let mut _4: &std::option::Option<T>; scope 2 { debug val => _0; } @@ -19,25 +20,21 @@ fn unwrap_unchecked(_1: Option<T>) -> T { } } scope 4 (inlined Option::<T>::is_some) { - debug self => _3; + debug self => _4; } } bb0: { - StorageLive(_3); + StorageLive(_4); StorageLive(_2); + StorageLive(_3); _2 = discriminant(_1); - switchInt(move _2) -> [1: bb1, otherwise: bb2]; - } - - bb1: { + _3 = Eq(_2, const 1_isize); + assume(move _3); _0 = move ((_1 as Some).0: T); - StorageDead(_2); StorageDead(_3); + StorageDead(_2); + StorageDead(_4); return; } - - bb2: { - unreachable; - } } diff --git a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-unwind.mir index 392f085bd4d..aeb93bd334f 100644 --- a/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/inline/unwrap_unchecked.unwrap_unchecked.PreCodegen.after.panic-unwind.mir @@ -6,7 +6,8 @@ fn unwrap_unchecked(_1: Option<T>) -> T { scope 1 (inlined #[track_caller] Option::<T>::unwrap_unchecked) { debug self => _1; let mut _2: isize; - let mut _3: &std::option::Option<T>; + let mut _3: bool; + let mut _4: &std::option::Option<T>; scope 2 { debug val => _0; } @@ -19,25 +20,21 @@ fn unwrap_unchecked(_1: Option<T>) -> T { } } scope 4 (inlined Option::<T>::is_some) { - debug self => _3; + debug self => _4; } } bb0: { - StorageLive(_3); + StorageLive(_4); StorageLive(_2); + StorageLive(_3); _2 = discriminant(_1); - switchInt(move _2) -> [1: bb1, otherwise: bb2]; - } - - bb1: { + _3 = Eq(_2, const 1_isize); + assume(move _3); _0 = move ((_1 as Some).0: T); - StorageDead(_2); StorageDead(_3); + StorageDead(_2); + StorageDead(_4); return; } - - bb2: { - unreachable; - } } diff --git a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff index 9d8f272abea..b2539f391d1 100644 --- a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff +++ b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff @@ -7,22 +7,18 @@ let _2: &[T]; let mut _3: &[T; 3]; let _4: [T; 3]; - let mut _5: T; - let mut _6: T; - let mut _7: T; - let mut _8: usize; - let mut _9: usize; - let mut _10: bool; - let mut _14: !; + let mut _5: usize; + let mut _6: bool; + let mut _10: !; scope 1 { debug v => _2; - let _11: &T; - let _12: &T; - let _13: &T; + let _7: &T; + let _8: &T; + let _9: &T; scope 2 { - debug v1 => _11; - debug v2 => _12; - debug v3 => _13; + debug v1 => _7; + debug v2 => _8; + debug v3 => _9; } } @@ -33,26 +29,25 @@ _3 = &_4; _2 = move _3 as &[T] (PointerCoercion(Unsize)); StorageDead(_3); - _8 = const 3_usize; - _9 = const 3_usize; - _10 = const true; + _5 = const 3_usize; + _6 = const true; goto -> bb2; } bb1: { - _14 = core::panicking::panic(const "internal error: entered unreachable code") -> unwind unreachable; + _10 = core::panicking::panic(const "internal error: entered unreachable code") -> unwind unreachable; } bb2: { - StorageLive(_11); - _11 = &(*_2)[0 of 3]; - StorageLive(_12); - _12 = &(*_2)[1 of 3]; - StorageLive(_13); - _13 = &(*_2)[2 of 3]; - StorageDead(_13); - StorageDead(_12); - StorageDead(_11); + StorageLive(_7); + _7 = &(*_2)[0 of 3]; + StorageLive(_8); + _8 = &(*_2)[1 of 3]; + StorageLive(_9); + _9 = &(*_2)[2 of 3]; + StorageDead(_9); + StorageDead(_8); + StorageDead(_7); StorageDead(_4); return; } diff --git a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff index 738b0b1b3e5..ff7f12c093c 100644 --- a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff +++ b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff @@ -7,22 +7,18 @@ let _2: &[T]; let mut _3: &[T; 3]; let _4: [T; 3]; - let mut _5: T; - let mut _6: T; - let mut _7: T; - let mut _8: usize; - let mut _9: usize; - let mut _10: bool; - let mut _14: !; + let mut _5: usize; + let mut _6: bool; + let mut _10: !; scope 1 { debug v => _2; - let _11: &T; - let _12: &T; - let _13: &T; + let _7: &T; + let _8: &T; + let _9: &T; scope 2 { - debug v1 => _11; - debug v2 => _12; - debug v3 => _13; + debug v1 => _7; + debug v2 => _8; + debug v3 => _9; } } @@ -33,26 +29,25 @@ _3 = &_4; _2 = move _3 as &[T] (PointerCoercion(Unsize)); StorageDead(_3); - _8 = const 3_usize; - _9 = const 3_usize; - _10 = const true; + _5 = const 3_usize; + _6 = const true; goto -> bb2; } bb1: { - _14 = core::panicking::panic(const "internal error: entered unreachable code") -> unwind continue; + _10 = core::panicking::panic(const "internal error: entered unreachable code") -> unwind continue; } bb2: { - StorageLive(_11); - _11 = &(*_2)[0 of 3]; - StorageLive(_12); - _12 = &(*_2)[1 of 3]; - StorageLive(_13); - _13 = &(*_2)[2 of 3]; - StorageDead(_13); - StorageDead(_12); - StorageDead(_11); + StorageLive(_7); + _7 = &(*_2)[0 of 3]; + StorageLive(_8); + _8 = &(*_2)[1 of 3]; + StorageLive(_9); + _9 = &(*_2)[2 of 3]; + StorageDead(_9); + StorageDead(_8); + StorageDead(_7); StorageDead(_4); return; } diff --git a/tests/mir-opt/pre-codegen/duplicate_switch_targets.ub_if_b.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/duplicate_switch_targets.ub_if_b.PreCodegen.after.mir index 65d71199aae..0114309dbb5 100644 --- a/tests/mir-opt/pre-codegen/duplicate_switch_targets.ub_if_b.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/duplicate_switch_targets.ub_if_b.PreCodegen.after.mir @@ -4,6 +4,7 @@ fn ub_if_b(_1: Thing) -> Thing { debug t => _1; let mut _0: Thing; let mut _2: isize; + let mut _3: bool; scope 1 (inlined unreachable_unchecked) { scope 2 { scope 3 (inlined unreachable_unchecked::runtime) { @@ -13,15 +14,9 @@ fn ub_if_b(_1: Thing) -> Thing { bb0: { _2 = discriminant(_1); - switchInt(move _2) -> [0: bb1, otherwise: bb2]; - } - - bb1: { + _3 = Eq(_2, const 0_isize); + assume(move _3); _0 = move _1; return; } - - bb2: { - unreachable; - } } diff --git a/tests/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff b/tests/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff index 491db551a7d..fe4b33001fc 100644 --- a/tests/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff +++ b/tests/mir-opt/separate_const_switch.identity.SeparateConstSwitch.diff @@ -52,7 +52,7 @@ StorageLive(_10); StorageLive(_11); _9 = discriminant(_1); - switchInt(move _9) -> [0: bb7, 1: bb5, otherwise: bb6]; + switchInt(move _9) -> [0: bb6, 1: bb5, otherwise: bb3]; } bb1: { @@ -92,10 +92,6 @@ } bb6: { - unreachable; - } - - bb7: { _10 = ((_1 as Ok).0: i32); _3 = ControlFlow::<Result<Infallible, i32>, i32>::Continue(move _10); goto -> bb1; diff --git a/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-const-prop.panic-abort.diff b/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-const-prop.panic-abort.diff index d3957158360..64a435f2245 100644 --- a/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-const-prop.panic-abort.diff +++ b/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-const-prop.panic-abort.diff @@ -3,18 +3,15 @@ fn main() -> () { let mut _0: (); - let mut _1: bool; - let _2: (); + let _1: (); bb0: { - StorageLive(_1); - _1 = const false; - switchInt(const false) -> [0: bb3, otherwise: bb1]; + goto -> bb3; } bb1: { - _2 = noop() -> [return: bb2, unwind unreachable]; + _1 = noop() -> [return: bb2, unwind unreachable]; } bb2: { @@ -26,7 +23,6 @@ } bb4: { - StorageDead(_1); return; } } diff --git a/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-const-prop.panic-unwind.diff b/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-const-prop.panic-unwind.diff index 81903c64dbd..146e00686ed 100644 --- a/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-const-prop.panic-unwind.diff +++ b/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-const-prop.panic-unwind.diff @@ -3,18 +3,15 @@ fn main() -> () { let mut _0: (); - let mut _1: bool; - let _2: (); + let _1: (); bb0: { - StorageLive(_1); - _1 = const false; - switchInt(const false) -> [0: bb3, otherwise: bb1]; + goto -> bb3; } bb1: { - _2 = noop() -> [return: bb2, unwind continue]; + _1 = noop() -> [return: bb2, unwind continue]; } bb2: { @@ -26,7 +23,6 @@ } bb4: { - StorageDead(_1); return; } } diff --git a/tests/mir-opt/uninhabited_enum_branching2.main.UninhabitedEnumBranching.diff b/tests/mir-opt/uninhabited_enum_branching.byref.UninhabitedEnumBranching.diff index 12ce6505af9..7919450cdc5 100644 --- a/tests/mir-opt/uninhabited_enum_branching2.main.UninhabitedEnumBranching.diff +++ b/tests/mir-opt/uninhabited_enum_branching.byref.UninhabitedEnumBranching.diff @@ -1,12 +1,12 @@ -- // MIR for `main` before UninhabitedEnumBranching -+ // MIR for `main` after UninhabitedEnumBranching +- // MIR for `byref` before UninhabitedEnumBranching ++ // MIR for `byref` after UninhabitedEnumBranching - fn main() -> () { + fn byref() -> () { let mut _0: (); let _1: Plop; - let mut _2: Test1; + let mut _2: Test3; let _3: &str; - let mut _4: &Test1; + let mut _4: &Test3; let mut _5: isize; let _6: &str; let _7: &str; @@ -23,15 +23,15 @@ bb0: { StorageLive(_1); StorageLive(_2); - _2 = Test1::C; - _1 = Plop { xx: const 51_u32, test1: move _2 }; + _2 = Test3::C; + _1 = Plop { xx: const 51_u32, test3: move _2 }; StorageDead(_2); StorageLive(_3); StorageLive(_4); - _4 = &(_1.1: Test1); + _4 = &(_1.1: Test3); _5 = discriminant((*_4)); - switchInt(move _5) -> [0: bb3, 1: bb4, 2: bb5, 3: bb1, otherwise: bb2]; -+ switchInt(move _5) -> [2: bb5, 3: bb1, otherwise: bb2]; ++ switchInt(move _5) -> [0: bb12, 1: bb12, 2: bb5, 3: bb1, otherwise: bb12]; } bb1: { @@ -71,9 +71,9 @@ StorageDead(_4); StorageDead(_3); StorageLive(_9); - _10 = discriminant((_1.1: Test1)); + _10 = discriminant((_1.1: Test3)); - switchInt(move _10) -> [0: bb8, 1: bb9, 2: bb10, 3: bb7, otherwise: bb2]; -+ switchInt(move _10) -> [2: bb10, 3: bb7, otherwise: bb2]; ++ switchInt(move _10) -> [0: bb12, 1: bb12, 2: bb10, 3: bb7, otherwise: bb12]; } bb7: { @@ -110,6 +110,10 @@ _0 = const (); StorageDead(_1); return; ++ } ++ ++ bb12: { ++ unreachable; } } diff --git a/tests/mir-opt/uninhabited_enum_branching.custom_discriminant.UninhabitedEnumBranching.diff b/tests/mir-opt/uninhabited_enum_branching.custom_discriminant.UninhabitedEnumBranching.diff new file mode 100644 index 00000000000..5e15298a78c --- /dev/null +++ b/tests/mir-opt/uninhabited_enum_branching.custom_discriminant.UninhabitedEnumBranching.diff @@ -0,0 +1,48 @@ +- // MIR for `custom_discriminant` before UninhabitedEnumBranching ++ // MIR for `custom_discriminant` after UninhabitedEnumBranching + + fn custom_discriminant() -> () { + let mut _0: (); + let _1: &str; + let mut _2: Test2; + let mut _3: isize; + let _4: &str; + + bb0: { + StorageLive(_1); + 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]; + } + + bb1: { + StorageLive(_4); + _4 = const "E"; + _1 = &(*_4); + StorageDead(_4); + goto -> bb4; + } + + bb2: { + unreachable; + } + + bb3: { + _1 = const "D"; + goto -> bb4; + } + + bb4: { + StorageDead(_2); + StorageDead(_1); + _0 = const (); + return; ++ } ++ ++ bb5: { ++ unreachable; + } + } + diff --git a/tests/mir-opt/uninhabited_enum_branching.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir b/tests/mir-opt/uninhabited_enum_branching.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir deleted file mode 100644 index 474f43104bb..00000000000 --- a/tests/mir-opt/uninhabited_enum_branching.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir +++ /dev/null @@ -1,60 +0,0 @@ -// MIR for `main` after SimplifyCfg-after-uninhabited-enum-branching - -fn main() -> () { - let mut _0: (); - let _1: &str; - let mut _2: Test1; - let mut _3: isize; - let _4: &str; - let _5: &str; - let _6: &str; - let mut _7: Test2; - let mut _8: isize; - let _9: &str; - - bb0: { - StorageLive(_1); - StorageLive(_2); - _2 = Test1::C; - _3 = discriminant(_2); - switchInt(move _3) -> [2: bb1, otherwise: bb2]; - } - - bb1: { - StorageLive(_5); - _5 = const "C"; - _1 = &(*_5); - StorageDead(_5); - StorageDead(_2); - StorageDead(_1); - StorageLive(_6); - StorageLive(_7); - _7 = Test2::D; - _8 = discriminant(_7); - switchInt(move _8) -> [4: bb4, 5: bb3, otherwise: bb2]; - } - - bb2: { - unreachable; - } - - bb3: { - StorageLive(_9); - _9 = const "E"; - _6 = &(*_9); - StorageDead(_9); - goto -> bb5; - } - - bb4: { - _6 = const "D"; - goto -> bb5; - } - - bb5: { - StorageDead(_7); - StorageDead(_6); - _0 = const (); - return; - } -} diff --git a/tests/mir-opt/uninhabited_enum_branching.rs b/tests/mir-opt/uninhabited_enum_branching.rs index 96ae84eca50..60389117b16 100644 --- a/tests/mir-opt/uninhabited_enum_branching.rs +++ b/tests/mir-opt/uninhabited_enum_branching.rs @@ -1,11 +1,11 @@ -// skip-filecheck -enum Empty { } +// unit-test: UninhabitedEnumBranching +enum Empty {} // test matching an enum with uninhabited variants enum Test1 { A(Empty), B(Empty), - C + C, } // test an enum where the discriminants don't match the variant indexes @@ -15,17 +15,75 @@ enum Test2 { E = 5, } -// EMIT_MIR uninhabited_enum_branching.main.UninhabitedEnumBranching.diff -// EMIT_MIR uninhabited_enum_branching.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir -fn main() { +// test matching an enum with uninhabited variants and multiple inhabited +enum Test3 { + A(Empty), + B(Empty), + C, + D, +} + +struct Plop { + xx: u32, + test3: Test3, +} + +// EMIT_MIR uninhabited_enum_branching.simple.UninhabitedEnumBranching.diff +fn simple() { + // CHECK-LABEL: fn simple( + // CHECK: [[discr:_.*]] = discriminant( + // CHECK: switchInt(move [[discr]]) -> [0: [[unreachable:bb.*]], 1: [[unreachable]], 2: bb1, otherwise: [[unreachable]]]; + // CHECK: [[unreachable]]: { + // CHECK-NEXT: unreachable; match Test1::C { Test1::A(_) => "A(Empty)", Test1::B(_) => "B(Empty)", Test1::C => "C", }; +} +// EMIT_MIR uninhabited_enum_branching.custom_discriminant.UninhabitedEnumBranching.diff +fn custom_discriminant() { + // CHECK-LABEL: fn custom_discriminant( + // CHECK: [[discr:_.*]] = discriminant( + // CHECK: switchInt(move [[discr]]) -> [4: bb3, 5: bb1, otherwise: bb5]; + // CHECK: bb5: { + // CHECK-NEXT: unreachable; match Test2::D { Test2::D => "D", Test2::E => "E", }; } + +// EMIT_MIR uninhabited_enum_branching.byref.UninhabitedEnumBranching.diff +fn byref() { + // CHECK-LABEL: 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]]]; + match &plop.test3 { + Test3::A(_) => "A(Empty)", + Test3::B(_) => "B(Empty)", + Test3::C => "C", + Test3::D => "D", + }; + + // CHECK: [[discr:_.*]] = discriminant( + // CHECK: switchInt(move [[discr]]) -> [0: [[unreachable]], 1: [[unreachable]], 2: bb10, 3: bb7, otherwise: [[unreachable]]]; + match plop.test3 { + Test3::A(_) => "A(Empty)", + Test3::B(_) => "B(Empty)", + Test3::C => "C", + Test3::D => "D", + }; + + // CHECK: [[unreachable]]: { + // CHECK-NEXT: unreachable; +} + +fn main() { + simple(); + custom_discriminant(); + byref(); +} diff --git a/tests/mir-opt/uninhabited_enum_branching.main.UninhabitedEnumBranching.diff b/tests/mir-opt/uninhabited_enum_branching.simple.UninhabitedEnumBranching.diff index 9db95abec34..410db79802e 100644 --- a/tests/mir-opt/uninhabited_enum_branching.main.UninhabitedEnumBranching.diff +++ b/tests/mir-opt/uninhabited_enum_branching.simple.UninhabitedEnumBranching.diff @@ -1,17 +1,13 @@ -- // MIR for `main` before UninhabitedEnumBranching -+ // MIR for `main` after UninhabitedEnumBranching +- // MIR for `simple` before UninhabitedEnumBranching ++ // MIR for `simple` after UninhabitedEnumBranching - fn main() -> () { + fn simple() -> () { let mut _0: (); let _1: &str; let mut _2: Test1; let mut _3: isize; let _4: &str; let _5: &str; - let _6: &str; - let mut _7: Test2; - let mut _8: isize; - let _9: &str; bb0: { StorageLive(_1); @@ -19,7 +15,7 @@ _2 = Test1::C; _3 = discriminant(_2); - switchInt(move _3) -> [0: bb3, 1: bb4, 2: bb1, otherwise: bb2]; -+ switchInt(move _3) -> [2: bb1, otherwise: bb2]; ++ switchInt(move _3) -> [0: bb6, 1: bb6, 2: bb1, otherwise: bb6]; } bb1: { @@ -50,31 +46,12 @@ bb5: { StorageDead(_2); StorageDead(_1); - StorageLive(_6); - StorageLive(_7); - _7 = Test2::D; - _8 = discriminant(_7); - switchInt(move _8) -> [4: bb7, 5: bb6, otherwise: bb2]; - } - - bb6: { - StorageLive(_9); - _9 = const "E"; - _6 = &(*_9); - StorageDead(_9); - goto -> bb8; - } - - bb7: { - _6 = const "D"; - goto -> bb8; - } - - bb8: { - StorageDead(_7); - StorageDead(_6); _0 = const (); return; ++ } ++ ++ bb6: { ++ unreachable; } } diff --git a/tests/mir-opt/uninhabited_enum_branching2.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir b/tests/mir-opt/uninhabited_enum_branching2.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir deleted file mode 100644 index 9c0c5d18917..00000000000 --- a/tests/mir-opt/uninhabited_enum_branching2.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir +++ /dev/null @@ -1,85 +0,0 @@ -// MIR for `main` after SimplifyCfg-after-uninhabited-enum-branching - -fn main() -> () { - let mut _0: (); - let _1: Plop; - let mut _2: Test1; - let _3: &str; - let mut _4: &Test1; - let mut _5: isize; - let _6: &str; - let _7: &str; - let _8: &str; - let _9: &str; - let mut _10: isize; - let _11: &str; - let _12: &str; - let _13: &str; - scope 1 { - debug plop => _1; - } - - bb0: { - StorageLive(_1); - StorageLive(_2); - _2 = Test1::C; - _1 = Plop { xx: const 51_u32, test1: move _2 }; - StorageDead(_2); - StorageLive(_3); - StorageLive(_4); - _4 = &(_1.1: Test1); - _5 = discriminant((*_4)); - switchInt(move _5) -> [2: bb3, 3: bb1, otherwise: bb2]; - } - - bb1: { - StorageLive(_8); - _8 = const "D"; - _3 = &(*_8); - StorageDead(_8); - goto -> bb4; - } - - bb2: { - unreachable; - } - - bb3: { - StorageLive(_7); - _7 = const "C"; - _3 = &(*_7); - StorageDead(_7); - goto -> bb4; - } - - bb4: { - StorageDead(_4); - StorageDead(_3); - StorageLive(_9); - _10 = discriminant((_1.1: Test1)); - switchInt(move _10) -> [2: bb6, 3: bb5, otherwise: bb2]; - } - - bb5: { - StorageLive(_13); - _13 = const "D"; - _9 = &(*_13); - StorageDead(_13); - goto -> bb7; - } - - bb6: { - StorageLive(_12); - _12 = const "C"; - _9 = &(*_12); - StorageDead(_12); - goto -> bb7; - } - - bb7: { - StorageDead(_9); - _0 = const (); - StorageDead(_1); - return; - } -} diff --git a/tests/mir-opt/uninhabited_enum_branching2.rs b/tests/mir-opt/uninhabited_enum_branching2.rs deleted file mode 100644 index 751f2ae01f8..00000000000 --- a/tests/mir-opt/uninhabited_enum_branching2.rs +++ /dev/null @@ -1,35 +0,0 @@ -// skip-filecheck -enum Empty { } - -// test matching an enum with uninhabited variants -enum Test1 { - A(Empty), - B(Empty), - C, - D, -} - -struct Plop { - xx: u32, - test1: Test1, -} - -// EMIT_MIR uninhabited_enum_branching2.main.UninhabitedEnumBranching.diff -// EMIT_MIR uninhabited_enum_branching2.main.SimplifyCfg-after-uninhabited-enum-branching.after.mir -fn main() { - let plop = Plop { xx: 51, test1: Test1::C }; - - match &plop.test1 { - Test1::A(_) => "A(Empty)", - Test1::B(_) => "B(Empty)", - Test1::C => "C", - Test1::D => "D", - }; - - match plop.test1 { - Test1::A(_) => "A(Empty)", - Test1::B(_) => "B(Empty)", - Test1::C => "C", - Test1::D => "D", - }; -} diff --git a/tests/mir-opt/uninhabited_fallthrough_elimination.keep_fallthrough.UninhabitedEnumBranching.diff b/tests/mir-opt/uninhabited_fallthrough_elimination.keep_fallthrough.UninhabitedEnumBranching.diff index 498e1e20f8a..79948139f88 100644 --- a/tests/mir-opt/uninhabited_fallthrough_elimination.keep_fallthrough.UninhabitedEnumBranching.diff +++ b/tests/mir-opt/uninhabited_fallthrough_elimination.keep_fallthrough.UninhabitedEnumBranching.diff @@ -9,7 +9,7 @@ bb0: { _2 = discriminant(_1); - switchInt(move _2) -> [0: bb2, 1: bb3, otherwise: bb1]; -+ switchInt(move _2) -> [1: bb3, otherwise: bb1]; ++ switchInt(move _2) -> [0: bb5, 1: bb3, otherwise: bb1]; } bb1: { @@ -29,6 +29,10 @@ bb4: { return; ++ } ++ ++ bb5: { ++ unreachable; } } diff --git a/tests/mir-opt/unreachable.as_match.UnreachablePropagation.panic-abort.diff b/tests/mir-opt/unreachable.as_match.UnreachablePropagation.panic-abort.diff new file mode 100644 index 00000000000..f6e594ffac7 --- /dev/null +++ b/tests/mir-opt/unreachable.as_match.UnreachablePropagation.panic-abort.diff @@ -0,0 +1,45 @@ +- // MIR for `as_match` before UnreachablePropagation ++ // MIR for `as_match` after UnreachablePropagation + + fn as_match() -> () { + let mut _0: (); + let mut _1: std::option::Option<Empty>; + let mut _2: isize; + let _3: Empty; + let mut _4: !; ++ let mut _5: bool; + scope 1 { + debug _x => _3; + } + + bb0: { + StorageLive(_1); + _1 = empty() -> [return: bb1, unwind unreachable]; + } + + bb1: { + _2 = discriminant(_1); +- switchInt(move _2) -> [0: bb4, 1: bb2, otherwise: bb3]; ++ _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: { + unreachable; + } + + bb4: { + _0 = const (); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/unreachable.as_match.UnreachablePropagation.panic-unwind.diff b/tests/mir-opt/unreachable.as_match.UnreachablePropagation.panic-unwind.diff new file mode 100644 index 00000000000..2813d64672e --- /dev/null +++ b/tests/mir-opt/unreachable.as_match.UnreachablePropagation.panic-unwind.diff @@ -0,0 +1,45 @@ +- // MIR for `as_match` before UnreachablePropagation ++ // MIR for `as_match` after UnreachablePropagation + + fn as_match() -> () { + let mut _0: (); + let mut _1: std::option::Option<Empty>; + let mut _2: isize; + let _3: Empty; + let mut _4: !; ++ let mut _5: bool; + scope 1 { + debug _x => _3; + } + + bb0: { + StorageLive(_1); + _1 = empty() -> [return: bb1, unwind continue]; + } + + bb1: { + _2 = discriminant(_1); +- switchInt(move _2) -> [0: bb4, 1: bb2, otherwise: bb3]; ++ _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: { + unreachable; + } + + bb4: { + _0 = const (); + StorageDead(_1); + return; + } + } + diff --git a/tests/mir-opt/unreachable.main.UnreachablePropagation.panic-abort.diff b/tests/mir-opt/unreachable.if_let.UnreachablePropagation.panic-abort.diff index eb5a0c39b0b..61959732720 100644 --- a/tests/mir-opt/unreachable.main.UnreachablePropagation.panic-abort.diff +++ b/tests/mir-opt/unreachable.if_let.UnreachablePropagation.panic-abort.diff @@ -1,13 +1,14 @@ -- // MIR for `main` before UnreachablePropagation -+ // MIR for `main` after UnreachablePropagation +- // MIR for `if_let` before UnreachablePropagation ++ // MIR for `if_let` after UnreachablePropagation - fn main() -> () { + fn if_let() -> () { let mut _0: (); let mut _1: std::option::Option<Empty>; let mut _2: isize; let _5: (); let mut _6: bool; let mut _7: !; ++ let mut _8: bool; scope 1 { debug _x => _3; let _3: Empty; @@ -25,7 +26,9 @@ bb1: { _2 = discriminant(_1); - switchInt(move _2) -> [1: bb2, otherwise: bb6]; -+ switchInt(move _2) -> [1: bb2, otherwise: bb3]; ++ _8 = Ne(_2, const 1_isize); ++ assume(move _8); ++ goto -> bb6; } bb2: { @@ -36,29 +39,31 @@ - StorageLive(_6); - _6 = const true; - switchInt(move _6) -> [0: bb4, otherwise: bb3]; -- } -- -- bb3: { ++ unreachable; + } + + bb3: { - _4 = const 21_i32; - _5 = const (); - goto -> bb5; -- } -- -- bb4: { ++ unreachable; + } + + bb4: { - _4 = const 42_i32; - _5 = const (); - goto -> bb5; -- } -- -- bb5: { ++ unreachable; + } + + bb5: { - StorageDead(_6); - StorageDead(_5); - StorageLive(_7); unreachable; } -- bb6: { -+ bb3: { + bb6: { _0 = const (); StorageDead(_1); return; diff --git a/tests/mir-opt/unreachable.main.UnreachablePropagation.panic-unwind.diff b/tests/mir-opt/unreachable.if_let.UnreachablePropagation.panic-unwind.diff index 906dce9819f..476e2f55994 100644 --- a/tests/mir-opt/unreachable.main.UnreachablePropagation.panic-unwind.diff +++ b/tests/mir-opt/unreachable.if_let.UnreachablePropagation.panic-unwind.diff @@ -1,13 +1,14 @@ -- // MIR for `main` before UnreachablePropagation -+ // MIR for `main` after UnreachablePropagation +- // MIR for `if_let` before UnreachablePropagation ++ // MIR for `if_let` after UnreachablePropagation - fn main() -> () { + fn if_let() -> () { let mut _0: (); let mut _1: std::option::Option<Empty>; let mut _2: isize; let _5: (); let mut _6: bool; let mut _7: !; ++ let mut _8: bool; scope 1 { debug _x => _3; let _3: Empty; @@ -25,7 +26,9 @@ bb1: { _2 = discriminant(_1); - switchInt(move _2) -> [1: bb2, otherwise: bb6]; -+ switchInt(move _2) -> [1: bb2, otherwise: bb3]; ++ _8 = Ne(_2, const 1_isize); ++ assume(move _8); ++ goto -> bb6; } bb2: { @@ -36,29 +39,31 @@ - StorageLive(_6); - _6 = const true; - switchInt(move _6) -> [0: bb4, otherwise: bb3]; -- } -- -- bb3: { ++ unreachable; + } + + bb3: { - _4 = const 21_i32; - _5 = const (); - goto -> bb5; -- } -- -- bb4: { ++ unreachable; + } + + bb4: { - _4 = const 42_i32; - _5 = const (); - goto -> bb5; -- } -- -- bb5: { ++ unreachable; + } + + bb5: { - StorageDead(_6); - StorageDead(_5); - StorageLive(_7); unreachable; } -- bb6: { -+ bb3: { + bb6: { _0 = const (); StorageDead(_1); return; diff --git a/tests/mir-opt/unreachable.rs b/tests/mir-opt/unreachable.rs index 5c0df09b752..5b96681d9df 100644 --- a/tests/mir-opt/unreachable.rs +++ b/tests/mir-opt/unreachable.rs @@ -1,13 +1,31 @@ -// skip-filecheck +// unit-test: UnreachablePropagation // EMIT_MIR_FOR_EACH_PANIC_STRATEGY + enum Empty {} fn empty() -> Option<Empty> { None } -// EMIT_MIR unreachable.main.UnreachablePropagation.diff -fn main() { +// EMIT_MIR unreachable.if_let.UnreachablePropagation.diff +fn if_let() { + // CHECK-LABEL: fn if_let( + // CHECK: bb0: { + // CHECK: {{_.*}} = empty() + // CHECK: bb1: { + // CHECK: [[ne:_.*]] = Ne({{.*}}, const 1_isize); + // CHECK-NEXT: assume(move [[ne]]); + // CHECK-NEXT: goto -> bb6; + // CHECK: bb2: { + // CHECK-NEXT: unreachable; + // CHECK: bb3: { + // CHECK-NEXT: unreachable; + // CHECK: bb4: { + // CHECK-NEXT: unreachable; + // CHECK: bb5: { + // CHECK-NEXT: unreachable; + // CHECK: bb6: { + // CHECK: return; if let Some(_x) = empty() { let mut _y; @@ -20,3 +38,29 @@ fn main() { match _x { } } } + +// EMIT_MIR unreachable.as_match.UnreachablePropagation.diff +fn as_match() { + // CHECK-LABEL: fn as_match( + // CHECK: bb0: { + // CHECK: {{_.*}} = empty() + // CHECK: bb1: { + // CHECK: [[eq:_.*]] = Eq({{.*}}, const 0_isize); + // CHECK-NEXT: assume(move [[eq]]); + // CHECK-NEXT: goto -> bb4; + // CHECK: bb2: { + // CHECK-NEXT: unreachable; + // CHECK: bb3: { + // CHECK-NEXT: unreachable; + // CHECK: bb4: { + // CHECK: return; + match empty() { + None => {} + Some(_x) => match _x {} + } +} + +fn main() { + if_let(); + as_match(); +} diff --git a/tests/mir-opt/unreachable_diverging.main.UnreachablePropagation.panic-abort.diff b/tests/mir-opt/unreachable_diverging.main.UnreachablePropagation.panic-abort.diff index 713757ce6e0..11d7924e736 100644 --- a/tests/mir-opt/unreachable_diverging.main.UnreachablePropagation.panic-abort.diff +++ b/tests/mir-opt/unreachable_diverging.main.UnreachablePropagation.panic-abort.diff @@ -9,6 +9,7 @@ let _5: (); let mut _6: bool; let mut _7: !; ++ let mut _8: bool; scope 1 { debug x => _1; scope 2 { @@ -35,7 +36,10 @@ StorageLive(_5); StorageLive(_6); _6 = _1; - switchInt(move _6) -> [0: bb4, otherwise: bb3]; +- switchInt(move _6) -> [0: bb4, otherwise: bb3]; ++ _8 = Ne(_6, const false); ++ assume(move _8); ++ goto -> bb3; } bb3: { diff --git a/tests/mir-opt/unreachable_diverging.main.UnreachablePropagation.panic-unwind.diff b/tests/mir-opt/unreachable_diverging.main.UnreachablePropagation.panic-unwind.diff index a0479fb9130..df6f5609fbf 100644 --- a/tests/mir-opt/unreachable_diverging.main.UnreachablePropagation.panic-unwind.diff +++ b/tests/mir-opt/unreachable_diverging.main.UnreachablePropagation.panic-unwind.diff @@ -9,6 +9,7 @@ let _5: (); let mut _6: bool; let mut _7: !; ++ let mut _8: bool; scope 1 { debug x => _1; scope 2 { @@ -35,7 +36,10 @@ StorageLive(_5); StorageLive(_6); _6 = _1; - switchInt(move _6) -> [0: bb4, otherwise: bb3]; +- switchInt(move _6) -> [0: bb4, otherwise: bb3]; ++ _8 = Ne(_6, const false); ++ assume(move _8); ++ goto -> bb3; } bb3: { diff --git a/tests/mir-opt/unreachable_diverging.rs b/tests/mir-opt/unreachable_diverging.rs index 3713bcaea16..b1df6f85262 100644 --- a/tests/mir-opt/unreachable_diverging.rs +++ b/tests/mir-opt/unreachable_diverging.rs @@ -1,5 +1,6 @@ -// skip-filecheck +// unit-test: UnreachablePropagation // EMIT_MIR_FOR_EACH_PANIC_STRATEGY + pub enum Empty {} fn empty() -> Option<Empty> { @@ -12,6 +13,23 @@ fn loop_forever() { // EMIT_MIR unreachable_diverging.main.UnreachablePropagation.diff fn main() { + // CHECK-LABEL: fn main( + // CHECK: bb0: { + // CHECK: {{_.*}} = empty() + // CHECK: bb1: { + // CHECK: switchInt({{.*}}) -> [1: bb2, otherwise: bb6]; + // CHECK: bb2: { + // CHECK: [[ne:_.*]] = Ne({{.*}}, const false); + // CHECK: assume(move [[ne]]); + // CHECK: goto -> bb3; + // CHECK: bb3: { + // CHECK: {{_.*}} = loop_forever() + // CHECK: bb4: { + // CHECK: unreachable; + // CHECK: bb5: { + // CHECK: unreachable; + // CHECK: bb6: { + // CHECK: return; let x = true; if let Some(bomb) = empty() { if x { diff --git a/tests/pretty/hir-fn-variadic.pp b/tests/pretty/hir-fn-variadic.pp new file mode 100644 index 00000000000..577d9400ad4 --- /dev/null +++ b/tests/pretty/hir-fn-variadic.pp @@ -0,0 +1,15 @@ +// pretty-compare-only +// pretty-mode:hir +// pp-exact:hir-fn-variadic.pp + +#![feature(c_variadic)] +#[prelude_import] +use ::std::prelude::rust_2015::*; +#[macro_use] +extern crate std; + +extern "C" { + fn foo(x: i32, va1: ...); +} + +unsafe extern "C" fn bar(_: i32, mut va2: ...) -> usize { va2.arg::<usize>() } diff --git a/tests/pretty/hir-fn-variadic.rs b/tests/pretty/hir-fn-variadic.rs new file mode 100644 index 00000000000..efb2754df62 --- /dev/null +++ b/tests/pretty/hir-fn-variadic.rs @@ -0,0 +1,13 @@ +// pretty-compare-only +// pretty-mode:hir +// pp-exact:hir-fn-variadic.pp + +#![feature(c_variadic)] + +extern "C" { + pub fn foo(x: i32, va1: ...); +} + +pub unsafe extern "C" fn bar(_: i32, mut va2: ...) -> usize { + va2.arg::<usize>() +} diff --git a/tests/run-coverage/bad_counter_ids.coverage b/tests/run-coverage/bad_counter_ids.coverage new file mode 100644 index 00000000000..d69ebf160ea --- /dev/null +++ b/tests/run-coverage/bad_counter_ids.coverage @@ -0,0 +1,69 @@ + LL| |#![feature(coverage_attribute)] + LL| |// compile-flags: --edition=2021 -Copt-level=0 -Zmir-opt-level=3 + LL| | + LL| |// Regression test for <https://github.com/rust-lang/rust/issues/117012>. + LL| |// + LL| |// If some coverage counters were removed by MIR optimizations, we need to take + LL| |// care not to refer to those counter IDs in coverage mappings, and instead + LL| |// replace them with a constant zero value. If we don't, `llvm-cov` might see + LL| |// a too-large counter ID and silently discard the entire function from its + LL| |// coverage reports. + LL| | + LL| 8|#[derive(Debug, PartialEq, Eq)] + LL| |struct Foo(u32); + LL| | + LL| 1|fn eq_good() { + LL| 1| println!("a"); + LL| 1| assert_eq!(Foo(1), Foo(1)); + LL| 1|} + LL| | + LL| 1|fn eq_good_message() { + LL| 1| println!("b"); + LL| 1| assert_eq!(Foo(1), Foo(1), "message b"); + ^0 + LL| 1|} + LL| | + LL| 1|fn ne_good() { + LL| 1| println!("c"); + LL| 1| assert_ne!(Foo(1), Foo(3)); + LL| 1|} + LL| | + LL| 1|fn ne_good_message() { + LL| 1| println!("d"); + LL| 1| assert_ne!(Foo(1), Foo(3), "message d"); + ^0 + LL| 1|} + LL| | + LL| 1|fn eq_bad() { + LL| 1| println!("e"); + LL| 1| assert_eq!(Foo(1), Foo(3)); + LL| 0|} + LL| | + LL| 1|fn eq_bad_message() { + LL| 1| println!("f"); + LL| 1| assert_eq!(Foo(1), Foo(3), "message f"); + LL| 0|} + LL| | + LL| 1|fn ne_bad() { + LL| 1| println!("g"); + LL| 1| assert_ne!(Foo(1), Foo(1)); + LL| 0|} + LL| | + LL| 1|fn ne_bad_message() { + LL| 1| println!("h"); + LL| 1| assert_ne!(Foo(1), Foo(1), "message h"); + LL| 0|} + LL| | + LL| |#[coverage(off)] + LL| |fn main() { + LL| | eq_good(); + LL| | eq_good_message(); + LL| | ne_good(); + LL| | ne_good_message(); + LL| | + LL| | assert!(std::panic::catch_unwind(eq_bad).is_err()); + LL| | assert!(std::panic::catch_unwind(eq_bad_message).is_err()); + LL| | assert!(std::panic::catch_unwind(ne_bad).is_err()); + LL| | assert!(std::panic::catch_unwind(ne_bad_message).is_err()); + LL| |} + diff --git a/tests/run-coverage/bad_counter_ids.rs b/tests/run-coverage/bad_counter_ids.rs new file mode 100644 index 00000000000..ef5460102b7 --- /dev/null +++ b/tests/run-coverage/bad_counter_ids.rs @@ -0,0 +1,66 @@ +#![feature(coverage_attribute)] +// compile-flags: --edition=2021 -Copt-level=0 -Zmir-opt-level=3 + +// Regression test for <https://github.com/rust-lang/rust/issues/117012>. +// +// If some coverage counters were removed by MIR optimizations, we need to take +// care not to refer to those counter IDs in coverage mappings, and instead +// replace them with a constant zero value. If we don't, `llvm-cov` might see +// a too-large counter ID and silently discard the entire function from its +// coverage reports. + +#[derive(Debug, PartialEq, Eq)] +struct Foo(u32); + +fn eq_good() { + println!("a"); + assert_eq!(Foo(1), Foo(1)); +} + +fn eq_good_message() { + println!("b"); + assert_eq!(Foo(1), Foo(1), "message b"); +} + +fn ne_good() { + println!("c"); + assert_ne!(Foo(1), Foo(3)); +} + +fn ne_good_message() { + println!("d"); + assert_ne!(Foo(1), Foo(3), "message d"); +} + +fn eq_bad() { + println!("e"); + assert_eq!(Foo(1), Foo(3)); +} + +fn eq_bad_message() { + println!("f"); + assert_eq!(Foo(1), Foo(3), "message f"); +} + +fn ne_bad() { + println!("g"); + assert_ne!(Foo(1), Foo(1)); +} + +fn ne_bad_message() { + println!("h"); + assert_ne!(Foo(1), Foo(1), "message h"); +} + +#[coverage(off)] +fn main() { + eq_good(); + eq_good_message(); + ne_good(); + ne_good_message(); + + assert!(std::panic::catch_unwind(eq_bad).is_err()); + assert!(std::panic::catch_unwind(eq_bad_message).is_err()); + assert!(std::panic::catch_unwind(ne_bad).is_err()); + assert!(std::panic::catch_unwind(ne_bad_message).is_err()); +} diff --git a/tests/rustdoc-gui/src/lib2/lib.rs b/tests/rustdoc-gui/src/lib2/lib.rs index 34e67d9d254..a2a3c31878b 100644 --- a/tests/rustdoc-gui/src/lib2/lib.rs +++ b/tests/rustdoc-gui/src/lib2/lib.rs @@ -147,13 +147,13 @@ pub struct LongItemInfo2; #[doc(cfg(any(target_os = "android", target_os = "linux", target_os = "emscripten", target_os = "dragonfly", target_os = "freebsd", target_os = "netbsd", target_os = "openbsd")))] impl SimpleTrait for LongItemInfo2 {} -pub struct WhereWhitespace<T>; +pub struct WhereWhitespace<T>(T); impl<T> WhereWhitespace<T> { pub fn new<F>(f: F) -> Self where F: FnMut() -> i32, - {} + {todo!()} } impl<K, T> Whitespace<&K> for WhereWhitespace<T> @@ -187,6 +187,11 @@ impl ItemInfoAlignmentTest { pub mod scroll_traits { use std::iter::*; + struct Intersperse<T>(T); + struct IntersperseWith<T, U>(T, U); + struct Flatten<T>(T); + struct Peekable<T>(T); + /// Shamelessly (partially) copied from `std::iter::Iterator`. /// It allows us to check that the scroll is working as expected on "hidden" items. pub trait Iterator { diff --git a/tests/rustdoc-json/enums/field_hidden.rs b/tests/rustdoc-json/enums/field_hidden.rs index 5c0d0ffd3df..f2409858057 100644 --- a/tests/rustdoc-json/enums/field_hidden.rs +++ b/tests/rustdoc-json/enums/field_hidden.rs @@ -1,7 +1,10 @@ // Regression test for <https://github.com/rust-lang/rust/issues/100529>. #![no_core] -#![feature(no_core)] +#![feature(no_core, lang_items)] + +#[lang = "sized"] +trait Sized {} // @has "$.index[*][?(@.name=='ParseError')]" // @has "$.index[*][?(@.name=='UnexpectedEndTag')]" diff --git a/tests/rustdoc-json/enums/kind.rs b/tests/rustdoc-json/enums/kind.rs index e283c074006..777161c4e4b 100644 --- a/tests/rustdoc-json/enums/kind.rs +++ b/tests/rustdoc-json/enums/kind.rs @@ -1,8 +1,11 @@ // ignore-tidy-linelength -#![feature(no_core)] +#![feature(no_core, lang_items)] #![no_core] +#[lang = "sized"] +trait Sized {} + pub enum Foo { // @set Unit = "$.index[*][?(@.name=='Unit')].id" // @is "$.index[*][?(@.name=='Unit')].inner.variant.kind" '"plain"' diff --git a/tests/rustdoc-json/enums/tuple_fields_hidden.rs b/tests/rustdoc-json/enums/tuple_fields_hidden.rs index 3aeb0356420..34a4f4aec53 100644 --- a/tests/rustdoc-json/enums/tuple_fields_hidden.rs +++ b/tests/rustdoc-json/enums/tuple_fields_hidden.rs @@ -1,6 +1,9 @@ -#![feature(no_core)] +#![feature(no_core, lang_items)] #![no_core] +#[lang = "sized"] +trait Sized {} + // @set 1.1.0 = "$.index[*][?(@.docs=='1.1.0')].id" // @set 2.1.0 = "$.index[*][?(@.docs=='2.1.0')].id" // @set 2.1.1 = "$.index[*][?(@.docs=='2.1.1')].id" diff --git a/tests/rustdoc-json/generic-associated-types/gats.rs b/tests/rustdoc-json/generic-associated-types/gats.rs index 99c57ff6540..9cfe649243f 100644 --- a/tests/rustdoc-json/generic-associated-types/gats.rs +++ b/tests/rustdoc-json/generic-associated-types/gats.rs @@ -1,11 +1,14 @@ // ignore-tidy-linelength #![no_core] -#![feature(lang_items, no_core)] +#![feature(lang_items, no_core, arbitrary_self_types)] #[lang = "sized"] pub trait Sized {} +#[lang = "receiver"] +pub trait Receiver {} + pub trait Display {} pub trait LendingIterator { diff --git a/tests/rustdoc-json/impls/auto.rs b/tests/rustdoc-json/impls/auto.rs index ace37e5b3df..96c3ab08b99 100644 --- a/tests/rustdoc-json/impls/auto.rs +++ b/tests/rustdoc-json/impls/auto.rs @@ -1,9 +1,12 @@ -#![feature(no_core, auto_traits, lang_items)] +#![feature(no_core, auto_traits, lang_items, arbitrary_self_types)] #![no_core] #[lang = "sized"] trait Sized {} +#[lang = "receiver"] +pub trait Receiver {} + pub auto trait Bar {} /// has span @@ -12,8 +15,8 @@ impl Foo { } // Testing spans, so all tests below code -// @is "$.index[*][?(@.docs=='has span')].span.begin" "[10, 0]" -// @is "$.index[*][?(@.docs=='has span')].span.end" "[12, 1]" +// @is "$.index[*][?(@.docs=='has span')].span.begin" "[13, 0]" +// @is "$.index[*][?(@.docs=='has span')].span.end" "[15, 1]" // FIXME: this doesn't work due to https://github.com/freestrings/jsonpath/issues/91 // is "$.index[*][?(@.inner.impl.synthetic==true)].span" null pub struct Foo; diff --git a/tests/rustdoc-json/type/inherent_associated_type_bound.rs b/tests/rustdoc-json/type/inherent_associated_type_bound.rs index 8e39f471824..6da23c8fb4e 100644 --- a/tests/rustdoc-json/type/inherent_associated_type_bound.rs +++ b/tests/rustdoc-json/type/inherent_associated_type_bound.rs @@ -16,5 +16,5 @@ pub struct Carrier<'a>(&'a ()); pub fn user(_: for<'b> fn(Carrier<'b>::Focus<i32>)) {} impl<'a> Carrier<'a> { - pub type Focus<T> = &'a mut T; + pub type Focus<T> = &'a mut T where T: 'a; } diff --git a/tests/rustdoc-ui/error-in-impl-trait/infinite-recursive-type-2.rs b/tests/rustdoc-ui/error-in-impl-trait/infinite-recursive-type-2.rs index e49fe079813..7151ebd599f 100644 --- a/tests/rustdoc-ui/error-in-impl-trait/infinite-recursive-type-2.rs +++ b/tests/rustdoc-ui/error-in-impl-trait/infinite-recursive-type-2.rs @@ -1,7 +1,6 @@ -// check-pass - pub fn f() -> impl Sized { pub enum E { + //~^ ERROR: recursive type V(E), } diff --git a/tests/rustdoc-ui/error-in-impl-trait/infinite-recursive-type-2.stderr b/tests/rustdoc-ui/error-in-impl-trait/infinite-recursive-type-2.stderr new file mode 100644 index 00000000000..edb5dfd4d55 --- /dev/null +++ b/tests/rustdoc-ui/error-in-impl-trait/infinite-recursive-type-2.stderr @@ -0,0 +1,17 @@ +error[E0072]: recursive type `f::E` has infinite size + --> $DIR/infinite-recursive-type-2.rs:2:5 + | +LL | pub enum E { + | ^^^^^^^^^^ +LL | +LL | V(E), + | - recursive without indirection + | +help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle + | +LL | V(Box<E>), + | ++++ + + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0072`. diff --git a/tests/rustdoc-ui/error-in-impl-trait/infinite-recursive-type.rs b/tests/rustdoc-ui/error-in-impl-trait/infinite-recursive-type.rs index 096130d7768..1f855051729 100644 --- a/tests/rustdoc-ui/error-in-impl-trait/infinite-recursive-type.rs +++ b/tests/rustdoc-ui/error-in-impl-trait/infinite-recursive-type.rs @@ -1,7 +1,6 @@ -// check-pass - fn f() -> impl Sized { enum E { + //~^ ERROR: recursive type V(E), } diff --git a/tests/rustdoc-ui/error-in-impl-trait/infinite-recursive-type.stderr b/tests/rustdoc-ui/error-in-impl-trait/infinite-recursive-type.stderr new file mode 100644 index 00000000000..349a569414c --- /dev/null +++ b/tests/rustdoc-ui/error-in-impl-trait/infinite-recursive-type.stderr @@ -0,0 +1,17 @@ +error[E0072]: recursive type `f::E` has infinite size + --> $DIR/infinite-recursive-type.rs:2:5 + | +LL | enum E { + | ^^^^^^ +LL | +LL | V(E), + | - recursive without indirection + | +help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle + | +LL | V(Box<E>), + | ++++ + + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0072`. diff --git a/tests/rustdoc-ui/invalid_const_in_lifetime_position.rs b/tests/rustdoc-ui/invalid_const_in_lifetime_position.rs index c3f4fd63bac..07fc239a8f8 100644 --- a/tests/rustdoc-ui/invalid_const_in_lifetime_position.rs +++ b/tests/rustdoc-ui/invalid_const_in_lifetime_position.rs @@ -4,3 +4,8 @@ trait X { fn f<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {} //~^ ERROR associated type takes 1 lifetime argument but 0 lifetime arguments //~| ERROR associated type takes 0 generic arguments but 1 generic argument +//~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments +//~| ERROR associated type takes 0 generic arguments but 1 generic argument +//~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments +//~| ERROR associated type takes 0 generic arguments but 1 generic argument +//~| ERROR trait `X` cannot be made into an object diff --git a/tests/rustdoc-ui/invalid_const_in_lifetime_position.stderr b/tests/rustdoc-ui/invalid_const_in_lifetime_position.stderr index 527729a8228..50d55284754 100644 --- a/tests/rustdoc-ui/invalid_const_in_lifetime_position.stderr +++ b/tests/rustdoc-ui/invalid_const_in_lifetime_position.stderr @@ -28,6 +28,86 @@ note: associated type defined here, with 0 generic parameters LL | type Y<'a>; | ^ -error: aborting due to 2 previous errors +error[E0107]: associated type takes 1 lifetime argument but 0 lifetime arguments were supplied + --> $DIR/invalid_const_in_lifetime_position.rs:4:26 + | +LL | fn f<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {} + | ^ expected 1 lifetime argument + | +note: associated type defined here, with 1 lifetime parameter: `'a` + --> $DIR/invalid_const_in_lifetime_position.rs:2:10 + | +LL | type Y<'a>; + | ^ -- + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: add missing lifetime argument + | +LL | fn f<'a>(arg : Box<dyn X<Y<'_, 1> = &'a ()>>) {} + | +++ + +error[E0107]: associated type takes 0 generic arguments but 1 generic argument was supplied + --> $DIR/invalid_const_in_lifetime_position.rs:4:26 + | +LL | fn f<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {} + | ^--- help: remove these generics + | | + | expected 0 generic arguments + | +note: associated type defined here, with 0 generic parameters + --> $DIR/invalid_const_in_lifetime_position.rs:2:10 + | +LL | type Y<'a>; + | ^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0107]: associated type takes 1 lifetime argument but 0 lifetime arguments were supplied + --> $DIR/invalid_const_in_lifetime_position.rs:4:26 + | +LL | fn f<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {} + | ^ expected 1 lifetime argument + | +note: associated type defined here, with 1 lifetime parameter: `'a` + --> $DIR/invalid_const_in_lifetime_position.rs:2:10 + | +LL | type Y<'a>; + | ^ -- + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: add missing lifetime argument + | +LL | fn f<'a>(arg : Box<dyn X<Y<'_, 1> = &'a ()>>) {} + | +++ + +error[E0107]: associated type takes 0 generic arguments but 1 generic argument was supplied + --> $DIR/invalid_const_in_lifetime_position.rs:4:26 + | +LL | fn f<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {} + | ^--- help: remove these generics + | | + | expected 0 generic arguments + | +note: associated type defined here, with 0 generic parameters + --> $DIR/invalid_const_in_lifetime_position.rs:2:10 + | +LL | type Y<'a>; + | ^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0038]: the trait `X` cannot be made into an object + --> $DIR/invalid_const_in_lifetime_position.rs:4:20 + | +LL | fn f<'a>(arg : Box<dyn X<Y<1> = &'a ()>>) {} + | ^^^^^^^^^^^^^^^^^^^^ `X` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> + --> $DIR/invalid_const_in_lifetime_position.rs:2:10 + | +LL | trait X { + | - this trait cannot be made into an object... +LL | type Y<'a>; + | ^ ...because it contains the generic associated type `Y` + = help: consider moving `Y` to another trait + +error: aborting due to 7 previous errors -For more information about this error, try `rustc --explain E0107`. +Some errors have detailed explanations: E0038, E0107. +For more information about an error, try `rustc --explain E0038`. diff --git a/tests/rustdoc-ui/issues/issue-105742.rs b/tests/rustdoc-ui/issues/issue-105742.rs index 1fbb70c7808..5e493515cad 100644 --- a/tests/rustdoc-ui/issues/issue-105742.rs +++ b/tests/rustdoc-ui/issues/issue-105742.rs @@ -21,6 +21,8 @@ pub trait SVec: Index< //~| missing generics for associated type `SVec::Item` //~| missing generics for associated type `SVec::Item` //~| missing generics for associated type `SVec::Item` + //~| missing generics for associated type `SVec::Item` + //~| missing generics for associated type `SVec::Item` Output = <Index<<Self as SVec>::Item, //~^ expected 1 lifetime argument //~| expected 1 generic argument @@ -30,6 +32,8 @@ pub trait SVec: Index< //~| missing generics for associated type `SVec::Item` //~| missing generics for associated type `SVec::Item` //~| missing generics for associated type `SVec::Item` + //~| missing generics for associated type `SVec::Item` + //~| missing generics for associated type `SVec::Item` Output = <Self as SVec>::Item> as SVec>::Item, //~^ expected 1 lifetime argument //~| expected 1 generic argument @@ -47,6 +51,10 @@ pub trait SVec: Index< //~| missing generics for associated type `SVec::Item` //~| missing generics for associated type `SVec::Item` //~| missing generics for associated type `SVec::Item` + //~| missing generics for associated type `SVec::Item` + //~| missing generics for associated type `SVec::Item` + //~| missing generics for associated type `SVec::Item` + //~| missing generics for associated type `SVec::Item` > { type Item<'a, T>; diff --git a/tests/rustdoc-ui/issues/issue-105742.stderr b/tests/rustdoc-ui/issues/issue-105742.stderr index 4d3f9f5bced..ad1020a1f08 100644 --- a/tests/rustdoc-ui/issues/issue-105742.stderr +++ b/tests/rustdoc-ui/issues/issue-105742.stderr @@ -5,7 +5,7 @@ LL | <Self as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/issue-105742.rs:51:10 + --> $DIR/issue-105742.rs:59:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -21,7 +21,7 @@ LL | <Self as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/issue-105742.rs:51:10 + --> $DIR/issue-105742.rs:59:10 | LL | type Item<'a, T>; | ^^^^ - @@ -31,13 +31,13 @@ LL | <Self as SVec>::Item<T>, | +++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:24:37 + --> $DIR/issue-105742.rs:26:37 | LL | Output = <Index<<Self as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/issue-105742.rs:51:10 + --> $DIR/issue-105742.rs:59:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -47,13 +47,13 @@ LL | Output = <Index<<Self as SVec>::Item<'a>, | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:24:37 + --> $DIR/issue-105742.rs:26:37 | LL | Output = <Index<<Self as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/issue-105742.rs:51:10 + --> $DIR/issue-105742.rs:59:10 | LL | type Item<'a, T>; | ^^^^ - @@ -63,13 +63,13 @@ LL | Output = <Index<<Self as SVec>::Item<T>, | +++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:33:30 + --> $DIR/issue-105742.rs:37:30 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/issue-105742.rs:51:10 + --> $DIR/issue-105742.rs:59:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -79,13 +79,13 @@ LL | Output = <Self as SVec>::Item<'a>> as SVec>::Item, | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:33:30 + --> $DIR/issue-105742.rs:37:30 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/issue-105742.rs:51:10 + --> $DIR/issue-105742.rs:59:10 | LL | type Item<'a, T>; | ^^^^ - @@ -95,13 +95,13 @@ LL | Output = <Self as SVec>::Item<T>> as SVec>::Item, | +++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:33:46 + --> $DIR/issue-105742.rs:37:46 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/issue-105742.rs:51:10 + --> $DIR/issue-105742.rs:59:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -111,13 +111,13 @@ LL | Output = <Self as SVec>::Item> as SVec>::Item<'a>, | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:33:46 + --> $DIR/issue-105742.rs:37:46 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/issue-105742.rs:51:10 + --> $DIR/issue-105742.rs:59:10 | LL | type Item<'a, T>; | ^^^^ - @@ -133,7 +133,7 @@ LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) { | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/issue-105742.rs:51:10 + --> $DIR/issue-105742.rs:59:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -149,7 +149,7 @@ LL | pub fn next<'a, T>(s: &'a mut dyn SVec<Item = T, Output = T>) { | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/issue-105742.rs:51:10 + --> $DIR/issue-105742.rs:59:10 | LL | type Item<'a, T>; | ^^^^ - @@ -165,7 +165,7 @@ LL | <Self as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/issue-105742.rs:51:10 + --> $DIR/issue-105742.rs:59:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -182,7 +182,7 @@ LL | <Self as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/issue-105742.rs:51:10 + --> $DIR/issue-105742.rs:59:10 | LL | type Item<'a, T>; | ^^^^ - @@ -193,13 +193,13 @@ LL | <Self as SVec>::Item<T>, | +++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:24:37 + --> $DIR/issue-105742.rs:26:37 | LL | Output = <Index<<Self as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/issue-105742.rs:51:10 + --> $DIR/issue-105742.rs:59:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -210,13 +210,13 @@ LL | Output = <Index<<Self as SVec>::Item<'a>, | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:24:37 + --> $DIR/issue-105742.rs:26:37 | LL | Output = <Index<<Self as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/issue-105742.rs:51:10 + --> $DIR/issue-105742.rs:59:10 | LL | type Item<'a, T>; | ^^^^ - @@ -227,13 +227,13 @@ LL | Output = <Index<<Self as SVec>::Item<T>, | +++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:33:30 + --> $DIR/issue-105742.rs:37:30 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/issue-105742.rs:51:10 + --> $DIR/issue-105742.rs:59:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -244,13 +244,13 @@ LL | Output = <Self as SVec>::Item<'a>> as SVec>::Item, | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:33:30 + --> $DIR/issue-105742.rs:37:30 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/issue-105742.rs:51:10 + --> $DIR/issue-105742.rs:59:10 | LL | type Item<'a, T>; | ^^^^ - @@ -261,13 +261,13 @@ LL | Output = <Self as SVec>::Item<T>> as SVec>::Item, | +++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:33:46 + --> $DIR/issue-105742.rs:37:46 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/issue-105742.rs:51:10 + --> $DIR/issue-105742.rs:59:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -278,13 +278,13 @@ LL | Output = <Self as SVec>::Item> as SVec>::Item<'a>, | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:33:46 + --> $DIR/issue-105742.rs:37:46 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/issue-105742.rs:51:10 + --> $DIR/issue-105742.rs:59:10 | LL | type Item<'a, T>; | ^^^^ - @@ -331,7 +331,7 @@ LL | <Self as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/issue-105742.rs:51:10 + --> $DIR/issue-105742.rs:59:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -348,7 +348,7 @@ LL | <Self as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/issue-105742.rs:51:10 + --> $DIR/issue-105742.rs:59:10 | LL | type Item<'a, T>; | ^^^^ - @@ -359,13 +359,13 @@ LL | <Self as SVec>::Item<T>, | +++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:24:37 + --> $DIR/issue-105742.rs:26:37 | LL | Output = <Index<<Self as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/issue-105742.rs:51:10 + --> $DIR/issue-105742.rs:59:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -376,13 +376,13 @@ LL | Output = <Index<<Self as SVec>::Item<'a>, | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:24:37 + --> $DIR/issue-105742.rs:26:37 | LL | Output = <Index<<Self as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/issue-105742.rs:51:10 + --> $DIR/issue-105742.rs:59:10 | LL | type Item<'a, T>; | ^^^^ - @@ -393,13 +393,13 @@ LL | Output = <Index<<Self as SVec>::Item<T>, | +++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:33:30 + --> $DIR/issue-105742.rs:37:30 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/issue-105742.rs:51:10 + --> $DIR/issue-105742.rs:59:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -410,13 +410,13 @@ LL | Output = <Self as SVec>::Item<'a>> as SVec>::Item, | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:33:30 + --> $DIR/issue-105742.rs:37:30 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/issue-105742.rs:51:10 + --> $DIR/issue-105742.rs:59:10 | LL | type Item<'a, T>; | ^^^^ - @@ -427,13 +427,13 @@ LL | Output = <Self as SVec>::Item<T>> as SVec>::Item, | +++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:33:46 + --> $DIR/issue-105742.rs:37:46 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/issue-105742.rs:51:10 + --> $DIR/issue-105742.rs:59:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -444,13 +444,13 @@ LL | Output = <Self as SVec>::Item> as SVec>::Item<'a>, | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:33:46 + --> $DIR/issue-105742.rs:37:46 | LL | Output = <Self as SVec>::Item> as SVec>::Item, | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/issue-105742.rs:51:10 + --> $DIR/issue-105742.rs:59:10 | LL | type Item<'a, T>; | ^^^^ - @@ -461,13 +461,13 @@ LL | Output = <Self as SVec>::Item> as SVec>::Item<T>, | +++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:53:38 + --> $DIR/issue-105742.rs:61:38 | LL | fn len(&self) -> <Self as SVec>::Item; | ^^^^ expected 1 lifetime argument | note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/issue-105742.rs:51:10 + --> $DIR/issue-105742.rs:59:10 | LL | type Item<'a, T>; | ^^^^ -- @@ -477,13 +477,13 @@ LL | fn len(&self) -> <Self as SVec>::Item<'_>; | ++++ error[E0107]: missing generics for associated type `SVec::Item` - --> $DIR/issue-105742.rs:53:38 + --> $DIR/issue-105742.rs:61:38 | LL | fn len(&self) -> <Self as SVec>::Item; | ^^^^ expected 1 generic argument | note: associated type defined here, with 1 generic parameter: `T` - --> $DIR/issue-105742.rs:51:10 + --> $DIR/issue-105742.rs:59:10 | LL | type Item<'a, T>; | ^^^^ - @@ -492,7 +492,143 @@ help: add missing generic argument LL | fn len(&self) -> <Self as SVec>::Item<T>; | +++ -error: aborting due to 29 previous errors +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:15:21 + | +LL | <Self as SVec>::Item, + | ^^^^ expected 1 lifetime argument + | +note: associated type defined here, with 1 lifetime parameter: `'a` + --> $DIR/issue-105742.rs:59:10 + | +LL | type Item<'a, T>; + | ^^^^ -- + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: add missing lifetime argument + | +LL | <Self as SVec>::Item<'a>, + | ++++ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:15:21 + | +LL | <Self as SVec>::Item, + | ^^^^ expected 1 generic argument + | +note: associated type defined here, with 1 generic parameter: `T` + --> $DIR/issue-105742.rs:59:10 + | +LL | type Item<'a, T>; + | ^^^^ - + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: add missing generic argument + | +LL | <Self as SVec>::Item<T>, + | +++ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:26:37 + | +LL | Output = <Index<<Self as SVec>::Item, + | ^^^^ expected 1 lifetime argument + | +note: associated type defined here, with 1 lifetime parameter: `'a` + --> $DIR/issue-105742.rs:59:10 + | +LL | type Item<'a, T>; + | ^^^^ -- + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: add missing lifetime argument + | +LL | Output = <Index<<Self as SVec>::Item<'a>, + | ++++ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:26:37 + | +LL | Output = <Index<<Self as SVec>::Item, + | ^^^^ expected 1 generic argument + | +note: associated type defined here, with 1 generic parameter: `T` + --> $DIR/issue-105742.rs:59:10 + | +LL | type Item<'a, T>; + | ^^^^ - + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: add missing generic argument + | +LL | Output = <Index<<Self as SVec>::Item<T>, + | +++ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:37:30 + | +LL | Output = <Self as SVec>::Item> as SVec>::Item, + | ^^^^ expected 1 lifetime argument + | +note: associated type defined here, with 1 lifetime parameter: `'a` + --> $DIR/issue-105742.rs:59:10 + | +LL | type Item<'a, T>; + | ^^^^ -- + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: add missing lifetime argument + | +LL | Output = <Self as SVec>::Item<'a>> as SVec>::Item, + | ++++ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:37:30 + | +LL | Output = <Self as SVec>::Item> as SVec>::Item, + | ^^^^ expected 1 generic argument + | +note: associated type defined here, with 1 generic parameter: `T` + --> $DIR/issue-105742.rs:59:10 + | +LL | type Item<'a, T>; + | ^^^^ - + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: add missing generic argument + | +LL | Output = <Self as SVec>::Item<T>> as SVec>::Item, + | +++ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:37:46 + | +LL | Output = <Self as SVec>::Item> as SVec>::Item, + | ^^^^ expected 1 lifetime argument + | +note: associated type defined here, with 1 lifetime parameter: `'a` + --> $DIR/issue-105742.rs:59:10 + | +LL | type Item<'a, T>; + | ^^^^ -- + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: add missing lifetime argument + | +LL | Output = <Self as SVec>::Item> as SVec>::Item<'a>, + | ++++ + +error[E0107]: missing generics for associated type `SVec::Item` + --> $DIR/issue-105742.rs:37:46 + | +LL | Output = <Self as SVec>::Item> as SVec>::Item, + | ^^^^ expected 1 generic argument + | +note: associated type defined here, with 1 generic parameter: `T` + --> $DIR/issue-105742.rs:59:10 + | +LL | type Item<'a, T>; + | ^^^^ - + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: add missing generic argument + | +LL | Output = <Self as SVec>::Item> as SVec>::Item<T>, + | +++ + +error: aborting due to 37 previous errors Some errors have detailed explanations: E0038, E0107. For more information about an error, try `rustc --explain E0038`. diff --git a/tests/rustdoc/not-wf-ambiguous-normalization.rs b/tests/rustdoc-ui/not-wf-ambiguous-normalization.rs index 1e9f925f845..3e4825d83b1 100644 --- a/tests/rustdoc/not-wf-ambiguous-normalization.rs +++ b/tests/rustdoc-ui/not-wf-ambiguous-normalization.rs @@ -12,6 +12,7 @@ struct DefaultAllocator; // `<DefaultAllocator as Allocator>::Buffer` to be ambiguous, // which caused an ICE with `-Znormalize-docs`. impl<T> Allocator for DefaultAllocator { + //~^ ERROR: type annotations needed type Buffer = (); } diff --git a/tests/rustdoc-ui/not-wf-ambiguous-normalization.stderr b/tests/rustdoc-ui/not-wf-ambiguous-normalization.stderr new file mode 100644 index 00000000000..34b20a0b32c --- /dev/null +++ b/tests/rustdoc-ui/not-wf-ambiguous-normalization.stderr @@ -0,0 +1,9 @@ +error[E0282]: type annotations needed + --> $DIR/not-wf-ambiguous-normalization.rs:14:23 + | +LL | impl<T> Allocator for DefaultAllocator { + | ^^^^^^^^^^^^^^^^ cannot infer type for type parameter `T` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/rustdoc-ui/recursive-deref-ice.rs b/tests/rustdoc-ui/recursive-deref-ice.rs index c44fd27f403..9e62841f99b 100644 --- a/tests/rustdoc-ui/recursive-deref-ice.rs +++ b/tests/rustdoc-ui/recursive-deref-ice.rs @@ -4,7 +4,10 @@ pub struct Attribute; -pub struct Map<'hir> {} +pub struct Map<'hir> { + lt: &'hir (), +} + impl<'hir> Map<'hir> { pub fn attrs(&self) -> &'hir [Attribute] { &[] } } diff --git a/tests/rustdoc-ui/unable-fulfill-trait.rs b/tests/rustdoc-ui/unable-fulfill-trait.rs index 70357082248..10887ab1903 100644 --- a/tests/rustdoc-ui/unable-fulfill-trait.rs +++ b/tests/rustdoc-ui/unable-fulfill-trait.rs @@ -3,7 +3,8 @@ pub struct Foo<'a, 'b, T> { field1: dyn Bar<'a, 'b,>, //~^ ERROR - //~^^ ERROR + //~| ERROR + //~| ERROR } pub trait Bar<'x, 's, U> diff --git a/tests/rustdoc-ui/unable-fulfill-trait.stderr b/tests/rustdoc-ui/unable-fulfill-trait.stderr index 72f35cb9224..d7735a4fd11 100644 --- a/tests/rustdoc-ui/unable-fulfill-trait.stderr +++ b/tests/rustdoc-ui/unable-fulfill-trait.stderr @@ -5,7 +5,7 @@ LL | field1: dyn Bar<'a, 'b,>, | ^^^ expected 1 generic argument | note: trait defined here, with 1 generic parameter: `U` - --> $DIR/unable-fulfill-trait.rs:9:11 + --> $DIR/unable-fulfill-trait.rs:10:11 | LL | pub trait Bar<'x, 's, U> | ^^^ - @@ -20,7 +20,24 @@ error[E0227]: ambiguous lifetime bound, explicit lifetime bound required LL | field1: dyn Bar<'a, 'b,>, | ^^^^^^^^^^^^^^^^ -error: aborting due to 2 previous errors +error[E0478]: lifetime bound not satisfied + --> $DIR/unable-fulfill-trait.rs:4:13 + | +LL | field1: dyn Bar<'a, 'b,>, + | ^^^^^^^^^^^^^^^^ + | +note: lifetime parameter instantiated with the lifetime `'b` as defined here + --> $DIR/unable-fulfill-trait.rs:3:20 + | +LL | pub struct Foo<'a, 'b, T> { + | ^^ +note: but lifetime parameter must outlive the lifetime `'a` as defined here + --> $DIR/unable-fulfill-trait.rs:3:16 + | +LL | pub struct Foo<'a, 'b, T> { + | ^^ + +error: aborting due to 3 previous errors -Some errors have detailed explanations: E0107, E0227. +Some errors have detailed explanations: E0107, E0227, E0478. For more information about an error, try `rustc --explain E0107`. diff --git a/tests/rustdoc/const-generics/add-impl.rs b/tests/rustdoc/const-generics/add-impl.rs index 195e47bc8ba..df490d2c636 100644 --- a/tests/rustdoc/const-generics/add-impl.rs +++ b/tests/rustdoc/const-generics/add-impl.rs @@ -7,7 +7,7 @@ pub struct Simd<T, const WIDTH: usize> { inner: T, } -// @has foo/struct.Simd.html '//div[@id="trait-implementations-list"]//h3[@class="code-header"]' 'impl Add<Simd<u8, 16>> for Simd<u8, 16>' +// @has foo/struct.Simd.html '//div[@id="trait-implementations-list"]//h3[@class="code-header"]' 'impl Add for Simd<u8, 16>' impl Add for Simd<u8, 16> { type Output = Self; diff --git a/tests/rustdoc/const-generics/const-impl.rs b/tests/rustdoc/const-generics/const-impl.rs index b424ea4b33c..f4eefcc1c33 100644 --- a/tests/rustdoc/const-generics/const-impl.rs +++ b/tests/rustdoc/const-generics/const-impl.rs @@ -2,7 +2,9 @@ #![feature(adt_const_params)] #![crate_name = "foo"] -#[derive(PartialEq, Eq)] +use std::marker::ConstParamTy; + +#[derive(PartialEq, Eq, ConstParamTy)] pub enum Order { Sorted, Unsorted, diff --git a/tests/rustdoc/decl-trailing-whitespace.declaration.html b/tests/rustdoc/decl-trailing-whitespace.declaration.html index d73393633f3..59c318c16f3 100644 --- a/tests/rustdoc/decl-trailing-whitespace.declaration.html +++ b/tests/rustdoc/decl-trailing-whitespace.declaration.html @@ -1,22 +1,16 @@ <code>pub trait Write { // Required methods fn <a href="#tymethod.poll_write" class="fn">poll_write</a>( - self: <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>, + self, cx: &mut <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>, buf: &mut [<a class="primitive" href="{{channel}}/std/primitive.usize.html">usize</a>] ) -> <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="enum" href="{{channel}}/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="{{channel}}/std/primitive.usize.html">usize</a>, <a class="struct" href="struct.Error.html" title="struct foo::Error">Error</a>>>; -<span class="item-spacer" /> fn <a href="#tymethod.poll_flush" class="fn">poll_flush</a>( - self: <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>, - cx: &mut <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>> - ) -> <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="enum" href="{{channel}}/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="{{channel}}/std/primitive.unit.html">()</a>, <a class="struct" href="struct.Error.html" title="struct foo::Error">Error</a>>>; -<span class="item-spacer" /> fn <a href="#tymethod.poll_close" class="fn">poll_close</a>( - self: <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>, - cx: &mut <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>> - ) -> <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="enum" href="{{channel}}/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="{{channel}}/std/primitive.unit.html">()</a>, <a class="struct" href="struct.Error.html" title="struct foo::Error">Error</a>>>; +<span class="item-spacer" /> fn <a href="#tymethod.poll_flush" class="fn">poll_flush</a>(self, cx: &mut <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>) -> <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="enum" href="{{channel}}/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="{{channel}}/std/primitive.unit.html">()</a>, <a class="struct" href="struct.Error.html" title="struct foo::Error">Error</a>>>; +<span class="item-spacer" /> fn <a href="#tymethod.poll_close" class="fn">poll_close</a>(self, cx: &mut <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>) -> <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="enum" href="{{channel}}/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="{{channel}}/std/primitive.unit.html">()</a>, <a class="struct" href="struct.Error.html" title="struct foo::Error">Error</a>>>; // Provided method fn <a href="#method.poll_write_vectored" class="fn">poll_write_vectored</a>( - self: <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>, + self, cx: &mut <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="{{channel}}/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>, bufs: &[<a class="primitive" href="{{channel}}/std/primitive.usize.html">usize</a>] ) -> <a class="enum" href="{{channel}}/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="enum" href="{{channel}}/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="{{channel}}/std/primitive.usize.html">usize</a>, <a class="struct" href="struct.Error.html" title="struct foo::Error">Error</a>>> { ... } diff --git a/tests/rustdoc/decl-trailing-whitespace.rs b/tests/rustdoc/decl-trailing-whitespace.rs index d2a12435d8f..66783774308 100644 --- a/tests/rustdoc/decl-trailing-whitespace.rs +++ b/tests/rustdoc/decl-trailing-whitespace.rs @@ -9,21 +9,21 @@ pub struct Error; pub trait Write { // @snapshot 'declaration' - '//*[@class="rust item-decl"]//code' fn poll_write( - self: Option<String>, + self, cx: &mut Option<String>, buf: &mut [usize] ) -> Option<Result<usize, Error>>; fn poll_flush( - self: Option<String>, + self, cx: &mut Option<String> ) -> Option<Result<(), Error>>; fn poll_close( - self: Option<String>, + self, cx: &mut Option<String>, ) -> Option<Result<(), Error>>; fn poll_write_vectored( - self: Option<String>, + self, cx: &mut Option<String>, bufs: &[usize] ) -> Option<Result<usize, Error>> {} diff --git a/tests/rustdoc/hide-complex-unevaluated-const-arguments.rs b/tests/rustdoc/hide-complex-unevaluated-const-arguments.rs index 6006354eba4..d728f772a69 100644 --- a/tests/rustdoc/hide-complex-unevaluated-const-arguments.rs +++ b/tests/rustdoc/hide-complex-unevaluated-const-arguments.rs @@ -4,9 +4,11 @@ // // Read the documentation of `rustdoc::clean::utils::print_const_expr` // for further details. -#![feature(const_trait_impl, generic_const_exprs)] +#![feature(const_trait_impl, generic_const_exprs, adt_const_params, generic_const_items)] #![allow(incomplete_features)] +use std::marker::ConstParamTy; + // @has hide_complex_unevaluated_const_arguments/trait.Stage.html pub trait Stage { // A helper constant that prevents const expressions containing it @@ -29,11 +31,13 @@ pub trait Stage { // // @has - '//*[@id="associatedconstant.ARRAY1"]' \ // 'const ARRAY1: [u8; { _ }]' - const ARRAY1: [u8; Struct::new(/* ... */).do_something(Self::ABSTRACT * 1_000)]; + const ARRAY1: [u8; Struct::new(/* ... */).do_something(Self::ABSTRACT * 1_000)] + where [(); Struct::new(/* ... */).do_something(Self::ABSTRACT * 1_000)]:; // @has - '//*[@id="associatedconstant.VERBOSE"]' \ // 'const VERBOSE: [u16; { _ }]' - const VERBOSE: [u16; compute("thing", 9 + 9) * Self::ABSTRACT]; + const VERBOSE: [u16; compute("thing", 9 + 9) * Self::ABSTRACT] + where [(); compute("thing", 9 + 9) * Self::ABSTRACT]:; // Check that we do not leak the private struct field contained within // the path. The output could definitely be improved upon @@ -69,6 +73,7 @@ pub trait Sub: Sup<{ 90 * 20 * 4 }, { Struct { private: () } }> {} pub trait Sup<const N: usize, const S: Struct> {} +#[derive(ConstParamTy, PartialEq, Eq)] pub struct Struct { private: () } impl Struct { diff --git a/tests/rustdoc/inline_cross/auxiliary/default-generic-args.rs b/tests/rustdoc/inline_cross/auxiliary/default-generic-args.rs new file mode 100644 index 00000000000..1e31f18927e --- /dev/null +++ b/tests/rustdoc/inline_cross/auxiliary/default-generic-args.rs @@ -0,0 +1,45 @@ +pub type BoxedStr = Box<str>; +pub type IntMap = std::collections::HashMap<i64, u64>; + +pub struct TyPair<T, U = T>(T, U); + +pub type T0 = TyPair<i32>; +pub type T1 = TyPair<i32, u32>; +pub type T2<K> = TyPair<i32, K>; +pub type T3<Q> = TyPair<Q, Q>; + +pub struct CtPair<const C: u32, const D: u32 = C>; + +pub type C0 = CtPair<43, 43>; +pub type C1 = CtPair<0, 1>; +pub type C2 = CtPair<{1 + 2}, 3>; + +pub struct Re<'a, U = &'a ()>(&'a (), U); + +pub type R0<'q> = Re<'q>; +pub type R1<'q> = Re<'q, &'q ()>; +pub type R2<'q> = Re<'q, &'static ()>; +pub type H0 = fn(for<'a> fn(Re<'a>)); +pub type H1 = for<'b> fn(for<'a> fn(Re<'a, &'b ()>)); +pub type H2 = for<'a> fn(for<'b> fn(Re<'a, &'b ()>)); + +pub struct Proj<T: Basis, U = <T as Basis>::Assoc>(T, U); +pub trait Basis { type Assoc; } +impl Basis for () { type Assoc = bool; } + +pub type P0 = Proj<()>; +pub type P1 = Proj<(), bool>; +pub type P2 = Proj<(), ()>; + +pub struct Alpha<T = for<'any> fn(&'any ())>(T); + +pub type A0 = Alpha; +pub type A1 = Alpha<for<'arbitrary> fn(&'arbitrary ())>; + +pub struct Multi<A = u64, B = u64>(A, B); + +pub type M0 = Multi<u64, ()>; + +pub trait Trait<'a, T = &'a ()> {} + +pub type F = dyn for<'a> Trait<'a>; diff --git a/tests/rustdoc/inline_cross/default-generic-args.rs b/tests/rustdoc/inline_cross/default-generic-args.rs new file mode 100644 index 00000000000..c9a87a19901 --- /dev/null +++ b/tests/rustdoc/inline_cross/default-generic-args.rs @@ -0,0 +1,104 @@ +#![crate_name = "user"] +// aux-crate:default_generic_args=default-generic-args.rs +// edition:2021 + +// @has user/type.BoxedStr.html +// @has - '//*[@class="rust item-decl"]//code' "Box<str>" +pub use default_generic_args::BoxedStr; + +// @has user/type.IntMap.html +// @has - '//*[@class="rust item-decl"]//code' "HashMap<i64, u64>" +pub use default_generic_args::IntMap; + +// @has user/type.T0.html +// @has - '//*[@class="rust item-decl"]//code' "TyPair<i32>" +pub use default_generic_args::T0; + +// @has user/type.T1.html +// @has - '//*[@class="rust item-decl"]//code' "TyPair<i32, u32>" +pub use default_generic_args::T1; + +// @has user/type.T2.html +// @has - '//*[@class="rust item-decl"]//code' "TyPair<i32, K>" +pub use default_generic_args::T2; + +// @has user/type.T3.html +// @has - '//*[@class="rust item-decl"]//code' "TyPair<Q>" +pub use default_generic_args::T3; + +// @has user/type.C0.html +// @has - '//*[@class="rust item-decl"]//code' "CtPair<43>" +pub use default_generic_args::C0; + +// @has user/type.C1.html +// @has - '//*[@class="rust item-decl"]//code' "CtPair<0, 1>" +pub use default_generic_args::C1; + +// @has user/type.C2.html +// @has - '//*[@class="rust item-decl"]//code' "CtPair<default_generic_args::::C2::{constant#0}, 3>" +pub use default_generic_args::C2; + +// @has user/type.R0.html +// @has - '//*[@class="rust item-decl"]//code' "Re<'q>" +pub use default_generic_args::R0; + +// @has user/type.R1.html +// @has - '//*[@class="rust item-decl"]//code' "Re<'q>" +pub use default_generic_args::R1; + +// @has user/type.R2.html +// Check that we consider regions: +// @has - '//*[@class="rust item-decl"]//code' "Re<'q, &'static ()>" +pub use default_generic_args::R2; + +// @has user/type.H0.html +// Check that we handle higher-ranked regions correctly: +// @has - '//*[@class="rust item-decl"]//code' "fn(_: for<'a> fn(_: Re<'a>))" +pub use default_generic_args::H0; + +// @has user/type.H1.html +// Check that we don't conflate distinct universially quantified regions (#1): +// @has - '//*[@class="rust item-decl"]//code' "for<'b> fn(_: for<'a> fn(_: Re<'a, &'b ()>))" +pub use default_generic_args::H1; + +// @has user/type.H2.html +// Check that we don't conflate distinct universially quantified regions (#2): +// @has - '//*[@class="rust item-decl"]//code' "for<'a> fn(_: for<'b> fn(_: Re<'a, &'b ()>))" +pub use default_generic_args::H2; + +// @has user/type.P0.html +// @has - '//*[@class="rust item-decl"]//code' "Proj<()>" +pub use default_generic_args::P0; + +// @has user/type.P1.html +// @has - '//*[@class="rust item-decl"]//code' "Proj<(), bool>" +pub use default_generic_args::P1; + +// @has user/type.P2.html +// @has - '//*[@class="rust item-decl"]//code' "Proj<(), ()>" +pub use default_generic_args::P2; + +// @has user/type.A0.html +// Ensure that we elide generic arguments that are alpha-equivalent to their respective +// generic parameter (modulo substs) (#1): +// @has - '//*[@class="rust item-decl"]//code' "Alpha" +pub use default_generic_args::A0; + +// @has user/type.A1.html +// Ensure that we elide generic arguments that are alpha-equivalent to their respective +// generic parameter (modulo substs) (#1): +// @has - '//*[@class="rust item-decl"]//code' "Alpha" +pub use default_generic_args::A1; + +// @has user/type.M0.html +// Test that we don't elide `u64` even if it coincides with `A`'s default precisely because +// `()` is not the default of `B`. Mindlessly eliding `u64` would lead to `M<()>` which is a +// different type (`M<(), u64>` versus `M<u64, ()>`). +// @has - '//*[@class="rust item-decl"]//code' "Multi<u64, ()>" +pub use default_generic_args::M0; + +// @has user/type.F.html +// FIXME: Ideally, we would elide `&'a ()` but `'a` is an escaping bound var which we can't reason +// about at the moment since we don't keep track of bound vars. +// @has - '//*[@class="rust item-decl"]//code' "dyn for<'a> Trait<'a, &'a ()>" +pub use default_generic_args::F; diff --git a/tests/rustdoc/inline_cross/dyn_trait.rs b/tests/rustdoc/inline_cross/dyn_trait.rs index 679972f035a..9871be79ca3 100644 --- a/tests/rustdoc/inline_cross/dyn_trait.rs +++ b/tests/rustdoc/inline_cross/dyn_trait.rs @@ -75,16 +75,16 @@ pub use dyn_trait::AmbiguousBoundWrappedEarly1; pub use dyn_trait::AmbiguousBoundWrappedStatic; // @has user/type.NoBoundsWrappedDefaulted.html -// @has - '//*[@class="rust item-decl"]//code' "Box<dyn Trait, Global>;" +// @has - '//*[@class="rust item-decl"]//code' "Box<dyn Trait>;" pub use dyn_trait::NoBoundsWrappedDefaulted; // @has user/type.NoBoundsWrappedEarly.html -// @has - '//*[@class="rust item-decl"]//code' "Box<dyn Trait + 'e, Global>;" +// @has - '//*[@class="rust item-decl"]//code' "Box<dyn Trait + 'e>;" pub use dyn_trait::NoBoundsWrappedEarly; // @has user/fn.nbwl.html -// @has - '//pre[@class="rust item-decl"]' "nbwl<'l>(_: Box<dyn Trait + 'l, Global>)" +// @has - '//pre[@class="rust item-decl"]' "nbwl<'l>(_: Box<dyn Trait + 'l>)" pub use dyn_trait::no_bounds_wrapped_late as nbwl; // @has user/fn.nbwel.html -// @has - '//pre[@class="rust item-decl"]' "nbwel(_: Box<dyn Trait + '_, Global>)" +// @has - '//pre[@class="rust item-decl"]' "nbwel(_: Box<dyn Trait + '_>)" // NB: It might seem counterintuitive to display the explicitly elided lifetime `'_` here instead of // eliding it but this behavior is correct: The default is `'static` here which != `'_`. pub use dyn_trait::no_bounds_wrapped_elided as nbwel; diff --git a/tests/rustdoc/inline_cross/impl_trait.rs b/tests/rustdoc/inline_cross/impl_trait.rs index 9b22026e490..3a2f5d16004 100644 --- a/tests/rustdoc/inline_cross/impl_trait.rs +++ b/tests/rustdoc/inline_cross/impl_trait.rs @@ -4,7 +4,7 @@ extern crate impl_trait_aux; // @has impl_trait/fn.func.html -// @has - '//pre[@class="rust item-decl"]' "pub fn func<'a>(_x: impl Clone + Into<Vec<u8, Global>> + 'a)" +// @has - '//pre[@class="rust item-decl"]' "pub fn func<'a>(_x: impl Clone + Into<Vec<u8>> + 'a)" // @!has - '//pre[@class="rust item-decl"]' 'where' pub use impl_trait_aux::func; @@ -34,6 +34,6 @@ pub use impl_trait_aux::func4; pub use impl_trait_aux::func5; // @has impl_trait/struct.Foo.html -// @has - '//*[@id="method.method"]//h4[@class="code-header"]' "pub fn method<'a>(_x: impl Clone + Into<Vec<u8, Global>> + 'a)" +// @has - '//*[@id="method.method"]//h4[@class="code-header"]' "pub fn method<'a>(_x: impl Clone + Into<Vec<u8>> + 'a)" // @!has - '//*[@id="method.method"]//h4[@class="code-header"]' 'where' pub use impl_trait_aux::Foo; diff --git a/tests/rustdoc/intra-doc/prim-associated-traits.rs b/tests/rustdoc/intra-doc/prim-associated-traits.rs index 8639a24f7f3..71d7d2189e6 100644 --- a/tests/rustdoc/intra-doc/prim-associated-traits.rs +++ b/tests/rustdoc/intra-doc/prim-associated-traits.rs @@ -41,6 +41,6 @@ pub struct Number { pub u_128: u128, pub ch: char, pub boolean: bool, - pub string: str, + pub string: &'static str, pub n: !, } diff --git a/tests/rustdoc/normalize-assoc-item.rs b/tests/rustdoc/normalize-assoc-item.rs index c6fd5e1101e..d39e1b15a4c 100644 --- a/tests/rustdoc/normalize-assoc-item.rs +++ b/tests/rustdoc/normalize-assoc-item.rs @@ -30,7 +30,7 @@ pub fn f2() -> <isize as Trait>::X { } pub struct S { - // @has 'normalize_assoc_item/struct.S.html' '//span[@id="structfield.box_me_up"]' 'box_me_up: Box<S, Global>' + // @has 'normalize_assoc_item/struct.S.html' '//span[@id="structfield.box_me_up"]' 'box_me_up: Box<S>' pub box_me_up: <S as Trait>::X, // @has 'normalize_assoc_item/struct.S.html' '//span[@id="structfield.generic"]' 'generic: (usize, isize)' pub generic: <Generic<usize> as Trait>::X, @@ -76,7 +76,7 @@ extern crate inner; // @has 'normalize_assoc_item/fn.foo.html' '//pre[@class="rust item-decl"]' "pub fn foo() -> i32" pub use inner::foo; -// @has 'normalize_assoc_item/fn.h.html' '//pre[@class="rust item-decl"]' "pub fn h<T>() -> IntoIter<T, Global>" +// @has 'normalize_assoc_item/fn.h.html' '//pre[@class="rust item-decl"]' "pub fn h<T>() -> IntoIter<T>" pub fn h<T>() -> <Vec<T> as IntoIterator>::IntoIter { vec![].into_iter() } diff --git a/tests/rustdoc/notable-trait/doc-notable_trait_box_is_not_an_iterator.rs b/tests/rustdoc/notable-trait/doc-notable_trait_box_is_not_an_iterator.rs index 3fb00c7db84..6b94d799483 100644 --- a/tests/rustdoc/notable-trait/doc-notable_trait_box_is_not_an_iterator.rs +++ b/tests/rustdoc/notable-trait/doc-notable_trait_box_is_not_an_iterator.rs @@ -3,25 +3,28 @@ #![feature(no_core)] #![no_core] #[lang = "owned_box"] -pub struct Box<T>; +pub struct Box<T>(*const T); impl<T> Box<T> { pub fn new(x: T) -> Box<T> { - Box + Box(std::ptr::null()) } } +#[lang = "sized"] +trait Sized {} + #[doc(notable_trait)] pub trait FakeIterator {} impl<I: FakeIterator> FakeIterator for Box<I> {} #[lang = "pin"] -pub struct Pin<T>; +pub struct Pin<T>(T); impl<T> Pin<T> { pub fn new(x: T) -> Pin<T> { - Pin + Pin(x) } } diff --git a/tests/rustdoc/sidebar-items.rs b/tests/rustdoc/sidebar-items.rs index 6f7afa59bdd..b746f698264 100644 --- a/tests/rustdoc/sidebar-items.rs +++ b/tests/rustdoc/sidebar-items.rs @@ -14,6 +14,7 @@ // @has - '//*[@class="sidebar-elems"]//section//a' 'Output' // @has - '//div[@class="sidebar-elems"]//h3/a[@href="#provided-associated-types"]' 'Provided Associated Types' // @has - '//*[@class="sidebar-elems"]//section//a' 'Extra' +// @has - '//div[@class="sidebar-elems"]//h3/a[@href="#object-safety"]' 'Object Safety' pub trait Foo { const FOO: usize; const BAR: u32 = 0; @@ -24,6 +25,12 @@ pub trait Foo { fn bar() -> Self::Output; } +// @has foo/trait.Safe.html +// @!has - '//div[@class="sidebar-elems"]//h3/a[@href="#object-safety"]' '' +pub trait Safe { + fn access(&self); +} + // @has foo/struct.Bar.html // @has - '//div[@class="sidebar-elems"]//h3/a[@href="#fields"]' 'Fields' // @has - '//*[@class="sidebar-elems"]//section//a[@href="#structfield.f"]' 'f' diff --git a/tests/rustdoc/trait-object-safe.rs b/tests/rustdoc/trait-object-safe.rs new file mode 100644 index 00000000000..818843f7558 --- /dev/null +++ b/tests/rustdoc/trait-object-safe.rs @@ -0,0 +1,27 @@ +#![crate_name = "foo"] + +// @has 'foo/trait.Unsafe.html' +// @has - '//*[@class="object-safety-info"]' 'This trait is not object safe.' +// @has - '//*[@id="object-safety"]' 'Object Safety' +pub trait Unsafe { + fn foo() -> Self; +} + +// @has 'foo/trait.Unsafe2.html' +// @has - '//*[@class="object-safety-info"]' 'This trait is not object safe.' +// @has - '//*[@id="object-safety"]' 'Object Safety' +pub trait Unsafe2<T> { + fn foo(i: T); +} + +// @has 'foo/trait.Safe.html' +// @!has - '//*[@class="object-safety-info"]' '' +// @!has - '//*[@id="object-safety"]' '' +pub trait Safe { + fn foo(&self); +} + +// @has 'foo/struct.Foo.html' +// @!has - '//*[@class="object-safety-info"]' '' +// @!has - '//*[@id="object-safety"]' '' +pub struct Foo; diff --git a/tests/rustdoc/where-clause-order.rs b/tests/rustdoc/where-clause-order.rs index 7261dfa7dd9..e3184b646bf 100644 --- a/tests/rustdoc/where-clause-order.rs +++ b/tests/rustdoc/where-clause-order.rs @@ -7,7 +7,7 @@ where } // @has 'foo/trait.SomeTrait.html' -// @has - "//*[@id='impl-SomeTrait-for-(A,+B,+C,+D,+E)']/h3" "impl<A, B, C, D, E> SomeTrait<(A, B, C, D, E)> for (A, B, C, D, E)where A: PartialOrd<A> + PartialEq<A>, B: PartialOrd<B> + PartialEq<B>, C: PartialOrd<C> + PartialEq<C>, D: PartialOrd<D> + PartialEq<D>, E: PartialOrd<E> + PartialEq<E> + ?Sized, " +// @has - "//*[@id='impl-SomeTrait-for-(A,+B,+C,+D,+E)']/h3" "impl<A, B, C, D, E> SomeTrait for (A, B, C, D, E)where A: PartialOrd<A> + PartialEq<A>, B: PartialOrd<B> + PartialEq<B>, C: PartialOrd<C> + PartialEq<C>, D: PartialOrd<D> + PartialEq<D>, E: PartialOrd<E> + PartialEq<E> + ?Sized, " impl<A, B, C, D, E> SomeTrait<(A, B, C, D, E)> for (A, B, C, D, E) where A: PartialOrd<A> + PartialEq<A>, diff --git a/tests/rustdoc/whitespace-after-where-clause.enum.html b/tests/rustdoc/whitespace-after-where-clause.enum.html index 20b60b68e88..ff4971f33cd 100644 --- a/tests/rustdoc/whitespace-after-where-clause.enum.html +++ b/tests/rustdoc/whitespace-after-where-clause.enum.html @@ -1,5 +1,5 @@ <pre class="rust item-decl"><code>pub enum Cow<'a, B><span class="where fmt-newline">where - B: <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>> + ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'a,</span>{ + B: <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><<a class="primitive" href="{{channel}}/std/primitive.unit.html">()</a>> + ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'a,</span>{ Borrowed(<a class="primitive" href="{{channel}}/std/primitive.reference.html">&'a B</a>), Whatever(<a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a>), }</code></pre> \ No newline at end of file diff --git a/tests/rustdoc/whitespace-after-where-clause.enum2.html b/tests/rustdoc/whitespace-after-where-clause.enum2.html index 065ce757de1..bfc50f8adcd 100644 --- a/tests/rustdoc/whitespace-after-where-clause.enum2.html +++ b/tests/rustdoc/whitespace-after-where-clause.enum2.html @@ -1,4 +1,4 @@ -<pre class="rust item-decl"><code>pub enum Cow2<'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>> + 'a> { +<pre class="rust item-decl"><code>pub enum Cow2<'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><<a class="primitive" href="{{channel}}/std/primitive.unit.html">()</a>> + 'a> { Borrowed(<a class="primitive" href="{{channel}}/std/primitive.reference.html">&'a B</a>), Whatever(<a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a>), }</code></pre> \ No newline at end of file diff --git a/tests/rustdoc/whitespace-after-where-clause.rs b/tests/rustdoc/whitespace-after-where-clause.rs index b540c7c97c1..832d3728e75 100644 --- a/tests/rustdoc/whitespace-after-where-clause.rs +++ b/tests/rustdoc/whitespace-after-where-clause.rs @@ -6,7 +6,8 @@ // @has 'foo/trait.ToOwned.html' // @snapshot trait - '//*[@class="rust item-decl"]' pub trait ToOwned<T> -where T: Clone +where + T: Clone, { type Owned; fn to_owned(&self) -> Self::Owned; @@ -26,7 +27,7 @@ pub trait ToOwned2<T: Clone> { // @snapshot enum - '//*[@class="rust item-decl"]' pub enum Cow<'a, B: ?Sized + 'a> where - B: ToOwned<Clone>, + B: ToOwned<()>, { Borrowed(&'a B), Whatever(u32), @@ -35,7 +36,7 @@ where // @has 'foo/enum.Cow2.html' // @snapshot enum2 - '//*[@class="rust item-decl"]' // There should be a whitespace before `{` in this case! -pub enum Cow2<'a, B: ?Sized + ToOwned<Clone> + 'a> { +pub enum Cow2<'a, B: ?Sized + ToOwned<()> + 'a> { Borrowed(&'a B), Whatever(u32), } @@ -44,7 +45,7 @@ pub enum Cow2<'a, B: ?Sized + ToOwned<Clone> + 'a> { // @snapshot struct - '//*[@class="rust item-decl"]' pub struct Struct<'a, B: ?Sized + 'a> where - B: ToOwned<Clone>, + B: ToOwned<()>, { pub a: &'a B, pub b: u32, @@ -53,7 +54,7 @@ where // @has 'foo/struct.Struct2.html' // @snapshot struct2 - '//*[@class="rust item-decl"]' // There should be a whitespace before `{` in this case! -pub struct Struct2<'a, B: ?Sized + ToOwned<Clone> + 'a> { +pub struct Struct2<'a, B: ?Sized + ToOwned<()> + 'a> { pub a: &'a B, pub b: u32, } @@ -62,7 +63,7 @@ pub struct Struct2<'a, B: ?Sized + ToOwned<Clone> + 'a> { // @snapshot union - '//*[@class="rust item-decl"]' pub union Union<'a, B: ?Sized + 'a> where - B: ToOwned<Clone>, + B: ToOwned<()>, { a: &'a B, b: u32, @@ -71,7 +72,7 @@ where // @has 'foo/union.Union2.html' // @snapshot union2 - '//*[@class="rust item-decl"]' // There should be a whitespace before `{` in this case! -pub union Union2<'a, B: ?Sized + ToOwned<Clone> + 'a> { +pub union Union2<'a, B: ?Sized + ToOwned<()> + 'a> { a: &'a B, b: u32, } diff --git a/tests/rustdoc/whitespace-after-where-clause.struct.html b/tests/rustdoc/whitespace-after-where-clause.struct.html index 948ddc499da..ca685358633 100644 --- a/tests/rustdoc/whitespace-after-where-clause.struct.html +++ b/tests/rustdoc/whitespace-after-where-clause.struct.html @@ -1,5 +1,5 @@ <pre class="rust item-decl"><code>pub struct Struct<'a, B><span class="where fmt-newline">where - B: <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>> + ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'a,</span>{ + B: <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><<a class="primitive" href="{{channel}}/std/primitive.unit.html">()</a>> + ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'a,</span>{ pub a: <a class="primitive" href="{{channel}}/std/primitive.reference.html">&'a B</a>, pub b: <a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a>, }</code></pre> \ No newline at end of file diff --git a/tests/rustdoc/whitespace-after-where-clause.struct2.html b/tests/rustdoc/whitespace-after-where-clause.struct2.html index c647e8d7121..5aa8110c18f 100644 --- a/tests/rustdoc/whitespace-after-where-clause.struct2.html +++ b/tests/rustdoc/whitespace-after-where-clause.struct2.html @@ -1,4 +1,4 @@ -<pre class="rust item-decl"><code>pub struct Struct2<'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>> + 'a> { +<pre class="rust item-decl"><code>pub struct Struct2<'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><<a class="primitive" href="{{channel}}/std/primitive.unit.html">()</a>> + 'a> { pub a: <a class="primitive" href="{{channel}}/std/primitive.reference.html">&'a B</a>, pub b: <a class="primitive" href="{{channel}}/std/primitive.u32.html">u32</a>, }</code></pre> \ No newline at end of file diff --git a/tests/rustdoc/whitespace-after-where-clause.union.html b/tests/rustdoc/whitespace-after-where-clause.union.html index 38b6cb8b5c6..40b0c671284 100644 --- a/tests/rustdoc/whitespace-after-where-clause.union.html +++ b/tests/rustdoc/whitespace-after-where-clause.union.html @@ -1,4 +1,4 @@ <pre class="rust item-decl"><code>pub union Union<'a, B><span class="where fmt-newline">where - B: <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>> + ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'a,</span>{ + B: <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><<a class="primitive" href="{{channel}}/std/primitive.unit.html">()</a>> + ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + 'a,</span>{ /* private fields */ }</code></pre> \ No newline at end of file diff --git a/tests/rustdoc/whitespace-after-where-clause.union2.html b/tests/rustdoc/whitespace-after-where-clause.union2.html index 66ad30c9200..177a161b83a 100644 --- a/tests/rustdoc/whitespace-after-where-clause.union2.html +++ b/tests/rustdoc/whitespace-after-where-clause.union2.html @@ -1,3 +1,3 @@ -<pre class="rust item-decl"><code>pub union Union2<'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><dyn <a class="trait" href="{{channel}}/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>> + 'a> { +<pre class="rust item-decl"><code>pub union Union2<'a, B: ?<a class="trait" href="{{channel}}/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="trait.ToOwned.html" title="trait foo::ToOwned">ToOwned</a><<a class="primitive" href="{{channel}}/std/primitive.unit.html">()</a>> + 'a> { /* private fields */ }</code></pre> \ No newline at end of file diff --git a/tests/ui-fulldeps/stable-mir/smir_visitor.rs b/tests/ui-fulldeps/stable-mir/smir_visitor.rs new file mode 100644 index 00000000000..de5148bb5f4 --- /dev/null +++ b/tests/ui-fulldeps/stable-mir/smir_visitor.rs @@ -0,0 +1,148 @@ +// run-pass +//! Sanity check Stable MIR Visitor + +// ignore-stage1 +// ignore-cross-compile +// ignore-remote +// ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 +// edition: 2021 + +#![feature(rustc_private)] +#![feature(assert_matches)] +#![feature(control_flow_enum)] + +extern crate rustc_middle; +#[macro_use] +extern crate rustc_smir; +extern crate rustc_driver; +extern crate rustc_interface; +extern crate stable_mir; + +use std::collections::HashSet; +use rustc_middle::ty::TyCtxt; +use rustc_smir::rustc_internal; +use stable_mir::*; +use stable_mir::mir::MirVisitor; +use std::io::Write; +use std::ops::ControlFlow; + +const CRATE_NAME: &str = "input"; + +fn test_visitor(_tcx: TyCtxt<'_>) -> ControlFlow<()> { + let main_fn = stable_mir::entry_fn(); + let main_body = main_fn.unwrap().body(); + let main_visitor = TestVisitor::collect(&main_body); + assert!(main_visitor.ret_val.is_some()); + assert!(main_visitor.args.is_empty()); + assert!(main_visitor.tys.contains(&main_visitor.ret_val.unwrap().ty)); + assert!(!main_visitor.calls.is_empty()); + + let exit_fn = main_visitor.calls.last().unwrap(); + assert!(exit_fn.mangled_name().contains("exit_fn"), "Unexpected last function: {exit_fn:?}"); + + let exit_body = exit_fn.body(); + let exit_visitor = TestVisitor::collect(&exit_body); + assert!(exit_visitor.ret_val.is_some()); + assert_eq!(exit_visitor.args.len(), 1); + assert!(exit_visitor.tys.contains(&exit_visitor.ret_val.unwrap().ty)); + assert!(exit_visitor.tys.contains(&exit_visitor.args[0].ty)); + ControlFlow::Continue(()) +} + +struct TestVisitor<'a> { + pub body: &'a mir::Body, + pub tys: HashSet<ty::Ty>, + pub ret_val: Option<mir::LocalDecl>, + pub args: Vec<mir::LocalDecl>, + pub calls: Vec<mir::mono::Instance> +} + +impl<'a> TestVisitor<'a> { + fn collect(body: &'a mir::Body) -> TestVisitor<'a> { + let mut visitor = TestVisitor { + body: &body, + tys: Default::default(), + ret_val: None, + args: vec![], + calls: vec![], + }; + visitor.visit_body(&body); + visitor + } +} + +impl<'a> mir::MirVisitor for TestVisitor<'a> { + fn visit_ty(&mut self, ty: &ty::Ty, _location: mir::visit::Location) { + self.tys.insert(*ty); + self.super_ty(ty) + } + + fn visit_ret_decl(&mut self, local: mir::Local, decl: &mir::LocalDecl) { + assert!(local == mir::RETURN_LOCAL); + assert!(self.ret_val.is_none()); + self.ret_val = Some(decl.clone()); + self.super_ret_decl(local, decl); + } + + fn visit_arg_decl(&mut self, local: mir::Local, decl: &mir::LocalDecl) { + self.args.push(decl.clone()); + assert_eq!(local, self.args.len()); + self.super_arg_decl(local, decl); + } + + fn visit_terminator(&mut self, term: &mir::Terminator, location: mir::visit::Location) { + if let mir::TerminatorKind::Call { func, .. } = &term.kind { + let ty::TyKind::RigidTy(ty) = func.ty(self.body.locals()).kind() else { unreachable! + () }; + let ty::RigidTy::FnDef(def, args) = ty else { unreachable!() }; + self.calls.push(mir::mono::Instance::resolve(def, &args).unwrap()); + } + self.super_terminator(term, location); + } +} + +/// This test will generate and analyze a dummy crate using the stable mir. +/// For that, it will first write the dummy crate into a file. +/// Then it will create a `StableMir` using custom arguments and then +/// it will run the compiler. +fn main() { + let path = "sim_visitor_input.rs"; + generate_input(&path).unwrap(); + let args = vec![ + "rustc".to_string(), + "-Cpanic=abort".to_string(), + "--crate-name".to_string(), + CRATE_NAME.to_string(), + path.to_string(), + ]; + run!(args, tcx, test_visitor(tcx)).unwrap(); +} + +fn generate_input(path: &str) -> std::io::Result<()> { + let mut file = std::fs::File::create(path)?; + write!( + file, + r#" + fn main() -> std::process::ExitCode {{ + let inputs = Inputs::new(); + let total = inputs.values.iter().sum(); + exit_fn(total) + }} + + fn exit_fn(code: u8) -> std::process::ExitCode {{ + std::process::ExitCode::from(code) + }} + + struct Inputs {{ + values: [u8; 3], + }} + + impl Inputs {{ + fn new() -> Inputs {{ + Inputs {{ values: [0, 1, 2] }} + }} + }} + "# + )?; + Ok(()) +} diff --git a/tests/ui/associated-type-bounds/duplicate.rs b/tests/ui/associated-type-bounds/duplicate.rs index 4b8bf52c374..5019804d494 100644 --- a/tests/ui/associated-type-bounds/duplicate.rs +++ b/tests/ui/associated-type-bounds/duplicate.rs @@ -5,258 +5,258 @@ use std::iter; use std::mem::ManuallyDrop; struct SI1<T: Iterator<Item: Copy, Item: Send>> { - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] f: T, } struct SI2<T: Iterator<Item: Copy, Item: Copy>> { - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] f: T, } struct SI3<T: Iterator<Item: 'static, Item: 'static>> { - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] f: T, } struct SW1<T> where T: Iterator<Item: Copy, Item: Send>, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { f: T, } struct SW2<T> where T: Iterator<Item: Copy, Item: Copy>, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { f: T, } struct SW3<T> where T: Iterator<Item: 'static, Item: 'static>, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { f: T, } enum EI1<T: Iterator<Item: Copy, Item: Send>> { - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] V(T), } enum EI2<T: Iterator<Item: Copy, Item: Copy>> { - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] V(T), } enum EI3<T: Iterator<Item: 'static, Item: 'static>> { - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] V(T), } enum EW1<T> where T: Iterator<Item: Copy, Item: Send>, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { V(T), } enum EW2<T> where T: Iterator<Item: Copy, Item: Copy>, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { V(T), } enum EW3<T> where T: Iterator<Item: 'static, Item: 'static>, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { V(T), } union UI1<T: Iterator<Item: Copy, Item: Send>> { - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] f: ManuallyDrop<T>, } union UI2<T: Iterator<Item: Copy, Item: Copy>> { - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] f: ManuallyDrop<T>, } union UI3<T: Iterator<Item: 'static, Item: 'static>> { - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] f: ManuallyDrop<T>, } union UW1<T> where T: Iterator<Item: Copy, Item: Send>, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { f: ManuallyDrop<T>, } union UW2<T> where T: Iterator<Item: Copy, Item: Copy>, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { f: ManuallyDrop<T>, } union UW3<T> where T: Iterator<Item: 'static, Item: 'static>, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { f: ManuallyDrop<T>, } fn FI1<T: Iterator<Item: Copy, Item: Send>>() {} -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] fn FI2<T: Iterator<Item: Copy, Item: Copy>>() {} -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] fn FI3<T: Iterator<Item: 'static, Item: 'static>>() {} -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] fn FW1<T>() where T: Iterator<Item: Copy, Item: Send>, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { } fn FW2<T>() where T: Iterator<Item: Copy, Item: Copy>, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { } fn FW3<T>() where T: Iterator<Item: 'static, Item: 'static>, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { } fn FRPIT1() -> impl Iterator<Item: Copy, Item: Send> { - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] iter::empty() } fn FRPIT2() -> impl Iterator<Item: Copy, Item: Copy> { - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] iter::empty() } fn FRPIT3() -> impl Iterator<Item: 'static, Item: 'static> { - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] iter::empty() } fn FAPIT1(_: impl Iterator<Item: Copy, Item: Send>) {} -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] fn FAPIT2(_: impl Iterator<Item: Copy, Item: Copy>) {} -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] fn FAPIT3(_: impl Iterator<Item: 'static, Item: 'static>) {} -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] type TAI1<T: Iterator<Item: Copy, Item: Send>> = T; -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] type TAI2<T: Iterator<Item: Copy, Item: Copy>> = T; -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] type TAI3<T: Iterator<Item: 'static, Item: 'static>> = T; -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] type TAW1<T> where T: Iterator<Item: Copy, Item: Send>, -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] = T; type TAW2<T> where T: Iterator<Item: Copy, Item: Copy>, -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] = T; type TAW3<T> where T: Iterator<Item: 'static, Item: 'static>, -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] = T; type ETAI1<T: Iterator<Item: Copy, Item: Send>> = impl Copy; -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] type ETAI2<T: Iterator<Item: Copy, Item: Copy>> = impl Copy; -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] type ETAI3<T: Iterator<Item: 'static, Item: 'static>> = impl Copy; -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] type ETAI4 = impl Iterator<Item: Copy, Item: Send>; -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] type ETAI5 = impl Iterator<Item: Copy, Item: Copy>; -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] type ETAI6 = impl Iterator<Item: 'static, Item: 'static>; -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] trait TRI1<T: Iterator<Item: Copy, Item: Send>> {} -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] trait TRI2<T: Iterator<Item: Copy, Item: Copy>> {} -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] trait TRI3<T: Iterator<Item: 'static, Item: 'static>> {} -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] trait TRS1: Iterator<Item: Copy, Item: Send> {} -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] -//~| ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] +//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] trait TRS2: Iterator<Item: Copy, Item: Copy> {} -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] -//~| ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] +//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] trait TRS3: Iterator<Item: 'static, Item: 'static> {} -//~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] -//~| ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] +//~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] +//~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] trait TRW1<T> where T: Iterator<Item: Copy, Item: Send>, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { } trait TRW2<T> where T: Iterator<Item: Copy, Item: Copy>, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { } trait TRW3<T> where T: Iterator<Item: 'static, Item: 'static>, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { } trait TRSW1 where Self: Iterator<Item: Copy, Item: Send>, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] - //~| ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] + //~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { } trait TRSW2 where Self: Iterator<Item: Copy, Item: Copy>, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] - //~| ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] + //~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { } trait TRSW3 where Self: Iterator<Item: 'static, Item: 'static>, - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] - //~| ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] + //~| ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] { } trait TRA1 { type A: Iterator<Item: Copy, Item: Send>; - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] } trait TRA2 { type A: Iterator<Item: Copy, Item: Copy>; - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ ERROR the value of the associated type `Item` in trait `Iterator` is already specified [E0719] } trait TRA3 { type A: Iterator<Item: 'static, Item: 'static>; - //~^ ERROR the value of the associated type `Item` (from trait `Iterator`) is already specified [E0719] + //~^ 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` (from trait `Iterator`) is already specified [E0719] +//~^ 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` (from trait `Iterator`) is already specified [E0719] +//~^ 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` (from trait `Iterator`) is already specified [E0719] +//~^ 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 3629aa4fcea..3888e62230f 100644 --- a/tests/ui/associated-type-bounds/duplicate.stderr +++ b/tests/ui/associated-type-bounds/duplicate.stderr @@ -1,4 +1,4 @@ -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:7:36 | LL | struct SI1<T: Iterator<Item: Copy, Item: Send>> { @@ -6,7 +6,7 @@ LL | struct SI1<T: Iterator<Item: Copy, Item: Send>> { | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +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>> { @@ -14,7 +14,7 @@ LL | struct SI2<T: Iterator<Item: Copy, Item: Copy>> { | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:15:39 | LL | struct SI3<T: Iterator<Item: 'static, Item: 'static>> { @@ -22,7 +22,7 @@ LL | struct SI3<T: Iterator<Item: 'static, Item: 'static>> { | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:21:29 | LL | T: Iterator<Item: Copy, Item: Send>, @@ -30,7 +30,7 @@ LL | T: Iterator<Item: Copy, Item: Send>, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:28:29 | LL | T: Iterator<Item: Copy, Item: Copy>, @@ -38,7 +38,7 @@ LL | T: Iterator<Item: Copy, Item: Copy>, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:35:32 | LL | T: Iterator<Item: 'static, Item: 'static>, @@ -46,7 +46,7 @@ LL | T: Iterator<Item: 'static, Item: 'static>, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:41:34 | LL | enum EI1<T: Iterator<Item: Copy, Item: Send>> { @@ -54,7 +54,7 @@ LL | enum EI1<T: Iterator<Item: Copy, Item: Send>> { | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:45:34 | LL | enum EI2<T: Iterator<Item: Copy, Item: Copy>> { @@ -62,7 +62,7 @@ LL | enum EI2<T: Iterator<Item: Copy, Item: Copy>> { | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:49:37 | LL | enum EI3<T: Iterator<Item: 'static, Item: 'static>> { @@ -70,7 +70,7 @@ LL | enum EI3<T: Iterator<Item: 'static, Item: 'static>> { | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:55:29 | LL | T: Iterator<Item: Copy, Item: Send>, @@ -78,7 +78,7 @@ LL | T: Iterator<Item: Copy, Item: Send>, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:62:29 | LL | T: Iterator<Item: Copy, Item: Copy>, @@ -86,7 +86,7 @@ LL | T: Iterator<Item: Copy, Item: Copy>, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:69:32 | LL | T: Iterator<Item: 'static, Item: 'static>, @@ -94,7 +94,7 @@ LL | T: Iterator<Item: 'static, Item: 'static>, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:75:35 | LL | union UI1<T: Iterator<Item: Copy, Item: Send>> { @@ -102,7 +102,7 @@ LL | union UI1<T: Iterator<Item: Copy, Item: Send>> { | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:79:35 | LL | union UI2<T: Iterator<Item: Copy, Item: Copy>> { @@ -110,7 +110,7 @@ LL | union UI2<T: Iterator<Item: Copy, Item: Copy>> { | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:83:38 | LL | union UI3<T: Iterator<Item: 'static, Item: 'static>> { @@ -118,7 +118,7 @@ LL | union UI3<T: Iterator<Item: 'static, Item: 'static>> { | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:89:29 | LL | T: Iterator<Item: Copy, Item: Send>, @@ -126,7 +126,7 @@ LL | T: Iterator<Item: Copy, Item: Send>, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:96:29 | LL | T: Iterator<Item: Copy, Item: Copy>, @@ -134,7 +134,7 @@ LL | T: Iterator<Item: Copy, Item: Copy>, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:103:32 | LL | T: Iterator<Item: 'static, Item: 'static>, @@ -142,7 +142,7 @@ LL | T: Iterator<Item: 'static, Item: 'static>, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:109:32 | LL | fn FI1<T: Iterator<Item: Copy, Item: Send>>() {} @@ -150,7 +150,7 @@ LL | fn FI1<T: Iterator<Item: Copy, Item: Send>>() {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:111:32 | LL | fn FI2<T: Iterator<Item: Copy, Item: Copy>>() {} @@ -158,7 +158,7 @@ LL | fn FI2<T: Iterator<Item: Copy, Item: Copy>>() {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:113:35 | LL | fn FI3<T: Iterator<Item: 'static, Item: 'static>>() {} @@ -166,7 +166,7 @@ LL | fn FI3<T: Iterator<Item: 'static, Item: 'static>>() {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:117:29 | LL | T: Iterator<Item: Copy, Item: Send>, @@ -174,7 +174,7 @@ LL | T: Iterator<Item: Copy, Item: Send>, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:123:29 | LL | T: Iterator<Item: Copy, Item: Copy>, @@ -182,7 +182,7 @@ LL | T: Iterator<Item: Copy, Item: Copy>, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:129:32 | LL | T: Iterator<Item: 'static, Item: 'static>, @@ -190,7 +190,7 @@ LL | T: Iterator<Item: 'static, Item: 'static>, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:134:42 | LL | fn FRPIT1() -> impl Iterator<Item: Copy, Item: Send> { @@ -198,7 +198,7 @@ LL | fn FRPIT1() -> impl Iterator<Item: Copy, Item: Send> { | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:138:42 | LL | fn FRPIT2() -> impl Iterator<Item: Copy, Item: Copy> { @@ -206,7 +206,7 @@ LL | fn FRPIT2() -> impl Iterator<Item: Copy, Item: Copy> { | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:142:45 | LL | fn FRPIT3() -> impl Iterator<Item: 'static, Item: 'static> { @@ -214,7 +214,7 @@ LL | fn FRPIT3() -> impl Iterator<Item: 'static, Item: 'static> { | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:146:40 | LL | fn FAPIT1(_: impl Iterator<Item: Copy, Item: Send>) {} @@ -222,7 +222,7 @@ LL | fn FAPIT1(_: impl Iterator<Item: Copy, Item: Send>) {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:148:40 | LL | fn FAPIT2(_: impl Iterator<Item: Copy, Item: Copy>) {} @@ -230,7 +230,7 @@ LL | fn FAPIT2(_: impl Iterator<Item: Copy, Item: Copy>) {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:150:43 | LL | fn FAPIT3(_: impl Iterator<Item: 'static, Item: 'static>) {} @@ -238,7 +238,7 @@ LL | fn FAPIT3(_: impl Iterator<Item: 'static, Item: 'static>) {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:153:35 | LL | type TAI1<T: Iterator<Item: Copy, Item: Send>> = T; @@ -246,7 +246,7 @@ LL | type TAI1<T: Iterator<Item: Copy, Item: Send>> = T; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:155:35 | LL | type TAI2<T: Iterator<Item: Copy, Item: Copy>> = T; @@ -254,7 +254,7 @@ LL | type TAI2<T: Iterator<Item: Copy, Item: Copy>> = T; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:157:38 | LL | type TAI3<T: Iterator<Item: 'static, Item: 'static>> = T; @@ -262,7 +262,7 @@ LL | type TAI3<T: Iterator<Item: 'static, Item: 'static>> = T; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:161:29 | LL | T: Iterator<Item: Copy, Item: Send>, @@ -270,7 +270,7 @@ LL | T: Iterator<Item: Copy, Item: Send>, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:166:29 | LL | T: Iterator<Item: Copy, Item: Copy>, @@ -278,7 +278,7 @@ LL | T: Iterator<Item: Copy, Item: Copy>, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:171:32 | LL | T: Iterator<Item: 'static, Item: 'static>, @@ -286,7 +286,7 @@ LL | T: Iterator<Item: 'static, Item: 'static>, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:175:36 | LL | type ETAI1<T: Iterator<Item: Copy, Item: Send>> = impl Copy; @@ -294,7 +294,7 @@ LL | type ETAI1<T: Iterator<Item: Copy, Item: Send>> = impl Copy; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:177:36 | LL | type ETAI2<T: Iterator<Item: Copy, Item: Copy>> = impl Copy; @@ -302,7 +302,7 @@ LL | type ETAI2<T: Iterator<Item: Copy, Item: Copy>> = impl Copy; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:179:39 | LL | type ETAI3<T: Iterator<Item: 'static, Item: 'static>> = impl Copy; @@ -310,7 +310,7 @@ LL | type ETAI3<T: Iterator<Item: 'static, Item: 'static>> = impl Copy; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:181:40 | LL | type ETAI4 = impl Iterator<Item: Copy, Item: Send>; @@ -318,7 +318,7 @@ LL | type ETAI4 = impl Iterator<Item: Copy, Item: Send>; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:183:40 | LL | type ETAI5 = impl Iterator<Item: Copy, Item: Copy>; @@ -326,7 +326,7 @@ LL | type ETAI5 = impl Iterator<Item: Copy, Item: Copy>; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:185:43 | LL | type ETAI6 = impl Iterator<Item: 'static, Item: 'static>; @@ -334,7 +334,7 @@ LL | type ETAI6 = impl Iterator<Item: 'static, Item: 'static>; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:188:36 | LL | trait TRI1<T: Iterator<Item: Copy, Item: Send>> {} @@ -342,7 +342,7 @@ LL | trait TRI1<T: Iterator<Item: Copy, Item: Send>> {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:190:36 | LL | trait TRI2<T: Iterator<Item: Copy, Item: Copy>> {} @@ -350,7 +350,7 @@ LL | trait TRI2<T: Iterator<Item: Copy, Item: Copy>> {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:192:39 | LL | trait TRI3<T: Iterator<Item: 'static, Item: 'static>> {} @@ -358,7 +358,7 @@ LL | trait TRI3<T: Iterator<Item: 'static, Item: 'static>> {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:194:34 | LL | trait TRS1: Iterator<Item: Copy, Item: Send> {} @@ -366,7 +366,7 @@ LL | trait TRS1: Iterator<Item: Copy, Item: Send> {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:194:34 | LL | trait TRS1: Iterator<Item: Copy, Item: Send> {} @@ -376,7 +376,7 @@ LL | trait TRS1: Iterator<Item: Copy, Item: Send> {} | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:197:34 | LL | trait TRS2: Iterator<Item: Copy, Item: Copy> {} @@ -384,7 +384,7 @@ LL | trait TRS2: Iterator<Item: Copy, Item: Copy> {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:197:34 | LL | trait TRS2: Iterator<Item: Copy, Item: Copy> {} @@ -394,7 +394,7 @@ LL | trait TRS2: Iterator<Item: Copy, Item: Copy> {} | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:200:37 | LL | trait TRS3: Iterator<Item: 'static, Item: 'static> {} @@ -402,7 +402,7 @@ LL | trait TRS3: Iterator<Item: 'static, Item: 'static> {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:200:37 | LL | trait TRS3: Iterator<Item: 'static, Item: 'static> {} @@ -412,7 +412,7 @@ LL | trait TRS3: Iterator<Item: 'static, Item: 'static> {} | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:205:29 | LL | T: Iterator<Item: Copy, Item: Send>, @@ -420,7 +420,7 @@ LL | T: Iterator<Item: Copy, Item: Send>, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:211:29 | LL | T: Iterator<Item: Copy, Item: Copy>, @@ -428,7 +428,7 @@ LL | T: Iterator<Item: Copy, Item: Copy>, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:217:32 | LL | T: Iterator<Item: 'static, Item: 'static>, @@ -436,7 +436,7 @@ LL | T: Iterator<Item: 'static, Item: 'static>, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:223:32 | LL | Self: Iterator<Item: Copy, Item: Send>, @@ -444,7 +444,7 @@ LL | Self: Iterator<Item: Copy, Item: Send>, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:223:32 | LL | Self: Iterator<Item: Copy, Item: Send>, @@ -454,7 +454,7 @@ LL | Self: Iterator<Item: Copy, Item: Send>, | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:230:32 | LL | Self: Iterator<Item: Copy, Item: Copy>, @@ -462,7 +462,7 @@ LL | Self: Iterator<Item: Copy, Item: Copy>, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:230:32 | LL | Self: Iterator<Item: Copy, Item: Copy>, @@ -472,7 +472,7 @@ LL | Self: Iterator<Item: Copy, Item: Copy>, | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:237:35 | LL | Self: Iterator<Item: 'static, Item: 'static>, @@ -480,7 +480,7 @@ LL | Self: Iterator<Item: 'static, Item: 'static>, | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:237:35 | LL | Self: Iterator<Item: 'static, Item: 'static>, @@ -490,7 +490,7 @@ LL | Self: Iterator<Item: 'static, Item: 'static>, | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:255:40 | LL | type TADyn1 = dyn Iterator<Item: Copy, Item: Send>; @@ -498,7 +498,7 @@ LL | type TADyn1 = dyn Iterator<Item: Copy, Item: Send>; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:257:44 | LL | type TADyn2 = Box<dyn Iterator<Item: Copy, Item: Copy>>; @@ -506,7 +506,7 @@ LL | type TADyn2 = Box<dyn Iterator<Item: Copy, Item: Copy>>; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:259:43 | LL | type TADyn3 = dyn Iterator<Item: 'static, Item: 'static>; @@ -514,7 +514,7 @@ LL | type TADyn3 = dyn Iterator<Item: 'static, Item: 'static>; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:243:34 | LL | type A: Iterator<Item: Copy, Item: Send>; @@ -522,7 +522,7 @@ LL | type A: Iterator<Item: Copy, Item: Send>; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:247:34 | LL | type A: Iterator<Item: Copy, Item: Copy>; @@ -530,7 +530,7 @@ LL | type A: Iterator<Item: Copy, Item: Copy>; | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/duplicate.rs:251:37 | LL | type A: Iterator<Item: 'static, Item: 'static>; diff --git a/tests/ui/associated-type-bounds/overlaping-bound-suggestion.stderr b/tests/ui/associated-type-bounds/overlaping-bound-suggestion.stderr index 61299550e98..2a308f83731 100644 --- a/tests/ui/associated-type-bounds/overlaping-bound-suggestion.stderr +++ b/tests/ui/associated-type-bounds/overlaping-bound-suggestion.stderr @@ -1,4 +1,4 @@ -error[E0191]: the value of the associated types `IntoIter` (from trait `IntoIterator`), `IntoIter` (from trait `IntoIterator`), `Item` (from trait `IntoIterator`), `Item` (from trait `IntoIterator`) must be specified +error[E0191]: the value of the associated types `Item`, `Item`, `IntoIter` and `IntoIter` in `IntoIterator` must be specified --> $DIR/overlaping-bound-suggestion.rs:7:13 | LL | inner: <IntoIterator<Item: IntoIterator<Item: >>::IntoIterator as Item>::Core, diff --git a/tests/ui/associated-types/associated-type-projection-from-multiple-supertraits.stderr b/tests/ui/associated-types/associated-type-projection-from-multiple-supertraits.stderr index 4f8954b80bc..66037054e06 100644 --- a/tests/ui/associated-types/associated-type-projection-from-multiple-supertraits.stderr +++ b/tests/ui/associated-types/associated-type-projection-from-multiple-supertraits.stderr @@ -45,7 +45,7 @@ LL | fn dent_object<COLOR>(c: dyn BoxCar<Color=COLOR>) { T: Vehicle::Color = COLOR, T: Box::Color = COLOR -error[E0191]: the value of the associated types `Color` (from trait `Box`), `Color` (from trait `Vehicle`) must be specified +error[E0191]: the value of the associated types `Color` in `Box`, `Color` in `Vehicle` must be specified --> $DIR/associated-type-projection-from-multiple-supertraits.rs:23:30 | LL | type Color; @@ -80,7 +80,7 @@ help: use fully-qualified syntax to disambiguate LL | fn paint<C:BoxCar>(c: C, d: <C as Box>::Color) { | ~~~~~~~~~~~~ -error[E0191]: the value of the associated types `Color` (from trait `Box`), `Color` (from trait `Vehicle`) must be specified +error[E0191]: the value of the associated types `Color` in `Box`, `Color` in `Vehicle` must be specified --> $DIR/associated-type-projection-from-multiple-supertraits.rs:32:32 | LL | type Color; diff --git a/tests/ui/associated-types/associated-types-incomplete-object.rs b/tests/ui/associated-types/associated-types-incomplete-object.rs index 4627dfd2b78..f6e4bdfbf37 100644 --- a/tests/ui/associated-types/associated-types-incomplete-object.rs +++ b/tests/ui/associated-types/associated-types-incomplete-object.rs @@ -21,11 +21,11 @@ pub fn main() { let a = &42isize as &dyn Foo<A=usize, B=char>; let b = &42isize as &dyn Foo<A=usize>; - //~^ ERROR the value of the associated type `B` (from trait `Foo`) must be specified + //~^ ERROR the value of the associated type `B` in `Foo` must be specified let c = &42isize as &dyn Foo<B=char>; - //~^ ERROR the value of the associated type `A` (from trait `Foo`) must be specified + //~^ ERROR the value of the associated type `A` in `Foo` must be specified let d = &42isize as &dyn Foo; - //~^ ERROR the value of the associated types `A` (from trait `Foo`), `B` (from trait + //~^ ERROR the value of the associated types `A` and `B` in `Foo` } diff --git a/tests/ui/associated-types/associated-types-incomplete-object.stderr b/tests/ui/associated-types/associated-types-incomplete-object.stderr index 32866c71468..0c9761afeb5 100644 --- a/tests/ui/associated-types/associated-types-incomplete-object.stderr +++ b/tests/ui/associated-types/associated-types-incomplete-object.stderr @@ -1,4 +1,4 @@ -error[E0191]: the value of the associated type `B` (from trait `Foo`) must be specified +error[E0191]: the value of the associated type `B` in `Foo` must be specified --> $DIR/associated-types-incomplete-object.rs:23:30 | LL | type B; @@ -7,7 +7,7 @@ LL | type B; LL | let b = &42isize as &dyn Foo<A=usize>; | ^^^^^^^^^^^^ help: specify the associated type: `Foo<A=usize, B = Type>` -error[E0191]: the value of the associated type `A` (from trait `Foo`) must be specified +error[E0191]: the value of the associated type `A` in `Foo` must be specified --> $DIR/associated-types-incomplete-object.rs:26:30 | LL | type A; @@ -16,7 +16,7 @@ LL | type A; LL | let c = &42isize as &dyn Foo<B=char>; | ^^^^^^^^^^^ help: specify the associated type: `Foo<B=char, A = Type>` -error[E0191]: the value of the associated types `A` (from trait `Foo`), `B` (from trait `Foo`) must be specified +error[E0191]: the value of the associated types `A` and `B` in `Foo` must be specified --> $DIR/associated-types-incomplete-object.rs:29:30 | LL | type A; diff --git a/tests/ui/associated-types/issue-22560.stderr b/tests/ui/associated-types/issue-22560.stderr index 2b88cf0b441..46e6e3951a5 100644 --- a/tests/ui/associated-types/issue-22560.stderr +++ b/tests/ui/associated-types/issue-22560.stderr @@ -9,7 +9,7 @@ LL | type Test = dyn Add + Sub; = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Add + Sub {}` = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits> -error[E0191]: the value of the associated types `Output` (from trait `Add`), `Output` (from trait `Sub`) must be specified +error[E0191]: the value of the associated types `Output` in `Add`, `Output` in `Sub` must be specified --> $DIR/issue-22560.rs:9:17 | LL | type Output; diff --git a/tests/ui/associated-types/issue-23595-1.stderr b/tests/ui/associated-types/issue-23595-1.stderr index 4307477a56a..3443c4925f4 100644 --- a/tests/ui/associated-types/issue-23595-1.stderr +++ b/tests/ui/associated-types/issue-23595-1.stderr @@ -1,4 +1,4 @@ -error[E0191]: the value of the associated types `ChildKey` (from trait `Hierarchy`), `Children` (from trait `Hierarchy`), `Value` (from trait `Hierarchy`) must be specified +error[E0191]: the value of the associated types `Value`, `ChildKey` and `Children` in `Hierarchy` must be specified --> $DIR/issue-23595-1.rs:8:58 | LL | type Value; diff --git a/tests/ui/associated-types/missing-associated-types.stderr b/tests/ui/associated-types/missing-associated-types.stderr index f617df984ae..e9669afe8c7 100644 --- a/tests/ui/associated-types/missing-associated-types.stderr +++ b/tests/ui/associated-types/missing-associated-types.stderr @@ -9,7 +9,7 @@ LL | type Foo<Rhs> = dyn Add<Rhs> + Sub<Rhs> + X<Rhs> + Y<Rhs>; = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Add<Rhs> + Sub<Rhs> + X<Rhs> + Y<Rhs> {}` = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits> -error[E0191]: the value of the associated types `A` (from trait `Y`), `Output` (from trait `Add`), `Output` (from trait `Mul`), `Output` (from trait `Sub`) must be specified +error[E0191]: the value of the associated types `A` in `Y`, `Output` in `Add`, `Output` in `Mul`, `Output` in `Sub` must be specified --> $DIR/missing-associated-types.rs:12:21 | LL | type A; @@ -38,7 +38,7 @@ LL | type Bar<Rhs> = dyn Add<Rhs> + Sub<Rhs> + X<Rhs> + Z<Rhs>; = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Add<Rhs> + Sub<Rhs> + X<Rhs> + Z<Rhs> {}` = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits> -error[E0191]: the value of the associated types `A` (from trait `Z`), `B` (from trait `Z`), `Output` (from trait `Add`), `Output` (from trait `Div`), `Output` (from trait `Div`), `Output` (from trait `Mul`), `Output` (from trait `Sub`) must be specified +error[E0191]: the value of the associated types `A` and `B` in `Z`, `Output` and `Output` in `Div`, `Output` in `Add`, `Output` in `Mul`, `Output` in `Sub` must be specified --> $DIR/missing-associated-types.rs:15:21 | LL | type A; @@ -74,7 +74,7 @@ LL | type Baz<Rhs> = dyn Add<Rhs> + Sub<Rhs> + Y<Rhs>; = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Add<Rhs> + Sub<Rhs> + Y<Rhs> {}` = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits> -error[E0191]: the value of the associated types `A` (from trait `Y`), `Output` (from trait `Add`), `Output` (from trait `Sub`) must be specified +error[E0191]: the value of the associated types `A` in `Y`, `Output` in `Add`, `Output` in `Sub` must be specified --> $DIR/missing-associated-types.rs:18:21 | LL | type A; @@ -102,7 +102,7 @@ LL | type Bat<Rhs> = dyn Add<Rhs> + Sub<Rhs> + Fine<Rhs>; = help: consider creating a new trait with all of these as supertraits and using that trait here instead: `trait NewTrait: Add<Rhs> + Sub<Rhs> + Fine<Rhs> {}` = note: auto-traits like `Send` and `Sync` are traits that have special properties; for more information on them, visit <https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits> -error[E0191]: the value of the associated types `Output` (from trait `Add`), `Output` (from trait `Sub`) must be specified +error[E0191]: the value of the associated types `Output` in `Add`, `Output` in `Sub` must be specified --> $DIR/missing-associated-types.rs:21:21 | LL | type Bat<Rhs> = dyn Add<Rhs> + Sub<Rhs> + Fine<Rhs>; @@ -115,7 +115,7 @@ help: specify the associated types LL | type Bat<Rhs> = dyn Add<Rhs, Output = Type> + Sub<Rhs, Output = Type> + Fine<Rhs>; | ~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~ -error[E0191]: the value of the associated types `Output` (from trait `Div`), `Output` (from trait `Mul`) must be specified +error[E0191]: the value of the associated types `Output` in `Div`, `Output` in `Mul` must be specified --> $DIR/missing-associated-types.rs:24:21 | LL | type Bal<Rhs> = dyn X<Rhs>; diff --git a/tests/ui/borrowck/alias-liveness/gat-static.rs b/tests/ui/borrowck/alias-liveness/gat-static.rs new file mode 100644 index 00000000000..92153124af9 --- /dev/null +++ b/tests/ui/borrowck/alias-liveness/gat-static.rs @@ -0,0 +1,29 @@ +// check-pass + +trait Foo { + type Assoc<'a> + where + Self: 'a; + + fn assoc(&mut self) -> Self::Assoc<'_>; +} + +fn overlapping_mut<T>(mut t: T) +where + T: Foo, + for<'a> T::Assoc<'a>: 'static, +{ + let a = t.assoc(); + let b = t.assoc(); +} + +fn live_past_borrow<T>(mut t: T) +where + T: Foo, + for<'a> T::Assoc<'a>: 'static { + let x = t.assoc(); + drop(t); + drop(x); +} + +fn main() {} diff --git a/tests/ui/borrowck/alias-liveness/higher-ranked-outlives-for-capture.rs b/tests/ui/borrowck/alias-liveness/higher-ranked-outlives-for-capture.rs new file mode 100644 index 00000000000..1f26c7babf2 --- /dev/null +++ b/tests/ui/borrowck/alias-liveness/higher-ranked-outlives-for-capture.rs @@ -0,0 +1,16 @@ +// known-bug: #42940 + +trait Captures<'a> {} +impl<T> Captures<'_> for T {} + +trait Outlives<'a>: 'a {} +impl<'a, T: 'a> Outlives<'a> for T {} + +// Test that we treat `for<'a> Opaque: 'a` as `Opaque: 'static` +fn test<'o>(v: &'o Vec<i32>) -> impl Captures<'o> + for<'a> Outlives<'a> {} + +fn statik() -> impl Sized { + test(&vec![]) +} + +fn main() {} diff --git a/tests/ui/borrowck/alias-liveness/higher-ranked-outlives-for-capture.stderr b/tests/ui/borrowck/alias-liveness/higher-ranked-outlives-for-capture.stderr new file mode 100644 index 00000000000..58a42d8afe4 --- /dev/null +++ b/tests/ui/borrowck/alias-liveness/higher-ranked-outlives-for-capture.stderr @@ -0,0 +1,16 @@ +error[E0716]: temporary value dropped while borrowed + --> $DIR/higher-ranked-outlives-for-capture.rs:13:11 + | +LL | test(&vec![]) + | ------^^^^^^- + | | | + | | creates a temporary value which is freed while still in use + | argument requires that borrow lasts for `'static` +LL | } + | - temporary value is freed at the end of this statement + | + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0716`. diff --git a/tests/ui/borrowck/alias-liveness/higher-ranked.rs b/tests/ui/borrowck/alias-liveness/higher-ranked.rs new file mode 100644 index 00000000000..afd0d3b31e3 --- /dev/null +++ b/tests/ui/borrowck/alias-liveness/higher-ranked.rs @@ -0,0 +1,16 @@ +// check-pass + +trait Captures<'a> {} +impl<T> Captures<'_> for T {} + +trait Outlives<'a>: 'a {} +impl<'a, T: 'a> Outlives<'a> for T {} + +// Test that we treat `for<'a> Opaque: 'a` as `Opaque: 'static` +fn test<'o>(v: &'o Vec<i32>) -> impl Captures<'o> + for<'a> Outlives<'a> {} + +fn opaque_doesnt_use_temporary() { + let a = test(&vec![]); +} + +fn main() {} diff --git a/tests/ui/borrowck/alias-liveness/opaque-capture.rs b/tests/ui/borrowck/alias-liveness/opaque-capture.rs new file mode 100644 index 00000000000..f4ca2728bdb --- /dev/null +++ b/tests/ui/borrowck/alias-liveness/opaque-capture.rs @@ -0,0 +1,17 @@ +// check-pass + +// Check that opaques capturing early and late-bound vars correctly mark +// regions required to be live using the item bounds. + +trait Captures<'a> {} +impl<T> Captures<'_> for T {} + +fn captures_temp_late<'a>(x: &'a Vec<i32>) -> impl Sized + Captures<'a> + 'static {} +fn captures_temp_early<'a: 'a>(x: &'a Vec<i32>) -> impl Sized + Captures<'a> + 'static {} + +fn test() { + let x = captures_temp_early(&vec![]); + let y = captures_temp_late(&vec![]); +} + +fn main() {} diff --git a/tests/ui/borrowck/alias-liveness/opaque-type-param.rs b/tests/ui/borrowck/alias-liveness/opaque-type-param.rs new file mode 100644 index 00000000000..a292463b2ac --- /dev/null +++ b/tests/ui/borrowck/alias-liveness/opaque-type-param.rs @@ -0,0 +1,14 @@ +// known-bug: #42940 + +trait Trait {} +impl Trait for () {} + +fn foo<'a>(s: &'a str) -> impl Trait + 'static { + bar(s) +} + +fn bar<P: AsRef<str>>(s: P) -> impl Trait + 'static { + () +} + +fn main() {} diff --git a/tests/ui/borrowck/alias-liveness/opaque-type-param.stderr b/tests/ui/borrowck/alias-liveness/opaque-type-param.stderr new file mode 100644 index 00000000000..e1fbbc14f44 --- /dev/null +++ b/tests/ui/borrowck/alias-liveness/opaque-type-param.stderr @@ -0,0 +1,13 @@ +error[E0700]: hidden type for `impl Trait + 'static` captures lifetime that does not appear in bounds + --> $DIR/opaque-type-param.rs:7:5 + | +LL | fn foo<'a>(s: &'a str) -> impl Trait + 'static { + | -- -------------------- opaque type defined here + | | + | hidden type `impl Trait + 'static` captures the lifetime `'a` as defined here +LL | bar(s) + | ^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0700`. diff --git a/tests/ui/borrowck/alias-liveness/rpit-static.rs b/tests/ui/borrowck/alias-liveness/rpit-static.rs new file mode 100644 index 00000000000..45da3edb878 --- /dev/null +++ b/tests/ui/borrowck/alias-liveness/rpit-static.rs @@ -0,0 +1,22 @@ +// check-pass + +trait Captures<'a> {} +impl<T> Captures<'_> for T {} + +fn foo(x: &mut i32) -> impl Sized + Captures<'_> + 'static {} + +fn overlapping_mut() { + let i = &mut 1; + let x = foo(i); + let y = foo(i); +} + +fn live_past_borrow() { + let y; + { + let x = &mut 1; + y = foo(x); + } +} + +fn main() {} diff --git a/tests/ui/borrowck/alias-liveness/rpitit-static.rs b/tests/ui/borrowck/alias-liveness/rpitit-static.rs new file mode 100644 index 00000000000..2cc68d2bf3d --- /dev/null +++ b/tests/ui/borrowck/alias-liveness/rpitit-static.rs @@ -0,0 +1,18 @@ +// check-pass + +trait Foo { + fn rpitit(&mut self) -> impl Sized + 'static; +} + +fn live_past_borrow<T: Foo>(mut t: T) { + let x = t.rpitit(); + drop(t); + drop(x); +} + +fn overlapping_mut<T: Foo>(mut t: T) { + let a = t.rpitit(); + let b = t.rpitit(); +} + +fn main() {} diff --git a/tests/ui/borrowck/alias-liveness/rtn-static.rs b/tests/ui/borrowck/alias-liveness/rtn-static.rs new file mode 100644 index 00000000000..1f136b8b998 --- /dev/null +++ b/tests/ui/borrowck/alias-liveness/rtn-static.rs @@ -0,0 +1,23 @@ +// check-pass + +#![feature(return_type_notation)] +//~^ WARN the feature `return_type_notation` is incomplete + +trait Foo { + fn borrow(&mut self) -> impl Sized + '_; +} + +fn live_past_borrow<T: Foo<borrow(): 'static>>(mut t: T) { + let x = t.borrow(); + drop(t); + drop(x); +} + +// Test that the `'_` item bound in `borrow` does not cause us to +// overlook the `'static` RTN bound. +fn overlapping_mut<T: Foo<borrow(): 'static>>(mut t: T) { + let x = t.borrow(); + let x = t.borrow(); +} + +fn main() {} diff --git a/tests/ui/borrowck/alias-liveness/rtn-static.stderr b/tests/ui/borrowck/alias-liveness/rtn-static.stderr new file mode 100644 index 00000000000..e9202db2c79 --- /dev/null +++ b/tests/ui/borrowck/alias-liveness/rtn-static.stderr @@ -0,0 +1,11 @@ +warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/rtn-static.rs:3:12 + | +LL | #![feature(return_type_notation)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/c-variadic/issue-86053-1.stderr b/tests/ui/c-variadic/issue-86053-1.stderr index 5a02f4aa93a..69e19e1d4d2 100644 --- a/tests/ui/c-variadic/issue-86053-1.stderr +++ b/tests/ui/c-variadic/issue-86053-1.stderr @@ -50,13 +50,7 @@ error: only foreign or `unsafe extern "C"` functions may be C-variadic --> $DIR/issue-86053-1.rs:11:12 | LL | self , ... , self , self , ... ) where F : FnOnce ( & 'a & 'b usize ) { - | ^^^ - -error: only foreign or `unsafe extern "C"` functions may be C-variadic - --> $DIR/issue-86053-1.rs:11:36 - | -LL | self , ... , self , self , ... ) where F : FnOnce ( & 'a & 'b usize ) { - | ^^^ + | ^^^ ^^^ error[E0412]: cannot find type `F` in this scope --> $DIR/issue-86053-1.rs:11:48 @@ -76,6 +70,6 @@ help: you might be missing a type parameter LL | fn ordering4 < 'a , 'b, F > ( a : , self , self , self , | +++ -error: aborting due to 11 previous errors +error: aborting due to 10 previous errors For more information about this error, try `rustc --explain E0412`. diff --git a/tests/ui/check-cfg/invalid-arguments.any_values.stderr b/tests/ui/check-cfg/invalid-arguments.any_values.stderr new file mode 100644 index 00000000000..f9a9c4a6e13 --- /dev/null +++ b/tests/ui/check-cfg/invalid-arguments.any_values.stderr @@ -0,0 +1,2 @@ +error: invalid `--check-cfg` argument: `cfg(any(),values())` (`values()` cannot be specified before the names) + diff --git a/tests/ui/check-cfg/invalid-arguments.rs b/tests/ui/check-cfg/invalid-arguments.rs index 79bef89c957..a56f48e0af9 100644 --- a/tests/ui/check-cfg/invalid-arguments.rs +++ b/tests/ui/check-cfg/invalid-arguments.rs @@ -6,7 +6,7 @@ // revisions: multiple_values_any not_empty_any not_empty_values_any // revisions: values_any_missing_values values_any_before_ident ident_in_values_1 // revisions: ident_in_values_2 unknown_meta_item_1 unknown_meta_item_2 unknown_meta_item_3 -// revisions: mixed_values_any mixed_any giberich +// revisions: mixed_values_any mixed_any any_values giberich unterminated // // compile-flags: -Z unstable-options // [anything_else]compile-flags: --check-cfg=anything_else(...) @@ -29,6 +29,8 @@ // [unknown_meta_item_3]compile-flags: --check-cfg=cfg(foo,values(test())) // [mixed_values_any]compile-flags: --check-cfg=cfg(foo,values("bar",any())) // [mixed_any]compile-flags: --check-cfg=cfg(any(),values(any())) +// [any_values]compile-flags: --check-cfg=cfg(any(),values()) // [giberich]compile-flags: --check-cfg=cfg(...) +// [unterminated]compile-flags: --check-cfg=cfg( fn main() {} diff --git a/tests/ui/check-cfg/invalid-arguments.unterminated.stderr b/tests/ui/check-cfg/invalid-arguments.unterminated.stderr new file mode 100644 index 00000000000..80161a6aa0f --- /dev/null +++ b/tests/ui/check-cfg/invalid-arguments.unterminated.stderr @@ -0,0 +1,2 @@ +error: invalid `--check-cfg` argument: `cfg(` (expected `cfg(name, values("value1", "value2", ... "valueN"))`) + diff --git a/tests/ui/const-generics/generic_const_exprs/object-safety-err-ret.stderr b/tests/ui/const-generics/generic_const_exprs/object-safety-err-ret.stderr index 7ce2b9ac95a..b7ec657120c 100644 --- a/tests/ui/const-generics/generic_const_exprs/object-safety-err-ret.stderr +++ b/tests/ui/const-generics/generic_const_exprs/object-safety-err-ret.stderr @@ -15,6 +15,7 @@ LL | fn test(&self) -> [u8; bar::<Self>()]; | ...because method `test` references the `Self` type in its `where` clause = help: consider moving `test` to another trait = help: consider moving `test` to another trait + = help: only type `()` implements the trait, consider using it directly instead error: aborting due to previous error diff --git a/tests/ui/consts/const-eval/issue-50814-2.mir-opt.stderr b/tests/ui/consts/const-eval/issue-50814-2.mir-opt.stderr new file mode 100644 index 00000000000..6454ce3d1ae --- /dev/null +++ b/tests/ui/consts/const-eval/issue-50814-2.mir-opt.stderr @@ -0,0 +1,21 @@ +error[E0080]: evaluation of `<A<()> as Foo<()>>::BAR` failed + --> $DIR/issue-50814-2.rs:16:24 + | +LL | const BAR: usize = [5, 6, 7][T::BOO]; + | ^^^^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 42 + +note: erroneous constant encountered + --> $DIR/issue-50814-2.rs:20:6 + | +LL | &<A<T> as Foo<T>>::BAR + | ^^^^^^^^^^^^^^^^^^^^^ + +note: erroneous constant encountered + --> $DIR/issue-50814-2.rs:20:5 + | +LL | &<A<T> as Foo<T>>::BAR + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/issue-50814-2.stderr b/tests/ui/consts/const-eval/issue-50814-2.normal.stderr index 450fb002373..c6b1df6c8f4 100644 --- a/tests/ui/consts/const-eval/issue-50814-2.stderr +++ b/tests/ui/consts/const-eval/issue-50814-2.normal.stderr @@ -1,17 +1,17 @@ error[E0080]: evaluation of `<A<()> as Foo<()>>::BAR` failed - --> $DIR/issue-50814-2.rs:14:24 + --> $DIR/issue-50814-2.rs:16:24 | LL | const BAR: usize = [5, 6, 7][T::BOO]; | ^^^^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 42 note: erroneous constant encountered - --> $DIR/issue-50814-2.rs:18:6 + --> $DIR/issue-50814-2.rs:20:6 | LL | &<A<T> as Foo<T>>::BAR | ^^^^^^^^^^^^^^^^^^^^^ note: the above error was encountered while instantiating `fn foo::<()>` - --> $DIR/issue-50814-2.rs:30:22 + --> $DIR/issue-50814-2.rs:32:22 | LL | println!("{:x}", foo::<()>() as *const usize as usize); | ^^^^^^^^^^^ diff --git a/tests/ui/consts/const-eval/issue-50814-2.rs b/tests/ui/consts/const-eval/issue-50814-2.rs index 53eb7b149f9..2eab93beb20 100644 --- a/tests/ui/consts/const-eval/issue-50814-2.rs +++ b/tests/ui/consts/const-eval/issue-50814-2.rs @@ -1,4 +1,6 @@ // build-fail +// revisions: normal mir-opt +// [mir-opt]compile-flags: -Zmir-opt-level=4 trait C { const BOO: usize; diff --git a/tests/ui/consts/const-eval/ub-enum.rs b/tests/ui/consts/const-eval/ub-enum.rs index 078283fbd1f..72a0c9efed2 100644 --- a/tests/ui/consts/const-eval/ub-enum.rs +++ b/tests/ui/consts/const-eval/ub-enum.rs @@ -2,7 +2,7 @@ // Strip out raw byte dumps to make comparison platform-independent: // 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] |╾─*a(lloc)?[0-9]+(\+[a-z0-9]+)?─*╼ )+ *│.*" -> "HEX_DUMP" -#![feature(never_type, const_discriminant)] +#![feature(never_type)] #![allow(invalid_value)] use std::mem; diff --git a/tests/ui/consts/const_discriminant.rs b/tests/ui/consts/const_discriminant.rs index b1180faa697..80deb0f784d 100644 --- a/tests/ui/consts/const_discriminant.rs +++ b/tests/ui/consts/const_discriminant.rs @@ -1,5 +1,4 @@ // run-pass -#![feature(const_discriminant)] #![allow(dead_code)] use std::mem::{discriminant, Discriminant}; diff --git a/tests/ui/coroutine/gen_block.e2024.stderr b/tests/ui/coroutine/gen_block.e2024.stderr new file mode 100644 index 00000000000..f250e2f79c7 --- /dev/null +++ b/tests/ui/coroutine/gen_block.e2024.stderr @@ -0,0 +1,19 @@ +error[E0658]: yield syntax is experimental + --> $DIR/gen_block.rs:15:16 + | +LL | let _ = || yield true; + | ^^^^^^^^^^ + | + = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information + = help: add `#![feature(coroutines)]` to the crate attributes to enable + +error[E0282]: type annotations needed + --> $DIR/gen_block.rs:6:17 + | +LL | let x = gen {}; + | ^^ cannot infer type + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0282, E0658. +For more information about an error, try `rustc --explain E0282`. diff --git a/tests/ui/coroutine/gen_block.none.stderr b/tests/ui/coroutine/gen_block.none.stderr new file mode 100644 index 00000000000..012a8308c7f --- /dev/null +++ b/tests/ui/coroutine/gen_block.none.stderr @@ -0,0 +1,49 @@ +error: expected identifier, found reserved keyword `yield` + --> $DIR/gen_block.rs:9:19 + | +LL | let y = gen { yield 42 }; + | --- ^^^^^ expected identifier, found reserved keyword + | | + | while parsing this struct + +error[E0422]: cannot find struct, variant or union type `gen` in this scope + --> $DIR/gen_block.rs:6:13 + | +LL | let x = gen {}; + | ^^^ not found in this scope + +error[E0422]: cannot find struct, variant or union type `gen` in this scope + --> $DIR/gen_block.rs:9:13 + | +LL | let y = gen { yield 42 }; + | ^^^ not found in this scope + +error[E0422]: cannot find struct, variant or union type `gen` in this scope + --> $DIR/gen_block.rs:12:5 + | +LL | gen {}; + | ^^^ not found in this scope + +error[E0658]: yield syntax is experimental + --> $DIR/gen_block.rs:15:16 + | +LL | let _ = || yield true; + | ^^^^^^^^^^ + | + = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information + = help: add `#![feature(coroutines)]` to the crate attributes to enable + +error[E0658]: yield syntax is experimental + --> $DIR/gen_block.rs:15:16 + | +LL | let _ = || yield true; + | ^^^^^^^^^^ + | + = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information + = help: add `#![feature(coroutines)]` to the crate attributes to enable + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 6 previous errors + +Some errors have detailed explanations: E0422, E0658. +For more information about an error, try `rustc --explain E0422`. diff --git a/tests/ui/coroutine/gen_block.rs b/tests/ui/coroutine/gen_block.rs new file mode 100644 index 00000000000..852c7c455a6 --- /dev/null +++ b/tests/ui/coroutine/gen_block.rs @@ -0,0 +1,17 @@ +// revisions: e2024 none +//[e2024] compile-flags: --edition 2024 -Zunstable-options +#![cfg_attr(e2024, feature(gen_blocks))] + +fn main() { + let x = gen {}; + //[none]~^ ERROR: cannot find + //[e2024]~^^ ERROR: type annotations needed + let y = gen { yield 42 }; + //[none]~^ ERROR: found reserved keyword `yield` + //[none]~| ERROR: cannot find + gen {}; + //[none]~^ ERROR: cannot find + + let _ = || yield true; //[none]~ ERROR yield syntax is experimental + //~^ ERROR yield syntax is experimental +} diff --git a/tests/ui/coroutine/gen_block_is_coro.rs b/tests/ui/coroutine/gen_block_is_coro.rs new file mode 100644 index 00000000000..c66ccefba85 --- /dev/null +++ b/tests/ui/coroutine/gen_block_is_coro.rs @@ -0,0 +1,18 @@ +//compile-flags: --edition 2024 -Zunstable-options +#![feature(coroutines, coroutine_trait, gen_blocks)] + +use std::ops::Coroutine; + +fn foo() -> impl Coroutine<Yield = u32, Return = ()> { //~ ERROR: Coroutine` is not satisfied + gen { yield 42 } +} + +fn bar() -> impl Coroutine<Yield = i64, Return = ()> { //~ ERROR: Coroutine` is not satisfied + gen { yield 42 } +} + +fn baz() -> impl Coroutine<Yield = i32, Return = ()> { //~ ERROR: Coroutine` is not satisfied + gen { yield 42 } +} + +fn main() {} diff --git a/tests/ui/coroutine/gen_block_is_coro.stderr b/tests/ui/coroutine/gen_block_is_coro.stderr new file mode 100644 index 00000000000..83a674fa53c --- /dev/null +++ b/tests/ui/coroutine/gen_block_is_coro.stderr @@ -0,0 +1,21 @@ +error[E0277]: the trait bound `{gen block@$DIR/gen_block_is_coro.rs:7:5: 7:21}: Coroutine` is not satisfied + --> $DIR/gen_block_is_coro.rs:6:13 + | +LL | fn foo() -> impl Coroutine<Yield = u32, Return = ()> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Coroutine` is not implemented for `{gen block@$DIR/gen_block_is_coro.rs:7:5: 7:21}` + +error[E0277]: the trait bound `{gen block@$DIR/gen_block_is_coro.rs:11:5: 11:21}: Coroutine` is not satisfied + --> $DIR/gen_block_is_coro.rs:10:13 + | +LL | fn bar() -> impl Coroutine<Yield = i64, Return = ()> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Coroutine` is not implemented for `{gen block@$DIR/gen_block_is_coro.rs:11:5: 11:21}` + +error[E0277]: the trait bound `{gen block@$DIR/gen_block_is_coro.rs:15:5: 15:21}: Coroutine` is not satisfied + --> $DIR/gen_block_is_coro.rs:14:13 + | +LL | fn baz() -> impl Coroutine<Yield = i32, Return = ()> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Coroutine` is not implemented for `{gen block@$DIR/gen_block_is_coro.rs:15:5: 15:21}` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/coroutine/gen_block_is_iter.rs b/tests/ui/coroutine/gen_block_is_iter.rs new file mode 100644 index 00000000000..92625cf7c28 --- /dev/null +++ b/tests/ui/coroutine/gen_block_is_iter.rs @@ -0,0 +1,19 @@ +// revisions: next old +//compile-flags: --edition 2024 -Zunstable-options +//[next] compile-flags: -Ztrait-solver=next +// check-pass +#![feature(gen_blocks)] + +fn foo() -> impl Iterator<Item = u32> { + gen { yield 42 } +} + +fn bar() -> impl Iterator<Item = i64> { + gen { yield 42 } +} + +fn baz() -> impl Iterator<Item = i32> { + gen { yield 42 } +} + +fn main() {} diff --git a/tests/ui/coroutine/gen_block_is_no_future.rs b/tests/ui/coroutine/gen_block_is_no_future.rs new file mode 100644 index 00000000000..94766519738 --- /dev/null +++ b/tests/ui/coroutine/gen_block_is_no_future.rs @@ -0,0 +1,8 @@ +//compile-flags: --edition 2024 -Zunstable-options +#![feature(gen_blocks)] + +fn foo() -> impl std::future::Future { //~ ERROR is not a future + gen { yield 42 } +} + +fn main() {} diff --git a/tests/ui/coroutine/gen_block_is_no_future.stderr b/tests/ui/coroutine/gen_block_is_no_future.stderr new file mode 100644 index 00000000000..db0c3c19b58 --- /dev/null +++ b/tests/ui/coroutine/gen_block_is_no_future.stderr @@ -0,0 +1,12 @@ +error[E0277]: `{gen block@$DIR/gen_block_is_no_future.rs:5:5: 5:21}` is not a future + --> $DIR/gen_block_is_no_future.rs:4:13 + | +LL | fn foo() -> impl std::future::Future { + | ^^^^^^^^^^^^^^^^^^^^^^^^ `{gen block@$DIR/gen_block_is_no_future.rs:5:5: 5:21}` is not a future + | + = help: the trait `Future` is not implemented for `{gen block@$DIR/gen_block_is_no_future.rs:5:5: 5:21}` + = note: {gen block@$DIR/gen_block_is_no_future.rs:5:5: 5:21} must be a future or must implement `IntoFuture` to be awaited + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/coroutine/gen_block_iterate.rs b/tests/ui/coroutine/gen_block_iterate.rs new file mode 100644 index 00000000000..18e1bb88772 --- /dev/null +++ b/tests/ui/coroutine/gen_block_iterate.rs @@ -0,0 +1,35 @@ +// revisions: next old +//compile-flags: --edition 2024 -Zunstable-options +//[next] compile-flags: -Ztrait-solver=next +// run-pass +#![feature(gen_blocks)] + +fn foo() -> impl Iterator<Item = u32> { + gen { yield 42; for x in 3..6 { yield x } } +} + +fn moved() -> impl Iterator<Item = u32> { + let mut x = "foo".to_string(); + gen move { + yield 42; + if x == "foo" { return } + x.clear(); + for x in 3..6 { yield x } + } +} + +fn main() { + let mut iter = foo(); + assert_eq!(iter.next(), Some(42)); + assert_eq!(iter.next(), Some(3)); + assert_eq!(iter.next(), Some(4)); + assert_eq!(iter.next(), Some(5)); + assert_eq!(iter.next(), None); + // `gen` blocks are fused + assert_eq!(iter.next(), None); + + let mut iter = moved(); + assert_eq!(iter.next(), Some(42)); + assert_eq!(iter.next(), None); + +} diff --git a/tests/ui/coroutine/gen_block_move.fixed b/tests/ui/coroutine/gen_block_move.fixed new file mode 100644 index 00000000000..5c6c8062322 --- /dev/null +++ b/tests/ui/coroutine/gen_block_move.fixed @@ -0,0 +1,17 @@ +// compile-flags: --edition 2024 -Zunstable-options +// run-rustfix +#![feature(gen_blocks)] + +fn moved() -> impl Iterator<Item = u32> { + let mut x = "foo".to_string(); + gen move { //~ ERROR: gen block may outlive the current function + yield 42; + if x == "foo" { return } + x.clear(); + for x in 3..6 { yield x } + } +} + +fn main() { + for _ in moved() {} +} diff --git a/tests/ui/coroutine/gen_block_move.rs b/tests/ui/coroutine/gen_block_move.rs new file mode 100644 index 00000000000..abbf8132476 --- /dev/null +++ b/tests/ui/coroutine/gen_block_move.rs @@ -0,0 +1,17 @@ +// compile-flags: --edition 2024 -Zunstable-options +// run-rustfix +#![feature(gen_blocks)] + +fn moved() -> impl Iterator<Item = u32> { + let mut x = "foo".to_string(); + gen { //~ ERROR: gen block may outlive the current function + yield 42; + if x == "foo" { return } + x.clear(); + for x in 3..6 { yield x } + } +} + +fn main() { + for _ in moved() {} +} diff --git a/tests/ui/coroutine/gen_block_move.stderr b/tests/ui/coroutine/gen_block_move.stderr new file mode 100644 index 00000000000..b93ac65f5e7 --- /dev/null +++ b/tests/ui/coroutine/gen_block_move.stderr @@ -0,0 +1,30 @@ +error[E0373]: gen block may outlive the current function, but it borrows `x`, which is owned by the current function + --> $DIR/gen_block_move.rs:7:5 + | +LL | / gen { +LL | | yield 42; +LL | | if x == "foo" { return } +LL | | x.clear(); + | | - `x` is borrowed here +LL | | for x in 3..6 { yield x } +LL | | } + | |_____^ may outlive borrowed value `x` + | +note: gen block is returned here + --> $DIR/gen_block_move.rs:7:5 + | +LL | / gen { +LL | | yield 42; +LL | | if x == "foo" { return } +LL | | x.clear(); +LL | | for x in 3..6 { yield x } +LL | | } + | |_____^ +help: to force the gen block to take ownership of `x` (and any other referenced variables), use the `move` keyword + | +LL | gen move { + | ++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0373`. diff --git a/tests/ui/coroutine/gen_block_panic.rs b/tests/ui/coroutine/gen_block_panic.rs new file mode 100644 index 00000000000..2da0eb512cc --- /dev/null +++ b/tests/ui/coroutine/gen_block_panic.rs @@ -0,0 +1,26 @@ +//compile-flags: --edition 2024 -Zunstable-options +// run-pass +// needs-unwind +#![feature(gen_blocks)] + +fn main() { + let mut iter = gen { + yield 42; + panic!("foo"); + yield 69; //~ WARN: unreachable statement + }; + assert_eq!(iter.next(), Some(42)); + let mut tmp = std::panic::AssertUnwindSafe(&mut iter); + match std::panic::catch_unwind(move || tmp.next()) { + Ok(_) => unreachable!(), + Err(err) => assert_eq!(*err.downcast::<&'static str>().unwrap(), "foo"), + } + + match std::panic::catch_unwind(move || iter.next()) { + Ok(_) => unreachable!(), + Err(err) => assert_eq!( + *err.downcast::<&'static str>().unwrap(), + "`gen fn` should just keep returning `None` after panicking", + ), + } +} diff --git a/tests/ui/coroutine/gen_block_panic.stderr b/tests/ui/coroutine/gen_block_panic.stderr new file mode 100644 index 00000000000..a0a6d1063c4 --- /dev/null +++ b/tests/ui/coroutine/gen_block_panic.stderr @@ -0,0 +1,12 @@ +warning: unreachable statement + --> $DIR/gen_block_panic.rs:10:9 + | +LL | panic!("foo"); + | ------------- any code following this expression is unreachable +LL | yield 69; + | ^^^^^^^^^ unreachable statement + | + = note: `#[warn(unreachable_code)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/coroutine/gen_fn.e2024.stderr b/tests/ui/coroutine/gen_fn.e2024.stderr new file mode 100644 index 00000000000..388e10fd65e --- /dev/null +++ b/tests/ui/coroutine/gen_fn.e2024.stderr @@ -0,0 +1,10 @@ +error: `gen` functions are not yet implemented + --> $DIR/gen_fn.rs:4:1 + | +LL | gen fn foo() {} + | ^^^ + | + = help: for now you can use `gen {}` blocks and return `impl Iterator` instead + +error: aborting due to previous error + diff --git a/tests/ui/coroutine/gen_fn.none.stderr b/tests/ui/coroutine/gen_fn.none.stderr new file mode 100644 index 00000000000..5e7bd9d8bbf --- /dev/null +++ b/tests/ui/coroutine/gen_fn.none.stderr @@ -0,0 +1,8 @@ +error: expected one of `#`, `async`, `const`, `default`, `extern`, `fn`, `pub`, `unsafe`, or `use`, found `gen` + --> $DIR/gen_fn.rs:4:1 + | +LL | gen fn foo() {} + | ^^^ expected one of 9 possible tokens + +error: aborting due to previous error + diff --git a/tests/ui/coroutine/gen_fn.rs b/tests/ui/coroutine/gen_fn.rs new file mode 100644 index 00000000000..da515f263b0 --- /dev/null +++ b/tests/ui/coroutine/gen_fn.rs @@ -0,0 +1,8 @@ +// revisions: e2024 none +//[e2024] compile-flags: --edition 2024 -Zunstable-options + +gen fn foo() {} +//[none]~^ ERROR: expected one of `#`, `async`, `const`, `default`, `extern`, `fn`, `pub`, `unsafe`, or `use`, found `gen` +//[e2024]~^^ ERROR: `gen` functions are not yet implemented + +fn main() {} diff --git a/tests/ui/coroutine/self_referential_gen_block.rs b/tests/ui/coroutine/self_referential_gen_block.rs new file mode 100644 index 00000000000..14daa2e9c35 --- /dev/null +++ b/tests/ui/coroutine/self_referential_gen_block.rs @@ -0,0 +1,17 @@ +// compile-flags: --edition 2024 -Zunstable-options +#![feature(gen_blocks)] +//! This test checks that we don't allow self-referential generators + +fn main() { + let mut x = { + let mut x = gen { + let y = 42; + let z = &y; //~ ERROR: borrow may still be in use when `gen` block yields + yield 43; + panic!("{z}"); + }; + x.next(); + Box::new(x) + }; + x.next(); +} diff --git a/tests/ui/coroutine/self_referential_gen_block.stderr b/tests/ui/coroutine/self_referential_gen_block.stderr new file mode 100644 index 00000000000..586f53df8f2 --- /dev/null +++ b/tests/ui/coroutine/self_referential_gen_block.stderr @@ -0,0 +1,11 @@ +error[E0626]: borrow may still be in use when `gen` block yields + --> $DIR/self_referential_gen_block.rs:9:21 + | +LL | let z = &y; + | ^^ +LL | yield 43; + | -------- possible yield occurs here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0626`. diff --git a/tests/ui/diagnostic_namespace/on_unimplemented/ignore_unsupported_options_and_continue_to_use_fallback.stderr b/tests/ui/diagnostic_namespace/on_unimplemented/ignore_unsupported_options_and_continue_to_use_fallback.stderr index 7860e540589..906472beb49 100644 --- a/tests/ui/diagnostic_namespace/on_unimplemented/ignore_unsupported_options_and_continue_to_use_fallback.stderr +++ b/tests/ui/diagnostic_namespace/on_unimplemented/ignore_unsupported_options_and_continue_to_use_fallback.stderr @@ -26,6 +26,7 @@ LL | takes_foo(()); | = help: the trait `Foo` is not implemented for `()` = note: custom note + = note: fallback note help: this trait has no implementations, consider adding one --> $DIR/ignore_unsupported_options_and_continue_to_use_fallback.rs:13:1 | diff --git a/tests/ui/diagnostic_namespace/on_unimplemented/multiple_notes.rs b/tests/ui/diagnostic_namespace/on_unimplemented/multiple_notes.rs new file mode 100644 index 00000000000..34cdb99c754 --- /dev/null +++ b/tests/ui/diagnostic_namespace/on_unimplemented/multiple_notes.rs @@ -0,0 +1,18 @@ +#![feature(diagnostic_namespace)] + +#[diagnostic::on_unimplemented(message = "Foo", label = "Bar", note = "Baz", note = "Boom")] +trait Foo {} + +#[diagnostic::on_unimplemented(message = "Bar", label = "Foo", note = "Baz")] +#[diagnostic::on_unimplemented(note = "Baz2")] +trait Bar {} + +fn takes_foo(_: impl Foo) {} +fn takes_bar(_: impl Bar) {} + +fn main() { + takes_foo(()); + //~^ERROR Foo + takes_bar(()); + //~^ERROR Bar +} diff --git a/tests/ui/diagnostic_namespace/on_unimplemented/multiple_notes.stderr b/tests/ui/diagnostic_namespace/on_unimplemented/multiple_notes.stderr new file mode 100644 index 00000000000..c72321d4617 --- /dev/null +++ b/tests/ui/diagnostic_namespace/on_unimplemented/multiple_notes.stderr @@ -0,0 +1,47 @@ +error[E0277]: Foo + --> $DIR/multiple_notes.rs:14:15 + | +LL | takes_foo(()); + | --------- ^^ Bar + | | + | required by a bound introduced by this call + | + = help: the trait `Foo` is not implemented for `()` + = note: Baz + = note: Boom +help: this trait has no implementations, consider adding one + --> $DIR/multiple_notes.rs:4:1 + | +LL | trait Foo {} + | ^^^^^^^^^ +note: required by a bound in `takes_foo` + --> $DIR/multiple_notes.rs:10:22 + | +LL | fn takes_foo(_: impl Foo) {} + | ^^^ required by this bound in `takes_foo` + +error[E0277]: Bar + --> $DIR/multiple_notes.rs:16:15 + | +LL | takes_bar(()); + | --------- ^^ Foo + | | + | required by a bound introduced by this call + | + = help: the trait `Bar` is not implemented for `()` + = note: Baz + = note: Baz2 +help: this trait has no implementations, consider adding one + --> $DIR/multiple_notes.rs:8:1 + | +LL | trait Bar {} + | ^^^^^^^^^ +note: required by a bound in `takes_bar` + --> $DIR/multiple_notes.rs:11:22 + | +LL | fn takes_bar(_: impl Bar) {} + | ^^^ required by this bound in `takes_bar` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/error-codes/E0191.stderr b/tests/ui/error-codes/E0191.stderr index cf80c9c46ca..57eda4785a9 100644 --- a/tests/ui/error-codes/E0191.stderr +++ b/tests/ui/error-codes/E0191.stderr @@ -1,4 +1,4 @@ -error[E0191]: the value of the associated type `Bar` (from trait `Trait`) must be specified +error[E0191]: the value of the associated type `Bar` in `Trait` must be specified --> $DIR/E0191.rs:5:16 | LL | type Bar; diff --git a/tests/ui/error-codes/E0220.stderr b/tests/ui/error-codes/E0220.stderr index e03eadacae4..0e0b5c7084c 100644 --- a/tests/ui/error-codes/E0220.stderr +++ b/tests/ui/error-codes/E0220.stderr @@ -4,7 +4,7 @@ error[E0220]: associated type `F` not found for `Trait` LL | type Foo = dyn Trait<F=i32>; | ^ help: `Trait` has the following associated type: `Bar` -error[E0191]: the value of the associated type `Bar` (from trait `Trait`) must be specified +error[E0191]: the value of the associated type `Bar` in `Trait` must be specified --> $DIR/E0220.rs:5:16 | LL | type Bar; diff --git a/tests/ui/error-codes/E0719.stderr b/tests/ui/error-codes/E0719.stderr index 685bd7175e3..00aea97139a 100644 --- a/tests/ui/error-codes/E0719.stderr +++ b/tests/ui/error-codes/E0719.stderr @@ -1,4 +1,4 @@ -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/E0719.rs:1:33 | LL | trait Foo: Iterator<Item = i32, Item = i32> {} @@ -6,7 +6,7 @@ LL | trait Foo: Iterator<Item = i32, Item = i32> {} | | | `Item` bound here first -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/E0719.rs:1:33 | LL | trait Foo: Iterator<Item = i32, Item = i32> {} @@ -16,7 +16,7 @@ LL | trait Foo: Iterator<Item = i32, Item = i32> {} | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0719]: the value of the associated type `Item` (from trait `Iterator`) is already specified +error[E0719]: the value of the associated type `Item` in trait `Iterator` is already specified --> $DIR/E0719.rs:7:42 | LL | fn test() -> Box<dyn Iterator<Item = (), Item = Unit>> { diff --git a/tests/ui/feature-gates/feature-gate-coroutines.stderr b/tests/ui/feature-gates/feature-gate-coroutines.e2024.stderr index dd561643901..2e529236ad8 100644 --- a/tests/ui/feature-gates/feature-gate-coroutines.stderr +++ b/tests/ui/feature-gates/feature-gate-coroutines.e2024.stderr @@ -1,5 +1,5 @@ error[E0658]: yield syntax is experimental - --> $DIR/feature-gate-coroutines.rs:2:5 + --> $DIR/feature-gate-coroutines.rs:5:5 | LL | yield true; | ^^^^^^^^^^ @@ -8,30 +8,21 @@ LL | yield true; = help: add `#![feature(coroutines)]` to the crate attributes to enable error[E0658]: yield syntax is experimental - --> $DIR/feature-gate-coroutines.rs:8:5 + --> $DIR/feature-gate-coroutines.rs:9:16 | -LL | yield; - | ^^^^^ - | - = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information - = help: add `#![feature(coroutines)]` to the crate attributes to enable - -error[E0658]: yield syntax is experimental - --> $DIR/feature-gate-coroutines.rs:9:5 - | -LL | yield 0; - | ^^^^^^^ +LL | let _ = || yield true; + | ^^^^^^^^^^ | = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information = help: add `#![feature(coroutines)]` to the crate attributes to enable error[E0627]: yield expression outside of coroutine literal - --> $DIR/feature-gate-coroutines.rs:2:5 + --> $DIR/feature-gate-coroutines.rs:5:5 | LL | yield true; | ^^^^^^^^^^ -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors Some errors have detailed explanations: E0627, E0658. For more information about an error, try `rustc --explain E0627`. diff --git a/tests/ui/feature-gates/feature-gate-coroutines.none.stderr b/tests/ui/feature-gates/feature-gate-coroutines.none.stderr new file mode 100644 index 00000000000..ab24805e467 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-coroutines.none.stderr @@ -0,0 +1,66 @@ +error[E0658]: yield syntax is experimental + --> $DIR/feature-gate-coroutines.rs:5:5 + | +LL | yield true; + | ^^^^^^^^^^ + | + = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information + = help: add `#![feature(coroutines)]` to the crate attributes to enable + +error[E0658]: yield syntax is experimental + --> $DIR/feature-gate-coroutines.rs:9:16 + | +LL | let _ = || yield true; + | ^^^^^^^^^^ + | + = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information + = help: add `#![feature(coroutines)]` to the crate attributes to enable + +error[E0658]: yield syntax is experimental + --> $DIR/feature-gate-coroutines.rs:16:5 + | +LL | yield; + | ^^^^^ + | + = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information + = help: add `#![feature(coroutines)]` to the crate attributes to enable + +error[E0658]: yield syntax is experimental + --> $DIR/feature-gate-coroutines.rs:17:5 + | +LL | yield 0; + | ^^^^^^^ + | + = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information + = help: add `#![feature(coroutines)]` to the crate attributes to enable + +error[E0658]: yield syntax is experimental + --> $DIR/feature-gate-coroutines.rs:5:5 + | +LL | yield true; + | ^^^^^^^^^^ + | + = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information + = help: add `#![feature(coroutines)]` to the crate attributes to enable + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0658]: yield syntax is experimental + --> $DIR/feature-gate-coroutines.rs:9:16 + | +LL | let _ = || yield true; + | ^^^^^^^^^^ + | + = note: see issue #43122 <https://github.com/rust-lang/rust/issues/43122> for more information + = help: add `#![feature(coroutines)]` to the crate attributes to enable + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0627]: yield expression outside of coroutine literal + --> $DIR/feature-gate-coroutines.rs:5:5 + | +LL | yield true; + | ^^^^^^^^^^ + +error: aborting due to 7 previous errors + +Some errors have detailed explanations: E0627, E0658. +For more information about an error, try `rustc --explain E0627`. diff --git a/tests/ui/feature-gates/feature-gate-coroutines.rs b/tests/ui/feature-gates/feature-gate-coroutines.rs index c3c5aec8824..53b58d486a8 100644 --- a/tests/ui/feature-gates/feature-gate-coroutines.rs +++ b/tests/ui/feature-gates/feature-gate-coroutines.rs @@ -1,10 +1,18 @@ +// revisions: e2024 none +//[e2024] compile-flags: --edition 2024 -Zunstable-options + fn main() { yield true; //~ ERROR yield syntax is experimental //~^ ERROR yield expression outside of coroutine literal + //[none]~^^ ERROR yield syntax is experimental + + let _ = || yield true; //~ ERROR yield syntax is experimental + //[none]~^ ERROR yield syntax is experimental } #[cfg(FALSE)] fn foo() { - yield; //~ ERROR yield syntax is experimental - yield 0; //~ ERROR yield syntax is experimental + // Ok in 2024 edition + yield; //[none]~ ERROR yield syntax is experimental + yield 0; //[none]~ ERROR yield syntax is experimental } diff --git a/tests/ui/feature-gates/feature-gate-dispatch-from-dyn-missing-impl.stderr b/tests/ui/feature-gates/feature-gate-dispatch-from-dyn-missing-impl.stderr index 303700c7ab4..00b8c0eef98 100644 --- a/tests/ui/feature-gates/feature-gate-dispatch-from-dyn-missing-impl.stderr +++ b/tests/ui/feature-gates/feature-gate-dispatch-from-dyn-missing-impl.stderr @@ -14,6 +14,7 @@ LL | trait Trait { | ----- this trait cannot be made into an object... LL | fn ptr(self: Ptr<Self>); | ^^^^^^^^^ ...because method `ptr`'s `self` parameter cannot be dispatched on + = help: only type `i32` implements the trait, consider using it directly instead error[E0038]: the trait `Trait` cannot be made into an object --> $DIR/feature-gate-dispatch-from-dyn-missing-impl.rs:32:5 @@ -31,6 +32,7 @@ LL | trait Trait { | ----- this trait cannot be made into an object... LL | fn ptr(self: Ptr<Self>); | ^^^^^^^^^ ...because method `ptr`'s `self` parameter cannot be dispatched on + = help: only type `i32` implements the trait, consider using it directly instead = note: required for the cast from `Ptr<{integer}>` to `Ptr<dyn Trait>` error: aborting due to 2 previous errors diff --git a/tests/ui/feature-gates/feature-gate-gen_blocks.e2024.stderr b/tests/ui/feature-gates/feature-gate-gen_blocks.e2024.stderr new file mode 100644 index 00000000000..1462c41e957 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-gen_blocks.e2024.stderr @@ -0,0 +1,28 @@ +error[E0658]: gen blocks are experimental + --> $DIR/feature-gate-gen_blocks.rs:5:5 + | +LL | gen {}; + | ^^^^^ + | + = note: see issue #117078 <https://github.com/rust-lang/rust/issues/117078> for more information + = help: add `#![feature(gen_blocks)]` to the crate attributes to enable + +error[E0658]: gen blocks are experimental + --> $DIR/feature-gate-gen_blocks.rs:13:5 + | +LL | gen {}; + | ^^^^^ + | + = note: see issue #117078 <https://github.com/rust-lang/rust/issues/117078> for more information + = help: add `#![feature(gen_blocks)]` to the crate attributes to enable + +error[E0282]: type annotations needed + --> $DIR/feature-gate-gen_blocks.rs:5:9 + | +LL | gen {}; + | ^^ cannot infer type + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0282, E0658. +For more information about an error, try `rustc --explain E0282`. diff --git a/tests/ui/feature-gates/feature-gate-gen_blocks.none.stderr b/tests/ui/feature-gates/feature-gate-gen_blocks.none.stderr new file mode 100644 index 00000000000..b448c35e846 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-gen_blocks.none.stderr @@ -0,0 +1,9 @@ +error[E0422]: cannot find struct, variant or union type `gen` in this scope + --> $DIR/feature-gate-gen_blocks.rs:5:5 + | +LL | gen {}; + | ^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0422`. diff --git a/tests/ui/feature-gates/feature-gate-gen_blocks.rs b/tests/ui/feature-gates/feature-gate-gen_blocks.rs new file mode 100644 index 00000000000..e2e1574a36a --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-gen_blocks.rs @@ -0,0 +1,15 @@ +// revisions: e2024 none +//[e2024] compile-flags: --edition 2024 -Zunstable-options + +fn main() { + gen {}; + //[none]~^ ERROR: cannot find struct, variant or union type `gen` + //[e2024]~^^ ERROR: gen blocks are experimental + //[e2024]~| ERROR: type annotations needed +} + +#[cfg(FALSE)] +fn foo() { + gen {}; + //[e2024]~^ ERROR: gen blocks are experimental +} diff --git a/tests/ui/feature-gates/feature-gate-precise_pointer_size_matching.rs b/tests/ui/feature-gates/feature-gate-precise_pointer_size_matching.rs index 4c77180b767..b4dc1fd4556 100644 --- a/tests/ui/feature-gates/feature-gate-precise_pointer_size_matching.rs +++ b/tests/ui/feature-gates/feature-gate-precise_pointer_size_matching.rs @@ -1,17 +1,17 @@ fn main() { match 0usize { - //~^ ERROR non-exhaustive patterns: `_` not covered - //~| NOTE pattern `_` not covered + //~^ ERROR non-exhaustive patterns: `usize::MAX..` not covered + //~| NOTE pattern `usize::MAX..` not covered //~| NOTE the matched value is of type `usize` //~| NOTE `usize` does not have a fixed maximum value 0..=usize::MAX => {} } match 0isize { - //~^ ERROR non-exhaustive patterns: `_` not covered - //~| NOTE pattern `_` not covered + //~^ ERROR non-exhaustive patterns: `..isize::MIN` and `isize::MAX..` not covered + //~| NOTE patterns `..isize::MIN` and `isize::MAX..` not covered //~| NOTE the matched value is of type `isize` - //~| NOTE `isize` does not have a fixed maximum value + //~| NOTE `isize` does not have fixed minimum and maximum values isize::MIN..=isize::MAX => {} } } diff --git a/tests/ui/feature-gates/feature-gate-precise_pointer_size_matching.stderr b/tests/ui/feature-gates/feature-gate-precise_pointer_size_matching.stderr index 853b57052ac..8694924e52f 100644 --- a/tests/ui/feature-gates/feature-gate-precise_pointer_size_matching.stderr +++ b/tests/ui/feature-gates/feature-gate-precise_pointer_size_matching.stderr @@ -1,31 +1,31 @@ -error[E0004]: non-exhaustive patterns: `_` not covered +error[E0004]: non-exhaustive patterns: `usize::MAX..` not covered --> $DIR/feature-gate-precise_pointer_size_matching.rs:2:11 | LL | match 0usize { - | ^^^^^^ pattern `_` not covered + | ^^^^^^ pattern `usize::MAX..` not covered | = note: the matched value is of type `usize` - = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ 0..=usize::MAX => {}, -LL + _ => todo!() +LL + usize::MAX.. => todo!() | -error[E0004]: non-exhaustive patterns: `_` not covered +error[E0004]: non-exhaustive patterns: `..isize::MIN` and `isize::MAX..` not covered --> $DIR/feature-gate-precise_pointer_size_matching.rs:10:11 | LL | match 0isize { - | ^^^^^^ pattern `_` not covered + | ^^^^^^ patterns `..isize::MIN` and `isize::MAX..` not covered | = note: the matched value is of type `isize` - = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | LL ~ isize::MIN..=isize::MAX => {}, -LL + _ => todo!() +LL + ..isize::MIN | isize::MAX.. => todo!() | error: aborting due to 2 previous errors 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 fd54faaf37c..9013d429530 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 @@ -12,6 +12,9 @@ LL | trait Foo { 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> error: aborting due to previous error diff --git a/tests/ui/generic-associated-types/issue-76535.base.stderr b/tests/ui/generic-associated-types/issue-76535.base.stderr index 370329b9f83..bb14e297174 100644 --- a/tests/ui/generic-associated-types/issue-76535.base.stderr +++ b/tests/ui/generic-associated-types/issue-76535.base.stderr @@ -28,6 +28,8 @@ LL | pub trait SuperTrait { LL | type SubType<'a>: SubTrait where Self: 'a; | ^^^^^^^ ...because it contains the generic associated type `SubType` = help: consider moving `SubType` to another trait + = help: only type `SuperStruct` is seen to implement the trait in this crate, consider using it directly instead + = note: `SuperTrait` can be implemented in other crates; if you want to support your users passing their own types here, you can't refer to a specific type error[E0038]: the trait `SuperTrait` cannot be made into an object --> $DIR/issue-76535.rs:39:57 @@ -43,6 +45,8 @@ LL | pub trait SuperTrait { LL | type SubType<'a>: SubTrait where Self: 'a; | ^^^^^^^ ...because it contains the generic associated type `SubType` = help: consider moving `SubType` to another trait + = help: only type `SuperStruct` is seen to implement the trait in this crate, consider using it directly instead + = note: `SuperTrait` can be implemented in other crates; if you want to support your users passing their own types here, you can't refer to a specific type = note: required for the cast from `Box<SuperStruct>` to `Box<dyn SuperTrait<SubType = SubStruct<'_>>>` error: aborting due to 3 previous errors diff --git a/tests/ui/generic-associated-types/issue-79422.base.stderr b/tests/ui/generic-associated-types/issue-79422.base.stderr index ad704f5e9f0..bcc6382cf7c 100644 --- a/tests/ui/generic-associated-types/issue-79422.base.stderr +++ b/tests/ui/generic-associated-types/issue-79422.base.stderr @@ -28,6 +28,9 @@ LL | trait MapLike<K, V> { 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 error[E0038]: the trait `MapLike` cannot be made into an object --> $DIR/issue-79422.rs:44:13 @@ -43,6 +46,9 @@ LL | trait MapLike<K, V> { 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 = 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/bivariant-lifetime-liveness.rs b/tests/ui/impl-trait/bivariant-lifetime-liveness.rs new file mode 100644 index 00000000000..fe99fe3f340 --- /dev/null +++ b/tests/ui/impl-trait/bivariant-lifetime-liveness.rs @@ -0,0 +1,15 @@ +// check-pass +// issue: 116794 + +// Uncaptured lifetimes should not be required to be live. + +struct Invariant<T>(*mut T); + +fn opaque<'a: 'a>(_: &'a str) -> Invariant<impl Sized> { + Invariant(&mut ()) +} + +fn main() { + let x = opaque(&String::new()); + drop(x); +} diff --git a/tests/ui/impl-trait/in-trait/foreign-dyn-error.stderr b/tests/ui/impl-trait/in-trait/foreign-dyn-error.stderr index bfb2be8cbc1..f29ec95d594 100644 --- a/tests/ui/impl-trait/in-trait/foreign-dyn-error.stderr +++ b/tests/ui/impl-trait/in-trait/foreign-dyn-error.stderr @@ -9,6 +9,7 @@ note: for a trait to be "object safe" it needs to allow building a vtable to all | LL | fn bar(self) -> impl Deref<Target = impl Sized>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait cannot be made into an object because method `bar` references an `impl Trait` type in its return type + = help: only type `rpitit::Foreign` implements the trait, consider using it directly instead error: aborting due to previous error diff --git a/tests/ui/impl-trait/in-trait/object-safety.stderr b/tests/ui/impl-trait/in-trait/object-safety.stderr index 3271cb18d9f..a7be0516cd3 100644 --- a/tests/ui/impl-trait/in-trait/object-safety.stderr +++ b/tests/ui/impl-trait/in-trait/object-safety.stderr @@ -12,6 +12,7 @@ LL | trait Foo { LL | fn baz(&self) -> impl Debug; | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type = help: consider moving `baz` to another trait + = help: only type `u32` implements the trait, consider using it directly instead error[E0038]: the trait `Foo` cannot be made into an object --> $DIR/object-safety.rs:17:15 @@ -27,6 +28,7 @@ LL | trait Foo { LL | fn baz(&self) -> impl Debug; | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type = help: consider moving `baz` to another trait + = help: only type `u32` implements the trait, consider using it directly instead error[E0038]: the trait `Foo` cannot be made into an object --> $DIR/object-safety.rs:17:13 @@ -42,6 +44,7 @@ LL | trait Foo { LL | fn baz(&self) -> impl Debug; | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type = help: consider moving `baz` to another trait + = help: only type `u32` implements the trait, consider using it directly instead error[E0038]: the trait `Foo` cannot be made into an object --> $DIR/object-safety.rs:14:13 @@ -57,6 +60,7 @@ LL | trait Foo { LL | fn baz(&self) -> impl Debug; | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type = help: consider moving `baz` to another trait + = help: only type `u32` implements the trait, consider using it directly instead = note: required for the cast from `Box<u32>` to `Box<dyn Foo>` error: aborting due to 4 previous errors diff --git a/tests/ui/impl-trait/object-unsafe-trait-in-return-position-dyn-trait.stderr b/tests/ui/impl-trait/object-unsafe-trait-in-return-position-dyn-trait.stderr index 687dbe65e6c..37c96d9bc4e 100644 --- a/tests/ui/impl-trait/object-unsafe-trait-in-return-position-dyn-trait.stderr +++ b/tests/ui/impl-trait/object-unsafe-trait-in-return-position-dyn-trait.stderr @@ -11,6 +11,9 @@ LL | trait NotObjectSafe { | ------------- this trait cannot be made into an object... LL | fn foo() -> Self; | ^^^ ...because associated function `foo` has no `self` parameter + = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `NotObjectSafe` for this new enum and using it instead: + A + B help: consider turning `foo` into a method by giving it a `&self` argument | LL | fn foo(&self) -> Self; @@ -33,6 +36,9 @@ LL | trait NotObjectSafe { | ------------- this trait cannot be made into an object... LL | fn foo() -> Self; | ^^^ ...because associated function `foo` has no `self` parameter + = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `NotObjectSafe` for this new enum and using it instead: + A + B help: consider turning `foo` into a method by giving it a `&self` argument | LL | fn foo(&self) -> Self; diff --git a/tests/ui/issues/issue-19380.stderr b/tests/ui/issues/issue-19380.stderr index 37e280fbcc7..f6244d9d44f 100644 --- a/tests/ui/issues/issue-19380.stderr +++ b/tests/ui/issues/issue-19380.stderr @@ -11,6 +11,7 @@ LL | trait Qiz { | --- this trait cannot be made into an object... LL | fn qiz(); | ^^^ ...because associated function `qiz` has no `self` parameter + = help: only type `Foo` implements the trait, consider using it directly instead help: consider turning `qiz` into a method by giving it a `&self` argument | LL | fn qiz(&self); @@ -33,6 +34,7 @@ LL | trait Qiz { | --- this trait cannot be made into an object... LL | fn qiz(); | ^^^ ...because associated function `qiz` has no `self` parameter + = help: only type `Foo` implements the trait, consider using it directly instead = note: required for the cast from `&Foo` to `&'static (dyn Qiz + 'static)` help: consider turning `qiz` into a method by giving it a `&self` argument | diff --git a/tests/ui/issues/issue-19482.rs b/tests/ui/issues/issue-19482.rs index 3f3c5de9b14..9d0c8d96d29 100644 --- a/tests/ui/issues/issue-19482.rs +++ b/tests/ui/issues/issue-19482.rs @@ -8,6 +8,6 @@ trait Foo { } fn bar(x: &dyn Foo) {} -//~^ ERROR the associated type `A` (from trait `Foo`) must be specified +//~^ ERROR the associated type `A` in `Foo` must be specified pub fn main() {} diff --git a/tests/ui/issues/issue-19482.stderr b/tests/ui/issues/issue-19482.stderr index d51cc1f081e..90e6f799560 100644 --- a/tests/ui/issues/issue-19482.stderr +++ b/tests/ui/issues/issue-19482.stderr @@ -1,4 +1,4 @@ -error[E0191]: the value of the associated type `A` (from trait `Foo`) must be specified +error[E0191]: the value of the associated type `A` in `Foo` must be specified --> $DIR/issue-19482.rs:10:16 | LL | type A; diff --git a/tests/ui/issues/issue-21950.stderr b/tests/ui/issues/issue-21950.stderr index 731615a6bd8..e498565d4e6 100644 --- a/tests/ui/issues/issue-21950.stderr +++ b/tests/ui/issues/issue-21950.stderr @@ -1,4 +1,4 @@ -error[E0191]: the value of the associated type `Output` (from trait `Add`) must be specified +error[E0191]: the value of the associated type `Output` in `Add` must be specified --> $DIR/issue-21950.rs:10:25 | LL | type Output; diff --git a/tests/ui/issues/issue-22434.rs b/tests/ui/issues/issue-22434.rs index 34057b46ecd..d9f7b987c64 100644 --- a/tests/ui/issues/issue-22434.rs +++ b/tests/ui/issues/issue-22434.rs @@ -3,6 +3,6 @@ pub trait Foo { } type I<'a> = &'a (dyn Foo + 'a); -//~^ ERROR the value of the associated type `A` (from trait `Foo`) must be specified +//~^ ERROR the value of the associated type `A` in `Foo` must be specified fn main() {} diff --git a/tests/ui/issues/issue-22434.stderr b/tests/ui/issues/issue-22434.stderr index b97fa2503b8..dab62bcbb4d 100644 --- a/tests/ui/issues/issue-22434.stderr +++ b/tests/ui/issues/issue-22434.stderr @@ -1,4 +1,4 @@ -error[E0191]: the value of the associated type `A` (from trait `Foo`) must be specified +error[E0191]: the value of the associated type `A` in `Foo` must be specified --> $DIR/issue-22434.rs:5:23 | LL | type A; diff --git a/tests/ui/issues/issue-23024.rs b/tests/ui/issues/issue-23024.rs index 010281ee371..25220dc3e61 100644 --- a/tests/ui/issues/issue-23024.rs +++ b/tests/ui/issues/issue-23024.rs @@ -8,5 +8,5 @@ fn main() println!("{:?}",(vfnfer[0] as dyn Fn)(3)); //~^ ERROR the precise format of `Fn`-family traits' //~| ERROR missing generics for trait `Fn` - //~| ERROR the value of the associated type `Output` (from trait `FnOnce`) + //~| ERROR the value of the associated type `Output` in `FnOnce` } diff --git a/tests/ui/issues/issue-23024.stderr b/tests/ui/issues/issue-23024.stderr index 2c325ffccee..7d187de1bc4 100644 --- a/tests/ui/issues/issue-23024.stderr +++ b/tests/ui/issues/issue-23024.stderr @@ -18,7 +18,7 @@ help: add missing generic argument LL | println!("{:?}",(vfnfer[0] as dyn Fn<Args>)(3)); | ++++++ -error[E0191]: the value of the associated type `Output` (from trait `FnOnce`) must be specified +error[E0191]: the value of the associated type `Output` in `FnOnce` must be specified --> $DIR/issue-23024.rs:8:39 | LL | println!("{:?}",(vfnfer[0] as dyn Fn)(3)); diff --git a/tests/ui/issues/issue-28344.stderr b/tests/ui/issues/issue-28344.stderr index f398a5da3e9..71d642109ac 100644 --- a/tests/ui/issues/issue-28344.stderr +++ b/tests/ui/issues/issue-28344.stderr @@ -12,7 +12,7 @@ help: use `dyn` LL | let x: u8 = <dyn BitXor>::bitor(0 as u8, 0 as u8); | ++++ + -error[E0191]: the value of the associated type `Output` (from trait `BitXor`) must be specified +error[E0191]: the value of the associated type `Output` in `BitXor` must be specified --> $DIR/issue-28344.rs:4:17 | LL | let x: u8 = BitXor::bitor(0 as u8, 0 as u8); @@ -40,7 +40,7 @@ help: use `dyn` LL | let g = <dyn BitXor>::bitor; | ++++ + -error[E0191]: the value of the associated type `Output` (from trait `BitXor`) must be specified +error[E0191]: the value of the associated type `Output` in `BitXor` must be specified --> $DIR/issue-28344.rs:10:13 | LL | let g = BitXor::bitor; diff --git a/tests/ui/issues/issue-37534.rs b/tests/ui/issues/issue-37534.rs index 1e67e9a8158..40f7186db09 100644 --- a/tests/ui/issues/issue-37534.rs +++ b/tests/ui/issues/issue-37534.rs @@ -1,6 +1,6 @@ -struct Foo<T: ?Hash> { } +struct Foo<T: ?Hash> {} //~^ ERROR expected trait, found derive macro `Hash` //~^^ ERROR parameter `T` is never used -//~^^^ WARN default bound relaxed for a type parameter, but this does nothing +//~^^^ WARN relaxing a default bound only does something for `?Sized` -fn main() { } +fn main() {} diff --git a/tests/ui/issues/issue-37534.stderr b/tests/ui/issues/issue-37534.stderr index 7d3dd8800bd..03fea2c1648 100644 --- a/tests/ui/issues/issue-37534.stderr +++ b/tests/ui/issues/issue-37534.stderr @@ -1,7 +1,7 @@ error[E0404]: expected trait, found derive macro `Hash` --> $DIR/issue-37534.rs:1:16 | -LL | struct Foo<T: ?Hash> { } +LL | struct Foo<T: ?Hash> {} | ^^^^ not a trait | help: consider importing this trait instead @@ -9,16 +9,16 @@ help: consider importing this trait instead LL + use std::hash::Hash; | -warning: default bound relaxed for a type parameter, but this does nothing because the given bound is not a default; only `?Sized` is supported - --> $DIR/issue-37534.rs:1:12 +warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default + --> $DIR/issue-37534.rs:1:15 | -LL | struct Foo<T: ?Hash> { } - | ^ +LL | struct Foo<T: ?Hash> {} + | ^^^^^ error[E0392]: parameter `T` is never used --> $DIR/issue-37534.rs:1:12 | -LL | struct Foo<T: ?Hash> { } +LL | struct Foo<T: ?Hash> {} | ^ unused parameter | = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` diff --git a/tests/ui/issues/issue-87199.rs b/tests/ui/issues/issue-87199.rs index a80a64a2f87..d16d4067673 100644 --- a/tests/ui/issues/issue-87199.rs +++ b/tests/ui/issues/issue-87199.rs @@ -6,11 +6,11 @@ // Check that these function definitions only emit warnings, not errors fn arg<T: ?Send>(_: T) {} -//~^ warning: default bound relaxed for a type parameter, but this does nothing +//~^ warning: relaxing a default bound only does something for `?Sized` fn ref_arg<T: ?Send>(_: &T) {} -//~^ warning: default bound relaxed for a type parameter, but this does nothing +//~^ warning: relaxing a default bound only does something for `?Sized` fn ret() -> impl Iterator<Item = ()> + ?Send { std::iter::empty() } -//~^ warning: default bound relaxed for a type parameter, but this does nothing +//~^ warning: relaxing a default bound only does something for `?Sized` // Check that there's no `?Sized` relaxation! fn main() { diff --git a/tests/ui/issues/issue-87199.stderr b/tests/ui/issues/issue-87199.stderr index 67949b37d40..e02cd7fcfa9 100644 --- a/tests/ui/issues/issue-87199.stderr +++ b/tests/ui/issues/issue-87199.stderr @@ -1,20 +1,20 @@ -warning: default bound relaxed for a type parameter, but this does nothing because the given bound is not a default; only `?Sized` is supported - --> $DIR/issue-87199.rs:8:8 +warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default + --> $DIR/issue-87199.rs:8:11 | LL | fn arg<T: ?Send>(_: T) {} - | ^ + | ^^^^^ -warning: default bound relaxed for a type parameter, but this does nothing because the given bound is not a default; only `?Sized` is supported - --> $DIR/issue-87199.rs:10:12 +warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default + --> $DIR/issue-87199.rs:10:15 | LL | fn ref_arg<T: ?Send>(_: &T) {} - | ^ + | ^^^^^ -warning: default bound relaxed for a type parameter, but this does nothing because the given bound is not a default; only `?Sized` is supported - --> $DIR/issue-87199.rs:12:13 +warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default + --> $DIR/issue-87199.rs:12:40 | LL | fn ret() -> impl Iterator<Item = ()> + ?Send { std::iter::empty() } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^ error[E0277]: the size for values of type `[i32]` cannot be known at compilation time --> $DIR/issue-87199.rs:18:15 diff --git a/tests/ui/layout/too-big-with-padding.rs b/tests/ui/layout/too-big-with-padding.rs new file mode 100644 index 00000000000..cf41ac872c2 --- /dev/null +++ b/tests/ui/layout/too-big-with-padding.rs @@ -0,0 +1,18 @@ +// build-fail +// compile-flags: --target i686-unknown-linux-gnu --crate-type lib +// needs-llvm-components: x86 +#![feature(no_core, lang_items)] +#![allow(internal_features)] +#![no_std] +#![no_core] + +// 0x7fffffff is fine, but after rounding up it becomes too big +#[repr(C, align(2))] +pub struct Example([u8; 0x7fffffff]); + +pub fn lib(_x: Example) {} //~ERROR: too big for the current architecture + +#[lang = "sized"] +pub trait Sized {} +#[lang = "copy"] +pub trait Copy: Sized {} diff --git a/tests/ui/layout/too-big-with-padding.stderr b/tests/ui/layout/too-big-with-padding.stderr new file mode 100644 index 00000000000..5cc854adce0 --- /dev/null +++ b/tests/ui/layout/too-big-with-padding.stderr @@ -0,0 +1,8 @@ +error: values of the type `Example` are too big for the current architecture + --> $DIR/too-big-with-padding.rs:13:1 + | +LL | pub fn lib(_x: Example) {} + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/lint/lint-unnecessary-parens.fixed b/tests/ui/lint/lint-unnecessary-parens.fixed index bafac05d8da..b17914da6e6 100644 --- a/tests/ui/lint/lint-unnecessary-parens.fixed +++ b/tests/ui/lint/lint-unnecessary-parens.fixed @@ -84,6 +84,14 @@ fn main() { _a = 0; //~ ERROR unnecessary parentheses around assigned value _a += 1; //~ ERROR unnecessary parentheses around assigned value + let mut _a = 3; //~ ERROR unnecessary parentheses around pattern + let mut _a = 3; //~ ERROR unnecessary parentheses around pattern + let mut _a = 3; //~ ERROR unnecessary parentheses around pattern + + let _a = 3; //~ ERROR unnecessary parentheses around pattern + let _a = 3; //~ ERROR unnecessary parentheses around pattern + let _a = 3; //~ ERROR unnecessary parentheses around pattern + let _a = baz!(3, 4); let _b = baz!(3); } diff --git a/tests/ui/lint/lint-unnecessary-parens.rs b/tests/ui/lint/lint-unnecessary-parens.rs index ce537a4dc1d..4cbd6562cd3 100644 --- a/tests/ui/lint/lint-unnecessary-parens.rs +++ b/tests/ui/lint/lint-unnecessary-parens.rs @@ -84,6 +84,14 @@ fn main() { _a = (0); //~ ERROR unnecessary parentheses around assigned value _a += (1); //~ ERROR unnecessary parentheses around assigned value + let(mut _a) = 3; //~ ERROR unnecessary parentheses around pattern + let (mut _a) = 3; //~ ERROR unnecessary parentheses around pattern + let( mut _a) = 3; //~ ERROR unnecessary parentheses around pattern + + let(_a) = 3; //~ ERROR unnecessary parentheses around pattern + let (_a) = 3; //~ ERROR unnecessary parentheses around pattern + let( _a) = 3; //~ ERROR unnecessary parentheses around pattern + let _a = baz!(3, 4); let _b = baz!(3); } diff --git a/tests/ui/lint/lint-unnecessary-parens.stderr b/tests/ui/lint/lint-unnecessary-parens.stderr index 2ad07530f8c..ba7a78b8da1 100644 --- a/tests/ui/lint/lint-unnecessary-parens.stderr +++ b/tests/ui/lint/lint-unnecessary-parens.stderr @@ -267,5 +267,77 @@ LL - _a += (1); LL + _a += 1; | -error: aborting due to 22 previous errors +error: unnecessary parentheses around pattern + --> $DIR/lint-unnecessary-parens.rs:87:8 + | +LL | let(mut _a) = 3; + | ^ ^ + | +help: remove these parentheses + | +LL - let(mut _a) = 3; +LL + let mut _a = 3; + | + +error: unnecessary parentheses around pattern + --> $DIR/lint-unnecessary-parens.rs:88:9 + | +LL | let (mut _a) = 3; + | ^ ^ + | +help: remove these parentheses + | +LL - let (mut _a) = 3; +LL + let mut _a = 3; + | + +error: unnecessary parentheses around pattern + --> $DIR/lint-unnecessary-parens.rs:89:8 + | +LL | let( mut _a) = 3; + | ^^ ^ + | +help: remove these parentheses + | +LL - let( mut _a) = 3; +LL + let mut _a = 3; + | + +error: unnecessary parentheses around pattern + --> $DIR/lint-unnecessary-parens.rs:91:8 + | +LL | let(_a) = 3; + | ^ ^ + | +help: remove these parentheses + | +LL - let(_a) = 3; +LL + let _a = 3; + | + +error: unnecessary parentheses around pattern + --> $DIR/lint-unnecessary-parens.rs:92:9 + | +LL | let (_a) = 3; + | ^ ^ + | +help: remove these parentheses + | +LL - let (_a) = 3; +LL + let _a = 3; + | + +error: unnecessary parentheses around pattern + --> $DIR/lint-unnecessary-parens.rs:93:8 + | +LL | let( _a) = 3; + | ^^ ^ + | +help: remove these parentheses + | +LL - let( _a) = 3; +LL + let _a = 3; + | + +error: aborting due to 28 previous errors diff --git a/tests/ui/lint/unused/issue-117284-arg-in-macro.rs b/tests/ui/lint/unused/issue-117284-arg-in-macro.rs new file mode 100644 index 00000000000..eea0f4c594d --- /dev/null +++ b/tests/ui/lint/unused/issue-117284-arg-in-macro.rs @@ -0,0 +1,17 @@ +#![deny(unused_variables)] +macro_rules! make_var { + ($struct:ident, $var:ident) => { + let $var = $struct.$var; + }; +} + +#[allow(unused)] +struct MyStruct { + var: i32, +} + +fn main() { + let s = MyStruct { var: 42 }; + make_var!(s, var); //~ ERROR unused variable: `var` + let a = 1; //~ ERROR unused variable: `a` +} diff --git a/tests/ui/lint/unused/issue-117284-arg-in-macro.stderr b/tests/ui/lint/unused/issue-117284-arg-in-macro.stderr new file mode 100644 index 00000000000..84efaa4f368 --- /dev/null +++ b/tests/ui/lint/unused/issue-117284-arg-in-macro.stderr @@ -0,0 +1,29 @@ +error: unused variable: `var` + --> $DIR/issue-117284-arg-in-macro.rs:15:18 + | +LL | make_var!(s, var); + | ^^^ + | +help: `var` is captured in macro and introduced a unused variable + --> $DIR/issue-117284-arg-in-macro.rs:4:13 + | +LL | let $var = $struct.$var; + | ^^^^ +... +LL | make_var!(s, var); + | ----------------- in this macro invocation +note: the lint level is defined here + --> $DIR/issue-117284-arg-in-macro.rs:1:9 + | +LL | #![deny(unused_variables)] + | ^^^^^^^^^^^^^^^^ + = note: this error originates in the macro `make_var` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: unused variable: `a` + --> $DIR/issue-117284-arg-in-macro.rs:16:9 + | +LL | let a = 1; + | ^ help: if this is intentional, prefix it with an underscore: `_a` + +error: aborting due to 2 previous errors + diff --git a/tests/ui/object-safety/assoc_type_bounds.rs b/tests/ui/object-safety/assoc_type_bounds.rs index 9abf7939c43..8634ba626a1 100644 --- a/tests/ui/object-safety/assoc_type_bounds.rs +++ b/tests/ui/object-safety/assoc_type_bounds.rs @@ -7,7 +7,7 @@ trait Foo<T> { trait Cake {} impl Cake for () {} -fn foo(_: &dyn Foo<()>) {} //~ ERROR: the value of the associated type `Bar` (from trait `Foo`) must be specified -fn bar(_: &dyn Foo<i32>) {} //~ ERROR: the value of the associated type `Bar` (from trait `Foo`) must be specified +fn foo(_: &dyn Foo<()>) {} //~ ERROR: the value of the associated type `Bar` in `Foo` must be specified +fn bar(_: &dyn Foo<i32>) {} //~ ERROR: the value of the associated type `Bar` in `Foo` must be specified fn main() {} diff --git a/tests/ui/object-safety/assoc_type_bounds.stderr b/tests/ui/object-safety/assoc_type_bounds.stderr index a1396dc3ad4..3d5482625af 100644 --- a/tests/ui/object-safety/assoc_type_bounds.stderr +++ b/tests/ui/object-safety/assoc_type_bounds.stderr @@ -1,4 +1,4 @@ -error[E0191]: the value of the associated type `Bar` (from trait `Foo`) must be specified +error[E0191]: the value of the associated type `Bar` in `Foo` must be specified --> $DIR/assoc_type_bounds.rs:10:16 | LL | type Bar @@ -7,7 +7,7 @@ LL | type Bar LL | fn foo(_: &dyn Foo<()>) {} | ^^^^^^^ help: specify the associated type: `Foo<(), Bar = Type>` -error[E0191]: the value of the associated type `Bar` (from trait `Foo`) must be specified +error[E0191]: the value of the associated type `Bar` in `Foo` must be specified --> $DIR/assoc_type_bounds.rs:11:16 | LL | type Bar diff --git a/tests/ui/object-safety/assoc_type_bounds2.rs b/tests/ui/object-safety/assoc_type_bounds2.rs index 0112123fd42..f7dc2fb8839 100644 --- a/tests/ui/object-safety/assoc_type_bounds2.rs +++ b/tests/ui/object-safety/assoc_type_bounds2.rs @@ -7,7 +7,7 @@ trait Foo<T> { trait Cake {} impl Cake for () {} -fn foo(_: &dyn Foo<()>) {} //~ ERROR: the value of the associated type `Bar` (from trait `Foo`) must be specified -fn bar(_: &dyn Foo<i32>) {} //~ ERROR: the value of the associated type `Bar` (from trait `Foo`) must be specified +fn foo(_: &dyn Foo<()>) {} //~ ERROR: the value of the associated type `Bar` in `Foo` must be specified +fn bar(_: &dyn Foo<i32>) {} //~ ERROR: the value of the associated type `Bar` in `Foo` must be specified fn main() {} diff --git a/tests/ui/object-safety/assoc_type_bounds2.stderr b/tests/ui/object-safety/assoc_type_bounds2.stderr index 7a3c0e02d48..815747436bf 100644 --- a/tests/ui/object-safety/assoc_type_bounds2.stderr +++ b/tests/ui/object-safety/assoc_type_bounds2.stderr @@ -1,4 +1,4 @@ -error[E0191]: the value of the associated type `Bar` (from trait `Foo`) must be specified +error[E0191]: the value of the associated type `Bar` in `Foo` must be specified --> $DIR/assoc_type_bounds2.rs:10:16 | LL | type Bar @@ -7,7 +7,7 @@ LL | type Bar LL | fn foo(_: &dyn Foo<()>) {} | ^^^^^^^ help: specify the associated type: `Foo<(), Bar = Type>` -error[E0191]: the value of the associated type `Bar` (from trait `Foo`) must be specified +error[E0191]: the value of the associated type `Bar` in `Foo` must be specified --> $DIR/assoc_type_bounds2.rs:11:16 | LL | type Bar diff --git a/tests/ui/object-safety/assoc_type_bounds_sized_others.rs b/tests/ui/object-safety/assoc_type_bounds_sized_others.rs index 647b72a759f..5b07bc92f32 100644 --- a/tests/ui/object-safety/assoc_type_bounds_sized_others.rs +++ b/tests/ui/object-safety/assoc_type_bounds_sized_others.rs @@ -10,7 +10,7 @@ trait Foo { } fn foo(_: &dyn Foo) {} -//~^ ERROR the value of the associated type `Bop` (from trait `Foo`) must be specified +//~^ ERROR the value of the associated type `Bop` in `Foo` must be specified trait Bar { type Bop; @@ -20,6 +20,6 @@ trait Bar { } fn bar(_: &dyn Bar) {} -//~^ ERROR the value of the associated type `Bop` (from trait `Bar`) must be specified +//~^ ERROR the value of the associated type `Bop` in `Bar` must be specified fn main() {} diff --git a/tests/ui/object-safety/assoc_type_bounds_sized_others.stderr b/tests/ui/object-safety/assoc_type_bounds_sized_others.stderr index e4c44334b34..5438faaaf05 100644 --- a/tests/ui/object-safety/assoc_type_bounds_sized_others.stderr +++ b/tests/ui/object-safety/assoc_type_bounds_sized_others.stderr @@ -1,4 +1,4 @@ -error[E0191]: the value of the associated type `Bop` (from trait `Foo`) must be specified +error[E0191]: the value of the associated type `Bop` in `Foo` must be specified --> $DIR/assoc_type_bounds_sized_others.rs:12:16 | LL | type Bop; @@ -7,7 +7,7 @@ LL | type Bop; LL | fn foo(_: &dyn Foo) {} | ^^^ help: specify the associated type: `Foo<Bop = Type>` -error[E0191]: the value of the associated type `Bop` (from trait `Bar`) must be specified +error[E0191]: the value of the associated type `Bop` in `Bar` must be specified --> $DIR/assoc_type_bounds_sized_others.rs:22:16 | LL | type Bop; diff --git a/tests/ui/object-safety/issue-19538.stderr b/tests/ui/object-safety/issue-19538.stderr index 183245b2322..31657501e25 100644 --- a/tests/ui/object-safety/issue-19538.stderr +++ b/tests/ui/object-safety/issue-19538.stderr @@ -13,6 +13,7 @@ LL | fn foo<T>(&self, val: T); LL | trait Bar: Foo { } | --- this trait cannot be made into an object... = help: consider moving `foo` to another trait + = help: only type `Thing` implements the trait, consider using it directly instead error[E0038]: the trait `Bar` cannot be made into an object --> $DIR/issue-19538.rs:17:30 @@ -29,6 +30,7 @@ LL | fn foo<T>(&self, val: T); LL | trait Bar: Foo { } | --- this trait cannot be made into an object... = help: consider moving `foo` to another trait + = help: only type `Thing` implements the trait, consider using it directly instead = note: required for the cast from `&mut Thing` to `&mut dyn Bar` error: aborting due to 2 previous errors diff --git a/tests/ui/object-safety/object-safety-issue-22040.stderr b/tests/ui/object-safety/object-safety-issue-22040.stderr index 0262d536246..2e59d88bdaf 100644 --- a/tests/ui/object-safety/object-safety-issue-22040.stderr +++ b/tests/ui/object-safety/object-safety-issue-22040.stderr @@ -11,6 +11,7 @@ LL | trait Expr: Debug + PartialEq { | ---- ^^^^^^^^^ ...because it uses `Self` as a type parameter | | | this trait cannot be made into an object... + = help: only type `SExpr<'x>` implements the trait, consider using it directly instead error: aborting due to previous error diff --git a/tests/ui/object-safety/object-safety-no-static.curr.stderr b/tests/ui/object-safety/object-safety-no-static.curr.stderr index 1b025229e54..b40470b457b 100644 --- a/tests/ui/object-safety/object-safety-no-static.curr.stderr +++ b/tests/ui/object-safety/object-safety-no-static.curr.stderr @@ -11,6 +11,7 @@ LL | trait Foo { | --- this trait cannot be made into an object... LL | fn foo() {} | ^^^ ...because associated function `foo` has no `self` parameter + = help: only type `Bar` implements the trait, consider using it directly instead help: consider turning `foo` into a method by giving it a `&self` argument | LL | fn foo(&self) {} diff --git a/tests/ui/object-safety/object-safety-no-static.object_safe_for_dispatch.stderr b/tests/ui/object-safety/object-safety-no-static.object_safe_for_dispatch.stderr index befcef952a8..1eae9a9b9da 100644 --- a/tests/ui/object-safety/object-safety-no-static.object_safe_for_dispatch.stderr +++ b/tests/ui/object-safety/object-safety-no-static.object_safe_for_dispatch.stderr @@ -11,6 +11,7 @@ LL | trait Foo { | --- this trait cannot be made into an object... LL | fn foo() {} | ^^^ ...because associated function `foo` has no `self` parameter + = help: only type `Bar` implements the trait, consider using it directly instead = note: required for the cast from `Box<Bar>` to `Box<dyn Foo>` help: consider turning `foo` into a method by giving it a `&self` argument | diff --git a/tests/ui/offset-of/offset-of-enum.rs b/tests/ui/offset-of/offset-of-enum.rs index d73505821ff..e8b5a08377b 100644 --- a/tests/ui/offset-of/offset-of-enum.rs +++ b/tests/ui/offset-of/offset-of-enum.rs @@ -9,5 +9,10 @@ enum Alpha { fn main() { offset_of!(Alpha::One, 0); //~ ERROR expected type, found variant `Alpha::One` - offset_of!(Alpha, Two.0); //~ ERROR no field `Two` on type `Alpha` + offset_of!(Alpha, One); //~ ERROR `One` is an enum variant; expected field at end of `offset_of` + offset_of!(Alpha, Two.0); + offset_of!(Alpha, Two.1); //~ ERROR no field named `1` on enum variant `Alpha::Two` + offset_of!(Alpha, Two.foo); //~ ERROR no field named `foo` on enum variant `Alpha::Two` + offset_of!(Alpha, NonExistent); //~ ERROR no variant named `NonExistent` found for enum `Alpha` + offset_of!(Beta, One); //~ ERROR cannot find type `Beta` in this scope } diff --git a/tests/ui/offset-of/offset-of-enum.stderr b/tests/ui/offset-of/offset-of-enum.stderr index 6958d199fbd..7e7ad41f5b6 100644 --- a/tests/ui/offset-of/offset-of-enum.stderr +++ b/tests/ui/offset-of/offset-of-enum.stderr @@ -7,13 +7,41 @@ LL | offset_of!(Alpha::One, 0); | not a type | help: try using the variant's enum: `Alpha` -error[E0609]: no field `Two` on type `Alpha` +error[E0412]: cannot find type `Beta` in this scope + --> $DIR/offset-of-enum.rs:17:16 + | +LL | offset_of!(Beta, One); + | ^^^^ not found in this scope + +error[E0795]: `One` is an enum variant; expected field at end of `offset_of` --> $DIR/offset-of-enum.rs:12:23 | -LL | offset_of!(Alpha, Two.0); - | ^^^ +LL | offset_of!(Alpha, One); + | ^^^ enum variant + +error[E0609]: no field named `1` on enum variant `Alpha::Two` + --> $DIR/offset-of-enum.rs:14:23 + | +LL | offset_of!(Alpha, Two.1); + | ^^^ - ...does not have this field + | | + | this enum variant... + +error[E0609]: no field named `foo` on enum variant `Alpha::Two` + --> $DIR/offset-of-enum.rs:15:23 + | +LL | offset_of!(Alpha, Two.foo); + | ^^^ --- ...does not have this field + | | + | this enum variant... + +error[E0599]: no variant named `NonExistent` found for enum `Alpha` + --> $DIR/offset-of-enum.rs:16:23 + | +LL | offset_of!(Alpha, NonExistent); + | ^^^^^^^^^^^ variant not found -error: aborting due to 2 previous errors +error: aborting due to 6 previous errors -Some errors have detailed explanations: E0573, E0609. -For more information about an error, try `rustc --explain E0573`. +Some errors have detailed explanations: E0412, E0573, E0599, E0609, E0795. +For more information about an error, try `rustc --explain E0412`. diff --git a/tests/ui/offset-of/offset-of-private.rs b/tests/ui/offset-of/offset-of-private.rs index 6b1a16ba62b..6fa30d63fb8 100644 --- a/tests/ui/offset-of/offset-of-private.rs +++ b/tests/ui/offset-of/offset-of-private.rs @@ -8,13 +8,20 @@ mod m { pub public: u8, private: u8, } + #[repr(C)] pub struct FooTuple(pub u8, u8); + #[repr(C)] struct Bar { pub public: u8, private: u8, } + + pub enum Baz { + Var1(Foo), + Var2(u64), + } } fn main() { @@ -25,4 +32,8 @@ fn main() { offset_of!(m::Bar, public); //~ ERROR struct `Bar` is private offset_of!(m::Bar, private); //~ ERROR struct `Bar` is private //~| ERROR field `private` of struct `Bar` is private + + offset_of!(m::Baz, Var1.0.public); + offset_of!(m::Baz, Var1.0.private); //~ ERROR field `private` of struct `Foo` is private + offset_of!(m::Baz, Var2.0); } diff --git a/tests/ui/offset-of/offset-of-private.stderr b/tests/ui/offset-of/offset-of-private.stderr index 0674b58f860..930e30e6390 100644 --- a/tests/ui/offset-of/offset-of-private.stderr +++ b/tests/ui/offset-of/offset-of-private.stderr @@ -1,46 +1,52 @@ error[E0603]: struct `Bar` is private - --> $DIR/offset-of-private.rs:25:19 + --> $DIR/offset-of-private.rs:32:19 | LL | offset_of!(m::Bar, public); | ^^^ private struct | note: the struct `Bar` is defined here - --> $DIR/offset-of-private.rs:14:5 + --> $DIR/offset-of-private.rs:16:5 | LL | struct Bar { | ^^^^^^^^^^ error[E0603]: struct `Bar` is private - --> $DIR/offset-of-private.rs:26:19 + --> $DIR/offset-of-private.rs:33:19 | LL | offset_of!(m::Bar, private); | ^^^ private struct | note: the struct `Bar` is defined here - --> $DIR/offset-of-private.rs:14:5 + --> $DIR/offset-of-private.rs:16:5 | LL | struct Bar { | ^^^^^^^^^^ error[E0616]: field `private` of struct `Foo` is private - --> $DIR/offset-of-private.rs:22:24 + --> $DIR/offset-of-private.rs:29:24 | LL | offset_of!(m::Foo, private); | ^^^^^^^ private field error[E0616]: field `1` of struct `FooTuple` is private - --> $DIR/offset-of-private.rs:24:29 + --> $DIR/offset-of-private.rs:31:29 | LL | offset_of!(m::FooTuple, 1); | ^ private field error[E0616]: field `private` of struct `Bar` is private - --> $DIR/offset-of-private.rs:26:24 + --> $DIR/offset-of-private.rs:33:24 | LL | offset_of!(m::Bar, private); | ^^^^^^^ private field -error: aborting due to 5 previous errors +error[E0616]: field `private` of struct `Foo` is private + --> $DIR/offset-of-private.rs:37:31 + | +LL | offset_of!(m::Baz, Var1.0.private); + | ^^^^^^^ private field + +error: aborting due to 6 previous errors Some errors have detailed explanations: E0603, E0616. For more information about an error, try `rustc --explain E0603`. diff --git a/tests/ui/or-patterns/exhaustiveness-pass.rs b/tests/ui/or-patterns/exhaustiveness-pass.rs index e8c8a0e7ba5..428b9a19fe6 100644 --- a/tests/ui/or-patterns/exhaustiveness-pass.rs +++ b/tests/ui/or-patterns/exhaustiveness-pass.rs @@ -35,4 +35,10 @@ fn main() { ((0, 0) | (1, 0),) => {} _ => {} } + + // This one caused ICE https://github.com/rust-lang/rust/issues/117378 + match (0u8, 0) { + (x @ 0 | x @ (1 | 2), _) => {} + (3.., _) => {} + } } diff --git a/tests/ui/parser/diff-markers/unclosed-delims-in-macro.rs b/tests/ui/parser/diff-markers/unclosed-delims-in-macro.rs new file mode 100644 index 00000000000..da1774acea5 --- /dev/null +++ b/tests/ui/parser/diff-markers/unclosed-delims-in-macro.rs @@ -0,0 +1,9 @@ +macro_rules! foo { +<<<<<<< HEAD + //~^ ERROR encountered diff marker + () { +======= + () { // +>>>>>>> 7a4f13c blah blah blah + } +} diff --git a/tests/ui/parser/diff-markers/unclosed-delims-in-macro.stderr b/tests/ui/parser/diff-markers/unclosed-delims-in-macro.stderr new file mode 100644 index 00000000000..e0b6f1b5eb8 --- /dev/null +++ b/tests/ui/parser/diff-markers/unclosed-delims-in-macro.stderr @@ -0,0 +1,18 @@ +error: encountered diff marker + --> $DIR/unclosed-delims-in-macro.rs:2:1 + | +LL | <<<<<<< HEAD + | ^^^^^^^ after this is the code before the merge +... +LL | ======= + | ------- +LL | () { // +LL | >>>>>>> 7a4f13c blah blah blah + | ^^^^^^^ above this are the incoming code changes + | + = help: if you're having merge conflicts after pulling new code, the top section is the code you already had and the bottom section is the remote code + = help: if you're in the middle of a rebase, the top section is the code being rebased onto and the bottom section is the code coming from the current commit being rebased + = note: for an explanation on these markers from the `git` documentation, visit <https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging#_checking_out_conflicts> + +error: aborting due to previous error + diff --git a/tests/ui/parser/diff-markers/unclosed-delims.rs b/tests/ui/parser/diff-markers/unclosed-delims.rs new file mode 100644 index 00000000000..653a605c28c --- /dev/null +++ b/tests/ui/parser/diff-markers/unclosed-delims.rs @@ -0,0 +1,14 @@ +mod tests { + #[test] +<<<<<<< HEAD +//~^ ERROR encountered diff marker +//~| NOTE after this is the code before the merge +//~| NOTE for an explanation on these markers + fn test1() { +======= +//~^ NOTE + fn test2() { +>>>>>>> 7a4f13c blah blah blah +//~^ NOTE above this are the incoming code changes + } +} diff --git a/tests/ui/parser/diff-markers/unclosed-delims.stderr b/tests/ui/parser/diff-markers/unclosed-delims.stderr new file mode 100644 index 00000000000..67199179b39 --- /dev/null +++ b/tests/ui/parser/diff-markers/unclosed-delims.stderr @@ -0,0 +1,18 @@ +error: encountered diff marker + --> $DIR/unclosed-delims.rs:3:1 + | +LL | <<<<<<< HEAD + | ^^^^^^^ after this is the code before the merge +... +LL | ======= + | ------- +... +LL | >>>>>>> 7a4f13c blah blah blah + | ^^^^^^^ above this are the incoming code changes + | + = help: if you're having merge conflicts after pulling new code, the top section is the code you already had and the bottom section is the remote code + = help: if you're in the middle of a rebase, the top section is the code being rebased onto and the bottom section is the code coming from the current commit being rebased + = note: for an explanation on these markers from the `git` documentation, visit <https://git-scm.com/book/en/v2/Git-Tools-Advanced-Merging#_checking_out_conflicts> + +error: aborting due to previous error + diff --git a/tests/ui/parser/issue-116781.rs b/tests/ui/parser/issue-116781.rs new file mode 100644 index 00000000000..0e951d2eaa4 --- /dev/null +++ b/tests/ui/parser/issue-116781.rs @@ -0,0 +1,8 @@ +#[derive(Debug)] +struct Foo { + #[cfg(all())] + field: fn(($),), //~ ERROR expected pattern, found `$` + //~^ ERROR expected pattern, found `$` +} + +fn main() {} diff --git a/tests/ui/parser/issue-116781.stderr b/tests/ui/parser/issue-116781.stderr new file mode 100644 index 00000000000..1a77b60a50d --- /dev/null +++ b/tests/ui/parser/issue-116781.stderr @@ -0,0 +1,16 @@ +error: expected pattern, found `$` + --> $DIR/issue-116781.rs:4:16 + | +LL | field: fn(($),), + | ^ expected pattern + +error: expected pattern, found `$` + --> $DIR/issue-116781.rs:4:16 + | +LL | field: fn(($),), + | ^ expected pattern + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 2 previous errors + diff --git a/tests/ui/parser/variadic-ffi-semantic-restrictions.rs b/tests/ui/parser/variadic-ffi-semantic-restrictions.rs index 0b61e267da8..b173e23e7a1 100644 --- a/tests/ui/parser/variadic-ffi-semantic-restrictions.rs +++ b/tests/ui/parser/variadic-ffi-semantic-restrictions.rs @@ -32,6 +32,18 @@ extern "C" fn f3_3(..., x: isize) {} //~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic //~| ERROR `...` must be the last argument of a C-variadic function +const unsafe extern "C" fn f4_1(x: isize, ...) {} +//~^ ERROR functions cannot be both `const` and C-variadic + +const extern "C" fn f4_2(x: isize, ...) {} +//~^ ERROR functions cannot be both `const` and C-variadic +//~| ERROR only foreign or `unsafe extern "C"` functions may be C-variadic + +const extern "C" fn f4_3(..., x: isize, ...) {} +//~^ ERROR functions cannot be both `const` and C-variadic +//~| ERROR only foreign or `unsafe extern "C"` functions may be C-variadic +//~| ERROR `...` must be the last argument of a C-variadic function + extern "C" { fn e_f1(...); //~^ ERROR C-variadic function must be declared with at least one named argument @@ -49,12 +61,13 @@ impl X { //~| ERROR C-variadic function must be declared with at least one named argument fn i_f3(..., x: isize, ...) {} //~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic - //~| ERROR only foreign or `unsafe extern "C"` functions may be C-variadic //~| ERROR `...` must be the last argument of a C-variadic function fn i_f4(..., x: isize, ...) {} //~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic - //~| ERROR only foreign or `unsafe extern "C"` functions may be C-variadic //~| ERROR `...` must be the last argument of a C-variadic function + const fn i_f5(x: isize, ...) {} + //~^ ERROR only foreign or `unsafe extern "C"` functions may be C-variadic + //~| ERROR functions cannot be both `const` and C-variadic } trait T { diff --git a/tests/ui/parser/variadic-ffi-semantic-restrictions.stderr b/tests/ui/parser/variadic-ffi-semantic-restrictions.stderr index f1cbbb279c8..18526080e4c 100644 --- a/tests/ui/parser/variadic-ffi-semantic-restrictions.stderr +++ b/tests/ui/parser/variadic-ffi-semantic-restrictions.stderr @@ -76,131 +76,172 @@ error: only foreign or `unsafe extern "C"` functions may be C-variadic LL | extern "C" fn f3_3(..., x: isize) {} | ^^^ +error: functions cannot be both `const` and C-variadic + --> $DIR/variadic-ffi-semantic-restrictions.rs:35:1 + | +LL | const unsafe extern "C" fn f4_1(x: isize, ...) {} + | ^^^^^ `const` because of this ^^^ C-variadic because of this + +error: functions cannot be both `const` and C-variadic + --> $DIR/variadic-ffi-semantic-restrictions.rs:38:1 + | +LL | const extern "C" fn f4_2(x: isize, ...) {} + | ^^^^^ `const` because of this ^^^ C-variadic because of this + +error: only foreign or `unsafe extern "C"` functions may be C-variadic + --> $DIR/variadic-ffi-semantic-restrictions.rs:38:36 + | +LL | const extern "C" fn f4_2(x: isize, ...) {} + | ^^^ + +error: `...` must be the last argument of a C-variadic function + --> $DIR/variadic-ffi-semantic-restrictions.rs:42:26 + | +LL | const extern "C" fn f4_3(..., x: isize, ...) {} + | ^^^ + +error: functions cannot be both `const` and C-variadic + --> $DIR/variadic-ffi-semantic-restrictions.rs:42:1 + | +LL | const extern "C" fn f4_3(..., x: isize, ...) {} + | ^^^^^ ^^^ ^^^ C-variadic because of this + | | | + | | C-variadic because of this + | `const` because of this + +error: only foreign or `unsafe extern "C"` functions may be C-variadic + --> $DIR/variadic-ffi-semantic-restrictions.rs:42:26 + | +LL | const extern "C" fn f4_3(..., x: isize, ...) {} + | ^^^ ^^^ + error: C-variadic function must be declared with at least one named argument - --> $DIR/variadic-ffi-semantic-restrictions.rs:36:13 + --> $DIR/variadic-ffi-semantic-restrictions.rs:48:13 | LL | fn e_f1(...); | ^^^ error: `...` must be the last argument of a C-variadic function - --> $DIR/variadic-ffi-semantic-restrictions.rs:38:13 + --> $DIR/variadic-ffi-semantic-restrictions.rs:50:13 | LL | fn e_f2(..., x: isize); | ^^^ error: only foreign or `unsafe extern "C"` functions may be C-variadic - --> $DIR/variadic-ffi-semantic-restrictions.rs:45:23 + --> $DIR/variadic-ffi-semantic-restrictions.rs:57:23 | LL | fn i_f1(x: isize, ...) {} | ^^^ error: C-variadic function must be declared with at least one named argument - --> $DIR/variadic-ffi-semantic-restrictions.rs:47:13 + --> $DIR/variadic-ffi-semantic-restrictions.rs:59:13 | LL | fn i_f2(...) {} | ^^^ error: only foreign or `unsafe extern "C"` functions may be C-variadic - --> $DIR/variadic-ffi-semantic-restrictions.rs:47:13 + --> $DIR/variadic-ffi-semantic-restrictions.rs:59:13 | LL | fn i_f2(...) {} | ^^^ error: `...` must be the last argument of a C-variadic function - --> $DIR/variadic-ffi-semantic-restrictions.rs:50:13 - | -LL | fn i_f3(..., x: isize, ...) {} - | ^^^ - -error: only foreign or `unsafe extern "C"` functions may be C-variadic - --> $DIR/variadic-ffi-semantic-restrictions.rs:50:13 + --> $DIR/variadic-ffi-semantic-restrictions.rs:62:13 | LL | fn i_f3(..., x: isize, ...) {} | ^^^ error: only foreign or `unsafe extern "C"` functions may be C-variadic - --> $DIR/variadic-ffi-semantic-restrictions.rs:50:28 + --> $DIR/variadic-ffi-semantic-restrictions.rs:62:13 | LL | fn i_f3(..., x: isize, ...) {} - | ^^^ + | ^^^ ^^^ error: `...` must be the last argument of a C-variadic function - --> $DIR/variadic-ffi-semantic-restrictions.rs:54:13 + --> $DIR/variadic-ffi-semantic-restrictions.rs:65:13 | LL | fn i_f4(..., x: isize, ...) {} | ^^^ error: only foreign or `unsafe extern "C"` functions may be C-variadic - --> $DIR/variadic-ffi-semantic-restrictions.rs:54:13 + --> $DIR/variadic-ffi-semantic-restrictions.rs:65:13 | LL | fn i_f4(..., x: isize, ...) {} - | ^^^ + | ^^^ ^^^ + +error: functions cannot be both `const` and C-variadic + --> $DIR/variadic-ffi-semantic-restrictions.rs:68:5 + | +LL | const fn i_f5(x: isize, ...) {} + | ^^^^^ ^^^ C-variadic because of this + | | + | `const` because of this error: only foreign or `unsafe extern "C"` functions may be C-variadic - --> $DIR/variadic-ffi-semantic-restrictions.rs:54:28 + --> $DIR/variadic-ffi-semantic-restrictions.rs:68:29 | -LL | fn i_f4(..., x: isize, ...) {} - | ^^^ +LL | const fn i_f5(x: isize, ...) {} + | ^^^ error: only foreign or `unsafe extern "C"` functions may be C-variadic - --> $DIR/variadic-ffi-semantic-restrictions.rs:61:23 + --> $DIR/variadic-ffi-semantic-restrictions.rs:74:23 | LL | fn t_f1(x: isize, ...) {} | ^^^ error: only foreign or `unsafe extern "C"` functions may be C-variadic - --> $DIR/variadic-ffi-semantic-restrictions.rs:63:23 + --> $DIR/variadic-ffi-semantic-restrictions.rs:76:23 | LL | fn t_f2(x: isize, ...); | ^^^ error: C-variadic function must be declared with at least one named argument - --> $DIR/variadic-ffi-semantic-restrictions.rs:65:13 + --> $DIR/variadic-ffi-semantic-restrictions.rs:78:13 | LL | fn t_f3(...) {} | ^^^ error: only foreign or `unsafe extern "C"` functions may be C-variadic - --> $DIR/variadic-ffi-semantic-restrictions.rs:65:13 + --> $DIR/variadic-ffi-semantic-restrictions.rs:78:13 | LL | fn t_f3(...) {} | ^^^ error: C-variadic function must be declared with at least one named argument - --> $DIR/variadic-ffi-semantic-restrictions.rs:68:13 + --> $DIR/variadic-ffi-semantic-restrictions.rs:81:13 | LL | fn t_f4(...); | ^^^ error: only foreign or `unsafe extern "C"` functions may be C-variadic - --> $DIR/variadic-ffi-semantic-restrictions.rs:68:13 + --> $DIR/variadic-ffi-semantic-restrictions.rs:81:13 | LL | fn t_f4(...); | ^^^ error: `...` must be the last argument of a C-variadic function - --> $DIR/variadic-ffi-semantic-restrictions.rs:71:13 + --> $DIR/variadic-ffi-semantic-restrictions.rs:84:13 | LL | fn t_f5(..., x: isize) {} | ^^^ error: only foreign or `unsafe extern "C"` functions may be C-variadic - --> $DIR/variadic-ffi-semantic-restrictions.rs:71:13 + --> $DIR/variadic-ffi-semantic-restrictions.rs:84:13 | LL | fn t_f5(..., x: isize) {} | ^^^ error: `...` must be the last argument of a C-variadic function - --> $DIR/variadic-ffi-semantic-restrictions.rs:74:13 + --> $DIR/variadic-ffi-semantic-restrictions.rs:87:13 | LL | fn t_f6(..., x: isize); | ^^^ error: only foreign or `unsafe extern "C"` functions may be C-variadic - --> $DIR/variadic-ffi-semantic-restrictions.rs:74:13 + --> $DIR/variadic-ffi-semantic-restrictions.rs:87:13 | LL | fn t_f6(..., x: isize); | ^^^ -error: aborting due to 34 previous errors +error: aborting due to 40 previous errors diff --git a/tests/ui/pattern/incorrect-placement-of-pattern-modifiers.fixed b/tests/ui/pattern/incorrect-placement-of-pattern-modifiers.fixed new file mode 100644 index 00000000000..cf6c2a24fdf --- /dev/null +++ b/tests/ui/pattern/incorrect-placement-of-pattern-modifiers.fixed @@ -0,0 +1,18 @@ +// run-rustfix +struct S { + field_name: (), +} + +fn main() { + match (S {field_name: ()}) { + S {field_name: ref _foo} => {} //~ ERROR expected `,` + } + match (S {field_name: ()}) { + S {field_name: mut _foo} => {} //~ ERROR expected `,` + } + match (S {field_name: ()}) { + S {field_name: ref mut _foo} => {} //~ ERROR expected `,` + } + // Verify that we recover enough to run typeck. + let _: usize = 3usize; //~ ERROR mismatched types +} diff --git a/tests/ui/pattern/incorrect-placement-of-pattern-modifiers.rs b/tests/ui/pattern/incorrect-placement-of-pattern-modifiers.rs new file mode 100644 index 00000000000..98772c1188e --- /dev/null +++ b/tests/ui/pattern/incorrect-placement-of-pattern-modifiers.rs @@ -0,0 +1,18 @@ +// run-rustfix +struct S { + field_name: (), +} + +fn main() { + match (S {field_name: ()}) { + S {ref field_name: _foo} => {} //~ ERROR expected `,` + } + match (S {field_name: ()}) { + S {mut field_name: _foo} => {} //~ ERROR expected `,` + } + match (S {field_name: ()}) { + S {ref mut field_name: _foo} => {} //~ ERROR expected `,` + } + // Verify that we recover enough to run typeck. + let _: usize = 3u8; //~ ERROR mismatched types +} diff --git a/tests/ui/pattern/incorrect-placement-of-pattern-modifiers.stderr b/tests/ui/pattern/incorrect-placement-of-pattern-modifiers.stderr new file mode 100644 index 00000000000..e80789253c0 --- /dev/null +++ b/tests/ui/pattern/incorrect-placement-of-pattern-modifiers.stderr @@ -0,0 +1,58 @@ +error: expected `,` + --> $DIR/incorrect-placement-of-pattern-modifiers.rs:8:26 + | +LL | S {ref field_name: _foo} => {} + | - ^ + | | + | while parsing the fields for this pattern + | +help: the pattern modifiers belong after the `:` + | +LL - S {ref field_name: _foo} => {} +LL + S {field_name: ref _foo} => {} + | + +error: expected `,` + --> $DIR/incorrect-placement-of-pattern-modifiers.rs:11:26 + | +LL | S {mut field_name: _foo} => {} + | - ^ + | | + | while parsing the fields for this pattern + | +help: the pattern modifiers belong after the `:` + | +LL - S {mut field_name: _foo} => {} +LL + S {field_name: mut _foo} => {} + | + +error: expected `,` + --> $DIR/incorrect-placement-of-pattern-modifiers.rs:14:30 + | +LL | S {ref mut field_name: _foo} => {} + | - ^ + | | + | while parsing the fields for this pattern + | +help: the pattern modifiers belong after the `:` + | +LL - S {ref mut field_name: _foo} => {} +LL + S {field_name: ref mut _foo} => {} + | + +error[E0308]: mismatched types + --> $DIR/incorrect-placement-of-pattern-modifiers.rs:17:20 + | +LL | let _: usize = 3u8; + | ----- ^^^ expected `usize`, found `u8` + | | + | expected due to this + | +help: change the type of the numeric literal from `u8` to `usize` + | +LL | let _: usize = 3usize; + | ~~~~~ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.allow.stderr b/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.allow.stderr index 9f277fa1e18..7f26c93aa28 100644 --- a/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.allow.stderr +++ b/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.allow.stderr @@ -1,5 +1,5 @@ error[E0004]: non-exhaustive patterns: type `usize` is non-empty - --> $DIR/pointer-sized-int.rs:48:11 + --> $DIR/pointer-sized-int.rs:54:11 | LL | match 7usize {} | ^^^^^^ diff --git a/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr b/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr index df330c60b1e..d16ec5412db 100644 --- a/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr +++ b/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr @@ -1,162 +1,162 @@ -error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/pointer-sized-int.rs:12:11 +error[E0004]: non-exhaustive patterns: `usize::MAX..` not covered + --> $DIR/pointer-sized-int.rs:14:11 | LL | match 0usize { - | ^^^^^^ pattern `_` not covered + | ^^^^^^ pattern `usize::MAX..` not covered | = note: the matched value is of type `usize` - = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ 0 ..= usize::MAX => {}, -LL + _ => todo!() +LL + usize::MAX.. => todo!() | -error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/pointer-sized-int.rs:17:11 +error[E0004]: non-exhaustive patterns: `..isize::MIN` and `isize::MAX..` not covered + --> $DIR/pointer-sized-int.rs:19:11 | LL | match 0isize { - | ^^^^^^ pattern `_` not covered + | ^^^^^^ patterns `..isize::MIN` and `isize::MAX..` not covered | = note: the matched value is of type `isize` - = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | LL ~ isize::MIN ..= isize::MAX => {}, -LL + _ => todo!() +LL + ..isize::MIN | isize::MAX.. => todo!() | -error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/pointer-sized-int.rs:22:8 +error[E0004]: non-exhaustive patterns: `usize::MAX..` not covered + --> $DIR/pointer-sized-int.rs:25:8 | LL | m!(0usize, 0..=usize::MAX); - | ^^^^^^ pattern `_` not covered + | ^^^^^^ pattern `usize::MAX..` not covered | = note: the matched value is of type `usize` - = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL | match $s { $($t)+ => {}, _ => todo!() } - | ++++++++++++++ +LL | match $s { $($t)+ => {}, usize::MAX.. => todo!() } + | +++++++++++++++++++++++++ -error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/pointer-sized-int.rs:24:8 +error[E0004]: non-exhaustive patterns: `usize::MAX..` not covered + --> $DIR/pointer-sized-int.rs:27:8 | LL | m!(0usize, 0..5 | 5..=usize::MAX); - | ^^^^^^ pattern `_` not covered + | ^^^^^^ pattern `usize::MAX..` not covered | = note: the matched value is of type `usize` - = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL | match $s { $($t)+ => {}, _ => todo!() } - | ++++++++++++++ +LL | match $s { $($t)+ => {}, usize::MAX.. => todo!() } + | +++++++++++++++++++++++++ -error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/pointer-sized-int.rs:26:8 +error[E0004]: non-exhaustive patterns: `usize::MAX..` not covered + --> $DIR/pointer-sized-int.rs:29:8 | LL | m!(0usize, 0..usize::MAX | usize::MAX); - | ^^^^^^ pattern `_` not covered + | ^^^^^^ pattern `usize::MAX..` not covered | = note: the matched value is of type `usize` - = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL | match $s { $($t)+ => {}, _ => todo!() } - | ++++++++++++++ +LL | match $s { $($t)+ => {}, usize::MAX.. => todo!() } + | +++++++++++++++++++++++++ -error[E0004]: non-exhaustive patterns: `(_, _)` not covered - --> $DIR/pointer-sized-int.rs:28:8 +error[E0004]: non-exhaustive patterns: `(usize::MAX.., _)` not covered + --> $DIR/pointer-sized-int.rs:31:8 | LL | m!((0usize, true), (0..5, true) | (5..=usize::MAX, true) | (0..=usize::MAX, false)); - | ^^^^^^^^^^^^^^ pattern `(_, _)` not covered + | ^^^^^^^^^^^^^^ pattern `(usize::MAX.., _)` not covered | = note: the matched value is of type `(usize, bool)` - = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL | match $s { $($t)+ => {}, (_, _) => todo!() } - | +++++++++++++++++++ +LL | match $s { $($t)+ => {}, (usize::MAX.., _) => todo!() } + | ++++++++++++++++++++++++++++++ -error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/pointer-sized-int.rs:31:8 +error[E0004]: non-exhaustive patterns: `..isize::MIN` and `isize::MAX..` not covered + --> $DIR/pointer-sized-int.rs:36:8 | LL | m!(0isize, isize::MIN..=isize::MAX); - | ^^^^^^ pattern `_` not covered + | ^^^^^^ patterns `..isize::MIN` and `isize::MAX..` not covered | = note: the matched value is of type `isize` - = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | -LL | match $s { $($t)+ => {}, _ => todo!() } - | ++++++++++++++ +LL | match $s { $($t)+ => {}, ..isize::MIN | isize::MAX.. => todo!() } + | ++++++++++++++++++++++++++++++++++++++++ -error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/pointer-sized-int.rs:33:8 +error[E0004]: non-exhaustive patterns: `..isize::MIN` and `isize::MAX..` not covered + --> $DIR/pointer-sized-int.rs:38:8 | LL | m!(0isize, isize::MIN..5 | 5..=isize::MAX); - | ^^^^^^ pattern `_` not covered + | ^^^^^^ patterns `..isize::MIN` and `isize::MAX..` not covered | = note: the matched value is of type `isize` - = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | -LL | match $s { $($t)+ => {}, _ => todo!() } - | ++++++++++++++ +LL | match $s { $($t)+ => {}, ..isize::MIN | isize::MAX.. => todo!() } + | ++++++++++++++++++++++++++++++++++++++++ -error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/pointer-sized-int.rs:35:8 +error[E0004]: non-exhaustive patterns: `..isize::MIN` and `isize::MAX..` not covered + --> $DIR/pointer-sized-int.rs:40:8 | LL | m!(0isize, isize::MIN..isize::MAX | isize::MAX); - | ^^^^^^ pattern `_` not covered + | ^^^^^^ patterns `..isize::MIN` and `isize::MAX..` not covered | = note: the matched value is of type `isize` - = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | -LL | match $s { $($t)+ => {}, _ => todo!() } - | ++++++++++++++ +LL | match $s { $($t)+ => {}, ..isize::MIN | isize::MAX.. => todo!() } + | ++++++++++++++++++++++++++++++++++++++++ -error[E0004]: non-exhaustive patterns: `(_, _)` not covered - --> $DIR/pointer-sized-int.rs:37:8 +error[E0004]: non-exhaustive patterns: `(..isize::MIN, _)` and `(isize::MAX.., _)` not covered + --> $DIR/pointer-sized-int.rs:42:8 | LL | m!((0isize, true), (isize::MIN..5, true) - | ^^^^^^^^^^^^^^ pattern `(_, _)` not covered + | ^^^^^^^^^^^^^^ patterns `(..isize::MIN, _)` and `(isize::MAX.., _)` not covered | = note: the matched value is of type `(isize, bool)` - = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | -LL | match $s { $($t)+ => {}, (_, _) => todo!() } - | +++++++++++++++++++ +LL | match $s { $($t)+ => {}, (..isize::MIN, _) | (isize::MAX.., _) => todo!() } + | ++++++++++++++++++++++++++++++++++++++++++++++++++ -error[E0004]: non-exhaustive patterns: `_` not covered - --> $DIR/pointer-sized-int.rs:41:11 +error[E0004]: non-exhaustive patterns: `..isize::MIN` and `isize::MAX..` not covered + --> $DIR/pointer-sized-int.rs:47:11 | LL | match 0isize { - | ^^^^^^ pattern `_` not covered + | ^^^^^^ patterns `..isize::MIN` and `isize::MAX..` not covered | = note: the matched value is of type `isize` - = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | LL ~ 1 ..= isize::MAX => {}, -LL + _ => todo!() +LL + ..isize::MIN | isize::MAX.. => todo!() | error[E0004]: non-exhaustive patterns: type `usize` is non-empty - --> $DIR/pointer-sized-int.rs:48:11 + --> $DIR/pointer-sized-int.rs:54:11 | LL | match 7usize {} | ^^^^^^ diff --git a/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.rs b/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.rs index 1ed18c26763..20a3cbe127f 100644 --- a/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.rs +++ b/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.rs @@ -1,6 +1,7 @@ // revisions: allow deny #![feature(exclusive_range_pattern)] #![cfg_attr(allow, feature(precise_pointer_size_matching))] +#![allow(overlapping_range_endpoints)] macro_rules! m { ($s:expr, $($t:tt)+) => { @@ -8,6 +9,7 @@ macro_rules! m { } } +#[rustfmt::skip] fn main() { match 0usize { //[deny]~^ ERROR non-exhaustive patterns @@ -19,6 +21,7 @@ fn main() { isize::MIN ..= isize::MAX => {} } + m!(0usize, 0..); m!(0usize, 0..=usize::MAX); //[deny]~^ ERROR non-exhaustive patterns m!(0usize, 0..5 | 5..=usize::MAX); @@ -27,7 +30,9 @@ fn main() { //[deny]~^ ERROR non-exhaustive patterns m!((0usize, true), (0..5, true) | (5..=usize::MAX, true) | (0..=usize::MAX, false)); //[deny]~^ ERROR non-exhaustive patterns + m!(0usize, 0..=usize::MAX | usize::MAX..); + m!(0isize, ..0 | 0..); m!(0isize, isize::MIN..=isize::MAX); //[deny]~^ ERROR non-exhaustive patterns m!(0isize, isize::MIN..5 | 5..=isize::MAX); @@ -37,6 +42,7 @@ fn main() { m!((0isize, true), (isize::MIN..5, true) | (5..=isize::MAX, true) | (isize::MIN..=isize::MAX, false)); //[deny]~^^ ERROR non-exhaustive patterns + m!(0isize, ..=isize::MIN | isize::MIN..=isize::MAX | isize::MAX..); match 0isize { //[deny]~^ ERROR non-exhaustive patterns diff --git a/tests/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.rs b/tests/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.rs index a2aa655ca54..d60f479c0d1 100644 --- a/tests/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.rs +++ b/tests/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.rs @@ -1,18 +1,18 @@ // This tests that the lint message explains the reason for the error. fn main() { match 0usize { - //~^ ERROR non-exhaustive patterns: `_` not covered - //~| NOTE pattern `_` not covered + //~^ ERROR non-exhaustive patterns: `usize::MAX..` not covered + //~| NOTE pattern `usize::MAX..` not covered //~| NOTE the matched value is of type `usize` //~| NOTE `usize` does not have a fixed maximum value 0..=usize::MAX => {} } match 0isize { - //~^ ERROR non-exhaustive patterns: `_` not covered - //~| NOTE pattern `_` not covered + //~^ ERROR non-exhaustive patterns: `..isize::MIN` and `isize::MAX..` not covered + //~| NOTE patterns `..isize::MIN` and `isize::MAX..` not covered //~| NOTE the matched value is of type `isize` - //~| NOTE `isize` does not have a fixed maximum value + //~| NOTE `isize` does not have fixed minimum and maximum values isize::MIN..=isize::MAX => {} } } diff --git a/tests/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.stderr b/tests/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.stderr index b80411b26b0..a7f93648ed3 100644 --- a/tests/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.stderr +++ b/tests/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.stderr @@ -1,31 +1,31 @@ -error[E0004]: non-exhaustive patterns: `_` not covered +error[E0004]: non-exhaustive patterns: `usize::MAX..` not covered --> $DIR/precise_pointer_matching-message.rs:3:11 | LL | match 0usize { - | ^^^^^^ pattern `_` not covered + | ^^^^^^ pattern `usize::MAX..` not covered | = note: the matched value is of type `usize` - = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ 0..=usize::MAX => {}, -LL + _ => todo!() +LL + usize::MAX.. => todo!() | -error[E0004]: non-exhaustive patterns: `_` not covered +error[E0004]: non-exhaustive patterns: `..isize::MIN` and `isize::MAX..` not covered --> $DIR/precise_pointer_matching-message.rs:11:11 | LL | match 0isize { - | ^^^^^^ pattern `_` not covered + | ^^^^^^ patterns `..isize::MIN` and `isize::MAX..` not covered | = note: the matched value is of type `isize` - = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | LL ~ isize::MIN..=isize::MAX => {}, -LL + _ => todo!() +LL + ..isize::MIN | isize::MAX.. => todo!() | error: aborting due to 2 previous errors diff --git a/tests/ui/pattern/usefulness/issue-85222-types-containing-non-exhaustive-types.rs b/tests/ui/pattern/usefulness/issue-85222-types-containing-non-exhaustive-types.rs index 8f58227ee2c..6cbcfed709f 100644 --- a/tests/ui/pattern/usefulness/issue-85222-types-containing-non-exhaustive-types.rs +++ b/tests/ui/pattern/usefulness/issue-85222-types-containing-non-exhaustive-types.rs @@ -6,19 +6,19 @@ struct B<T, U>(T, U); fn main() { match 0 { - //~^ ERROR non-exhaustive patterns: `_` not covered [E0004] + //~^ ERROR non-exhaustive patterns: `usize::MAX..` not covered [E0004] 0 => (), 1..=usize::MAX => (), } match (0usize, 0usize) { - //~^ ERROR non-exhaustive patterns: `(_, _)` not covered [E0004] + //~^ ERROR non-exhaustive patterns: `(usize::MAX.., _)` not covered [E0004] (0, 0) => (), (1..=usize::MAX, 1..=usize::MAX) => (), } match (0isize, 0usize) { - //~^ ERROR non-exhaustive patterns: `(_, _)` not covered [E0004] + //~^ ERROR non-exhaustive patterns: `(..isize::MIN, _)` and `(isize::MAX.., _)` not covered [E0004] (isize::MIN..=isize::MAX, 0) => (), (isize::MIN..=isize::MAX, 1..=usize::MAX) => (), } @@ -30,14 +30,14 @@ fn main() { } match Some(4) { - //~^ ERROR non-exhaustive patterns: `Some(_)` not covered + //~^ ERROR non-exhaustive patterns: `Some(usize::MAX..)` not covered Some(0) => (), Some(1..=usize::MAX) => (), None => (), } match Some(Some(Some(0))) { - //~^ ERROR non-exhaustive patterns: `Some(Some(Some(_)))` not covered + //~^ ERROR non-exhaustive patterns: `Some(Some(Some(usize::MAX..)))` not covered Some(Some(Some(0))) => (), Some(Some(Some(1..=usize::MAX))) => (), Some(Some(None)) => (), @@ -46,13 +46,13 @@ fn main() { } match (A { a: 0usize }) { - //~^ ERROR non-exhaustive patterns: `A { .. }` not covered [E0004] + //~^ ERROR non-exhaustive patterns: `A { a: usize::MAX.. }` not covered [E0004] A { a: 0 } => (), A { a: 1..=usize::MAX } => (), } match B(0isize, 0usize) { - //~^ ERROR non-exhaustive patterns: `B(_, _)` not covered [E0004] + //~^ ERROR non-exhaustive patterns: `B(..isize::MIN, _)` and `B(isize::MAX.., _)` not covered [E0004] B(isize::MIN..=isize::MAX, 0) => (), B(isize::MIN..=isize::MAX, 1..=usize::MAX) => (), } @@ -60,7 +60,7 @@ fn main() { // Should report only the note about usize not having fixed max value and not report // report the note about isize match B(0isize, 0usize) { - //~^ ERROR non-exhaustive patterns: `B(_, _)` not covered [E0004] + //~^ ERROR non-exhaustive patterns: `B(_, usize::MAX..)` not covered [E0004] B(_, 0) => (), B(_, 1..=usize::MAX) => (), } diff --git a/tests/ui/pattern/usefulness/issue-85222-types-containing-non-exhaustive-types.stderr b/tests/ui/pattern/usefulness/issue-85222-types-containing-non-exhaustive-types.stderr index ea1d99e20ae..556efcda516 100644 --- a/tests/ui/pattern/usefulness/issue-85222-types-containing-non-exhaustive-types.stderr +++ b/tests/ui/pattern/usefulness/issue-85222-types-containing-non-exhaustive-types.stderr @@ -1,46 +1,46 @@ -error[E0004]: non-exhaustive patterns: `_` not covered +error[E0004]: non-exhaustive patterns: `usize::MAX..` not covered --> $DIR/issue-85222-types-containing-non-exhaustive-types.rs:8:11 | LL | match 0 { - | ^ pattern `_` not covered + | ^ pattern `usize::MAX..` not covered | = note: the matched value is of type `usize` - = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ 1..=usize::MAX => (), -LL ~ _ => todo!(), +LL ~ usize::MAX.. => todo!(), | -error[E0004]: non-exhaustive patterns: `(_, _)` not covered +error[E0004]: non-exhaustive patterns: `(usize::MAX.., _)` not covered --> $DIR/issue-85222-types-containing-non-exhaustive-types.rs:14:11 | LL | match (0usize, 0usize) { - | ^^^^^^^^^^^^^^^^ pattern `(_, _)` not covered + | ^^^^^^^^^^^^^^^^ pattern `(usize::MAX.., _)` not covered | = note: the matched value is of type `(usize, usize)` - = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ (1..=usize::MAX, 1..=usize::MAX) => (), -LL ~ (_, _) => todo!(), +LL ~ (usize::MAX.., _) => todo!(), | -error[E0004]: non-exhaustive patterns: `(_, _)` not covered +error[E0004]: non-exhaustive patterns: `(..isize::MIN, _)` and `(isize::MAX.., _)` not covered --> $DIR/issue-85222-types-containing-non-exhaustive-types.rs:20:11 | LL | match (0isize, 0usize) { - | ^^^^^^^^^^^^^^^^ pattern `(_, _)` not covered + | ^^^^^^^^^^^^^^^^ patterns `(..isize::MIN, _)` and `(isize::MAX.., _)` not covered | = note: the matched value is of type `(isize, usize)` - = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | LL ~ (isize::MIN..=isize::MAX, 1..=usize::MAX) => (), -LL ~ (_, _) => todo!(), +LL ~ (..isize::MIN, _) | (isize::MAX.., _) => todo!(), | error[E0004]: non-exhaustive patterns: `Some(_)` not covered @@ -61,11 +61,11 @@ LL ~ None => {}, LL + Some(_) => todo!() | -error[E0004]: non-exhaustive patterns: `Some(_)` not covered +error[E0004]: non-exhaustive patterns: `Some(usize::MAX..)` not covered --> $DIR/issue-85222-types-containing-non-exhaustive-types.rs:32:11 | LL | match Some(4) { - | ^^^^^^^ pattern `Some(_)` not covered + | ^^^^^^^ pattern `Some(usize::MAX..)` not covered | note: `Option<usize>` defined here --> $SRC_DIR/core/src/option.rs:LL:COL @@ -73,19 +73,19 @@ note: `Option<usize>` defined here | = note: not covered = note: the matched value is of type `Option<usize>` - = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ None => (), -LL ~ Some(_) => todo!(), +LL ~ Some(usize::MAX..) => todo!(), | -error[E0004]: non-exhaustive patterns: `Some(Some(Some(_)))` not covered +error[E0004]: non-exhaustive patterns: `Some(Some(Some(usize::MAX..)))` not covered --> $DIR/issue-85222-types-containing-non-exhaustive-types.rs:39:11 | LL | match Some(Some(Some(0))) { - | ^^^^^^^^^^^^^^^^^^^ pattern `Some(Some(Some(_)))` not covered + | ^^^^^^^^^^^^^^^^^^^ pattern `Some(Some(Some(usize::MAX..)))` not covered | note: `Option<Option<Option<usize>>>` defined here --> $SRC_DIR/core/src/option.rs:LL:COL @@ -97,19 +97,19 @@ note: `Option<Option<Option<usize>>>` defined here | = note: not covered = note: the matched value is of type `Option<Option<Option<usize>>>` - = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ None => (), -LL ~ Some(Some(Some(_))) => todo!(), +LL ~ Some(Some(Some(usize::MAX..))) => todo!(), | -error[E0004]: non-exhaustive patterns: `A { .. }` not covered +error[E0004]: non-exhaustive patterns: `A { a: usize::MAX.. }` not covered --> $DIR/issue-85222-types-containing-non-exhaustive-types.rs:48:11 | LL | match (A { a: 0usize }) { - | ^^^^^^^^^^^^^^^^^ pattern `A { .. }` not covered + | ^^^^^^^^^^^^^^^^^ pattern `A { a: usize::MAX.. }` not covered | note: `A<usize>` defined here --> $DIR/issue-85222-types-containing-non-exhaustive-types.rs:1:8 @@ -117,19 +117,19 @@ note: `A<usize>` defined here LL | struct A<T> { | ^ = note: the matched value is of type `A<usize>` - = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ A { a: 1..=usize::MAX } => (), -LL ~ A { .. } => todo!(), +LL ~ A { a: usize::MAX.. } => todo!(), | -error[E0004]: non-exhaustive patterns: `B(_, _)` not covered +error[E0004]: non-exhaustive patterns: `B(..isize::MIN, _)` and `B(isize::MAX.., _)` not covered --> $DIR/issue-85222-types-containing-non-exhaustive-types.rs:54:11 | LL | match B(0isize, 0usize) { - | ^^^^^^^^^^^^^^^^^ pattern `B(_, _)` not covered + | ^^^^^^^^^^^^^^^^^ patterns `B(..isize::MIN, _)` and `B(isize::MAX.., _)` not covered | note: `B<isize, usize>` defined here --> $DIR/issue-85222-types-containing-non-exhaustive-types.rs:5:8 @@ -137,19 +137,19 @@ note: `B<isize, usize>` defined here LL | struct B<T, U>(T, U); | ^ = note: the matched value is of type `B<isize, usize>` - = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = note: `isize` does not have fixed minimum and maximum values, so half-open ranges are necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | LL ~ B(isize::MIN..=isize::MAX, 1..=usize::MAX) => (), -LL ~ B(_, _) => todo!(), +LL ~ B(..isize::MIN, _) | B(isize::MAX.., _) => todo!(), | -error[E0004]: non-exhaustive patterns: `B(_, _)` not covered +error[E0004]: non-exhaustive patterns: `B(_, usize::MAX..)` not covered --> $DIR/issue-85222-types-containing-non-exhaustive-types.rs:62:11 | LL | match B(0isize, 0usize) { - | ^^^^^^^^^^^^^^^^^ pattern `B(_, _)` not covered + | ^^^^^^^^^^^^^^^^^ pattern `B(_, usize::MAX..)` not covered | note: `B<isize, usize>` defined here --> $DIR/issue-85222-types-containing-non-exhaustive-types.rs:5:8 @@ -157,12 +157,12 @@ note: `B<isize, usize>` defined here LL | struct B<T, U>(T, U); | ^ = note: the matched value is of type `B<isize, usize>` - = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively + = note: `usize` does not have a fixed maximum value, so half-open ranges are necessary to match exhaustively = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ B(_, 1..=usize::MAX) => (), -LL ~ B(_, _) => todo!(), +LL ~ B(_, usize::MAX..) => todo!(), | error: aborting due to 9 previous errors diff --git a/tests/ui/pattern/usefulness/non-exhaustive-pattern-witness.rs b/tests/ui/pattern/usefulness/non-exhaustive-pattern-witness.rs index 4bd34421922..9e60d4f41a1 100644 --- a/tests/ui/pattern/usefulness/non-exhaustive-pattern-witness.rs +++ b/tests/ui/pattern/usefulness/non-exhaustive-pattern-witness.rs @@ -1,88 +1,101 @@ struct Foo { first: bool, - second: Option<[usize; 4]> + second: Option<[usize; 4]>, } fn struct_with_a_nested_enum_and_vector() { match (Foo { first: true, second: None }) { -//~^ ERROR non-exhaustive patterns: `Foo { first: false, second: Some([_, _, _, _]) }` not covered + //~^ ERROR non-exhaustive patterns: `Foo { first: false, second: Some([0_usize, _, _, _]) }` and `Foo { first: false, second: Some([2_usize.., _, _, _]) }` not covered Foo { first: true, second: None } => (), Foo { first: true, second: Some(_) } => (), Foo { first: false, second: None } => (), - Foo { first: false, second: Some([1, 2, 3, 4]) } => () + Foo { first: false, second: Some([1, 2, 3, 4]) } => (), } } enum Color { Red, Green, - CustomRGBA { a: bool, r: u8, g: u8, b: u8 } + CustomRGBA { a: bool, r: u8, g: u8, b: u8 }, } fn enum_with_single_missing_variant() { match Color::Red { - //~^ ERROR non-exhaustive patterns: `Color::Red` not covered + //~^ ERROR non-exhaustive patterns: `Color::Red` not covered Color::CustomRGBA { .. } => (), - Color::Green => () + Color::Green => (), } } enum Direction { - North, East, South, West + North, + East, + South, + West, } fn enum_with_multiple_missing_variants() { match Direction::North { - //~^ ERROR non-exhaustive patterns: `Direction::East`, `Direction::South` and `Direction::West` not covered - Direction::North => () + //~^ ERROR non-exhaustive patterns: `Direction::East`, `Direction::South` and `Direction::West` not covered + Direction::North => (), } } enum ExcessiveEnum { - First, Second, Third, Fourth, Fifth, Sixth, Seventh, Eighth, Ninth, Tenth, Eleventh, Twelfth + First, + Second, + Third, + Fourth, + Fifth, + Sixth, + Seventh, + Eighth, + Ninth, + Tenth, + Eleventh, + Twelfth, } fn enum_with_excessive_missing_variants() { match ExcessiveEnum::First { - //~^ ERROR `ExcessiveEnum::Second`, `ExcessiveEnum::Third`, `ExcessiveEnum::Fourth` and 8 more not covered - - ExcessiveEnum::First => () + //~^ ERROR `ExcessiveEnum::Second`, `ExcessiveEnum::Third`, `ExcessiveEnum::Fourth` and 8 more not covered + ExcessiveEnum::First => (), } } fn enum_struct_variant() { match Color::Red { - //~^ ERROR non-exhaustive patterns: `Color::CustomRGBA { a: true, .. }` not covered + //~^ ERROR non-exhaustive patterns: `Color::CustomRGBA { a: true, .. }` not covered Color::Red => (), Color::Green => (), Color::CustomRGBA { a: false, r: _, g: _, b: 0 } => (), - Color::CustomRGBA { a: false, r: _, g: _, b: _ } => () + Color::CustomRGBA { a: false, r: _, g: _, b: _ } => (), } } enum Enum { First, - Second(bool) + Second(bool), } fn vectors_with_nested_enums() { let x: &'static [Enum] = &[Enum::First, Enum::Second(false)]; match *x { - //~^ ERROR non-exhaustive patterns: `[Enum::Second(true), Enum::Second(false)]` not covered + //~^ ERROR non-exhaustive patterns: `[Enum::Second(true), Enum::Second(false)]` not covered [] => (), [_] => (), [Enum::First, _] => (), [Enum::Second(true), Enum::First] => (), [Enum::Second(true), Enum::Second(true)] => (), [Enum::Second(false), _] => (), - [_, _, ref tail @ .., _] => () + [_, _, ref tail @ .., _] => (), } } fn missing_nil() { match ((), false) { - //~^ ERROR non-exhaustive patterns: `((), false)` not covered - ((), true) => () + //~^ ERROR non-exhaustive patterns: `((), false)` not covered + ((), true) => (), } } diff --git a/tests/ui/pattern/usefulness/non-exhaustive-pattern-witness.stderr b/tests/ui/pattern/usefulness/non-exhaustive-pattern-witness.stderr index d798ec722dd..f914b98d923 100644 --- a/tests/ui/pattern/usefulness/non-exhaustive-pattern-witness.stderr +++ b/tests/ui/pattern/usefulness/non-exhaustive-pattern-witness.stderr @@ -1,8 +1,8 @@ -error[E0004]: non-exhaustive patterns: `Foo { first: false, second: Some([_, _, _, _]) }` not covered +error[E0004]: non-exhaustive patterns: `Foo { first: false, second: Some([0_usize, _, _, _]) }` and `Foo { first: false, second: Some([2_usize.., _, _, _]) }` not covered --> $DIR/non-exhaustive-pattern-witness.rs:7:11 | LL | match (Foo { first: true, second: None }) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `Foo { first: false, second: Some([_, _, _, _]) }` not covered + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ patterns `Foo { first: false, second: Some([0_usize, _, _, _]) }` and `Foo { first: false, second: Some([2_usize.., _, _, _]) }` not covered | note: `Foo` defined here --> $DIR/non-exhaustive-pattern-witness.rs:1:8 @@ -10,12 +10,10 @@ note: `Foo` defined here LL | struct Foo { | ^^^ = note: the matched value is of type `Foo` - = note: `usize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively - = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | LL ~ Foo { first: false, second: Some([1, 2, 3, 4]) } => (), -LL + Foo { first: false, second: Some([_, _, _, _]) } => todo!() +LL ~ Foo { first: false, second: Some([0_usize, _, _, _]) } | Foo { first: false, second: Some([2_usize.., _, _, _]) } => todo!(), | error[E0004]: non-exhaustive patterns: `Color::Red` not covered @@ -35,40 +33,42 @@ LL | Red, help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ Color::Green => (), -LL + Color::Red => todo!() +LL ~ Color::Red => todo!(), | error[E0004]: non-exhaustive patterns: `Direction::East`, `Direction::South` and `Direction::West` not covered - --> $DIR/non-exhaustive-pattern-witness.rs:35:11 + --> $DIR/non-exhaustive-pattern-witness.rs:38:11 | LL | match Direction::North { | ^^^^^^^^^^^^^^^^ patterns `Direction::East`, `Direction::South` and `Direction::West` not covered | note: `Direction` defined here - --> $DIR/non-exhaustive-pattern-witness.rs:31:12 + --> $DIR/non-exhaustive-pattern-witness.rs:32:5 | LL | enum Direction { | --------- -LL | North, East, South, West - | ^^^^ ^^^^^ ^^^^ not covered - | | | - | | not covered - | not covered +LL | North, +LL | East, + | ^^^^ not covered +LL | South, + | ^^^^^ not covered +LL | West, + | ^^^^ not covered = note: the matched value is of type `Direction` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | LL ~ Direction::North => (), -LL + Direction::East | Direction::South | Direction::West => todo!() +LL ~ Direction::East | Direction::South | Direction::West => todo!(), | error[E0004]: non-exhaustive patterns: `ExcessiveEnum::Second`, `ExcessiveEnum::Third`, `ExcessiveEnum::Fourth` and 8 more not covered - --> $DIR/non-exhaustive-pattern-witness.rs:46:11 + --> $DIR/non-exhaustive-pattern-witness.rs:60:11 | LL | match ExcessiveEnum::First { | ^^^^^^^^^^^^^^^^^^^^ patterns `ExcessiveEnum::Second`, `ExcessiveEnum::Third`, `ExcessiveEnum::Fourth` and 8 more not covered | note: `ExcessiveEnum` defined here - --> $DIR/non-exhaustive-pattern-witness.rs:41:6 + --> $DIR/non-exhaustive-pattern-witness.rs:44:6 | LL | enum ExcessiveEnum { | ^^^^^^^^^^^^^ @@ -76,11 +76,11 @@ LL | enum ExcessiveEnum { help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms | LL ~ ExcessiveEnum::First => (), -LL + _ => todo!() +LL ~ _ => todo!(), | error[E0004]: non-exhaustive patterns: `Color::CustomRGBA { a: true, .. }` not covered - --> $DIR/non-exhaustive-pattern-witness.rs:54:11 + --> $DIR/non-exhaustive-pattern-witness.rs:67:11 | LL | match Color::Red { | ^^^^^^^^^^ pattern `Color::CustomRGBA { a: true, .. }` not covered @@ -91,17 +91,17 @@ note: `Color` defined here LL | enum Color { | ----- ... -LL | CustomRGBA { a: bool, r: u8, g: u8, b: u8 } +LL | CustomRGBA { a: bool, r: u8, g: u8, b: u8 }, | ^^^^^^^^^^ not covered = note: the matched value is of type `Color` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ Color::CustomRGBA { a: false, r: _, g: _, b: _ } => (), -LL + Color::CustomRGBA { a: true, .. } => todo!() +LL ~ Color::CustomRGBA { a: true, .. } => todo!(), | error[E0004]: non-exhaustive patterns: `[Enum::Second(true), Enum::Second(false)]` not covered - --> $DIR/non-exhaustive-pattern-witness.rs:70:11 + --> $DIR/non-exhaustive-pattern-witness.rs:83:11 | LL | match *x { | ^^ pattern `[Enum::Second(true), Enum::Second(false)]` not covered @@ -110,11 +110,11 @@ LL | match *x { help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ [_, _, ref tail @ .., _] => (), -LL + [Enum::Second(true), Enum::Second(false)] => todo!() +LL ~ [Enum::Second(true), Enum::Second(false)] => todo!(), | error[E0004]: non-exhaustive patterns: `((), false)` not covered - --> $DIR/non-exhaustive-pattern-witness.rs:83:11 + --> $DIR/non-exhaustive-pattern-witness.rs:96:11 | LL | match ((), false) { | ^^^^^^^^^^^ pattern `((), false)` not covered @@ -123,7 +123,7 @@ LL | match ((), false) { help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | LL ~ ((), true) => (), -LL + ((), false) => todo!() +LL ~ ((), false) => todo!(), | error: aborting due to 7 previous errors diff --git a/tests/ui/pattern/usefulness/refutable-pattern-errors.rs b/tests/ui/pattern/usefulness/refutable-pattern-errors.rs index 7a3e991d593..7603da1bb2c 100644 --- a/tests/ui/pattern/usefulness/refutable-pattern-errors.rs +++ b/tests/ui/pattern/usefulness/refutable-pattern-errors.rs @@ -1,6 +1,6 @@ -fn func((1, (Some(1), 2..=3)): (isize, (Option<isize>, isize))) { } +fn func((1, (Some(1), 2..=3)): (isize, (Option<isize>, isize))) {} //~^ ERROR refutable pattern in function argument -//~| `(_, _)` not covered +//~| `(..=0_isize, _)` and `(2_isize.., _)` not covered fn main() { let (1, (Some(1), 2..=3)) = (1, (None, 2)); diff --git a/tests/ui/pattern/usefulness/refutable-pattern-errors.stderr b/tests/ui/pattern/usefulness/refutable-pattern-errors.stderr index beb51a4d450..e66cd113023 100644 --- a/tests/ui/pattern/usefulness/refutable-pattern-errors.stderr +++ b/tests/ui/pattern/usefulness/refutable-pattern-errors.stderr @@ -1,8 +1,8 @@ error[E0005]: refutable pattern in function argument --> $DIR/refutable-pattern-errors.rs:1:9 | -LL | fn func((1, (Some(1), 2..=3)): (isize, (Option<isize>, isize))) { } - | ^^^^^^^^^^^^^^^^^^^^^ pattern `(_, _)` not covered +LL | fn func((1, (Some(1), 2..=3)): (isize, (Option<isize>, isize))) {} + | ^^^^^^^^^^^^^^^^^^^^^ patterns `(..=0_isize, _)` and `(2_isize.., _)` not covered | = note: the matched value is of type `(isize, (Option<isize>, isize))` diff --git a/tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.rs b/tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.rs index 17dc38ab25d..4203dd94d43 100644 --- a/tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.rs +++ b/tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.rs @@ -1,6 +1,6 @@ fn main() { let f = |3: isize| println!("hello"); //~^ ERROR refutable pattern in function argument - //~| `_` not covered + //~| `..=2_isize` and `4_isize..` not covered f(4); } diff --git a/tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.stderr b/tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.stderr index ab3f6f69fb1..01f077909e8 100644 --- a/tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.stderr +++ b/tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.stderr @@ -2,7 +2,7 @@ error[E0005]: refutable pattern in function argument --> $DIR/refutable-pattern-in-fn-arg.rs:2:14 | LL | let f = |3: isize| println!("hello"); - | ^ pattern `_` not covered + | ^ patterns `..=2_isize` and `4_isize..` not covered | = note: the matched value is of type `isize` help: alternatively, you could prepend the pattern with an underscore to define a new named variable; identifiers cannot begin with digits diff --git a/tests/ui/pattern/usefulness/tuple-struct-nonexhaustive.stderr b/tests/ui/pattern/usefulness/tuple-struct-nonexhaustive.stderr index 50c7fc889f4..ef707ed4aa4 100644 --- a/tests/ui/pattern/usefulness/tuple-struct-nonexhaustive.stderr +++ b/tests/ui/pattern/usefulness/tuple-struct-nonexhaustive.stderr @@ -1,8 +1,8 @@ -error[E0004]: non-exhaustive patterns: `Foo(_, _)` not covered +error[E0004]: non-exhaustive patterns: `Foo(..=0_isize, _)` and `Foo(3_isize.., _)` not covered --> $DIR/tuple-struct-nonexhaustive.rs:5:11 | LL | match x { - | ^ pattern `Foo(_, _)` not covered + | ^ patterns `Foo(..=0_isize, _)` and `Foo(3_isize.., _)` not covered | note: `Foo` defined here --> $DIR/tuple-struct-nonexhaustive.rs:1:8 @@ -10,12 +10,10 @@ note: `Foo` defined here LL | struct Foo(isize, isize); | ^^^ = note: the matched value is of type `Foo` - = note: `isize` does not have a fixed maximum value, so a wildcard `_` is necessary to match exhaustively - = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching -help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | LL ~ Foo(2, b) => println!("{}", b), -LL + Foo(_, _) => todo!() +LL + Foo(..=0_isize, _) | Foo(3_isize.., _) => todo!() | error: aborting due to previous error diff --git a/tests/ui/privacy/sealed-traits/sealed-trait-local.rs b/tests/ui/privacy/sealed-traits/sealed-trait-local.rs index 778ddf0f817..9ae01259a78 100644 --- a/tests/ui/privacy/sealed-traits/sealed-trait-local.rs +++ b/tests/ui/privacy/sealed-traits/sealed-trait-local.rs @@ -13,7 +13,43 @@ pub mod a { } } -struct S; -impl a::Sealed for S {} //~ ERROR the trait bound `S: Hidden` is not satisfied +pub mod c { + pub trait Sealed: self::d::Hidden { + fn foo() {} + } + + struct X; + impl Sealed for X {} + impl self::d::Hidden for X {} + + struct Y; + impl Sealed for Y {} + impl self::d::Hidden for Y {} + + mod d { + pub trait Hidden {} + } +} +pub mod e { + pub trait Sealed: self::f::Hidden { + fn foo() {} + } + + struct X; + impl self::f::Hidden for X {} + + struct Y; + impl self::f::Hidden for Y {} + impl<T: self::f::Hidden> Sealed for T {} + + mod f { + pub trait Hidden {} + } +} + +struct S; +impl a::Sealed for S {} //~ ERROR the trait bound +impl c::Sealed for S {} //~ ERROR the trait bound +impl e::Sealed for S {} //~ ERROR the trait bound fn main() {} diff --git a/tests/ui/privacy/sealed-traits/sealed-trait-local.stderr b/tests/ui/privacy/sealed-traits/sealed-trait-local.stderr index 5f8076fc84d..a7f77a1c0c0 100644 --- a/tests/ui/privacy/sealed-traits/sealed-trait-local.stderr +++ b/tests/ui/privacy/sealed-traits/sealed-trait-local.stderr @@ -1,16 +1,50 @@ -error[E0277]: the trait bound `S: Hidden` is not satisfied - --> $DIR/sealed-trait-local.rs:17:20 +error[E0277]: the trait bound `S: b::Hidden` is not satisfied + --> $DIR/sealed-trait-local.rs:52:20 | LL | impl a::Sealed for S {} - | ^ the trait `Hidden` is not implemented for `S` + | ^ the trait `b::Hidden` is not implemented for `S` | -note: required by a bound in `Sealed` +note: required by a bound in `a::Sealed` --> $DIR/sealed-trait-local.rs:3:23 | LL | pub trait Sealed: self::b::Hidden { | ^^^^^^^^^^^^^^^ required by this bound in `Sealed` = note: `Sealed` is a "sealed trait", because to implement it you also need to implement `a::b::Hidden`, which is not accessible; this is usually done to force you to use one of the provided types that already implement it + = help: the following type implements the trait: + a::X -error: aborting due to previous error +error[E0277]: the trait bound `S: d::Hidden` is not satisfied + --> $DIR/sealed-trait-local.rs:53:20 + | +LL | impl c::Sealed for S {} + | ^ the trait `d::Hidden` is not implemented for `S` + | +note: required by a bound in `c::Sealed` + --> $DIR/sealed-trait-local.rs:17:23 + | +LL | pub trait Sealed: self::d::Hidden { + | ^^^^^^^^^^^^^^^ required by this bound in `Sealed` + = note: `Sealed` is a "sealed trait", because to implement it you also need to implement `c::d::Hidden`, which is not accessible; this is usually done to force you to use one of the provided types that already implement it + = help: the following types implement the trait: + c::X + c::Y + +error[E0277]: the trait bound `S: f::Hidden` is not satisfied + --> $DIR/sealed-trait-local.rs:54:20 + | +LL | impl e::Sealed for S {} + | ^ the trait `f::Hidden` is not implemented for `S` + | +note: required by a bound in `e::Sealed` + --> $DIR/sealed-trait-local.rs:35:23 + | +LL | pub trait Sealed: self::f::Hidden { + | ^^^^^^^^^^^^^^^ required by this bound in `Sealed` + = note: `Sealed` is a "sealed trait", because to implement it you also need to implement `e::f::Hidden`, which is not accessible; this is usually done to force you to use one of the provided types that already implement it + = help: the following types implement the trait: + e::X + e::Y + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfcs/rfc-2396-target_feature-11/fn-traits.stderr b/tests/ui/rfcs/rfc-2396-target_feature-11/fn-traits.stderr index fc7bf22775d..4fb0d43d1b7 100644 --- a/tests/ui/rfcs/rfc-2396-target_feature-11/fn-traits.stderr +++ b/tests/ui/rfcs/rfc-2396-target_feature-11/fn-traits.stderr @@ -58,6 +58,7 @@ LL | call(foo_unsafe); | required by a bound introduced by this call | = help: the trait `Fn<()>` is not implemented for fn item `unsafe fn() {foo_unsafe}` + = note: unsafe function cannot be called generically without an unsafe block = note: wrap the `unsafe fn() {foo_unsafe}` in a closure with no arguments: `|| { /* code */ }` = note: `#[target_feature]` functions do not implement the `Fn` traits note: required by a bound in `call` @@ -75,6 +76,7 @@ LL | call_mut(foo_unsafe); | required by a bound introduced by this call | = help: the trait `FnMut<()>` is not implemented for fn item `unsafe fn() {foo_unsafe}` + = note: unsafe function cannot be called generically without an unsafe block = note: wrap the `unsafe fn() {foo_unsafe}` in a closure with no arguments: `|| { /* code */ }` = note: `#[target_feature]` functions do not implement the `Fn` traits note: required by a bound in `call_mut` @@ -92,6 +94,7 @@ LL | call_once(foo_unsafe); | required by a bound introduced by this call | = help: the trait `FnOnce<()>` is not implemented for fn item `unsafe fn() {foo_unsafe}` + = note: unsafe function cannot be called generically without an unsafe block = note: wrap the `unsafe fn() {foo_unsafe}` in a closure with no arguments: `|| { /* code */ }` = note: `#[target_feature]` functions do not implement the `Fn` traits note: required by a bound in `call_once` diff --git a/tests/ui/self/arbitrary-self-from-method-substs.default.stderr b/tests/ui/self/arbitrary-self-from-method-substs.default.stderr new file mode 100644 index 00000000000..cbf5e6c541a --- /dev/null +++ b/tests/ui/self/arbitrary-self-from-method-substs.default.stderr @@ -0,0 +1,13 @@ +error[E0658]: `R` cannot be used as the type of `self` without the `arbitrary_self_types` feature + --> $DIR/arbitrary-self-from-method-substs.rs:8:43 + | +LL | fn get<R: Deref<Target = Self>>(self: R) -> u32 { + | ^ + | + = note: see issue #44874 <https://github.com/rust-lang/rust/issues/44874> for more information + = help: add `#![feature(arbitrary_self_types)]` to the crate attributes to enable + = help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/self/arbitrary-self-from-method-substs.stderr b/tests/ui/self/arbitrary-self-from-method-substs.feature.stderr index 6c252fadf46..7378d53c373 100644 --- a/tests/ui/self/arbitrary-self-from-method-substs.stderr +++ b/tests/ui/self/arbitrary-self-from-method-substs.feature.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/arbitrary-self-from-method-substs.rs:14:5 + --> $DIR/arbitrary-self-from-method-substs.rs:16:5 | LL | foo.get::<&Foo>(); | ^^^ expected `&Foo`, found `Foo` diff --git a/tests/ui/self/arbitrary-self-from-method-substs.rs b/tests/ui/self/arbitrary-self-from-method-substs.rs index 0f911a20842..004445dc327 100644 --- a/tests/ui/self/arbitrary-self-from-method-substs.rs +++ b/tests/ui/self/arbitrary-self-from-method-substs.rs @@ -1,10 +1,12 @@ -#![feature(arbitrary_self_types)] +// revisions: default feature +#![cfg_attr(feature, feature(arbitrary_self_types))] use std::ops::Deref; struct Foo(u32); impl Foo { - fn get<R: Deref<Target=Self>>(self: R) -> u32 { + fn get<R: Deref<Target = Self>>(self: R) -> u32 { + //[default]~^ ERROR: `R` cannot be used as the type of `self` self.0 } } @@ -12,5 +14,5 @@ impl Foo { fn main() { let mut foo = Foo(1); foo.get::<&Foo>(); - //~^ ERROR mismatched types + //[feature]~^ ERROR mismatched types } diff --git a/tests/ui/self/arbitrary-self-types-not-object-safe.curr.stderr b/tests/ui/self/arbitrary-self-types-not-object-safe.curr.stderr index 13591f5b635..fdd18c6b37b 100644 --- a/tests/ui/self/arbitrary-self-types-not-object-safe.curr.stderr +++ b/tests/ui/self/arbitrary-self-types-not-object-safe.curr.stderr @@ -14,6 +14,7 @@ LL | trait Foo { | --- this trait cannot be made into an object... LL | fn foo(self: &Rc<Self>) -> usize; | ^^^^^^^^^ ...because method `foo`'s `self` parameter cannot be dispatched on + = help: only type `usize` implements the trait, consider using it directly instead error[E0038]: the trait `Foo` cannot be made into an object --> $DIR/arbitrary-self-types-not-object-safe.rs:33:13 @@ -31,6 +32,7 @@ LL | trait Foo { | --- this trait cannot be made into an object... LL | fn foo(self: &Rc<Self>) -> usize; | ^^^^^^^^^ ...because method `foo`'s `self` parameter cannot be dispatched on + = help: only type `usize` implements the trait, consider using it directly instead = note: required for the cast from `Rc<usize>` to `Rc<dyn Foo>` error: aborting due to 2 previous errors diff --git a/tests/ui/self/arbitrary-self-types-not-object-safe.object_safe_for_dispatch.stderr b/tests/ui/self/arbitrary-self-types-not-object-safe.object_safe_for_dispatch.stderr index 593f705353a..0a567ddcc2e 100644 --- a/tests/ui/self/arbitrary-self-types-not-object-safe.object_safe_for_dispatch.stderr +++ b/tests/ui/self/arbitrary-self-types-not-object-safe.object_safe_for_dispatch.stderr @@ -14,6 +14,7 @@ LL | trait Foo { | --- this trait cannot be made into an object... LL | fn foo(self: &Rc<Self>) -> usize; | ^^^^^^^^^ ...because method `foo`'s `self` parameter cannot be dispatched on + = help: only type `usize` implements the trait, consider using it directly instead = note: required for the cast from `Rc<usize>` to `Rc<dyn Foo>` error: aborting due to previous error diff --git a/tests/ui/stability-attribute/stability-attribute-sanity-4.rs b/tests/ui/stability-attribute/stability-attribute-sanity-4.rs index 4fe8e45fd04..01a46d15c8d 100644 --- a/tests/ui/stability-attribute/stability-attribute-sanity-4.rs +++ b/tests/ui/stability-attribute/stability-attribute-sanity-4.rs @@ -19,6 +19,7 @@ mod bogus_attribute_types_2 { #[stable(feature = "a", since = "3.3.3")] #[deprecated] //~ ERROR missing 'since' + //~^ ERROR missing 'note' fn f5() { } #[stable(feature = "a", since = "3.3.3")] diff --git a/tests/ui/stability-attribute/stability-attribute-sanity-4.stderr b/tests/ui/stability-attribute/stability-attribute-sanity-4.stderr index a76f5be1e3d..8ead943ffe3 100644 --- a/tests/ui/stability-attribute/stability-attribute-sanity-4.stderr +++ b/tests/ui/stability-attribute/stability-attribute-sanity-4.stderr @@ -28,12 +28,19 @@ error[E0542]: missing 'since' LL | #[deprecated] | ^^^^^^^^^^^^^ +error[E0543]: missing 'note' + --> $DIR/stability-attribute-sanity-4.rs:21:5 + | +LL | #[deprecated] + | ^^^^^^^^^^^^^ + error[E0542]: missing 'since' - --> $DIR/stability-attribute-sanity-4.rs:25:5 + --> $DIR/stability-attribute-sanity-4.rs:26:5 | LL | #[deprecated = "a"] | ^^^^^^^^^^^^^^^^^^^ -error: aborting due to 6 previous errors +error: aborting due to 7 previous errors -For more information about this error, try `rustc --explain E0542`. +Some errors have detailed explanations: E0542, E0543. +For more information about an error, try `rustc --explain E0542`. diff --git a/tests/ui/stability-attribute/stability-attribute-sanity.rs b/tests/ui/stability-attribute/stability-attribute-sanity.rs index 8258b6f5ae0..7857a0603bd 100644 --- a/tests/ui/stability-attribute/stability-attribute-sanity.rs +++ b/tests/ui/stability-attribute/stability-attribute-sanity.rs @@ -41,7 +41,7 @@ mod missing_version { fn f2() { } #[stable(feature = "a", since = "4.4.4")] - #[deprecated(since = "a")] //~ ERROR missing 'note' [E0543] + #[deprecated(since = "5.5.5")] //~ ERROR missing 'note' [E0543] fn f3() { } } @@ -58,18 +58,17 @@ fn multiple2() { } fn multiple3() { } #[stable(feature = "e", since = "b")] //~ ERROR 'since' must be a Rust version number, such as "1.31.0" -#[deprecated(since = "b", note = "text")] -#[deprecated(since = "b", note = "text")] //~ ERROR multiple `deprecated` attributes +#[deprecated(since = "5.5.5", note = "text")] +#[deprecated(since = "5.5.5", note = "text")] //~ ERROR multiple `deprecated` attributes #[rustc_const_unstable(feature = "c", issue = "none")] #[rustc_const_unstable(feature = "d", issue = "none")] //~ ERROR multiple stability levels pub const fn multiple4() { } -#[stable(feature = "a", since = "1.0.0")] //~ ERROR invalid deprecation version found -//~^ ERROR feature `a` is declared stable since 1.0.0 -#[deprecated(since = "invalid", note = "text")] +#[stable(feature = "a", since = "1.0.0")] //~ ERROR feature `a` is declared stable since 1.0.0 +#[deprecated(since = "invalid", note = "text")] //~ ERROR 'since' must be a Rust version number, such as "1.31.0" fn invalid_deprecation_version() {} -#[deprecated(since = "a", note = "text")] +#[deprecated(since = "5.5.5", note = "text")] fn deprecated_without_unstable_or_stable() { } //~^^ ERROR deprecated attribute must be paired with either stable or unstable attribute diff --git a/tests/ui/stability-attribute/stability-attribute-sanity.stderr b/tests/ui/stability-attribute/stability-attribute-sanity.stderr index 955230742bd..c614fc2b9f7 100644 --- a/tests/ui/stability-attribute/stability-attribute-sanity.stderr +++ b/tests/ui/stability-attribute/stability-attribute-sanity.stderr @@ -1,14 +1,14 @@ error: multiple `deprecated` attributes --> $DIR/stability-attribute-sanity.rs:62:1 | -LL | #[deprecated(since = "b", note = "text")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute +LL | #[deprecated(since = "5.5.5", note = "text")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute | note: attribute also specified here --> $DIR/stability-attribute-sanity.rs:61:1 | -LL | #[deprecated(since = "b", note = "text")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[deprecated(since = "5.5.5", note = "text")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0541]: unknown meta item 'reason' --> $DIR/stability-attribute-sanity.rs:8:46 @@ -73,8 +73,8 @@ LL | #[deprecated(note = "a")] error[E0543]: missing 'note' --> $DIR/stability-attribute-sanity.rs:44:5 | -LL | #[deprecated(since = "a")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[deprecated(since = "5.5.5")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0544]: multiple stability levels --> $DIR/stability-attribute-sanity.rs:49:1 @@ -106,20 +106,17 @@ error[E0544]: multiple stability levels LL | #[rustc_const_unstable(feature = "d", issue = "none")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: invalid deprecation version found - --> $DIR/stability-attribute-sanity.rs:67:1 +error: 'since' must be a Rust version number, such as "1.31.0" + --> $DIR/stability-attribute-sanity.rs:68:1 | -LL | #[stable(feature = "a", since = "1.0.0")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid deprecation version -... -LL | fn invalid_deprecation_version() {} - | ----------------------------------- the stability attribute annotates this item +LL | #[deprecated(since = "invalid", note = "text")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0549]: deprecated attribute must be paired with either stable or unstable attribute - --> $DIR/stability-attribute-sanity.rs:72:1 + --> $DIR/stability-attribute-sanity.rs:71:1 | -LL | #[deprecated(since = "a", note = "text")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[deprecated(since = "5.5.5", note = "text")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0711]: feature `a` is declared stable since 1.0.0, but was previously declared stable since 4.4.4 --> $DIR/stability-attribute-sanity.rs:67:1 diff --git a/tests/ui/suggestions/path-display.stderr b/tests/ui/suggestions/path-display.stderr index 8359b36588e..46d0b35825b 100644 --- a/tests/ui/suggestions/path-display.stderr +++ b/tests/ui/suggestions/path-display.stderr @@ -5,6 +5,7 @@ LL | println!("{}", path); | ^^^^ `Path` cannot be formatted with the default formatter; call `.display()` on it | = help: the trait `std::fmt::Display` is not implemented for `Path` + = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead = note: call `.display()` or `.to_string_lossy()` to safely print paths, as they may contain non-Unicode data = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -15,6 +16,7 @@ LL | println!("{}", path); | ^^^^ `PathBuf` cannot be formatted with the default formatter; call `.display()` on it | = help: the trait `std::fmt::Display` is not implemented for `PathBuf` + = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead = note: call `.display()` or `.to_string_lossy()` to safely print paths, as they may contain non-Unicode data = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/suggestions/trait-hidden-method.stderr b/tests/ui/suggestions/trait-hidden-method.stderr index a5a65d193db..5dec2071846 100644 --- a/tests/ui/suggestions/trait-hidden-method.stderr +++ b/tests/ui/suggestions/trait-hidden-method.stderr @@ -1,4 +1,4 @@ -error[E0191]: the value of the associated type `Item` (from trait `Iterator`) must be specified +error[E0191]: the value of the associated type `Item` in `Iterator` must be specified --> $DIR/trait-hidden-method.rs:6:33 | LL | Box::new(1..=10) as Box<dyn Iterator> diff --git a/tests/ui/suggestions/use-type-argument-instead-of-assoc-type.stderr b/tests/ui/suggestions/use-type-argument-instead-of-assoc-type.stderr index 175a5fbba61..7c84dd4b8ff 100644 --- a/tests/ui/suggestions/use-type-argument-instead-of-assoc-type.stderr +++ b/tests/ui/suggestions/use-type-argument-instead-of-assoc-type.stderr @@ -14,7 +14,7 @@ help: replace the generic bounds with the associated types LL | i: Box<dyn T<usize, usize, A = usize, C = usize, B=usize>>, | +++ +++ -error[E0191]: the value of the associated types `A` (from trait `T`), `C` (from trait `T`) must be specified +error[E0191]: the value of the associated types `C` and `A` in `T` must be specified --> $DIR/use-type-argument-instead-of-assoc-type.rs:7:16 | LL | type A; diff --git a/tests/ui/trait-bounds/restrict-assoc-type-of-generic-bound.fixed b/tests/ui/trait-bounds/restrict-assoc-type-of-generic-bound.fixed new file mode 100644 index 00000000000..b3f5ad52db5 --- /dev/null +++ b/tests/ui/trait-bounds/restrict-assoc-type-of-generic-bound.fixed @@ -0,0 +1,11 @@ +// run-rustfix +pub trait MyTrait { + type T; + + fn bar(self) -> Self::T; +} + +pub fn foo<A: MyTrait<T = B>, B>(a: A) -> B { + return a.bar(); //~ ERROR mismatched types +} +fn main() {} diff --git a/tests/ui/trait-bounds/restrict-assoc-type-of-generic-bound.rs b/tests/ui/trait-bounds/restrict-assoc-type-of-generic-bound.rs new file mode 100644 index 00000000000..213abda7782 --- /dev/null +++ b/tests/ui/trait-bounds/restrict-assoc-type-of-generic-bound.rs @@ -0,0 +1,11 @@ +// run-rustfix +pub trait MyTrait { + type T; + + fn bar(self) -> Self::T; +} + +pub fn foo<A: MyTrait, B>(a: A) -> B { + return a.bar(); //~ ERROR mismatched types +} +fn main() {} diff --git a/tests/ui/trait-bounds/restrict-assoc-type-of-generic-bound.stderr b/tests/ui/trait-bounds/restrict-assoc-type-of-generic-bound.stderr new file mode 100644 index 00000000000..61132efc414 --- /dev/null +++ b/tests/ui/trait-bounds/restrict-assoc-type-of-generic-bound.stderr @@ -0,0 +1,20 @@ +error[E0308]: mismatched types + --> $DIR/restrict-assoc-type-of-generic-bound.rs:9:12 + | +LL | pub fn foo<A: MyTrait, B>(a: A) -> B { + | - - expected `B` because of return type + | | + | expected this type parameter +LL | return a.bar(); + | ^^^^^^^ expected type parameter `B`, found associated type + | + = note: expected type parameter `B` + found associated type `<A as MyTrait>::T` +help: consider further restricting this bound + | +LL | pub fn foo<A: MyTrait<T = B>, B>(a: A) -> B { + | +++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/traits/alias/object-fail.stderr b/tests/ui/traits/alias/object-fail.stderr index 048a150df8c..a27a3ea0ec0 100644 --- a/tests/ui/traits/alias/object-fail.stderr +++ b/tests/ui/traits/alias/object-fail.stderr @@ -9,7 +9,7 @@ note: for a trait to be "object safe" it needs to allow building a vtable to all | = note: the trait cannot be made into an object because it uses `Self` as a type parameter -error[E0191]: the value of the associated type `Item` (from trait `Iterator`) must be specified +error[E0191]: the value of the associated type `Item` in `Iterator` must be specified --> $DIR/object-fail.rs:9:17 | LL | let _: &dyn IteratorAlias = &vec![123].into_iter(); diff --git a/tests/ui/traits/issue-38604.stderr b/tests/ui/traits/issue-38604.stderr index d5327602430..3ab9af21bc4 100644 --- a/tests/ui/traits/issue-38604.stderr +++ b/tests/ui/traits/issue-38604.stderr @@ -11,6 +11,7 @@ LL | trait Foo where u32: Q<Self> { | --- ^^^^^^^ ...because it uses `Self` as a type parameter | | | this trait cannot be made into an object... + = help: only type `()` implements the trait, consider using it directly instead error[E0038]: the trait `Foo` cannot be made into an object --> $DIR/issue-38604.rs:15:9 @@ -25,6 +26,7 @@ LL | trait Foo where u32: Q<Self> { | --- ^^^^^^^ ...because it uses `Self` as a type parameter | | | this trait cannot be made into an object... + = help: only type `()` implements the trait, consider using it directly instead = note: required for the cast from `Box<()>` to `Box<dyn Foo>` error: aborting due to 2 previous errors diff --git a/tests/ui/traits/item-privacy.stderr b/tests/ui/traits/item-privacy.stderr index af2e0763212..244cc2fc592 100644 --- a/tests/ui/traits/item-privacy.stderr +++ b/tests/ui/traits/item-privacy.stderr @@ -8,11 +8,10 @@ LL | S.a(); | ^ method not found in `S` | = help: items from traits can only be used if the trait is implemented and in scope -note: `method::A` defines an item `a`, perhaps you need to implement it - --> $DIR/item-privacy.rs:6:5 +help: the following trait is implemented but not in scope; perhaps add a `use` for it: + | +LL + use method::A; | -LL | trait A { - | ^^^^^^^ error[E0599]: no method named `b` found for struct `S` in the current scope --> $DIR/item-privacy.rs:68:7 @@ -51,11 +50,10 @@ LL | S::a(&S); | ^ function or associated item not found in `S` | = help: items from traits can only be used if the trait is implemented and in scope -note: `method::A` defines an item `a`, perhaps you need to implement it - --> $DIR/item-privacy.rs:6:5 +help: the following trait is implemented but not in scope; perhaps add a `use` for it: + | +LL + use method::A; | -LL | trait A { - | ^^^^^^^ error[E0599]: no function or associated item named `b` found for struct `S` in the current scope --> $DIR/item-privacy.rs:80:8 @@ -91,11 +89,10 @@ LL | S::A; | ^ associated item not found in `S` | = help: items from traits can only be used if the trait is implemented and in scope -note: `assoc_const::A` defines an item `A`, perhaps you need to implement it - --> $DIR/item-privacy.rs:24:5 +help: the following trait is implemented but not in scope; perhaps add a `use` for it: + | +LL + use assoc_const::A; | -LL | trait A { - | ^^^^^^^ error[E0599]: no associated item named `B` found for struct `S` in the current scope --> $DIR/item-privacy.rs:98:8 @@ -143,6 +140,7 @@ LL | const C: u8 = 0; = help: consider moving `C` to another trait = help: consider moving `A` to another trait = help: consider moving `B` to another trait + = help: only type `S` implements the trait, consider using it directly instead error[E0223]: ambiguous associated type --> $DIR/item-privacy.rs:115:12 diff --git a/tests/ui/traits/new-solver/fn-trait.stderr b/tests/ui/traits/new-solver/fn-trait.stderr index d52bcaf25b8..ff6903c5dbf 100644 --- a/tests/ui/traits/new-solver/fn-trait.stderr +++ b/tests/ui/traits/new-solver/fn-trait.stderr @@ -7,6 +7,7 @@ LL | require_fn(f as unsafe fn() -> i32); | required by a bound introduced by this call | = help: the trait `Fn<()>` is not implemented for `unsafe fn() -> i32` + = note: unsafe function cannot be called generically without an unsafe block = note: wrap the `unsafe fn() -> i32` in a closure with no arguments: `|| { /* code */ }` note: required by a bound in `require_fn` --> $DIR/fn-trait.rs:3:23 @@ -97,6 +98,7 @@ LL | require_fn(h); | required by a bound introduced by this call | = help: the trait `Fn<()>` is not implemented for fn item `unsafe fn() -> i32 {h}` + = note: unsafe function cannot be called generically without an unsafe block = note: wrap the `unsafe fn() -> i32 {h}` in a closure with no arguments: `|| { /* code */ }` note: required by a bound in `require_fn` --> $DIR/fn-trait.rs:3:23 diff --git a/tests/ui/traits/non_lifetime_binders/supertrait-object-safety.stderr b/tests/ui/traits/non_lifetime_binders/supertrait-object-safety.stderr index d56519223f4..b6e540c5ffc 100644 --- a/tests/ui/traits/non_lifetime_binders/supertrait-object-safety.stderr +++ b/tests/ui/traits/non_lifetime_binders/supertrait-object-safety.stderr @@ -20,6 +20,7 @@ LL | trait Foo: for<T> Bar<T> {} | --- ^^^^^^^^^^^^^ ...because where clause cannot reference non-lifetime `for<...>` variables | | | this trait cannot be made into an object... + = help: only type `()` implements the trait, consider using it directly instead = note: required for the cast from `&()` to `&dyn Foo` error[E0038]: the trait `Foo` cannot be made into an object @@ -35,6 +36,7 @@ LL | trait Foo: for<T> Bar<T> {} | --- ^^^^^^^^^^^^^ ...because where clause cannot reference non-lifetime `for<...>` variables | | | this trait cannot be made into an object... + = help: only type `()` implements the trait, consider using it directly instead error[E0038]: the trait `Foo` cannot be made into an object --> $DIR/supertrait-object-safety.rs:22:5 @@ -49,6 +51,7 @@ LL | trait Foo: for<T> Bar<T> {} | --- ^^^^^^^^^^^^^ ...because where clause cannot reference non-lifetime `for<...>` variables | | | this trait cannot be made into an object... + = help: only type `()` implements the trait, consider using it directly instead error: aborting due to 3 previous errors; 1 warning emitted diff --git a/tests/ui/traits/object/object-unsafe-missing-assoc-type.rs b/tests/ui/traits/object/object-unsafe-missing-assoc-type.rs new file mode 100644 index 00000000000..21f7fd92e80 --- /dev/null +++ b/tests/ui/traits/object/object-unsafe-missing-assoc-type.rs @@ -0,0 +1,7 @@ +trait Foo { + type Bar<T>; +} + +fn bar(x: &dyn Foo) {} //~ ERROR the trait `Foo` cannot be made into an object + +fn main() {} diff --git a/tests/ui/traits/object/object-unsafe-missing-assoc-type.stderr b/tests/ui/traits/object/object-unsafe-missing-assoc-type.stderr new file mode 100644 index 00000000000..fcaa583e2bd --- /dev/null +++ b/tests/ui/traits/object/object-unsafe-missing-assoc-type.stderr @@ -0,0 +1,18 @@ +error[E0038]: the trait `Foo` cannot be made into an object + --> $DIR/object-unsafe-missing-assoc-type.rs:5:16 + | +LL | fn bar(x: &dyn Foo) {} + | ^^^ `Foo` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> + --> $DIR/object-unsafe-missing-assoc-type.rs:2:10 + | +LL | trait Foo { + | --- this trait cannot be made into an object... +LL | type Bar<T>; + | ^^^ ...because it contains the generic associated type `Bar` + = help: consider moving `Bar` to another trait + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/traits/object/safety.stderr b/tests/ui/traits/object/safety.stderr index a51b6975938..19a46a502c2 100644 --- a/tests/ui/traits/object/safety.stderr +++ b/tests/ui/traits/object/safety.stderr @@ -11,6 +11,7 @@ LL | trait Tr { | -- this trait cannot be made into an object... LL | fn foo(); | ^^^ ...because associated function `foo` has no `self` parameter + = help: only type `St` implements the trait, consider using it directly instead = note: required for the cast from `&St` to `&dyn Tr` help: consider turning `foo` into a method by giving it a `&self` argument | @@ -34,6 +35,7 @@ LL | trait Tr { | -- this trait cannot be made into an object... LL | fn foo(); | ^^^ ...because associated function `foo` has no `self` parameter + = help: only type `St` implements the trait, consider using it directly instead help: consider turning `foo` into a method by giving it a `&self` argument | LL | fn foo(&self); diff --git a/tests/ui/traits/object/with-self-in-projection-output-bad.rs b/tests/ui/traits/object/with-self-in-projection-output-bad.rs index f34fa80a0ce..9515397fb8d 100644 --- a/tests/ui/traits/object/with-self-in-projection-output-bad.rs +++ b/tests/ui/traits/object/with-self-in-projection-output-bad.rs @@ -43,8 +43,8 @@ impl NormalizableHelper for u32 fn main() { let _x: Box<dyn Helper<Target=i32>> = Box::new(2u32); - //~^ ERROR the value of the associated type `Output` (from trait `Base`) must be specified + //~^ ERROR the value of the associated type `Output` in `Base` must be specified let _y: Box<dyn NormalizableHelper<Target=i32>> = Box::new(2u32); - //~^ ERROR the value of the associated type `Output` (from trait `Base`) must be specified + //~^ ERROR the value of the associated type `Output` in `Base` must be specified } diff --git a/tests/ui/traits/object/with-self-in-projection-output-bad.stderr b/tests/ui/traits/object/with-self-in-projection-output-bad.stderr index 641bfe23666..c9b36e8d29d 100644 --- a/tests/ui/traits/object/with-self-in-projection-output-bad.stderr +++ b/tests/ui/traits/object/with-self-in-projection-output-bad.stderr @@ -1,4 +1,4 @@ -error[E0191]: the value of the associated type `Output` (from trait `Base`) must be specified +error[E0191]: the value of the associated type `Output` in `Base` must be specified --> $DIR/with-self-in-projection-output-bad.rs:45:21 | LL | type Output; @@ -7,7 +7,7 @@ LL | type Output; LL | let _x: Box<dyn Helper<Target=i32>> = Box::new(2u32); | ^^^^^^^^^^^^^^^^^^ help: specify the associated type: `Helper<Target=i32, Output = Type>` -error[E0191]: the value of the associated type `Output` (from trait `Base`) must be specified +error[E0191]: the value of the associated type `Output` in `Base` must be specified --> $DIR/with-self-in-projection-output-bad.rs:48:21 | LL | type Output; diff --git a/tests/ui/traits/test-2.stderr b/tests/ui/traits/test-2.stderr index 74a0fc42708..3972e539776 100644 --- a/tests/ui/traits/test-2.stderr +++ b/tests/ui/traits/test-2.stderr @@ -42,6 +42,9 @@ LL | trait bar { fn dup(&self) -> Self; fn blah<X>(&self); } | this trait cannot be made into an object... = help: consider moving `dup` to another trait = help: consider moving `blah` to another trait + = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `bar` for this new enum and using it instead: + i32 + u32 error[E0038]: the trait `bar` cannot be made into an object --> $DIR/test-2.rs:13:5 @@ -59,6 +62,9 @@ LL | trait bar { fn dup(&self) -> Self; fn blah<X>(&self); } | this trait cannot be made into an object... = help: consider moving `dup` to another trait = help: consider moving `blah` to another trait + = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `bar` for this new enum and using it instead: + i32 + u32 error[E0038]: the trait `bar` cannot be made into an object --> $DIR/test-2.rs:13:6 @@ -76,6 +82,9 @@ LL | trait bar { fn dup(&self) -> Self; fn blah<X>(&self); } | this trait cannot be made into an object... = help: consider moving `dup` to another trait = help: consider moving `blah` to another trait + = help: the following types implement the trait, consider defining an enum where each variant holds one of these types, implementing `bar` for this new enum and using it instead: + i32 + u32 = note: required for the cast from `Box<{integer}>` to `Box<dyn bar>` error: aborting due to 5 previous errors diff --git a/tests/ui/type-alias-impl-trait/duplicate-lifetimes-from-rpit-containing-tait.rs b/tests/ui/type-alias-impl-trait/duplicate-lifetimes-from-rpit-containing-tait.rs new file mode 100644 index 00000000000..4c56fe2d1dc --- /dev/null +++ b/tests/ui/type-alias-impl-trait/duplicate-lifetimes-from-rpit-containing-tait.rs @@ -0,0 +1,13 @@ +// check-pass + +#![feature(type_alias_impl_trait)] + +type Opaque<'lt> = impl Sized + 'lt; + +fn test<'a>( + arg: impl Iterator<Item = &'a u8>, +) -> impl Iterator<Item = Opaque<'a>> { + arg +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/duplicate-lifetimes-from-rpit-containing-tait2.rs b/tests/ui/type-alias-impl-trait/duplicate-lifetimes-from-rpit-containing-tait2.rs new file mode 100644 index 00000000000..97f8c799fc5 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/duplicate-lifetimes-from-rpit-containing-tait2.rs @@ -0,0 +1,15 @@ +// check-pass +// edition: 2021 + +#![feature(type_alias_impl_trait)] + +struct Foo<'a>(&'a ()); + +impl<'a> Foo<'a> { + async fn new() -> () { + type T = impl Sized; + let _: T = (); + } +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/infinite-cycle-involving-weak.rs b/tests/ui/type-alias-impl-trait/infinite-cycle-involving-weak.rs new file mode 100644 index 00000000000..6609d4eb5a2 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/infinite-cycle-involving-weak.rs @@ -0,0 +1,8 @@ +#![feature(type_alias_impl_trait)] + +type T = impl Copy; +//~^ ERROR cannot resolve opaque type + +static STATIC: T = None::<&'static T>; + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/infinite-cycle-involving-weak.stderr b/tests/ui/type-alias-impl-trait/infinite-cycle-involving-weak.stderr new file mode 100644 index 00000000000..50ae6f38641 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/infinite-cycle-involving-weak.stderr @@ -0,0 +1,9 @@ +error[E0720]: cannot resolve opaque type + --> $DIR/infinite-cycle-involving-weak.rs:3:10 + | +LL | type T = impl Copy; + | ^^^^^^^^^ cannot resolve opaque type + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0720`. diff --git a/tests/ui/type-alias-impl-trait/nested_impl_trait_in_assoc_ty.rs b/tests/ui/type-alias-impl-trait/nested_impl_trait_in_assoc_ty.rs new file mode 100644 index 00000000000..5f3dbaa1798 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/nested_impl_trait_in_assoc_ty.rs @@ -0,0 +1,44 @@ +//! This test checks that we do not walk types in async blocks for +//! determining the opaque types that appear in a signature. async blocks, +//! all other coroutines and closures are always private and not part of +//! a signature. They become part of a signature via `dyn Trait` or `impl Trait`, +//! which is something that we process abstractly without looking at its hidden +//! types. +// edition: 2021 +// check-pass + +#![feature(impl_trait_in_assoc_type)] + +use std::future::Future; + +pub struct MemtableLocalStateStore { + mem_table: MemTable, +} + +impl LocalStateStore for MemtableLocalStateStore { + type IterStream<'a> = impl Sized + 'a where Self: 'a; + + fn iter(&self) -> impl Future<Output = Self::IterStream<'_>> + '_ { + async move { merge_stream(self.mem_table.iter()) } + } +} + +trait LocalStateStore { + type IterStream<'a> + where + Self: 'a; + + fn iter(&self) -> impl Future<Output = Self::IterStream<'_>> + '_; +} + +struct MemTable; + +impl MemTable { + fn iter<'a>(&'a self) -> impl Iterator<Item = &'a ()> { + std::iter::empty() + } +} + +pub(crate) async fn merge_stream<'a>(mem_table_iter: impl Iterator<Item = &'a ()>) {} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/unconstrained-due-to-bad-pattern.rs b/tests/ui/type-alias-impl-trait/unconstrained-due-to-bad-pattern.rs new file mode 100644 index 00000000000..ae3d317ab46 --- /dev/null +++ b/tests/ui/type-alias-impl-trait/unconstrained-due-to-bad-pattern.rs @@ -0,0 +1,14 @@ +#![feature(type_alias_impl_trait)] + +type Tait = impl Copy; +// Make sure that this TAIT isn't considered unconstrained... + +fn empty_opaque() -> Tait { + if false { + match empty_opaque() {} + //~^ ERROR non-empty + } + 0u8 +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/unconstrained-due-to-bad-pattern.stderr b/tests/ui/type-alias-impl-trait/unconstrained-due-to-bad-pattern.stderr new file mode 100644 index 00000000000..6cc5b7a8a0a --- /dev/null +++ b/tests/ui/type-alias-impl-trait/unconstrained-due-to-bad-pattern.stderr @@ -0,0 +1,17 @@ +error[E0004]: non-exhaustive patterns: type `Tait` is non-empty + --> $DIR/unconstrained-due-to-bad-pattern.rs:8:15 + | +LL | match empty_opaque() {} + | ^^^^^^^^^^^^^^ + | + = note: the matched value is of type `Tait` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown + | +LL ~ match empty_opaque() { +LL + _ => todo!(), +LL + } + | + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr b/tests/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr index 8a296dc7ee6..4412c49eadd 100644 --- a/tests/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr +++ b/tests/ui/type/type-parameter-defaults-referencing-Self-ppaux.stderr @@ -24,6 +24,7 @@ LL | trait MyAdd<Rhs=Self> { fn add(&self, other: &Rhs) -> Self; } | | | this trait cannot be made into an object... = help: consider moving `add` to another trait + = help: only type `i32` implements the trait, consider using it directly instead error: aborting due to 2 previous errors diff --git a/tests/ui/typeck/issue-114529-illegal-break-with-value.rs b/tests/ui/typeck/issue-114529-illegal-break-with-value.rs new file mode 100644 index 00000000000..613d1b6343a --- /dev/null +++ b/tests/ui/typeck/issue-114529-illegal-break-with-value.rs @@ -0,0 +1,20 @@ +// Regression test for issue #114529 +// Tests that we do not ICE during const eval for a +// break-with-value in contexts where it is illegal + +#[allow(while_true)] +fn main() { + [(); { + while true { + break 9; //~ ERROR `break` with value from a `while` loop + }; + 51 + }]; + + [(); { + while let Some(v) = Some(9) { + break v; //~ ERROR `break` with value from a `while` loop + }; + 51 + }]; +} diff --git a/tests/ui/typeck/issue-114529-illegal-break-with-value.stderr b/tests/ui/typeck/issue-114529-illegal-break-with-value.stderr new file mode 100644 index 00000000000..4d6c27bbbd0 --- /dev/null +++ b/tests/ui/typeck/issue-114529-illegal-break-with-value.stderr @@ -0,0 +1,29 @@ +error[E0571]: `break` with value from a `while` loop + --> $DIR/issue-114529-illegal-break-with-value.rs:9:13 + | +LL | while true { + | ---------- you can't `break` with a value in a `while` loop +LL | break 9; + | ^^^^^^^ can only break with a value inside `loop` or breakable block + | +help: use `break` on its own without a value inside this `while` loop + | +LL | break; + | ~~~~~ + +error[E0571]: `break` with value from a `while` loop + --> $DIR/issue-114529-illegal-break-with-value.rs:16:13 + | +LL | while let Some(v) = Some(9) { + | --------------------------- you can't `break` with a value in a `while` loop +LL | break v; + | ^^^^^^^ can only break with a value inside `loop` or breakable block + | +help: use `break` on its own without a value inside this `while` loop + | +LL | break; + | ~~~~~ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0571`. diff --git a/tests/ui/unsized/maybe-bounds-where.rs b/tests/ui/unsized/maybe-bounds-where.rs index d7af0c42480..7e82a3eb449 100644 --- a/tests/ui/unsized/maybe-bounds-where.rs +++ b/tests/ui/unsized/maybe-bounds-where.rs @@ -11,11 +11,11 @@ trait Trait<'a> {} struct S4<T>(T) where for<'a> T: ?Trait<'a>; //~^ ERROR `?Trait` bounds are only permitted at the point where a type parameter is declared -//~| WARN default bound relaxed for a type parameter +//~| WARN relaxing a default bound only does something for `?Sized` struct S5<T>(*const T) where T: ?Trait<'static> + ?Sized; //~^ ERROR type parameter has more than one relaxed default bound -//~| WARN default bound relaxed for a type parameter +//~| WARN relaxing a default bound only does something for `?Sized` impl<T> S1<T> { fn f() where T: ?Sized {} diff --git a/tests/ui/unsized/maybe-bounds-where.stderr b/tests/ui/unsized/maybe-bounds-where.stderr index 39bc1b88e56..683bd387bb2 100644 --- a/tests/ui/unsized/maybe-bounds-where.stderr +++ b/tests/ui/unsized/maybe-bounds-where.stderr @@ -28,23 +28,23 @@ error: `?Trait` bounds are only permitted at the point where a type parameter is LL | fn f() where T: ?Sized {} | ^^^^^^ -warning: default bound relaxed for a type parameter, but this does nothing because the given bound is not a default; only `?Sized` is supported - --> $DIR/maybe-bounds-where.rs:12:11 +warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default + --> $DIR/maybe-bounds-where.rs:12:34 | LL | struct S4<T>(T) where for<'a> T: ?Trait<'a>; - | ^ + | ^^^^^^^^^^ error[E0203]: type parameter has more than one relaxed default bound, only one is supported - --> $DIR/maybe-bounds-where.rs:16:11 + --> $DIR/maybe-bounds-where.rs:16:33 | LL | struct S5<T>(*const T) where T: ?Trait<'static> + ?Sized; - | ^ + | ^^^^^^^^^^^^^^^ ^^^^^^ -warning: default bound relaxed for a type parameter, but this does nothing because the given bound is not a default; only `?Sized` is supported - --> $DIR/maybe-bounds-where.rs:16:11 +warning: relaxing a default bound only does something for `?Sized`; all other traits are not bound by default + --> $DIR/maybe-bounds-where.rs:16:33 | LL | struct S5<T>(*const T) where T: ?Trait<'static> + ?Sized; - | ^ + | ^^^^^^^^^^^^^^^ error: aborting due to 6 previous errors; 2 warnings emitted diff --git a/tests/ui/wf/wf-convert-unsafe-trait-obj-box.stderr b/tests/ui/wf/wf-convert-unsafe-trait-obj-box.stderr index 40a25c7df6b..85f5073364f 100644 --- a/tests/ui/wf/wf-convert-unsafe-trait-obj-box.stderr +++ b/tests/ui/wf/wf-convert-unsafe-trait-obj-box.stderr @@ -11,6 +11,7 @@ LL | trait Trait: Sized {} | ----- ^^^^^ ...because it requires `Self: Sized` | | | this trait cannot be made into an object... + = help: only type `S` implements the trait, consider using it directly instead = note: required for the cast from `Box<S>` to `Box<dyn Trait>` error[E0038]: the trait `Trait` cannot be made into an object @@ -26,6 +27,7 @@ LL | trait Trait: Sized {} | ----- ^^^^^ ...because it requires `Self: Sized` | | | this trait cannot be made into an object... + = help: only type `S` implements the trait, consider using it directly instead = note: required for the cast from `Box<S>` to `Box<(dyn Trait + 'static)>` error[E0038]: the trait `Trait` cannot be made into an object @@ -41,6 +43,7 @@ LL | trait Trait: Sized {} | ----- ^^^^^ ...because it requires `Self: Sized` | | | this trait cannot be made into an object... + = help: only type `S` implements the trait, consider using it directly instead = note: required for the cast from `Box<S>` to `Box<dyn Trait>` error: aborting due to 3 previous errors diff --git a/tests/ui/wf/wf-convert-unsafe-trait-obj.stderr b/tests/ui/wf/wf-convert-unsafe-trait-obj.stderr index e2c71df2feb..a2a19631649 100644 --- a/tests/ui/wf/wf-convert-unsafe-trait-obj.stderr +++ b/tests/ui/wf/wf-convert-unsafe-trait-obj.stderr @@ -11,6 +11,7 @@ LL | trait Trait: Sized {} | ----- ^^^^^ ...because it requires `Self: Sized` | | | this trait cannot be made into an object... + = help: only type `S` implements the trait, consider using it directly instead = note: required for the cast from `&S` to `&dyn Trait` error[E0038]: the trait `Trait` cannot be made into an object @@ -26,6 +27,7 @@ LL | trait Trait: Sized {} | ----- ^^^^^ ...because it requires `Self: Sized` | | | this trait cannot be made into an object... + = help: only type `S` implements the trait, consider using it directly instead = note: required for the cast from `&S` to `&dyn Trait` error[E0038]: the trait `Trait` cannot be made into an object @@ -41,6 +43,7 @@ LL | trait Trait: Sized {} | ----- ^^^^^ ...because it requires `Self: Sized` | | | this trait cannot be made into an object... + = help: only type `S` implements the trait, consider using it directly instead = note: required for the cast from `&S` to `&dyn Trait` error: aborting due to 3 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 d5b23572ff5..a0279774abe 100644 --- a/tests/ui/wf/wf-unsafe-trait-obj-match.stderr +++ b/tests/ui/wf/wf-unsafe-trait-obj-match.stderr @@ -29,6 +29,9 @@ LL | trait Trait: Sized {} | ----- ^^^^^ ...because it requires `Self: 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 = note: required for the cast from `&S` to `&dyn Trait` error[E0038]: the trait `Trait` cannot be made into an object @@ -48,6 +51,9 @@ LL | trait Trait: Sized {} | ----- ^^^^^ ...because it requires `Self: 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 = note: required for the cast from `&R` to `&dyn Trait` error: aborting due to 3 previous errors |
