mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 21:43:37 +00:00
Merge pull request #18605 from ChayimFriedman2/wildcard-imports
fix: Fixed another bug with glob imports
This commit is contained in:
commit
4b4cec882a
2 changed files with 46 additions and 2 deletions
|
@ -910,8 +910,13 @@ impl DefCollector<'_> {
|
||||||
self.update(module_id, &items, vis, Some(ImportType::Glob(id)));
|
self.update(module_id, &items, vis, Some(ImportType::Glob(id)));
|
||||||
// record the glob import in case we add further items
|
// record the glob import in case we add further items
|
||||||
let glob = self.glob_imports.entry(m.local_id).or_default();
|
let glob = self.glob_imports.entry(m.local_id).or_default();
|
||||||
if !glob.iter().any(|(mid, _, _)| *mid == module_id) {
|
match glob.iter_mut().find(|(mid, _, _)| *mid == module_id) {
|
||||||
glob.push((module_id, vis, id));
|
None => glob.push((module_id, vis, id)),
|
||||||
|
Some((_, old_vis, _)) => {
|
||||||
|
if let Some(new_vis) = old_vis.max(vis, &self.def_map) {
|
||||||
|
*old_vis = new_vis;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -451,3 +451,42 @@ mod glob_target {
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn regression_18580() {
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
pub mod libs {
|
||||||
|
pub struct Placeholder;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod reexport_2 {
|
||||||
|
use reexport_1::*;
|
||||||
|
pub use reexport_1::*;
|
||||||
|
|
||||||
|
pub mod reexport_1 {
|
||||||
|
pub use crate::libs::*;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
use reexport_2::*;
|
||||||
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
crate
|
||||||
|
Placeholder: t v
|
||||||
|
libs: t
|
||||||
|
reexport_1: t
|
||||||
|
reexport_2: t
|
||||||
|
|
||||||
|
crate::libs
|
||||||
|
Placeholder: t v
|
||||||
|
|
||||||
|
crate::reexport_2
|
||||||
|
Placeholder: t v
|
||||||
|
reexport_1: t
|
||||||
|
|
||||||
|
crate::reexport_2::reexport_1
|
||||||
|
Placeholder: t v
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue