mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
Use chalk_ir::OpaqueTyId
This commit is contained in:
parent
1bf6b7360c
commit
b035c314b4
7 changed files with 53 additions and 63 deletions
|
@ -12,7 +12,7 @@ use la_arena::ArenaMap;
|
||||||
use crate::{
|
use crate::{
|
||||||
method_resolution::{InherentImpls, TraitImpls},
|
method_resolution::{InherentImpls, TraitImpls},
|
||||||
traits::chalk,
|
traits::chalk,
|
||||||
Binders, CallableDefId, FnDefId, GenericPredicate, InferenceResult, OpaqueTyId, PolyFnSig,
|
Binders, CallableDefId, FnDefId, GenericPredicate, ImplTraitId, InferenceResult, PolyFnSig,
|
||||||
ReturnTypeImplTraits, TraitRef, Ty, TyDefId, ValueTyDefId,
|
ReturnTypeImplTraits, TraitRef, Ty, TyDefId, ValueTyDefId,
|
||||||
};
|
};
|
||||||
use hir_expand::name::Name;
|
use hir_expand::name::Name;
|
||||||
|
@ -83,7 +83,7 @@ pub trait HirDatabase: DefDatabase + Upcast<dyn DefDatabase> {
|
||||||
#[salsa::interned]
|
#[salsa::interned]
|
||||||
fn intern_type_param_id(&self, param_id: TypeParamId) -> InternedTypeParamId;
|
fn intern_type_param_id(&self, param_id: TypeParamId) -> InternedTypeParamId;
|
||||||
#[salsa::interned]
|
#[salsa::interned]
|
||||||
fn intern_impl_trait_id(&self, id: OpaqueTyId) -> InternedOpaqueTyId;
|
fn intern_impl_trait_id(&self, id: ImplTraitId) -> InternedOpaqueTyId;
|
||||||
#[salsa::interned]
|
#[salsa::interned]
|
||||||
fn intern_closure(&self, id: (DefWithBodyId, ExprId)) -> InternedClosureId;
|
fn intern_closure(&self, id: (DefWithBodyId, ExprId)) -> InternedClosureId;
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ use hir_expand::name::Name;
|
||||||
use crate::{
|
use crate::{
|
||||||
db::HirDatabase, from_assoc_type_id, from_foreign_def_id, from_placeholder_idx, primitive,
|
db::HirDatabase, from_assoc_type_id, from_foreign_def_id, from_placeholder_idx, primitive,
|
||||||
to_assoc_type_id, traits::chalk::from_chalk, utils::generics, AdtId, AliasTy, CallableDefId,
|
to_assoc_type_id, traits::chalk::from_chalk, utils::generics, AdtId, AliasTy, CallableDefId,
|
||||||
CallableSig, GenericPredicate, Interner, Lifetime, Obligation, OpaqueTy, OpaqueTyId,
|
CallableSig, GenericPredicate, ImplTraitId, Interner, Lifetime, Obligation, OpaqueTy,
|
||||||
ProjectionTy, Scalar, Substs, TraitRef, Ty, TyKind,
|
ProjectionTy, Scalar, Substs, TraitRef, Ty, TyKind,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -313,22 +313,26 @@ impl HirDisplay for Ty {
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: all this just to decide whether to use parentheses...
|
||||||
let datas;
|
let datas;
|
||||||
let predicates = match t.interned(&Interner) {
|
let predicates = match t.interned(&Interner) {
|
||||||
TyKind::Dyn(predicates) if predicates.len() > 1 => {
|
TyKind::Dyn(predicates) if predicates.len() > 1 => {
|
||||||
Cow::Borrowed(predicates.as_ref())
|
Cow::Borrowed(predicates.as_ref())
|
||||||
}
|
}
|
||||||
&TyKind::Alias(AliasTy::Opaque(OpaqueTy {
|
&TyKind::Alias(AliasTy::Opaque(OpaqueTy { opaque_ty_id, ref parameters })) => {
|
||||||
opaque_ty_id: OpaqueTyId::ReturnTypeImplTrait(func, idx),
|
let impl_trait_id = f.db.lookup_intern_impl_trait_id(opaque_ty_id.into());
|
||||||
ref parameters,
|
if let ImplTraitId::ReturnTypeImplTrait(func, idx) = impl_trait_id {
|
||||||
})) => {
|
datas =
|
||||||
datas =
|
f.db.return_type_impl_traits(func)
|
||||||
f.db.return_type_impl_traits(func).expect("impl trait id without data");
|
.expect("impl trait id without data");
|
||||||
let data = (*datas)
|
let data = (*datas)
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|rpit| rpit.impl_traits[idx as usize].bounds.clone());
|
.map(|rpit| rpit.impl_traits[idx as usize].bounds.clone());
|
||||||
let bounds = data.subst(parameters);
|
let bounds = data.subst(parameters);
|
||||||
Cow::Owned(bounds.value)
|
Cow::Owned(bounds.value)
|
||||||
|
} else {
|
||||||
|
Cow::Borrowed(&[][..])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_ => Cow::Borrowed(&[][..]),
|
_ => Cow::Borrowed(&[][..]),
|
||||||
};
|
};
|
||||||
|
@ -499,8 +503,9 @@ impl HirDisplay for Ty {
|
||||||
write!(f, "{}", type_alias.name)?;
|
write!(f, "{}", type_alias.name)?;
|
||||||
}
|
}
|
||||||
TyKind::OpaqueType(opaque_ty_id, parameters) => {
|
TyKind::OpaqueType(opaque_ty_id, parameters) => {
|
||||||
match opaque_ty_id {
|
let impl_trait_id = f.db.lookup_intern_impl_trait_id((*opaque_ty_id).into());
|
||||||
&OpaqueTyId::ReturnTypeImplTrait(func, idx) => {
|
match impl_trait_id {
|
||||||
|
ImplTraitId::ReturnTypeImplTrait(func, idx) => {
|
||||||
let datas =
|
let datas =
|
||||||
f.db.return_type_impl_traits(func).expect("impl trait id without data");
|
f.db.return_type_impl_traits(func).expect("impl trait id without data");
|
||||||
let data = (*datas)
|
let data = (*datas)
|
||||||
|
@ -510,7 +515,7 @@ impl HirDisplay for Ty {
|
||||||
write_bounds_like_dyn_trait_with_prefix("impl", &bounds.value, f)?;
|
write_bounds_like_dyn_trait_with_prefix("impl", &bounds.value, f)?;
|
||||||
// FIXME: it would maybe be good to distinguish this from the alias type (when debug printing), and to show the substitution
|
// FIXME: it would maybe be good to distinguish this from the alias type (when debug printing), and to show the substitution
|
||||||
}
|
}
|
||||||
OpaqueTyId::AsyncBlockTypeImplTrait(..) => {
|
ImplTraitId::AsyncBlockTypeImplTrait(..) => {
|
||||||
write!(f, "impl Future<Output = ")?;
|
write!(f, "impl Future<Output = ")?;
|
||||||
parameters[0].hir_fmt(f)?;
|
parameters[0].hir_fmt(f)?;
|
||||||
write!(f, ">")?;
|
write!(f, ">")?;
|
||||||
|
@ -566,8 +571,9 @@ impl HirDisplay for Ty {
|
||||||
}
|
}
|
||||||
TyKind::Alias(AliasTy::Projection(p_ty)) => p_ty.hir_fmt(f)?,
|
TyKind::Alias(AliasTy::Projection(p_ty)) => p_ty.hir_fmt(f)?,
|
||||||
TyKind::Alias(AliasTy::Opaque(opaque_ty)) => {
|
TyKind::Alias(AliasTy::Opaque(opaque_ty)) => {
|
||||||
match opaque_ty.opaque_ty_id {
|
let impl_trait_id = f.db.lookup_intern_impl_trait_id(opaque_ty.opaque_ty_id.into());
|
||||||
OpaqueTyId::ReturnTypeImplTrait(func, idx) => {
|
match impl_trait_id {
|
||||||
|
ImplTraitId::ReturnTypeImplTrait(func, idx) => {
|
||||||
let datas =
|
let datas =
|
||||||
f.db.return_type_impl_traits(func).expect("impl trait id without data");
|
f.db.return_type_impl_traits(func).expect("impl trait id without data");
|
||||||
let data = (*datas)
|
let data = (*datas)
|
||||||
|
@ -576,7 +582,7 @@ impl HirDisplay for Ty {
|
||||||
let bounds = data.subst(&opaque_ty.parameters);
|
let bounds = data.subst(&opaque_ty.parameters);
|
||||||
write_bounds_like_dyn_trait_with_prefix("impl", &bounds.value, f)?;
|
write_bounds_like_dyn_trait_with_prefix("impl", &bounds.value, f)?;
|
||||||
}
|
}
|
||||||
OpaqueTyId::AsyncBlockTypeImplTrait(..) => {
|
ImplTraitId::AsyncBlockTypeImplTrait(..) => {
|
||||||
write!(f, "{{async block}}")?;
|
write!(f, "{{async block}}")?;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -21,8 +21,8 @@ use crate::{
|
||||||
to_assoc_type_id,
|
to_assoc_type_id,
|
||||||
traits::{chalk::from_chalk, FnTrait, InEnvironment},
|
traits::{chalk::from_chalk, FnTrait, InEnvironment},
|
||||||
utils::{generics, variant_data, Generics},
|
utils::{generics, variant_data, Generics},
|
||||||
AdtId, Binders, CallableDefId, FnPointer, FnSig, Interner, Obligation, OpaqueTyId, Rawness,
|
AdtId, Binders, CallableDefId, FnPointer, FnSig, Interner, Obligation, Rawness, Scalar, Substs,
|
||||||
Scalar, Substs, TraitRef, Ty, TyKind,
|
TraitRef, Ty, TyKind,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
@ -179,7 +179,8 @@ impl<'a> InferenceContext<'a> {
|
||||||
// Use the first type parameter as the output type of future.
|
// Use the first type parameter as the output type of future.
|
||||||
// existenail type AsyncBlockImplTrait<InnerType>: Future<Output = InnerType>
|
// existenail type AsyncBlockImplTrait<InnerType>: Future<Output = InnerType>
|
||||||
let inner_ty = self.infer_expr(*body, &Expectation::none());
|
let inner_ty = self.infer_expr(*body, &Expectation::none());
|
||||||
let opaque_ty_id = OpaqueTyId::AsyncBlockTypeImplTrait(self.owner, *body);
|
let impl_trait_id = crate::ImplTraitId::AsyncBlockTypeImplTrait(self.owner, *body);
|
||||||
|
let opaque_ty_id = self.db.intern_impl_trait_id(impl_trait_id).into();
|
||||||
TyKind::OpaqueType(opaque_ty_id, Substs::single(inner_ty)).intern(&Interner)
|
TyKind::OpaqueType(opaque_ty_id, Substs::single(inner_ty)).intern(&Interner)
|
||||||
}
|
}
|
||||||
Expr::Loop { body, label } => {
|
Expr::Loop { body, label } => {
|
||||||
|
|
|
@ -54,6 +54,7 @@ pub type ForeignDefId = chalk_ir::ForeignDefId<Interner>;
|
||||||
pub type AssocTypeId = chalk_ir::AssocTypeId<Interner>;
|
pub type AssocTypeId = chalk_ir::AssocTypeId<Interner>;
|
||||||
pub type FnDefId = chalk_ir::FnDefId<Interner>;
|
pub type FnDefId = chalk_ir::FnDefId<Interner>;
|
||||||
pub type ClosureId = chalk_ir::ClosureId<Interner>;
|
pub type ClosureId = chalk_ir::ClosureId<Interner>;
|
||||||
|
pub type OpaqueTyId = chalk_ir::OpaqueTyId<Interner>;
|
||||||
pub type PlaceholderIndex = chalk_ir::PlaceholderIndex;
|
pub type PlaceholderIndex = chalk_ir::PlaceholderIndex;
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
|
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
|
||||||
|
@ -875,8 +876,8 @@ impl Ty {
|
||||||
pub fn impl_trait_bounds(&self, db: &dyn HirDatabase) -> Option<Vec<GenericPredicate>> {
|
pub fn impl_trait_bounds(&self, db: &dyn HirDatabase) -> Option<Vec<GenericPredicate>> {
|
||||||
match self.interned(&Interner) {
|
match self.interned(&Interner) {
|
||||||
TyKind::OpaqueType(opaque_ty_id, ..) => {
|
TyKind::OpaqueType(opaque_ty_id, ..) => {
|
||||||
match opaque_ty_id {
|
match db.lookup_intern_impl_trait_id((*opaque_ty_id).into()) {
|
||||||
OpaqueTyId::AsyncBlockTypeImplTrait(def, _expr) => {
|
ImplTraitId::AsyncBlockTypeImplTrait(def, _expr) => {
|
||||||
let krate = def.module(db.upcast()).krate();
|
let krate = def.module(db.upcast()).krate();
|
||||||
if let Some(future_trait) = db
|
if let Some(future_trait) = db
|
||||||
.lang_item(krate, "future_trait".into())
|
.lang_item(krate, "future_trait".into())
|
||||||
|
@ -894,12 +895,13 @@ impl Ty {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
OpaqueTyId::ReturnTypeImplTrait(..) => None,
|
ImplTraitId::ReturnTypeImplTrait(..) => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TyKind::Alias(AliasTy::Opaque(opaque_ty)) => {
|
TyKind::Alias(AliasTy::Opaque(opaque_ty)) => {
|
||||||
let predicates = match opaque_ty.opaque_ty_id {
|
let predicates = match db.lookup_intern_impl_trait_id(opaque_ty.opaque_ty_id.into())
|
||||||
OpaqueTyId::ReturnTypeImplTrait(func, idx) => {
|
{
|
||||||
|
ImplTraitId::ReturnTypeImplTrait(func, idx) => {
|
||||||
db.return_type_impl_traits(func).map(|it| {
|
db.return_type_impl_traits(func).map(|it| {
|
||||||
let data = (*it)
|
let data = (*it)
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
@ -908,7 +910,7 @@ impl Ty {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// It always has an parameter for Future::Output type.
|
// It always has an parameter for Future::Output type.
|
||||||
OpaqueTyId::AsyncBlockTypeImplTrait(..) => unreachable!(),
|
ImplTraitId::AsyncBlockTypeImplTrait(..) => unreachable!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
predicates.map(|it| it.value)
|
predicates.map(|it| it.value)
|
||||||
|
@ -1123,7 +1125,7 @@ impl<T: TypeWalk> TypeWalk for Vec<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
|
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash)]
|
||||||
pub enum OpaqueTyId {
|
pub enum ImplTraitId {
|
||||||
ReturnTypeImplTrait(hir_def::FunctionId, u16),
|
ReturnTypeImplTrait(hir_def::FunctionId, u16),
|
||||||
AsyncBlockTypeImplTrait(hir_def::DefWithBodyId, ExprId),
|
AsyncBlockTypeImplTrait(hir_def::DefWithBodyId, ExprId),
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ use crate::{
|
||||||
make_mut_slice, variant_data,
|
make_mut_slice, variant_data,
|
||||||
},
|
},
|
||||||
AliasTy, Binders, BoundVar, CallableSig, DebruijnIndex, FnPointer, FnSig, GenericPredicate,
|
AliasTy, Binders, BoundVar, CallableSig, DebruijnIndex, FnPointer, FnSig, GenericPredicate,
|
||||||
OpaqueTy, OpaqueTyId, PolyFnSig, ProjectionPredicate, ProjectionTy, ReturnTypeImplTrait,
|
ImplTraitId, OpaqueTy, PolyFnSig, ProjectionPredicate, ProjectionTy, ReturnTypeImplTrait,
|
||||||
ReturnTypeImplTraits, Substs, TraitEnvironment, TraitRef, Ty, TyKind, TypeWalk,
|
ReturnTypeImplTraits, Substs, TraitEnvironment, TraitRef, Ty, TyKind, TypeWalk,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -228,14 +228,12 @@ impl Ty {
|
||||||
Some(GenericDefId::FunctionId(f)) => f,
|
Some(GenericDefId::FunctionId(f)) => f,
|
||||||
_ => panic!("opaque impl trait lowering in non-function"),
|
_ => panic!("opaque impl trait lowering in non-function"),
|
||||||
};
|
};
|
||||||
let impl_trait_id = OpaqueTyId::ReturnTypeImplTrait(func, idx);
|
let impl_trait_id = ImplTraitId::ReturnTypeImplTrait(func, idx);
|
||||||
|
let opaque_ty_id = ctx.db.intern_impl_trait_id(impl_trait_id).into();
|
||||||
let generics = generics(ctx.db.upcast(), func.into());
|
let generics = generics(ctx.db.upcast(), func.into());
|
||||||
let parameters = Substs::bound_vars(&generics, ctx.in_binders);
|
let parameters = Substs::bound_vars(&generics, ctx.in_binders);
|
||||||
TyKind::Alias(AliasTy::Opaque(OpaqueTy {
|
TyKind::Alias(AliasTy::Opaque(OpaqueTy { opaque_ty_id, parameters }))
|
||||||
opaque_ty_id: impl_trait_id,
|
.intern(&Interner)
|
||||||
parameters,
|
|
||||||
}))
|
|
||||||
.intern(&Interner)
|
|
||||||
}
|
}
|
||||||
ImplTraitLoweringMode::Param => {
|
ImplTraitLoweringMode::Param => {
|
||||||
let idx = ctx.impl_trait_counter.get();
|
let idx = ctx.impl_trait_counter.get();
|
||||||
|
|
|
@ -177,10 +177,9 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn opaque_ty_data(&self, id: chalk_ir::OpaqueTyId<Interner>) -> Arc<OpaqueTyDatum> {
|
fn opaque_ty_data(&self, id: chalk_ir::OpaqueTyId<Interner>) -> Arc<OpaqueTyDatum> {
|
||||||
let interned_id = crate::db::InternedOpaqueTyId::from(id);
|
let full_id = self.db.lookup_intern_impl_trait_id(id.into());
|
||||||
let full_id = self.db.lookup_intern_impl_trait_id(interned_id);
|
|
||||||
let bound = match full_id {
|
let bound = match full_id {
|
||||||
crate::OpaqueTyId::ReturnTypeImplTrait(func, idx) => {
|
crate::ImplTraitId::ReturnTypeImplTrait(func, idx) => {
|
||||||
let datas = self
|
let datas = self
|
||||||
.db
|
.db
|
||||||
.return_type_impl_traits(func)
|
.return_type_impl_traits(func)
|
||||||
|
@ -202,7 +201,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
|
||||||
let num_vars = datas.num_binders;
|
let num_vars = datas.num_binders;
|
||||||
make_binders(bound, num_vars)
|
make_binders(bound, num_vars)
|
||||||
}
|
}
|
||||||
crate::OpaqueTyId::AsyncBlockTypeImplTrait(..) => {
|
crate::ImplTraitId::AsyncBlockTypeImplTrait(..) => {
|
||||||
if let Some((future_trait, future_output)) = self
|
if let Some((future_trait, future_output)) = self
|
||||||
.db
|
.db
|
||||||
.lang_item(self.krate, "future_trait".into())
|
.lang_item(self.krate, "future_trait".into())
|
||||||
|
|
|
@ -15,7 +15,7 @@ use crate::{
|
||||||
primitive::UintTy,
|
primitive::UintTy,
|
||||||
traits::{Canonical, Obligation},
|
traits::{Canonical, Obligation},
|
||||||
AliasTy, CallableDefId, FnPointer, FnSig, GenericPredicate, InEnvironment, OpaqueTy,
|
AliasTy, CallableDefId, FnPointer, FnSig, GenericPredicate, InEnvironment, OpaqueTy,
|
||||||
OpaqueTyId, ProjectionPredicate, ProjectionTy, Scalar, Substs, TraitRef, Ty,
|
ProjectionPredicate, ProjectionTy, Scalar, Substs, TraitRef, Ty,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::interner::*;
|
use super::interner::*;
|
||||||
|
@ -41,8 +41,7 @@ impl ToChalk for Ty {
|
||||||
chalk_ir::TyKind::AssociatedType(assoc_type_id, substitution).intern(&Interner)
|
chalk_ir::TyKind::AssociatedType(assoc_type_id, substitution).intern(&Interner)
|
||||||
}
|
}
|
||||||
|
|
||||||
TyKind::OpaqueType(impl_trait_id, substs) => {
|
TyKind::OpaqueType(id, substs) => {
|
||||||
let id = impl_trait_id.to_chalk(db);
|
|
||||||
let substitution = substs.to_chalk(db);
|
let substitution = substs.to_chalk(db);
|
||||||
chalk_ir::TyKind::OpaqueType(id, substitution).intern(&Interner)
|
chalk_ir::TyKind::OpaqueType(id, substitution).intern(&Interner)
|
||||||
}
|
}
|
||||||
|
@ -103,7 +102,7 @@ impl ToChalk for Ty {
|
||||||
chalk_ir::TyKind::Dyn(bounded_ty).intern(&Interner)
|
chalk_ir::TyKind::Dyn(bounded_ty).intern(&Interner)
|
||||||
}
|
}
|
||||||
TyKind::Alias(AliasTy::Opaque(opaque_ty)) => {
|
TyKind::Alias(AliasTy::Opaque(opaque_ty)) => {
|
||||||
let opaque_ty_id = opaque_ty.opaque_ty_id.to_chalk(db);
|
let opaque_ty_id = opaque_ty.opaque_ty_id;
|
||||||
let substitution = opaque_ty.parameters.to_chalk(db);
|
let substitution = opaque_ty.parameters.to_chalk(db);
|
||||||
chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Opaque(chalk_ir::OpaqueTy {
|
chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Opaque(chalk_ir::OpaqueTy {
|
||||||
opaque_ty_id,
|
opaque_ty_id,
|
||||||
|
@ -125,9 +124,9 @@ impl ToChalk for Ty {
|
||||||
TyKind::Alias(AliasTy::Projection(ProjectionTy { associated_ty, parameters }))
|
TyKind::Alias(AliasTy::Projection(ProjectionTy { associated_ty, parameters }))
|
||||||
}
|
}
|
||||||
chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Opaque(opaque_ty)) => {
|
chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Opaque(opaque_ty)) => {
|
||||||
let impl_trait_id = from_chalk(db, opaque_ty.opaque_ty_id);
|
let opaque_ty_id = opaque_ty.opaque_ty_id;
|
||||||
let parameters = from_chalk(db, opaque_ty.substitution);
|
let parameters = from_chalk(db, opaque_ty.substitution);
|
||||||
TyKind::Alias(AliasTy::Opaque(OpaqueTy { opaque_ty_id: impl_trait_id, parameters }))
|
TyKind::Alias(AliasTy::Opaque(OpaqueTy { opaque_ty_id, parameters }))
|
||||||
}
|
}
|
||||||
chalk_ir::TyKind::Function(chalk_ir::FnPointer {
|
chalk_ir::TyKind::Function(chalk_ir::FnPointer {
|
||||||
num_binders,
|
num_binders,
|
||||||
|
@ -165,7 +164,7 @@ impl ToChalk for Ty {
|
||||||
}
|
}
|
||||||
|
|
||||||
chalk_ir::TyKind::OpaqueType(opaque_type_id, subst) => {
|
chalk_ir::TyKind::OpaqueType(opaque_type_id, subst) => {
|
||||||
TyKind::OpaqueType(from_chalk(db, opaque_type_id), from_chalk(db, subst))
|
TyKind::OpaqueType(opaque_type_id, from_chalk(db, subst))
|
||||||
}
|
}
|
||||||
|
|
||||||
chalk_ir::TyKind::Scalar(scalar) => TyKind::Scalar(scalar),
|
chalk_ir::TyKind::Scalar(scalar) => TyKind::Scalar(scalar),
|
||||||
|
@ -268,21 +267,6 @@ impl ToChalk for hir_def::TraitId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToChalk for OpaqueTyId {
|
|
||||||
type Chalk = chalk_ir::OpaqueTyId<Interner>;
|
|
||||||
|
|
||||||
fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::OpaqueTyId<Interner> {
|
|
||||||
db.intern_impl_trait_id(self).into()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn from_chalk(
|
|
||||||
db: &dyn HirDatabase,
|
|
||||||
opaque_ty_id: chalk_ir::OpaqueTyId<Interner>,
|
|
||||||
) -> OpaqueTyId {
|
|
||||||
db.lookup_intern_impl_trait_id(opaque_ty_id.into())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ToChalk for hir_def::ImplId {
|
impl ToChalk for hir_def::ImplId {
|
||||||
type Chalk = ImplId;
|
type Chalk = ImplId;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue