remove some hacks from nameresolution for macros

This commit is contained in:
Aleksey Kladov 2019-06-08 20:42:02 +03:00
parent 780e1a365b
commit caefa6982b
7 changed files with 68 additions and 66 deletions

View file

@ -2,11 +2,11 @@
use std::sync::Arc;
use rustc_hash::{FxHashMap, FxHashSet};
use either::Either;
use crate::{
ModuleDef, Trait,
ModuleDef, Trait, MacroDef,
code_model::Crate,
MacroDefId,
db::HirDatabase,
name::{Name, KnownName},
nameres::{PerNs, CrateDefMap, CrateModuleId},
@ -130,13 +130,16 @@ impl Resolver {
resolution
}
pub(crate) fn resolve_macro_call(
pub(crate) fn resolve_path_as_macro(
&self,
db: &impl HirDatabase,
path: Option<Path>,
) -> Option<MacroDefId> {
let m = self.module()?;
m.0.find_macro(db, m.1, &path?)
path: &Path,
) -> Option<MacroDef> {
let (item_map, module) = self.module()?;
match item_map.resolve_path_with_macro(db, module, path) {
(Either::Right(macro_def), None) => Some(macro_def),
_ => None,
}
}
/// Returns the resolved path segments