From 5ff3299dd61ea5c5790c01819994c9d8fa6afc09 Mon Sep 17 00:00:00 2001 From: cynecx Date: Fri, 26 Mar 2021 18:30:59 +0100 Subject: syntax: return owned string instead of leaking string --- crates/ide/src/diagnostics/fixes.rs | 2 +- crates/ide/src/inlay_hints.rs | 2 +- crates/ide/src/syntax_highlighting/format.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'crates/ide/src') diff --git a/crates/ide/src/diagnostics/fixes.rs b/crates/ide/src/diagnostics/fixes.rs index 2f840909c..5fb3e2d91 100644 --- a/crates/ide/src/diagnostics/fixes.rs +++ b/crates/ide/src/diagnostics/fixes.rs @@ -210,7 +210,7 @@ fn missing_record_expr_field_fix( } let new_field = make::record_field( None, - make::name(record_expr_field.field_name()?.text()), + make::name(&record_expr_field.field_name()?.text()), make::ty(&new_field_type.display_source_code(sema.db, module.into()).ok()?), ); diff --git a/crates/ide/src/inlay_hints.rs b/crates/ide/src/inlay_hints.rs index 16c04eeee..25f96222c 100644 --- a/crates/ide/src/inlay_hints.rs +++ b/crates/ide/src/inlay_hints.rs @@ -416,7 +416,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() { + match name_ref.text().as_str() { "clone" => method_call_expr.receiver().map(|rec| rec.to_string()), name_ref => Some(name_ref.to_owned()), } diff --git a/crates/ide/src/syntax_highlighting/format.rs b/crates/ide/src/syntax_highlighting/format.rs index e503abc93..5bbadb0f4 100644 --- a/crates/ide/src/syntax_highlighting/format.rs +++ b/crates/ide/src/syntax_highlighting/format.rs @@ -31,7 +31,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(), "format_args" | "format_args_nl") { + if !matches!(name.text().as_str(), "format_args" | "format_args_nl") { return None; } -- cgit v1.2.3