find_usages limited to actual usages again

This commit is contained in:
Matt Niemeir 2020-03-10 22:27:38 -05:00
parent ce8121bd65
commit 13ccbb2919
2 changed files with 84 additions and 14 deletions

View file

@ -381,6 +381,76 @@ mod tests {
);
}
#[test]
fn test_field_shorthand_correct_struct() {
test_rename(
r#"
struct Foo {
i<|>: i32,
}
struct Bar {
i: i32,
}
impl Bar {
fn new(i: i32) -> Self {
Self { i }
}
}
"#,
"j",
r#"
struct Foo {
j: i32,
}
struct Bar {
i: i32,
}
impl Bar {
fn new(i: i32) -> Self {
Self { i }
}
}
"#,
);
}
#[test]
fn test_shadow_local_for_struct_shorthand() {
test_rename(
r#"
struct Foo {
i: i32,
}
fn baz(i<|>: i32) -> Self {
let x = Foo { i };
{
let i = 0;
Foo { i }
}
}
"#,
"j",
r#"
struct Foo {
i: i32,
}
fn baz(j: i32) -> Self {
let x = Foo { i: j };
{
let i = 0;
Foo { i }
}
}
"#,
);
}
#[test]
fn test_rename_mod() {
let (analysis, position) = analysis_and_position(