Skip to content

Commit e9dc753

Browse files
committed
Auto merge of #115748 - RalfJung:post-mono, r=oli-obk
move required_consts check to general post-mono-check function This factors some code that is common between the interpreter and the codegen backends into shared helper functions. Also as a side-effect the interpreter now uses the same `eval` functions as everyone else to get the evaluated MIR constants. Also this is in preparation for another post-mono check that will be needed for (the current hackfix for) rust-lang/rust#115709: ensuring that all locals are dynamically sized. I didn't expect this to change diagnostics, but it's just cycle errors that change. r? `@oli-obk`
2 parents 66aa7f7 + 3226e4b commit e9dc753

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

clippy_lints/src/non_copy_const.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ fn is_value_unfrozen_raw<'tcx>(
204204
// similar to 2., but with the a frozen variant) (e.g. borrowing
205205
// `borrow_interior_mutable_const::enums::AssocConsts::TO_BE_FROZEN_VARIANT`).
206206
// I chose this way because unfrozen enums as assoc consts are rare (or, hopefully, none).
207-
err == ErrorHandled::TooGeneric
207+
matches!(err, ErrorHandled::TooGeneric(..))
208208
},
209209
|val| val.map_or(true, |val| inner(cx, val, ty)),
210210
)
@@ -244,8 +244,8 @@ pub fn const_eval_resolve<'tcx>(
244244
};
245245
tcx.const_eval_global_id_for_typeck(param_env, cid, span)
246246
},
247-
Ok(None) => Err(ErrorHandled::TooGeneric),
248-
Err(err) => Err(ErrorHandled::Reported(err.into())),
247+
Ok(None) => Err(ErrorHandled::TooGeneric(span.unwrap_or(rustc_span::DUMMY_SP))),
248+
Err(err) => Err(ErrorHandled::Reported(err.into(), span.unwrap_or(rustc_span::DUMMY_SP))),
249249
}
250250
}
251251

tests/ui-toml/suppress_lint_in_const/test.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ error[E0080]: evaluation of `main::{constant#3}` failed
44
LL | const { &ARR[idx4()] }; // Ok, should not produce stderr, since `suppress-restriction-lint-in-const` is set true.
55
| ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4
66

7-
note: erroneous constant used
7+
note: erroneous constant encountered
88
--> $DIR/test.rs:37:5
99
|
1010
LL | const { &ARR[idx4()] }; // Ok, should not produce stderr, since `suppress-restriction-lint-in-const` is set true.

tests/ui/indexing_slicing_index.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ error[E0080]: evaluation of `main::{constant#3}` failed
2424
LL | const { &ARR[idx4()] };
2525
| ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4
2626

27-
note: erroneous constant used
27+
note: erroneous constant encountered
2828
--> $DIR/indexing_slicing_index.rs:48:5
2929
|
3030
LL | const { &ARR[idx4()] };

0 commit comments

Comments
 (0)