diff --git a/crates/hir-def/src/attr.rs b/crates/hir-def/src/attr.rs index 4dde093f968..9224773aa80 100644 --- a/crates/hir-def/src/attr.rs +++ b/crates/hir-def/src/attr.rs @@ -1,5 +1,7 @@ //! A higher level attributes based on TokenTree, with also some shortcuts. +pub mod builtin; + #[cfg(test)] mod tests; diff --git a/crates/hir-def/src/builtin_attr.rs b/crates/hir-def/src/attr/builtin.rs similarity index 100% rename from crates/hir-def/src/builtin_attr.rs rename to crates/hir-def/src/attr/builtin.rs diff --git a/crates/hir-def/src/lib.rs b/crates/hir-def/src/lib.rs index 407ef4b4a78..65c33322b1d 100644 --- a/crates/hir-def/src/lib.rs +++ b/crates/hir-def/src/lib.rs @@ -19,7 +19,6 @@ pub mod db; pub mod attr; pub mod path; pub mod builtin_type; -pub mod builtin_attr; pub mod per_ns; pub mod item_scope; diff --git a/crates/hir-def/src/nameres/attr_resolution.rs b/crates/hir-def/src/nameres/attr_resolution.rs index 9eb3eaa489e..6fad01ec2f7 100644 --- a/crates/hir-def/src/nameres/attr_resolution.rs +++ b/crates/hir-def/src/nameres/attr_resolution.rs @@ -4,7 +4,8 @@ use hir_expand::{attrs::Attr, MacroCallId}; use syntax::{ast, SmolStr}; use crate::{ - attr_macro_as_call_id, builtin_attr, + attr::builtin::{find_builtin_attr_idx, TOOL_MODULES}, + attr_macro_as_call_id, db::DefDatabase, item_scope::BuiltinShadowMode, macro_id_to_def_id, @@ -76,7 +77,7 @@ impl DefMap { let pred = |n: &_| *n == name; let registered = self.registered_tools.iter().map(SmolStr::as_str); - let is_tool = builtin_attr::TOOL_MODULES.iter().copied().chain(registered).any(pred); + let is_tool = TOOL_MODULES.iter().copied().chain(registered).any(pred); // FIXME: tool modules can be shadowed by actual modules if is_tool { return true; @@ -84,8 +85,7 @@ impl DefMap { if segments.len() == 1 { let mut registered = self.registered_attrs.iter().map(SmolStr::as_str); - let is_inert = - builtin_attr::find_builtin_attr_idx(&name).is_some() || registered.any(pred); + let is_inert = find_builtin_attr_idx(&name).is_some() || registered.any(pred); return is_inert; } } diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 05bcf12be5b..a355ea16422 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -109,8 +109,7 @@ pub use crate::{ pub use { cfg::{CfgAtom, CfgExpr, CfgOptions}, hir_def::{ - attr::{Attrs, AttrsWithOwner, Documentation}, - builtin_attr::AttributeTemplate, + attr::{builtin::AttributeTemplate, Attrs, AttrsWithOwner, Documentation}, data::adt::StructKind, find_path::PrefixKind, import_map, @@ -2697,7 +2696,7 @@ impl BuiltinAttr { } fn builtin(name: &str) -> Option { - hir_def::builtin_attr::find_builtin_attr_idx(name) + hir_def::attr::builtin::find_builtin_attr_idx(name) .map(|idx| BuiltinAttr { krate: None, idx: idx as u32 }) } @@ -2705,14 +2704,14 @@ impl BuiltinAttr { // FIXME: Return a `Name` here match self.krate { Some(krate) => db.crate_def_map(krate).registered_attrs()[self.idx as usize].clone(), - None => SmolStr::new(hir_def::builtin_attr::INERT_ATTRIBUTES[self.idx as usize].name), + None => SmolStr::new(hir_def::attr::builtin::INERT_ATTRIBUTES[self.idx as usize].name), } } pub fn template(&self, _: &dyn HirDatabase) -> Option { match self.krate { Some(_) => None, - None => Some(hir_def::builtin_attr::INERT_ATTRIBUTES[self.idx as usize].template), + None => Some(hir_def::attr::builtin::INERT_ATTRIBUTES[self.idx as usize].template), } } } @@ -2735,7 +2734,7 @@ impl ToolModule { } fn builtin(name: &str) -> Option { - hir_def::builtin_attr::TOOL_MODULES + hir_def::attr::builtin::TOOL_MODULES .iter() .position(|&tool| tool == name) .map(|idx| ToolModule { krate: None, idx: idx as u32 }) @@ -2745,7 +2744,7 @@ impl ToolModule { // FIXME: Return a `Name` here match self.krate { Some(krate) => db.crate_def_map(krate).registered_tools()[self.idx as usize].clone(), - None => SmolStr::new(hir_def::builtin_attr::TOOL_MODULES[self.idx as usize]), + None => SmolStr::new(hir_def::attr::builtin::TOOL_MODULES[self.idx as usize]), } } }