fn use_from_crate() {
check_at(
r#"
-struct Struct;
+struct Struct {}
fn outer() {
- use Struct;
+ fn Struct() {}
+ use Struct as PlainStruct;
use crate::Struct as CrateStruct;
use self::Struct as SelfStruct;
$0
"#,
expect![[r#"
block scope
- CrateStruct: t v
- SelfStruct: t v
- Struct: t v
+ CrateStruct: t
+ PlainStruct: t v
+ SelfStruct: t
+ Struct: v
crate
- Struct: t v
+ Struct: t
outer: v
"#]],
);
}
}
- 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 => {
// 2018-style absolute path -- only extern prelude