aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-07-05 17:07:11 +0100
committerbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-07-05 17:07:11 +0100
commitfeae74e02c4ed0a134b6d3f18dd5d79baff85c3d (patch)
treefacf2c398e8dd428225a84455437abf81a478ee0 /crates/ra_hir/src
parentec6f71576ace170fd306a68f77e5c5e9646d15be (diff)
parent001e34e6e31503195d176a349bc9476681c79e7f (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]>
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/adt.rs8
-rw-r--r--crates/ra_hir/src/expr/validation.rs4
-rw-r--r--crates/ra_hir/src/ids.rs4
-rw-r--r--crates/ra_hir/src/ty/infer.rs4
-rw-r--r--crates/ra_hir/src/ty/method_resolution.rs10
-rw-r--r--crates/ra_hir/src/ty/primitive.rs2
-rw-r--r--crates/ra_hir/src/ty/traits.rs2
7 files changed, 17 insertions, 17 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
36impl Struct { 36impl 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
70impl EnumVariant { 70impl 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
361impl MacroCallId { 361impl 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
87impl BindingMode { 87impl 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