diff options
author | Matthias Krüger <[email protected]> | 2021-03-17 00:56:31 +0000 |
---|---|---|
committer | Matthias Krüger <[email protected]> | 2021-03-17 00:56:31 +0000 |
commit | 048dad8c2e86006e53b3a134279729efb28b9e32 (patch) | |
tree | b9e584f4d1c276b60cb0bd7cee3a4ad158a0ac66 | |
parent | c5d654d5132b702d028ed00b5ec5c654a0b4a2fa (diff) |
don't clone types that are copy (clippy::clone_on_copy)
-rw-r--r-- | crates/hir_expand/src/hygiene.rs | 7 | ||||
-rw-r--r-- | crates/ide/src/doc_links.rs | 4 | ||||
-rw-r--r-- | crates/ide/src/goto_definition.rs | 2 | ||||
-rw-r--r-- | crates/ide/src/syntax_highlighting/inject.rs | 2 | ||||
-rw-r--r-- | crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs | 7 | ||||
-rw-r--r-- | crates/ide_completion/src/completions/pattern.rs | 4 | ||||
-rw-r--r-- | crates/ide_completion/src/render.rs | 2 | ||||
-rw-r--r-- | crates/ide_ssr/src/lib.rs | 7 | ||||
-rw-r--r-- | crates/ide_ssr/src/matching.rs | 2 | ||||
-rw-r--r-- | crates/mbe/src/benchmark.rs | 5 | ||||
-rw-r--r-- | crates/mbe/src/parser.rs | 2 | ||||
-rw-r--r-- | crates/rust-analyzer/src/diagnostics/to_proto.rs | 2 |
12 files changed, 18 insertions, 28 deletions
diff --git a/crates/hir_expand/src/hygiene.rs b/crates/hir_expand/src/hygiene.rs index c8ea81210..87cad326d 100644 --- a/crates/hir_expand/src/hygiene.rs +++ b/crates/hir_expand/src/hygiene.rs | |||
@@ -23,7 +23,7 @@ pub struct Hygiene { | |||
23 | 23 | ||
24 | impl Hygiene { | 24 | impl Hygiene { |
25 | pub fn new(db: &dyn AstDatabase, file_id: HirFileId) -> Hygiene { | 25 | pub fn new(db: &dyn AstDatabase, file_id: HirFileId) -> Hygiene { |
26 | Hygiene { frames: Some(HygieneFrames::new(db, file_id.clone())) } | 26 | Hygiene { frames: Some(HygieneFrames::new(db, file_id)) } |
27 | } | 27 | } |
28 | 28 | ||
29 | pub fn new_unhygienic() -> Hygiene { | 29 | pub fn new_unhygienic() -> Hygiene { |
@@ -129,10 +129,7 @@ impl HygieneInfo { | |||
129 | mbe::Origin::Call => (&self.macro_arg.1, self.arg_start), | 129 | mbe::Origin::Call => (&self.macro_arg.1, self.arg_start), |
130 | mbe::Origin::Def => ( | 130 | mbe::Origin::Def => ( |
131 | &self.macro_def.1, | 131 | &self.macro_def.1, |
132 | self.def_start | 132 | *self.def_start.as_ref().expect("`Origin::Def` used with non-`macro_rules!` macro"), |
133 | .as_ref() | ||
134 | .expect("`Origin::Def` used with non-`macro_rules!` macro") | ||
135 | .clone(), | ||
136 | ), | 133 | ), |
137 | }; | 134 | }; |
138 | 135 | ||
diff --git a/crates/ide/src/doc_links.rs b/crates/ide/src/doc_links.rs index 461e11060..5ea9fc4fb 100644 --- a/crates/ide/src/doc_links.rs +++ b/crates/ide/src/doc_links.rs | |||
@@ -93,7 +93,7 @@ pub(crate) fn remove_links(markdown: &str) -> String { | |||
93 | 93 | ||
94 | let mut cb = |_: BrokenLink| { | 94 | let mut cb = |_: BrokenLink| { |
95 | let empty = InlineStr::try_from("").unwrap(); | 95 | let empty = InlineStr::try_from("").unwrap(); |
96 | Some((CowStr::Inlined(empty.clone()), CowStr::Inlined(empty))) | 96 | Some((CowStr::Inlined(empty), CowStr::Inlined(empty))) |
97 | }; | 97 | }; |
98 | let doc = Parser::new_with_broken_link_callback(markdown, opts, Some(&mut cb)); | 98 | let doc = Parser::new_with_broken_link_callback(markdown, opts, Some(&mut cb)); |
99 | let doc = doc.filter_map(move |evt| match evt { | 99 | let doc = doc.filter_map(move |evt| match evt { |
@@ -147,7 +147,7 @@ fn get_doc_link(db: &RootDatabase, definition: Definition) -> Option<String> { | |||
147 | _ => return None, | 147 | _ => return None, |
148 | }; | 148 | }; |
149 | 149 | ||
150 | let ns = ItemInNs::from(target_def.clone()); | 150 | let ns = ItemInNs::from(target_def); |
151 | 151 | ||
152 | let module = definition.module(db)?; | 152 | let module = definition.module(db)?; |
153 | let krate = module.krate(); | 153 | let krate = module.krate(); |
diff --git a/crates/ide/src/goto_definition.rs b/crates/ide/src/goto_definition.rs index 6986477a5..b71f4917c 100644 --- a/crates/ide/src/goto_definition.rs +++ b/crates/ide/src/goto_definition.rs | |||
@@ -102,7 +102,7 @@ fn extract_positioned_link_from_comment( | |||
102 | None => comment_range.end(), | 102 | None => comment_range.end(), |
103 | } | 103 | } |
104 | })?; | 104 | })?; |
105 | Some((def_link.to_string(), ns.clone())) | 105 | Some((def_link.to_string(), *ns)) |
106 | } | 106 | } |
107 | 107 | ||
108 | fn pick_best(tokens: TokenAtOffset<SyntaxToken>) -> Option<SyntaxToken> { | 108 | fn pick_best(tokens: TokenAtOffset<SyntaxToken>) -> Option<SyntaxToken> { |
diff --git a/crates/ide/src/syntax_highlighting/inject.rs b/crates/ide/src/syntax_highlighting/inject.rs index 8cdc3688f..4f825523c 100644 --- a/crates/ide/src/syntax_highlighting/inject.rs +++ b/crates/ide/src/syntax_highlighting/inject.rs | |||
@@ -56,7 +56,7 @@ pub(super) fn ra_fixture( | |||
56 | for range in inj.map_range_up(hl_range.range) { | 56 | for range in inj.map_range_up(hl_range.range) { |
57 | if let Some(range) = literal.map_range_up(range) { | 57 | if let Some(range) = literal.map_range_up(range) { |
58 | hl_range.range = range; | 58 | hl_range.range = range; |
59 | hl.add(hl_range.clone()); | 59 | hl.add(hl_range); |
60 | } | 60 | } |
61 | } | 61 | } |
62 | } | 62 | } |
diff --git a/crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs index 335e0ed95..596c536a7 100644 --- a/crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs +++ b/crates/ide_assists/src/handlers/extract_struct_from_enum_variant.rs | |||
@@ -145,11 +145,8 @@ fn insert_import( | |||
145 | variant_hir_name: &Name, | 145 | variant_hir_name: &Name, |
146 | ) -> Option<()> { | 146 | ) -> Option<()> { |
147 | let db = ctx.db(); | 147 | let db = ctx.db(); |
148 | let mod_path = module.find_use_path_prefixed( | 148 | let mod_path = |
149 | db, | 149 | module.find_use_path_prefixed(db, *enum_module_def, ctx.config.insert_use.prefix_kind); |
150 | enum_module_def.clone(), | ||
151 | ctx.config.insert_use.prefix_kind, | ||
152 | ); | ||
153 | if let Some(mut mod_path) = mod_path { | 150 | if let Some(mut mod_path) = mod_path { |
154 | mod_path.pop_segment(); | 151 | mod_path.pop_segment(); |
155 | mod_path.push_segment(variant_hir_name.clone()); | 152 | mod_path.push_segment(variant_hir_name.clone()); |
diff --git a/crates/ide_completion/src/completions/pattern.rs b/crates/ide_completion/src/completions/pattern.rs index 46cef58f0..476eecff0 100644 --- a/crates/ide_completion/src/completions/pattern.rs +++ b/crates/ide_completion/src/completions/pattern.rs | |||
@@ -26,11 +26,11 @@ pub(crate) fn complete_pattern(acc: &mut Completions, ctx: &CompletionContext) { | |||
26 | let add_resolution = match &res { | 26 | let add_resolution = match &res { |
27 | hir::ScopeDef::ModuleDef(def) => match def { | 27 | hir::ScopeDef::ModuleDef(def) => match def { |
28 | hir::ModuleDef::Adt(hir::Adt::Struct(strukt)) => { | 28 | hir::ModuleDef::Adt(hir::Adt::Struct(strukt)) => { |
29 | acc.add_struct_pat(ctx, strukt.clone(), Some(name.clone())); | 29 | acc.add_struct_pat(ctx, *strukt, Some(name.clone())); |
30 | true | 30 | true |
31 | } | 31 | } |
32 | hir::ModuleDef::Variant(variant) if !ctx.is_irrefutable_pat_binding => { | 32 | hir::ModuleDef::Variant(variant) if !ctx.is_irrefutable_pat_binding => { |
33 | acc.add_variant_pat(ctx, variant.clone(), Some(name.clone())); | 33 | acc.add_variant_pat(ctx, *variant, Some(name.clone())); |
34 | true | 34 | true |
35 | } | 35 | } |
36 | hir::ModuleDef::Adt(hir::Adt::Enum(..)) | 36 | hir::ModuleDef::Adt(hir::Adt::Enum(..)) |
diff --git a/crates/ide_completion/src/render.rs b/crates/ide_completion/src/render.rs index 4e4923e0d..12921e12b 100644 --- a/crates/ide_completion/src/render.rs +++ b/crates/ide_completion/src/render.rs | |||
@@ -81,7 +81,7 @@ impl<'a> RenderContext<'a> { | |||
81 | } | 81 | } |
82 | 82 | ||
83 | fn snippet_cap(&self) -> Option<SnippetCap> { | 83 | fn snippet_cap(&self) -> Option<SnippetCap> { |
84 | self.completion.config.snippet_cap.clone() | 84 | self.completion.config.snippet_cap |
85 | } | 85 | } |
86 | 86 | ||
87 | fn db(&self) -> &'a RootDatabase { | 87 | fn db(&self) -> &'a RootDatabase { |
diff --git a/crates/ide_ssr/src/lib.rs b/crates/ide_ssr/src/lib.rs index 00585f448..47434f4af 100644 --- a/crates/ide_ssr/src/lib.rs +++ b/crates/ide_ssr/src/lib.rs | |||
@@ -139,11 +139,8 @@ impl<'db> MatchFinder<'db> { | |||
139 | pub fn at_first_file(db: &'db ide_db::RootDatabase) -> Result<MatchFinder<'db>, SsrError> { | 139 | pub fn at_first_file(db: &'db ide_db::RootDatabase) -> Result<MatchFinder<'db>, SsrError> { |
140 | use ide_db::base_db::SourceDatabaseExt; | 140 | use ide_db::base_db::SourceDatabaseExt; |
141 | use ide_db::symbol_index::SymbolsDatabase; | 141 | use ide_db::symbol_index::SymbolsDatabase; |
142 | if let Some(first_file_id) = db | 142 | if let Some(first_file_id) = |
143 | .local_roots() | 143 | db.local_roots().iter().next().and_then(|root| db.source_root(*root).iter().next()) |
144 | .iter() | ||
145 | .next() | ||
146 | .and_then(|root| db.source_root(root.clone()).iter().next()) | ||
147 | { | 144 | { |
148 | Ok(MatchFinder::in_context( | 145 | Ok(MatchFinder::in_context( |
149 | db, | 146 | db, |
diff --git a/crates/ide_ssr/src/matching.rs b/crates/ide_ssr/src/matching.rs index e1adb381e..b3072fb9f 100644 --- a/crates/ide_ssr/src/matching.rs +++ b/crates/ide_ssr/src/matching.rs | |||
@@ -127,7 +127,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> { | |||
127 | restrict_range: &Option<FileRange>, | 127 | restrict_range: &Option<FileRange>, |
128 | sema: &'sema Semantics<'db, ide_db::RootDatabase>, | 128 | sema: &'sema Semantics<'db, ide_db::RootDatabase>, |
129 | ) -> Result<Match, MatchFailed> { | 129 | ) -> Result<Match, MatchFailed> { |
130 | let match_state = Matcher { sema, restrict_range: restrict_range.clone(), rule }; | 130 | let match_state = Matcher { sema, restrict_range: *restrict_range, rule }; |
131 | // First pass at matching, where we check that node types and idents match. | 131 | // First pass at matching, where we check that node types and idents match. |
132 | match_state.attempt_match_node(&mut Phase::First, &rule.pattern.node, code)?; | 132 | match_state.attempt_match_node(&mut Phase::First, &rule.pattern.node, code)?; |
133 | match_state.validate_range(&sema.original_range(code))?; | 133 | match_state.validate_range(&sema.original_range(code))?; |
diff --git a/crates/mbe/src/benchmark.rs b/crates/mbe/src/benchmark.rs index bd8ea6452..ba814a2e1 100644 --- a/crates/mbe/src/benchmark.rs +++ b/crates/mbe/src/benchmark.rs | |||
@@ -165,7 +165,7 @@ fn invocation_fixtures(rules: &FxHashMap<String, MacroRules>) -> Vec<(String, tt | |||
165 | } | 165 | } |
166 | Separator::Puncts(puncts) => { | 166 | Separator::Puncts(puncts) => { |
167 | for it in puncts { | 167 | for it in puncts { |
168 | parent.token_trees.push(tt::Leaf::Punct(it.clone()).into()) | 168 | parent.token_trees.push(tt::Leaf::Punct(*it).into()) |
169 | } | 169 | } |
170 | } | 170 | } |
171 | }; | 171 | }; |
@@ -174,8 +174,7 @@ fn invocation_fixtures(rules: &FxHashMap<String, MacroRules>) -> Vec<(String, tt | |||
174 | } | 174 | } |
175 | } | 175 | } |
176 | Op::Subtree { tokens, delimiter } => { | 176 | Op::Subtree { tokens, delimiter } => { |
177 | let mut subtree = | 177 | let mut subtree = tt::Subtree { delimiter: *delimiter, token_trees: Vec::new() }; |
178 | tt::Subtree { delimiter: delimiter.clone(), token_trees: Vec::new() }; | ||
179 | tokens.iter().for_each(|it| { | 178 | tokens.iter().for_each(|it| { |
180 | collect_from_op(it, &mut subtree, seed); | 179 | collect_from_op(it, &mut subtree, seed); |
181 | }); | 180 | }); |
diff --git a/crates/mbe/src/parser.rs b/crates/mbe/src/parser.rs index 8671322e1..7b5b8ec16 100644 --- a/crates/mbe/src/parser.rs +++ b/crates/mbe/src/parser.rs | |||
@@ -262,7 +262,7 @@ fn parse_repeat(src: &mut TtIter) -> Result<(Option<Separator>, RepeatKind), Par | |||
262 | if puncts.len() == 3 { | 262 | if puncts.len() == 3 { |
263 | return Err(ParseError::InvalidRepeat); | 263 | return Err(ParseError::InvalidRepeat); |
264 | } | 264 | } |
265 | puncts.push(punct.clone()) | 265 | puncts.push(*punct) |
266 | } | 266 | } |
267 | _ => return Err(ParseError::InvalidRepeat), | 267 | _ => return Err(ParseError::InvalidRepeat), |
268 | } | 268 | } |
diff --git a/crates/rust-analyzer/src/diagnostics/to_proto.rs b/crates/rust-analyzer/src/diagnostics/to_proto.rs index 0ad832c0e..76994de71 100644 --- a/crates/rust-analyzer/src/diagnostics/to_proto.rs +++ b/crates/rust-analyzer/src/diagnostics/to_proto.rs | |||
@@ -161,7 +161,7 @@ pub(crate) fn map_rust_diagnostic_to_lsp( | |||
161 | return Vec::new(); | 161 | return Vec::new(); |
162 | } | 162 | } |
163 | 163 | ||
164 | let severity = diagnostic_severity(config, rd.level.clone(), rd.code.clone()); | 164 | let severity = diagnostic_severity(config, rd.level, rd.code.clone()); |
165 | 165 | ||
166 | let mut source = String::from("rustc"); | 166 | let mut source = String::from("rustc"); |
167 | let mut code = rd.code.as_ref().map(|c| c.code.clone()); | 167 | let mut code = rd.code.as_ref().map(|c| c.code.clone()); |