Use bind by-move to get the parent from the match

This commit is contained in:
DropDemBits 2023-03-31 17:48:59 -04:00
parent afe3dcd3ff
commit 0a144f7fff
No known key found for this signature in database
GPG key ID: 7FE02A6C1EDFA075

View file

@ -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;
} }