Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-def/src/body/tests/block.rs')
-rw-r--r--crates/hir-def/src/body/tests/block.rs62
1 files changed, 62 insertions, 0 deletions
diff --git a/crates/hir-def/src/body/tests/block.rs b/crates/hir-def/src/body/tests/block.rs
index 985c6387ba..f483efa851 100644
--- a/crates/hir-def/src/body/tests/block.rs
+++ b/crates/hir-def/src/body/tests/block.rs
@@ -528,3 +528,65 @@ fn f() {$0
"#]],
)
}
+
+#[test]
+fn resolve_extern_prelude_in_block() {
+ check_at(
+ r#"
+//- /main.rs crate:main deps:core
+fn main() {
+ mod f {
+ use core::S;
+ $0
+ }
+}
+
+//- /core.rs crate:core
+pub struct S;
+ "#,
+ expect![[r#"
+ block scope
+ f: t
+
+ block scope::f
+ S: ti vi
+
+ crate
+ main: v
+ "#]],
+ )
+}
+
+#[test]
+fn shadow_extern_prelude_in_block() {
+ check_at(
+ r#"
+//- /main.rs crate:main deps:core
+fn main() {
+ mod core { pub struct S; }
+ {
+ fn inner() {} // forces a block def map
+ use core::S; // should resolve to the local one
+ $0
+ }
+}
+
+//- /core.rs crate:core
+pub const S;
+ "#,
+ expect![[r#"
+ block scope
+ S: ti vi
+ inner: v
+
+ block scope
+ core: t
+
+ block scope::core
+ S: t v
+
+ crate
+ main: v
+ "#]],
+ )
+}