diff options
| author | bors <bors@rust-lang.org> | 2025-08-10 05:44:53 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-08-10 05:44:53 +0000 |
| commit | 8712e4567551a2714efa66dac204ec7137bc5605 (patch) | |
| tree | 6c5ca51afb3504cdcfa75e7fc3bfb14da0d7f176 /compiler/rustc_hir/src/def.rs | |
| parent | 915a766b2f9fd53a8cd7b1fad003d3f8e488ff4b (diff) | |
| parent | d5f2260bd37966b76ef6ee9c22d0cdebdcbe97a9 (diff) | |
| download | rust-8712e4567551a2714efa66dac204ec7137bc5605.tar.gz rust-8712e4567551a2714efa66dac204ec7137bc5605.zip | |
Auto merge of #144873 - cjgillot:implications, r=lqd
Implement `stability_implications` without a visitor. Since https://github.com/rust-lang/rust/pull/143845, the `Annotator` visitor was a no-op when the crate is not staged_api. This PR avoids using a visitor altogether, making `stability_implications` truly a no-op in most cases.
Diffstat (limited to 'compiler/rustc_hir/src/def.rs')
| -rw-r--r-- | compiler/rustc_hir/src/def.rs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/compiler/rustc_hir/src/def.rs b/compiler/rustc_hir/src/def.rs index 2201d493f2d..339d4e2eab7 100644 --- a/compiler/rustc_hir/src/def.rs +++ b/compiler/rustc_hir/src/def.rs @@ -306,6 +306,11 @@ impl DefKind { } #[inline] + pub fn is_adt(self) -> bool { + matches!(self, DefKind::Struct | DefKind::Union | DefKind::Enum) + } + + #[inline] pub fn is_fn_like(self) -> bool { matches!( self, @@ -313,6 +318,43 @@ impl DefKind { ) } + /// Whether the corresponding item has generic parameters, ie. the `generics_of` query works. + pub fn has_generics(self) -> bool { + match self { + DefKind::AnonConst + | DefKind::AssocConst + | DefKind::AssocFn + | DefKind::AssocTy + | DefKind::Closure + | DefKind::Const + | DefKind::Ctor(..) + | DefKind::Enum + | DefKind::Field + | DefKind::Fn + | DefKind::ForeignTy + | DefKind::Impl { .. } + | DefKind::InlineConst + | DefKind::OpaqueTy + | DefKind::Static { .. } + | DefKind::Struct + | DefKind::SyntheticCoroutineBody + | DefKind::Trait + | DefKind::TraitAlias + | DefKind::TyAlias + | DefKind::Union + | DefKind::Variant => true, + DefKind::ConstParam + | DefKind::ExternCrate + | DefKind::ForeignMod + | DefKind::GlobalAsm + | DefKind::LifetimeParam + | DefKind::Macro(_) + | DefKind::Mod + | DefKind::TyParam + | DefKind::Use => false, + } + } + /// Whether `query get_codegen_attrs` should be used with this definition. pub fn has_codegen_attrs(self) -> bool { match self { |
