mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
fix: Fix reference completions being emitted in places other than argument lists
This commit is contained in:
parent
ad91622d11
commit
82ed68c95e
2 changed files with 16 additions and 5 deletions
|
@ -353,7 +353,7 @@ fn expected_type_and_name(
|
||||||
_ => ty,
|
_ => ty,
|
||||||
};
|
};
|
||||||
|
|
||||||
loop {
|
let (ty, name) = loop {
|
||||||
break match_ast! {
|
break match_ast! {
|
||||||
match node {
|
match node {
|
||||||
ast::LetStmt(it) => {
|
ast::LetStmt(it) => {
|
||||||
|
@ -385,9 +385,7 @@ fn expected_type_and_name(
|
||||||
token.clone(),
|
token.clone(),
|
||||||
).map(|ap| {
|
).map(|ap| {
|
||||||
let name = ap.ident().map(NameOrNameRef::Name);
|
let name = ap.ident().map(NameOrNameRef::Name);
|
||||||
|
(Some(ap.ty), name)
|
||||||
let ty = strip_refs(ap.ty);
|
|
||||||
(Some(ty), name)
|
|
||||||
})
|
})
|
||||||
.unwrap_or((None, None))
|
.unwrap_or((None, None))
|
||||||
},
|
},
|
||||||
|
@ -489,7 +487,8 @@ fn expected_type_and_name(
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
|
(ty.map(strip_refs), name)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn classify_lifetime(
|
fn classify_lifetime(
|
||||||
|
|
|
@ -411,3 +411,15 @@ fn main() {
|
||||||
expect!["ty: i32, name: ?"],
|
expect!["ty: i32, name: ?"],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn expected_type_ref_return_pos() {
|
||||||
|
check_expected_type_and_name(
|
||||||
|
r#"
|
||||||
|
fn f(thing: u32) -> &u32 {
|
||||||
|
&thin$0
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
expect!["ty: u32, name: ?"],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue