From 46b4f89c920c314caf1a8af2abdb09732d100d67 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 20 Jan 2021 01:56:11 +0300 Subject: . --- crates/ssr/src/matching.rs | 13 +++++++------ crates/ssr/src/replacing.rs | 2 +- crates/ssr/src/resolving.rs | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) (limited to 'crates/ssr') diff --git a/crates/ssr/src/matching.rs b/crates/ssr/src/matching.rs index 42d313f91..df013bae9 100644 --- a/crates/ssr/src/matching.rs +++ b/crates/ssr/src/matching.rs @@ -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 = 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)?; diff --git a/crates/ssr/src/replacing.rs b/crates/ssr/src/replacing.rs index 7e7ce37bd..06a94a46c 100644 --- a/crates/ssr/src/replacing.rs +++ b/crates/ssr/src/replacing.rs @@ -173,7 +173,7 @@ impl ReplacementRenderer<'_> { ); } } else { - self.out.push_str(token.text().as_str()); + self.out.push_str(token.text()); } } diff --git a/crates/ssr/src/resolving.rs b/crates/ssr/src/resolving.rs index f5ceb5729..14e5a3b69 100644 --- a/crates/ssr/src/resolving.rs +++ b/crates/ssr/src/resolving.rs @@ -228,7 +228,7 @@ impl<'db> ResolutionScope<'db> { None, |_ty, assoc_item| { let item_name = assoc_item.name(self.scope.db)?; - if item_name.to_string().as_str() == name.text().as_str() { + if item_name.to_string().as_str() == name.text() { Some(hir::PathResolution::AssocItem(assoc_item)) } else { None -- cgit v1.2.3