diff options
-rw-r--r-- | crates/ra_hir/src/ty/infer.rs | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs index 2f1c50355..827addddd 100644 --- a/crates/ra_hir/src/ty/infer.rs +++ b/crates/ra_hir/src/ty/infer.rs | |||
@@ -40,7 +40,7 @@ use crate::{ | |||
40 | PatId, Statement, UnaryOp, | 40 | PatId, Statement, UnaryOp, |
41 | }, | 41 | }, |
42 | generics::{GenericParams, HasGenericParams}, | 42 | generics::{GenericParams, HasGenericParams}, |
43 | name::{INTO_ITERATOR, ITEM, ITER, SELF_TYPE, STD}, | 43 | name, |
44 | nameres::{Namespace, PerNs}, | 44 | nameres::{Namespace, PerNs}, |
45 | path::{GenericArg, GenericArgs, PathKind, PathSegment}, | 45 | path::{GenericArg, GenericArgs, PathKind, PathSegment}, |
46 | resolve::{ | 46 | resolve::{ |
@@ -843,7 +843,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
843 | // Parent arguments are unknown, except for the receiver type | 843 | // Parent arguments are unknown, except for the receiver type |
844 | if let Some(parent_generics) = def_generics.and_then(|p| p.parent_params.clone()) { | 844 | if let Some(parent_generics) = def_generics.and_then(|p| p.parent_params.clone()) { |
845 | for param in &parent_generics.params { | 845 | for param in &parent_generics.params { |
846 | if param.name == SELF_TYPE { | 846 | if param.name == name::SELF_TYPE { |
847 | substs.push(receiver_ty.clone()); | 847 | substs.push(receiver_ty.clone()); |
848 | } else { | 848 | } else { |
849 | substs.push(Ty::Unknown); | 849 | substs.push(Ty::Unknown); |
@@ -1362,35 +1362,33 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
1362 | let into_iter_path = Path { | 1362 | let into_iter_path = Path { |
1363 | kind: PathKind::Abs, | 1363 | kind: PathKind::Abs, |
1364 | segments: vec![ | 1364 | segments: vec![ |
1365 | PathSegment { name: STD, args_and_bindings: None }, | 1365 | PathSegment { name: name::STD, args_and_bindings: None }, |
1366 | PathSegment { name: ITER, args_and_bindings: None }, | 1366 | PathSegment { name: name::ITER, args_and_bindings: None }, |
1367 | PathSegment { name: INTO_ITERATOR, args_and_bindings: None }, | 1367 | PathSegment { name: name::INTO_ITERATOR, args_and_bindings: None }, |
1368 | ], | 1368 | ], |
1369 | }; | 1369 | }; |
1370 | 1370 | ||
1371 | match self.resolver.resolve_path_segments(self.db, &into_iter_path).into_fully_resolved() { | 1371 | match self.resolver.resolve_path_segments(self.db, &into_iter_path).into_fully_resolved() { |
1372 | PerNs { types: Some(Def(Trait(trait_))), .. } => { | 1372 | PerNs { types: Some(Def(Trait(trait_))), .. } => { |
1373 | Some(trait_.associated_type_by_name(self.db, ITEM)?) | 1373 | Some(trait_.associated_type_by_name(self.db, name::ITEM)?) |
1374 | } | 1374 | } |
1375 | _ => None, | 1375 | _ => None, |
1376 | } | 1376 | } |
1377 | } | 1377 | } |
1378 | 1378 | ||
1379 | fn resolve_ops_try_ok(&self) -> Option<TypeAlias> { | 1379 | fn resolve_ops_try_ok(&self) -> Option<TypeAlias> { |
1380 | use crate::name::{OK, OPS, TRY}; | ||
1381 | |||
1382 | let ops_try_path = Path { | 1380 | let ops_try_path = Path { |
1383 | kind: PathKind::Abs, | 1381 | kind: PathKind::Abs, |
1384 | segments: vec![ | 1382 | segments: vec![ |
1385 | PathSegment { name: STD, args_and_bindings: None }, | 1383 | PathSegment { name: name::STD, args_and_bindings: None }, |
1386 | PathSegment { name: OPS, args_and_bindings: None }, | 1384 | PathSegment { name: name::OPS, args_and_bindings: None }, |
1387 | PathSegment { name: TRY, args_and_bindings: None }, | 1385 | PathSegment { name: name::TRY, args_and_bindings: None }, |
1388 | ], | 1386 | ], |
1389 | }; | 1387 | }; |
1390 | 1388 | ||
1391 | match self.resolver.resolve_path_segments(self.db, &ops_try_path).into_fully_resolved() { | 1389 | match self.resolver.resolve_path_segments(self.db, &ops_try_path).into_fully_resolved() { |
1392 | PerNs { types: Some(Def(Trait(trait_))), .. } => { | 1390 | PerNs { types: Some(Def(Trait(trait_))), .. } => { |
1393 | Some(trait_.associated_type_by_name(self.db, OK)?) | 1391 | Some(trait_.associated_type_by_name(self.db, name::OK)?) |
1394 | } | 1392 | } |
1395 | _ => None, | 1393 | _ => None, |
1396 | } | 1394 | } |