aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/infer.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-07-08 09:29:19 +0100
committerbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-07-08 09:29:19 +0100
commit5b19825e376b67aabbe8d5b163bf69b1acd92f04 (patch)
treebdf8054c58b9dba7116473ae4b0a772851a27c0c /crates/ra_hir/src/ty/infer.rs
parenta4316d6c63486d718f4d2e56d151180ef40ff0a1 (diff)
parent09b72489dd085dadce94b454408d18a36abb1681 (diff)
Merge #1507
1507: Constify KnownName's r=matklad a=mominul Closes #1503 Co-authored-by: Muhammad Mominul Huque <[email protected]>
Diffstat (limited to 'crates/ra_hir/src/ty/infer.rs')
-rw-r--r--crates/ra_hir/src/ty/infer.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs
index 973de70df..52a49070a 100644
--- a/crates/ra_hir/src/ty/infer.rs
+++ b/crates/ra_hir/src/ty/infer.rs
@@ -40,6 +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 nameres::{Namespace, PerNs}, 44 nameres::{Namespace, PerNs},
44 path::{GenericArg, GenericArgs, PathKind, PathSegment}, 45 path::{GenericArg, GenericArgs, PathKind, PathSegment},
45 resolve::{ 46 resolve::{
@@ -48,8 +49,8 @@ use crate::{
48 }, 49 },
49 ty::infer::diagnostics::InferenceDiagnostic, 50 ty::infer::diagnostics::InferenceDiagnostic,
50 type_ref::{Mutability, TypeRef}, 51 type_ref::{Mutability, TypeRef},
51 AdtDef, AsName, ConstData, DefWithBody, FnData, Function, HirDatabase, ImplItem, KnownName, 52 AdtDef, ConstData, DefWithBody, FnData, Function, HirDatabase, ImplItem, ModuleDef, Name, Path,
52 ModuleDef, Name, Path, StructField, 53 StructField,
53}; 54};
54 55
55mod unify; 56mod unify;
@@ -842,7 +843,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
842 // Parent arguments are unknown, except for the receiver type 843 // Parent arguments are unknown, except for the receiver type
843 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()) {
844 for param in &parent_generics.params { 845 for param in &parent_generics.params {
845 if param.name.as_known_name() == Some(crate::KnownName::SelfType) { 846 if param.name == SELF_TYPE {
846 substs.push(receiver_ty.clone()); 847 substs.push(receiver_ty.clone());
847 } else { 848 } else {
848 substs.push(Ty::Unknown); 849 substs.push(Ty::Unknown);
@@ -1346,15 +1347,15 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
1346 let into_iter_path = Path { 1347 let into_iter_path = Path {
1347 kind: PathKind::Abs, 1348 kind: PathKind::Abs,
1348 segments: vec![ 1349 segments: vec![
1349 PathSegment { name: KnownName::Std.as_name(), args_and_bindings: None }, 1350 PathSegment { name: STD, args_and_bindings: None },
1350 PathSegment { name: KnownName::Iter.as_name(), args_and_bindings: None }, 1351 PathSegment { name: ITER, args_and_bindings: None },
1351 PathSegment { name: KnownName::IntoIterator.as_name(), args_and_bindings: None }, 1352 PathSegment { name: INTO_ITERATOR, args_and_bindings: None },
1352 ], 1353 ],
1353 }; 1354 };
1354 1355
1355 match self.resolver.resolve_path_segments(self.db, &into_iter_path).into_fully_resolved() { 1356 match self.resolver.resolve_path_segments(self.db, &into_iter_path).into_fully_resolved() {
1356 PerNs { types: Some(Def(Trait(trait_))), .. } => { 1357 PerNs { types: Some(Def(Trait(trait_))), .. } => {
1357 Some(trait_.associated_type_by_name(self.db, KnownName::Item.as_name())?) 1358 Some(trait_.associated_type_by_name(self.db, ITEM)?)
1358 } 1359 }
1359 _ => None, 1360 _ => None,
1360 } 1361 }