aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/infer/path.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-02-18 14:37:34 +0000
committerGitHub <[email protected]>2020-02-18 14:37:34 +0000
commitcecf25b72f2af84fc1535cf52d6f3c1b52802565 (patch)
tree37c8dde0a459caacae6629da08d86be270469ef5 /crates/ra_hir_ty/src/infer/path.rs
parenteab80cd961919b9321e1d34343ae3f3adb0502e5 (diff)
parentf6816c253b96e8436f1156d6bd6b0942ee9fb4d3 (diff)
Merge #3220
3220: Fix clippy warnings, update Cargo.toml versions r=matklad a=SomeoneToIgnore In the `cargo xtask lint` ouptut, there were two interesting Clippy warnings that might be interesting to investigate further: * warning: this argument (4 byte) is passed by reference, but would be more efficient if passed by value (limit: 8 byte) * warning: large size difference between variants Co-authored-by: Kirill Bulatov <[email protected]>
Diffstat (limited to 'crates/ra_hir_ty/src/infer/path.rs')
-rw-r--r--crates/ra_hir_ty/src/infer/path.rs47
1 files changed, 24 insertions, 23 deletions
diff --git a/crates/ra_hir_ty/src/infer/path.rs b/crates/ra_hir_ty/src/infer/path.rs
index 686ce7a21..471d60342 100644
--- a/crates/ra_hir_ty/src/infer/path.rs
+++ b/crates/ra_hir_ty/src/infer/path.rs
@@ -104,8 +104,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
104 let segment = 104 let segment =
105 remaining_segments.last().expect("there should be at least one segment here"); 105 remaining_segments.last().expect("there should be at least one segment here");
106 let ctx = crate::lower::TyLoweringContext::new(self.db, &self.resolver); 106 let ctx = crate::lower::TyLoweringContext::new(self.db, &self.resolver);
107 let trait_ref = 107 let trait_ref = TraitRef::from_resolved_path(&ctx, trait_, resolved_segment, None);
108 TraitRef::from_resolved_path(&ctx, trait_.into(), resolved_segment, None);
109 self.resolve_trait_assoc_item(trait_ref, segment, id) 108 self.resolve_trait_assoc_item(trait_ref, segment, id)
110 } 109 }
111 (def, _) => { 110 (def, _) => {
@@ -144,30 +143,32 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
144 id: ExprOrPatId, 143 id: ExprOrPatId,
145 ) -> Option<(ValueNs, Option<Substs>)> { 144 ) -> Option<(ValueNs, Option<Substs>)> {
146 let trait_ = trait_ref.trait_; 145 let trait_ = trait_ref.trait_;
147 let item = self 146 let item =
148 .db 147 self.db.trait_data(trait_).items.iter().map(|(_name, id)| (*id)).find_map(|item| {
149 .trait_data(trait_) 148 match item {
150 .items 149 AssocItemId::FunctionId(func) => {
151 .iter() 150 if segment.name == &self.db.function_data(func).name {
152 .map(|(_name, id)| (*id).into()) 151 Some(AssocItemId::FunctionId(func))
153 .find_map(|item| match item { 152 } else {
154 AssocItemId::FunctionId(func) => { 153 None
155 if segment.name == &self.db.function_data(func).name { 154 }
156 Some(AssocItemId::FunctionId(func))
157 } else {
158 None
159 } 155 }
160 }
161 156
162 AssocItemId::ConstId(konst) => { 157 AssocItemId::ConstId(konst) => {
163 if self.db.const_data(konst).name.as_ref().map_or(false, |n| n == segment.name) 158 if self
164 { 159 .db
165 Some(AssocItemId::ConstId(konst)) 160 .const_data(konst)
166 } else { 161 .name
167 None 162 .as_ref()
163 .map_or(false, |n| n == segment.name)
164 {
165 Some(AssocItemId::ConstId(konst))
166 } else {
167 None
168 }
168 } 169 }
170 AssocItemId::TypeAliasId(_) => None,
169 } 171 }
170 AssocItemId::TypeAliasId(_) => None,
171 })?; 172 })?;
172 let def = match item { 173 let def = match item {
173 AssocItemId::FunctionId(f) => ValueNs::FunctionId(f), 174 AssocItemId::FunctionId(f) => ValueNs::FunctionId(f),
@@ -233,7 +234,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
233 AssocContainerId::ContainerId(_) => None, 234 AssocContainerId::ContainerId(_) => None,
234 }; 235 };
235 236
236 self.write_assoc_resolution(id, item.into()); 237 self.write_assoc_resolution(id, item);
237 Some((def, substs)) 238 Some((def, substs))
238 }, 239 },
239 ) 240 )