Skip to content

Commit fd91dfb

Browse files
committed
cleanup leftovers of const_err lint
1 parent deb708a commit fd91dfb

File tree

5 files changed

+16
-31
lines changed

5 files changed

+16
-31
lines changed

compiler/rustc_const_eval/src/const_eval/error.rs

+3-22
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use rustc_errors::{DiagnosticArgValue, DiagnosticMessage, IntoDiagnostic, IntoDi
44
use rustc_middle::mir::AssertKind;
55
use rustc_middle::ty::TyCtxt;
66
use rustc_middle::ty::{layout::LayoutError, ConstInt};
7-
use rustc_span::source_map::Spanned;
87
use rustc_span::{ErrorGuaranteed, Span, Symbol};
98

109
use super::InterpCx;
@@ -132,35 +131,17 @@ where
132131
{
133132
// Special handling for certain errors
134133
match error {
135-
// Don't emit a new diagnostic for these errors
134+
// Don't emit a new diagnostic for these errors, they are already reported elsewhere or
135+
// should remain silent.
136136
err_inval!(Layout(LayoutError::Unknown(_))) | err_inval!(TooGeneric) => {
137137
ErrorHandled::TooGeneric
138138
}
139139
err_inval!(AlreadyReported(guar)) => ErrorHandled::Reported(guar),
140140
err_inval!(Layout(LayoutError::ReferencesError(guar))) => {
141141
ErrorHandled::Reported(guar.into())
142142
}
143-
err_inval!(Layout(layout_error @ LayoutError::SizeOverflow(_))) => {
144-
// We must *always* hard error on these, even if the caller wants just a lint.
145-
// The `message` makes little sense here, this is a more serious error than the
146-
// caller thinks anyway.
147-
// See <https://github.com/rust-lang/rust/pull/63152>.
148-
let (our_span, frames) = get_span_and_frames();
149-
let span = span.unwrap_or(our_span);
150-
let mut err =
151-
tcx.sess.create_err(Spanned { span, node: layout_error.into_diagnostic() });
152-
err.code(rustc_errors::error_code!(E0080));
153-
let Some((mut err, handler)) = err.into_diagnostic() else {
154-
panic!("did not emit diag");
155-
};
156-
for frame in frames {
157-
err.eager_subdiagnostic(handler, frame);
158-
}
159-
160-
ErrorHandled::Reported(handler.emit_diagnostic(&mut err).unwrap().into())
161-
}
143+
// Report remaining errors.
162144
_ => {
163-
// Report as hard error.
164145
let (our_span, frames) = get_span_and_frames();
165146
let span = span.unwrap_or(our_span);
166147
let err = mk(span, frames);

compiler/rustc_const_eval/src/const_eval/eval_queries.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ pub fn eval_to_allocation_raw_provider<'tcx>(
372372
};
373373
let alloc_id = mplace.ptr().provenance.unwrap();
374374

375-
// Validation failed, report an error. This is always a hard error.
375+
// Validation failed, report an error.
376376
if let Err(error) = validation {
377377
let (error, backtrace) = error.into_parts();
378378
backtrace.print_backtrace();

tests/ui/limits/issue-55878.stderr

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
error[E0080]: values of the type `[u8; usize::MAX]` are too big for the current architecture
1+
error[E0080]: evaluation of constant value failed
22
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
33
|
4+
= note: values of the type `[u8; usize::MAX]` are too big for the current architecture
5+
|
46
note: inside `std::mem::size_of::<[u8; usize::MAX]>`
57
--> $SRC_DIR/core/src/mem/mod.rs:LL:COL
68
note: inside `main`

tests/ui/limits/issue-56762.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ impl TooBigArray {
1414
}
1515

1616
static MY_TOO_BIG_ARRAY_1: TooBigArray = TooBigArray::new();
17-
//~^ ERROR values of the type `[u8; 2305843009213693951]` are too big
17+
//~^ ERROR could not evaluate static initializer
18+
//~| too big
1819
static MY_TOO_BIG_ARRAY_2: [u8; HUGE_SIZE] = [0x00; HUGE_SIZE];
19-
//~^ ERROR values of the type `[u8; 2305843009213693951]` are too big
20+
//~^ ERROR could not evaluate static initializer
21+
//~| too big
2022

2123
fn main() { }

tests/ui/limits/issue-56762.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
error[E0080]: values of the type `[u8; 2305843009213693951]` are too big for the current architecture
1+
error[E0080]: could not evaluate static initializer
22
--> $DIR/issue-56762.rs:16:1
33
|
44
LL | static MY_TOO_BIG_ARRAY_1: TooBigArray = TooBigArray::new();
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ values of the type `[u8; 2305843009213693951]` are too big for the current architecture
66

7-
error[E0080]: values of the type `[u8; 2305843009213693951]` are too big for the current architecture
8-
--> $DIR/issue-56762.rs:18:1
7+
error[E0080]: could not evaluate static initializer
8+
--> $DIR/issue-56762.rs:19:1
99
|
1010
LL | static MY_TOO_BIG_ARRAY_2: [u8; HUGE_SIZE] = [0x00; HUGE_SIZE];
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
11+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ values of the type `[u8; 2305843009213693951]` are too big for the current architecture
1212

1313
error: aborting due to 2 previous errors
1414

0 commit comments

Comments
 (0)