More ids in Ty
This commit is contained in:
parent
ecd1204804
commit
3e32ac4f86
4 changed files with 13 additions and 17 deletions
|
@ -538,14 +538,6 @@ pub enum DefWithBody {
|
|||
impl_froms!(DefWithBody: Function, Const, Static);
|
||||
|
||||
impl DefWithBody {
|
||||
pub(crate) fn krate(self, db: &impl HirDatabase) -> Option<Crate> {
|
||||
match self {
|
||||
DefWithBody::Const(c) => c.krate(db),
|
||||
DefWithBody::Function(f) => f.krate(db),
|
||||
DefWithBody::Static(s) => s.krate(db),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn module(self, db: &impl HirDatabase) -> Module {
|
||||
match self {
|
||||
DefWithBody::Const(c) => c.module(db),
|
||||
|
|
|
@ -17,12 +17,12 @@ use std::ops::Deref;
|
|||
use std::sync::Arc;
|
||||
use std::{fmt, iter, mem};
|
||||
|
||||
use hir_def::{generics::GenericParams, AdtId, GenericDefId};
|
||||
use hir_def::{generics::GenericParams, AdtId, DefWithBodyId, GenericDefId};
|
||||
use ra_db::{impl_intern_key, salsa};
|
||||
|
||||
use crate::{
|
||||
db::HirDatabase, expr::ExprId, util::make_mut_slice, Adt, Crate, DefWithBody, FloatTy, IntTy,
|
||||
Mutability, Name, Trait, TypeAlias, Uncertain,
|
||||
db::HirDatabase, expr::ExprId, util::make_mut_slice, Adt, Crate, FloatTy, IntTy, Mutability,
|
||||
Name, Trait, TypeAlias, Uncertain,
|
||||
};
|
||||
use display::{HirDisplay, HirFormatter};
|
||||
|
||||
|
@ -113,7 +113,7 @@ pub enum TypeCtor {
|
|||
///
|
||||
/// The closure signature is stored in a `FnPtr` type in the first type
|
||||
/// parameter.
|
||||
Closure { def: DefWithBody, expr: ExprId },
|
||||
Closure { def: DefWithBodyId, expr: ExprId },
|
||||
}
|
||||
|
||||
/// This exists just for Chalk, because Chalk just has a single `StructId` where
|
||||
|
@ -169,7 +169,8 @@ impl TypeCtor {
|
|||
| TypeCtor::Ref(_)
|
||||
| TypeCtor::FnPtr { .. }
|
||||
| TypeCtor::Tuple { .. } => None,
|
||||
TypeCtor::Closure { def, .. } => def.krate(db),
|
||||
// Closure's krate is irrelevant for coherence I would think?
|
||||
TypeCtor::Closure { .. } => None,
|
||||
TypeCtor::Adt(adt) => adt.krate(db),
|
||||
TypeCtor::FnDef(callable) => Some(callable.krate(db).into()),
|
||||
TypeCtor::AssociatedType(type_alias) => type_alias.krate(db),
|
||||
|
|
|
@ -137,8 +137,10 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
|
|||
TypeCtor::FnPtr { num_args: sig_tys.len() as u16 - 1 },
|
||||
Substs(sig_tys.into()),
|
||||
);
|
||||
let closure_ty =
|
||||
Ty::apply_one(TypeCtor::Closure { def: self.owner, expr: tgt_expr }, sig_ty);
|
||||
let closure_ty = Ty::apply_one(
|
||||
TypeCtor::Closure { def: self.owner.into(), expr: tgt_expr },
|
||||
sig_ty,
|
||||
);
|
||||
|
||||
// Eagerly try to relate the closure type with the expected
|
||||
// type, otherwise we often won't have enough information to
|
||||
|
|
|
@ -2,13 +2,14 @@
|
|||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use chalk_ir::{cast::Cast, family::ChalkIr};
|
||||
use hir_def::DefWithBodyId;
|
||||
use log::debug;
|
||||
use ra_db::{impl_intern_key, salsa};
|
||||
use ra_prof::profile;
|
||||
use rustc_hash::FxHashSet;
|
||||
|
||||
use super::{Canonical, GenericPredicate, HirDisplay, ProjectionTy, TraitRef, Ty, TypeWalk};
|
||||
use crate::{db::HirDatabase, expr::ExprId, Crate, DefWithBody, ImplBlock, Trait, TypeAlias};
|
||||
use crate::{db::HirDatabase, expr::ExprId, Crate, ImplBlock, Trait, TypeAlias};
|
||||
|
||||
use self::chalk::{from_chalk, ToChalk};
|
||||
|
||||
|
@ -290,7 +291,7 @@ impl FnTrait {
|
|||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct ClosureFnTraitImplData {
|
||||
def: DefWithBody,
|
||||
def: DefWithBodyId,
|
||||
expr: ExprId,
|
||||
fn_trait: FnTrait,
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue