Rollup merge of #144226 - cjgillot:known-panics-panics, r=oli-obk

Do not assert layout in KnownPanicsLint.

Fixes rust-lang/rust#121176
Fixes rust-lang/rust#129109
Fixes rust-lang/rust#130970
Fixes rust-lang/rust#131347
Fixes rust-lang/rust#139872
Fixes rust-lang/rust#140332
This commit is contained in:
Matthias Krüger
2025-07-27 10:19:00 +02:00
committed by GitHub
31 changed files with 159 additions and 229 deletions

View File

@@ -767,7 +767,8 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(),
DefKind::Static { .. } => {
check_static_inhabited(tcx, def_id);
check_static_linkage(tcx, def_id);
res = res.and(wfcheck::check_static_item(tcx, def_id));
let ty = tcx.type_of(def_id).instantiate_identity();
res = res.and(wfcheck::check_static_item(tcx, def_id, ty, true));
}
DefKind::Const => res = res.and(wfcheck::check_const_item(tcx, def_id)),
_ => unreachable!(),

View File

@@ -1180,12 +1180,13 @@ fn check_item_fn(
}
#[instrument(level = "debug", skip(tcx))]
pub(super) fn check_static_item(
tcx: TyCtxt<'_>,
pub(crate) fn check_static_item<'tcx>(
tcx: TyCtxt<'tcx>,
item_id: LocalDefId,
ty: Ty<'tcx>,
should_check_for_sync: bool,
) -> Result<(), ErrorGuaranteed> {
enter_wf_checking_ctxt(tcx, item_id, |wfcx| {
let ty = tcx.type_of(item_id).instantiate_identity();
let span = tcx.ty_span(item_id);
let item_ty = wfcx.deeply_normalize(span, Some(WellFormedLoc::Ty(item_id)), ty);
@@ -1212,9 +1213,9 @@ pub(super) fn check_static_item(
}
// Ensure that the end result is `Sync` in a non-thread local `static`.
let should_check_for_sync = tcx.static_mutability(item_id.to_def_id())
== Some(hir::Mutability::Not)
let should_check_for_sync = should_check_for_sync
&& !is_foreign_item
&& tcx.static_mutability(item_id.to_def_id()) == Some(hir::Mutability::Not)
&& !tcx.is_thread_local_static(item_id.to_def_id());
if should_check_for_sync {