Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions compiler/rustc_hir/src/def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,13 @@ impl DefKind {
| DefKind::ExternCrate => false,
}
}

/// Returns `true` if `self` is a kind of definition that does not have its own
/// type-checking context, i.e. closure, coroutine or inline const.
#[inline]
pub fn is_typeck_child(self) -> bool {
matches!(self, DefKind::Closure | DefKind::InlineConst | DefKind::SyntheticCoroutineBody)
}
}

/// The resolution of a path or export.
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_hir_analysis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@ pub fn check_crate(tcx: TyCtxt<'_>) {
_ => (),
}
// Skip `AnonConst`s because we feed their `type_of`.
if !matches!(def_kind, DefKind::AnonConst) {
// Also skip items for which typeck forwards to parent typeck.
if !(matches!(def_kind, DefKind::AnonConst) || def_kind.is_typeck_child()) {
tcx.ensure_ok().typeck(item_def_id);
}
// Ensure we generate the new `DefId` before finishing `check_crate`.
Expand Down
5 changes: 1 addition & 4 deletions compiler/rustc_middle/src/ty/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -609,10 +609,7 @@ impl<'tcx> TyCtxt<'tcx> {
/// Returns `true` if `def_id` refers to a definition that does not have its own
/// type-checking context, i.e. closure, coroutine or inline const.
pub fn is_typeck_child(self, def_id: DefId) -> bool {
matches!(
self.def_kind(def_id),
DefKind::Closure | DefKind::InlineConst | DefKind::SyntheticCoroutineBody
)
self.def_kind(def_id).is_typeck_child()
}

/// Returns `true` if `def_id` refers to a trait (i.e., `trait Foo { ... }`).
Expand Down
Loading