mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-14 06:03:58 +00:00
Remove import from resolution
This commit is contained in:
parent
6d8a2ec3dd
commit
ec56f59ac1
2 changed files with 12 additions and 17 deletions
|
@ -30,7 +30,7 @@ static BUILTIN_SCOPE: Lazy<FxHashMap<Name, Resolution>> = Lazy::new(|| {
|
||||||
BuiltinType::ALL
|
BuiltinType::ALL
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(name, ty)| {
|
.map(|(name, ty)| {
|
||||||
(name.clone(), Resolution { def: PerNs::types(ty.clone().into()), import: None })
|
(name.clone(), Resolution { def: PerNs::types(ty.clone().into()), import: false })
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
});
|
});
|
||||||
|
@ -54,7 +54,7 @@ impl ItemScope {
|
||||||
|
|
||||||
pub fn declarations(&self) -> impl Iterator<Item = ModuleDefId> + '_ {
|
pub fn declarations(&self) -> impl Iterator<Item = ModuleDefId> + '_ {
|
||||||
self.entries()
|
self.entries()
|
||||||
.filter_map(|(_name, res)| if res.import.is_none() { Some(res.def) } else { None })
|
.filter_map(|(_name, res)| if !res.import { Some(res.def) } else { None })
|
||||||
.flat_map(|per_ns| {
|
.flat_map(|per_ns| {
|
||||||
per_ns.take_types().into_iter().chain(per_ns.take_values().into_iter())
|
per_ns.take_types().into_iter().chain(per_ns.take_values().into_iter())
|
||||||
})
|
})
|
||||||
|
@ -123,25 +123,21 @@ impl ItemScope {
|
||||||
|
|
||||||
if existing.def.types.is_none() && res.def.types.is_some() {
|
if existing.def.types.is_none() && res.def.types.is_some() {
|
||||||
existing.def.types = res.def.types;
|
existing.def.types = res.def.types;
|
||||||
existing.import = import.or(res.import);
|
existing.import = import.is_some() || res.import;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
if existing.def.values.is_none() && res.def.values.is_some() {
|
if existing.def.values.is_none() && res.def.values.is_some() {
|
||||||
existing.def.values = res.def.values;
|
existing.def.values = res.def.values;
|
||||||
existing.import = import.or(res.import);
|
existing.import = import.is_some() || res.import;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
if existing.def.macros.is_none() && res.def.macros.is_some() {
|
if existing.def.macros.is_none() && res.def.macros.is_some() {
|
||||||
existing.def.macros = res.def.macros;
|
existing.def.macros = res.def.macros;
|
||||||
existing.import = import.or(res.import);
|
existing.import = import.is_some() || res.import;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if existing.def.is_none()
|
if existing.def.is_none() && res.def.is_none() && !existing.import && res.import {
|
||||||
&& res.def.is_none()
|
|
||||||
&& existing.import.is_none()
|
|
||||||
&& res.import.is_some()
|
|
||||||
{
|
|
||||||
existing.import = res.import;
|
existing.import = res.import;
|
||||||
}
|
}
|
||||||
changed
|
changed
|
||||||
|
@ -160,6 +156,5 @@ impl ItemScope {
|
||||||
pub struct Resolution {
|
pub struct Resolution {
|
||||||
/// None for unresolved
|
/// None for unresolved
|
||||||
pub def: PerNs,
|
pub def: PerNs,
|
||||||
/// ident by which this is imported into local scope.
|
pub(crate) import: bool,
|
||||||
pub(crate) import: Option<LocalImportId>,
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,7 +219,7 @@ where
|
||||||
self.update(
|
self.update(
|
||||||
self.def_map.root,
|
self.def_map.root,
|
||||||
None,
|
None,
|
||||||
&[(name, Resolution { def: PerNs::macros(macro_), import: None })],
|
&[(name, Resolution { def: PerNs::macros(macro_), import: false })],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -404,7 +404,7 @@ where
|
||||||
let variant = EnumVariantId { parent: e, local_id };
|
let variant = EnumVariantId { parent: e, local_id };
|
||||||
let res = Resolution {
|
let res = Resolution {
|
||||||
def: PerNs::both(variant.into(), variant.into()),
|
def: PerNs::both(variant.into(), variant.into()),
|
||||||
import: Some(import_id),
|
import: true,
|
||||||
};
|
};
|
||||||
(name, res)
|
(name, res)
|
||||||
})
|
})
|
||||||
|
@ -431,7 +431,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let resolution = Resolution { def, import: Some(import_id) };
|
let resolution = Resolution { def, import: true };
|
||||||
self.update(module_id, Some(import_id), &[(name, resolution)]);
|
self.update(module_id, Some(import_id), &[(name, resolution)]);
|
||||||
}
|
}
|
||||||
None => tested_by!(bogus_paths),
|
None => tested_by!(bogus_paths),
|
||||||
|
@ -719,7 +719,7 @@ where
|
||||||
def: PerNs::types(
|
def: PerNs::types(
|
||||||
ModuleId { krate: self.def_collector.def_map.krate, local_id: res }.into(),
|
ModuleId { krate: self.def_collector.def_map.krate, local_id: res }.into(),
|
||||||
),
|
),
|
||||||
import: None,
|
import: false,
|
||||||
};
|
};
|
||||||
self.def_collector.update(self.module_id, None, &[(name, resolution)]);
|
self.def_collector.update(self.module_id, None, &[(name, resolution)]);
|
||||||
res
|
res
|
||||||
|
@ -791,7 +791,7 @@ where
|
||||||
PerNs::types(def.into())
|
PerNs::types(def.into())
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let resolution = Resolution { def, import: None };
|
let resolution = Resolution { def, import: false };
|
||||||
self.def_collector.update(self.module_id, None, &[(name, resolution)])
|
self.def_collector.update(self.module_id, None, &[(name, resolution)])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue