This commit is contained in:
Alex Waygood 2025-11-22 23:45:41 +00:00 committed by Aria Desires
parent a10c4e2027
commit dd1ac81f15
3 changed files with 9 additions and 13 deletions

View File

@ -318,7 +318,7 @@ impl ModuleName {
db: &dyn Db,
importing_file: File,
) -> Result<Self, ModuleNameResolutionError> {
relative_module_name(db, importing_file, None, NonZeroU32::new(1).unwrap())
Self::from_identifier_parts(db, importing_file, None, 1)
}
}

View File

@ -1551,11 +1551,11 @@ impl<'ast> Visitor<'ast> for SemanticIndexBuilder<'_, 'ast> {
);
}
} else {
self.imported_modules.extend(
module_name
.ancestors()
.zip(std::iter::repeat(ImportKind::ImportFrom)),
);
for name in module_name.ancestors() {
self.imported_modules
.entry(name)
.or_insert(ImportKind::ImportFrom);
}
}
}
}

View File

@ -12250,13 +12250,9 @@ impl<'db> ModuleLiteralType<'db> {
.into_iter()
.flat_map(|file| imported_modules(db, file))
.filter_map(|(submodule_name, kind)| {
Some((submodule_name.relative_to(self.module(db).name(db))?, kind))
})
.filter_map(|(relative_submodule, kind)| {
relative_submodule
.components()
.next()
.map(|module| (Name::from(module), *kind))
let relative_name = submodule_name.relative_to(self.module(db).name(db))?;
let available_attribute = relative_name.components().next()?;
Some((Name::from(available_attribute), *kind))
})
}