Skip to content

Commit 2af99ef

Browse files
Don't typeck during WF, instead check outside of WF in check_crate
1 parent c3e8ba3 commit 2af99ef

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

Diff for: compiler/rustc_hir_analysis/src/check/check.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -745,14 +745,10 @@ fn check_static_linkage(tcx: TyCtxt<'_>, def_id: LocalDefId) {
745745
pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) {
746746
match tcx.def_kind(def_id) {
747747
DefKind::Static { .. } => {
748-
tcx.ensure_ok().typeck(def_id);
749-
maybe_check_static_with_link_section(tcx, def_id);
750748
check_static_inhabited(tcx, def_id);
751749
check_static_linkage(tcx, def_id);
752750
}
753-
DefKind::Const => {
754-
tcx.ensure_ok().typeck(def_id);
755-
}
751+
DefKind::Const => {}
756752
DefKind::Enum => {
757753
check_enum(tcx, def_id);
758754
}
@@ -766,7 +762,6 @@ pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) {
766762
ExternAbi::Rust,
767763
)
768764
}
769-
// Everything else is checked entirely within check_item_body
770765
}
771766
DefKind::Impl { of_trait } => {
772767
if of_trait && let Some(impl_trait_header) = tcx.impl_trait_header(def_id) {

Diff for: compiler/rustc_hir_analysis/src/check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ pub fn forbid_intrinsic_abi(tcx: TyCtxt<'_>, sp: Span, abi: ExternAbi) {
145145
}
146146
}
147147

148-
fn maybe_check_static_with_link_section(tcx: TyCtxt<'_>, id: LocalDefId) {
148+
pub(super) fn maybe_check_static_with_link_section(tcx: TyCtxt<'_>, id: LocalDefId) {
149149
// Only restricted on wasm target for now
150150
if !tcx.sess.target.is_like_wasm {
151151
return;

Diff for: compiler/rustc_hir_analysis/src/lib.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,10 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
212212
tcx.par_hir_body_owners(|item_def_id| {
213213
let def_kind = tcx.def_kind(item_def_id);
214214
match def_kind {
215-
DefKind::Static { .. } => tcx.ensure_ok().eval_static_initializer(item_def_id),
215+
DefKind::Static { .. } => {
216+
tcx.ensure_ok().eval_static_initializer(item_def_id);
217+
check::maybe_check_static_with_link_section(tcx, item_def_id);
218+
}
216219
DefKind::Const if tcx.generics_of(item_def_id).is_empty() => {
217220
let instance = ty::Instance::new(item_def_id.into(), ty::GenericArgs::empty());
218221
let cid = GlobalId { instance, promoted: None };
@@ -223,12 +226,9 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
223226
}
224227
});
225228

226-
// FIXME: Remove this when we implement creating `DefId`s
227-
// for anon constants during their parents' typeck.
228-
// Typeck all body owners in parallel will produce queries
229-
// cycle errors because it may typeck on anon constants directly.
230229
tcx.par_hir_body_owners(|item_def_id| {
231230
let def_kind = tcx.def_kind(item_def_id);
231+
// Skip `AnonConst`s because we feed their `type_of`.
232232
if !matches!(def_kind, DefKind::AnonConst) {
233233
tcx.ensure_ok().typeck(item_def_id);
234234
}

0 commit comments

Comments
 (0)