diff options
| author | bors <bors@rust-lang.org> | 2025-09-12 03:51:54 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-09-12 03:51:54 +0000 |
| commit | 8e2ed71effd5f81bff319c0c7adaca42084e2a71 (patch) | |
| tree | 9036671b06a3ec003c2c4ff0aebf39045fd33b5d /compiler/rustc_hir/src/def.rs | |
| parent | 2a9bacf6187685931d52346a0ecff2e52bdc91cc (diff) | |
| parent | 7e826fb14be36b4faf879c3aa1fe1a50b5750a5b (diff) | |
| download | rust-8e2ed71effd5f81bff319c0c7adaca42084e2a71.tar.gz rust-8e2ed71effd5f81bff319c0c7adaca42084e2a71.zip | |
Auto merge of #146328 - zetanumbers:fix-141951, r=lcnr
Skip typeck for items w/o their own typeck context Skip items which forward typeck to their ancestor. Should remove some potential but unnecessary typeck query waits, hence might improve performance for the parallel frontend. Thanks to `@ywxt` for a fix suggestion Fixes rust-lang/rust#141951
Diffstat (limited to 'compiler/rustc_hir/src/def.rs')
| -rw-r--r-- | compiler/rustc_hir/src/def.rs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/compiler/rustc_hir/src/def.rs b/compiler/rustc_hir/src/def.rs index 8af4740f376..95abe5c40dd 100644 --- a/compiler/rustc_hir/src/def.rs +++ b/compiler/rustc_hir/src/def.rs @@ -440,6 +440,43 @@ 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 { + match self { + DefKind::Closure | DefKind::InlineConst | DefKind::SyntheticCoroutineBody => true, + DefKind::Mod + | DefKind::Struct + | DefKind::Union + | DefKind::Enum + | DefKind::Variant + | DefKind::Trait + | DefKind::TyAlias + | DefKind::ForeignTy + | DefKind::TraitAlias + | DefKind::AssocTy + | DefKind::TyParam + | DefKind::Fn + | DefKind::Const + | DefKind::ConstParam + | DefKind::Static { .. } + | DefKind::Ctor(_, _) + | DefKind::AssocFn + | DefKind::AssocConst + | DefKind::Macro(_) + | DefKind::ExternCrate + | DefKind::Use + | DefKind::ForeignMod + | DefKind::AnonConst + | DefKind::OpaqueTy + | DefKind::Field + | DefKind::LifetimeParam + | DefKind::GlobalAsm + | DefKind::Impl { .. } => false, + } + } } /// The resolution of a path or export. |
