mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-04 12:44:40 +00:00
Import glob imports from other crates
This is the easy part since we don't have to consider the fixpoint algorithm.
This commit is contained in:
parent
c1e295682e
commit
2e1d739a80
@ -5,4 +5,5 @@ test_utils::marks!(
|
||||
type_var_cycles_resolve_as_possible
|
||||
type_var_resolves_to_int_var
|
||||
glob_enum
|
||||
glob_across_crates
|
||||
);
|
||||
|
@ -276,12 +276,25 @@ where
|
||||
log::debug!("glob import: {:?}", import);
|
||||
match def.take_types() {
|
||||
Some(ModuleDef::Module(m)) => {
|
||||
// TODO
|
||||
if m.krate != self.krate {
|
||||
tested_by!(glob_across_crates);
|
||||
// glob import from other crate => we can just import everything once
|
||||
let item_map = self.db.item_map(m.krate);
|
||||
let scope = &item_map[m.module_id];
|
||||
self.update(module_id, |items| {
|
||||
// TODO: handle shadowing and visibility
|
||||
items.items.extend(
|
||||
scope.items.iter().map(|(name, res)| (name.clone(), res.clone())),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
Some(ModuleDef::Enum(e)) => {
|
||||
tested_by!(glob_enum);
|
||||
// glob import from enum => just import all the variants
|
||||
let variants = e.variants(self.db);
|
||||
let resolutions = variants.into_iter()
|
||||
let resolutions = variants
|
||||
.into_iter()
|
||||
.filter_map(|variant| {
|
||||
let res = Resolution {
|
||||
def: PerNs::both(variant.into(), e.into()),
|
||||
|
@ -251,6 +251,7 @@ fn glob_enum() {
|
||||
|
||||
#[test]
|
||||
fn glob_across_crates() {
|
||||
covers!(glob_across_crates);
|
||||
let (mut db, sr) = MockDatabase::with_files(
|
||||
"
|
||||
//- /main.rs
|
||||
|
Loading…
Reference in New Issue
Block a user