Rollup merge of #123675 - oli-obk:static_wf_ice, r=compiler-errors

Taint const qualifs if a static is referenced that didn't pass wfcheck

It is correct to only check the signature here, as the ICE is caused by `USE_WITH_ERROR` trying to allocate memory to store the result of `WITH_ERROR` before evaluating it.

fixes #123153
This commit is contained in:
Guillaume Gomez 2024-04-17 00:00:22 +02:00 committed by GitHub
commit 4885ddfa92
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 63 additions and 17 deletions

View file

@ -331,6 +331,11 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
if self.tcx.is_thread_local_static(def_id) {
self.tcx.dcx().span_bug(span, "tls access is checked in `Rvalue::ThreadLocalRef`");
}
if let Some(def_id) = def_id.as_local()
&& let Err(guar) = self.tcx.at(span).check_well_formed(hir::OwnerId { def_id })
{
self.error_emitted = Some(guar);
}
self.check_op_spanned(ops::StaticAccess, span)
}