Skip to content

Commit 3f5c992

Browse files
committed
Move hir_def::builtin_attr to hir_def::attr::builtin
1 parent 12b069f commit 3f5c992

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

crates/hir-def/src/attr.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! A higher level attributes based on TokenTree, with also some shortcuts.
22
3+
pub mod builtin;
4+
35
#[cfg(test)]
46
mod tests;
57

crates/hir-def/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ pub mod db;
1919
pub mod attr;
2020
pub mod path;
2121
pub mod builtin_type;
22-
pub mod builtin_attr;
2322
pub mod per_ns;
2423
pub mod item_scope;
2524

crates/hir-def/src/nameres/attr_resolution.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ use hir_expand::{attrs::Attr, MacroCallId};
44
use syntax::{ast, SmolStr};
55

66
use crate::{
7-
attr_macro_as_call_id, builtin_attr,
7+
attr::builtin::{find_builtin_attr_idx, TOOL_MODULES},
8+
attr_macro_as_call_id,
89
db::DefDatabase,
910
item_scope::BuiltinShadowMode,
1011
macro_id_to_def_id,
@@ -76,16 +77,15 @@ impl DefMap {
7677
let pred = |n: &_| *n == name;
7778

7879
let registered = self.registered_tools.iter().map(SmolStr::as_str);
79-
let is_tool = builtin_attr::TOOL_MODULES.iter().copied().chain(registered).any(pred);
80+
let is_tool = TOOL_MODULES.iter().copied().chain(registered).any(pred);
8081
// FIXME: tool modules can be shadowed by actual modules
8182
if is_tool {
8283
return true;
8384
}
8485

8586
if segments.len() == 1 {
8687
let mut registered = self.registered_attrs.iter().map(SmolStr::as_str);
87-
let is_inert =
88-
builtin_attr::find_builtin_attr_idx(&name).is_some() || registered.any(pred);
88+
let is_inert = find_builtin_attr_idx(&name).is_some() || registered.any(pred);
8989
return is_inert;
9090
}
9191
}

crates/hir/src/lib.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ pub use crate::{
109109
pub use {
110110
cfg::{CfgAtom, CfgExpr, CfgOptions},
111111
hir_def::{
112-
attr::{Attrs, AttrsWithOwner, Documentation},
113-
builtin_attr::AttributeTemplate,
112+
attr::{builtin::AttributeTemplate, Attrs, AttrsWithOwner, Documentation},
114113
data::adt::StructKind,
115114
find_path::PrefixKind,
116115
import_map,
@@ -2697,22 +2696,22 @@ impl BuiltinAttr {
26972696
}
26982697

26992698
fn builtin(name: &str) -> Option<Self> {
2700-
hir_def::builtin_attr::find_builtin_attr_idx(name)
2699+
hir_def::attr::builtin::find_builtin_attr_idx(name)
27012700
.map(|idx| BuiltinAttr { krate: None, idx: idx as u32 })
27022701
}
27032702

27042703
pub fn name(&self, db: &dyn HirDatabase) -> SmolStr {
27052704
// FIXME: Return a `Name` here
27062705
match self.krate {
27072706
Some(krate) => db.crate_def_map(krate).registered_attrs()[self.idx as usize].clone(),
2708-
None => SmolStr::new(hir_def::builtin_attr::INERT_ATTRIBUTES[self.idx as usize].name),
2707+
None => SmolStr::new(hir_def::attr::builtin::INERT_ATTRIBUTES[self.idx as usize].name),
27092708
}
27102709
}
27112710

27122711
pub fn template(&self, _: &dyn HirDatabase) -> Option<AttributeTemplate> {
27132712
match self.krate {
27142713
Some(_) => None,
2715-
None => Some(hir_def::builtin_attr::INERT_ATTRIBUTES[self.idx as usize].template),
2714+
None => Some(hir_def::attr::builtin::INERT_ATTRIBUTES[self.idx as usize].template),
27162715
}
27172716
}
27182717
}
@@ -2735,7 +2734,7 @@ impl ToolModule {
27352734
}
27362735

27372736
fn builtin(name: &str) -> Option<Self> {
2738-
hir_def::builtin_attr::TOOL_MODULES
2737+
hir_def::attr::builtin::TOOL_MODULES
27392738
.iter()
27402739
.position(|&tool| tool == name)
27412740
.map(|idx| ToolModule { krate: None, idx: idx as u32 })
@@ -2745,7 +2744,7 @@ impl ToolModule {
27452744
// FIXME: Return a `Name` here
27462745
match self.krate {
27472746
Some(krate) => db.crate_def_map(krate).registered_tools()[self.idx as usize].clone(),
2748-
None => SmolStr::new(hir_def::builtin_attr::TOOL_MODULES[self.idx as usize]),
2747+
None => SmolStr::new(hir_def::attr::builtin::TOOL_MODULES[self.idx as usize]),
27492748
}
27502749
}
27512750
}

0 commit comments

Comments
 (0)