Auto merge of #121087 - oli-obk:eager_const_failures, r=lcnr
Always evaluate free constants and statics, even if previous errors occurred work towards https://github.com/rust-lang/rust/issues/79738 We will need to evaluate static items before the `definitions.freeze()` below, as we will start creating new `DefId`s (for nested allocations) within the `eval_static_initializer` query. But even without that motivation, this is a good change. Hard errors should always be reported and not silenced if other errors happened earlier.
This commit is contained in:
commit
cce6a6e22e
69 changed files with 650 additions and 519 deletions
|
@ -198,6 +198,17 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
|
|||
collect::test_opaque_hidden_types(tcx)?;
|
||||
}
|
||||
|
||||
// Make sure we evaluate all static and (non-associated) const items, even if unused.
|
||||
// If any of these fail to evaluate, we do not want this crate to pass compilation.
|
||||
tcx.hir().par_body_owners(|item_def_id| {
|
||||
let def_kind = tcx.def_kind(item_def_id);
|
||||
match def_kind {
|
||||
DefKind::Static(_) => tcx.ensure().eval_static_initializer(item_def_id),
|
||||
DefKind::Const => tcx.ensure().const_eval_poly(item_def_id.into()),
|
||||
_ => (),
|
||||
}
|
||||
});
|
||||
|
||||
// Freeze definitions as we don't add new ones at this point. This improves performance by
|
||||
// allowing lock-free access to them.
|
||||
tcx.untracked().definitions.freeze();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue