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_def/src/resolver.rs | 2 +- crates/hir_expand/src/db.rs | 2 +- crates/hir_ty/src/lower.rs | 3 +-- crates/syntax/src/algo.rs | 4 ++-- crates/syntax/src/ast/make.rs | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) (limited to 'crates') diff --git a/crates/hir_def/src/resolver.rs b/crates/hir_def/src/resolver.rs index 4a2d1c087..04ea9c5d7 100644 --- a/crates/hir_def/src/resolver.rs +++ b/crates/hir_def/src/resolver.rs @@ -472,7 +472,7 @@ impl Scope { } Scope::ExprScope(scope) => { if let Some((label, name)) = scope.expr_scopes.label(scope.scope_id) { - f(name.clone(), ScopeDef::Label(label)) + f(name, ScopeDef::Label(label)) } scope.expr_scopes.entries(scope.scope_id).iter().for_each(|e| { f(e.name().clone(), ScopeDef::Local(e.pat())); 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> { diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs index cbbb535e5..c914a3b8e 100644 --- a/crates/hir_ty/src/lower.rs +++ b/crates/hir_ty/src/lower.rs @@ -946,8 +946,7 @@ pub(crate) fn trait_environment_query( let substs = Substitution::type_params(db, trait_id); let trait_ref = TraitRef { trait_id: to_chalk_trait_id(trait_id), substitution: substs }; let pred = WhereClause::Implemented(trait_ref); - let program_clause: chalk_ir::ProgramClause = - pred.clone().to_chalk(db).cast(&Interner); + let program_clause: chalk_ir::ProgramClause = pred.to_chalk(db).cast(&Interner); clauses.push(program_clause.into_from_env_clause(&Interner)); } diff --git a/crates/syntax/src/algo.rs b/crates/syntax/src/algo.rs index 82ebf9037..a153a9e1c 100644 --- a/crates/syntax/src/algo.rs +++ b/crates/syntax/src/algo.rs @@ -567,7 +567,7 @@ impl<'a> SyntaxRewriter<'a> { fn element_to_green(element: SyntaxElement) -> NodeOrToken { match element { - NodeOrToken::Node(it) => NodeOrToken::Node(it.green().to_owned()), + NodeOrToken::Node(it) => NodeOrToken::Node(it.green()), NodeOrToken::Token(it) => NodeOrToken::Token(it.green().to_owned()), } } @@ -625,7 +625,7 @@ fn position_of_child(parent: &SyntaxNode, child: SyntaxElement) -> usize { fn to_green_element(element: SyntaxElement) -> NodeOrToken { match element { - NodeOrToken::Node(it) => it.green().to_owned().into(), + NodeOrToken::Node(it) => it.green().into(), NodeOrToken::Token(it) => it.green().to_owned().into(), } } diff --git a/crates/syntax/src/ast/make.rs b/crates/syntax/src/ast/make.rs index 810c8d4c8..7049affd9 100644 --- a/crates/syntax/src/ast/make.rs +++ b/crates/syntax/src/ast/make.rs @@ -532,7 +532,7 @@ fn ast_from_text(text: &str) -> N { } fn unroot(n: SyntaxNode) -> SyntaxNode { - SyntaxNode::new_root(n.green().to_owned()) + SyntaxNode::new_root(n.green()) } pub mod tokens { -- cgit v1.2.3