From 9e692049b462dbb35b5f3da0125f05aeaa38346d Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Mon, 5 Feb 2024 22:39:10 +0000 Subject: [PATCH 1/2] Run const_prop_lint in check builds, too --- compiler/rustc_abi/src/layout.rs | 9 +- compiler/rustc_interface/src/passes.rs | 1 + compiler/rustc_middle/src/query/mod.rs | 6 + compiler/rustc_mir_transform/src/lib.rs | 24 +- src/doc/rustc/src/lints/levels.md | 4 +- .../ui-toml/suppress_lint_in_const/test.rs | 5 +- .../suppress_lint_in_const/test.stderr | 24 +- .../clippy/tests/ui/indexing_slicing_index.rs | 4 +- .../tests/ui/indexing_slicing_index.stderr | 23 +- tests/mir-opt/dataflow-const-prop/enum.rs | 2 +- ...mutes.integer_transmutes.InstSimplify.diff | 14 +- .../instsimplify/combine_transmutes.rs | 11 +- .../array_const_index-0.stderr | 14 + .../array_const_index-1.stderr | 14 + .../associated-consts/defaults-cyclic-fail.rs | 2 - .../defaults-cyclic-fail.stderr | 10 +- .../defaults-not-assumed-fail.rs | 2 - .../defaults-not-assumed-fail.stderr | 8 +- ...9-assoc-const-static-recursion-impl.stderr | 9 +- ...onst-static-recursion-trait-default.stderr | 9 +- ...-assoc-const-static-recursion-trait.stderr | 9 +- .../indirect-recursion-issue-112047.rs | 3 - .../indirect-recursion-issue-112047.stderr | 2 +- .../occurs-check/opaques.next.stderr | 4 +- .../coherence/occurs-check/opaques.old.stderr | 8 + tests/ui/coherence/occurs-check/opaques.rs | 6 +- tests/ui/const_prop/const-prop-ice.rs | 2 - tests/ui/const_prop/const-prop-ice.stderr | 2 +- tests/ui/const_prop/const-prop-ice2.rs | 2 - tests/ui/const_prop/const-prop-ice2.stderr | 2 +- tests/ui/consts/const-err-early.rs | 2 +- tests/ui/consts/const-err-early.stderr | 80 +++++- tests/ui/consts/const-err-late.rs | 1 - tests/ui/consts/const-err-late.stderr | 12 +- tests/ui/consts/const-err-multi.stderr | 56 ++++ tests/ui/consts/const-err2.noopt.stderr | 14 +- tests/ui/consts/const-err2.opt.stderr | 14 +- ...const-err2.opt_with_overflow_checks.stderr | 14 +- tests/ui/consts/const-err2.rs | 2 - .../conditional_array_execution.stderr | 23 ++ .../const-eval/const-eval-overflow2.stderr | 48 ++++ .../const-eval/const-eval-overflow2b.stderr | 48 ++++ .../const-eval/const-eval-overflow2c.stderr | 48 ++++ .../const-eval/const-eval-query-stack.stderr | 6 +- .../const-eval/const_fn_ptr_fail2.stderr | 46 +++ .../index_out_of_bounds_propagated.rs | 2 - .../index_out_of_bounds_propagated.stderr | 2 +- tests/ui/consts/const-eval/issue-43197.stderr | 46 +++ tests/ui/consts/const-eval/issue-44578.rs | 2 - tests/ui/consts/const-eval/issue-44578.stderr | 8 +- tests/ui/consts/const-eval/issue-49296.stderr | 23 ++ .../const-eval/panic-assoc-never-type.rs | 2 - .../const-eval/panic-assoc-never-type.stderr | 8 +- .../consts/const-eval/panic-never-type.stderr | 14 + .../stable-metric/ctfe-fn-call.stderr | 23 ++ .../stable-metric/ctfe-labelled-loop.stderr | 23 ++ .../stable-metric/ctfe-recursion.stderr | 23 ++ .../validate_uninhabited_zsts.64bit.stderr | 52 ++-- .../const-eval/validate_uninhabited_zsts.rs | 2 - .../const-float-bits-reject-conv.stderr | 86 +++--- .../consts/const-mut-refs/mut_ref_in_final.rs | 1 + .../const-mut-refs/mut_ref_in_final.stderr | 40 ++- tests/ui/consts/const-slice-oob.stderr | 14 + tests/ui/consts/const-unwrap.stderr | 23 ++ .../consts/const_unsafe_unreachable_ub.stderr | 23 ++ tests/ui/consts/dangling_raw_ptr.stderr | 14 + .../interior-mut-const-via-union.64bit.stderr | 6 +- .../ui/consts/interior-mut-const-via-union.rs | 1 - tests/ui/consts/issue-54348.rs | 2 - tests/ui/consts/issue-54348.stderr | 4 +- tests/ui/consts/large_const_alloc.rs | 3 +- tests/ui/consts/large_const_alloc.stderr | 18 +- tests/ui/consts/large_static_alloc.rs | 11 + tests/ui/consts/large_static_alloc.stderr | 9 + tests/ui/consts/miri_unleashed/assoc_const.rs | 1 - .../consts/miri_unleashed/assoc_const.stderr | 8 +- .../ui/consts/miri_unleashed/assoc_const_2.rs | 2 +- .../mutable_pointer_in_const.64bit.stderr | 22 ++ .../mutable_pointer_in_const.rs | 25 ++ .../mutable_references_err.64bit.stderr | 75 +++-- .../miri_unleashed/mutable_references_err.rs | 17 +- .../consts/missing_span_in_backtrace.stderr | 14 + .../consts/uninhabited-const-issue-61744.rs | 2 - .../uninhabited-const-issue-61744.stderr | 262 +++++++++--------- ...ecursive-coroutine-indirect.current.stderr | 2 +- .../recursive-coroutine-indirect.next.stderr | 2 +- .../recursive-coroutine-indirect.rs | 1 - tests/ui/limits/issue-55878.rs | 1 - tests/ui/limits/issue-55878.stderr | 6 +- tests/ui/lint/lint-type-overflow2.rs | 1 + tests/ui/lint/lint-type-overflow2.stderr | 18 +- tests/ui/lint/unconditional_panic_98444.rs | 2 - .../ui/lint/unconditional_panic_98444.stderr | 2 +- tests/ui/mir/mir_detects_invalid_ops.rs | 2 - tests/ui/mir/mir_detects_invalid_ops.stderr | 4 +- .../issue-8460-const.noopt.stderr | 48 ++-- .../issue-8460-const.opt.stderr | 48 ++-- ...8460-const.opt_with_overflow_checks.stderr | 48 ++-- .../ui/numbers-arithmetic/issue-8460-const.rs | 2 - .../numbers-arithmetic/overflowing-lsh-1.rs | 1 - .../overflowing-lsh-1.stderr | 4 +- .../numbers-arithmetic/overflowing-lsh-2.rs | 1 - .../overflowing-lsh-2.stderr | 4 +- .../numbers-arithmetic/overflowing-lsh-3.rs | 1 - .../overflowing-lsh-3.stderr | 4 +- .../numbers-arithmetic/overflowing-lsh-4.rs | 1 - .../overflowing-lsh-4.stderr | 4 +- .../numbers-arithmetic/overflowing-rsh-1.rs | 1 - .../overflowing-rsh-1.stderr | 4 +- .../numbers-arithmetic/overflowing-rsh-2.rs | 1 - .../overflowing-rsh-2.stderr | 4 +- .../numbers-arithmetic/overflowing-rsh-3.rs | 1 - .../overflowing-rsh-3.stderr | 4 +- .../numbers-arithmetic/overflowing-rsh-4.rs | 1 - .../overflowing-rsh-4.stderr | 4 +- .../numbers-arithmetic/overflowing-rsh-5.rs | 1 - .../overflowing-rsh-5.stderr | 4 +- tests/ui/query-system/query_depth.rs | 4 +- tests/ui/query-system/query_depth.stderr | 2 +- .../issue-26548-recursion-via-normalize.rs | 8 +- ...issue-26548-recursion-via-normalize.stderr | 12 +- .../const-drop.precise.stderr | 58 +++- .../type-generic-monomorphisation-empty.rs | 2 - ...-generic-monomorphisation-non-primitive.rs | 2 - ...type-generic-monomorphisation-oversized.rs | 2 - .../type-generic-monomorphisation-wide-ptr.rs | 2 - .../ui/simd/type-generic-monomorphisation.rs | 3 - tests/ui/simd/type-wide-ptr.rs | 2 - tests/ui/sized/recursive-type-binding.rs | 3 +- tests/ui/sized/recursive-type-binding.stderr | 4 +- .../recursive-type-coercion-from-never.rs | 3 +- .../recursive-type-coercion-from-never.stderr | 4 +- .../indirect-recursion-issue-112047.rs | 1 - .../indirect-recursion-issue-112047.stderr | 4 +- .../mututally-recursive-overflow.rs | 3 +- 135 files changed, 1318 insertions(+), 595 deletions(-) create mode 100644 tests/ui/coherence/occurs-check/opaques.old.stderr create mode 100644 tests/ui/consts/large_static_alloc.rs create mode 100644 tests/ui/consts/large_static_alloc.stderr create mode 100644 tests/ui/consts/miri_unleashed/mutable_pointer_in_const.64bit.stderr create mode 100644 tests/ui/consts/miri_unleashed/mutable_pointer_in_const.rs diff --git a/compiler/rustc_abi/src/layout.rs b/compiler/rustc_abi/src/layout.rs index ec3ab828b7194..484328c17e0e0 100644 --- a/compiler/rustc_abi/src/layout.rs +++ b/compiler/rustc_abi/src/layout.rs @@ -426,10 +426,11 @@ where } } } - _ => assert!( - start == Bound::Unbounded && end == Bound::Unbounded, - "nonscalar layout for layout_scalar_valid_range type: {st:#?}", - ), + _ => { + if start != Bound::Unbounded || end != Bound::Unbounded { + return None; + } + } } Some(st) diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index 9795640412069..86465f3634221 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -738,6 +738,7 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> { // Run unsafety check because it's responsible for stealing and // deallocating THIR. tcx.ensure().check_unsafety(def_id); + tcx.ensure().const_prop_lint(def_id); tcx.ensure().mir_borrowck(def_id) }); }); diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index 938fba0ed0981..71ecc0c09f98f 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -1018,6 +1018,12 @@ rustc_queries! { cache_on_disk_if(tcx) { tcx.is_typeck_child(key.to_def_id()) } } + /// Run the const prop lints on the `mir_promoted` of an item. + query const_prop_lint(key: LocalDefId) { + desc { |tcx| "checking const prop lints for `{}`", tcx.def_path_str(key) } + cache_on_disk_if { true } + } + /// Gets a complete map from all types to their inherent impls. /// Not meant to be used directly outside of coherence. query crate_inherent_impls(k: ()) -> Result<&'tcx CrateInherentImpls, ErrorGuaranteed> { diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index 031515ea95828..bda2f175e68f9 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -142,6 +142,7 @@ pub fn provide(providers: &mut Providers) { is_ctfe_mir_available: |tcx, did| is_mir_available(tcx, did), mir_callgraph_reachable: inline::cycle::mir_callgraph_reachable, mir_inliner_callees: inline::cycle::mir_inliner_callees, + const_prop_lint, promoted_mir, deduced_param_attrs: deduce_param_attrs::deduced_param_attrs, ..*providers @@ -398,6 +399,27 @@ fn inner_mir_for_ctfe(tcx: TyCtxt<'_>, def: LocalDefId) -> Body<'_> { body } +fn const_prop_lint(tcx: TyCtxt<'_>, def: LocalDefId) { + let (body, _) = tcx.mir_promoted(def); + let body = body.borrow(); + + let mir_borrowck = tcx.mir_borrowck(def); + + // If there are impossible bounds on the body being const prop linted, + // the const eval logic used in const prop may ICE unexpectedly. + let predicates = tcx + .predicates_of(body.source.def_id()) + .predicates + .iter() + .filter_map(|(p, _)| if p.is_global() { Some(*p) } else { None }); + if !traits::impossible_predicates(tcx, traits::elaborate(tcx, predicates).collect()) + && mir_borrowck.tainted_by_errors.is_none() + && body.tainted_by_errors.is_none() + { + const_prop_lint::ConstPropLint.run_lint(tcx, &body); + } +} + /// Obtain just the main MIR (no promoteds) and run some cleanups on it. This also runs /// mir borrowck *before* doing so in order to ensure that borrowck can be run and doesn't /// end up missing the source MIR due to stealing happening. @@ -406,6 +428,7 @@ fn mir_drops_elaborated_and_const_checked(tcx: TyCtxt<'_>, def: LocalDefId) -> & tcx.ensure_with_value().mir_coroutine_witnesses(def); } let mir_borrowck = tcx.mir_borrowck(def); + tcx.ensure().const_prop_lint(def); let is_fn_like = tcx.def_kind(def).is_fn_like(); if is_fn_like { @@ -538,7 +561,6 @@ fn run_runtime_lowering_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { &elaborate_box_derefs::ElaborateBoxDerefs, &coroutine::StateTransform, &add_retag::AddRetag, - &Lint(const_prop_lint::ConstPropLint), ]; pm::run_passes_no_validate(tcx, body, passes, Some(MirPhase::Runtime(RuntimePhase::Initial))); } diff --git a/src/doc/rustc/src/lints/levels.md b/src/doc/rustc/src/lints/levels.md index 93892d6ade61b..4e2c93afc9f19 100644 --- a/src/doc/rustc/src/lints/levels.md +++ b/src/doc/rustc/src/lints/levels.md @@ -71,7 +71,7 @@ level is capped via cap-lints. A 'deny' lint produces an error if you violate it. For example, this code runs into the `exceeding_bitshifts` lint. -```rust,no_run +```rust,compile_fail fn main() { 100u8 << 10; } @@ -246,7 +246,7 @@ pub fn foo() {} This is the maximum level for all lints. So for example, if we take our code sample from the "deny" lint level above: -```rust,no_run +```rust,compile_fail fn main() { 100u8 << 10; } diff --git a/src/tools/clippy/tests/ui-toml/suppress_lint_in_const/test.rs b/src/tools/clippy/tests/ui-toml/suppress_lint_in_const/test.rs index 3edb3a10b7695..661bd1e8ea4dd 100644 --- a/src/tools/clippy/tests/ui-toml/suppress_lint_in_const/test.rs +++ b/src/tools/clippy/tests/ui-toml/suppress_lint_in_const/test.rs @@ -35,9 +35,8 @@ fn main() { x[const { idx() }]; // Ok, should not produce stderr. x[const { idx4() }]; // Ok, let rustc's `unconditional_panic` lint handle `usize` indexing on arrays. const { &ARR[idx()] }; // Ok, should not produce stderr, since `suppress-restriction-lint-in-const` is set true. - const { &ARR[idx4()] }; // Ok, should not produce stderr, since `suppress-restriction-lint-in-const` is set true. - // - //~^^ ERROR: failed + // FIXME errors in rustc and subsequently blocks all lints in this file. Can reenable once solved on the rustc side + //const { &ARR[idx4()] }; // Ok, should not produce stderr, since `suppress-restriction-lint-in-const` is set true. let y = &x; y[0]; // Ok, referencing shouldn't affect this lint. See the issue 6021 diff --git a/src/tools/clippy/tests/ui-toml/suppress_lint_in_const/test.stderr b/src/tools/clippy/tests/ui-toml/suppress_lint_in_const/test.stderr index 84e7eff45573e..56acca8cc0226 100644 --- a/src/tools/clippy/tests/ui-toml/suppress_lint_in_const/test.stderr +++ b/src/tools/clippy/tests/ui-toml/suppress_lint_in_const/test.stderr @@ -1,15 +1,3 @@ -error[E0080]: evaluation of `main::{constant#3}` failed - --> $DIR/test.rs:38:14 - | -LL | const { &ARR[idx4()] }; // Ok, should not produce stderr, since `suppress-restriction-lint-in-const` is set true. - | ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4 - -note: erroneous constant encountered - --> $DIR/test.rs:38:5 - | -LL | const { &ARR[idx4()] }; // Ok, should not produce stderr, since `suppress-restriction-lint-in-const` is set true. - | ^^^^^^^^^^^^^^^^^^^^^^ - error: indexing may panic --> $DIR/test.rs:29:5 | @@ -21,7 +9,7 @@ LL | x[index]; = help: to override `-D warnings` add `#[allow(clippy::indexing_slicing)]` error: indexing may panic - --> $DIR/test.rs:47:5 + --> $DIR/test.rs:46:5 | LL | v[0]; | ^^^^ @@ -29,7 +17,7 @@ LL | v[0]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic - --> $DIR/test.rs:48:5 + --> $DIR/test.rs:47:5 | LL | v[10]; | ^^^^^ @@ -37,7 +25,7 @@ LL | v[10]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic - --> $DIR/test.rs:49:5 + --> $DIR/test.rs:48:5 | LL | v[1 << 3]; | ^^^^^^^^^ @@ -45,7 +33,7 @@ LL | v[1 << 3]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic - --> $DIR/test.rs:55:5 + --> $DIR/test.rs:54:5 | LL | v[N]; | ^^^^ @@ -53,7 +41,7 @@ LL | v[N]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic - --> $DIR/test.rs:56:5 + --> $DIR/test.rs:55:5 | LL | v[M]; | ^^^^ @@ -66,6 +54,6 @@ error[E0080]: evaluation of constant value failed LL | const REF_ERR: &i32 = &ARR[idx4()]; // Ok, let rustc handle const contexts. | ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4 -error: aborting due to 8 previous errors +error: aborting due to 7 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/src/tools/clippy/tests/ui/indexing_slicing_index.rs b/src/tools/clippy/tests/ui/indexing_slicing_index.rs index 1ac0bb11014aa..62a4290efe113 100644 --- a/src/tools/clippy/tests/ui/indexing_slicing_index.rs +++ b/src/tools/clippy/tests/ui/indexing_slicing_index.rs @@ -45,8 +45,8 @@ fn main() { const { &ARR[idx()] }; //~^ ERROR: indexing may panic // This should be linted, since `suppress-restriction-lint-in-const` default is false. - const { &ARR[idx4()] }; - //~^ ERROR: indexing may panic + // FIXME can't include here for now, as the error on it causes all lints to get silenced + //const { &ARR[idx4()] }; let y = &x; // Ok, referencing shouldn't affect this lint. See the issue 6021 diff --git a/src/tools/clippy/tests/ui/indexing_slicing_index.stderr b/src/tools/clippy/tests/ui/indexing_slicing_index.stderr index 6d64fa1e6cf89..fdaf6c42d149d 100644 --- a/src/tools/clippy/tests/ui/indexing_slicing_index.stderr +++ b/src/tools/clippy/tests/ui/indexing_slicing_index.stderr @@ -18,18 +18,6 @@ LL | const REF_ERR: &i32 = &ARR[idx4()]; // Ok, let rustc handle const contexts. = help: consider using `.get(n)` or `.get_mut(n)` instead = note: the suggestion might not be applicable in constant blocks -error[E0080]: evaluation of `main::{constant#3}` failed - --> $DIR/indexing_slicing_index.rs:48:14 - | -LL | const { &ARR[idx4()] }; - | ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4 - -note: erroneous constant encountered - --> $DIR/indexing_slicing_index.rs:48:5 - | -LL | const { &ARR[idx4()] }; - | ^^^^^^^^^^^^^^^^^^^^^^ - error: indexing may panic --> $DIR/indexing_slicing_index.rs:29:5 | @@ -62,15 +50,6 @@ LL | const { &ARR[idx()] }; = help: consider using `.get(n)` or `.get_mut(n)` instead = note: the suggestion might not be applicable in constant blocks -error: indexing may panic - --> $DIR/indexing_slicing_index.rs:48:14 - | -LL | const { &ARR[idx4()] }; - | ^^^^^^^^^^^ - | - = help: consider using `.get(n)` or `.get_mut(n)` instead - = note: the suggestion might not be applicable in constant blocks - error: index is out of bounds --> $DIR/indexing_slicing_index.rs:55:5 | @@ -135,6 +114,6 @@ error[E0080]: evaluation of constant value failed LL | const REF_ERR: &i32 = &ARR[idx4()]; // Ok, let rustc handle const contexts. | ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4 -error: aborting due to 17 previous errors +error: aborting due to 15 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/tests/mir-opt/dataflow-const-prop/enum.rs b/tests/mir-opt/dataflow-const-prop/enum.rs index 7ad64d05be434..0de3f33fe3776 100644 --- a/tests/mir-opt/dataflow-const-prop/enum.rs +++ b/tests/mir-opt/dataflow-const-prop/enum.rs @@ -62,7 +62,7 @@ fn statics() { static RC: &E = &E::V2(4); - // CHECK: [[t:_.*]] = const {alloc2: &&E}; + // CHECK: [[t:_.*]] = const {alloc4: &&E}; // CHECK: [[e2]] = (*[[t]]); let e2 = RC; diff --git a/tests/mir-opt/instsimplify/combine_transmutes.integer_transmutes.InstSimplify.diff b/tests/mir-opt/instsimplify/combine_transmutes.integer_transmutes.InstSimplify.diff index 8eff802dd3c4b..42230873d32a4 100644 --- a/tests/mir-opt/instsimplify/combine_transmutes.integer_transmutes.InstSimplify.diff +++ b/tests/mir-opt/instsimplify/combine_transmutes.integer_transmutes.InstSimplify.diff @@ -5,19 +5,15 @@ let mut _0: (); let mut _1: u32; let mut _2: i64; - let mut _3: i64; - let mut _4: u32; - let mut _5: usize; + let mut _3: usize; bb0: { - _1 = const 1_i32 as u32 (Transmute); +- _2 = const 1_u64 as i64 (Transmute); +- _3 = const 1_isize as usize (Transmute); + _1 = const 1_i32 as u32 (IntToInt); - _2 = const 1_i32 as i64 (Transmute); -- _3 = const 1_u64 as i64 (Transmute); -+ _3 = const 1_u64 as i64 (IntToInt); - _4 = const 1_u64 as u32 (Transmute); -- _5 = const 1_isize as usize (Transmute); -+ _5 = const 1_isize as usize (IntToInt); ++ _2 = const 1_u64 as i64 (IntToInt); ++ _3 = const 1_isize as usize (IntToInt); return; } } diff --git a/tests/mir-opt/instsimplify/combine_transmutes.rs b/tests/mir-opt/instsimplify/combine_transmutes.rs index b8e15da905bda..8cf889bb621bf 100644 --- a/tests/mir-opt/instsimplify/combine_transmutes.rs +++ b/tests/mir-opt/instsimplify/combine_transmutes.rs @@ -6,7 +6,7 @@ #![feature(custom_mir)] use std::intrinsics::mir::*; -use std::mem::{MaybeUninit, ManuallyDrop, transmute}; +use std::mem::{transmute, ManuallyDrop, MaybeUninit}; // EMIT_MIR combine_transmutes.identity_transmutes.InstSimplify.diff pub unsafe fn identity_transmutes() { @@ -25,19 +25,15 @@ pub unsafe fn integer_transmutes() { // CHECK-LABEL: fn integer_transmutes( // CHECK-NOT: _i32 as u32 (Transmute); // CHECK: _i32 as u32 (IntToInt); - // CHECK: _i32 as i64 (Transmute); // CHECK-NOT: _u64 as i64 (Transmute); // CHECK: _u64 as i64 (IntToInt); - // CHECK: _u64 as u32 (Transmute); // CHECK-NOT: _isize as usize (Transmute); // CHECK: _isize as usize (IntToInt); mir! { { let A = CastTransmute::(1); // Can be a cast - let B = CastTransmute::(1); // UB let C = CastTransmute::(1); // Can be a cast - let D = CastTransmute::(1); // UB let E = CastTransmute::(1); // Can be a cast Return() } @@ -62,4 +58,7 @@ pub unsafe fn adt_transmutes() { let _a: ManuallyDrop = transmute(MaybeUninit::::uninit()); } -pub union Union32 { u32: u32, i32: i32 } +pub union Union32 { + u32: u32, + i32: i32, +} diff --git a/tests/ui/array-slice-vec/array_const_index-0.stderr b/tests/ui/array-slice-vec/array_const_index-0.stderr index d16e8d50dfdd5..29a838b929362 100644 --- a/tests/ui/array-slice-vec/array_const_index-0.stderr +++ b/tests/ui/array-slice-vec/array_const_index-0.stderr @@ -4,6 +4,20 @@ error[E0080]: evaluation of constant value failed LL | const B: i32 = (&A)[1]; | ^^^^^^^ index out of bounds: the length is 0 but the index is 1 +note: erroneous constant encountered + --> $DIR/array_const_index-0.rs:7:13 + | +LL | let _ = B; + | ^ + +note: erroneous constant encountered + --> $DIR/array_const_index-0.rs:7:13 + | +LL | let _ = B; + | ^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/array-slice-vec/array_const_index-1.stderr b/tests/ui/array-slice-vec/array_const_index-1.stderr index f9ba2f13911bd..caf4e3741e738 100644 --- a/tests/ui/array-slice-vec/array_const_index-1.stderr +++ b/tests/ui/array-slice-vec/array_const_index-1.stderr @@ -4,6 +4,20 @@ error[E0080]: evaluation of constant value failed LL | const B: i32 = A[1]; | ^^^^ index out of bounds: the length is 0 but the index is 1 +note: erroneous constant encountered + --> $DIR/array_const_index-1.rs:7:13 + | +LL | let _ = B; + | ^ + +note: erroneous constant encountered + --> $DIR/array_const_index-1.rs:7:13 + | +LL | let _ = B; + | ^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/associated-consts/defaults-cyclic-fail.rs b/tests/ui/associated-consts/defaults-cyclic-fail.rs index 9ef0003da173f..80f64ba6e8838 100644 --- a/tests/ui/associated-consts/defaults-cyclic-fail.rs +++ b/tests/ui/associated-consts/defaults-cyclic-fail.rs @@ -1,5 +1,3 @@ -// build-fail - // Cyclic assoc. const defaults don't error unless *used* trait Tr { const A: u8 = Self::B; diff --git a/tests/ui/associated-consts/defaults-cyclic-fail.stderr b/tests/ui/associated-consts/defaults-cyclic-fail.stderr index 9cee03041fe6d..3415fd7838d57 100644 --- a/tests/ui/associated-consts/defaults-cyclic-fail.stderr +++ b/tests/ui/associated-consts/defaults-cyclic-fail.stderr @@ -1,27 +1,27 @@ error[E0391]: cycle detected when simplifying constant for the type system `Tr::A` - --> $DIR/defaults-cyclic-fail.rs:5:5 + --> $DIR/defaults-cyclic-fail.rs:3:5 | LL | const A: u8 = Self::B; | ^^^^^^^^^^^ | note: ...which requires const-evaluating + checking `Tr::A`... - --> $DIR/defaults-cyclic-fail.rs:5:19 + --> $DIR/defaults-cyclic-fail.rs:3:19 | LL | const A: u8 = Self::B; | ^^^^^^^ note: ...which requires simplifying constant for the type system `Tr::B`... - --> $DIR/defaults-cyclic-fail.rs:8:5 + --> $DIR/defaults-cyclic-fail.rs:6:5 | LL | const B: u8 = Self::A; | ^^^^^^^^^^^ note: ...which requires const-evaluating + checking `Tr::B`... - --> $DIR/defaults-cyclic-fail.rs:8:19 + --> $DIR/defaults-cyclic-fail.rs:6:19 | LL | const B: u8 = Self::A; | ^^^^^^^ = note: ...which again requires simplifying constant for the type system `Tr::A`, completing the cycle note: cycle used when const-evaluating + checking `main::promoted[1]` - --> $DIR/defaults-cyclic-fail.rs:16:16 + --> $DIR/defaults-cyclic-fail.rs:14:16 | LL | assert_eq!(<() as Tr>::A, 0); | ^^^^^^^^^^^^^ diff --git a/tests/ui/associated-consts/defaults-not-assumed-fail.rs b/tests/ui/associated-consts/defaults-not-assumed-fail.rs index 495dfb338ae31..79db01376eee7 100644 --- a/tests/ui/associated-consts/defaults-not-assumed-fail.rs +++ b/tests/ui/associated-consts/defaults-not-assumed-fail.rs @@ -1,5 +1,3 @@ -// build-fail - trait Tr { const A: u8 = 255; diff --git a/tests/ui/associated-consts/defaults-not-assumed-fail.stderr b/tests/ui/associated-consts/defaults-not-assumed-fail.stderr index 091a50f9463b9..4e89aea4d4ff3 100644 --- a/tests/ui/associated-consts/defaults-not-assumed-fail.stderr +++ b/tests/ui/associated-consts/defaults-not-assumed-fail.stderr @@ -1,17 +1,17 @@ error[E0080]: evaluation of `<() as Tr>::B` failed - --> $DIR/defaults-not-assumed-fail.rs:8:19 + --> $DIR/defaults-not-assumed-fail.rs:6:19 | LL | const B: u8 = Self::A + 1; | ^^^^^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow note: erroneous constant encountered - --> $DIR/defaults-not-assumed-fail.rs:33:16 + --> $DIR/defaults-not-assumed-fail.rs:31:16 | LL | assert_eq!(<() as Tr>::B, 0); // causes the error above | ^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/defaults-not-assumed-fail.rs:33:5 + --> $DIR/defaults-not-assumed-fail.rs:31:5 | LL | assert_eq!(<() as Tr>::B, 0); // causes the error above | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | assert_eq!(<() as Tr>::B, 0); // causes the error above = note: this note originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) note: erroneous constant encountered - --> $DIR/defaults-not-assumed-fail.rs:33:5 + --> $DIR/defaults-not-assumed-fail.rs:31:5 | LL | assert_eq!(<() as Tr>::B, 0); // causes the error above | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/associated-consts/issue-24949-assoc-const-static-recursion-impl.stderr b/tests/ui/associated-consts/issue-24949-assoc-const-static-recursion-impl.stderr index 88b17be601ceb..5b64ac8360215 100644 --- a/tests/ui/associated-consts/issue-24949-assoc-const-static-recursion-impl.stderr +++ b/tests/ui/associated-consts/issue-24949-assoc-const-static-recursion-impl.stderr @@ -1,4 +1,4 @@ -error[E0391]: cycle detected when elaborating drops for `::BAR` +error[E0391]: cycle detected when checking const prop lints for `::BAR` --> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:12:22 | LL | const BAR: u32 = IMPL_REF_BAR; @@ -29,7 +29,12 @@ note: ...which requires caching mir of `::BAR`, completing the cycle +note: ...which requires elaborating drops for `::BAR`... + --> $DIR/issue-24949-assoc-const-static-recursion-impl.rs:12:5 + | +LL | const BAR: u32 = IMPL_REF_BAR; + | ^^^^^^^^^^^^^^ + = note: ...which again requires checking const prop lints for `::BAR`, completing the cycle = note: cycle used when running analysis passes on this crate = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information diff --git a/tests/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait-default.stderr b/tests/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait-default.stderr index fd1b4f2f964b0..f2d57e87e5647 100644 --- a/tests/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait-default.stderr +++ b/tests/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait-default.stderr @@ -1,4 +1,4 @@ -error[E0391]: cycle detected when elaborating drops for `FooDefault::BAR` +error[E0391]: cycle detected when checking const prop lints for `FooDefault::BAR` --> $DIR/issue-24949-assoc-const-static-recursion-trait-default.rs:8:22 | LL | const BAR: u32 = DEFAULT_REF_BAR; @@ -29,7 +29,12 @@ note: ...which requires caching mir of `FooDefault::BAR` for CTFE... | LL | const BAR: u32 = DEFAULT_REF_BAR; | ^^^^^^^^^^^^^^ - = note: ...which again requires elaborating drops for `FooDefault::BAR`, completing the cycle +note: ...which requires 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 again requires checking const prop lints for `FooDefault::BAR`, completing the cycle = note: cycle used when running analysis passes on this crate = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information diff --git a/tests/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.stderr b/tests/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.stderr index 303400f928e65..2e49bb1ce9c40 100644 --- a/tests/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.stderr +++ b/tests/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.stderr @@ -1,4 +1,4 @@ -error[E0391]: cycle detected when elaborating drops for `::BAR` +error[E0391]: cycle detected when checking const prop lints for `::BAR` --> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:12:22 | LL | const BAR: u32 = TRAIT_REF_BAR; @@ -29,7 +29,12 @@ note: ...which requires caching mir of `::BAR`, completing the cycle +note: ...which requires elaborating drops for `::BAR`... + --> $DIR/issue-24949-assoc-const-static-recursion-trait.rs:12:5 + | +LL | const BAR: u32 = TRAIT_REF_BAR; + | ^^^^^^^^^^^^^^ + = note: ...which again requires checking const prop lints for `::BAR`, completing the cycle = note: cycle used when running analysis passes on this crate = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information diff --git a/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.rs b/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.rs index 4b615343a05f2..df14146d2a8b1 100644 --- a/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.rs +++ b/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.rs @@ -1,8 +1,5 @@ // edition: 2021 -// Test doesn't fail until monomorphization time, unfortunately. -// build-fail - fn main() { let _ = async { A.first().await.second().await; diff --git a/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.stderr b/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.stderr index 8126c6e13942e..4ca6ef8981984 100644 --- a/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.stderr +++ b/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.stderr @@ -1,5 +1,5 @@ error[E0733]: recursion in an async fn requires boxing - --> $DIR/indirect-recursion-issue-112047.rs:34:5 + --> $DIR/indirect-recursion-issue-112047.rs:31:5 | LL | async fn second(self) { | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/coherence/occurs-check/opaques.next.stderr b/tests/ui/coherence/occurs-check/opaques.next.stderr index 4ad8257d2c14b..122434c0d32f6 100644 --- a/tests/ui/coherence/occurs-check/opaques.next.stderr +++ b/tests/ui/coherence/occurs-check/opaques.next.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `Trait>` for type `Alias<_>` - --> $DIR/opaques.rs:30:1 + --> $DIR/opaques.rs:34:1 | LL | impl Trait for T { | ---------------------- first implementation here @@ -8,7 +8,7 @@ LL | impl Trait for defining_scope::Alias { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Alias<_>` error[E0282]: type annotations needed - --> $DIR/opaques.rs:13:20 + --> $DIR/opaques.rs:17:20 | LL | pub fn cast(x: Container, T>) -> Container { | ^ cannot infer type for struct `Container, T>` diff --git a/tests/ui/coherence/occurs-check/opaques.old.stderr b/tests/ui/coherence/occurs-check/opaques.old.stderr new file mode 100644 index 0000000000000..c3155fa67b0a9 --- /dev/null +++ b/tests/ui/coherence/occurs-check/opaques.old.stderr @@ -0,0 +1,8 @@ +error: internal compiler error: unexpected ambiguity: Canonical { value: ParamEnvAnd { param_env: ParamEnv { caller_bounds: [Binder { value: TraitPredicate(, polarity:Positive), bound_vars: [] }], reveal: All }, value: AliasTy { args: [T/#0, T/#0], def_id: DefId(0:15 ~ opaques[e7ab]::Trait::Assoc) } }, max_universe: U0, variables: [] } Canonical { value: QueryResponse { var_values: CanonicalVarValues { var_values: [] }, region_constraints: QueryRegionConstraints { outlives: [], member_constraints: [] }, certainty: Ambiguous, opaque_types: [], value: NormalizationResult { normalized_ty: ^0 } }, max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] } + | + = error: internal compiler error: unexpected ambiguity: Canonical { value: ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All }, value: AliasTy { args: [(), ()], def_id: DefId(0:15 ~ opaques[e7ab]::Trait::Assoc) } }, max_universe: U0, variables: [] } Canonical { value: QueryResponse { var_values: CanonicalVarValues { var_values: [] }, region_constraints: QueryRegionConstraints { outlives: [], member_constraints: [] }, certainty: Ambiguous, opaque_types: [], value: NormalizationResult { normalized_ty: ^0 } }, max_universe: U0, variables: [CanonicalVarInfo { kind: Ty(General(U0)) }] } + | + = query stack during panic: +end of query stack +error: aborting due to 2 previous errors + diff --git a/tests/ui/coherence/occurs-check/opaques.rs b/tests/ui/coherence/occurs-check/opaques.rs index 73cd42bf3f25d..c6fa589f511e5 100644 --- a/tests/ui/coherence/occurs-check/opaques.rs +++ b/tests/ui/coherence/occurs-check/opaques.rs @@ -4,7 +4,11 @@ // A regression test for #105787 //[old] known-bug: #105787 -//[old] check-pass +//[old] failure-status: 101 +// normalize-stderr-test "note: .*\n\n" -> "" +// normalize-stderr-test "thread 'rustc' panicked.*\n" -> "" +// normalize-stderr-test "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: " +// rustc-env:RUST_BACKTRACE=0 #![feature(type_alias_impl_trait)] mod defining_scope { use super::*; diff --git a/tests/ui/const_prop/const-prop-ice.rs b/tests/ui/const_prop/const-prop-ice.rs index 5bffe0206294d..1a904c6048815 100644 --- a/tests/ui/const_prop/const-prop-ice.rs +++ b/tests/ui/const_prop/const-prop-ice.rs @@ -1,5 +1,3 @@ -// build-fail - fn main() { [0; 3][3u64 as usize]; //~ ERROR this operation will panic at runtime } diff --git a/tests/ui/const_prop/const-prop-ice.stderr b/tests/ui/const_prop/const-prop-ice.stderr index 8a0f831ba847d..0c82e430fb2b2 100644 --- a/tests/ui/const_prop/const-prop-ice.stderr +++ b/tests/ui/const_prop/const-prop-ice.stderr @@ -1,5 +1,5 @@ error: this operation will panic at runtime - --> $DIR/const-prop-ice.rs:4:5 + --> $DIR/const-prop-ice.rs:2:5 | LL | [0; 3][3u64 as usize]; | ^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 3 diff --git a/tests/ui/const_prop/const-prop-ice2.rs b/tests/ui/const_prop/const-prop-ice2.rs index d533e394c06fb..3209665957870 100644 --- a/tests/ui/const_prop/const-prop-ice2.rs +++ b/tests/ui/const_prop/const-prop-ice2.rs @@ -1,5 +1,3 @@ -// build-fail - fn main() { enum Enum { One=1 } let xs=[0;1 as usize]; diff --git a/tests/ui/const_prop/const-prop-ice2.stderr b/tests/ui/const_prop/const-prop-ice2.stderr index 593b0b94ca2de..261ed7ba863c2 100644 --- a/tests/ui/const_prop/const-prop-ice2.stderr +++ b/tests/ui/const_prop/const-prop-ice2.stderr @@ -1,5 +1,5 @@ error: this operation will panic at runtime - --> $DIR/const-prop-ice2.rs:6:20 + --> $DIR/const-prop-ice2.rs:4:20 | LL | println!("{}", xs[Enum::One as usize]); | ^^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 1 diff --git a/tests/ui/consts/const-err-early.rs b/tests/ui/consts/const-err-early.rs index a3105b4fc4a37..d84c5a248ee1e 100644 --- a/tests/ui/consts/const-err-early.rs +++ b/tests/ui/consts/const-err-early.rs @@ -10,5 +10,5 @@ fn main() { let _c = C; let _d = D; let _e = E; - let _e = [6u8][1]; + let _e = [6u8][1]; //~ ERROR: will panic at runtime } diff --git a/tests/ui/consts/const-err-early.stderr b/tests/ui/consts/const-err-early.stderr index 59bf637b7adbd..6747c2bd5cc60 100644 --- a/tests/ui/consts/const-err-early.stderr +++ b/tests/ui/consts/const-err-early.stderr @@ -4,30 +4,108 @@ error[E0080]: evaluation of constant value failed LL | pub const A: i8 = -i8::MIN; | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow +note: erroneous constant encountered + --> $DIR/const-err-early.rs:8:14 + | +LL | let _a = A; + | ^ + +note: erroneous constant encountered + --> $DIR/const-err-early.rs:8:14 + | +LL | let _a = A; + | ^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error[E0080]: evaluation of constant value failed --> $DIR/const-err-early.rs:2:19 | LL | pub const B: u8 = 200u8 + 200u8; | ^^^^^^^^^^^^^ attempt to compute `200_u8 + 200_u8`, which would overflow +note: erroneous constant encountered + --> $DIR/const-err-early.rs:9:14 + | +LL | let _b = B; + | ^ + +note: erroneous constant encountered + --> $DIR/const-err-early.rs:9:14 + | +LL | let _b = B; + | ^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error[E0080]: evaluation of constant value failed --> $DIR/const-err-early.rs:3:19 | LL | pub const C: u8 = 200u8 * 4; | ^^^^^^^^^ attempt to compute `200_u8 * 4_u8`, which would overflow +note: erroneous constant encountered + --> $DIR/const-err-early.rs:10:14 + | +LL | let _c = C; + | ^ + +note: erroneous constant encountered + --> $DIR/const-err-early.rs:10:14 + | +LL | let _c = C; + | ^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error[E0080]: evaluation of constant value failed --> $DIR/const-err-early.rs:4:19 | LL | pub const D: u8 = 42u8 - (42u8 + 1); | ^^^^^^^^^^^^^^^^^ attempt to compute `42_u8 - 43_u8`, which would overflow +note: erroneous constant encountered + --> $DIR/const-err-early.rs:11:14 + | +LL | let _d = D; + | ^ + +note: erroneous constant encountered + --> $DIR/const-err-early.rs:11:14 + | +LL | let _d = D; + | ^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error[E0080]: evaluation of constant value failed --> $DIR/const-err-early.rs:5:19 | LL | pub const E: u8 = [5u8][1]; | ^^^^^^^^ index out of bounds: the length is 1 but the index is 1 -error: aborting due to 5 previous errors +note: erroneous constant encountered + --> $DIR/const-err-early.rs:12:14 + | +LL | let _e = E; + | ^ + +note: erroneous constant encountered + --> $DIR/const-err-early.rs:12:14 + | +LL | let _e = E; + | ^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: this operation will panic at runtime + --> $DIR/const-err-early.rs:13:14 + | +LL | let _e = [6u8][1]; + | ^^^^^^^^ index out of bounds: the length is 1 but the index is 1 + | + = note: `#[deny(unconditional_panic)]` on by default + +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-err-late.rs b/tests/ui/consts/const-err-late.rs index d2476e4934656..61a3a217a0151 100644 --- a/tests/ui/consts/const-err-late.rs +++ b/tests/ui/consts/const-err-late.rs @@ -1,4 +1,3 @@ -// build-fail // compile-flags: -C overflow-checks=on #![allow(arithmetic_overflow, unconditional_panic)] diff --git a/tests/ui/consts/const-err-late.stderr b/tests/ui/consts/const-err-late.stderr index 53badeafa35b6..cd61e341d74fa 100644 --- a/tests/ui/consts/const-err-late.stderr +++ b/tests/ui/consts/const-err-late.stderr @@ -1,29 +1,29 @@ error[E0080]: evaluation of `S::::FOO` failed - --> $DIR/const-err-late.rs:13:21 + --> $DIR/const-err-late.rs:12:21 | LL | const FOO: u8 = [5u8][1]; | ^^^^^^^^ index out of bounds: the length is 1 but the index is 1 note: erroneous constant encountered - --> $DIR/const-err-late.rs:19:16 + --> $DIR/const-err-late.rs:18:16 | LL | black_box((S::::FOO, S::::FOO)); | ^^^^^^^^^^^^^ error[E0080]: evaluation of `S::::FOO` failed - --> $DIR/const-err-late.rs:13:21 + --> $DIR/const-err-late.rs:12:21 | LL | const FOO: u8 = [5u8][1]; | ^^^^^^^^ index out of bounds: the length is 1 but the index is 1 note: erroneous constant encountered - --> $DIR/const-err-late.rs:19:31 + --> $DIR/const-err-late.rs:18:31 | LL | black_box((S::::FOO, S::::FOO)); | ^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/const-err-late.rs:19:16 + --> $DIR/const-err-late.rs:18:16 | LL | black_box((S::::FOO, S::::FOO)); | ^^^^^^^^^^^^^ @@ -31,7 +31,7 @@ LL | black_box((S::::FOO, S::::FOO)); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` note: erroneous constant encountered - --> $DIR/const-err-late.rs:19:31 + --> $DIR/const-err-late.rs:18:31 | LL | black_box((S::::FOO, S::::FOO)); | ^^^^^^^^^^^^^ diff --git a/tests/ui/consts/const-err-multi.stderr b/tests/ui/consts/const-err-multi.stderr index 2fe0b9bb463a5..69410dcefcb22 100644 --- a/tests/ui/consts/const-err-multi.stderr +++ b/tests/ui/consts/const-err-multi.stderr @@ -4,24 +4,80 @@ error[E0080]: evaluation of constant value failed LL | pub const A: i8 = -i8::MIN; | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow +note: erroneous constant encountered + --> $DIR/const-err-multi.rs:11:14 + | +LL | let _ = (A, B, C, D); + | ^ + note: erroneous constant encountered --> $DIR/const-err-multi.rs:3:19 | LL | pub const B: i8 = A; | ^ +note: erroneous constant encountered + --> $DIR/const-err-multi.rs:11:17 + | +LL | let _ = (A, B, C, D); + | ^ + note: erroneous constant encountered --> $DIR/const-err-multi.rs:5:19 | LL | pub const C: u8 = A as u8; | ^ +note: erroneous constant encountered + --> $DIR/const-err-multi.rs:11:20 + | +LL | let _ = (A, B, C, D); + | ^ + note: erroneous constant encountered --> $DIR/const-err-multi.rs:7:24 | LL | pub const D: i8 = 50 - A; | ^ +note: erroneous constant encountered + --> $DIR/const-err-multi.rs:11:23 + | +LL | let _ = (A, B, C, D); + | ^ + +note: erroneous constant encountered + --> $DIR/const-err-multi.rs:11:14 + | +LL | let _ = (A, B, C, D); + | ^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +note: erroneous constant encountered + --> $DIR/const-err-multi.rs:11:17 + | +LL | let _ = (A, B, C, D); + | ^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +note: erroneous constant encountered + --> $DIR/const-err-multi.rs:11:20 + | +LL | let _ = (A, B, C, D); + | ^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +note: erroneous constant encountered + --> $DIR/const-err-multi.rs:11:23 + | +LL | let _ = (A, B, C, D); + | ^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-err2.noopt.stderr b/tests/ui/consts/const-err2.noopt.stderr index 8b1688c4a8989..1ded24dbf8ad1 100644 --- a/tests/ui/consts/const-err2.noopt.stderr +++ b/tests/ui/consts/const-err2.noopt.stderr @@ -1,5 +1,5 @@ error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:19:13 + --> $DIR/const-err2.rs:17:13 | LL | let a = -i8::MIN; | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow @@ -7,37 +7,37 @@ LL | let a = -i8::MIN; = note: `#[deny(arithmetic_overflow)]` on by default error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:21:18 + --> $DIR/const-err2.rs:19:18 | LL | let a_i128 = -i128::MIN; | ^^^^^^^^^^ attempt to negate `i128::MIN`, which would overflow error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:23:13 + --> $DIR/const-err2.rs:21:13 | LL | let b = 200u8 + 200u8 + 200u8; | ^^^^^^^^^^^^^ attempt to compute `200_u8 + 200_u8`, which would overflow error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:25:18 + --> $DIR/const-err2.rs:23:18 | LL | let b_i128 = i128::MIN - i128::MAX; | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN - i128::MAX`, which would overflow error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:27:13 + --> $DIR/const-err2.rs:25:13 | LL | let c = 200u8 * 4; | ^^^^^^^^^ attempt to compute `200_u8 * 4_u8`, which would overflow error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:29:13 + --> $DIR/const-err2.rs:27:13 | LL | let d = 42u8 - (42u8 + 1); | ^^^^^^^^^^^^^^^^^ attempt to compute `42_u8 - 43_u8`, which would overflow error: this operation will panic at runtime - --> $DIR/const-err2.rs:31:14 + --> $DIR/const-err2.rs:29:14 | LL | let _e = [5u8][1]; | ^^^^^^^^ index out of bounds: the length is 1 but the index is 1 diff --git a/tests/ui/consts/const-err2.opt.stderr b/tests/ui/consts/const-err2.opt.stderr index 8b1688c4a8989..1ded24dbf8ad1 100644 --- a/tests/ui/consts/const-err2.opt.stderr +++ b/tests/ui/consts/const-err2.opt.stderr @@ -1,5 +1,5 @@ error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:19:13 + --> $DIR/const-err2.rs:17:13 | LL | let a = -i8::MIN; | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow @@ -7,37 +7,37 @@ LL | let a = -i8::MIN; = note: `#[deny(arithmetic_overflow)]` on by default error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:21:18 + --> $DIR/const-err2.rs:19:18 | LL | let a_i128 = -i128::MIN; | ^^^^^^^^^^ attempt to negate `i128::MIN`, which would overflow error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:23:13 + --> $DIR/const-err2.rs:21:13 | LL | let b = 200u8 + 200u8 + 200u8; | ^^^^^^^^^^^^^ attempt to compute `200_u8 + 200_u8`, which would overflow error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:25:18 + --> $DIR/const-err2.rs:23:18 | LL | let b_i128 = i128::MIN - i128::MAX; | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN - i128::MAX`, which would overflow error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:27:13 + --> $DIR/const-err2.rs:25:13 | LL | let c = 200u8 * 4; | ^^^^^^^^^ attempt to compute `200_u8 * 4_u8`, which would overflow error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:29:13 + --> $DIR/const-err2.rs:27:13 | LL | let d = 42u8 - (42u8 + 1); | ^^^^^^^^^^^^^^^^^ attempt to compute `42_u8 - 43_u8`, which would overflow error: this operation will panic at runtime - --> $DIR/const-err2.rs:31:14 + --> $DIR/const-err2.rs:29:14 | LL | let _e = [5u8][1]; | ^^^^^^^^ index out of bounds: the length is 1 but the index is 1 diff --git a/tests/ui/consts/const-err2.opt_with_overflow_checks.stderr b/tests/ui/consts/const-err2.opt_with_overflow_checks.stderr index 8b1688c4a8989..1ded24dbf8ad1 100644 --- a/tests/ui/consts/const-err2.opt_with_overflow_checks.stderr +++ b/tests/ui/consts/const-err2.opt_with_overflow_checks.stderr @@ -1,5 +1,5 @@ error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:19:13 + --> $DIR/const-err2.rs:17:13 | LL | let a = -i8::MIN; | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow @@ -7,37 +7,37 @@ LL | let a = -i8::MIN; = note: `#[deny(arithmetic_overflow)]` on by default error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:21:18 + --> $DIR/const-err2.rs:19:18 | LL | let a_i128 = -i128::MIN; | ^^^^^^^^^^ attempt to negate `i128::MIN`, which would overflow error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:23:13 + --> $DIR/const-err2.rs:21:13 | LL | let b = 200u8 + 200u8 + 200u8; | ^^^^^^^^^^^^^ attempt to compute `200_u8 + 200_u8`, which would overflow error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:25:18 + --> $DIR/const-err2.rs:23:18 | LL | let b_i128 = i128::MIN - i128::MAX; | ^^^^^^^^^^^^^^^^^^^^^ attempt to compute `i128::MIN - i128::MAX`, which would overflow error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:27:13 + --> $DIR/const-err2.rs:25:13 | LL | let c = 200u8 * 4; | ^^^^^^^^^ attempt to compute `200_u8 * 4_u8`, which would overflow error: this arithmetic operation will overflow - --> $DIR/const-err2.rs:29:13 + --> $DIR/const-err2.rs:27:13 | LL | let d = 42u8 - (42u8 + 1); | ^^^^^^^^^^^^^^^^^ attempt to compute `42_u8 - 43_u8`, which would overflow error: this operation will panic at runtime - --> $DIR/const-err2.rs:31:14 + --> $DIR/const-err2.rs:29:14 | LL | let _e = [5u8][1]; | ^^^^^^^^ index out of bounds: the length is 1 but the index is 1 diff --git a/tests/ui/consts/const-err2.rs b/tests/ui/consts/const-err2.rs index db49ec25aaaeb..3673d6dab925c 100644 --- a/tests/ui/consts/const-err2.rs +++ b/tests/ui/consts/const-err2.rs @@ -7,8 +7,6 @@ //[opt]compile-flags: -O //[opt_with_overflow_checks]compile-flags: -C overflow-checks=on -O -// build-fail - #![feature(rustc_attrs)] fn black_box(_: T) { diff --git a/tests/ui/consts/const-eval/conditional_array_execution.stderr b/tests/ui/consts/const-eval/conditional_array_execution.stderr index 3003437807970..3ae49f43f7786 100644 --- a/tests/ui/consts/const-eval/conditional_array_execution.stderr +++ b/tests/ui/consts/const-eval/conditional_array_execution.stderr @@ -4,6 +4,29 @@ error[E0080]: evaluation of constant value failed LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; | ^^^^^ attempt to compute `5_u32 - 6_u32`, which would overflow +note: erroneous constant encountered + --> $DIR/conditional_array_execution.rs:7:20 + | +LL | println!("{}", FOO); + | ^^^ + +note: erroneous constant encountered + --> $DIR/conditional_array_execution.rs:7:20 + | +LL | println!("{}", FOO); + | ^^^ + | + = note: this note 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) + +note: erroneous constant encountered + --> $DIR/conditional_array_execution.rs:7:20 + | +LL | println!("{}", FOO); + | ^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + = note: this note 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) + error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/const-eval-overflow2.stderr b/tests/ui/consts/const-eval/const-eval-overflow2.stderr index 341c15daf65b5..ce78b9036fde8 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow2.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow2.stderr @@ -4,48 +4,96 @@ error[E0080]: evaluation of constant value failed LL | i8::MIN - 1, | ^^^^^^^^^^^ attempt to compute `i8::MIN - 1_i8`, which would overflow +note: erroneous constant encountered + --> $DIR/const-eval-overflow2.rs:57:9 + | +LL | foo(VALS_I8); + | ^^^^^^^ + error[E0080]: evaluation of constant value failed --> $DIR/const-eval-overflow2.rs:18:6 | LL | i16::MIN - 1, | ^^^^^^^^^^^^ attempt to compute `i16::MIN - 1_i16`, which would overflow +note: erroneous constant encountered + --> $DIR/const-eval-overflow2.rs:58:9 + | +LL | foo(VALS_I16); + | ^^^^^^^^ + error[E0080]: evaluation of constant value failed --> $DIR/const-eval-overflow2.rs:24:6 | LL | i32::MIN - 1, | ^^^^^^^^^^^^ attempt to compute `i32::MIN - 1_i32`, which would overflow +note: erroneous constant encountered + --> $DIR/const-eval-overflow2.rs:59:9 + | +LL | foo(VALS_I32); + | ^^^^^^^^ + error[E0080]: evaluation of constant value failed --> $DIR/const-eval-overflow2.rs:30:6 | LL | i64::MIN - 1, | ^^^^^^^^^^^^ attempt to compute `i64::MIN - 1_i64`, which would overflow +note: erroneous constant encountered + --> $DIR/const-eval-overflow2.rs:60:9 + | +LL | foo(VALS_I64); + | ^^^^^^^^ + error[E0080]: evaluation of constant value failed --> $DIR/const-eval-overflow2.rs:36:6 | LL | u8::MIN - 1, | ^^^^^^^^^^^ attempt to compute `0_u8 - 1_u8`, which would overflow +note: erroneous constant encountered + --> $DIR/const-eval-overflow2.rs:62:9 + | +LL | foo(VALS_U8); + | ^^^^^^^ + error[E0080]: evaluation of constant value failed --> $DIR/const-eval-overflow2.rs:41:6 | LL | u16::MIN - 1, | ^^^^^^^^^^^^ attempt to compute `0_u16 - 1_u16`, which would overflow +note: erroneous constant encountered + --> $DIR/const-eval-overflow2.rs:63:9 + | +LL | foo(VALS_U16); + | ^^^^^^^^ + error[E0080]: evaluation of constant value failed --> $DIR/const-eval-overflow2.rs:46:6 | LL | u32::MIN - 1, | ^^^^^^^^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow +note: erroneous constant encountered + --> $DIR/const-eval-overflow2.rs:64:9 + | +LL | foo(VALS_U32); + | ^^^^^^^^ + error[E0080]: evaluation of constant value failed --> $DIR/const-eval-overflow2.rs:52:6 | LL | u64::MIN - 1, | ^^^^^^^^^^^^ attempt to compute `0_u64 - 1_u64`, which would overflow +note: erroneous constant encountered + --> $DIR/const-eval-overflow2.rs:65:9 + | +LL | foo(VALS_U64); + | ^^^^^^^^ + error: aborting due to 8 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/const-eval-overflow2b.stderr b/tests/ui/consts/const-eval/const-eval-overflow2b.stderr index e661836b4b951..d14ae4d882cc9 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow2b.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow2b.stderr @@ -4,48 +4,96 @@ error[E0080]: evaluation of constant value failed LL | i8::MAX + 1, | ^^^^^^^^^^^ attempt to compute `i8::MAX + 1_i8`, which would overflow +note: erroneous constant encountered + --> $DIR/const-eval-overflow2b.rs:57:9 + | +LL | foo(VALS_I8); + | ^^^^^^^ + error[E0080]: evaluation of constant value failed --> $DIR/const-eval-overflow2b.rs:18:6 | LL | i16::MAX + 1, | ^^^^^^^^^^^^ attempt to compute `i16::MAX + 1_i16`, which would overflow +note: erroneous constant encountered + --> $DIR/const-eval-overflow2b.rs:58:9 + | +LL | foo(VALS_I16); + | ^^^^^^^^ + error[E0080]: evaluation of constant value failed --> $DIR/const-eval-overflow2b.rs:24:6 | LL | i32::MAX + 1, | ^^^^^^^^^^^^ attempt to compute `i32::MAX + 1_i32`, which would overflow +note: erroneous constant encountered + --> $DIR/const-eval-overflow2b.rs:59:9 + | +LL | foo(VALS_I32); + | ^^^^^^^^ + error[E0080]: evaluation of constant value failed --> $DIR/const-eval-overflow2b.rs:30:6 | LL | i64::MAX + 1, | ^^^^^^^^^^^^ attempt to compute `i64::MAX + 1_i64`, which would overflow +note: erroneous constant encountered + --> $DIR/const-eval-overflow2b.rs:60:9 + | +LL | foo(VALS_I64); + | ^^^^^^^^ + error[E0080]: evaluation of constant value failed --> $DIR/const-eval-overflow2b.rs:36:6 | LL | u8::MAX + 1, | ^^^^^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow +note: erroneous constant encountered + --> $DIR/const-eval-overflow2b.rs:62:9 + | +LL | foo(VALS_U8); + | ^^^^^^^ + error[E0080]: evaluation of constant value failed --> $DIR/const-eval-overflow2b.rs:41:6 | LL | u16::MAX + 1, | ^^^^^^^^^^^^ attempt to compute `u16::MAX + 1_u16`, which would overflow +note: erroneous constant encountered + --> $DIR/const-eval-overflow2b.rs:63:9 + | +LL | foo(VALS_U16); + | ^^^^^^^^ + error[E0080]: evaluation of constant value failed --> $DIR/const-eval-overflow2b.rs:46:6 | LL | u32::MAX + 1, | ^^^^^^^^^^^^ attempt to compute `u32::MAX + 1_u32`, which would overflow +note: erroneous constant encountered + --> $DIR/const-eval-overflow2b.rs:64:9 + | +LL | foo(VALS_U32); + | ^^^^^^^^ + error[E0080]: evaluation of constant value failed --> $DIR/const-eval-overflow2b.rs:52:6 | LL | u64::MAX + 1, | ^^^^^^^^^^^^ attempt to compute `u64::MAX + 1_u64`, which would overflow +note: erroneous constant encountered + --> $DIR/const-eval-overflow2b.rs:65:9 + | +LL | foo(VALS_U64); + | ^^^^^^^^ + error: aborting due to 8 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/const-eval-overflow2c.stderr b/tests/ui/consts/const-eval/const-eval-overflow2c.stderr index 1fad15492fb82..461e1e837553c 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow2c.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow2c.stderr @@ -4,48 +4,96 @@ error[E0080]: evaluation of constant value failed LL | i8::MIN * 2, | ^^^^^^^^^^^ attempt to compute `i8::MIN * 2_i8`, which would overflow +note: erroneous constant encountered + --> $DIR/const-eval-overflow2c.rs:57:9 + | +LL | foo(VALS_I8); + | ^^^^^^^ + error[E0080]: evaluation of constant value failed --> $DIR/const-eval-overflow2c.rs:18:6 | LL | i16::MIN * 2, | ^^^^^^^^^^^^ attempt to compute `i16::MIN * 2_i16`, which would overflow +note: erroneous constant encountered + --> $DIR/const-eval-overflow2c.rs:58:9 + | +LL | foo(VALS_I16); + | ^^^^^^^^ + error[E0080]: evaluation of constant value failed --> $DIR/const-eval-overflow2c.rs:24:6 | LL | i32::MIN * 2, | ^^^^^^^^^^^^ attempt to compute `i32::MIN * 2_i32`, which would overflow +note: erroneous constant encountered + --> $DIR/const-eval-overflow2c.rs:59:9 + | +LL | foo(VALS_I32); + | ^^^^^^^^ + error[E0080]: evaluation of constant value failed --> $DIR/const-eval-overflow2c.rs:30:6 | LL | i64::MIN * 2, | ^^^^^^^^^^^^ attempt to compute `i64::MIN * 2_i64`, which would overflow +note: erroneous constant encountered + --> $DIR/const-eval-overflow2c.rs:60:9 + | +LL | foo(VALS_I64); + | ^^^^^^^^ + error[E0080]: evaluation of constant value failed --> $DIR/const-eval-overflow2c.rs:36:6 | LL | u8::MAX * 2, | ^^^^^^^^^^^ attempt to compute `u8::MAX * 2_u8`, which would overflow +note: erroneous constant encountered + --> $DIR/const-eval-overflow2c.rs:62:9 + | +LL | foo(VALS_U8); + | ^^^^^^^ + error[E0080]: evaluation of constant value failed --> $DIR/const-eval-overflow2c.rs:41:6 | LL | u16::MAX * 2, | ^^^^^^^^^^^^ attempt to compute `u16::MAX * 2_u16`, which would overflow +note: erroneous constant encountered + --> $DIR/const-eval-overflow2c.rs:63:9 + | +LL | foo(VALS_U16); + | ^^^^^^^^ + error[E0080]: evaluation of constant value failed --> $DIR/const-eval-overflow2c.rs:46:6 | LL | u32::MAX * 2, | ^^^^^^^^^^^^ attempt to compute `u32::MAX * 2_u32`, which would overflow +note: erroneous constant encountered + --> $DIR/const-eval-overflow2c.rs:64:9 + | +LL | foo(VALS_U32); + | ^^^^^^^^ + error[E0080]: evaluation of constant value failed --> $DIR/const-eval-overflow2c.rs:52:6 | LL | u64::MAX * 2, | ^^^^^^^^^^^^ attempt to compute `u64::MAX * 2_u64`, which would overflow +note: erroneous constant encountered + --> $DIR/const-eval-overflow2c.rs:65:9 + | +LL | foo(VALS_U64); + | ^^^^^^^^ + error: aborting due to 8 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/const-eval-query-stack.stderr b/tests/ui/consts/const-eval/const-eval-query-stack.stderr index 2fcb3d41dd927..fa9701badbe6f 100644 --- a/tests/ui/consts/const-eval/const-eval-query-stack.stderr +++ b/tests/ui/consts/const-eval/const-eval-query-stack.stderr @@ -7,6 +7,8 @@ LL | const X: i32 = 1 / 0; query stack during panic: #0 [eval_to_allocation_raw] const-evaluating + checking `X` #1 [eval_to_const_value_raw] simplifying constant for the type system `X` -#2 [lint_mod] linting top-level module -#3 [analysis] running analysis passes on this crate +#2 [eval_to_allocation_raw] const-evaluating + checking `main::promoted[1]` +#3 [eval_to_const_value_raw] simplifying constant for the type system `main::promoted[1]` +#4 [const_prop_lint] checking const prop lints for `main` +#5 [analysis] running analysis passes on this crate end of query stack diff --git a/tests/ui/consts/const-eval/const_fn_ptr_fail2.stderr b/tests/ui/consts/const-eval/const_fn_ptr_fail2.stderr index 0734f479f9897..47f2ac2d00c3a 100644 --- a/tests/ui/consts/const-eval/const_fn_ptr_fail2.stderr +++ b/tests/ui/consts/const-eval/const_fn_ptr_fail2.stderr @@ -15,6 +15,29 @@ note: inside `Y` LL | const Y: usize = bar(X, 2); // FIXME: should fail to typeck someday | ^^^^^^^^^ +note: erroneous constant encountered + --> $DIR/const_fn_ptr_fail2.rs:18:16 + | +LL | assert_eq!(Y, 4); + | ^ + +note: erroneous constant encountered + --> $DIR/const_fn_ptr_fail2.rs:18:5 + | +LL | assert_eq!(Y, 4); + | ^^^^^^^^^^^^^^^^ + | + = note: this note originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) + +note: erroneous constant encountered + --> $DIR/const_fn_ptr_fail2.rs:18:5 + | +LL | assert_eq!(Y, 4); + | ^^^^^^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + = note: this note originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) + error[E0080]: evaluation of constant value failed --> $DIR/const_fn_ptr_fail2.rs:9:5 | @@ -32,6 +55,29 @@ note: inside `Z` LL | const Z: usize = bar(double, 2); // FIXME: should fail to typeck someday | ^^^^^^^^^^^^^^ +note: erroneous constant encountered + --> $DIR/const_fn_ptr_fail2.rs:19:16 + | +LL | assert_eq!(Z, 4); + | ^ + +note: erroneous constant encountered + --> $DIR/const_fn_ptr_fail2.rs:19:5 + | +LL | assert_eq!(Z, 4); + | ^^^^^^^^^^^^^^^^ + | + = note: this note originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) + +note: erroneous constant encountered + --> $DIR/const_fn_ptr_fail2.rs:19:5 + | +LL | assert_eq!(Z, 4); + | ^^^^^^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + = note: this note originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) + warning: skipping const checks | help: skipping check that does not even have a feature gate diff --git a/tests/ui/consts/const-eval/index_out_of_bounds_propagated.rs b/tests/ui/consts/const-eval/index_out_of_bounds_propagated.rs index 608e6e112a10b..f30ad6bb6375a 100644 --- a/tests/ui/consts/const-eval/index_out_of_bounds_propagated.rs +++ b/tests/ui/consts/const-eval/index_out_of_bounds_propagated.rs @@ -1,5 +1,3 @@ -// build-fail - fn main() { let array = [std::env::args().len()]; array[1]; //~ ERROR operation will panic diff --git a/tests/ui/consts/const-eval/index_out_of_bounds_propagated.stderr b/tests/ui/consts/const-eval/index_out_of_bounds_propagated.stderr index 64c87af430883..6f2997458f47d 100644 --- a/tests/ui/consts/const-eval/index_out_of_bounds_propagated.stderr +++ b/tests/ui/consts/const-eval/index_out_of_bounds_propagated.stderr @@ -1,5 +1,5 @@ error: this operation will panic at runtime - --> $DIR/index_out_of_bounds_propagated.rs:5:5 + --> $DIR/index_out_of_bounds_propagated.rs:3:5 | LL | array[1]; | ^^^^^^^^ index out of bounds: the length is 1 but the index is 1 diff --git a/tests/ui/consts/const-eval/issue-43197.stderr b/tests/ui/consts/const-eval/issue-43197.stderr index c59f13e488828..2b5af768b5e79 100644 --- a/tests/ui/consts/const-eval/issue-43197.stderr +++ b/tests/ui/consts/const-eval/issue-43197.stderr @@ -4,12 +4,58 @@ error[E0080]: evaluation of constant value failed LL | const X: u32 = 0 - 1; | ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow +note: erroneous constant encountered + --> $DIR/issue-43197.rs:10:23 + | +LL | println!("{} {}", X, Y); + | ^ + +note: erroneous constant encountered + --> $DIR/issue-43197.rs:10:23 + | +LL | println!("{} {}", X, Y); + | ^ + | + = note: this note 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) + +note: erroneous constant encountered + --> $DIR/issue-43197.rs:10:23 + | +LL | println!("{} {}", X, Y); + | ^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + = note: this note 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) + error[E0080]: evaluation of constant value failed --> $DIR/issue-43197.rs:8:24 | LL | const Y: u32 = foo(0 - 1); | ^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow +note: erroneous constant encountered + --> $DIR/issue-43197.rs:10:26 + | +LL | println!("{} {}", X, Y); + | ^ + +note: erroneous constant encountered + --> $DIR/issue-43197.rs:10:26 + | +LL | println!("{} {}", X, Y); + | ^ + | + = note: this note 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) + +note: erroneous constant encountered + --> $DIR/issue-43197.rs:10:26 + | +LL | println!("{} {}", X, Y); + | ^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + = note: this note 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) + error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/issue-44578.rs b/tests/ui/consts/const-eval/issue-44578.rs index e4dcc62302caa..65c95ad65e3a4 100644 --- a/tests/ui/consts/const-eval/issue-44578.rs +++ b/tests/ui/consts/const-eval/issue-44578.rs @@ -1,5 +1,3 @@ -// build-fail - trait Foo { const AMT: usize; } diff --git a/tests/ui/consts/const-eval/issue-44578.stderr b/tests/ui/consts/const-eval/issue-44578.stderr index 6aabe53011c96..d7a3bec95a3f8 100644 --- a/tests/ui/consts/const-eval/issue-44578.stderr +++ b/tests/ui/consts/const-eval/issue-44578.stderr @@ -1,17 +1,17 @@ error[E0080]: evaluation of ` as Foo>::AMT` failed - --> $DIR/issue-44578.rs:13:24 + --> $DIR/issue-44578.rs:11:24 | LL | const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 1 note: erroneous constant encountered - --> $DIR/issue-44578.rs:25:20 + --> $DIR/issue-44578.rs:23:20 | LL | println!("{}", as Foo>::AMT); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/issue-44578.rs:25:20 + --> $DIR/issue-44578.rs:23:20 | LL | println!("{}", as Foo>::AMT); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | println!("{}", as Foo>::AMT); = note: this note 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) note: erroneous constant encountered - --> $DIR/issue-44578.rs:25:20 + --> $DIR/issue-44578.rs:23:20 | LL | println!("{}", as Foo>::AMT); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/consts/const-eval/issue-49296.stderr b/tests/ui/consts/const-eval/issue-49296.stderr index 485a11d1f3c6f..62fb6f7ce6b25 100644 --- a/tests/ui/consts/const-eval/issue-49296.stderr +++ b/tests/ui/consts/const-eval/issue-49296.stderr @@ -4,6 +4,29 @@ error[E0080]: evaluation of constant value failed LL | const X: u64 = *wat(42); | ^^^^^^^^ memory access failed: ALLOC0 has been freed, so this pointer is dangling +note: erroneous constant encountered + --> $DIR/issue-49296.rs:13:20 + | +LL | println!("{}", X); + | ^ + +note: erroneous constant encountered + --> $DIR/issue-49296.rs:13:20 + | +LL | println!("{}", X); + | ^ + | + = note: this note 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) + +note: erroneous constant encountered + --> $DIR/issue-49296.rs:13:20 + | +LL | println!("{}", X); + | ^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + = note: this note 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) + error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/panic-assoc-never-type.rs b/tests/ui/consts/const-eval/panic-assoc-never-type.rs index 88ce5b0d895f3..2c6656ac69b34 100644 --- a/tests/ui/consts/const-eval/panic-assoc-never-type.rs +++ b/tests/ui/consts/const-eval/panic-assoc-never-type.rs @@ -1,5 +1,3 @@ -// build-fail - // Regression test for #66975 #![feature(never_type)] diff --git a/tests/ui/consts/const-eval/panic-assoc-never-type.stderr b/tests/ui/consts/const-eval/panic-assoc-never-type.stderr index eef39255927ab..ab5f23baf2d8b 100644 --- a/tests/ui/consts/const-eval/panic-assoc-never-type.stderr +++ b/tests/ui/consts/const-eval/panic-assoc-never-type.stderr @@ -1,19 +1,19 @@ error[E0080]: evaluation of constant value failed - --> $DIR/panic-assoc-never-type.rs:9:21 + --> $DIR/panic-assoc-never-type.rs:7:21 | LL | const VOID: ! = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/panic-assoc-never-type.rs:9:21 + | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/panic-assoc-never-type.rs:7:21 | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) note: erroneous constant encountered - --> $DIR/panic-assoc-never-type.rs:14:13 + --> $DIR/panic-assoc-never-type.rs:12:13 | LL | let _ = PrintName::VOID; | ^^^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/panic-assoc-never-type.rs:14:13 + --> $DIR/panic-assoc-never-type.rs:12:13 | LL | let _ = PrintName::VOID; | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/consts/const-eval/panic-never-type.stderr b/tests/ui/consts/const-eval/panic-never-type.stderr index d3ba3eefb1abf..d82fa68ec4405 100644 --- a/tests/ui/consts/const-eval/panic-never-type.stderr +++ b/tests/ui/consts/const-eval/panic-never-type.stderr @@ -6,6 +6,20 @@ LL | const VOID: ! = panic!(); | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) +note: erroneous constant encountered + --> $DIR/panic-never-type.rs:8:13 + | +LL | let _ = VOID; + | ^^^^ + +note: erroneous constant encountered + --> $DIR/panic-never-type.rs:8:13 + | +LL | let _ = VOID; + | ^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.stderr b/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.stderr index f087c9960c28f..706d16934e46f 100644 --- a/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.stderr +++ b/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.stderr @@ -13,5 +13,28 @@ LL | const X: u32 = call_foo(); | ^^^^^^^^^^^^ = note: `#[deny(long_running_const_eval)]` on by default +note: erroneous constant encountered + --> $DIR/ctfe-fn-call.rs:35:16 + | +LL | println!("{X}"); + | ^ + +note: erroneous constant encountered + --> $DIR/ctfe-fn-call.rs:35:15 + | +LL | println!("{X}"); + | ^^^ + | + = note: this note 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) + +note: erroneous constant encountered + --> $DIR/ctfe-fn-call.rs:35:15 + | +LL | println!("{X}"); + | ^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + = note: this note 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) + error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.stderr b/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.stderr index ecb48fc62a3d8..706a2ad79d1e6 100644 --- a/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.stderr +++ b/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.stderr @@ -19,5 +19,28 @@ LL | const X: u32 = labelled_loop(19); | ^^^^^^^^^^^^ = note: `#[deny(long_running_const_eval)]` on by default +note: erroneous constant encountered + --> $DIR/ctfe-labelled-loop.rs:19:16 + | +LL | println!("{X}"); + | ^ + +note: erroneous constant encountered + --> $DIR/ctfe-labelled-loop.rs:19:15 + | +LL | println!("{X}"); + | ^^^ + | + = note: this note 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) + +note: erroneous constant encountered + --> $DIR/ctfe-labelled-loop.rs:19:15 + | +LL | println!("{X}"); + | ^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + = note: this note 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) + error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.stderr b/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.stderr index a05d792c95ca8..18a4139a25558 100644 --- a/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.stderr +++ b/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.stderr @@ -13,5 +13,28 @@ LL | const X: u32 = recurse(19); | ^^^^^^^^^^^^ = note: `#[deny(long_running_const_eval)]` on by default +note: erroneous constant encountered + --> $DIR/ctfe-recursion.rs:16:16 + | +LL | println!("{X}"); + | ^ + +note: erroneous constant encountered + --> $DIR/ctfe-recursion.rs:16:15 + | +LL | println!("{X}"); + | ^^^ + | + = note: this note 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) + +note: erroneous constant encountered + --> $DIR/ctfe-recursion.rs:16:15 + | +LL | println!("{X}"); + | ^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + = note: this note 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) + error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr b/tests/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr index b423edbdcec8d..a7d5d295ed5a7 100644 --- a/tests/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr +++ b/tests/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr @@ -1,12 +1,3 @@ -warning: the type `!` does not permit zero-initialization - --> $DIR/validate_uninhabited_zsts.rs:4:14 - | -LL | unsafe { std::mem::transmute(()) } - | ^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed - | - = note: the `!` type has no valid value - = note: `#[warn(invalid_value)]` on by default - error[E0080]: evaluation of constant value failed --> $DIR/validate_uninhabited_zsts.rs:4:14 | @@ -19,34 +10,45 @@ note: inside `foo` LL | unsafe { std::mem::transmute(()) } | ^^^^^^^^^^^^^^^^^^^^^^^ note: inside `FOO` - --> $DIR/validate_uninhabited_zsts.rs:19:33 + --> $DIR/validate_uninhabited_zsts.rs:18:33 | LL | const FOO: [empty::Empty; 3] = [foo(); 3]; | ^^^^^ +note: erroneous constant encountered + --> $DIR/validate_uninhabited_zsts.rs:24:5 + | +LL | FOO; + | ^^^ + +note: erroneous constant encountered + --> $DIR/validate_uninhabited_zsts.rs:24:5 + | +LL | FOO; + | ^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error[E0080]: evaluation of constant value failed - --> $DIR/validate_uninhabited_zsts.rs:21:42 + --> $DIR/validate_uninhabited_zsts.rs:20:42 | LL | const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered a value of uninhabited type `Void` -warning: the type `empty::Empty` does not permit zero-initialization - --> $DIR/validate_uninhabited_zsts.rs:21:42 +note: erroneous constant encountered + --> $DIR/validate_uninhabited_zsts.rs:25:5 | -LL | const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; - | ^^^^^^^^^^^^^^^^^^^^^^^ this code causes undefined behavior when executed - | -note: in this struct field - --> $DIR/validate_uninhabited_zsts.rs:16:22 +LL | BAR; + | ^^^ + +note: erroneous constant encountered + --> $DIR/validate_uninhabited_zsts.rs:25:5 | -LL | pub struct Empty(Void); - | ^^^^ -note: enums with no inhabited variants have no valid value - --> $DIR/validate_uninhabited_zsts.rs:13:5 +LL | BAR; + | ^^^ | -LL | enum Void {} - | ^^^^^^^^^ + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: aborting due to 2 previous errors; 2 warnings emitted +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/validate_uninhabited_zsts.rs b/tests/ui/consts/const-eval/validate_uninhabited_zsts.rs index b6783175dd379..b3bb39c554eb3 100644 --- a/tests/ui/consts/const-eval/validate_uninhabited_zsts.rs +++ b/tests/ui/consts/const-eval/validate_uninhabited_zsts.rs @@ -3,7 +3,6 @@ const fn foo() -> ! { unsafe { std::mem::transmute(()) } //~^ ERROR evaluation of constant value failed - //~| WARN the type `!` does not permit zero-initialization [invalid_value] } // Type defined in a submodule, so that it is not "visibly" @@ -20,7 +19,6 @@ const FOO: [empty::Empty; 3] = [foo(); 3]; const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; //~^ ERROR evaluation of constant value failed -//~| WARN the type `empty::Empty` does not permit zero-initialization fn main() { FOO; diff --git a/tests/ui/consts/const-float-bits-reject-conv.stderr b/tests/ui/consts/const-float-bits-reject-conv.stderr index 1511dab12b0e3..6b205bcbd582d 100644 --- a/tests/ui/consts/const-float-bits-reject-conv.stderr +++ b/tests/ui/consts/const-float-bits-reject-conv.stderr @@ -14,22 +14,6 @@ LL | const MASKED_NAN1: u32 = f32::NAN.to_bits() ^ 0x002A_AAAA; | ^^^^^^^^^^^^^^^^^^ = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/num/f32.rs:LL:COL - | - = note: the evaluated program panicked at 'const-eval error: cannot use f32::to_bits on a NaN', $SRC_DIR/core/src/num/f32.rs:LL:COL - | -note: inside `core::f32::::to_bits::ct_f32_to_u32` - --> $SRC_DIR/core/src/num/f32.rs:LL:COL -note: inside `core::f32::::to_bits` - --> $SRC_DIR/core/src/num/f32.rs:LL:COL -note: inside `f32::MASKED_NAN2` - --> $DIR/const-float-bits-reject-conv.rs:30:30 - | -LL | const MASKED_NAN2: u32 = f32::NAN.to_bits() ^ 0x0055_5555; - | ^^^^^^^^^^^^^^^^^^ - = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) - note: erroneous constant encountered --> $DIR/const-float-bits-reject-conv.rs:35:34 | @@ -49,27 +33,39 @@ LL | const_assert!(f32::from_bits(MASKED_NAN1).to_bits(), MASKED_NAN1); | ^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/const-float-bits-reject-conv.rs:43:34 + --> $DIR/const-float-bits-reject-conv.rs:42:58 | -LL | const_assert!(f32::from_bits(MASKED_NAN2).to_bits(), MASKED_NAN2); - | ^^^^^^^^^^^ +LL | const_assert!(f32::from_bits(MASKED_NAN1).to_bits(), MASKED_NAN1); + | ^^^^^^^^^^^ error[E0080]: evaluation of constant value failed - --> $SRC_DIR/core/src/num/f64.rs:LL:COL + --> $SRC_DIR/core/src/num/f32.rs:LL:COL | - = note: the evaluated program panicked at 'const-eval error: cannot use f64::to_bits on a NaN', $SRC_DIR/core/src/num/f64.rs:LL:COL + = note: the evaluated program panicked at 'const-eval error: cannot use f32::to_bits on a NaN', $SRC_DIR/core/src/num/f32.rs:LL:COL | -note: inside `core::f64::::to_bits::ct_f64_to_u64` - --> $SRC_DIR/core/src/num/f64.rs:LL:COL -note: inside `core::f64::::to_bits` - --> $SRC_DIR/core/src/num/f64.rs:LL:COL -note: inside `f64::MASKED_NAN1` - --> $DIR/const-float-bits-reject-conv.rs:50:30 +note: inside `core::f32::::to_bits::ct_f32_to_u32` + --> $SRC_DIR/core/src/num/f32.rs:LL:COL +note: inside `core::f32::::to_bits` + --> $SRC_DIR/core/src/num/f32.rs:LL:COL +note: inside `f32::MASKED_NAN2` + --> $DIR/const-float-bits-reject-conv.rs:30:30 | -LL | const MASKED_NAN1: u64 = f64::NAN.to_bits() ^ 0x000A_AAAA_AAAA_AAAA; +LL | const MASKED_NAN2: u32 = f32::NAN.to_bits() ^ 0x0055_5555; | ^^^^^^^^^^^^^^^^^^ = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) +note: erroneous constant encountered + --> $DIR/const-float-bits-reject-conv.rs:43:34 + | +LL | const_assert!(f32::from_bits(MASKED_NAN2).to_bits(), MASKED_NAN2); + | ^^^^^^^^^^^ + +note: erroneous constant encountered + --> $DIR/const-float-bits-reject-conv.rs:43:58 + | +LL | const_assert!(f32::from_bits(MASKED_NAN2).to_bits(), MASKED_NAN2); + | ^^^^^^^^^^^ + error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/num/f64.rs:LL:COL | @@ -79,10 +75,10 @@ note: inside `core::f64::::to_bits::ct_f64_to_u64` --> $SRC_DIR/core/src/num/f64.rs:LL:COL note: inside `core::f64::::to_bits` --> $SRC_DIR/core/src/num/f64.rs:LL:COL -note: inside `f64::MASKED_NAN2` - --> $DIR/const-float-bits-reject-conv.rs:52:30 +note: inside `f64::MASKED_NAN1` + --> $DIR/const-float-bits-reject-conv.rs:50:30 | -LL | const MASKED_NAN2: u64 = f64::NAN.to_bits() ^ 0x0005_5555_5555_5555; +LL | const MASKED_NAN1: u64 = f64::NAN.to_bits() ^ 0x000A_AAAA_AAAA_AAAA; | ^^^^^^^^^^^^^^^^^^ = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -104,12 +100,40 @@ note: erroneous constant encountered LL | const_assert!(f64::from_bits(MASKED_NAN1).to_bits(), MASKED_NAN1); | ^^^^^^^^^^^ +note: erroneous constant encountered + --> $DIR/const-float-bits-reject-conv.rs:61:58 + | +LL | const_assert!(f64::from_bits(MASKED_NAN1).to_bits(), MASKED_NAN1); + | ^^^^^^^^^^^ + +error[E0080]: evaluation of constant value failed + --> $SRC_DIR/core/src/num/f64.rs:LL:COL + | + = note: the evaluated program panicked at 'const-eval error: cannot use f64::to_bits on a NaN', $SRC_DIR/core/src/num/f64.rs:LL:COL + | +note: inside `core::f64::::to_bits::ct_f64_to_u64` + --> $SRC_DIR/core/src/num/f64.rs:LL:COL +note: inside `core::f64::::to_bits` + --> $SRC_DIR/core/src/num/f64.rs:LL:COL +note: inside `f64::MASKED_NAN2` + --> $DIR/const-float-bits-reject-conv.rs:52:30 + | +LL | const MASKED_NAN2: u64 = f64::NAN.to_bits() ^ 0x0005_5555_5555_5555; + | ^^^^^^^^^^^^^^^^^^ + = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) + note: erroneous constant encountered --> $DIR/const-float-bits-reject-conv.rs:62:34 | LL | const_assert!(f64::from_bits(MASKED_NAN2).to_bits(), MASKED_NAN2); | ^^^^^^^^^^^ +note: erroneous constant encountered + --> $DIR/const-float-bits-reject-conv.rs:62:58 + | +LL | const_assert!(f64::from_bits(MASKED_NAN2).to_bits(), MASKED_NAN2); + | ^^^^^^^^^^^ + error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-mut-refs/mut_ref_in_final.rs b/tests/ui/consts/const-mut-refs/mut_ref_in_final.rs index 93197d5bce494..01369cad0c3ab 100644 --- a/tests/ui/consts/const-mut-refs/mut_ref_in_final.rs +++ b/tests/ui/consts/const-mut-refs/mut_ref_in_final.rs @@ -8,6 +8,7 @@ const A: *const i32 = &4; // but we do not want to allow this to compile, // as that would be an enormous footgun in oli-obk's opinion. const B: *mut i32 = &mut 4; //~ ERROR mutable references are not allowed +//~^ ERROR mutable pointer in final value of constant // Ok, no actual mutable allocation exists const B2: Option<&mut i32> = None; diff --git a/tests/ui/consts/const-mut-refs/mut_ref_in_final.stderr b/tests/ui/consts/const-mut-refs/mut_ref_in_final.stderr index 59e6aa4011c23..bb335ed4a9f95 100644 --- a/tests/ui/consts/const-mut-refs/mut_ref_in_final.stderr +++ b/tests/ui/consts/const-mut-refs/mut_ref_in_final.stderr @@ -5,7 +5,7 @@ LL | const B: *mut i32 = &mut 4; | ^^^^^^ error[E0716]: temporary value dropped while borrowed - --> $DIR/mut_ref_in_final.rs:16:40 + --> $DIR/mut_ref_in_final.rs:17:40 | LL | const B3: Option<&mut i32> = Some(&mut 42); | ----------^^- @@ -15,7 +15,7 @@ LL | const B3: Option<&mut i32> = Some(&mut 42); | using this value as a constant requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed - --> $DIR/mut_ref_in_final.rs:19:42 + --> $DIR/mut_ref_in_final.rs:20:42 | LL | const B4: Option<&mut i32> = helper(&mut 42); | ------------^^- @@ -25,7 +25,7 @@ LL | const B4: Option<&mut i32> = helper(&mut 42); | using this value as a constant requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed - --> $DIR/mut_ref_in_final.rs:34:65 + --> $DIR/mut_ref_in_final.rs:35:65 | LL | const FOO: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | -------------------------------^^-- @@ -35,7 +35,7 @@ LL | const FOO: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | using this value as a constant requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed - --> $DIR/mut_ref_in_final.rs:37:67 + --> $DIR/mut_ref_in_final.rs:38:67 | LL | static FOO2: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | -------------------------------^^-- @@ -45,7 +45,7 @@ LL | static FOO2: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | using this value as a static requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed - --> $DIR/mut_ref_in_final.rs:40:71 + --> $DIR/mut_ref_in_final.rs:41:71 | LL | static mut FOO3: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | -------------------------------^^-- @@ -55,30 +55,50 @@ LL | static mut FOO3: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | using this value as a static requires that borrow lasts for `'static` error[E0764]: mutable references are not allowed in the final value of statics - --> $DIR/mut_ref_in_final.rs:53:53 + --> $DIR/mut_ref_in_final.rs:54:53 | LL | static RAW_MUT_CAST_S: SyncPtr = SyncPtr { x : &mut 42 as *mut _ as *const _ }; | ^^^^^^^ error[E0764]: mutable references are not allowed in the final value of statics - --> $DIR/mut_ref_in_final.rs:55:54 + --> $DIR/mut_ref_in_final.rs:56:54 | LL | static RAW_MUT_COERCE_S: SyncPtr = SyncPtr { x: &mut 0 }; | ^^^^^^ error[E0764]: mutable references are not allowed in the final value of constants - --> $DIR/mut_ref_in_final.rs:57:52 + --> $DIR/mut_ref_in_final.rs:58:52 | LL | const RAW_MUT_CAST_C: SyncPtr = SyncPtr { x : &mut 42 as *mut _ as *const _ }; | ^^^^^^^ error[E0764]: mutable references are not allowed in the final value of constants - --> $DIR/mut_ref_in_final.rs:59:53 + --> $DIR/mut_ref_in_final.rs:60:53 | LL | const RAW_MUT_COERCE_C: SyncPtr = SyncPtr { x: &mut 0 }; | ^^^^^^ -error: aborting due to 10 previous errors +error: encountered mutable pointer in final value of constant + --> $DIR/mut_ref_in_final.rs:10:1 + | +LL | const B: *mut i32 = &mut 4; + | ^^^^^^^^^^^^^^^^^ + +note: erroneous constant encountered + --> $DIR/mut_ref_in_final.rs:65:15 + | +LL | unsafe { *B = 4 } // Bad news + | ^ + +note: erroneous constant encountered + --> $DIR/mut_ref_in_final.rs:65:15 + | +LL | unsafe { *B = 4 } // Bad news + | ^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 11 previous errors Some errors have detailed explanations: E0716, E0764. For more information about an error, try `rustc --explain E0716`. diff --git a/tests/ui/consts/const-slice-oob.stderr b/tests/ui/consts/const-slice-oob.stderr index 30ec340d2a237..f41a495db3e0b 100644 --- a/tests/ui/consts/const-slice-oob.stderr +++ b/tests/ui/consts/const-slice-oob.stderr @@ -4,6 +4,20 @@ error[E0080]: evaluation of constant value failed LL | const BAR: u32 = FOO[5]; | ^^^^^^ index out of bounds: the length is 3 but the index is 5 +note: erroneous constant encountered + --> $DIR/const-slice-oob.rs:7:13 + | +LL | let _ = BAR; + | ^^^ + +note: erroneous constant encountered + --> $DIR/const-slice-oob.rs:7:13 + | +LL | let _ = BAR; + | ^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-unwrap.stderr b/tests/ui/consts/const-unwrap.stderr index fee22a1d070b8..76a50c13eeaed 100644 --- a/tests/ui/consts/const-unwrap.stderr +++ b/tests/ui/consts/const-unwrap.stderr @@ -4,6 +4,29 @@ error[E0080]: evaluation of constant value failed LL | const BAR: i32 = Option::::None.unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'called `Option::unwrap()` on a `None` value', $DIR/const-unwrap.rs:7:38 +note: erroneous constant encountered + --> $DIR/const-unwrap.rs:12:20 + | +LL | println!("{}", BAR); + | ^^^ + +note: erroneous constant encountered + --> $DIR/const-unwrap.rs:12:20 + | +LL | println!("{}", BAR); + | ^^^ + | + = note: this note 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) + +note: erroneous constant encountered + --> $DIR/const-unwrap.rs:12:20 + | +LL | println!("{}", BAR); + | ^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + = note: this note 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) + error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const_unsafe_unreachable_ub.stderr b/tests/ui/consts/const_unsafe_unreachable_ub.stderr index 6394563e2bb87..36e5977f494d7 100644 --- a/tests/ui/consts/const_unsafe_unreachable_ub.stderr +++ b/tests/ui/consts/const_unsafe_unreachable_ub.stderr @@ -16,6 +16,29 @@ note: inside `BAR` LL | const BAR: bool = unsafe { foo(false) }; | ^^^^^^^^^^ +note: erroneous constant encountered + --> $DIR/const_unsafe_unreachable_ub.rs:13:16 + | +LL | assert_eq!(BAR, true); + | ^^^ + +note: erroneous constant encountered + --> $DIR/const_unsafe_unreachable_ub.rs:13:5 + | +LL | assert_eq!(BAR, true); + | ^^^^^^^^^^^^^^^^^^^^^ + | + = note: this note originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) + +note: erroneous constant encountered + --> $DIR/const_unsafe_unreachable_ub.rs:13:5 + | +LL | assert_eq!(BAR, true); + | ^^^^^^^^^^^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + = note: this note originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) + error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/dangling_raw_ptr.stderr b/tests/ui/consts/dangling_raw_ptr.stderr index 28a58ae7be292..1221bcffc2024 100644 --- a/tests/ui/consts/dangling_raw_ptr.stderr +++ b/tests/ui/consts/dangling_raw_ptr.stderr @@ -4,5 +4,19 @@ error: encountered dangling pointer in final value of constant LL | const FOO: *const u32 = { | ^^^^^^^^^^^^^^^^^^^^^ +note: erroneous constant encountered + --> $DIR/dangling_raw_ptr.rs:7:13 + | +LL | let x = FOO; + | ^^^ + +note: erroneous constant encountered + --> $DIR/dangling_raw_ptr.rs:7:13 + | +LL | let x = FOO; + | ^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error: aborting due to 1 previous error diff --git a/tests/ui/consts/interior-mut-const-via-union.64bit.stderr b/tests/ui/consts/interior-mut-const-via-union.64bit.stderr index 9cc98975ca9b5..f39ebe0afbd23 100644 --- a/tests/ui/consts/interior-mut-const-via-union.64bit.stderr +++ b/tests/ui/consts/interior-mut-const-via-union.64bit.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/interior-mut-const-via-union.rs:35:1 + --> $DIR/interior-mut-const-via-union.rs:34:1 | LL | fn main() { | ^^^^^^^^^ constructing invalid value at ..y..0: encountered `UnsafeCell` in read-only memory @@ -10,13 +10,13 @@ LL | fn main() { } note: erroneous constant encountered - --> $DIR/interior-mut-const-via-union.rs:37:25 + --> $DIR/interior-mut-const-via-union.rs:36:25 | LL | let _: &'static _ = &C; | ^^ note: erroneous constant encountered - --> $DIR/interior-mut-const-via-union.rs:37:25 + --> $DIR/interior-mut-const-via-union.rs:36:25 | LL | let _: &'static _ = &C; | ^^ diff --git a/tests/ui/consts/interior-mut-const-via-union.rs b/tests/ui/consts/interior-mut-const-via-union.rs index 4f67ec979029e..e58d4b6fdc53d 100644 --- a/tests/ui/consts/interior-mut-const-via-union.rs +++ b/tests/ui/consts/interior-mut-const-via-union.rs @@ -1,7 +1,6 @@ // Check that constants with interior mutability inside unions are rejected // during validation. // -// build-fail // stderr-per-bitwidth #![feature(const_mut_refs)] diff --git a/tests/ui/consts/issue-54348.rs b/tests/ui/consts/issue-54348.rs index 5c38d7c42f6b2..0c2edfb0db6b1 100644 --- a/tests/ui/consts/issue-54348.rs +++ b/tests/ui/consts/issue-54348.rs @@ -1,5 +1,3 @@ -// build-fail - fn main() { [1][0u64 as usize]; [1][1.5 as usize]; //~ ERROR operation will panic diff --git a/tests/ui/consts/issue-54348.stderr b/tests/ui/consts/issue-54348.stderr index eb85f349843c4..50f606eb98fd5 100644 --- a/tests/ui/consts/issue-54348.stderr +++ b/tests/ui/consts/issue-54348.stderr @@ -1,5 +1,5 @@ error: this operation will panic at runtime - --> $DIR/issue-54348.rs:5:5 + --> $DIR/issue-54348.rs:3:5 | LL | [1][1.5 as usize]; | ^^^^^^^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 1 @@ -7,7 +7,7 @@ LL | [1][1.5 as usize]; = note: `#[deny(unconditional_panic)]` on by default error: this operation will panic at runtime - --> $DIR/issue-54348.rs:6:5 + --> $DIR/issue-54348.rs:4:5 | LL | [1][1u64 as usize]; | ^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 1 diff --git a/tests/ui/consts/large_const_alloc.rs b/tests/ui/consts/large_const_alloc.rs index 298ed38d180e6..c7f79e4fedb07 100644 --- a/tests/ui/consts/large_const_alloc.rs +++ b/tests/ui/consts/large_const_alloc.rs @@ -9,7 +9,8 @@ const FOO: () = { static FOO2: () = { let x = [0_u8; (1 << 47) - 1]; - //~^ ERROR could not evaluate static initializer + //^ if this errors again, remove `large_static_alloc.rs` + // error hidden by previous error. }; fn main() { diff --git a/tests/ui/consts/large_const_alloc.stderr b/tests/ui/consts/large_const_alloc.stderr index 25d660f1217f4..7a9f922aa20fd 100644 --- a/tests/ui/consts/large_const_alloc.stderr +++ b/tests/ui/consts/large_const_alloc.stderr @@ -4,12 +4,20 @@ error[E0080]: evaluation of constant value failed LL | let x = [0_u8; (1 << 47) - 1]; | ^^^^^^^^^^^^^^^^^^^^^ tried to allocate more memory than available to compiler -error[E0080]: could not evaluate static initializer - --> $DIR/large_const_alloc.rs:11:13 +note: erroneous constant encountered + --> $DIR/large_const_alloc.rs:17:5 | -LL | let x = [0_u8; (1 << 47) - 1]; - | ^^^^^^^^^^^^^^^^^^^^^ tried to allocate more memory than available to compiler +LL | FOO; + | ^^^ + +note: erroneous constant encountered + --> $DIR/large_const_alloc.rs:17:5 + | +LL | FOO; + | ^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/large_static_alloc.rs b/tests/ui/consts/large_static_alloc.rs new file mode 100644 index 0000000000000..999eebc8159a5 --- /dev/null +++ b/tests/ui/consts/large_static_alloc.rs @@ -0,0 +1,11 @@ +// only-64bit +// on 32bit and 16bit platforms it is plausible that the maximum allocation size will succeed + +static FOO2: () = { + let x = [0_u8; (1 << 47) - 1]; + //~^ ERROR could not evaluate static initializer +}; + +fn main() { + FOO2; +} diff --git a/tests/ui/consts/large_static_alloc.stderr b/tests/ui/consts/large_static_alloc.stderr new file mode 100644 index 0000000000000..28ebce578519f --- /dev/null +++ b/tests/ui/consts/large_static_alloc.stderr @@ -0,0 +1,9 @@ +error[E0080]: could not evaluate static initializer + --> $DIR/large_static_alloc.rs:5:13 + | +LL | let x = [0_u8; (1 << 47) - 1]; + | ^^^^^^^^^^^^^^^^^^^^^ tried to allocate more memory than available to compiler + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/miri_unleashed/assoc_const.rs b/tests/ui/consts/miri_unleashed/assoc_const.rs index 7bb0c1b772ad1..d22bf3fd3d826 100644 --- a/tests/ui/consts/miri_unleashed/assoc_const.rs +++ b/tests/ui/consts/miri_unleashed/assoc_const.rs @@ -1,4 +1,3 @@ -// build-fail // compile-flags: -Zunleash-the-miri-inside-of-you // a test demonstrating why we do need to run static const qualification on associated constants diff --git a/tests/ui/consts/miri_unleashed/assoc_const.stderr b/tests/ui/consts/miri_unleashed/assoc_const.stderr index 3303a78426534..bd01c75102401 100644 --- a/tests/ui/consts/miri_unleashed/assoc_const.stderr +++ b/tests/ui/consts/miri_unleashed/assoc_const.stderr @@ -8,19 +8,19 @@ note: inside `std::ptr::drop_in_place::> - shim(Some(Vec))` note: inside `std::ptr::drop_in_place::<(Vec, u32)> - shim(Some((Vec, u32)))` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL note: inside `, String>>::F` - --> $DIR/assoc_const.rs:12:31 + --> $DIR/assoc_const.rs:11:31 | LL | const F: u32 = (U::X, 42).1; | ^ note: erroneous constant encountered - --> $DIR/assoc_const.rs:29:13 + --> $DIR/assoc_const.rs:28:13 | LL | let y = , String>>::F; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/assoc_const.rs:29:13 + --> $DIR/assoc_const.rs:28:13 | LL | let y = , String>>::F; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -30,7 +30,7 @@ LL | let y = , String>>::F; warning: skipping const checks | help: skipping check that does not even have a feature gate - --> $DIR/assoc_const.rs:12:20 + --> $DIR/assoc_const.rs:11:20 | LL | const F: u32 = (U::X, 42).1; | ^^^^^^^^^^ diff --git a/tests/ui/consts/miri_unleashed/assoc_const_2.rs b/tests/ui/consts/miri_unleashed/assoc_const_2.rs index aad5b34606ee3..09e4a6ab3fd0e 100644 --- a/tests/ui/consts/miri_unleashed/assoc_const_2.rs +++ b/tests/ui/consts/miri_unleashed/assoc_const_2.rs @@ -1,4 +1,4 @@ -// build-fail +// check-fail // a test demonstrating that const qualification cannot prevent monomorphization time errors diff --git a/tests/ui/consts/miri_unleashed/mutable_pointer_in_const.64bit.stderr b/tests/ui/consts/miri_unleashed/mutable_pointer_in_const.64bit.stderr new file mode 100644 index 0000000000000..e0690a61ad3d3 --- /dev/null +++ b/tests/ui/consts/miri_unleashed/mutable_pointer_in_const.64bit.stderr @@ -0,0 +1,22 @@ +error: encountered mutable pointer in final value of constant + --> $DIR/mutable_pointer_in_const.rs:16:1 + | +LL | const MUH: Meh = Meh { + | ^^^^^^^^^^^^^^ + +note: erroneous constant encountered + --> $DIR/mutable_pointer_in_const.rs:23:10 + | +LL | *MUH.x.get() = 99; + | ^^^ + +warning: skipping const checks + | +help: skipping check that does not even have a feature gate + --> $DIR/mutable_pointer_in_const.rs:18:8 + | +LL | x: &UnsafeCell::new(42), + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error; 1 warning emitted + diff --git a/tests/ui/consts/miri_unleashed/mutable_pointer_in_const.rs b/tests/ui/consts/miri_unleashed/mutable_pointer_in_const.rs new file mode 100644 index 0000000000000..4d7d0ac7ec6b6 --- /dev/null +++ b/tests/ui/consts/miri_unleashed/mutable_pointer_in_const.rs @@ -0,0 +1,25 @@ +// stderr-per-bitwidth +// compile-flags: -Zunleash-the-miri-inside-of-you +#![allow(invalid_reference_casting, static_mut_ref)] + +use std::cell::UnsafeCell; + +// this test ensures that our mutability story is sound + +struct Meh { + x: &'static UnsafeCell, +} +unsafe impl Sync for Meh {} + +// the following will never be ok! no interior mut behind consts, because +// all allocs interned here will be marked immutable. +const MUH: Meh = Meh { + //~^ ERROR: mutable pointer in final value + x: &UnsafeCell::new(42), +}; + +fn main() { + unsafe { + *MUH.x.get() = 99; + } +} diff --git a/tests/ui/consts/miri_unleashed/mutable_references_err.64bit.stderr b/tests/ui/consts/miri_unleashed/mutable_references_err.64bit.stderr index 3ff6811ea61fb..75259ca937ce8 100644 --- a/tests/ui/consts/miri_unleashed/mutable_references_err.64bit.stderr +++ b/tests/ui/consts/miri_unleashed/mutable_references_err.64bit.stderr @@ -1,17 +1,11 @@ error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references_err.rs:17:1 - | -LL | const MUH: Meh = Meh { - | ^^^^^^^^^^^^^^ - -error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references_err.rs:27:1 + --> $DIR/mutable_references_err.rs:16:1 | LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references_err.rs:32:1 + --> $DIR/mutable_references_err.rs:21:1 | LL | const SUBTLE: &mut i32 = unsafe { &mut FOO }; | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference in a `const` or `static` @@ -22,13 +16,13 @@ LL | const SUBTLE: &mut i32 = unsafe { &mut FOO }; } error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references_err.rs:35:1 + --> $DIR/mutable_references_err.rs:24:1 | LL | const BLUNT: &mut i32 = &mut 42; | ^^^^^^^^^^^^^^^^^^^^^ error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references_err.rs:40:1 + --> $DIR/mutable_references_err.rs:29:1 | LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered mutable reference or box pointing to read-only memory @@ -39,7 +33,7 @@ LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const } error[E0080]: it is undefined behavior to use this value - --> $DIR/mutable_references_err.rs:47:1 + --> $DIR/mutable_references_err.rs:36:1 | LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to a static variable in a constant @@ -50,43 +44,43 @@ LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE }; } error[E0080]: evaluation of constant value failed - --> $DIR/mutable_references_err.rs:51:43 + --> $DIR/mutable_references_err.rs:40:43 | LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF }; | ^^^^^^^^^^^^^ constant accesses static error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references_err.rs:55:1 + --> $DIR/mutable_references_err.rs:44:1 | LL | const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references_err.rs:57:1 + --> $DIR/mutable_references_err.rs:46:1 | LL | const POINTS_TO_MUTABLE_INNER2: *const i32 = &mut 42 as *const _; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references_err.rs:59:1 + --> $DIR/mutable_references_err.rs:48:1 | LL | const INTERIOR_MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references_err.rs:69:1 + --> $DIR/mutable_references_err.rs:58:1 | LL | const RAW_SYNC: SyncPtr = SyncPtr { x: &AtomicI32::new(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references_err.rs:71:1 + --> $DIR/mutable_references_err.rs:60:1 | LL | const RAW_MUT_CAST: SyncPtr = SyncPtr { x : &mut 42 as *mut _ as *const _ }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references_err.rs:73:1 + --> $DIR/mutable_references_err.rs:62:1 | LL | const RAW_MUT_COERCE: SyncPtr = SyncPtr { x: &mut 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -94,106 +88,101 @@ LL | const RAW_MUT_COERCE: SyncPtr = SyncPtr { x: &mut 0 }; warning: skipping const checks | help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:18:8 - | -LL | x: &UnsafeCell::new(42), - | ^^^^^^^^^^^^^^^^^^^^ -help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:27:27 + --> $DIR/mutable_references_err.rs:16:27 | LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:32:40 + --> $DIR/mutable_references_err.rs:21:40 | LL | const SUBTLE: &mut i32 = unsafe { &mut FOO }; | ^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:32:40 + --> $DIR/mutable_references_err.rs:21:40 | LL | const SUBTLE: &mut i32 = unsafe { &mut FOO }; | ^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:32:35 + --> $DIR/mutable_references_err.rs:21:35 | LL | const SUBTLE: &mut i32 = unsafe { &mut FOO }; | ^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:35:25 + --> $DIR/mutable_references_err.rs:24:25 | LL | const BLUNT: &mut i32 = &mut 42; | ^^^^^^^ help: skipping check for `const_mut_refs` feature - --> $DIR/mutable_references_err.rs:40:49 + --> $DIR/mutable_references_err.rs:29:49 | LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check for `const_mut_refs` feature - --> $DIR/mutable_references_err.rs:40:49 + --> $DIR/mutable_references_err.rs:29:49 | LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:40:49 + --> $DIR/mutable_references_err.rs:29:49 | LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:47:44 + --> $DIR/mutable_references_err.rs:36:44 | LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE }; | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:47:44 + --> $DIR/mutable_references_err.rs:36:44 | LL | const POINTS_TO_MUTABLE1: &i32 = unsafe { &MUTABLE }; | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:50:36 + --> $DIR/mutable_references_err.rs:39:36 | LL | static mut MUTABLE_REF: &mut i32 = &mut 42; | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:51:45 + --> $DIR/mutable_references_err.rs:40:45 | LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF }; | ^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:51:45 + --> $DIR/mutable_references_err.rs:40:45 | LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF }; | ^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:55:45 + --> $DIR/mutable_references_err.rs:44:45 | LL | const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _; | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:57:46 + --> $DIR/mutable_references_err.rs:46:46 | LL | const POINTS_TO_MUTABLE_INNER2: *const i32 = &mut 42 as *const _; | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:59:47 + --> $DIR/mutable_references_err.rs:48:47 | LL | const INTERIOR_MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _; | ^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:69:51 + --> $DIR/mutable_references_err.rs:58:51 | LL | const RAW_SYNC: SyncPtr = SyncPtr { x: &AtomicI32::new(42) }; | ^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:71:50 + --> $DIR/mutable_references_err.rs:60:50 | LL | const RAW_MUT_CAST: SyncPtr = SyncPtr { x : &mut 42 as *mut _ as *const _ }; | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references_err.rs:73:51 + --> $DIR/mutable_references_err.rs:62:51 | LL | const RAW_MUT_COERCE: SyncPtr = SyncPtr { x: &mut 0 }; | ^^^^^^ -error: aborting due to 13 previous errors; 1 warning emitted +error: aborting due to 12 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/miri_unleashed/mutable_references_err.rs b/tests/ui/consts/miri_unleashed/mutable_references_err.rs index 83a460dadd0ef..08311fe45a1f8 100644 --- a/tests/ui/consts/miri_unleashed/mutable_references_err.rs +++ b/tests/ui/consts/miri_unleashed/mutable_references_err.rs @@ -7,17 +7,6 @@ use std::cell::UnsafeCell; // this test ensures that our mutability story is sound -struct Meh { - x: &'static UnsafeCell, -} -unsafe impl Sync for Meh {} - -// the following will never be ok! no interior mut behind consts, because -// all allocs interned here will be marked immutable. -const MUH: Meh = Meh { //~ ERROR: mutable pointer in final value - x: &UnsafeCell::new(42), -}; - struct Synced { x: UnsafeCell, } @@ -73,8 +62,4 @@ const RAW_MUT_CAST: SyncPtr = SyncPtr { x : &mut 42 as *mut _ as *const _ } const RAW_MUT_COERCE: SyncPtr = SyncPtr { x: &mut 0 }; //~^ ERROR mutable pointer in final value -fn main() { - unsafe { - *MUH.x.get() = 99; - } -} +fn main() {} diff --git a/tests/ui/consts/missing_span_in_backtrace.stderr b/tests/ui/consts/missing_span_in_backtrace.stderr index 3e3e8e976be80..4820e4d78bb14 100644 --- a/tests/ui/consts/missing_span_in_backtrace.stderr +++ b/tests/ui/consts/missing_span_in_backtrace.stderr @@ -23,6 +23,20 @@ note: inside `X` = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported +note: erroneous constant encountered + --> $DIR/missing_span_in_backtrace.rs:26:5 + | +26 | X + | ^ + +note: erroneous constant encountered + --> $DIR/missing_span_in_backtrace.rs:26:5 + | +26 | X + | ^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/uninhabited-const-issue-61744.rs b/tests/ui/consts/uninhabited-const-issue-61744.rs index ca6449cce30d5..8ffca758e49db 100644 --- a/tests/ui/consts/uninhabited-const-issue-61744.rs +++ b/tests/ui/consts/uninhabited-const-issue-61744.rs @@ -1,5 +1,3 @@ -// build-fail - pub const unsafe fn fake_type() -> T { hint_unreachable() //~ ERROR evaluation of `::CONSTANT` failed } diff --git a/tests/ui/consts/uninhabited-const-issue-61744.stderr b/tests/ui/consts/uninhabited-const-issue-61744.stderr index c6dd11ee5db92..0d9ca209511bb 100644 --- a/tests/ui/consts/uninhabited-const-issue-61744.stderr +++ b/tests/ui/consts/uninhabited-const-issue-61744.stderr @@ -1,658 +1,658 @@ error[E0080]: evaluation of `::CONSTANT` failed - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ reached the configured maximum number of stack frames | note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `hint_unreachable` - --> $DIR/uninhabited-const-issue-61744.rs:8:5 + --> $DIR/uninhabited-const-issue-61744.rs:6:5 | LL | fake_type() | ^^^^^^^^^^^ note: inside `fake_type::` - --> $DIR/uninhabited-const-issue-61744.rs:4:5 + --> $DIR/uninhabited-const-issue-61744.rs:2:5 | LL | hint_unreachable() | ^^^^^^^^^^^^^^^^^^ note: inside `::CONSTANT` - --> $DIR/uninhabited-const-issue-61744.rs:12:36 + --> $DIR/uninhabited-const-issue-61744.rs:10:36 | LL | const CONSTANT: i32 = unsafe { fake_type() }; | ^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/uninhabited-const-issue-61744.rs:18:10 + --> $DIR/uninhabited-const-issue-61744.rs:16:10 | LL | dbg!(i32::CONSTANT); | ^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/uninhabited-const-issue-61744.rs:18:10 + --> $DIR/uninhabited-const-issue-61744.rs:16:10 | LL | dbg!(i32::CONSTANT); | ^^^^^^^^^^^^^ diff --git a/tests/ui/impl-trait/recursive-coroutine-indirect.current.stderr b/tests/ui/impl-trait/recursive-coroutine-indirect.current.stderr index df457c13e70cb..cb679b05a65c4 100644 --- a/tests/ui/impl-trait/recursive-coroutine-indirect.current.stderr +++ b/tests/ui/impl-trait/recursive-coroutine-indirect.current.stderr @@ -1,5 +1,5 @@ error[E0733]: recursion in a coroutine requires boxing - --> $DIR/recursive-coroutine-indirect.rs:10:5 + --> $DIR/recursive-coroutine-indirect.rs:9:5 | LL | move || { | ^^^^^^^ diff --git a/tests/ui/impl-trait/recursive-coroutine-indirect.next.stderr b/tests/ui/impl-trait/recursive-coroutine-indirect.next.stderr index df457c13e70cb..cb679b05a65c4 100644 --- a/tests/ui/impl-trait/recursive-coroutine-indirect.next.stderr +++ b/tests/ui/impl-trait/recursive-coroutine-indirect.next.stderr @@ -1,5 +1,5 @@ error[E0733]: recursion in a coroutine requires boxing - --> $DIR/recursive-coroutine-indirect.rs:10:5 + --> $DIR/recursive-coroutine-indirect.rs:9:5 | LL | move || { | ^^^^^^^ diff --git a/tests/ui/impl-trait/recursive-coroutine-indirect.rs b/tests/ui/impl-trait/recursive-coroutine-indirect.rs index 99b6be3358fc0..2686569281d30 100644 --- a/tests/ui/impl-trait/recursive-coroutine-indirect.rs +++ b/tests/ui/impl-trait/recursive-coroutine-indirect.rs @@ -1,7 +1,6 @@ // revisions: current next //[next] compile-flags: -Znext-solver -//[next] build-fail // Deeply normalizing writeback results of opaques makes this into a post-mono error :( #![feature(coroutines)] diff --git a/tests/ui/limits/issue-55878.rs b/tests/ui/limits/issue-55878.rs index c1c54646db871..fee664caa1783 100644 --- a/tests/ui/limits/issue-55878.rs +++ b/tests/ui/limits/issue-55878.rs @@ -1,4 +1,3 @@ -// build-fail // normalize-stderr-64bit "18446744073709551615" -> "SIZE" // normalize-stderr-32bit "4294967295" -> "SIZE" diff --git a/tests/ui/limits/issue-55878.stderr b/tests/ui/limits/issue-55878.stderr index 97ca0f4fb592c..d1e0eb89b54fb 100644 --- a/tests/ui/limits/issue-55878.stderr +++ b/tests/ui/limits/issue-55878.stderr @@ -6,13 +6,13 @@ error[E0080]: evaluation of constant value failed note: inside `std::mem::size_of::<[u8; usize::MAX]>` --> $SRC_DIR/core/src/mem/mod.rs:LL:COL note: inside `main` - --> $DIR/issue-55878.rs:7:26 + --> $DIR/issue-55878.rs:6:26 | LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/issue-55878.rs:7:26 + --> $DIR/issue-55878.rs:6:26 | LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -20,7 +20,7 @@ LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>()); = note: this note 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) note: erroneous constant encountered - --> $DIR/issue-55878.rs:7:26 + --> $DIR/issue-55878.rs:6:26 | LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/lint/lint-type-overflow2.rs b/tests/ui/lint/lint-type-overflow2.rs index 9b1eb510bbd83..7769ba0ee88e3 100644 --- a/tests/ui/lint/lint-type-overflow2.rs +++ b/tests/ui/lint/lint-type-overflow2.rs @@ -4,6 +4,7 @@ fn main() { let x2: i8 = --128; //~ ERROR literal out of range for `i8` + //~^ ERROR arithmetic operation will overflow let x = -3.40282357e+38_f32; //~ ERROR literal out of range for `f32` let x = 3.40282357e+38_f32; //~ ERROR literal out of range for `f32` diff --git a/tests/ui/lint/lint-type-overflow2.stderr b/tests/ui/lint/lint-type-overflow2.stderr index eb593d062f218..0e2159f5fd548 100644 --- a/tests/ui/lint/lint-type-overflow2.stderr +++ b/tests/ui/lint/lint-type-overflow2.stderr @@ -1,3 +1,11 @@ +error: this arithmetic operation will overflow + --> $DIR/lint-type-overflow2.rs:6:18 + | +LL | let x2: i8 = --128; + | ^^^^^ attempt to negate `i8::MIN`, which would overflow + | + = note: `#[deny(arithmetic_overflow)]` on by default + error: literal out of range for `i8` --> $DIR/lint-type-overflow2.rs:6:20 | @@ -13,7 +21,7 @@ LL | #![deny(overflowing_literals)] | ^^^^^^^^^^^^^^^^^^^^ error: literal out of range for `f32` - --> $DIR/lint-type-overflow2.rs:8:14 + --> $DIR/lint-type-overflow2.rs:9:14 | LL | let x = -3.40282357e+38_f32; | ^^^^^^^^^^^^^^^^^^ @@ -21,7 +29,7 @@ LL | let x = -3.40282357e+38_f32; = note: the literal `3.40282357e+38_f32` does not fit into the type `f32` and will be converted to `f32::INFINITY` error: literal out of range for `f32` - --> $DIR/lint-type-overflow2.rs:9:14 + --> $DIR/lint-type-overflow2.rs:10:14 | LL | let x = 3.40282357e+38_f32; | ^^^^^^^^^^^^^^^^^^ @@ -29,7 +37,7 @@ LL | let x = 3.40282357e+38_f32; = note: the literal `3.40282357e+38_f32` does not fit into the type `f32` and will be converted to `f32::INFINITY` error: literal out of range for `f64` - --> $DIR/lint-type-overflow2.rs:10:14 + --> $DIR/lint-type-overflow2.rs:11:14 | LL | let x = -1.7976931348623159e+308_f64; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -37,12 +45,12 @@ LL | let x = -1.7976931348623159e+308_f64; = note: the literal `1.7976931348623159e+308_f64` does not fit into the type `f64` and will be converted to `f64::INFINITY` error: literal out of range for `f64` - --> $DIR/lint-type-overflow2.rs:11:14 + --> $DIR/lint-type-overflow2.rs:12:14 | LL | let x = 1.7976931348623159e+308_f64; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: the literal `1.7976931348623159e+308_f64` does not fit into the type `f64` and will be converted to `f64::INFINITY` -error: aborting due to 5 previous errors +error: aborting due to 6 previous errors diff --git a/tests/ui/lint/unconditional_panic_98444.rs b/tests/ui/lint/unconditional_panic_98444.rs index 011fabfbbe94c..675f931b5d011 100644 --- a/tests/ui/lint/unconditional_panic_98444.rs +++ b/tests/ui/lint/unconditional_panic_98444.rs @@ -1,5 +1,3 @@ -// build-fail - fn main() { let xs: [i32; 5] = [1, 2, 3, 4, 5]; let _ = &xs; diff --git a/tests/ui/lint/unconditional_panic_98444.stderr b/tests/ui/lint/unconditional_panic_98444.stderr index 29719b2dad523..f7a6f769fb36b 100644 --- a/tests/ui/lint/unconditional_panic_98444.stderr +++ b/tests/ui/lint/unconditional_panic_98444.stderr @@ -1,5 +1,5 @@ error: this operation will panic at runtime - --> $DIR/unconditional_panic_98444.rs:6:13 + --> $DIR/unconditional_panic_98444.rs:4:13 | LL | let _ = xs[7]; | ^^^^^ index out of bounds: the length is 5 but the index is 7 diff --git a/tests/ui/mir/mir_detects_invalid_ops.rs b/tests/ui/mir/mir_detects_invalid_ops.rs index 136c03cd9f1bc..ca0fc7cf7582b 100644 --- a/tests/ui/mir/mir_detects_invalid_ops.rs +++ b/tests/ui/mir/mir_detects_invalid_ops.rs @@ -1,5 +1,3 @@ -// build-fail - fn main() { divide_by_zero(); mod_by_zero(); diff --git a/tests/ui/mir/mir_detects_invalid_ops.stderr b/tests/ui/mir/mir_detects_invalid_ops.stderr index 0fe56f4172515..ee1946247fc24 100644 --- a/tests/ui/mir/mir_detects_invalid_ops.stderr +++ b/tests/ui/mir/mir_detects_invalid_ops.stderr @@ -1,5 +1,5 @@ error: this operation will panic at runtime - --> $DIR/mir_detects_invalid_ops.rs:11:14 + --> $DIR/mir_detects_invalid_ops.rs:9:14 | LL | let _z = 1 / y; | ^^^^^ attempt to divide `1_i32` by zero @@ -7,7 +7,7 @@ LL | let _z = 1 / y; = note: `#[deny(unconditional_panic)]` on by default error: this operation will panic at runtime - --> $DIR/mir_detects_invalid_ops.rs:16:14 + --> $DIR/mir_detects_invalid_ops.rs:14:14 | LL | let _z = 1 % y; | ^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero diff --git a/tests/ui/numbers-arithmetic/issue-8460-const.noopt.stderr b/tests/ui/numbers-arithmetic/issue-8460-const.noopt.stderr index 2fba94d07401c..69b1c7dff5f44 100644 --- a/tests/ui/numbers-arithmetic/issue-8460-const.noopt.stderr +++ b/tests/ui/numbers-arithmetic/issue-8460-const.noopt.stderr @@ -1,5 +1,5 @@ error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:11:36 + --> $DIR/issue-8460-const.rs:9:36 | LL | assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN / -1_isize`, which would overflow @@ -7,139 +7,139 @@ LL | assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err()); = note: `#[deny(unconditional_panic)]` on by default error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:13:36 + --> $DIR/issue-8460-const.rs:11:36 | LL | assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^ attempt to compute `i8::MIN / -1_i8`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:15:36 + --> $DIR/issue-8460-const.rs:13:36 | LL | assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute `i16::MIN / -1_i16`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:17:36 + --> $DIR/issue-8460-const.rs:15:36 | LL | assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute `i32::MIN / -1_i32`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:19:36 + --> $DIR/issue-8460-const.rs:17:36 | LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute `i64::MIN / -1_i64`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:21:36 + --> $DIR/issue-8460-const.rs:19:36 | LL | assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN / -1_i128`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:23:36 + --> $DIR/issue-8460-const.rs:21:36 | LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); | ^^^^^^^^^^ attempt to divide `1_isize` by zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:25:36 + --> $DIR/issue-8460-const.rs:23:36 | LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); | ^^^^^^^ attempt to divide `1_i8` by zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:27:36 + --> $DIR/issue-8460-const.rs:25:36 | LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); | ^^^^^^^^ attempt to divide `1_i16` by zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:29:36 + --> $DIR/issue-8460-const.rs:27:36 | LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); | ^^^^^^^^ attempt to divide `1_i32` by zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:31:36 + --> $DIR/issue-8460-const.rs:29:36 | LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); | ^^^^^^^^ attempt to divide `1_i64` by zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:33:36 + --> $DIR/issue-8460-const.rs:31:36 | LL | assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err()); | ^^^^^^^^^ attempt to divide `1_i128` by zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:35:36 + --> $DIR/issue-8460-const.rs:33:36 | LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN % -1_isize`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:37:36 + --> $DIR/issue-8460-const.rs:35:36 | LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^ attempt to compute `i8::MIN % -1_i8`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:39:36 + --> $DIR/issue-8460-const.rs:37:36 | LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute `i16::MIN % -1_i16`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:41:36 + --> $DIR/issue-8460-const.rs:39:36 | LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute `i32::MIN % -1_i32`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:43:36 + --> $DIR/issue-8460-const.rs:41:36 | LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:45:36 + --> $DIR/issue-8460-const.rs:43:36 | LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN % -1_i128`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:47:36 + --> $DIR/issue-8460-const.rs:45:36 | LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:49:36 + --> $DIR/issue-8460-const.rs:47:36 | LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); | ^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:51:36 + --> $DIR/issue-8460-const.rs:49:36 | LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err()); | ^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:53:36 + --> $DIR/issue-8460-const.rs:51:36 | LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err()); | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:55:36 + --> $DIR/issue-8460-const.rs:53:36 | LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err()); | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:57:36 + --> $DIR/issue-8460-const.rs:55:36 | LL | assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err()); | ^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero diff --git a/tests/ui/numbers-arithmetic/issue-8460-const.opt.stderr b/tests/ui/numbers-arithmetic/issue-8460-const.opt.stderr index 2fba94d07401c..69b1c7dff5f44 100644 --- a/tests/ui/numbers-arithmetic/issue-8460-const.opt.stderr +++ b/tests/ui/numbers-arithmetic/issue-8460-const.opt.stderr @@ -1,5 +1,5 @@ error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:11:36 + --> $DIR/issue-8460-const.rs:9:36 | LL | assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN / -1_isize`, which would overflow @@ -7,139 +7,139 @@ LL | assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err()); = note: `#[deny(unconditional_panic)]` on by default error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:13:36 + --> $DIR/issue-8460-const.rs:11:36 | LL | assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^ attempt to compute `i8::MIN / -1_i8`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:15:36 + --> $DIR/issue-8460-const.rs:13:36 | LL | assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute `i16::MIN / -1_i16`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:17:36 + --> $DIR/issue-8460-const.rs:15:36 | LL | assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute `i32::MIN / -1_i32`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:19:36 + --> $DIR/issue-8460-const.rs:17:36 | LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute `i64::MIN / -1_i64`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:21:36 + --> $DIR/issue-8460-const.rs:19:36 | LL | assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN / -1_i128`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:23:36 + --> $DIR/issue-8460-const.rs:21:36 | LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); | ^^^^^^^^^^ attempt to divide `1_isize` by zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:25:36 + --> $DIR/issue-8460-const.rs:23:36 | LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); | ^^^^^^^ attempt to divide `1_i8` by zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:27:36 + --> $DIR/issue-8460-const.rs:25:36 | LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); | ^^^^^^^^ attempt to divide `1_i16` by zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:29:36 + --> $DIR/issue-8460-const.rs:27:36 | LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); | ^^^^^^^^ attempt to divide `1_i32` by zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:31:36 + --> $DIR/issue-8460-const.rs:29:36 | LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); | ^^^^^^^^ attempt to divide `1_i64` by zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:33:36 + --> $DIR/issue-8460-const.rs:31:36 | LL | assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err()); | ^^^^^^^^^ attempt to divide `1_i128` by zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:35:36 + --> $DIR/issue-8460-const.rs:33:36 | LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN % -1_isize`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:37:36 + --> $DIR/issue-8460-const.rs:35:36 | LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^ attempt to compute `i8::MIN % -1_i8`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:39:36 + --> $DIR/issue-8460-const.rs:37:36 | LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute `i16::MIN % -1_i16`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:41:36 + --> $DIR/issue-8460-const.rs:39:36 | LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute `i32::MIN % -1_i32`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:43:36 + --> $DIR/issue-8460-const.rs:41:36 | LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:45:36 + --> $DIR/issue-8460-const.rs:43:36 | LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN % -1_i128`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:47:36 + --> $DIR/issue-8460-const.rs:45:36 | LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:49:36 + --> $DIR/issue-8460-const.rs:47:36 | LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); | ^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:51:36 + --> $DIR/issue-8460-const.rs:49:36 | LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err()); | ^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:53:36 + --> $DIR/issue-8460-const.rs:51:36 | LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err()); | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:55:36 + --> $DIR/issue-8460-const.rs:53:36 | LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err()); | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:57:36 + --> $DIR/issue-8460-const.rs:55:36 | LL | assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err()); | ^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero diff --git a/tests/ui/numbers-arithmetic/issue-8460-const.opt_with_overflow_checks.stderr b/tests/ui/numbers-arithmetic/issue-8460-const.opt_with_overflow_checks.stderr index 2fba94d07401c..69b1c7dff5f44 100644 --- a/tests/ui/numbers-arithmetic/issue-8460-const.opt_with_overflow_checks.stderr +++ b/tests/ui/numbers-arithmetic/issue-8460-const.opt_with_overflow_checks.stderr @@ -1,5 +1,5 @@ error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:11:36 + --> $DIR/issue-8460-const.rs:9:36 | LL | assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN / -1_isize`, which would overflow @@ -7,139 +7,139 @@ LL | assert!(thread::spawn(move|| { isize::MIN / -1; }).join().is_err()); = note: `#[deny(unconditional_panic)]` on by default error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:13:36 + --> $DIR/issue-8460-const.rs:11:36 | LL | assert!(thread::spawn(move|| { i8::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^ attempt to compute `i8::MIN / -1_i8`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:15:36 + --> $DIR/issue-8460-const.rs:13:36 | LL | assert!(thread::spawn(move|| { i16::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute `i16::MIN / -1_i16`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:17:36 + --> $DIR/issue-8460-const.rs:15:36 | LL | assert!(thread::spawn(move|| { i32::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute `i32::MIN / -1_i32`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:19:36 + --> $DIR/issue-8460-const.rs:17:36 | LL | assert!(thread::spawn(move|| { i64::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute `i64::MIN / -1_i64`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:21:36 + --> $DIR/issue-8460-const.rs:19:36 | LL | assert!(thread::spawn(move|| { i128::MIN / -1; }).join().is_err()); | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN / -1_i128`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:23:36 + --> $DIR/issue-8460-const.rs:21:36 | LL | assert!(thread::spawn(move|| { 1isize / 0; }).join().is_err()); | ^^^^^^^^^^ attempt to divide `1_isize` by zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:25:36 + --> $DIR/issue-8460-const.rs:23:36 | LL | assert!(thread::spawn(move|| { 1i8 / 0; }).join().is_err()); | ^^^^^^^ attempt to divide `1_i8` by zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:27:36 + --> $DIR/issue-8460-const.rs:25:36 | LL | assert!(thread::spawn(move|| { 1i16 / 0; }).join().is_err()); | ^^^^^^^^ attempt to divide `1_i16` by zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:29:36 + --> $DIR/issue-8460-const.rs:27:36 | LL | assert!(thread::spawn(move|| { 1i32 / 0; }).join().is_err()); | ^^^^^^^^ attempt to divide `1_i32` by zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:31:36 + --> $DIR/issue-8460-const.rs:29:36 | LL | assert!(thread::spawn(move|| { 1i64 / 0; }).join().is_err()); | ^^^^^^^^ attempt to divide `1_i64` by zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:33:36 + --> $DIR/issue-8460-const.rs:31:36 | LL | assert!(thread::spawn(move|| { 1i128 / 0; }).join().is_err()); | ^^^^^^^^^ attempt to divide `1_i128` by zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:35:36 + --> $DIR/issue-8460-const.rs:33:36 | LL | assert!(thread::spawn(move|| { isize::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^^^ attempt to compute `isize::MIN % -1_isize`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:37:36 + --> $DIR/issue-8460-const.rs:35:36 | LL | assert!(thread::spawn(move|| { i8::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^ attempt to compute `i8::MIN % -1_i8`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:39:36 + --> $DIR/issue-8460-const.rs:37:36 | LL | assert!(thread::spawn(move|| { i16::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute `i16::MIN % -1_i16`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:41:36 + --> $DIR/issue-8460-const.rs:39:36 | LL | assert!(thread::spawn(move|| { i32::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute `i32::MIN % -1_i32`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:43:36 + --> $DIR/issue-8460-const.rs:41:36 | LL | assert!(thread::spawn(move|| { i64::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^ attempt to compute `i64::MIN % -1_i64`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:45:36 + --> $DIR/issue-8460-const.rs:43:36 | LL | assert!(thread::spawn(move|| { i128::MIN % -1; }).join().is_err()); | ^^^^^^^^^^^^^^ attempt to compute `i128::MIN % -1_i128`, which would overflow error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:47:36 + --> $DIR/issue-8460-const.rs:45:36 | LL | assert!(thread::spawn(move|| { 1isize % 0; }).join().is_err()); | ^^^^^^^^^^ attempt to calculate the remainder of `1_isize` with a divisor of zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:49:36 + --> $DIR/issue-8460-const.rs:47:36 | LL | assert!(thread::spawn(move|| { 1i8 % 0; }).join().is_err()); | ^^^^^^^ attempt to calculate the remainder of `1_i8` with a divisor of zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:51:36 + --> $DIR/issue-8460-const.rs:49:36 | LL | assert!(thread::spawn(move|| { 1i16 % 0; }).join().is_err()); | ^^^^^^^^ attempt to calculate the remainder of `1_i16` with a divisor of zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:53:36 + --> $DIR/issue-8460-const.rs:51:36 | LL | assert!(thread::spawn(move|| { 1i32 % 0; }).join().is_err()); | ^^^^^^^^ attempt to calculate the remainder of `1_i32` with a divisor of zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:55:36 + --> $DIR/issue-8460-const.rs:53:36 | LL | assert!(thread::spawn(move|| { 1i64 % 0; }).join().is_err()); | ^^^^^^^^ attempt to calculate the remainder of `1_i64` with a divisor of zero error: this operation will panic at runtime - --> $DIR/issue-8460-const.rs:57:36 + --> $DIR/issue-8460-const.rs:55:36 | LL | assert!(thread::spawn(move|| { 1i128 % 0; }).join().is_err()); | ^^^^^^^^^ attempt to calculate the remainder of `1_i128` with a divisor of zero diff --git a/tests/ui/numbers-arithmetic/issue-8460-const.rs b/tests/ui/numbers-arithmetic/issue-8460-const.rs index 02e7567dafabb..5329776e9ac33 100644 --- a/tests/ui/numbers-arithmetic/issue-8460-const.rs +++ b/tests/ui/numbers-arithmetic/issue-8460-const.rs @@ -3,8 +3,6 @@ //[opt]compile-flags: -O //[opt_with_overflow_checks]compile-flags: -C overflow-checks=on -O -// build-fail - use std::thread; fn main() { diff --git a/tests/ui/numbers-arithmetic/overflowing-lsh-1.rs b/tests/ui/numbers-arithmetic/overflowing-lsh-1.rs index 7f8b0c877600f..68df950674ec0 100644 --- a/tests/ui/numbers-arithmetic/overflowing-lsh-1.rs +++ b/tests/ui/numbers-arithmetic/overflowing-lsh-1.rs @@ -1,4 +1,3 @@ -// build-fail // compile-flags: -C debug-assertions #![deny(arithmetic_overflow)] diff --git a/tests/ui/numbers-arithmetic/overflowing-lsh-1.stderr b/tests/ui/numbers-arithmetic/overflowing-lsh-1.stderr index 5d2c4a6c8e270..813e421df3401 100644 --- a/tests/ui/numbers-arithmetic/overflowing-lsh-1.stderr +++ b/tests/ui/numbers-arithmetic/overflowing-lsh-1.stderr @@ -1,11 +1,11 @@ error: this arithmetic operation will overflow - --> $DIR/overflowing-lsh-1.rs:7:14 + --> $DIR/overflowing-lsh-1.rs:6:14 | LL | let _x = 1_i32 << 32; | ^^^^^^^^^^^ attempt to shift left by `32_i32`, which would overflow | note: the lint level is defined here - --> $DIR/overflowing-lsh-1.rs:4:9 + --> $DIR/overflowing-lsh-1.rs:3:9 | LL | #![deny(arithmetic_overflow)] | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/numbers-arithmetic/overflowing-lsh-2.rs b/tests/ui/numbers-arithmetic/overflowing-lsh-2.rs index 76718ecd1fa7a..7ae3d66ee6405 100644 --- a/tests/ui/numbers-arithmetic/overflowing-lsh-2.rs +++ b/tests/ui/numbers-arithmetic/overflowing-lsh-2.rs @@ -1,4 +1,3 @@ -// build-fail // compile-flags: -C debug-assertions #![deny(arithmetic_overflow)] diff --git a/tests/ui/numbers-arithmetic/overflowing-lsh-2.stderr b/tests/ui/numbers-arithmetic/overflowing-lsh-2.stderr index 8ac72aefe0dc0..058ad33aeea92 100644 --- a/tests/ui/numbers-arithmetic/overflowing-lsh-2.stderr +++ b/tests/ui/numbers-arithmetic/overflowing-lsh-2.stderr @@ -1,11 +1,11 @@ error: this arithmetic operation will overflow - --> $DIR/overflowing-lsh-2.rs:7:14 + --> $DIR/overflowing-lsh-2.rs:6:14 | LL | let _x = 1 << -1; | ^^^^^^^ attempt to shift left by `-1_i32`, which would overflow | note: the lint level is defined here - --> $DIR/overflowing-lsh-2.rs:4:9 + --> $DIR/overflowing-lsh-2.rs:3:9 | LL | #![deny(arithmetic_overflow)] | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/numbers-arithmetic/overflowing-lsh-3.rs b/tests/ui/numbers-arithmetic/overflowing-lsh-3.rs index b2bdd09bffb91..100f28173a8be 100644 --- a/tests/ui/numbers-arithmetic/overflowing-lsh-3.rs +++ b/tests/ui/numbers-arithmetic/overflowing-lsh-3.rs @@ -1,4 +1,3 @@ -// build-fail // compile-flags: -C debug-assertions #![deny(arithmetic_overflow)] diff --git a/tests/ui/numbers-arithmetic/overflowing-lsh-3.stderr b/tests/ui/numbers-arithmetic/overflowing-lsh-3.stderr index 43d541b030433..14b01139b2e0c 100644 --- a/tests/ui/numbers-arithmetic/overflowing-lsh-3.stderr +++ b/tests/ui/numbers-arithmetic/overflowing-lsh-3.stderr @@ -1,11 +1,11 @@ error: this arithmetic operation will overflow - --> $DIR/overflowing-lsh-3.rs:7:14 + --> $DIR/overflowing-lsh-3.rs:6:14 | LL | let _x = 1_u64 << 64; | ^^^^^^^^^^^ attempt to shift left by `64_i32`, which would overflow | note: the lint level is defined here - --> $DIR/overflowing-lsh-3.rs:4:9 + --> $DIR/overflowing-lsh-3.rs:3:9 | LL | #![deny(arithmetic_overflow)] | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/numbers-arithmetic/overflowing-lsh-4.rs b/tests/ui/numbers-arithmetic/overflowing-lsh-4.rs index 1042bfcb34d3d..ec5f47dded15c 100644 --- a/tests/ui/numbers-arithmetic/overflowing-lsh-4.rs +++ b/tests/ui/numbers-arithmetic/overflowing-lsh-4.rs @@ -1,4 +1,3 @@ -// build-fail // compile-flags: -C debug-assertions // This function is checking that our automatic truncation does not diff --git a/tests/ui/numbers-arithmetic/overflowing-lsh-4.stderr b/tests/ui/numbers-arithmetic/overflowing-lsh-4.stderr index 00a3581069f5b..8dceb5befff60 100644 --- a/tests/ui/numbers-arithmetic/overflowing-lsh-4.stderr +++ b/tests/ui/numbers-arithmetic/overflowing-lsh-4.stderr @@ -1,11 +1,11 @@ error: this arithmetic operation will overflow - --> $DIR/overflowing-lsh-4.rs:11:13 + --> $DIR/overflowing-lsh-4.rs:10:13 | LL | let x = 1_i8 << 17; | ^^^^^^^^^^ attempt to shift left by `17_i32`, which would overflow | note: the lint level is defined here - --> $DIR/overflowing-lsh-4.rs:7:9 + --> $DIR/overflowing-lsh-4.rs:6:9 | LL | #![deny(arithmetic_overflow)] | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/numbers-arithmetic/overflowing-rsh-1.rs b/tests/ui/numbers-arithmetic/overflowing-rsh-1.rs index 80593c8656f51..6c67677ee0c6f 100644 --- a/tests/ui/numbers-arithmetic/overflowing-rsh-1.rs +++ b/tests/ui/numbers-arithmetic/overflowing-rsh-1.rs @@ -1,4 +1,3 @@ -// build-fail // compile-flags: -C debug-assertions #![deny(arithmetic_overflow)] diff --git a/tests/ui/numbers-arithmetic/overflowing-rsh-1.stderr b/tests/ui/numbers-arithmetic/overflowing-rsh-1.stderr index 62763e9e1df8b..16f028958b378 100644 --- a/tests/ui/numbers-arithmetic/overflowing-rsh-1.stderr +++ b/tests/ui/numbers-arithmetic/overflowing-rsh-1.stderr @@ -1,11 +1,11 @@ error: this arithmetic operation will overflow - --> $DIR/overflowing-rsh-1.rs:7:14 + --> $DIR/overflowing-rsh-1.rs:6:14 | LL | let _x = -1_i32 >> 32; | ^^^^^^^^^^^^ attempt to shift right by `32_i32`, which would overflow | note: the lint level is defined here - --> $DIR/overflowing-rsh-1.rs:4:9 + --> $DIR/overflowing-rsh-1.rs:3:9 | LL | #![deny(arithmetic_overflow)] | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/numbers-arithmetic/overflowing-rsh-2.rs b/tests/ui/numbers-arithmetic/overflowing-rsh-2.rs index 917352bfce417..a046caee9d641 100644 --- a/tests/ui/numbers-arithmetic/overflowing-rsh-2.rs +++ b/tests/ui/numbers-arithmetic/overflowing-rsh-2.rs @@ -1,4 +1,3 @@ -// build-fail // compile-flags: -C debug-assertions #![deny(arithmetic_overflow)] diff --git a/tests/ui/numbers-arithmetic/overflowing-rsh-2.stderr b/tests/ui/numbers-arithmetic/overflowing-rsh-2.stderr index 519e62fef7d89..0152ceb66f5c1 100644 --- a/tests/ui/numbers-arithmetic/overflowing-rsh-2.stderr +++ b/tests/ui/numbers-arithmetic/overflowing-rsh-2.stderr @@ -1,11 +1,11 @@ error: this arithmetic operation will overflow - --> $DIR/overflowing-rsh-2.rs:7:14 + --> $DIR/overflowing-rsh-2.rs:6:14 | LL | let _x = -1_i32 >> -1; | ^^^^^^^^^^^^ attempt to shift right by `-1_i32`, which would overflow | note: the lint level is defined here - --> $DIR/overflowing-rsh-2.rs:4:9 + --> $DIR/overflowing-rsh-2.rs:3:9 | LL | #![deny(arithmetic_overflow)] | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/numbers-arithmetic/overflowing-rsh-3.rs b/tests/ui/numbers-arithmetic/overflowing-rsh-3.rs index 1e052990a7630..c5cdcaaa23c56 100644 --- a/tests/ui/numbers-arithmetic/overflowing-rsh-3.rs +++ b/tests/ui/numbers-arithmetic/overflowing-rsh-3.rs @@ -1,4 +1,3 @@ -// build-fail // compile-flags: -C debug-assertions #![deny(arithmetic_overflow)] diff --git a/tests/ui/numbers-arithmetic/overflowing-rsh-3.stderr b/tests/ui/numbers-arithmetic/overflowing-rsh-3.stderr index de24ea1fcde93..1dbd5274049a2 100644 --- a/tests/ui/numbers-arithmetic/overflowing-rsh-3.stderr +++ b/tests/ui/numbers-arithmetic/overflowing-rsh-3.stderr @@ -1,11 +1,11 @@ error: this arithmetic operation will overflow - --> $DIR/overflowing-rsh-3.rs:7:14 + --> $DIR/overflowing-rsh-3.rs:6:14 | LL | let _x = -1_i64 >> 64; | ^^^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow | note: the lint level is defined here - --> $DIR/overflowing-rsh-3.rs:4:9 + --> $DIR/overflowing-rsh-3.rs:3:9 | LL | #![deny(arithmetic_overflow)] | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/numbers-arithmetic/overflowing-rsh-4.rs b/tests/ui/numbers-arithmetic/overflowing-rsh-4.rs index be918becd3a3a..6b62a37b21ad4 100644 --- a/tests/ui/numbers-arithmetic/overflowing-rsh-4.rs +++ b/tests/ui/numbers-arithmetic/overflowing-rsh-4.rs @@ -1,4 +1,3 @@ -// build-fail // compile-flags: -C debug-assertions // This function is checking that our (type-based) automatic diff --git a/tests/ui/numbers-arithmetic/overflowing-rsh-4.stderr b/tests/ui/numbers-arithmetic/overflowing-rsh-4.stderr index 47588012fb692..ea018e622e2f4 100644 --- a/tests/ui/numbers-arithmetic/overflowing-rsh-4.stderr +++ b/tests/ui/numbers-arithmetic/overflowing-rsh-4.stderr @@ -1,11 +1,11 @@ error: this arithmetic operation will overflow - --> $DIR/overflowing-rsh-4.rs:11:13 + --> $DIR/overflowing-rsh-4.rs:10:13 | LL | let x = 2_i8 >> 17; | ^^^^^^^^^^ attempt to shift right by `17_i32`, which would overflow | note: the lint level is defined here - --> $DIR/overflowing-rsh-4.rs:7:9 + --> $DIR/overflowing-rsh-4.rs:6:9 | LL | #![deny(arithmetic_overflow)] | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/numbers-arithmetic/overflowing-rsh-5.rs b/tests/ui/numbers-arithmetic/overflowing-rsh-5.rs index f75e779ed158c..e675c7e87cadc 100644 --- a/tests/ui/numbers-arithmetic/overflowing-rsh-5.rs +++ b/tests/ui/numbers-arithmetic/overflowing-rsh-5.rs @@ -1,4 +1,3 @@ -// build-fail // compile-flags: -C debug-assertions #![deny(arithmetic_overflow)] diff --git a/tests/ui/numbers-arithmetic/overflowing-rsh-5.stderr b/tests/ui/numbers-arithmetic/overflowing-rsh-5.stderr index e9a1572d3cc9d..d130e8f415498 100644 --- a/tests/ui/numbers-arithmetic/overflowing-rsh-5.stderr +++ b/tests/ui/numbers-arithmetic/overflowing-rsh-5.stderr @@ -1,11 +1,11 @@ error: this arithmetic operation will overflow - --> $DIR/overflowing-rsh-5.rs:7:14 + --> $DIR/overflowing-rsh-5.rs:6:14 | LL | let _n = 1i64 >> [64][0]; | ^^^^^^^^^^^^^^^ attempt to shift right by `64_i32`, which would overflow | note: the lint level is defined here - --> $DIR/overflowing-rsh-5.rs:4:9 + --> $DIR/overflowing-rsh-5.rs:3:9 | LL | #![deny(arithmetic_overflow)] | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/query-system/query_depth.rs b/tests/ui/query-system/query_depth.rs index e600c1c08e5cf..e98bb6c0e4573 100644 --- a/tests/ui/query-system/query_depth.rs +++ b/tests/ui/query-system/query_depth.rs @@ -1,5 +1,3 @@ -// build-fail - #![recursion_limit = "64"] type Byte = Option>>> >>>>; fn main() { -//~^ ERROR: queries overflow the depth limit! + //~^ ERROR: queries overflow the depth limit! println!("{}", std::mem::size_of::()); } diff --git a/tests/ui/query-system/query_depth.stderr b/tests/ui/query-system/query_depth.stderr index d455e0e4ff8fa..3d14690dabf7b 100644 --- a/tests/ui/query-system/query_depth.stderr +++ b/tests/ui/query-system/query_depth.stderr @@ -1,5 +1,5 @@ error: queries overflow the depth limit! - --> $DIR/query_depth.rs:28:1 + --> $DIR/query_depth.rs:26:1 | LL | fn main() { | ^^^^^^^^^ diff --git a/tests/ui/recursion/issue-26548-recursion-via-normalize.rs b/tests/ui/recursion/issue-26548-recursion-via-normalize.rs index 6c7fc4beb543d..30437b84cb129 100644 --- a/tests/ui/recursion/issue-26548-recursion-via-normalize.rs +++ b/tests/ui/recursion/issue-26548-recursion-via-normalize.rs @@ -1,9 +1,8 @@ -//~ ERROR cycle detected when computing layout of `core::option::Option` +//~ ERROR cycle detected when computing layout of `S` //~| NOTE see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information -//~| NOTE ...which requires computing layout of `S`... +//~| NOTE ...which requires computing layout of `core::option::Option`... //~| NOTE ...which requires computing layout of `core::option::Option<::It>`... -//~| NOTE ...which again requires computing layout of `core::option::Option`, completing the cycle -//~| NOTE cycle used when computing layout of `core::option::Option<::It>` +//~| NOTE ...which again requires computing layout of `S`, completing the cycle trait Mirror { type It: ?Sized; @@ -14,5 +13,6 @@ impl Mirror for T { struct S(Option<::It>); fn main() { + //~^ NOTE cycle used when checking const prop lints for `main` let _s = S(None); } diff --git a/tests/ui/recursion/issue-26548-recursion-via-normalize.stderr b/tests/ui/recursion/issue-26548-recursion-via-normalize.stderr index e77fb025bcf19..aa3d0108876b4 100644 --- a/tests/ui/recursion/issue-26548-recursion-via-normalize.stderr +++ b/tests/ui/recursion/issue-26548-recursion-via-normalize.stderr @@ -1,9 +1,13 @@ -error[E0391]: cycle detected when computing layout of `core::option::Option` +error[E0391]: cycle detected when computing layout of `S` | - = note: ...which requires computing layout of `S`... = note: ...which requires computing layout of `core::option::Option<::It>`... - = note: ...which again requires computing layout of `core::option::Option`, completing the cycle - = note: cycle used when computing layout of `core::option::Option<::It>` + = note: ...which requires computing layout of `core::option::Option`... + = note: ...which again requires computing layout of `S`, completing the cycle +note: cycle used when checking const prop lints for `main` + --> $DIR/issue-26548-recursion-via-normalize.rs:15:1 + | +LL | fn main() { + | ^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to 1 previous error diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.precise.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.precise.stderr index f166bdf6cecce..099eac7eae407 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.precise.stderr +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.precise.stderr @@ -1,15 +1,57 @@ -error[E0493]: destructor of `T` cannot be evaluated at compile-time - --> $DIR/const-drop.rs:19:32 - | -LL | const fn a(_: T) {} - | ^ the destructor for this type cannot be evaluated in constant functions - error[E0493]: destructor of `S<'_>` cannot be evaluated at compile-time --> $DIR/const-drop.rs:24:13 | LL | let _ = S(&mut c); | ^^^^^^^^^ the destructor for this type cannot be evaluated in constant functions -error: aborting due to 2 previous errors +error[E0080]: evaluation of constant value failed + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL + | + = note: calling non-const function ` as Drop>::drop` + | +note: inside `std::ptr::drop_in_place::> - shim(Some(S<'_>))` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL +note: inside `b` + --> $DIR/const-drop.rs:24:22 + | +LL | let _ = S(&mut c); + | ^ +note: inside `C` + --> $DIR/const-drop.rs:30:15 + | +LL | const C: u8 = b(); + | ^^^ + +note: erroneous constant encountered + --> $DIR/const-drop.rs:115:16 + | +LL | assert_eq!(C, 2); + | ^ + +note: erroneous constant encountered + --> $DIR/const-drop.rs:115:5 + | +LL | assert_eq!(C, 2); + | ^^^^^^^^^^^^^^^^ + | + = note: this note originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) + +note: erroneous constant encountered + --> $DIR/const-drop.rs:115:5 + | +LL | assert_eq!(C, 2); + | ^^^^^^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + = note: this note originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0493]: destructor of `T` cannot be evaluated at compile-time + --> $DIR/const-drop.rs:19:32 + | +LL | const fn a(_: T) {} + | ^ the destructor for this type cannot be evaluated in constant functions + +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0493`. +Some errors have detailed explanations: E0080, E0493. +For more information about an error, try `rustc --explain E0080`. diff --git a/tests/ui/simd/type-generic-monomorphisation-empty.rs b/tests/ui/simd/type-generic-monomorphisation-empty.rs index 2bf6641e9c91c..fc0428ac787db 100644 --- a/tests/ui/simd/type-generic-monomorphisation-empty.rs +++ b/tests/ui/simd/type-generic-monomorphisation-empty.rs @@ -1,5 +1,3 @@ -// build-fail - #![feature(repr_simd, platform_intrinsics)] // error-pattern:monomorphising SIMD type `Simd<0>` of zero length diff --git a/tests/ui/simd/type-generic-monomorphisation-non-primitive.rs b/tests/ui/simd/type-generic-monomorphisation-non-primitive.rs index 0bc73b155801e..1bc048f9c964e 100644 --- a/tests/ui/simd/type-generic-monomorphisation-non-primitive.rs +++ b/tests/ui/simd/type-generic-monomorphisation-non-primitive.rs @@ -1,5 +1,3 @@ -// build-fail - #![feature(repr_simd)] struct E; diff --git a/tests/ui/simd/type-generic-monomorphisation-oversized.rs b/tests/ui/simd/type-generic-monomorphisation-oversized.rs index a7dc482f3cb1d..f02936b59e43f 100644 --- a/tests/ui/simd/type-generic-monomorphisation-oversized.rs +++ b/tests/ui/simd/type-generic-monomorphisation-oversized.rs @@ -1,5 +1,3 @@ -// build-fail - #![feature(repr_simd, platform_intrinsics)] // error-pattern:monomorphising SIMD type `Simd<65536>` of length greater than 32768 diff --git a/tests/ui/simd/type-generic-monomorphisation-wide-ptr.rs b/tests/ui/simd/type-generic-monomorphisation-wide-ptr.rs index 3e02b08ce5da2..a356856da5656 100644 --- a/tests/ui/simd/type-generic-monomorphisation-wide-ptr.rs +++ b/tests/ui/simd/type-generic-monomorphisation-wide-ptr.rs @@ -1,5 +1,3 @@ -// build-fail - #![feature(repr_simd)] // error-pattern:monomorphising SIMD type `S<[*mut [u8]; 4]>` with a non-primitive-scalar (integer/float/pointer) element type `*mut [u8]` diff --git a/tests/ui/simd/type-generic-monomorphisation.rs b/tests/ui/simd/type-generic-monomorphisation.rs index 12f9d65d77af0..e29fdfcfe6822 100644 --- a/tests/ui/simd/type-generic-monomorphisation.rs +++ b/tests/ui/simd/type-generic-monomorphisation.rs @@ -1,8 +1,5 @@ -// build-fail - #![feature(repr_simd, platform_intrinsics)] - // error-pattern:monomorphising SIMD type `Simd2` with a non-primitive-scalar (integer/float/pointer) element type `X` struct X(Vec); diff --git a/tests/ui/simd/type-wide-ptr.rs b/tests/ui/simd/type-wide-ptr.rs index 88f62a07ea0d8..07a94d9a72eb6 100644 --- a/tests/ui/simd/type-wide-ptr.rs +++ b/tests/ui/simd/type-wide-ptr.rs @@ -1,5 +1,3 @@ -// build-fail - #![feature(repr_simd)] // error-pattern:monomorphising SIMD type `S` with a non-primitive-scalar (integer/float/pointer) element type `*mut [u8]` diff --git a/tests/ui/sized/recursive-type-binding.rs b/tests/ui/sized/recursive-type-binding.rs index 7d95417a6ffd9..4b8f32ee012fc 100644 --- a/tests/ui/sized/recursive-type-binding.rs +++ b/tests/ui/sized/recursive-type-binding.rs @@ -1,5 +1,4 @@ -// build-fail -//~^ ERROR cycle detected when computing layout of `Foo<()>` +//~ ERROR cycle detected when computing layout of `Foo<()>` trait A { type Assoc: ?Sized; } diff --git a/tests/ui/sized/recursive-type-binding.stderr b/tests/ui/sized/recursive-type-binding.stderr index d9c2efa4d53b7..7a86644ce2b7f 100644 --- a/tests/ui/sized/recursive-type-binding.stderr +++ b/tests/ui/sized/recursive-type-binding.stderr @@ -2,8 +2,8 @@ error[E0391]: cycle detected when computing layout of `Foo<()>` | = note: ...which requires computing layout of `<() as A>::Assoc`... = note: ...which again requires computing layout of `Foo<()>`, completing the cycle -note: cycle used when elaborating drops for `main` - --> $DIR/recursive-type-binding.rs:11:1 +note: cycle used when checking const prop lints for `main` + --> $DIR/recursive-type-binding.rs:10:1 | LL | fn main() { | ^^^^^^^^^ diff --git a/tests/ui/sized/recursive-type-coercion-from-never.rs b/tests/ui/sized/recursive-type-coercion-from-never.rs index a1b654637316d..4e060b639f578 100644 --- a/tests/ui/sized/recursive-type-coercion-from-never.rs +++ b/tests/ui/sized/recursive-type-coercion-from-never.rs @@ -1,5 +1,4 @@ -// build-fail -//~^ ERROR cycle detected when computing layout of `Foo<()>` +//~ ERROR cycle detected when computing layout of `Foo<()>` // Regression test for a stack overflow: https://github.com/rust-lang/rust/issues/113197 diff --git a/tests/ui/sized/recursive-type-coercion-from-never.stderr b/tests/ui/sized/recursive-type-coercion-from-never.stderr index 7580e780dda59..d8f49321dda05 100644 --- a/tests/ui/sized/recursive-type-coercion-from-never.stderr +++ b/tests/ui/sized/recursive-type-coercion-from-never.stderr @@ -2,8 +2,8 @@ error[E0391]: cycle detected when computing layout of `Foo<()>` | = note: ...which requires computing layout of `<() as A>::Assoc`... = note: ...which again requires computing layout of `Foo<()>`, completing the cycle -note: cycle used when elaborating drops for `main` - --> $DIR/recursive-type-coercion-from-never.rs:14:1 +note: cycle used when checking const prop lints for `main` + --> $DIR/recursive-type-coercion-from-never.rs:13:1 | LL | fn main() { | ^^^^^^^^^ diff --git a/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.rs b/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.rs index e7b23d5f8a1c9..7a2ea881b6432 100644 --- a/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.rs +++ b/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.rs @@ -1,5 +1,4 @@ // edition: 2021 -// build-fail #![feature(impl_trait_in_assoc_type)] diff --git a/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.stderr b/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.stderr index b62186103c7cb..89c4bd1d50d6b 100644 --- a/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.stderr +++ b/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.stderr @@ -1,5 +1,5 @@ error[E0733]: recursion in an async block requires boxing - --> $DIR/indirect-recursion-issue-112047.rs:22:9 + --> $DIR/indirect-recursion-issue-112047.rs:21:9 | LL | async move { recur(self).await; } | ^^^^^^^^^^^^^-----------------^^^ @@ -7,7 +7,7 @@ LL | async move { recur(self).await; } | recursive call here | note: which leads to this async fn - --> $DIR/indirect-recursion-issue-112047.rs:14:1 + --> $DIR/indirect-recursion-issue-112047.rs:13:1 | LL | async fn recur(t: impl Recur) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/type-alias-impl-trait/mututally-recursive-overflow.rs b/tests/ui/type-alias-impl-trait/mututally-recursive-overflow.rs index 1ccd1b0cbad4b..95d0d736263be 100644 --- a/tests/ui/type-alias-impl-trait/mututally-recursive-overflow.rs +++ b/tests/ui/type-alias-impl-trait/mututally-recursive-overflow.rs @@ -1,6 +1,5 @@ // edition: 2021 -// build-fail -//~^^ ERROR overflow evaluating the requirement `<() as B>::Assoc == _` +//~^ ERROR overflow evaluating the requirement `<() as B>::Assoc == _` #![feature(rustc_attrs)] #![feature(impl_trait_in_assoc_type)] From f2718930bcd77dd2b0fc7adb6e3a16c39b55af4e Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Thu, 8 Feb 2024 10:02:20 +0000 Subject: [PATCH 2/2] Don't evaluate predicates twice to check for impossible predicates --- compiler/rustc_middle/src/query/erase.rs | 1 + compiler/rustc_middle/src/query/mod.rs | 3 +- compiler/rustc_middle/src/traits/util.rs | 6 ++ compiler/rustc_mir_transform/src/lib.rs | 76 +++++++++++------------- 4 files changed, 45 insertions(+), 41 deletions(-) diff --git a/compiler/rustc_middle/src/query/erase.rs b/compiler/rustc_middle/src/query/erase.rs index a272a51f32747..5ae942ce3ceef 100644 --- a/compiler/rustc_middle/src/query/erase.rs +++ b/compiler/rustc_middle/src/query/erase.rs @@ -241,6 +241,7 @@ trivial! { Option, Option, Result<(), rustc_errors::ErrorGuaranteed>, + Result<(), traits::util::HasImpossiblePredicates>, Result<(), rustc_middle::traits::query::NoSolution>, Result, rustc_ast::expand::allocator::AllocatorKind, diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index 71ecc0c09f98f..c1f2e2e9d91a2 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -39,6 +39,7 @@ use crate::traits::query::{ OutlivesBound, }; use crate::traits::specialization_graph; +use crate::traits::util::HasImpossiblePredicates; use crate::traits::{ CodegenObligationError, EvaluationResult, ImplSource, ObjectSafetyViolation, ObligationCause, OverflowError, WellFormedLoc, @@ -1019,7 +1020,7 @@ rustc_queries! { } /// Run the const prop lints on the `mir_promoted` of an item. - query const_prop_lint(key: LocalDefId) { + query const_prop_lint(key: LocalDefId) -> Result<(), HasImpossiblePredicates> { desc { |tcx| "checking const prop lints for `{}`", tcx.def_path_str(key) } cache_on_disk_if { true } } diff --git a/compiler/rustc_middle/src/traits/util.rs b/compiler/rustc_middle/src/traits/util.rs index b4054f8ff5edd..6183e0dda699e 100644 --- a/compiler/rustc_middle/src/traits/util.rs +++ b/compiler/rustc_middle/src/traits/util.rs @@ -46,3 +46,9 @@ impl<'tcx> Iterator for Elaborator<'tcx> { } } } + +/// Used as an error type to signal that an item may have an invalid body, because its +/// where bounds are trivially not satisfyable. +#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)] +#[derive(HashStable, Encodable, Decodable)] +pub struct HasImpossiblePredicates; diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index bda2f175e68f9..e5d5b3d65d0f1 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -40,6 +40,7 @@ use rustc_middle::mir::{ SourceInfo, Statement, StatementKind, TerminatorKind, START_BLOCK, }; use rustc_middle::query::Providers; +use rustc_middle::traits::util::HasImpossiblePredicates; use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt}; use rustc_span::{source_map::Spanned, sym, DUMMY_SP}; use rustc_trait_selection::traits; @@ -399,51 +400,12 @@ fn inner_mir_for_ctfe(tcx: TyCtxt<'_>, def: LocalDefId) -> Body<'_> { body } -fn const_prop_lint(tcx: TyCtxt<'_>, def: LocalDefId) { +fn const_prop_lint(tcx: TyCtxt<'_>, def: LocalDefId) -> Result<(), HasImpossiblePredicates> { let (body, _) = tcx.mir_promoted(def); let body = body.borrow(); let mir_borrowck = tcx.mir_borrowck(def); - // If there are impossible bounds on the body being const prop linted, - // the const eval logic used in const prop may ICE unexpectedly. - let predicates = tcx - .predicates_of(body.source.def_id()) - .predicates - .iter() - .filter_map(|(p, _)| if p.is_global() { Some(*p) } else { None }); - if !traits::impossible_predicates(tcx, traits::elaborate(tcx, predicates).collect()) - && mir_borrowck.tainted_by_errors.is_none() - && body.tainted_by_errors.is_none() - { - const_prop_lint::ConstPropLint.run_lint(tcx, &body); - } -} - -/// Obtain just the main MIR (no promoteds) and run some cleanups on it. This also runs -/// mir borrowck *before* doing so in order to ensure that borrowck can be run and doesn't -/// end up missing the source MIR due to stealing happening. -fn mir_drops_elaborated_and_const_checked(tcx: TyCtxt<'_>, def: LocalDefId) -> &Steal> { - if tcx.is_coroutine(def.to_def_id()) { - tcx.ensure_with_value().mir_coroutine_witnesses(def); - } - let mir_borrowck = tcx.mir_borrowck(def); - tcx.ensure().const_prop_lint(def); - - let is_fn_like = tcx.def_kind(def).is_fn_like(); - if is_fn_like { - // Do not compute the mir call graph without said call graph actually being used. - if pm::should_run_pass(tcx, &inline::Inline) { - tcx.ensure_with_value().mir_inliner_callees(ty::InstanceDef::Item(def.to_def_id())); - } - } - - let (body, _) = tcx.mir_promoted(def); - let mut body = body.steal(); - if let Some(error_reported) = mir_borrowck.tainted_by_errors { - body.tainted_by_errors = Some(error_reported); - } - // Check if it's even possible to satisfy the 'where' clauses // for this item. // @@ -478,6 +440,40 @@ fn mir_drops_elaborated_and_const_checked(tcx: TyCtxt<'_>, def: LocalDefId) -> & .iter() .filter_map(|(p, _)| if p.is_global() { Some(*p) } else { None }); if traits::impossible_predicates(tcx, traits::elaborate(tcx, predicates).collect()) { + Err(HasImpossiblePredicates) + } else { + if mir_borrowck.tainted_by_errors.is_none() && body.tainted_by_errors.is_none() { + const_prop_lint::ConstPropLint.run_lint(tcx, &body); + } + Ok(()) + } +} + +/// Obtain just the main MIR (no promoteds) and run some cleanups on it. This also runs +/// mir borrowck *before* doing so in order to ensure that borrowck can be run and doesn't +/// end up missing the source MIR due to stealing happening. +fn mir_drops_elaborated_and_const_checked(tcx: TyCtxt<'_>, def: LocalDefId) -> &Steal> { + if tcx.is_coroutine(def.to_def_id()) { + tcx.ensure_with_value().mir_coroutine_witnesses(def); + } + let mir_borrowck = tcx.mir_borrowck(def); + let has_impossible_predicates = tcx.const_prop_lint(def); + + let is_fn_like = tcx.def_kind(def).is_fn_like(); + if is_fn_like { + // Do not compute the mir call graph without said call graph actually being used. + if pm::should_run_pass(tcx, &inline::Inline) { + tcx.ensure_with_value().mir_inliner_callees(ty::InstanceDef::Item(def.to_def_id())); + } + } + + let (body, _) = tcx.mir_promoted(def); + let mut body = body.steal(); + if let Some(error_reported) = mir_borrowck.tainted_by_errors { + body.tainted_by_errors = Some(error_reported); + } + + if let Err(HasImpossiblePredicates) = has_impossible_predicates { trace!("found unsatisfiable predicates for {:?}", body.source); // Clear the body to only contain a single `unreachable` statement. let bbs = body.basic_blocks.as_mut();