aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ty.rs')
-rw-r--r--crates/ra_hir/src/ty.rs25
1 files changed, 15 insertions, 10 deletions
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs
index 2a2dc26b4..680ddc2f9 100644
--- a/crates/ra_hir/src/ty.rs
+++ b/crates/ra_hir/src/ty.rs
@@ -19,14 +19,16 @@ use std::sync::Arc;
19use std::{fmt, iter, mem}; 19use std::{fmt, iter, mem};
20 20
21use hir_def::{ 21use hir_def::{
22 generics::GenericParams, AdtId, ContainerId, DefWithBodyId, GenericDefId, HasModule, Lookup, 22 expr::ExprId, generics::GenericParams, type_ref::Mutability, AdtId, ContainerId, DefWithBodyId,
23 TraitId, TypeAliasId, 23 GenericDefId, HasModule, Lookup, TraitId, TypeAliasId,
24}; 24};
25use ra_db::{impl_intern_key, salsa}; 25use ra_db::{impl_intern_key, salsa};
26 26
27use crate::{ 27use crate::{
28 db::HirDatabase, expr::ExprId, util::make_mut_slice, Adt, Crate, FloatTy, IntTy, Mutability, 28 db::HirDatabase,
29 Name, Trait, Uncertain, 29 ty::primitive::{FloatTy, IntTy, Uncertain},
30 util::make_mut_slice,
31 Adt, Crate, Name,
30}; 32};
31use display::{HirDisplay, HirFormatter}; 33use display::{HirDisplay, HirFormatter};
32 34
@@ -35,8 +37,8 @@ pub(crate) use infer::{infer_query, InferTy, InferenceResult};
35pub use lower::CallableDef; 37pub use lower::CallableDef;
36pub(crate) use lower::{ 38pub(crate) use lower::{
37 callable_item_sig, field_types_query, generic_defaults_query, 39 callable_item_sig, field_types_query, generic_defaults_query,
38 generic_predicates_for_param_query, generic_predicates_query, type_for_def, Namespace, 40 generic_predicates_for_param_query, generic_predicates_query, ty_query, value_ty_query,
39 TypableDef, 41 TyDefId, TypableDef, ValueTyDefId,
40}; 42};
41pub(crate) use traits::{InEnvironment, Obligation, ProjectionPredicate, TraitEnvironment}; 43pub(crate) use traits::{InEnvironment, Obligation, ProjectionPredicate, TraitEnvironment};
42 44
@@ -445,7 +447,7 @@ impl Deref for Substs {
445#[derive(Clone, PartialEq, Eq, Debug, Hash)] 447#[derive(Clone, PartialEq, Eq, Debug, Hash)]
446pub struct TraitRef { 448pub struct TraitRef {
447 /// FIXME name? 449 /// FIXME name?
448 pub trait_: Trait, 450 pub trait_: TraitId,
449 pub substs: Substs, 451 pub substs: Substs,
450} 452}
451 453
@@ -676,7 +678,7 @@ impl Ty {
676 } 678 }
677 679
678 /// If this is an `impl Trait` or `dyn Trait`, returns that trait. 680 /// If this is an `impl Trait` or `dyn Trait`, returns that trait.
679 pub fn inherent_trait(&self) -> Option<Trait> { 681 pub fn inherent_trait(&self) -> Option<TraitId> {
680 match self { 682 match self {
681 Ty::Dyn(predicates) | Ty::Opaque(predicates) => { 683 Ty::Dyn(predicates) | Ty::Opaque(predicates) => {
682 predicates.iter().find_map(|pred| match pred { 684 predicates.iter().find_map(|pred| match pred {
@@ -988,7 +990,10 @@ impl HirDisplay for Ty {
988 write!( 990 write!(
989 f, 991 f,
990 "{}", 992 "{}",
991 trait_ref.trait_.name(f.db).unwrap_or_else(Name::missing) 993 f.db.trait_data(trait_ref.trait_)
994 .name
995 .clone()
996 .unwrap_or_else(Name::missing)
992 )?; 997 )?;
993 if trait_ref.substs.len() > 1 { 998 if trait_ref.substs.len() > 1 {
994 write!(f, "<")?; 999 write!(f, "<")?;
@@ -1049,7 +1054,7 @@ impl TraitRef {
1049 } else { 1054 } else {
1050 write!(f, ": ")?; 1055 write!(f, ": ")?;
1051 } 1056 }
1052 write!(f, "{}", self.trait_.name(f.db).unwrap_or_else(Name::missing))?; 1057 write!(f, "{}", f.db.trait_data(self.trait_).name.clone().unwrap_or_else(Name::missing))?;
1053 if self.substs.len() > 1 { 1058 if self.substs.len() > 1 {
1054 write!(f, "<")?; 1059 write!(f, "<")?;
1055 f.write_joined(&self.substs[1..], ", ")?; 1060 f.write_joined(&self.substs[1..], ", ")?;