mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
Cleanup
This commit is contained in:
parent
326f066aa2
commit
99af523b68
7 changed files with 15 additions and 20 deletions
|
@ -1037,7 +1037,7 @@ impl From<PerNs> for ScopeDef {
|
|||
.or_else(|| def.take_values())
|
||||
.map(|module_def_id| ScopeDef::ModuleDef(module_def_id.into()))
|
||||
.or_else(|| {
|
||||
def.get_macros().map(|macro_def_id| ScopeDef::MacroDef(macro_def_id.into()))
|
||||
def.take_macros().map(|macro_def_id| ScopeDef::MacroDef(macro_def_id.into()))
|
||||
})
|
||||
.unwrap_or(ScopeDef::Unknown)
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ impl Expander {
|
|||
}
|
||||
|
||||
fn resolve_path_as_macro(&self, db: &impl DefDatabase, path: &Path) -> Option<MacroDefId> {
|
||||
self.crate_def_map.resolve_path(db, self.module.module_id, path).0.get_macros()
|
||||
self.crate_def_map.resolve_path(db, self.module.module_id, path).0.take_macros()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,20 +8,23 @@
|
|||
//! actually true.
|
||||
|
||||
pub mod db;
|
||||
|
||||
pub mod attr;
|
||||
pub mod path;
|
||||
pub mod type_ref;
|
||||
pub mod builtin_type;
|
||||
pub mod adt;
|
||||
pub mod diagnostics;
|
||||
pub mod expr;
|
||||
pub mod body;
|
||||
pub mod generics;
|
||||
pub mod resolver;
|
||||
pub mod per_ns;
|
||||
|
||||
pub mod adt;
|
||||
pub mod data;
|
||||
pub mod generics;
|
||||
pub mod lang_item;
|
||||
pub mod docs;
|
||||
pub mod per_ns;
|
||||
|
||||
pub mod expr;
|
||||
pub mod body;
|
||||
pub mod resolver;
|
||||
|
||||
mod trace;
|
||||
mod nameres;
|
||||
|
|
|
@ -169,7 +169,7 @@ impl ModuleScope {
|
|||
pub fn macros<'a>(&'a self) -> impl Iterator<Item = (&'a Name, MacroDefId)> + 'a {
|
||||
self.items
|
||||
.iter()
|
||||
.filter_map(|(name, res)| res.def.get_macros().map(|macro_| (name, macro_)))
|
||||
.filter_map(|(name, res)| res.def.take_macros().map(|macro_| (name, macro_)))
|
||||
}
|
||||
|
||||
/// Iterate over all legacy textual scoped macros visable at the end of the module
|
||||
|
|
|
@ -476,7 +476,7 @@ where
|
|||
path,
|
||||
);
|
||||
|
||||
if let Some(def) = resolved_res.resolved_def.get_macros() {
|
||||
if let Some(def) = resolved_res.resolved_def.take_macros() {
|
||||
let call_id = self.db.intern_macro(MacroCallLoc { def, ast_id: *ast_id });
|
||||
resolved.push((*module_id, call_id, def));
|
||||
res = ReachedFixedPoint::No;
|
||||
|
|
|
@ -44,10 +44,6 @@ impl PerNs {
|
|||
self.types.is_none() && self.values.is_none() && self.macros.is_none()
|
||||
}
|
||||
|
||||
pub fn is_all(&self) -> bool {
|
||||
self.types.is_some() && self.values.is_some() && self.macros.is_some()
|
||||
}
|
||||
|
||||
pub fn take_types(self) -> Option<ModuleDefId> {
|
||||
self.types
|
||||
}
|
||||
|
@ -56,14 +52,10 @@ impl PerNs {
|
|||
self.values
|
||||
}
|
||||
|
||||
pub fn get_macros(&self) -> Option<MacroDefId> {
|
||||
pub fn take_macros(self) -> Option<MacroDefId> {
|
||||
self.macros
|
||||
}
|
||||
|
||||
pub fn only_macros(&self) -> PerNs {
|
||||
PerNs { types: None, values: None, macros: self.macros }
|
||||
}
|
||||
|
||||
pub fn or(self, other: PerNs) -> PerNs {
|
||||
PerNs {
|
||||
types: self.types.or(other.types),
|
||||
|
|
|
@ -308,7 +308,7 @@ impl Resolver {
|
|||
|
||||
pub fn resolve_path_as_macro(&self, db: &impl DefDatabase, path: &Path) -> Option<MacroDefId> {
|
||||
let (item_map, module) = self.module()?;
|
||||
item_map.resolve_path(db, module, path).0.get_macros()
|
||||
item_map.resolve_path(db, module, path).0.take_macros()
|
||||
}
|
||||
|
||||
pub fn process_all_names(&self, db: &impl DefDatabase, f: &mut dyn FnMut(Name, ScopeDef)) {
|
||||
|
|
Loading…
Reference in a new issue