Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir/src/attrs.rs')
-rw-r--r--crates/hir/src/attrs.rs19
1 files changed, 18 insertions, 1 deletions
diff --git a/crates/hir/src/attrs.rs b/crates/hir/src/attrs.rs
index 27e7985146..223103b6e5 100644
--- a/crates/hir/src/attrs.rs
+++ b/crates/hir/src/attrs.rs
@@ -38,7 +38,11 @@ pub enum AttrsOwner {
Field(FieldId),
LifetimeParam(LifetimeParamId),
TypeOrConstParam(TypeOrConstParamId),
- /// Things that do not have attributes. Used for builtin derives.
+ /// Things that do not have attributes.
+ ///
+ /// Used for:
+ /// - builtin derives
+ /// - builtin types (as those do not have attributes)
Dummy,
}
@@ -85,6 +89,19 @@ impl AttrsWithOwner {
self.attrs.contains(AttrFlags::IS_UNSTABLE)
}
+ /// Currently, it could be that `is_unstable() == true` but `unstable_feature == None`
+ /// (due to unstable features not being retrieved for fields etc.).
+ #[inline]
+ pub fn unstable_feature(&self, db: &dyn HirDatabase) -> Option<Symbol> {
+ match self.owner {
+ AttrsOwner::AttrDef(owner) => self.attrs.unstable_feature(db, owner),
+ AttrsOwner::Field(_)
+ | AttrsOwner::LifetimeParam(_)
+ | AttrsOwner::TypeOrConstParam(_)
+ | AttrsOwner::Dummy => None,
+ }
+ }
+
#[inline]
pub fn is_macro_export(&self) -> bool {
self.attrs.contains(AttrFlags::IS_MACRO_EXPORT)