mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 15:15:24 +00:00
.
This commit is contained in:
parent
63f509f492
commit
46b4f89c92
28 changed files with 69 additions and 67 deletions
|
@ -10,8 +10,11 @@ use hir::Semantics;
|
|||
use ide_db::base_db::FileRange;
|
||||
use rustc_hash::FxHashMap;
|
||||
use std::{cell::Cell, iter::Peekable};
|
||||
use syntax::ast::{AstNode, AstToken};
|
||||
use syntax::{ast, SyntaxElement, SyntaxElementChildren, SyntaxKind, SyntaxNode, SyntaxToken};
|
||||
use syntax::{
|
||||
ast::{AstNode, AstToken},
|
||||
SmolStr,
|
||||
};
|
||||
use test_utils::mark;
|
||||
|
||||
// Creates a match error. If we're currently attempting to match some code that we thought we were
|
||||
|
@ -398,11 +401,11 @@ impl<'db, 'sema> Matcher<'db, 'sema> {
|
|||
code: &SyntaxNode,
|
||||
) -> Result<(), MatchFailed> {
|
||||
// Build a map keyed by field name.
|
||||
let mut fields_by_name = FxHashMap::default();
|
||||
let mut fields_by_name: FxHashMap<SmolStr, SyntaxNode> = FxHashMap::default();
|
||||
for child in code.children() {
|
||||
if let Some(record) = ast::RecordExprField::cast(child.clone()) {
|
||||
if let Some(name) = record.field_name() {
|
||||
fields_by_name.insert(name.text().clone(), child.clone());
|
||||
fields_by_name.insert(name.text().into(), child.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -473,9 +476,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> {
|
|||
}
|
||||
SyntaxElement::Node(n) => {
|
||||
if let Some(first_token) = n.first_token() {
|
||||
if Some(first_token.text().as_str())
|
||||
== next_pattern_token.as_deref()
|
||||
{
|
||||
if Some(first_token.text()) == next_pattern_token.as_deref() {
|
||||
if let Some(SyntaxElement::Node(p)) = pattern.next() {
|
||||
// We have a subtree that starts with the next token in our pattern.
|
||||
self.attempt_match_token_tree(phase, &p, &n)?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue