From 012fec54dc508896493d5d3073b4786c93d66fe9 Mon Sep 17 00:00:00 2001 From: Muhammad Mominul Huque Date: Mon, 8 Jul 2019 03:29:38 +0600 Subject: Constify KnownName's --- crates/ra_hir/src/ty/infer.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'crates/ra_hir/src/ty/infer.rs') diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs index 973de70df..41980a325 100644 --- a/crates/ra_hir/src/ty/infer.rs +++ b/crates/ra_hir/src/ty/infer.rs @@ -40,6 +40,7 @@ use crate::{ PatId, Statement, UnaryOp, }, generics::{GenericParams, HasGenericParams}, + name::{SELF_TYPE, INTO_ITERATOR, ITEM, ITER, STD}, nameres::{Namespace, PerNs}, path::{GenericArg, GenericArgs, PathKind, PathSegment}, resolve::{ @@ -48,7 +49,7 @@ use crate::{ }, ty::infer::diagnostics::InferenceDiagnostic, type_ref::{Mutability, TypeRef}, - AdtDef, AsName, ConstData, DefWithBody, FnData, Function, HirDatabase, ImplItem, KnownName, + AdtDef, ConstData, DefWithBody, FnData, Function, HirDatabase, ImplItem, ModuleDef, Name, Path, StructField, }; @@ -842,7 +843,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { // Parent arguments are unknown, except for the receiver type if let Some(parent_generics) = def_generics.and_then(|p| p.parent_params.clone()) { for param in &parent_generics.params { - if param.name.as_known_name() == Some(crate::KnownName::SelfType) { + if param.name == SELF_TYPE { substs.push(receiver_ty.clone()); } else { substs.push(Ty::Unknown); @@ -1346,15 +1347,15 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { let into_iter_path = Path { kind: PathKind::Abs, segments: vec![ - PathSegment { name: KnownName::Std.as_name(), args_and_bindings: None }, - PathSegment { name: KnownName::Iter.as_name(), args_and_bindings: None }, - PathSegment { name: KnownName::IntoIterator.as_name(), args_and_bindings: None }, + PathSegment { name: STD, args_and_bindings: None }, + PathSegment { name: ITER, args_and_bindings: None }, + PathSegment { name: INTO_ITERATOR, args_and_bindings: None }, ], }; match self.resolver.resolve_path_segments(self.db, &into_iter_path).into_fully_resolved() { PerNs { types: Some(Def(Trait(trait_))), .. } => { - Some(trait_.associated_type_by_name(self.db, KnownName::Item.as_name())?) + Some(trait_.associated_type_by_name(self.db, ITEM)?) } _ => None, } -- cgit v1.2.3 From 09b72489dd085dadce94b454408d18a36abb1681 Mon Sep 17 00:00:00 2001 From: Muhammad Mominul Huque Date: Mon, 8 Jul 2019 04:09:35 +0600 Subject: cargo format --- crates/ra_hir/src/ty/infer.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'crates/ra_hir/src/ty/infer.rs') diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs index 41980a325..52a49070a 100644 --- a/crates/ra_hir/src/ty/infer.rs +++ b/crates/ra_hir/src/ty/infer.rs @@ -40,7 +40,7 @@ use crate::{ PatId, Statement, UnaryOp, }, generics::{GenericParams, HasGenericParams}, - name::{SELF_TYPE, INTO_ITERATOR, ITEM, ITER, STD}, + name::{INTO_ITERATOR, ITEM, ITER, SELF_TYPE, STD}, nameres::{Namespace, PerNs}, path::{GenericArg, GenericArgs, PathKind, PathSegment}, resolve::{ @@ -49,8 +49,8 @@ use crate::{ }, ty::infer::diagnostics::InferenceDiagnostic, type_ref::{Mutability, TypeRef}, - AdtDef, ConstData, DefWithBody, FnData, Function, HirDatabase, ImplItem, - ModuleDef, Name, Path, StructField, + AdtDef, ConstData, DefWithBody, FnData, Function, HirDatabase, ImplItem, ModuleDef, Name, Path, + StructField, }; mod unify; -- cgit v1.2.3