Only populate prelude for crate-level DefMaps
This commit is contained in:
@@ -54,6 +54,7 @@ pub(super) fn collect_defs(
|
|||||||
) -> DefMap {
|
) -> DefMap {
|
||||||
let crate_graph = db.crate_graph();
|
let crate_graph = db.crate_graph();
|
||||||
|
|
||||||
|
if block.is_none() {
|
||||||
// populate external prelude
|
// populate external prelude
|
||||||
for dep in &crate_graph[def_map.krate].dependencies {
|
for dep in &crate_graph[def_map.krate].dependencies {
|
||||||
log::debug!("crate dep {:?} -> {:?}", dep.name, dep.crate_id);
|
log::debug!("crate dep {:?} -> {:?}", dep.name, dep.crate_id);
|
||||||
@@ -70,6 +71,7 @@ pub(super) fn collect_defs(
|
|||||||
def_map.prelude = dep_def_map.prelude;
|
def_map.prelude = dep_def_map.prelude;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let cfg_options = &crate_graph[def_map.krate].cfg_options;
|
let cfg_options = &crate_graph[def_map.krate].cfg_options;
|
||||||
let proc_macros = &crate_graph[def_map.krate].proc_macro;
|
let proc_macros = &crate_graph[def_map.krate].proc_macro;
|
||||||
|
|||||||
@@ -3897,4 +3897,46 @@ trait A where
|
|||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn string_shadowed_with_inner_items() {
|
||||||
|
check(
|
||||||
|
r#"
|
||||||
|
//- /main.rs crate:main deps:alloc
|
||||||
|
|
||||||
|
/// Custom `String` type.
|
||||||
|
struct String;
|
||||||
|
|
||||||
|
fn f() {
|
||||||
|
let _: String$0;
|
||||||
|
|
||||||
|
fn inner() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
//- /alloc.rs crate:alloc
|
||||||
|
#[prelude_import]
|
||||||
|
pub use string::*;
|
||||||
|
|
||||||
|
mod string {
|
||||||
|
/// This is `alloc::String`.
|
||||||
|
pub struct String;
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
*String*
|
||||||
|
|
||||||
|
```rust
|
||||||
|
main
|
||||||
|
```
|
||||||
|
|
||||||
|
```rust
|
||||||
|
struct String
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Custom `String` type.
|
||||||
|
"#]],
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user