From 46b4f89c920c314caf1a8af2abdb09732d100d67 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 20 Jan 2021 01:56:11 +0300 Subject: . --- crates/ide/src/display/navigation_target.rs | 3 +-- crates/ide/src/display/short_label.rs | 4 ++-- crates/ide/src/extend_selection.rs | 4 ++-- crates/ide/src/inlay_hints.rs | 2 +- crates/ide/src/join_lines.rs | 2 +- crates/ide/src/syntax_highlighting/format.rs | 2 +- crates/ide/src/syntax_highlighting/inject.rs | 2 +- 7 files changed, 9 insertions(+), 10 deletions(-) (limited to 'crates/ide/src') diff --git a/crates/ide/src/display/navigation_target.rs b/crates/ide/src/display/navigation_target.rs index 00e601244..671aa1373 100644 --- a/crates/ide/src/display/navigation_target.rs +++ b/crates/ide/src/display/navigation_target.rs @@ -153,8 +153,7 @@ impl NavigationTarget { node: InFile<&dyn ast::NameOwner>, kind: SymbolKind, ) -> NavigationTarget { - let name = - node.value.name().map(|it| it.text().clone()).unwrap_or_else(|| SmolStr::new("_")); + let name = node.value.name().map(|it| it.text().into()).unwrap_or_else(|| "_".into()); let focus_range = node.value.name().map(|it| node.with_value(it.syntax()).original_file_range(db).range); let frange = node.map(|it| it.syntax()).original_file_range(db); diff --git a/crates/ide/src/display/short_label.rs b/crates/ide/src/display/short_label.rs index 990f740b8..b8e4cc181 100644 --- a/crates/ide/src/display/short_label.rs +++ b/crates/ide/src/display/short_label.rs @@ -90,7 +90,7 @@ impl ShortLabel for ast::Variant { impl ShortLabel for ast::ConstParam { fn short_label(&self) -> Option { let mut buf = "const ".to_owned(); - buf.push_str(self.name()?.text().as_str()); + buf.push_str(self.name()?.text()); if let Some(type_ref) = self.ty() { format_to!(buf, ": {}", type_ref.syntax()); } @@ -117,6 +117,6 @@ where { let mut buf = node.visibility().map(|v| format!("{} ", v.syntax())).unwrap_or_default(); buf.push_str(label); - buf.push_str(node.name()?.text().as_str()); + buf.push_str(node.name()?.text()); Some(buf) } diff --git a/crates/ide/src/extend_selection.rs b/crates/ide/src/extend_selection.rs index 17a540972..2d722dee0 100644 --- a/crates/ide/src/extend_selection.rs +++ b/crates/ide/src/extend_selection.rs @@ -213,8 +213,8 @@ fn extend_ws(root: &SyntaxNode, ws: SyntaxToken, offset: TextSize) -> TextRange let ws_text = ws.text(); let suffix = TextRange::new(offset, ws.text_range().end()) - ws.text_range().start(); let prefix = TextRange::new(ws.text_range().start(), offset) - ws.text_range().start(); - let ws_suffix = &ws_text.as_str()[suffix]; - let ws_prefix = &ws_text.as_str()[prefix]; + let ws_suffix = &ws_text[suffix]; + let ws_prefix = &ws_text[prefix]; if ws_text.contains('\n') && !ws_suffix.contains('\n') { if let Some(node) = ws.next_sibling_or_token() { let start = match ws_prefix.rfind('\n') { diff --git a/crates/ide/src/inlay_hints.rs b/crates/ide/src/inlay_hints.rs index a2039fcc7..54485fd30 100644 --- a/crates/ide/src/inlay_hints.rs +++ b/crates/ide/src/inlay_hints.rs @@ -411,7 +411,7 @@ fn get_string_representation(expr: &ast::Expr) -> Option { match expr { ast::Expr::MethodCallExpr(method_call_expr) => { let name_ref = method_call_expr.name_ref()?; - match name_ref.text().as_str() { + match name_ref.text() { "clone" => method_call_expr.receiver().map(|rec| rec.to_string()), name_ref => Some(name_ref.to_owned()), } diff --git a/crates/ide/src/join_lines.rs b/crates/ide/src/join_lines.rs index 981467c8d..631bde0f1 100644 --- a/crates/ide/src/join_lines.rs +++ b/crates/ide/src/join_lines.rs @@ -59,7 +59,7 @@ fn remove_newline(edit: &mut TextEditBuilder, token: &SyntaxToken, offset: TextS // The node is either the first or the last in the file let suff = &token.text()[TextRange::new( offset - token.text_range().start() + TextSize::of('\n'), - TextSize::of(token.text().as_str()), + TextSize::of(token.text()), )]; let spaces = suff.bytes().take_while(|&b| b == b' ').count(); diff --git a/crates/ide/src/syntax_highlighting/format.rs b/crates/ide/src/syntax_highlighting/format.rs index a74ca844b..8a9b5ca8c 100644 --- a/crates/ide/src/syntax_highlighting/format.rs +++ b/crates/ide/src/syntax_highlighting/format.rs @@ -30,7 +30,7 @@ fn is_format_string(string: &ast::String) -> Option<()> { let parent = string.syntax().parent(); let name = parent.parent().and_then(ast::MacroCall::cast)?.path()?.segment()?.name_ref()?; - if !matches!(name.text().as_str(), "format_args" | "format_args_nl") { + if !matches!(name.text(), "format_args" | "format_args_nl") { return None; } diff --git a/crates/ide/src/syntax_highlighting/inject.rs b/crates/ide/src/syntax_highlighting/inject.rs index 281461493..8cdc3688f 100644 --- a/crates/ide/src/syntax_highlighting/inject.rs +++ b/crates/ide/src/syntax_highlighting/inject.rs @@ -116,7 +116,7 @@ pub(super) fn doc_comment(hl: &mut Highlights, node: &SyntaxNode) { None => (), } - let line: &str = comment.text().as_str(); + let line: &str = comment.text(); let range = comment.syntax().text_range(); let mut pos = TextSize::of(comment.prefix()); -- cgit v1.2.3