diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-07-05 17:07:11 +0100 |
---|---|---|
committer | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-07-05 17:07:11 +0100 |
commit | feae74e02c4ed0a134b6d3f18dd5d79baff85c3d (patch) | |
tree | facf2c398e8dd428225a84455437abf81a478ee0 | |
parent | ec6f71576ace170fd306a68f77e5c5e9646d15be (diff) | |
parent | 001e34e6e31503195d176a349bc9476681c79e7f (diff) |
Merge #1493
1493: Clippy trivially_copy_pass_by_ref r=matklad a=kjeremy
Clippy says that this is more efficient.
Co-authored-by: Jeremy Kolb <[email protected]>
-rw-r--r-- | crates/ra_hir/src/adt.rs | 8 | ||||
-rw-r--r-- | crates/ra_hir/src/expr/validation.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/ids.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/infer.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/method_resolution.rs | 10 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/primitive.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/traits.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/impls.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/line_index_utils.rs | 4 | ||||
-rw-r--r-- | crates/ra_mbe/src/subtree_source.rs | 4 | ||||
-rw-r--r-- | crates/ra_mbe/src/tt_cursor.rs | 16 |
11 files changed, 30 insertions, 30 deletions
diff --git a/crates/ra_hir/src/adt.rs b/crates/ra_hir/src/adt.rs index 9c0c8fdd0..5a3ea5f55 100644 --- a/crates/ra_hir/src/adt.rs +++ b/crates/ra_hir/src/adt.rs | |||
@@ -34,8 +34,8 @@ impl AdtDef { | |||
34 | } | 34 | } |
35 | 35 | ||
36 | impl Struct { | 36 | impl Struct { |
37 | pub(crate) fn variant_data(&self, db: &impl DefDatabase) -> Arc<VariantData> { | 37 | pub(crate) fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> { |
38 | db.struct_data(*self).variant_data.clone() | 38 | db.struct_data(self).variant_data.clone() |
39 | } | 39 | } |
40 | } | 40 | } |
41 | 41 | ||
@@ -69,7 +69,7 @@ fn variants(enum_def: &ast::EnumDef) -> impl Iterator<Item = &ast::EnumVariant> | |||
69 | 69 | ||
70 | impl EnumVariant { | 70 | impl EnumVariant { |
71 | pub(crate) fn source_impl( | 71 | pub(crate) fn source_impl( |
72 | &self, | 72 | self, |
73 | db: &(impl DefDatabase + AstDatabase), | 73 | db: &(impl DefDatabase + AstDatabase), |
74 | ) -> Source<TreeArc<ast::EnumVariant>> { | 74 | ) -> Source<TreeArc<ast::EnumVariant>> { |
75 | let src = self.parent.source(db); | 75 | let src = self.parent.source(db); |
@@ -81,7 +81,7 @@ impl EnumVariant { | |||
81 | .to_owned(); | 81 | .to_owned(); |
82 | Source { file_id: src.file_id, ast } | 82 | Source { file_id: src.file_id, ast } |
83 | } | 83 | } |
84 | pub(crate) fn variant_data(&self, db: &impl DefDatabase) -> Arc<VariantData> { | 84 | pub(crate) fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> { |
85 | db.enum_data(self.parent).variants[self.id].variant_data.clone() | 85 | db.enum_data(self.parent).variants[self.id].variant_data.clone() |
86 | } | 86 | } |
87 | } | 87 | } |
diff --git a/crates/ra_hir/src/expr/validation.rs b/crates/ra_hir/src/expr/validation.rs index 8206dae2e..4e6131dce 100644 --- a/crates/ra_hir/src/expr/validation.rs +++ b/crates/ra_hir/src/expr/validation.rs | |||
@@ -31,7 +31,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
31 | let body = self.func.body(db); | 31 | let body = self.func.body(db); |
32 | for e in body.exprs() { | 32 | for e in body.exprs() { |
33 | if let (id, Expr::StructLit { path, fields, spread }) = e { | 33 | if let (id, Expr::StructLit { path, fields, spread }) = e { |
34 | self.validate_struct_literal(id, path, fields, spread, db); | 34 | self.validate_struct_literal(id, path, fields, *spread, db); |
35 | } | 35 | } |
36 | } | 36 | } |
37 | } | 37 | } |
@@ -41,7 +41,7 @@ impl<'a, 'b> ExprValidator<'a, 'b> { | |||
41 | id: ExprId, | 41 | id: ExprId, |
42 | _path: &Option<Path>, | 42 | _path: &Option<Path>, |
43 | fields: &[StructLitField], | 43 | fields: &[StructLitField], |
44 | spread: &Option<ExprId>, | 44 | spread: Option<ExprId>, |
45 | db: &impl HirDatabase, | 45 | db: &impl HirDatabase, |
46 | ) { | 46 | ) { |
47 | if spread.is_some() { | 47 | if spread.is_some() { |
diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs index bd1e2f2e6..5212b78ac 100644 --- a/crates/ra_hir/src/ids.rs +++ b/crates/ra_hir/src/ids.rs | |||
@@ -359,8 +359,8 @@ impl AstItemDef<ast::TypeAliasDef> for TypeAliasId { | |||
359 | } | 359 | } |
360 | 360 | ||
361 | impl MacroCallId { | 361 | impl MacroCallId { |
362 | pub fn debug_dump(&self, db: &impl AstDatabase) -> String { | 362 | pub fn debug_dump(self, db: &impl AstDatabase) -> String { |
363 | let loc = self.clone().loc(db); | 363 | let loc = self.loc(db); |
364 | let node = loc.ast_id.to_node(db); | 364 | let node = loc.ast_id.to_node(db); |
365 | let syntax_str = node.syntax().text().chunks().collect::<Vec<_>>().join(" "); | 365 | let syntax_str = node.syntax().text().chunks().collect::<Vec<_>>().join(" "); |
366 | 366 | ||
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs index 8322de0a8..a23daabc2 100644 --- a/crates/ra_hir/src/ty/infer.rs +++ b/crates/ra_hir/src/ty/infer.rs | |||
@@ -85,7 +85,7 @@ enum BindingMode { | |||
85 | } | 85 | } |
86 | 86 | ||
87 | impl BindingMode { | 87 | impl BindingMode { |
88 | pub fn convert(annotation: &BindingAnnotation) -> BindingMode { | 88 | pub fn convert(annotation: BindingAnnotation) -> BindingMode { |
89 | match annotation { | 89 | match annotation { |
90 | BindingAnnotation::Unannotated | BindingAnnotation::Mutable => BindingMode::Move, | 90 | BindingAnnotation::Unannotated | BindingAnnotation::Mutable => BindingMode::Move, |
91 | BindingAnnotation::Ref => BindingMode::Ref(Mutability::Shared), | 91 | BindingAnnotation::Ref => BindingMode::Ref(Mutability::Shared), |
@@ -778,7 +778,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
778 | let mode = if mode == &BindingAnnotation::Unannotated { | 778 | let mode = if mode == &BindingAnnotation::Unannotated { |
779 | default_bm | 779 | default_bm |
780 | } else { | 780 | } else { |
781 | BindingMode::convert(mode) | 781 | BindingMode::convert(*mode) |
782 | }; | 782 | }; |
783 | let inner_ty = if let Some(subpat) = subpat { | 783 | let inner_ty = if let Some(subpat) = subpat { |
784 | self.infer_pat(*subpat, expected, default_bm) | 784 | self.infer_pat(*subpat, expected, default_bm) |
diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs index bc890fe79..10a6e0b10 100644 --- a/crates/ra_hir/src/ty/method_resolution.rs +++ b/crates/ra_hir/src/ty/method_resolution.rs | |||
@@ -58,7 +58,7 @@ impl CrateImplBlocks { | |||
58 | 58 | ||
59 | pub fn lookup_impl_blocks_for_trait<'a>( | 59 | pub fn lookup_impl_blocks_for_trait<'a>( |
60 | &'a self, | 60 | &'a self, |
61 | tr: &Trait, | 61 | tr: Trait, |
62 | ) -> impl Iterator<Item = ImplBlock> + 'a { | 62 | ) -> impl Iterator<Item = ImplBlock> + 'a { |
63 | self.impls_by_trait.get(&tr).into_iter().flat_map(|i| i.iter()).map( | 63 | self.impls_by_trait.get(&tr).into_iter().flat_map(|i| i.iter()).map( |
64 | move |(module_id, impl_id)| { | 64 | move |(module_id, impl_id)| { |
@@ -68,8 +68,8 @@ impl CrateImplBlocks { | |||
68 | ) | 68 | ) |
69 | } | 69 | } |
70 | 70 | ||
71 | fn collect_recursive(&mut self, db: &impl HirDatabase, module: &Module) { | 71 | fn collect_recursive(&mut self, db: &impl HirDatabase, module: Module) { |
72 | let module_impl_blocks = db.impls_in_module(module.clone()); | 72 | let module_impl_blocks = db.impls_in_module(module); |
73 | 73 | ||
74 | for (impl_id, _) in module_impl_blocks.impls.iter() { | 74 | for (impl_id, _) in module_impl_blocks.impls.iter() { |
75 | let impl_block = ImplBlock::from_id(module_impl_blocks.module, impl_id); | 75 | let impl_block = ImplBlock::from_id(module_impl_blocks.module, impl_id); |
@@ -94,7 +94,7 @@ impl CrateImplBlocks { | |||
94 | } | 94 | } |
95 | 95 | ||
96 | for child in module.children(db) { | 96 | for child in module.children(db) { |
97 | self.collect_recursive(db, &child); | 97 | self.collect_recursive(db, child); |
98 | } | 98 | } |
99 | } | 99 | } |
100 | 100 | ||
@@ -108,7 +108,7 @@ impl CrateImplBlocks { | |||
108 | impls_by_trait: FxHashMap::default(), | 108 | impls_by_trait: FxHashMap::default(), |
109 | }; | 109 | }; |
110 | if let Some(module) = krate.root_module(db) { | 110 | if let Some(module) = krate.root_module(db) { |
111 | crate_impl_blocks.collect_recursive(db, &module); | 111 | crate_impl_blocks.collect_recursive(db, module); |
112 | } | 112 | } |
113 | Arc::new(crate_impl_blocks) | 113 | Arc::new(crate_impl_blocks) |
114 | } | 114 | } |
diff --git a/crates/ra_hir/src/ty/primitive.rs b/crates/ra_hir/src/ty/primitive.rs index 62b75b764..2c60fefd6 100644 --- a/crates/ra_hir/src/ty/primitive.rs +++ b/crates/ra_hir/src/ty/primitive.rs | |||
@@ -131,7 +131,7 @@ impl IntTy { | |||
131 | IntTy { signedness: Signedness::Unsigned, bitness: IntBitness::X128 } | 131 | IntTy { signedness: Signedness::Unsigned, bitness: IntBitness::X128 } |
132 | } | 132 | } |
133 | 133 | ||
134 | pub(crate) fn ty_to_string(&self) -> &'static str { | 134 | pub(crate) fn ty_to_string(self) -> &'static str { |
135 | match (self.signedness, self.bitness) { | 135 | match (self.signedness, self.bitness) { |
136 | (Signedness::Signed, IntBitness::Xsize) => "isize", | 136 | (Signedness::Signed, IntBitness::Xsize) => "isize", |
137 | (Signedness::Signed, IntBitness::X8) => "i8", | 137 | (Signedness::Signed, IntBitness::X8) => "i8", |
diff --git a/crates/ra_hir/src/ty/traits.rs b/crates/ra_hir/src/ty/traits.rs index 3c902451b..cff4de316 100644 --- a/crates/ra_hir/src/ty/traits.rs +++ b/crates/ra_hir/src/ty/traits.rs | |||
@@ -50,7 +50,7 @@ pub(crate) fn impls_for_trait_query( | |||
50 | impls.extend(db.impls_for_trait(dep.krate, trait_).iter()); | 50 | impls.extend(db.impls_for_trait(dep.krate, trait_).iter()); |
51 | } | 51 | } |
52 | let crate_impl_blocks = db.impls_in_crate(krate); | 52 | let crate_impl_blocks = db.impls_in_crate(krate); |
53 | impls.extend(crate_impl_blocks.lookup_impl_blocks_for_trait(&trait_)); | 53 | impls.extend(crate_impl_blocks.lookup_impl_blocks_for_trait(trait_)); |
54 | impls.into_iter().collect::<Vec<_>>().into() | 54 | impls.into_iter().collect::<Vec<_>>().into() |
55 | } | 55 | } |
56 | 56 | ||
diff --git a/crates/ra_ide_api/src/impls.rs b/crates/ra_ide_api/src/impls.rs index f8a62bd71..97615b01f 100644 --- a/crates/ra_ide_api/src/impls.rs +++ b/crates/ra_ide_api/src/impls.rs | |||
@@ -65,7 +65,7 @@ fn impls_for_trait( | |||
65 | 65 | ||
66 | Some( | 66 | Some( |
67 | impls | 67 | impls |
68 | .lookup_impl_blocks_for_trait(&tr) | 68 | .lookup_impl_blocks_for_trait(tr) |
69 | .map(|imp| NavigationTarget::from_impl_block(db, imp)) | 69 | .map(|imp| NavigationTarget::from_impl_block(db, imp)) |
70 | .collect(), | 70 | .collect(), |
71 | ) | 71 | ) |
diff --git a/crates/ra_ide_api/src/line_index_utils.rs b/crates/ra_ide_api/src/line_index_utils.rs index 8f63db5f1..534009b98 100644 --- a/crates/ra_ide_api/src/line_index_utils.rs +++ b/crates/ra_ide_api/src/line_index_utils.rs | |||
@@ -213,7 +213,7 @@ impl RunningLineCol { | |||
213 | self.col_adjust = TextUnit::from(0); | 213 | self.col_adjust = TextUnit::from(0); |
214 | } | 214 | } |
215 | 215 | ||
216 | fn adjust_col(&mut self, range: &TextRange) { | 216 | fn adjust_col(&mut self, range: TextRange) { |
217 | self.col_adjust += range.len() - TextUnit::from(1); | 217 | self.col_adjust += range.len() - TextUnit::from(1); |
218 | } | 218 | } |
219 | } | 219 | } |
@@ -244,7 +244,7 @@ pub fn translate_offset_with_edit( | |||
244 | let clamp = offset.min(x.start()); | 244 | let clamp = offset.min(x.start()); |
245 | return res.to_line_col(clamp); | 245 | return res.to_line_col(clamp); |
246 | } else { | 246 | } else { |
247 | res.adjust_col(x); | 247 | res.adjust_col(*x); |
248 | } | 248 | } |
249 | } | 249 | } |
250 | } | 250 | } |
diff --git a/crates/ra_mbe/src/subtree_source.rs b/crates/ra_mbe/src/subtree_source.rs index e1c6e7d91..6603ff34d 100644 --- a/crates/ra_mbe/src/subtree_source.rs +++ b/crates/ra_mbe/src/subtree_source.rs | |||
@@ -145,7 +145,7 @@ fn convert_ident(ident: &tt::Ident) -> TtToken { | |||
145 | TtToken { kind, is_joint_to_next: false, text: ident.text.clone() } | 145 | TtToken { kind, is_joint_to_next: false, text: ident.text.clone() } |
146 | } | 146 | } |
147 | 147 | ||
148 | fn convert_punct(p: &tt::Punct) -> TtToken { | 148 | fn convert_punct(p: tt::Punct) -> TtToken { |
149 | let kind = match p.char { | 149 | let kind = match p.char { |
150 | // lexer may produce compound tokens for these ones | 150 | // lexer may produce compound tokens for these ones |
151 | '.' => T![.], | 151 | '.' => T![.], |
@@ -167,6 +167,6 @@ fn convert_leaf(leaf: &tt::Leaf) -> TtToken { | |||
167 | match leaf { | 167 | match leaf { |
168 | tt::Leaf::Literal(l) => convert_literal(l), | 168 | tt::Leaf::Literal(l) => convert_literal(l), |
169 | tt::Leaf::Ident(ident) => convert_ident(ident), | 169 | tt::Leaf::Ident(ident) => convert_ident(ident), |
170 | tt::Leaf::Punct(punct) => convert_punct(punct), | 170 | tt::Leaf::Punct(punct) => convert_punct(*punct), |
171 | } | 171 | } |
172 | } | 172 | } |
diff --git a/crates/ra_mbe/src/tt_cursor.rs b/crates/ra_mbe/src/tt_cursor.rs index 8e360ce0f..468276397 100644 --- a/crates/ra_mbe/src/tt_cursor.rs +++ b/crates/ra_mbe/src/tt_cursor.rs | |||
@@ -170,20 +170,20 @@ impl<'a> TtCursor<'a> { | |||
170 | } | 170 | } |
171 | } | 171 | } |
172 | 172 | ||
173 | fn eat_punct3(&mut self, p: &tt::Punct) -> Option<SmallVec<[tt::Punct; 3]>> { | 173 | fn eat_punct3(&mut self, p: tt::Punct) -> Option<SmallVec<[tt::Punct; 3]>> { |
174 | let sec = *self.eat_punct()?; | 174 | let sec = *self.eat_punct()?; |
175 | let third = *self.eat_punct()?; | 175 | let third = *self.eat_punct()?; |
176 | Some(smallvec![*p, sec, third]) | 176 | Some(smallvec![p, sec, third]) |
177 | } | 177 | } |
178 | 178 | ||
179 | fn eat_punct2(&mut self, p: &tt::Punct) -> Option<SmallVec<[tt::Punct; 3]>> { | 179 | fn eat_punct2(&mut self, p: tt::Punct) -> Option<SmallVec<[tt::Punct; 3]>> { |
180 | let sec = *self.eat_punct()?; | 180 | let sec = *self.eat_punct()?; |
181 | Some(smallvec![*p, sec]) | 181 | Some(smallvec![p, sec]) |
182 | } | 182 | } |
183 | 183 | ||
184 | fn eat_multi_char_punct<'b, I>( | 184 | fn eat_multi_char_punct<'b, I>( |
185 | &mut self, | 185 | &mut self, |
186 | p: &tt::Punct, | 186 | p: tt::Punct, |
187 | iter: &mut TokenPeek<'b, I>, | 187 | iter: &mut TokenPeek<'b, I>, |
188 | ) -> Option<SmallVec<[tt::Punct; 3]>> | 188 | ) -> Option<SmallVec<[tt::Punct; 3]>> |
189 | where | 189 | where |
@@ -250,7 +250,7 @@ impl<'a> TtCursor<'a> { | |||
250 | // But at this phase, some punct still is jointed. | 250 | // But at this phase, some punct still is jointed. |
251 | // So we by pass that check here. | 251 | // So we by pass that check here. |
252 | let mut peekable = TokenPeek::new(self.subtree.token_trees[self.pos..].iter()); | 252 | let mut peekable = TokenPeek::new(self.subtree.token_trees[self.pos..].iter()); |
253 | let puncts = self.eat_multi_char_punct(punct, &mut peekable); | 253 | let puncts = self.eat_multi_char_punct(*punct, &mut peekable); |
254 | let puncts = puncts.unwrap_or_else(|| smallvec![*punct]); | 254 | let puncts = puncts.unwrap_or_else(|| smallvec![*punct]); |
255 | 255 | ||
256 | Some(crate::Separator::Puncts(puncts)) | 256 | Some(crate::Separator::Puncts(puncts)) |
@@ -292,7 +292,7 @@ where | |||
292 | TokenPeek { iter: itertools::multipeek(iter) } | 292 | TokenPeek { iter: itertools::multipeek(iter) } |
293 | } | 293 | } |
294 | 294 | ||
295 | pub fn current_punct2(&mut self, p: &tt::Punct) -> Option<((char, char), bool)> { | 295 | pub fn current_punct2(&mut self, p: tt::Punct) -> Option<((char, char), bool)> { |
296 | if p.spacing != tt::Spacing::Joint { | 296 | if p.spacing != tt::Spacing::Joint { |
297 | return None; | 297 | return None; |
298 | } | 298 | } |
@@ -302,7 +302,7 @@ where | |||
302 | Some(((p.char, p1.char), p1.spacing == tt::Spacing::Joint)) | 302 | Some(((p.char, p1.char), p1.spacing == tt::Spacing::Joint)) |
303 | } | 303 | } |
304 | 304 | ||
305 | pub fn current_punct3(&mut self, p: &tt::Punct) -> Option<((char, char, char), bool)> { | 305 | pub fn current_punct3(&mut self, p: tt::Punct) -> Option<((char, char, char), bool)> { |
306 | self.current_punct2(p).and_then(|((p0, p1), last_joint)| { | 306 | self.current_punct2(p).and_then(|((p0, p1), last_joint)| { |
307 | if !last_joint { | 307 | if !last_joint { |
308 | None | 308 | None |