diff options
author | Aleksey Kladov <[email protected]> | 2019-11-25 15:31:48 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-11-25 15:31:48 +0000 |
commit | 3e32ac4f866e2b9430dd1e91b2c7fa3824c646a9 (patch) | |
tree | 67c6c2d2ddc939da2bb3e3e6f0e5b87b53215da0 /crates/ra_hir/src | |
parent | ecd1204804a2a3c8b9b98e4b9d18feef06ab51c7 (diff) |
More ids in Ty
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 8 | ||||
-rw-r--r-- | crates/ra_hir/src/ty.rs | 11 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/infer/expr.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/traits.rs | 5 |
4 files changed, 13 insertions, 17 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index ae730beb5..f7fc80d4e 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -538,14 +538,6 @@ pub enum DefWithBody { | |||
538 | impl_froms!(DefWithBody: Function, Const, Static); | 538 | impl_froms!(DefWithBody: Function, Const, Static); |
539 | 539 | ||
540 | impl DefWithBody { | 540 | impl DefWithBody { |
541 | pub(crate) fn krate(self, db: &impl HirDatabase) -> Option<Crate> { | ||
542 | match self { | ||
543 | DefWithBody::Const(c) => c.krate(db), | ||
544 | DefWithBody::Function(f) => f.krate(db), | ||
545 | DefWithBody::Static(s) => s.krate(db), | ||
546 | } | ||
547 | } | ||
548 | |||
549 | pub fn module(self, db: &impl HirDatabase) -> Module { | 541 | pub fn module(self, db: &impl HirDatabase) -> Module { |
550 | match self { | 542 | match self { |
551 | DefWithBody::Const(c) => c.module(db), | 543 | DefWithBody::Const(c) => c.module(db), |
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs index 3cbcbd1d0..bac21732e 100644 --- a/crates/ra_hir/src/ty.rs +++ b/crates/ra_hir/src/ty.rs | |||
@@ -17,12 +17,12 @@ use std::ops::Deref; | |||
17 | use std::sync::Arc; | 17 | use std::sync::Arc; |
18 | use std::{fmt, iter, mem}; | 18 | use std::{fmt, iter, mem}; |
19 | 19 | ||
20 | use hir_def::{generics::GenericParams, AdtId, GenericDefId}; | 20 | use hir_def::{generics::GenericParams, AdtId, DefWithBodyId, GenericDefId}; |
21 | use ra_db::{impl_intern_key, salsa}; | 21 | use ra_db::{impl_intern_key, salsa}; |
22 | 22 | ||
23 | use crate::{ | 23 | use crate::{ |
24 | db::HirDatabase, expr::ExprId, util::make_mut_slice, Adt, Crate, DefWithBody, FloatTy, IntTy, | 24 | db::HirDatabase, expr::ExprId, util::make_mut_slice, Adt, Crate, FloatTy, IntTy, Mutability, |
25 | Mutability, Name, Trait, TypeAlias, Uncertain, | 25 | Name, Trait, TypeAlias, Uncertain, |
26 | }; | 26 | }; |
27 | use display::{HirDisplay, HirFormatter}; | 27 | use display::{HirDisplay, HirFormatter}; |
28 | 28 | ||
@@ -113,7 +113,7 @@ pub enum TypeCtor { | |||
113 | /// | 113 | /// |
114 | /// The closure signature is stored in a `FnPtr` type in the first type | 114 | /// The closure signature is stored in a `FnPtr` type in the first type |
115 | /// parameter. | 115 | /// parameter. |
116 | Closure { def: DefWithBody, expr: ExprId }, | 116 | Closure { def: DefWithBodyId, expr: ExprId }, |
117 | } | 117 | } |
118 | 118 | ||
119 | /// This exists just for Chalk, because Chalk just has a single `StructId` where | 119 | /// This exists just for Chalk, because Chalk just has a single `StructId` where |
@@ -169,7 +169,8 @@ impl TypeCtor { | |||
169 | | TypeCtor::Ref(_) | 169 | | TypeCtor::Ref(_) |
170 | | TypeCtor::FnPtr { .. } | 170 | | TypeCtor::FnPtr { .. } |
171 | | TypeCtor::Tuple { .. } => None, | 171 | | TypeCtor::Tuple { .. } => None, |
172 | TypeCtor::Closure { def, .. } => def.krate(db), | 172 | // Closure's krate is irrelevant for coherence I would think? |
173 | TypeCtor::Closure { .. } => None, | ||
173 | TypeCtor::Adt(adt) => adt.krate(db), | 174 | TypeCtor::Adt(adt) => adt.krate(db), |
174 | TypeCtor::FnDef(callable) => Some(callable.krate(db).into()), | 175 | TypeCtor::FnDef(callable) => Some(callable.krate(db).into()), |
175 | TypeCtor::AssociatedType(type_alias) => type_alias.krate(db), | 176 | TypeCtor::AssociatedType(type_alias) => type_alias.krate(db), |
diff --git a/crates/ra_hir/src/ty/infer/expr.rs b/crates/ra_hir/src/ty/infer/expr.rs index 994a6d7e9..b581d192f 100644 --- a/crates/ra_hir/src/ty/infer/expr.rs +++ b/crates/ra_hir/src/ty/infer/expr.rs | |||
@@ -137,8 +137,10 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
137 | TypeCtor::FnPtr { num_args: sig_tys.len() as u16 - 1 }, | 137 | TypeCtor::FnPtr { num_args: sig_tys.len() as u16 - 1 }, |
138 | Substs(sig_tys.into()), | 138 | Substs(sig_tys.into()), |
139 | ); | 139 | ); |
140 | let closure_ty = | 140 | let closure_ty = Ty::apply_one( |
141 | Ty::apply_one(TypeCtor::Closure { def: self.owner, expr: tgt_expr }, sig_ty); | 141 | TypeCtor::Closure { def: self.owner.into(), expr: tgt_expr }, |
142 | sig_ty, | ||
143 | ); | ||
142 | 144 | ||
143 | // Eagerly try to relate the closure type with the expected | 145 | // Eagerly try to relate the closure type with the expected |
144 | // type, otherwise we often won't have enough information to | 146 | // type, otherwise we often won't have enough information to |
diff --git a/crates/ra_hir/src/ty/traits.rs b/crates/ra_hir/src/ty/traits.rs index 268fa09e4..b9a5d651f 100644 --- a/crates/ra_hir/src/ty/traits.rs +++ b/crates/ra_hir/src/ty/traits.rs | |||
@@ -2,13 +2,14 @@ | |||
2 | use std::sync::{Arc, Mutex}; | 2 | use std::sync::{Arc, Mutex}; |
3 | 3 | ||
4 | use chalk_ir::{cast::Cast, family::ChalkIr}; | 4 | use chalk_ir::{cast::Cast, family::ChalkIr}; |
5 | use hir_def::DefWithBodyId; | ||
5 | use log::debug; | 6 | use log::debug; |
6 | use ra_db::{impl_intern_key, salsa}; | 7 | use ra_db::{impl_intern_key, salsa}; |
7 | use ra_prof::profile; | 8 | use ra_prof::profile; |
8 | use rustc_hash::FxHashSet; | 9 | use rustc_hash::FxHashSet; |
9 | 10 | ||
10 | use super::{Canonical, GenericPredicate, HirDisplay, ProjectionTy, TraitRef, Ty, TypeWalk}; | 11 | use super::{Canonical, GenericPredicate, HirDisplay, ProjectionTy, TraitRef, Ty, TypeWalk}; |
11 | use crate::{db::HirDatabase, expr::ExprId, Crate, DefWithBody, ImplBlock, Trait, TypeAlias}; | 12 | use crate::{db::HirDatabase, expr::ExprId, Crate, ImplBlock, Trait, TypeAlias}; |
12 | 13 | ||
13 | use self::chalk::{from_chalk, ToChalk}; | 14 | use self::chalk::{from_chalk, ToChalk}; |
14 | 15 | ||
@@ -290,7 +291,7 @@ impl FnTrait { | |||
290 | 291 | ||
291 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 292 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
292 | pub struct ClosureFnTraitImplData { | 293 | pub struct ClosureFnTraitImplData { |
293 | def: DefWithBody, | 294 | def: DefWithBodyId, |
294 | expr: ExprId, | 295 | expr: ExprId, |
295 | fn_trait: FnTrait, | 296 | fn_trait: FnTrait, |
296 | } | 297 | } |