From a17294dc0fe106f0a8f12f8bc61ab17eacf251ef Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sun, 1 Dec 2024 14:47:10 +0100 Subject: [PATCH] fix ICE when promoted has layout size overflow --- .../rustc_const_eval/src/const_eval/error.rs | 17 ++++-- .../src/interpret/eval_context.rs | 11 ++-- .../rustc_middle/src/mir/interpret/error.rs | 26 +++----- tests/crashes/125476.rs | 4 -- .../unevaluated-const-ice-119731.stderr | 14 +++++ tests/ui/consts/const-integer-bool-ops.stderr | 60 +++++++++++++++++++ .../consts/const-mut-refs/issue-76510.stderr | 6 ++ tests/ui/consts/const-tup-index-span.stderr | 6 ++ tests/ui/consts/issue-54954.stderr | 18 ++++++ .../consts/missing_assoc_const_type2.stderr | 6 ++ ..._running_out_of_memory_issue-130687.stderr | 6 -- tests/ui/consts/promoted_size_overflow.rs | 7 +++ tests/ui/consts/promoted_size_overflow.stderr | 9 +++ .../consts/uninhabited-const-issue-61744.rs | 6 +- .../uninhabited-const-issue-61744.stderr | 14 ----- tests/ui/enum-discriminant/issue-41394.stderr | 6 ++ .../ctfe-id-unlimited.return.stderr | 6 -- .../base-layout-is-sized-ice-123078.stderr | 6 ++ tests/ui/limits/issue-55878.stderr | 17 ------ ...om-outer-item-in-const-item.default.stderr | 14 +++++ ...m-in-const-item.generic_const_items.stderr | 14 +++++ tests/ui/resolve/issue-50599.stderr | 6 ++ .../avoid-invalid-mir.stderr | 6 ++ ...bitrary-self-from-method-substs-ice.stderr | 6 ++ .../type-dependent-def-issue-49241.stderr | 6 ++ 25 files changed, 218 insertions(+), 79 deletions(-) delete mode 100644 tests/crashes/125476.rs create mode 100644 tests/ui/consts/promoted_size_overflow.rs create mode 100644 tests/ui/consts/promoted_size_overflow.stderr diff --git a/compiler/rustc_const_eval/src/const_eval/error.rs b/compiler/rustc_const_eval/src/const_eval/error.rs index 1271d9d2d0da6..3cb77d1dcb5c7 100644 --- a/compiler/rustc_const_eval/src/const_eval/error.rs +++ b/compiler/rustc_const_eval/src/const_eval/error.rs @@ -139,12 +139,14 @@ where match error { // Don't emit a new diagnostic for these errors, they are already reported elsewhere or // should remain silent. + err_inval!(AlreadyReported(info)) => ErrorHandled::Reported(info, span), err_inval!(Layout(LayoutError::Unknown(_))) | err_inval!(TooGeneric) => { ErrorHandled::TooGeneric(span) } - err_inval!(AlreadyReported(guar)) => ErrorHandled::Reported(guar, span), err_inval!(Layout(LayoutError::ReferencesError(guar))) => { - ErrorHandled::Reported(ReportedErrorInfo::tainted_by_errors(guar), span) + // This can occur in infallible promoteds e.g. when a non-existent type or field is + // encountered. + ErrorHandled::Reported(ReportedErrorInfo::allowed_in_infallible(guar), span) } // Report remaining errors. _ => { @@ -152,7 +154,12 @@ where let span = span.substitute_dummy(our_span); let err = mk(span, frames); let mut err = tcx.dcx().create_err(err); - let can_be_spurious = matches!(error, InterpErrorKind::ResourceExhaustion(_)); + // We allow invalid programs in infallible promoteds since invalid layouts can occur + // anyway (e.g. due to size overflow). And we allow OOM as that can happen any time. + let allowed_in_infallible = matches!( + error, + InterpErrorKind::ResourceExhaustion(_) | InterpErrorKind::InvalidProgram(_) + ); let msg = error.diagnostic_message(); error.add_args(&mut err); @@ -160,8 +167,8 @@ where // Use *our* span to label the interp error err.span_label(our_span, msg); let g = err.emit(); - let reported = if can_be_spurious { - ReportedErrorInfo::spurious(g) + let reported = if allowed_in_infallible { + ReportedErrorInfo::allowed_in_infallible(g) } else { ReportedErrorInfo::from(g) }; diff --git a/compiler/rustc_const_eval/src/interpret/eval_context.rs b/compiler/rustc_const_eval/src/interpret/eval_context.rs index fe93a48c2f2cb..241be5e175cd4 100644 --- a/compiler/rustc_const_eval/src/interpret/eval_context.rs +++ b/compiler/rustc_const_eval/src/interpret/eval_context.rs @@ -268,7 +268,7 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { }; // do not continue if typeck errors occurred (can only occur in local crate) if let Some(err) = body.tainted_by_errors { - throw_inval!(AlreadyReported(ReportedErrorInfo::tainted_by_errors(err))); + throw_inval!(AlreadyReported(ReportedErrorInfo::from(err))); } interp_ok(body) } @@ -585,13 +585,10 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> { match err { ErrorHandled::TooGeneric(..) => {}, ErrorHandled::Reported(reported, span) => { - if reported.is_tainted_by_errors() { - // const-eval will return "tainted" errors if e.g. the layout cannot - // be computed as the type references non-existing names. - // See . - } else if reported.can_be_spurious() { + if reported.is_allowed_in_infallible() { // These errors can just sometimes happen, even when the expression - // is nominally "infallible", e.g. when running out of memory. + // is nominally "infallible", e.g. when running out of memory + // or when some layout could not be computed. } else { // Looks like the const is not captured by `required_consts`, that's bad. span_bug!(span, "interpret const eval failure of {val:?} which is not in required_consts"); diff --git a/compiler/rustc_middle/src/mir/interpret/error.rs b/compiler/rustc_middle/src/mir/interpret/error.rs index 08afa33c6b432..ad5d678178de6 100644 --- a/compiler/rustc_middle/src/mir/interpret/error.rs +++ b/compiler/rustc_middle/src/mir/interpret/error.rs @@ -46,7 +46,7 @@ impl ErrorHandled { pub fn emit_note(&self, tcx: TyCtxt<'_>) { match self { &ErrorHandled::Reported(err, span) => { - if !err.is_tainted_by_errors && !span.is_dummy() { + if !err.allowed_in_infallible && !span.is_dummy() { tcx.dcx().emit_note(error::ErroneousConstant { span }); } } @@ -58,34 +58,26 @@ impl ErrorHandled { #[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable, TyEncodable, TyDecodable)] pub struct ReportedErrorInfo { error: ErrorGuaranteed, - is_tainted_by_errors: bool, - /// Whether this is the kind of error that can sometimes occur, and sometimes not. - /// Used for resource exhaustion errors. - can_be_spurious: bool, + /// Whether this error is allowed to show up even in otherwise "infallible" promoteds. + /// This is for things like overflows during size computation or resource exhaustion. + allowed_in_infallible: bool, } impl ReportedErrorInfo { #[inline] - pub fn tainted_by_errors(error: ErrorGuaranteed) -> ReportedErrorInfo { - ReportedErrorInfo { is_tainted_by_errors: true, can_be_spurious: false, error } - } - #[inline] - pub fn spurious(error: ErrorGuaranteed) -> ReportedErrorInfo { - ReportedErrorInfo { can_be_spurious: true, is_tainted_by_errors: false, error } + pub fn allowed_in_infallible(error: ErrorGuaranteed) -> ReportedErrorInfo { + ReportedErrorInfo { allowed_in_infallible: true, error } } - pub fn is_tainted_by_errors(&self) -> bool { - self.is_tainted_by_errors - } - pub fn can_be_spurious(&self) -> bool { - self.can_be_spurious + pub fn is_allowed_in_infallible(&self) -> bool { + self.allowed_in_infallible } } impl From for ReportedErrorInfo { #[inline] fn from(error: ErrorGuaranteed) -> ReportedErrorInfo { - ReportedErrorInfo { is_tainted_by_errors: false, can_be_spurious: false, error } + ReportedErrorInfo { allowed_in_infallible: false, error } } } diff --git a/tests/crashes/125476.rs b/tests/crashes/125476.rs deleted file mode 100644 index ad739639b7221..0000000000000 --- a/tests/crashes/125476.rs +++ /dev/null @@ -1,4 +0,0 @@ -//@ known-bug: rust-lang/rust#125476 -//@ only-x86_64 -pub struct Data([u8; usize::MAX >> 2]); -const _: &'static [Data] = &[]; diff --git a/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr b/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr index 30a45ce377e7e..4eb374b202041 100644 --- a/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr +++ b/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr @@ -72,6 +72,20 @@ help: add `#![feature(adt_const_params)]` to the crate attributes to enable more LL + #![feature(adt_const_params)] | +note: erroneous constant encountered + --> $DIR/unevaluated-const-ice-119731.rs:22:19 + | +LL | impl v17<512, v0> { + | ^^ + +note: erroneous constant encountered + --> $DIR/unevaluated-const-ice-119731.rs:22:19 + | +LL | impl v17<512, v0> { + | ^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error: maximum number of nodes exceeded in constant v20::v17::::{constant#0} --> $DIR/unevaluated-const-ice-119731.rs:28:37 | diff --git a/tests/ui/consts/const-integer-bool-ops.stderr b/tests/ui/consts/const-integer-bool-ops.stderr index 4e503e5a5c0a4..d58a8e93ff6f7 100644 --- a/tests/ui/consts/const-integer-bool-ops.stderr +++ b/tests/ui/consts/const-integer-bool-ops.stderr @@ -16,6 +16,12 @@ error[E0308]: mismatched types LL | const X: usize = 42 && 39; | ^^^^^^^^ expected `usize`, found `bool` +note: erroneous constant encountered + --> $DIR/const-integer-bool-ops.rs:8:18 + | +LL | const ARR: [i32; X] = [99; 34]; + | ^ + error[E0308]: mismatched types --> $DIR/const-integer-bool-ops.rs:10:19 | @@ -34,6 +40,12 @@ error[E0308]: mismatched types LL | const X1: usize = 42 || 39; | ^^^^^^^^ expected `usize`, found `bool` +note: erroneous constant encountered + --> $DIR/const-integer-bool-ops.rs:17:19 + | +LL | const ARR1: [i32; X1] = [99; 47]; + | ^^ + error[E0308]: mismatched types --> $DIR/const-integer-bool-ops.rs:19:19 | @@ -52,6 +64,12 @@ error[E0308]: mismatched types LL | const X2: usize = -42 || -39; | ^^^^^^^^^^ expected `usize`, found `bool` +note: erroneous constant encountered + --> $DIR/const-integer-bool-ops.rs:26:19 + | +LL | const ARR2: [i32; X2] = [99; 18446744073709551607]; + | ^^ + error[E0308]: mismatched types --> $DIR/const-integer-bool-ops.rs:28:19 | @@ -70,42 +88,84 @@ error[E0308]: mismatched types LL | const X3: usize = -42 && -39; | ^^^^^^^^^^ expected `usize`, found `bool` +note: erroneous constant encountered + --> $DIR/const-integer-bool-ops.rs:35:19 + | +LL | const ARR3: [i32; X3] = [99; 6]; + | ^^ + error[E0308]: mismatched types --> $DIR/const-integer-bool-ops.rs:37:18 | LL | const Y: usize = 42.0 == 42.0; | ^^^^^^^^^^^^ expected `usize`, found `bool` +note: erroneous constant encountered + --> $DIR/const-integer-bool-ops.rs:40:19 + | +LL | const ARRR: [i32; Y] = [99; 1]; + | ^ + error[E0308]: mismatched types --> $DIR/const-integer-bool-ops.rs:42:19 | LL | const Y1: usize = 42.0 >= 42.0; | ^^^^^^^^^^^^ expected `usize`, found `bool` +note: erroneous constant encountered + --> $DIR/const-integer-bool-ops.rs:45:20 + | +LL | const ARRR1: [i32; Y1] = [99; 1]; + | ^^ + error[E0308]: mismatched types --> $DIR/const-integer-bool-ops.rs:47:19 | LL | const Y2: usize = 42.0 <= 42.0; | ^^^^^^^^^^^^ expected `usize`, found `bool` +note: erroneous constant encountered + --> $DIR/const-integer-bool-ops.rs:50:20 + | +LL | const ARRR2: [i32; Y2] = [99; 1]; + | ^^ + error[E0308]: mismatched types --> $DIR/const-integer-bool-ops.rs:52:19 | LL | const Y3: usize = 42.0 > 42.0; | ^^^^^^^^^^^ expected `usize`, found `bool` +note: erroneous constant encountered + --> $DIR/const-integer-bool-ops.rs:55:20 + | +LL | const ARRR3: [i32; Y3] = [99; 0]; + | ^^ + error[E0308]: mismatched types --> $DIR/const-integer-bool-ops.rs:57:19 | LL | const Y4: usize = 42.0 < 42.0; | ^^^^^^^^^^^ expected `usize`, found `bool` +note: erroneous constant encountered + --> $DIR/const-integer-bool-ops.rs:60:20 + | +LL | const ARRR4: [i32; Y4] = [99; 0]; + | ^^ + error[E0308]: mismatched types --> $DIR/const-integer-bool-ops.rs:62:19 | LL | const Y5: usize = 42.0 != 42.0; | ^^^^^^^^^^^^ expected `usize`, found `bool` +note: erroneous constant encountered + --> $DIR/const-integer-bool-ops.rs:65:20 + | +LL | const ARRR5: [i32; Y5] = [99; 0]; + | ^^ + error: aborting due to 18 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/consts/const-mut-refs/issue-76510.stderr b/tests/ui/consts/const-mut-refs/issue-76510.stderr index aff86e83578d7..a63be676fdab9 100644 --- a/tests/ui/consts/const-mut-refs/issue-76510.stderr +++ b/tests/ui/consts/const-mut-refs/issue-76510.stderr @@ -4,6 +4,12 @@ error[E0764]: mutable references are not allowed in the final value of constants LL | const S: &'static mut str = &mut " hello "; | ^^^^^^^^^^^^^^ +note: erroneous constant encountered + --> $DIR/issue-76510.rs:7:70 + | +LL | let s = transmute::<(*const u8, usize), &ManuallyDrop>((S.as_ptr(), 3)); + | ^ + error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0764`. diff --git a/tests/ui/consts/const-tup-index-span.stderr b/tests/ui/consts/const-tup-index-span.stderr index 792e18aa8fd4b..2a3f0cfb06dfe 100644 --- a/tests/ui/consts/const-tup-index-span.stderr +++ b/tests/ui/consts/const-tup-index-span.stderr @@ -11,6 +11,12 @@ help: use a trailing comma to create a tuple with one element LL | const TUP: (usize,) = (5usize << 64,); | + ++ +note: erroneous constant encountered + --> $DIR/const-tup-index-span.rs:6:18 + | +LL | const ARR: [i32; TUP.0] = []; + | ^^^ + error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/consts/issue-54954.stderr b/tests/ui/consts/issue-54954.stderr index b8c983eb7b81c..ed6aa9c44a3d9 100644 --- a/tests/ui/consts/issue-54954.stderr +++ b/tests/ui/consts/issue-54954.stderr @@ -19,6 +19,24 @@ LL | | core::mem::size_of::() LL | | } | |_____- `Tt::const_val` defined here +note: erroneous constant encountered + --> $DIR/issue-54954.rs:11:15 + | +LL | fn f(z: [f32; ARR_LEN]) -> [f32; ARR_LEN] { + | ^^^^^^^ + +note: erroneous constant encountered + --> $DIR/issue-54954.rs:11:34 + | +LL | fn f(z: [f32; ARR_LEN]) -> [f32; ARR_LEN] { + | ^^^^^^^ + +note: erroneous constant encountered + --> $DIR/issue-54954.rs:16:22 + | +LL | let _ = f([1f32; ARR_LEN]); + | ^^^^^^^ + error: aborting due to 2 previous errors Some errors have detailed explanations: E0379, E0790. diff --git a/tests/ui/consts/missing_assoc_const_type2.stderr b/tests/ui/consts/missing_assoc_const_type2.stderr index 1255ca2d102b5..3279a077464b8 100644 --- a/tests/ui/consts/missing_assoc_const_type2.stderr +++ b/tests/ui/consts/missing_assoc_const_type2.stderr @@ -4,5 +4,11 @@ error: missing type for `const` item LL | const FIRST: = 10; | ^ help: provide a type for the associated constant: `u8` +note: erroneous constant encountered + --> $DIR/missing_assoc_const_type2.rs:18:5 + | +LL | TwoDigits::FIRST as usize + | ^^^^^^^^^^^^^^^^ + error: aborting due to 1 previous error diff --git a/tests/ui/consts/promoted_running_out_of_memory_issue-130687.stderr b/tests/ui/consts/promoted_running_out_of_memory_issue-130687.stderr index 50e920f05f930..f5d767efceb76 100644 --- a/tests/ui/consts/promoted_running_out_of_memory_issue-130687.stderr +++ b/tests/ui/consts/promoted_running_out_of_memory_issue-130687.stderr @@ -4,12 +4,6 @@ error[E0080]: evaluation of constant value failed LL | const _: &'static Data = &Data([0; (1 << 47) - 1]); | ^^^^^^^^^^^^^^^^^^ tried to allocate more memory than available to compiler -note: erroneous constant encountered - --> $DIR/promoted_running_out_of_memory_issue-130687.rs:8:26 - | -LL | const _: &'static Data = &Data([0; (1 << 47) - 1]); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/promoted_size_overflow.rs b/tests/ui/consts/promoted_size_overflow.rs new file mode 100644 index 0000000000000..3d606905e782c --- /dev/null +++ b/tests/ui/consts/promoted_size_overflow.rs @@ -0,0 +1,7 @@ +//@ only-64bit +pub struct Data([u8; usize::MAX >> 2]); +const _: &'static [Data] = &[]; +//~^ERROR: evaluation of constant value failed +//~| too big for the target architecture + +fn main() {} diff --git a/tests/ui/consts/promoted_size_overflow.stderr b/tests/ui/consts/promoted_size_overflow.stderr new file mode 100644 index 0000000000000..cfb8260bed040 --- /dev/null +++ b/tests/ui/consts/promoted_size_overflow.stderr @@ -0,0 +1,9 @@ +error[E0080]: evaluation of constant value failed + --> $DIR/promoted_size_overflow.rs:3:29 + | +LL | const _: &'static [Data] = &[]; + | ^^ values of the type `[u8; 4611686018427387903]` are too big for the target architecture + +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 6168268bfedc7..19ee842c36bff 100644 --- a/tests/ui/consts/uninhabited-const-issue-61744.rs +++ b/tests/ui/consts/uninhabited-const-issue-61744.rs @@ -5,15 +5,15 @@ pub const unsafe fn fake_type() -> T { } pub const unsafe fn hint_unreachable() -> ! { - fake_type() + fake_type() //~ inside } trait Const { - const CONSTANT: i32 = unsafe { fake_type() }; + const CONSTANT: i32 = unsafe { fake_type() }; //~ inside } impl Const for T {} pub fn main() -> () { - dbg!(i32::CONSTANT); //~ constant + dbg!(i32::CONSTANT); } diff --git a/tests/ui/consts/uninhabited-const-issue-61744.stderr b/tests/ui/consts/uninhabited-const-issue-61744.stderr index c6dd11ee5db92..7575ad730b304 100644 --- a/tests/ui/consts/uninhabited-const-issue-61744.stderr +++ b/tests/ui/consts/uninhabited-const-issue-61744.stderr @@ -645,20 +645,6 @@ note: inside `::CONSTANT` LL | const CONSTANT: i32 = unsafe { fake_type() }; | ^^^^^^^^^^^ -note: erroneous constant encountered - --> $DIR/uninhabited-const-issue-61744.rs:18:10 - | -LL | dbg!(i32::CONSTANT); - | ^^^^^^^^^^^^^ - -note: erroneous constant encountered - --> $DIR/uninhabited-const-issue-61744.rs:18:10 - | -LL | dbg!(i32::CONSTANT); - | ^^^^^^^^^^^^^ - | - = 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/enum-discriminant/issue-41394.stderr b/tests/ui/enum-discriminant/issue-41394.stderr index e81562df04f54..9bf4fc79b1b08 100644 --- a/tests/ui/enum-discriminant/issue-41394.stderr +++ b/tests/ui/enum-discriminant/issue-41394.stderr @@ -6,6 +6,12 @@ LL | A = "" + 1 | | | &str +note: erroneous constant encountered + --> $DIR/issue-41394.rs:7:9 + | +LL | A = Foo::A as isize + | ^^^^^^^^^^^^^^^ + error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0369`. diff --git a/tests/ui/explicit-tail-calls/ctfe-id-unlimited.return.stderr b/tests/ui/explicit-tail-calls/ctfe-id-unlimited.return.stderr index 4a1e50b4111e3..46769cdea8a75 100644 --- a/tests/ui/explicit-tail-calls/ctfe-id-unlimited.return.stderr +++ b/tests/ui/explicit-tail-calls/ctfe-id-unlimited.return.stderr @@ -25,12 +25,6 @@ note: inside `ID_ED` LL | const ID_ED: u32 = rec_id(ORIGINAL); | ^^^^^^^^^^^^^^^^ -note: erroneous constant encountered - --> $DIR/ctfe-id-unlimited.rs:31:40 - | -LL | const ASSERT: () = assert!(ORIGINAL == ID_ED); - | ^^^^^ - error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/layout/base-layout-is-sized-ice-123078.stderr b/tests/ui/layout/base-layout-is-sized-ice-123078.stderr index 455bd2cbf8b6e..ee7f5162552da 100644 --- a/tests/ui/layout/base-layout-is-sized-ice-123078.stderr +++ b/tests/ui/layout/base-layout-is-sized-ice-123078.stderr @@ -25,6 +25,12 @@ LL | const C: S = unsafe { std::mem::transmute(()) }; = note: source type: `()` (0 bits) = note: target type: `S` (size can vary because of [u8]) +note: erroneous constant encountered + --> $DIR/base-layout-is-sized-ice-123078.rs:13:5 + | +LL | C; + | ^ + error: aborting due to 2 previous errors Some errors have detailed explanations: E0277, E0512. diff --git a/tests/ui/limits/issue-55878.stderr b/tests/ui/limits/issue-55878.stderr index 0a5f17be80473..51c4837f45839 100644 --- a/tests/ui/limits/issue-55878.stderr +++ b/tests/ui/limits/issue-55878.stderr @@ -11,23 +11,6 @@ note: inside `main` LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: erroneous constant encountered - --> $DIR/issue-55878.rs:7:26 - | -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 - | -LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = 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/resolve/generic-params-from-outer-item-in-const-item.default.stderr b/tests/ui/resolve/generic-params-from-outer-item-in-const-item.default.stderr index fbb9ede8aa175..c7e9df10d41cb 100644 --- a/tests/ui/resolve/generic-params-from-outer-item-in-const-item.default.stderr +++ b/tests/ui/resolve/generic-params-from-outer-item-in-const-item.default.stderr @@ -29,6 +29,20 @@ LL | const _: u32 = T::C; | = note: a `const` is a separate item from the item that contains it +note: erroneous constant encountered + --> $DIR/generic-params-from-outer-item-in-const-item.rs:22:9 + | +LL | I + | ^ + +note: erroneous constant encountered + --> $DIR/generic-params-from-outer-item-in-const-item.rs:22:9 + | +LL | I + | ^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0401`. diff --git a/tests/ui/resolve/generic-params-from-outer-item-in-const-item.generic_const_items.stderr b/tests/ui/resolve/generic-params-from-outer-item-in-const-item.generic_const_items.stderr index 60aa94038c3ad..64c436d3cebc6 100644 --- a/tests/ui/resolve/generic-params-from-outer-item-in-const-item.generic_const_items.stderr +++ b/tests/ui/resolve/generic-params-from-outer-item-in-const-item.generic_const_items.stderr @@ -35,6 +35,20 @@ LL | const _: u32 = T::C; | = note: a `const` is a separate item from the item that contains it +note: erroneous constant encountered + --> $DIR/generic-params-from-outer-item-in-const-item.rs:22:9 + | +LL | I + | ^ + +note: erroneous constant encountered + --> $DIR/generic-params-from-outer-item-in-const-item.rs:22:9 + | +LL | I + | ^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0401`. diff --git a/tests/ui/resolve/issue-50599.stderr b/tests/ui/resolve/issue-50599.stderr index 24fb3d580b8fa..427dc9f204918 100644 --- a/tests/ui/resolve/issue-50599.stderr +++ b/tests/ui/resolve/issue-50599.stderr @@ -20,6 +20,12 @@ LL - const M: usize = (f64::from(N) * std::f64::LOG10_2) as usize; LL + const M: usize = (f64::from(N) * LOG10_2) as usize; | +note: erroneous constant encountered + --> $DIR/issue-50599.rs:4:29 + | +LL | let mut digits = [0u32; M]; + | ^ + error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/avoid-invalid-mir.stderr b/tests/ui/rfcs/rfc-2497-if-let-chains/avoid-invalid-mir.stderr index 606f808f09369..eab2604d4c0c5 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/avoid-invalid-mir.stderr +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/avoid-invalid-mir.stderr @@ -6,5 +6,11 @@ LL | !let y = 42; | = note: only supported directly in conditions of `if` and `while` expressions +note: erroneous constant encountered + --> $DIR/avoid-invalid-mir.rs:11:13 + | +LL | x: [(); N] + | ^ + error: aborting due to 1 previous error diff --git a/tests/ui/self/arbitrary-self-from-method-substs-ice.stderr b/tests/ui/self/arbitrary-self-from-method-substs-ice.stderr index cf4c219215e08..e4991823d28a2 100644 --- a/tests/ui/self/arbitrary-self-from-method-substs-ice.stderr +++ b/tests/ui/self/arbitrary-self-from-method-substs-ice.stderr @@ -17,6 +17,12 @@ LL | const fn get>(self: R) -> u32 { LL | } | - value is dropped here +note: erroneous constant encountered + --> $DIR/arbitrary-self-from-method-substs-ice.rs:24:5 + | +LL | FOO; + | ^^^ + error[E0801]: invalid generic `self` parameter type: `R` --> $DIR/arbitrary-self-from-method-substs-ice.rs:10:49 | diff --git a/tests/ui/type/type-dependent-def-issue-49241.stderr b/tests/ui/type/type-dependent-def-issue-49241.stderr index cf372dc59681e..4e55618e5cb1f 100644 --- a/tests/ui/type/type-dependent-def-issue-49241.stderr +++ b/tests/ui/type/type-dependent-def-issue-49241.stderr @@ -9,6 +9,12 @@ help: consider using `let` instead of `const` LL | let l: usize = v.count(); | ~~~ +note: erroneous constant encountered + --> $DIR/type-dependent-def-issue-49241.rs:4:18 + | +LL | let s: [u32; l] = v.into_iter().collect(); + | ^ + error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0435`.