Remove import from resolution

This commit is contained in:
Aleksey Kladov 2019-12-21 17:22:48 +01:00
parent 6d8a2ec3dd
commit ec56f59ac1
2 changed files with 12 additions and 17 deletions

View file

@ -30,7 +30,7 @@ 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: None })
(name.clone(), Resolution { def: PerNs::types(ty.clone().into()), import: false })
})
.collect()
});
@ -54,7 +54,7 @@ impl ItemScope {
pub fn declarations(&self) -> impl Iterator<Item = ModuleDefId> + '_ {
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| {
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() {
existing.def.types = res.def.types;
existing.import = import.or(res.import);
existing.import = import.is_some() || res.import;
changed = true;
}
if existing.def.values.is_none() && res.def.values.is_some() {
existing.def.values = res.def.values;
existing.import = import.or(res.import);
existing.import = import.is_some() || res.import;
changed = true;
}
if existing.def.macros.is_none() && res.def.macros.is_some() {
existing.def.macros = res.def.macros;
existing.import = import.or(res.import);
existing.import = import.is_some() || res.import;
changed = true;
}
if existing.def.is_none()
&& res.def.is_none()
&& existing.import.is_none()
&& res.import.is_some()
{
if existing.def.is_none() && res.def.is_none() && !existing.import && res.import {
existing.import = res.import;
}
changed
@ -160,6 +156,5 @@ impl ItemScope {
pub struct Resolution {
/// None for unresolved
pub def: PerNs,
/// ident by which this is imported into local scope.
pub(crate) import: Option<LocalImportId>,
pub(crate) import: bool,
}

View file

@ -219,7 +219,7 @@ where
self.update(
self.def_map.root,
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 res = Resolution {
def: PerNs::both(variant.into(), variant.into()),
import: Some(import_id),
import: true,
};
(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)]);
}
None => tested_by!(bogus_paths),
@ -719,7 +719,7 @@ where
def: PerNs::types(
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)]);
res
@ -791,7 +791,7 @@ where
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)])
}