Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-def/src/lang_item.rs')
| -rw-r--r-- | crates/hir-def/src/lang_item.rs | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/crates/hir-def/src/lang_item.rs b/crates/hir-def/src/lang_item.rs index 4d17650285..07b27659ab 100644 --- a/crates/hir-def/src/lang_item.rs +++ b/crates/hir-def/src/lang_item.rs @@ -192,8 +192,7 @@ impl LangItems { } pub(crate) fn lang_attr(db: &dyn DefDatabase, item: AttrDefId) -> Option<LangItem> { - let attrs = db.attrs(item); - attrs.by_key("lang").string_value().and_then(LangItem::from_str) + db.attrs(item).lang_item() } pub(crate) fn notable_traits_in_deps( @@ -261,18 +260,9 @@ macro_rules! language_item_table { } /// Opposite of [`LangItem::name`] - #[allow(clippy::should_implement_trait)] - pub fn from_str(name: &str) -> Option<Self> { - match name { - $( stringify!($name) => Some(LangItem::$variant), )* - _ => None, - } - } - - /// Opposite of [`LangItem::name`] - pub fn from_symbol(sym: Symbol) -> Option<Self> { + pub fn from_symbol(sym: &Symbol) -> Option<Self> { match sym { - $(sym if sym == $module::$name => Some(LangItem::$variant), )* + $(sym if *sym == $module::$name => Some(LangItem::$variant), )* _ => None, } } @@ -283,7 +273,7 @@ macro_rules! language_item_table { impl LangItem { /// Opposite of [`LangItem::name`] pub fn from_name(name: &hir_expand::name::Name) -> Option<Self> { - Self::from_str(name.as_str()) + Self::from_symbol(name.symbol()) } pub fn path(&self, db: &dyn DefDatabase, start_crate: CrateId) -> Option<Path> { |