Use aliases in import resolution
This commit is contained in:
parent
5a7fce4e4c
commit
d8ef8acb47
@ -251,10 +251,14 @@ fn populate_module(&mut self, module_id: ModuleId, input: Arc<LoweredModule>) {
|
||||
};
|
||||
}
|
||||
for (import_id, import_data) in input.imports.iter() {
|
||||
if let Some(segment) = import_data.path.segments.iter().last() {
|
||||
if let Some(last_segment) = import_data.path.segments.iter().last() {
|
||||
if !import_data.is_glob {
|
||||
let name = import_data
|
||||
.alias
|
||||
.clone()
|
||||
.unwrap_or_else(|| last_segment.name.clone());
|
||||
module_items.items.insert(
|
||||
segment.name.clone(),
|
||||
name,
|
||||
Resolution {
|
||||
def: PerNs::none(),
|
||||
import: Some(import_id),
|
||||
@ -319,19 +323,18 @@ fn resolve_import(
|
||||
|
||||
if reached_fixedpoint == ReachedFixedPoint::Yes {
|
||||
let last_segment = import.path.segments.last().unwrap();
|
||||
let name = import
|
||||
.alias
|
||||
.clone()
|
||||
.unwrap_or_else(|| last_segment.name.clone());
|
||||
log::debug!("resolved import {:?} ({:?}) to {:?}", name, import, def,);
|
||||
self.update(module_id, |items| {
|
||||
let res = Resolution {
|
||||
def,
|
||||
import: Some(import_id),
|
||||
};
|
||||
items.items.insert(last_segment.name.clone(), res);
|
||||
items.items.insert(name, res);
|
||||
});
|
||||
log::debug!(
|
||||
"resolved import {:?} ({:?}) cross-source root to {:?}",
|
||||
last_segment.name,
|
||||
import,
|
||||
def,
|
||||
);
|
||||
}
|
||||
reached_fixedpoint
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user