Skip to content

Commit

Permalink
test: add tests for extern preludes resolving in local mods
Browse files Browse the repository at this point in the history
  • Loading branch information
roife committed May 21, 2024
1 parent ea2a16c commit 719eee2
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions src/tools/rust-analyzer/crates/hir-def/src/body/tests/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
"#]],
)
}

0 comments on commit 719eee2

Please sign in to comment.