From 3d9b3a8575ef3cb557fd847b941000df3b2db670 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sun, 21 Mar 2021 12:05:08 +0100 Subject: remove more redundant clones (clippy::redundant_clone()) --- crates/hir_expand/src/db.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/hir_expand/src') diff --git a/crates/hir_expand/src/db.rs b/crates/hir_expand/src/db.rs index 2748e25cf..fc73e435b 100644 --- a/crates/hir_expand/src/db.rs +++ b/crates/hir_expand/src/db.rs @@ -173,7 +173,7 @@ fn macro_arg_text(db: &dyn AstDatabase, id: MacroCallId) -> Option { }; let loc = db.lookup_intern_macro(id); let arg = loc.kind.arg(db)?; - Some(arg.green().to_owned()) + Some(arg.green()) } fn macro_arg(db: &dyn AstDatabase, id: MacroCallId) -> Option> { -- cgit v1.2.3 From 8a671168576b9b552a22be285646fc293a80d8c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sun, 21 Mar 2021 12:38:21 +0100 Subject: use strip_prefix() instead of starts_with and slicing (clippy::manual_strip) --- crates/hir_expand/src/name.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'crates/hir_expand/src') diff --git a/crates/hir_expand/src/name.rs b/crates/hir_expand/src/name.rs index 43de9edd6..0aeea48d5 100644 --- a/crates/hir_expand/src/name.rs +++ b/crates/hir_expand/src/name.rs @@ -48,9 +48,8 @@ impl Name { /// Resolve a name from the text of token. fn resolve(raw_text: &str) -> Name { - let raw_start = "r#"; - if raw_text.starts_with(raw_start) { - Name::new_text(SmolStr::new(&raw_text[raw_start.len()..])) + if let Some(text) = raw_text.strip_prefix("r#") { + Name::new_text(SmolStr::new(text)) } else { Name::new_text(raw_text.into()) } -- cgit v1.2.3