Fix resolution of self
module within blocks
This commit is contained in:
parent
80ab753d7e
commit
997bd97b77
@ -26,9 +26,10 @@ fn inner() {}
|
|||||||
fn use_from_crate() {
|
fn use_from_crate() {
|
||||||
check_at(
|
check_at(
|
||||||
r#"
|
r#"
|
||||||
struct Struct;
|
struct Struct {}
|
||||||
fn outer() {
|
fn outer() {
|
||||||
use Struct;
|
fn Struct() {}
|
||||||
|
use Struct as PlainStruct;
|
||||||
use crate::Struct as CrateStruct;
|
use crate::Struct as CrateStruct;
|
||||||
use self::Struct as SelfStruct;
|
use self::Struct as SelfStruct;
|
||||||
$0
|
$0
|
||||||
@ -36,12 +37,13 @@ fn outer() {
|
|||||||
"#,
|
"#,
|
||||||
expect![[r#"
|
expect![[r#"
|
||||||
block scope
|
block scope
|
||||||
CrateStruct: t v
|
CrateStruct: t
|
||||||
SelfStruct: t v
|
PlainStruct: t v
|
||||||
Struct: t v
|
SelfStruct: t
|
||||||
|
Struct: v
|
||||||
|
|
||||||
crate
|
crate
|
||||||
Struct: t v
|
Struct: t
|
||||||
outer: v
|
outer: v
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
|
@ -227,7 +227,15 @@ pub(super) fn resolve_path_fp_with_macro_single(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PerNs::types(self.module_id(module).into(), Visibility::Public)
|
// Resolve `self` to the containing crate-rooted module if we're a block
|
||||||
|
self.with_ancestor_maps(db, module, &mut |def_map, module| {
|
||||||
|
if def_map.block.is_some() {
|
||||||
|
None // keep ascending
|
||||||
|
} else {
|
||||||
|
Some(PerNs::types(def_map.module_id(module).into(), Visibility::Public))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.expect("block DefMap not rooted in crate DefMap")
|
||||||
}
|
}
|
||||||
PathKind::Abs => {
|
PathKind::Abs => {
|
||||||
// 2018-style absolute path -- only extern prelude
|
// 2018-style absolute path -- only extern prelude
|
||||||
|
Loading…
Reference in New Issue
Block a user