mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-30 10:45:18 +00:00
Auto merge of #14355 - Veykril:completion-ref-strip, r=Veykril
fix: Fix reference completions being emitted in places other than argument lists Fixes https://github.com/rust-lang/rust-analyzer/issues/14331
This commit is contained in:
commit
e611fbe6ab
@ -353,7 +353,7 @@ fn expected_type_and_name(
|
||||
_ => ty,
|
||||
};
|
||||
|
||||
loop {
|
||||
let (ty, name) = loop {
|
||||
break match_ast! {
|
||||
match node {
|
||||
ast::LetStmt(it) => {
|
||||
@ -385,9 +385,7 @@ fn expected_type_and_name(
|
||||
token.clone(),
|
||||
).map(|ap| {
|
||||
let name = ap.ident().map(NameOrNameRef::Name);
|
||||
|
||||
let ty = strip_refs(ap.ty);
|
||||
(Some(ty), name)
|
||||
(Some(ap.ty), name)
|
||||
})
|
||||
.unwrap_or((None, None))
|
||||
},
|
||||
@ -489,7 +487,8 @@ fn expected_type_and_name(
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
(ty.map(strip_refs), name)
|
||||
}
|
||||
|
||||
fn classify_lifetime(
|
||||
|
@ -411,3 +411,15 @@ fn main() {
|
||||
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…
Reference in New Issue
Block a user