Skip to content

Commit 187ddf3

Browse files
authored
Unrolled build for #144534
Rollup merge of #144534 - RalfJung:should_check_for_sync, r=compiler-errors check_static_item: explain should_check_for_sync choices Follow-up to #144226. r? ``@oli-obk``
2 parents 2b5e239 + da1991d commit 187ddf3

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

compiler/rustc_hir_analysis/src/check/check.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,9 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Result<(),
768768
check_static_inhabited(tcx, def_id);
769769
check_static_linkage(tcx, def_id);
770770
let ty = tcx.type_of(def_id).instantiate_identity();
771-
res = res.and(wfcheck::check_static_item(tcx, def_id, ty, true));
771+
res = res.and(wfcheck::check_static_item(
772+
tcx, def_id, ty, /* should_check_for_sync */ true,
773+
));
772774
}
773775
DefKind::Const => res = res.and(wfcheck::check_const_item(tcx, def_id)),
774776
_ => unreachable!(),

compiler/rustc_hir_analysis/src/collect/type_of.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,9 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<'_
221221
let ty = icx.lower_ty(ty);
222222
// MIR relies on references to statics being scalars.
223223
// Verify that here to avoid ill-formed MIR.
224-
match check_static_item(tcx, def_id, ty, false) {
224+
// We skip the `Sync` check to avoid cycles for type-alias-impl-trait,
225+
// relying on the fact that non-Sync statics don't ICE the rest of the compiler.
226+
match check_static_item(tcx, def_id, ty, /* should_check_for_sync */ false) {
225227
Ok(()) => ty,
226228
Err(guar) => Ty::new_error(tcx, guar),
227229
}
@@ -286,7 +288,9 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<'_
286288
let ty = icx.lower_ty(ty);
287289
// MIR relies on references to statics being scalars.
288290
// Verify that here to avoid ill-formed MIR.
289-
match check_static_item(tcx, def_id, ty, false) {
291+
// We skip the `Sync` check to avoid cycles for type-alias-impl-trait,
292+
// relying on the fact that non-Sync statics don't ICE the rest of the compiler.
293+
match check_static_item(tcx, def_id, ty, /* should_check_for_sync */ false) {
290294
Ok(()) => ty,
291295
Err(guar) => Ty::new_error(tcx, guar),
292296
}

0 commit comments

Comments
 (0)