mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-30 03:27:44 +00:00
Merge pull request #20513 from A4-Tacks/let-in-let-chain
Add let in let-chain completion support
This commit is contained in:
commit
544ef84898
2 changed files with 17 additions and 3 deletions
|
|
@ -1176,19 +1176,23 @@ fn classify_name_ref<'db>(
|
|||
Some(res)
|
||||
};
|
||||
|
||||
let is_in_condition = |it: &ast::Expr| {
|
||||
fn is_in_condition(it: &ast::Expr) -> bool {
|
||||
(|| {
|
||||
let parent = it.syntax().parent()?;
|
||||
if let Some(expr) = ast::WhileExpr::cast(parent.clone()) {
|
||||
Some(expr.condition()? == *it)
|
||||
} else if let Some(expr) = ast::IfExpr::cast(parent) {
|
||||
} else if let Some(expr) = ast::IfExpr::cast(parent.clone()) {
|
||||
Some(expr.condition()? == *it)
|
||||
} else if let Some(expr) = ast::BinExpr::cast(parent)
|
||||
&& expr.op_token()?.kind() == T![&&]
|
||||
{
|
||||
Some(is_in_condition(&expr.into()))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})()
|
||||
.unwrap_or(false)
|
||||
};
|
||||
}
|
||||
|
||||
let make_path_kind_expr = |expr: ast::Expr| {
|
||||
let it = expr.syntax();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue