mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 14:21:44 +00:00
Correct has_ref detection
This commit is contained in:
parent
638cc3e59f
commit
3a57f700d8
2 changed files with 31 additions and 1 deletions
|
@ -876,7 +876,7 @@ fn path_or_use_tree_qualifier(path: &ast::Path) -> Option<(ast::Path, bool)> {
|
||||||
|
|
||||||
fn has_ref(token: &SyntaxToken) -> bool {
|
fn has_ref(token: &SyntaxToken) -> bool {
|
||||||
let mut token = token.clone();
|
let mut token = token.clone();
|
||||||
for skip in [WHITESPACE, IDENT, T![mut]] {
|
for skip in [IDENT, WHITESPACE, T![mut]] {
|
||||||
if token.kind() == skip {
|
if token.kind() == skip {
|
||||||
token = match token.prev_token() {
|
token = match token.prev_token() {
|
||||||
Some(it) => it,
|
Some(it) => it,
|
||||||
|
@ -998,6 +998,20 @@ fn bar(x: &mut u32) {}
|
||||||
check_expected_type_and_name(
|
check_expected_type_and_name(
|
||||||
r#"
|
r#"
|
||||||
fn foo() { bar(& c$0); }
|
fn foo() { bar(& c$0); }
|
||||||
|
fn bar(x: &u32) {}
|
||||||
|
"#,
|
||||||
|
expect![[r#"ty: u32, name: x"#]],
|
||||||
|
);
|
||||||
|
check_expected_type_and_name(
|
||||||
|
r#"
|
||||||
|
fn foo() { bar(&mut c$0); }
|
||||||
|
fn bar(x: &mut u32) {}
|
||||||
|
"#,
|
||||||
|
expect![[r#"ty: u32, name: x"#]],
|
||||||
|
);
|
||||||
|
check_expected_type_and_name(
|
||||||
|
r#"
|
||||||
|
fn foo() { bar(&c$0); }
|
||||||
fn bar(x: &u32) {}
|
fn bar(x: &u32) {}
|
||||||
"#,
|
"#,
|
||||||
expect![[r#"ty: u32, name: x"#]],
|
expect![[r#"ty: u32, name: x"#]],
|
||||||
|
|
|
@ -1156,6 +1156,22 @@ fn main() {
|
||||||
fn foo(…) []
|
fn foo(…) []
|
||||||
"#]],
|
"#]],
|
||||||
);
|
);
|
||||||
|
check_relevance(
|
||||||
|
r#"
|
||||||
|
struct S;
|
||||||
|
fn foo(s: &mut S) {}
|
||||||
|
fn main() {
|
||||||
|
let mut ssss = S;
|
||||||
|
foo(&mut s$0);
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
expect![[r#"
|
||||||
|
lc ssss [type+local]
|
||||||
|
st S []
|
||||||
|
fn main() []
|
||||||
|
fn foo(…) []
|
||||||
|
"#]],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue