mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 11:59:49 +00:00
Use bind by-move to get the parent from the match
This commit is contained in:
parent
afe3dcd3ff
commit
0a144f7fff
1 changed files with 2 additions and 4 deletions
|
@ -675,14 +675,12 @@ fn is_consumed_lvalue(node: &SyntaxNode, local: &hir::Local, db: &RootDatabase)
|
||||||
|
|
||||||
/// Returns true if the parent nodes of `node` all match the `SyntaxKind`s in `kinds` exactly.
|
/// Returns true if the parent nodes of `node` all match the `SyntaxKind`s in `kinds` exactly.
|
||||||
fn parents_match(mut node: NodeOrToken<SyntaxNode, SyntaxToken>, mut kinds: &[SyntaxKind]) -> bool {
|
fn parents_match(mut node: NodeOrToken<SyntaxNode, SyntaxToken>, mut kinds: &[SyntaxKind]) -> bool {
|
||||||
while let (Some(parent), [kind, rest @ ..]) = (&node.parent(), kinds) {
|
while let (Some(parent), [kind, rest @ ..]) = (node.parent(), kinds) {
|
||||||
if parent.kind() != *kind {
|
if parent.kind() != *kind {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Would be nice to get parent out of the match, but binding by-move and by-value
|
node = parent.into();
|
||||||
// in the same pattern is unstable: rust-lang/rust#68354.
|
|
||||||
node = node.parent().unwrap().into();
|
|
||||||
kinds = rest;
|
kinds = rest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue