Merge pull request #21451 from A4-Tacks/comp-ref-mut-before-method-call

Fix not complete `mut` and `raw` in `&x.foo()`
This commit is contained in:
Shoyu Vanilla (Flint) 2026-01-13 07:12:08 +00:00 committed by GitHub
commit 1a2200aed6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 29 additions and 6 deletions

View file

@ -1305,14 +1305,14 @@ fn classify_name_ref<'db>(
let make_path_kind_expr = |expr: ast::Expr| {
let it = expr.syntax();
let prev_token = iter::successors(it.first_token(), |it| it.prev_token())
.skip(1)
.find(|it| !it.kind().is_trivia());
let in_block_expr = is_in_block(it);
let (in_loop_body, innermost_breakable) = is_in_breakable(it).unzip();
let after_if_expr = is_after_if_expr(it.clone());
let ref_expr_parent =
path.as_single_name_ref().and_then(|_| it.parent()).and_then(ast::RefExpr::cast);
let after_amp = non_trivia_sibling(it.clone().into(), Direction::Prev)
.map(|it| it.kind() == SyntaxKind::AMP)
.unwrap_or(false);
let after_amp = prev_token.as_ref().is_some_and(|it| it.kind() == SyntaxKind::AMP);
let ref_expr_parent = prev_token.and_then(|it| it.parent()).and_then(ast::RefExpr::cast);
let (innermost_ret_ty, self_param) = {
let find_ret_ty = |it: SyntaxNode| {
if let Some(item) = ast::Item::cast(it.clone()) {

View file

@ -706,7 +706,30 @@ fn completes_after_ref_expr() {
kw while
kw while let
"#]],
)
);
check(
r#"fn main() { let _ = &$0x.foo() }"#,
expect![[r#"
fn main() fn()
bt u32 u32
kw const
kw crate::
kw false
kw for
kw if
kw if let
kw loop
kw match
kw mut
kw raw
kw return
kw self::
kw true
kw unsafe
kw while
kw while let
"#]],
);
}
#[test]