Remove import field

This commit is contained in:
Aleksey Kladov 2019-12-22 15:28:55 +01:00
parent 2c60f42825
commit 558956c84b
2 changed files with 8 additions and 19 deletions

View file

@ -30,9 +30,7 @@ pub struct ItemScope {
static BUILTIN_SCOPE: Lazy<FxHashMap<Name, Resolution>> = Lazy::new(|| {
BuiltinType::ALL
.iter()
.map(|(name, ty)| {
(name.clone(), Resolution { def: PerNs::types(ty.clone().into()), import: false })
})
.map(|(name, ty)| (name.clone(), Resolution { def: PerNs::types(ty.clone().into()) }))
.collect()
});
@ -113,29 +111,23 @@ impl ItemScope {
self.legacy_macros.insert(name, mac);
}
pub(crate) fn push_res(&mut self, name: Name, res: &Resolution, import: bool) -> bool {
pub(crate) fn push_res(&mut self, name: Name, res: &Resolution, _import: bool) -> bool {
let mut changed = false;
let existing = self.visible.entry(name.clone()).or_default();
if existing.def.types.is_none() && res.def.types.is_some() {
existing.def.types = res.def.types;
existing.import = import || res.import;
changed = true;
}
if existing.def.values.is_none() && res.def.values.is_some() {
existing.def.values = res.def.values;
existing.import = import || res.import;
changed = true;
}
if existing.def.macros.is_none() && res.def.macros.is_some() {
existing.def.macros = res.def.macros;
existing.import = import || res.import;
changed = true;
}
if existing.def.is_none() && res.def.is_none() && !existing.import && res.import {
existing.import = res.import;
}
changed
}
@ -152,7 +144,6 @@ impl ItemScope {
pub struct Resolution {
/// None for unresolved
pub def: PerNs,
pub(crate) import: bool,
}
impl From<ModuleDefId> for PerNs {

View file

@ -218,7 +218,7 @@ where
self.update(
self.def_map.root,
None,
&[(name, Resolution { def: PerNs::macros(macro_), import: false })],
&[(name, Resolution { def: PerNs::macros(macro_) })],
);
}
}
@ -401,10 +401,8 @@ where
.map(|(local_id, variant_data)| {
let name = variant_data.name.clone();
let variant = EnumVariantId { parent: e, local_id };
let res = Resolution {
def: PerNs::both(variant.into(), variant.into()),
import: true,
};
let res =
Resolution { def: PerNs::both(variant.into(), variant.into()) };
(name, res)
})
.collect::<Vec<_>>();
@ -430,7 +428,7 @@ where
}
}
let resolution = Resolution { def, import: true };
let resolution = Resolution { def };
self.update(module_id, Some(import_id), &[(name, resolution)]);
}
None => tested_by!(bogus_paths),
@ -717,7 +715,7 @@ where
let module = ModuleId { krate: self.def_collector.def_map.krate, local_id: res };
let def: ModuleDefId = module.into();
self.def_collector.def_map.modules[self.module_id].scope.define_def(def);
let resolution = Resolution { def: def.into(), import: false };
let resolution = Resolution { def: def.into() };
self.def_collector.update(self.module_id, None, &[(name, resolution)]);
res
}
@ -777,7 +775,7 @@ where
.into(),
};
self.def_collector.def_map.modules[self.module_id].scope.define_def(def);
let resolution = Resolution { def: def.into(), import: false };
let resolution = Resolution { def: def.into() };
self.def_collector.update(self.module_id, None, &[(name, resolution)])
}