aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty
diff options
context:
space:
mode:
authoruHOOCCOOHu <[email protected]>2019-09-15 13:14:33 +0100
committeruHOOCCOOHu <[email protected]>2019-09-15 13:14:33 +0100
commit7ed3be32916facf3b709d5277381408cd3ec134a (patch)
tree7ac9169b41465315ca1c5541c096ea61ac789357 /crates/ra_hir/src/ty
parentde9670fe456d89f97e8044d4e0919d2c16d1087f (diff)
Define known paths and group names
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r--crates/ra_hir/src/ty/autoderef.rs2
-rw-r--r--crates/ra_hir/src/ty/infer.rs37
2 files changed, 13 insertions, 26 deletions
diff --git a/crates/ra_hir/src/ty/autoderef.rs b/crates/ra_hir/src/ty/autoderef.rs
index 5ba7cf2e0..94f8ecdc9 100644
--- a/crates/ra_hir/src/ty/autoderef.rs
+++ b/crates/ra_hir/src/ty/autoderef.rs
@@ -42,7 +42,7 @@ fn deref_by_trait(
42 crate::lang_item::LangItemTarget::Trait(t) => t, 42 crate::lang_item::LangItemTarget::Trait(t) => t,
43 _ => return None, 43 _ => return None,
44 }; 44 };
45 let target = deref_trait.associated_type_by_name(db, &name::TARGET)?; 45 let target = deref_trait.associated_type_by_name(db, &name::TARGET_TYPE)?;
46 46
47 if target.generic_params(db).count_params_including_parent() != 1 { 47 if target.generic_params(db).count_params_including_parent() != 1 {
48 // the Target type + Deref trait should only have one generic parameter, 48 // the Target type + Deref trait should only have one generic parameter,
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs
index 3981de829..785499f77 100644
--- a/crates/ra_hir/src/ty/infer.rs
+++ b/crates/ra_hir/src/ty/infer.rs
@@ -44,7 +44,7 @@ use crate::{
44 generics::{GenericParams, HasGenericParams}, 44 generics::{GenericParams, HasGenericParams},
45 name, 45 name,
46 nameres::Namespace, 46 nameres::Namespace,
47 path::{GenericArg, GenericArgs, PathKind}, 47 path::{known, GenericArg, GenericArgs},
48 resolve::{ResolveValueResult, Resolver, TypeNs, ValueNs}, 48 resolve::{ResolveValueResult, Resolver, TypeNs, ValueNs},
49 ty::infer::diagnostics::InferenceDiagnostic, 49 ty::infer::diagnostics::InferenceDiagnostic,
50 type_ref::{Mutability, TypeRef}, 50 type_ref::{Mutability, TypeRef},
@@ -1442,39 +1442,26 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
1442 } 1442 }
1443 1443
1444 fn resolve_into_iter_item(&self) -> Option<TypeAlias> { 1444 fn resolve_into_iter_item(&self) -> Option<TypeAlias> {
1445 let into_iter_path = Path::from_simple_segments( 1445 let path = known::std_iter_into_iterator();
1446 PathKind::Abs, 1446 let trait_ = self.resolver.resolve_known_trait(self.db, &path)?;
1447 vec![name::STD, name::ITER, name::INTO_ITERATOR], 1447 trait_.associated_type_by_name(self.db, &name::ITEM_TYPE)
1448 );
1449
1450 let trait_ = self.resolver.resolve_known_trait(self.db, &into_iter_path)?;
1451 trait_.associated_type_by_name(self.db, &name::ITEM)
1452 } 1448 }
1453 1449
1454 fn resolve_ops_try_ok(&self) -> Option<TypeAlias> { 1450 fn resolve_ops_try_ok(&self) -> Option<TypeAlias> {
1455 let ops_try_path = 1451 let path = known::std_ops_try();
1456 Path::from_simple_segments(PathKind::Abs, vec![name::STD, name::OPS, name::TRY]); 1452 let trait_ = self.resolver.resolve_known_trait(self.db, &path)?;
1457 1453 trait_.associated_type_by_name(self.db, &name::OK_TYPE)
1458 let trait_ = self.resolver.resolve_known_trait(self.db, &ops_try_path)?;
1459 trait_.associated_type_by_name(self.db, &name::OK)
1460 } 1454 }
1461 1455
1462 fn resolve_future_future_output(&self) -> Option<TypeAlias> { 1456 fn resolve_future_future_output(&self) -> Option<TypeAlias> {
1463 let future_future_path = Path::from_simple_segments( 1457 let path = known::std_future_future();
1464 PathKind::Abs, 1458 let trait_ = self.resolver.resolve_known_trait(self.db, &path)?;
1465 vec![name::STD, name::FUTURE_MOD, name::FUTURE_TYPE], 1459 trait_.associated_type_by_name(self.db, &name::OUTPUT_TYPE)
1466 );
1467
1468 let trait_ = self.resolver.resolve_known_trait(self.db, &future_future_path)?;
1469 trait_.associated_type_by_name(self.db, &name::OUTPUT)
1470 } 1460 }
1471 1461
1472 fn resolve_boxed_box(&self) -> Option<Adt> { 1462 fn resolve_boxed_box(&self) -> Option<Adt> {
1473 let boxed_box_path = Path::from_simple_segments( 1463 let path = known::std_boxed_box();
1474 PathKind::Abs, 1464 let struct_ = self.resolver.resolve_known_struct(self.db, &path)?;
1475 vec![name::STD, name::BOXED_MOD, name::BOX_TYPE],
1476 );
1477 let struct_ = self.resolver.resolve_known_struct(self.db, &boxed_box_path)?;
1478 Some(Adt::Struct(struct_)) 1465 Some(Adt::Struct(struct_))
1479 } 1466 }
1480} 1467}