diff options
| author | Carl Scherer <carl.scherer@49nord.de> | 2022-03-08 17:20:31 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-03-23 16:50:41 +0000 |
| commit | 5e4ff266187e2049a5810f0580bd37dcafc2334d (patch) | |
| tree | f88a964fec65c19bfc4d2d244b6f36c330a22de5 /src | |
| parent | c99b42cf14014987a147918fac2ad3d3290b257e (diff) | |
| download | rust-5e4ff266187e2049a5810f0580bd37dcafc2334d.tar.gz rust-5e4ff266187e2049a5810f0580bd37dcafc2334d.zip | |
separate const prop lint from optimizations
Diffstat (limited to 'src')
25 files changed, 238 insertions, 61 deletions
diff --git a/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-impl.rs b/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-impl.rs index be8162c86b9..0315938a7ed 100644 --- a/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-impl.rs +++ b/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-impl.rs @@ -4,12 +4,12 @@ trait Foo { const BAR: u32; } -const IMPL_REF_BAR: u32 = GlobalImplRef::BAR; //~ ERROR E0391 +const IMPL_REF_BAR: u32 = GlobalImplRef::BAR; struct GlobalImplRef; impl GlobalImplRef { - const BAR: u32 = IMPL_REF_BAR; + const BAR: u32 = IMPL_REF_BAR; //~ ERROR E0391 } fn main() {} diff --git a/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-impl.stderr b/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-impl.stderr index 61b16cb9d58..3d696bb049c 100644 --- a/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-impl.stderr +++ b/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-impl.stderr @@ -1,9 +1,15 @@ -error[E0391]: cycle detected when simplifying constant for the type system `IMPL_REF_BAR` +error[E0391]: cycle detected when elaborating drops for `<impl at $DIR/issue-24949-assoc-const-static-recursion-impl.rs:11:1: 13:2>::BAR` + --> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:12:5 + | +LL | const BAR: u32 = IMPL_REF_BAR; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: ...which requires normalizing `IMPL_REF_BAR`... +note: ...which requires simplifying constant for the type system `IMPL_REF_BAR`... --> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:7:1 | LL | const IMPL_REF_BAR: u32 = GlobalImplRef::BAR; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | note: ...which requires simplifying constant for the type system `IMPL_REF_BAR`... --> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:7:1 | @@ -35,8 +41,7 @@ note: ...which requires caching mir of `<impl at $DIR/issue-24949-assoc-const-st | LL | const BAR: u32 = IMPL_REF_BAR; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: ...which requires normalizing `IMPL_REF_BAR`... - = note: ...which again requires simplifying constant for the type system `IMPL_REF_BAR`, completing the cycle + = note: ...which again requires elaborating drops for `<impl at $DIR/issue-24949-assoc-const-static-recursion-impl.rs:11:1: 13:2>::BAR`, completing the cycle = note: cycle used when running analysis passes on this crate error: aborting due to previous error diff --git a/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait-default.rs b/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait-default.rs index cec75ae19f4..4e89f686288 100644 --- a/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait-default.rs +++ b/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait-default.rs @@ -5,10 +5,10 @@ trait Foo { } trait FooDefault { - const BAR: u32 = DEFAULT_REF_BAR; + const BAR: u32 = DEFAULT_REF_BAR; //~ ERROR E0391 } -const DEFAULT_REF_BAR: u32 = <GlobalDefaultRef>::BAR; //~ ERROR E0391 +const DEFAULT_REF_BAR: u32 = <GlobalDefaultRef>::BAR; struct GlobalDefaultRef; diff --git a/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait-default.stderr b/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait-default.stderr index 494dc0c0ed4..71e26245e16 100644 --- a/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait-default.stderr +++ b/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait-default.stderr @@ -1,9 +1,15 @@ -error[E0391]: cycle detected when simplifying constant for the type system `DEFAULT_REF_BAR` +error[E0391]: cycle detected when elaborating drops for `FooDefault::BAR` + --> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:8:5 + | +LL | const BAR: u32 = DEFAULT_REF_BAR; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: ...which requires normalizing `DEFAULT_REF_BAR`... +note: ...which requires simplifying constant for the type system `DEFAULT_REF_BAR`... --> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:11:1 | LL | const DEFAULT_REF_BAR: u32 = <GlobalDefaultRef>::BAR; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | note: ...which requires simplifying constant for the type system `DEFAULT_REF_BAR`... --> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:11:1 | @@ -35,8 +41,7 @@ note: ...which requires caching mir of `FooDefault::BAR` for CTFE... | LL | const BAR: u32 = DEFAULT_REF_BAR; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: ...which requires normalizing `DEFAULT_REF_BAR`... - = note: ...which again requires simplifying constant for the type system `DEFAULT_REF_BAR`, completing the cycle + = note: ...which again requires elaborating drops for `FooDefault::BAR`, completing the cycle = note: cycle used when running analysis passes on this crate error: aborting due to previous error diff --git a/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.rs b/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.rs index 62af8534340..68b653ff3c5 100644 --- a/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.rs +++ b/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.rs @@ -4,12 +4,12 @@ trait Foo { const BAR: u32; } -const TRAIT_REF_BAR: u32 = <GlobalTraitRef>::BAR; //~ ERROR E0391 +const TRAIT_REF_BAR: u32 = <GlobalTraitRef>::BAR; struct GlobalTraitRef; impl Foo for GlobalTraitRef { - const BAR: u32 = TRAIT_REF_BAR; + const BAR: u32 = TRAIT_REF_BAR; //~ ERROR E0391 } fn main() {} diff --git a/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.stderr b/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.stderr index 4ff253bffcb..020d758e153 100644 --- a/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.stderr +++ b/src/test/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.stderr @@ -1,9 +1,15 @@ -error[E0391]: cycle detected when simplifying constant for the type system `TRAIT_REF_BAR` +error[E0391]: cycle detected when elaborating drops for `<impl at $DIR/issue-24949-assoc-const-static-recursion-trait.rs:11:1: 13:2>::BAR` + --> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:12:5 + | +LL | const BAR: u32 = TRAIT_REF_BAR; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: ...which requires normalizing `TRAIT_REF_BAR`... +note: ...which requires simplifying constant for the type system `TRAIT_REF_BAR`... --> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:7:1 | LL | const TRAIT_REF_BAR: u32 = <GlobalTraitRef>::BAR; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | note: ...which requires simplifying constant for the type system `TRAIT_REF_BAR`... --> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:7:1 | @@ -35,8 +41,7 @@ note: ...which requires caching mir of `<impl at $DIR/issue-24949-assoc-const-st | LL | const BAR: u32 = TRAIT_REF_BAR; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: ...which requires normalizing `TRAIT_REF_BAR`... - = note: ...which again requires simplifying constant for the type system `TRAIT_REF_BAR`, completing the cycle + = note: ...which again requires elaborating drops for `<impl at $DIR/issue-24949-assoc-const-static-recursion-trait.rs:11:1: 13:2>::BAR`, completing the cycle = note: cycle used when running analysis passes on this crate error: aborting due to previous error diff --git a/src/test/ui/const_prop/inline_spans.rs b/src/test/ui/const_prop/inline_spans.rs index f1cfcfee557..504f2781156 100644 --- a/src/test/ui/const_prop/inline_spans.rs +++ b/src/test/ui/const_prop/inline_spans.rs @@ -1,18 +1,15 @@ -// build-fail +// build-pass // compile-flags: -Zmir-opt-level=3 +// Overflow can't be detected by const prop +// could only be detected after optimizations #![deny(warnings)] fn main() { let _ = add(u8::MAX, 1); - //~^ NOTE in this expansion of inlined source - //~| NOTE in this expansion of inlined source } #[inline(always)] fn add(x: u8, y: u8) -> u8 { x + y - //~^ ERROR this arithmetic operation will overflow - //~| NOTE attempt to compute `u8::MAX + 1_u8`, which would overflow - //~| NOTE `#[deny(arithmetic_overflow)]` on by default } diff --git a/src/test/ui/const_prop/inline_spans.stderr b/src/test/ui/const_prop/inline_spans.stderr deleted file mode 100644 index f99a3142386..00000000000 --- a/src/test/ui/const_prop/inline_spans.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error: this arithmetic operation will overflow - --> $DIR/inline_spans.rs:14:5 - | -LL | let _ = add(u8::MAX, 1); - | --------------- in this inlined function call -... -LL | x + y - | ^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow - | - = note: `#[deny(arithmetic_overflow)]` on by default - -error: aborting due to previous error - diff --git a/src/test/ui/consts/const-eval/const-eval-query-stack.stderr b/src/test/ui/consts/const-eval/const-eval-query-stack.stderr index 45a3d901c98..8bd5c08dc46 100644 --- a/src/test/ui/consts/const-eval/const-eval-query-stack.stderr +++ b/src/test/ui/consts/const-eval/const-eval-query-stack.stderr @@ -21,6 +21,7 @@ LL | let x: &'static i32 = &X; | ^ referenced constant has errors query stack during panic: #0 [try_normalize_mir_const_after_erasing_regions] normalizing `main::promoted[1]` -#1 [optimized_mir] optimizing MIR for `main` -#2 [collect_and_partition_mono_items] collect_and_partition_mono_items +#1 [mir_drops_elaborated_and_const_checked] elaborating drops for `main` +#2 [optimized_mir] optimizing MIR for `main` +#3 [collect_and_partition_mono_items] collect_and_partition_mono_items end of query stack diff --git a/src/test/ui/consts/const-eval/issue-49296.stderr b/src/test/ui/consts/const-eval/issue-49296.stderr index 1864a284579..cc4f1594c32 100644 --- a/src/test/ui/consts/const-eval/issue-49296.stderr +++ b/src/test/ui/consts/const-eval/issue-49296.stderr @@ -2,7 +2,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/issue-49296.rs:9:16 | LL | const X: u64 = *wat(42); - | ^^^^^^^^ pointer to alloc2 was dereferenced after this allocation got freed + | ^^^^^^^^ pointer to alloc3 was dereferenced after this allocation got freed error: aborting due to previous error diff --git a/src/test/ui/consts/const-eval/panic-assoc-never-type.rs b/src/test/ui/consts/const-eval/panic-assoc-never-type.rs index 2bdf5d54765..80b0a1432fb 100644 --- a/src/test/ui/consts/const-eval/panic-assoc-never-type.rs +++ b/src/test/ui/consts/const-eval/panic-assoc-never-type.rs @@ -13,4 +13,5 @@ impl PrintName { fn main() { let _ = PrintName::VOID; + //~^ ERROR erroneous constant used [E0080] } diff --git a/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr b/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr index 9631b7748b5..0116a83910d 100644 --- a/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr +++ b/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr @@ -6,6 +6,12 @@ LL | const VOID: ! = panic!(); | = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to previous error +error[E0080]: erroneous constant used + --> $DIR/panic-assoc-never-type.rs:15:13 + | +LL | let _ = PrintName::VOID; + | ^^^^^^^^^^^^^^^ referenced constant has errors + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/promoted_errors.noopt.stderr b/src/test/ui/consts/const-eval/promoted_errors.noopt.stderr index 77e7d484071..5bfd4ef92a9 100644 --- a/src/test/ui/consts/const-eval/promoted_errors.noopt.stderr +++ b/src/test/ui/consts/const-eval/promoted_errors.noopt.stderr @@ -1,3 +1,45 @@ +warning: this arithmetic operation will overflow + --> $DIR/promoted_errors.rs:15:5 + | +LL | 0 - 1 + | ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow + | +note: the lint level is defined here + --> $DIR/promoted_errors.rs:11:20 + | +LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] + | ^^^^^^^^^^^^^^^^^^^ + +warning: this operation will panic at runtime + --> $DIR/promoted_errors.rs:21:5 + | +LL | 1 / 0 + | ^^^^^ attempt to divide `1_i32` by zero + | +note: the lint level is defined here + --> $DIR/promoted_errors.rs:11:41 + | +LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] + | ^^^^^^^^^^^^^^^^^^^ + +warning: this operation will panic at runtime + --> $DIR/promoted_errors.rs:27:5 + | +LL | 1 / (1 - 1) + | ^^^^^^^^^^^ attempt to divide `1_i32` by zero + +warning: this operation will panic at runtime + --> $DIR/promoted_errors.rs:31:5 + | +LL | 1 / (false as i32) + | ^^^^^^^^^^^^^^^^^^ attempt to divide `1_i32` by zero + +warning: this operation will panic at runtime + --> $DIR/promoted_errors.rs:35:5 + | +LL | [1, 2, 3][4] + | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 + warning: any use of this value will cause an error --> $DIR/promoted_errors.rs:15:5 | @@ -6,7 +48,7 @@ LL | 0 - 1 | | | attempt to compute `0_u32 - 1_u32`, which would overflow | inside `overflow` at $DIR/promoted_errors.rs:15:5 - | inside `X` at $DIR/promoted_errors.rs:38:29 + | inside `X` at $DIR/promoted_errors.rs:43:29 ... LL | / const X: () = { LL | | let _x: &'static u32 = &overflow(); @@ -26,7 +68,7 @@ LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:38:28 + --> $DIR/promoted_errors.rs:43:28 | LL | / const X: () = { LL | | let _x: &'static u32 = &overflow(); @@ -41,5 +83,5 @@ LL | | }; = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> -warning: 2 warnings emitted +warning: 7 warnings emitted diff --git a/src/test/ui/consts/const-eval/promoted_errors.opt.stderr b/src/test/ui/consts/const-eval/promoted_errors.opt.stderr index 6b17346e6ec..0a8a8aef3cf 100644 --- a/src/test/ui/consts/const-eval/promoted_errors.opt.stderr +++ b/src/test/ui/consts/const-eval/promoted_errors.opt.stderr @@ -1,12 +1,54 @@ +warning: this arithmetic operation will overflow + --> $DIR/promoted_errors.rs:15:5 + | +LL | 0 - 1 + | ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow + | +note: the lint level is defined here + --> $DIR/promoted_errors.rs:11:20 + | +LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] + | ^^^^^^^^^^^^^^^^^^^ + +warning: this operation will panic at runtime + --> $DIR/promoted_errors.rs:21:5 + | +LL | 1 / 0 + | ^^^^^ attempt to divide `1_i32` by zero + | +note: the lint level is defined here + --> $DIR/promoted_errors.rs:11:41 + | +LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] + | ^^^^^^^^^^^^^^^^^^^ + +warning: this operation will panic at runtime + --> $DIR/promoted_errors.rs:27:5 + | +LL | 1 / (1 - 1) + | ^^^^^^^^^^^ attempt to divide `1_i32` by zero + +warning: this operation will panic at runtime + --> $DIR/promoted_errors.rs:31:5 + | +LL | 1 / (false as i32) + | ^^^^^^^^^^^^^^^^^^ attempt to divide `1_i32` by zero + +warning: this operation will panic at runtime + --> $DIR/promoted_errors.rs:35:5 + | +LL | [1, 2, 3][4] + | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 + warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:20:5 + --> $DIR/promoted_errors.rs:21:5 | LL | 1 / 0 | ^^^^^ | | | attempt to divide `1_i32` by zero - | inside `div_by_zero1` at $DIR/promoted_errors.rs:20:5 - | inside `X` at $DIR/promoted_errors.rs:41:29 + | inside `div_by_zero1` at $DIR/promoted_errors.rs:21:5 + | inside `X` at $DIR/promoted_errors.rs:46:29 ... LL | / const X: () = { LL | | let _x: &'static u32 = &overflow(); @@ -26,7 +68,7 @@ LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:41:28 + --> $DIR/promoted_errors.rs:46:28 | LL | / const X: () = { LL | | let _x: &'static u32 = &overflow(); @@ -42,5 +84,5 @@ LL | | }; = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> -warning: 2 warnings emitted +warning: 7 warnings emitted diff --git a/src/test/ui/consts/const-eval/promoted_errors.opt_with_overflow_checks.stderr b/src/test/ui/consts/const-eval/promoted_errors.opt_with_overflow_checks.stderr index 77e7d484071..5bfd4ef92a9 100644 --- a/src/test/ui/consts/const-eval/promoted_errors.opt_with_overflow_checks.stderr +++ b/src/test/ui/consts/const-eval/promoted_errors.opt_with_overflow_checks.stderr @@ -1,3 +1,45 @@ +warning: this arithmetic operation will overflow + --> $DIR/promoted_errors.rs:15:5 + | +LL | 0 - 1 + | ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow + | +note: the lint level is defined here + --> $DIR/promoted_errors.rs:11:20 + | +LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] + | ^^^^^^^^^^^^^^^^^^^ + +warning: this operation will panic at runtime + --> $DIR/promoted_errors.rs:21:5 + | +LL | 1 / 0 + | ^^^^^ attempt to divide `1_i32` by zero + | +note: the lint level is defined here + --> $DIR/promoted_errors.rs:11:41 + | +LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] + | ^^^^^^^^^^^^^^^^^^^ + +warning: this operation will panic at runtime + --> $DIR/promoted_errors.rs:27:5 + | +LL | 1 / (1 - 1) + | ^^^^^^^^^^^ attempt to divide `1_i32` by zero + +warning: this operation will panic at runtime + --> $DIR/promoted_errors.rs:31:5 + | +LL | 1 / (false as i32) + | ^^^^^^^^^^^^^^^^^^ attempt to divide `1_i32` by zero + +warning: this operation will panic at runtime + --> $DIR/promoted_errors.rs:35:5 + | +LL | [1, 2, 3][4] + | ^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 4 + warning: any use of this value will cause an error --> $DIR/promoted_errors.rs:15:5 | @@ -6,7 +48,7 @@ LL | 0 - 1 | | | attempt to compute `0_u32 - 1_u32`, which would overflow | inside `overflow` at $DIR/promoted_errors.rs:15:5 - | inside `X` at $DIR/promoted_errors.rs:38:29 + | inside `X` at $DIR/promoted_errors.rs:43:29 ... LL | / const X: () = { LL | | let _x: &'static u32 = &overflow(); @@ -26,7 +68,7 @@ LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:38:28 + --> $DIR/promoted_errors.rs:43:28 | LL | / const X: () = { LL | | let _x: &'static u32 = &overflow(); @@ -41,5 +83,5 @@ LL | | }; = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> -warning: 2 warnings emitted +warning: 7 warnings emitted diff --git a/src/test/ui/consts/const-eval/promoted_errors.rs b/src/test/ui/consts/const-eval/promoted_errors.rs index 5bafea1ed46..eb891de33c4 100644 --- a/src/test/ui/consts/const-eval/promoted_errors.rs +++ b/src/test/ui/consts/const-eval/promoted_errors.rs @@ -15,20 +15,25 @@ const fn overflow() -> u32 { 0 - 1 //[opt_with_overflow_checks,noopt]~^ WARN any use of this value will cause an error //[opt_with_overflow_checks,noopt]~| WARN this was previously accepted by the compiler + //~^^^ WARN this arithmetic operation will overflow } const fn div_by_zero1() -> i32 { 1 / 0 //[opt]~^ WARN any use of this value will cause an error //[opt]~| WARN this was previously accepted by the compiler but is being phased out + //~^^^ WARN this operation will panic at runtime } const fn div_by_zero2() -> i32 { 1 / (1 - 1) + //~^ WARN this operation will panic at runtime } const fn div_by_zero3() -> i32 { 1 / (false as i32) + //~^ WARN this operation will panic at runtime } const fn oob() -> i32 { [1, 2, 3][4] + //~^ WARN this operation will panic at runtime } // An unused constant containing failing promoteds. diff --git a/src/test/ui/consts/const-eval/union-const-eval-field.rs b/src/test/ui/consts/const-eval/union-const-eval-field.rs index 80263718330..a1e48cac4fa 100644 --- a/src/test/ui/consts/const-eval/union-const-eval-field.rs +++ b/src/test/ui/consts/const-eval/union-const-eval-field.rs @@ -28,6 +28,7 @@ const fn read_field3() -> Field3 { const FIELD3: Field3 = unsafe { UNION.field3 }; //~^ ERROR it is undefined behavior to use this value FIELD3 + //~^ ERROR erroneous constant used [E0080] } fn main() { diff --git a/src/test/ui/consts/const-eval/union-const-eval-field.stderr b/src/test/ui/consts/const-eval/union-const-eval-field.stderr index e5a107ff011..8f818462781 100644 --- a/src/test/ui/consts/const-eval/union-const-eval-field.stderr +++ b/src/test/ui/consts/const-eval/union-const-eval-field.stderr @@ -9,6 +9,12 @@ LL | const FIELD3: Field3 = unsafe { UNION.field3 }; __ __ __ __ __ __ __ __ │ ░░░░░░░░ } -error: aborting due to previous error +error[E0080]: erroneous constant used + --> $DIR/union-const-eval-field.rs:30:5 + | +LL | FIELD3 + | ^^^^^^ referenced constant has errors + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/issue-56164.rs b/src/test/ui/consts/issue-56164.rs index 22ac75514f6..094ca377e03 100644 --- a/src/test/ui/consts/issue-56164.rs +++ b/src/test/ui/consts/issue-56164.rs @@ -1,5 +1,7 @@ const fn foo() { (||{})() } //~^ ERROR cannot call non-const closure +//~| ERROR erroneous constant used [const_err] +//~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! const fn bad(input: fn()) { input() diff --git a/src/test/ui/consts/issue-56164.stderr b/src/test/ui/consts/issue-56164.stderr index 803424eedf3..b997aff0e83 100644 --- a/src/test/ui/consts/issue-56164.stderr +++ b/src/test/ui/consts/issue-56164.stderr @@ -8,11 +8,21 @@ LL | const fn foo() { (||{})() } = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error: function pointers are not allowed in const fn - --> $DIR/issue-56164.rs:5:5 + --> $DIR/issue-56164.rs:7:5 | LL | input() | ^^^^^^^ -error: aborting due to 2 previous errors +error: erroneous constant used + --> $DIR/issue-56164.rs:1:18 + | +LL | const fn foo() { (||{})() } + | ^^^^^^ referenced constant has errors + | + = note: `#[deny(const_err)]` on by default + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0015`. diff --git a/src/test/ui/consts/issue-66693.rs b/src/test/ui/consts/issue-66693.rs index 909bef7aefb..99d28eb773f 100644 --- a/src/test/ui/consts/issue-66693.rs +++ b/src/test/ui/consts/issue-66693.rs @@ -8,7 +8,10 @@ static _FOO: () = panic!(true); //~^ ERROR: argument to `panic!()` in a const context must have type `&str` const fn _foo() { - panic!(&1); //~ ERROR: argument to `panic!()` in a const context must have type `&str` + panic!(&1); + //~^ ERROR: argument to `panic!()` in a const context must have type `&str` + //~| ERROR: erroneous constant used [const_err] + //~| WARNING: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! } // ensure that conforming panics don't cause an error diff --git a/src/test/ui/consts/issue-66693.stderr b/src/test/ui/consts/issue-66693.stderr index 3530324bda2..b8257684983 100644 --- a/src/test/ui/consts/issue-66693.stderr +++ b/src/test/ui/consts/issue-66693.stderr @@ -22,5 +22,15 @@ LL | panic!(&1); | = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 3 previous errors +error: erroneous constant used + --> $DIR/issue-66693.rs:11:12 + | +LL | panic!(&1); + | ^^ referenced constant has errors + | + = note: `#[deny(const_err)]` on by default + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #71800 <https://github.com/rust-lang/rust/issues/71800> + +error: aborting due to 4 previous errors diff --git a/src/test/ui/consts/promotion.rs b/src/test/ui/consts/promotion.rs index 580c6d62f10..b7f451b0262 100644 --- a/src/test/ui/consts/promotion.rs +++ b/src/test/ui/consts/promotion.rs @@ -4,11 +4,14 @@ //[opt_with_overflow_checks]compile-flags: -C overflow-checks=on -O // build-pass -#[allow(arithmetic_overflow)] +// #![allow(arithmetic_overflow, unconditional_panic)] const fn assert_static<T>(_: &'static T) {} -const fn fail() -> i32 { 1/0 } +#[allow(unconditional_panic)] +const fn fail() -> i32 { + 1/0 +} const C: i32 = { // Promoted that fails to evaluate in dead code -- this must work // (for backwards compatibility reasons). diff --git a/src/test/ui/recursion/issue-26548-recursion-via-normalize.rs b/src/test/ui/recursion/issue-26548-recursion-via-normalize.rs index 4fd5622b062..366ea7d3b3f 100644 --- a/src/test/ui/recursion/issue-26548-recursion-via-normalize.rs +++ b/src/test/ui/recursion/issue-26548-recursion-via-normalize.rs @@ -2,7 +2,6 @@ //~| NOTE ...which requires computing layout of `core::option::Option<<S as Mirror>::It>`... //~| NOTE ...which requires computing layout of `core::option::Option<S>`... //~| NOTE ...which again requires computing layout of `S`, completing the cycle -//~| NOTE cycle used when computing layout of `core::option::Option<S>` // build-fail @@ -15,5 +14,6 @@ impl<T: ?Sized> Mirror for T { struct S(Option<<S as Mirror>::It>); fn main() { + //~^ NOTE cycle used when elaborating drops for `main` let _s = S(None); } diff --git a/src/test/ui/recursion/issue-26548-recursion-via-normalize.stderr b/src/test/ui/recursion/issue-26548-recursion-via-normalize.stderr index 6042379a918..5b675dc9f81 100644 --- a/src/test/ui/recursion/issue-26548-recursion-via-normalize.stderr +++ b/src/test/ui/recursion/issue-26548-recursion-via-normalize.stderr @@ -3,7 +3,11 @@ error[E0391]: cycle detected when computing layout of `S` = note: ...which requires computing layout of `core::option::Option<<S as Mirror>::It>`... = note: ...which requires computing layout of `core::option::Option<S>`... = note: ...which again requires computing layout of `S`, completing the cycle - = note: cycle used when computing layout of `core::option::Option<S>` +note: cycle used when elaborating drops for `main` + --> $DIR/issue-26548-recursion-via-normalize.rs:16:1 + | +LL | fn main() { + | ^^^^^^^^^ error: aborting due to previous error |
