mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Update chalk 0.32.0 -> 0.35.0
This commit is contained in:
parent
1f5c655d0c
commit
299a65ff71
16
Cargo.lock
16
Cargo.lock
@ -460,9 +460,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chalk-derive"
|
name = "chalk-derive"
|
||||||
version = "0.32.0"
|
version = "0.35.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2d072b2ba723f0bada7c515d8b3725224bc4f5052d2a92dcbeb0b118ff37084a"
|
checksum = "bc6d2895e93c0939074a7a0f525fd549b49da8362dea3def555e4aab95ff64cd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@ -472,9 +472,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chalk-engine"
|
name = "chalk-engine"
|
||||||
version = "0.32.0"
|
version = "0.35.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6fb5475f6083d6d6c509e1c335c4f69ad04144ac090faa1afb134a53c3695841"
|
checksum = "93ed23c35d243ccc2caeae7ba4660a091e74b11c40e441d7849f07d8e71b5cb8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chalk-derive",
|
"chalk-derive",
|
||||||
"chalk-ir",
|
"chalk-ir",
|
||||||
@ -485,9 +485,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chalk-ir"
|
name = "chalk-ir"
|
||||||
version = "0.32.0"
|
version = "0.35.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f60cdb0e18c5455cb6a85e8464aad3622b70476018edfa8845691df66f7e9a05"
|
checksum = "40d7f6140cccc889117e7372b6f9cfbc8103c86a1a0269ff6ab868f20ab414d6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chalk-derive",
|
"chalk-derive",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
@ -495,9 +495,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chalk-solve"
|
name = "chalk-solve"
|
||||||
version = "0.32.0"
|
version = "0.35.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "981534d499a8476ecc0b520be4d3864757f96211826a75360fbf2cb6fae362ab"
|
checksum = "fa65b636e64cbfcba31f053da97c32f3e15f2670b3cc620b84231a1656d754ec"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chalk-derive",
|
"chalk-derive",
|
||||||
"chalk-ir",
|
"chalk-ir",
|
||||||
|
@ -26,7 +26,7 @@ rustc_index = { path = "../rustc_index" }
|
|||||||
rustc_serialize = { path = "../rustc_serialize" }
|
rustc_serialize = { path = "../rustc_serialize" }
|
||||||
rustc_ast = { path = "../rustc_ast" }
|
rustc_ast = { path = "../rustc_ast" }
|
||||||
rustc_span = { path = "../rustc_span" }
|
rustc_span = { path = "../rustc_span" }
|
||||||
chalk-ir = "0.32.0"
|
chalk-ir = "0.35.0"
|
||||||
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
|
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
|
||||||
measureme = "9.0.0"
|
measureme = "9.0.0"
|
||||||
rustc_session = { path = "../rustc_session" }
|
rustc_session = { path = "../rustc_session" }
|
||||||
|
@ -102,48 +102,6 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
|
|||||||
Some(write())
|
Some(write())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn debug_application_ty(
|
|
||||||
application_ty: &chalk_ir::ApplicationTy<Self>,
|
|
||||||
fmt: &mut fmt::Formatter<'_>,
|
|
||||||
) -> Option<fmt::Result> {
|
|
||||||
match application_ty.name {
|
|
||||||
chalk_ir::TypeName::Ref(mutbl) => {
|
|
||||||
let data = application_ty.substitution.interned();
|
|
||||||
match (&**data[0].interned(), &**data[1].interned()) {
|
|
||||||
(
|
|
||||||
chalk_ir::GenericArgData::Lifetime(lifetime),
|
|
||||||
chalk_ir::GenericArgData::Ty(ty),
|
|
||||||
) => Some(match mutbl {
|
|
||||||
chalk_ir::Mutability::Not => write!(fmt, "(&{:?} {:?})", lifetime, ty),
|
|
||||||
chalk_ir::Mutability::Mut => write!(fmt, "(&{:?} mut {:?})", lifetime, ty),
|
|
||||||
}),
|
|
||||||
_ => unreachable!(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
chalk_ir::TypeName::Array => {
|
|
||||||
let data = application_ty.substitution.interned();
|
|
||||||
match (&**data[0].interned(), &**data[1].interned()) {
|
|
||||||
(chalk_ir::GenericArgData::Ty(ty), chalk_ir::GenericArgData::Const(len)) => {
|
|
||||||
Some(write!(fmt, "[{:?}; {:?}]", ty, len))
|
|
||||||
}
|
|
||||||
_ => unreachable!(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
chalk_ir::TypeName::Slice => {
|
|
||||||
let data = application_ty.substitution.interned();
|
|
||||||
let ty = match &**data[0].interned() {
|
|
||||||
chalk_ir::GenericArgData::Ty(t) => t,
|
|
||||||
_ => unreachable!(),
|
|
||||||
};
|
|
||||||
Some(write!(fmt, "[{:?}]", ty))
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
let chalk_ir::ApplicationTy { name, substitution } = application_ty;
|
|
||||||
Some(write!(fmt, "{:?}{:?}", name, chalk_ir::debug::Angle(substitution.interned())))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn debug_substitution(
|
fn debug_substitution(
|
||||||
substitution: &chalk_ir::Substitution<Self>,
|
substitution: &chalk_ir::Substitution<Self>,
|
||||||
fmt: &mut fmt::Formatter<'_>,
|
fmt: &mut fmt::Formatter<'_>,
|
||||||
@ -174,6 +132,32 @@ impl<'tcx> chalk_ir::interner::Interner for RustInterner<'tcx> {
|
|||||||
Some(write!(fmt, "{:?}", clauses.interned()))
|
Some(write!(fmt, "{:?}", clauses.interned()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn debug_ty(ty: &chalk_ir::Ty<Self>, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> {
|
||||||
|
match &ty.interned().kind {
|
||||||
|
chalk_ir::TyKind::Ref(chalk_ir::Mutability::Not, lifetime, ty) => {
|
||||||
|
Some(write!(fmt, "(&{:?} {:?})", lifetime, ty))
|
||||||
|
}
|
||||||
|
chalk_ir::TyKind::Ref(chalk_ir::Mutability::Mut, lifetime, ty) => {
|
||||||
|
Some(write!(fmt, "(&{:?} mut {:?})", lifetime, ty))
|
||||||
|
}
|
||||||
|
chalk_ir::TyKind::Array(ty, len) => Some(write!(fmt, "[{:?}; {:?}]", ty, len)),
|
||||||
|
chalk_ir::TyKind::Slice(ty) => Some(write!(fmt, "[{:?}]", ty)),
|
||||||
|
chalk_ir::TyKind::Tuple(len, substs) => Some((|| {
|
||||||
|
write!(fmt, "(")?;
|
||||||
|
for (idx, substitution) in substs.interned().iter().enumerate() {
|
||||||
|
if idx == *len && *len != 1 {
|
||||||
|
// Don't add a trailing comma if the tuple has more than one element
|
||||||
|
write!(fmt, "{:?}", substitution)?;
|
||||||
|
} else {
|
||||||
|
write!(fmt, "{:?},", substitution)?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
write!(fmt, ")")
|
||||||
|
})()),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn debug_alias(
|
fn debug_alias(
|
||||||
alias_ty: &chalk_ir::AliasTy<Self>,
|
alias_ty: &chalk_ir::AliasTy<Self>,
|
||||||
fmt: &mut fmt::Formatter<'_>,
|
fmt: &mut fmt::Formatter<'_>,
|
||||||
|
@ -12,9 +12,9 @@ rustc_hir = { path = "../rustc_hir" }
|
|||||||
rustc_index = { path = "../rustc_index" }
|
rustc_index = { path = "../rustc_index" }
|
||||||
rustc_ast = { path = "../rustc_ast" }
|
rustc_ast = { path = "../rustc_ast" }
|
||||||
rustc_span = { path = "../rustc_span" }
|
rustc_span = { path = "../rustc_span" }
|
||||||
chalk-ir = "0.32.0"
|
chalk-ir = "0.35.0"
|
||||||
chalk-solve = "0.32.0"
|
chalk-solve = "0.35.0"
|
||||||
chalk-engine = "0.32.0"
|
chalk-engine = "0.35.0"
|
||||||
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
|
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
|
||||||
rustc_infer = { path = "../rustc_infer" }
|
rustc_infer = { path = "../rustc_infer" }
|
||||||
rustc_trait_selection = { path = "../rustc_trait_selection" }
|
rustc_trait_selection = { path = "../rustc_trait_selection" }
|
||||||
|
@ -324,19 +324,19 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
|||||||
fn impl_provided_for(
|
fn impl_provided_for(
|
||||||
&self,
|
&self,
|
||||||
auto_trait_id: chalk_ir::TraitId<RustInterner<'tcx>>,
|
auto_trait_id: chalk_ir::TraitId<RustInterner<'tcx>>,
|
||||||
app_ty: &chalk_ir::ApplicationTy<RustInterner<'tcx>>,
|
chalk_ty: &chalk_ir::TyKind<RustInterner<'tcx>>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
use chalk_ir::Scalar::*;
|
use chalk_ir::Scalar::*;
|
||||||
use chalk_ir::TypeName::*;
|
use chalk_ir::TyKind::*;
|
||||||
|
|
||||||
let trait_def_id = auto_trait_id.0;
|
let trait_def_id = auto_trait_id.0;
|
||||||
let all_impls = self.interner.tcx.all_impls(trait_def_id);
|
let all_impls = self.interner.tcx.all_impls(trait_def_id);
|
||||||
for impl_def_id in all_impls {
|
for impl_def_id in all_impls {
|
||||||
let trait_ref = self.interner.tcx.impl_trait_ref(impl_def_id).unwrap();
|
let trait_ref = self.interner.tcx.impl_trait_ref(impl_def_id).unwrap();
|
||||||
let self_ty = trait_ref.self_ty();
|
let self_ty = trait_ref.self_ty();
|
||||||
let provides = match (self_ty.kind(), app_ty.name) {
|
let provides = match (self_ty.kind(), chalk_ty) {
|
||||||
(&ty::Adt(impl_adt_def, ..), Adt(id)) => impl_adt_def.did == id.0.did,
|
(&ty::Adt(impl_adt_def, ..), Adt(id, ..)) => impl_adt_def.did == id.0.did,
|
||||||
(_, AssociatedType(_ty_id)) => {
|
(_, AssociatedType(_ty_id, ..)) => {
|
||||||
// FIXME(chalk): See https://github.com/rust-lang/rust/pull/77152#discussion_r494484774
|
// FIXME(chalk): See https://github.com/rust-lang/rust/pull/77152#discussion_r494484774
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
@ -365,10 +365,10 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
|||||||
(ast::FloatTy::F32, chalk_ir::FloatTy::F32)
|
(ast::FloatTy::F32, chalk_ir::FloatTy::F32)
|
||||||
| (ast::FloatTy::F64, chalk_ir::FloatTy::F64)
|
| (ast::FloatTy::F64, chalk_ir::FloatTy::F64)
|
||||||
),
|
),
|
||||||
(&ty::Tuple(..), Tuple(..)) => true,
|
(&ty::Tuple(substs), Tuple(len, _)) => substs.len() == *len,
|
||||||
(&ty::Array(..), Array) => true,
|
(&ty::Array(..), Array(..)) => true,
|
||||||
(&ty::Slice(..), Slice) => true,
|
(&ty::Slice(..), Slice(..)) => true,
|
||||||
(&ty::RawPtr(type_and_mut), Raw(mutability)) => {
|
(&ty::RawPtr(type_and_mut), Raw(mutability, _)) => {
|
||||||
match (type_and_mut.mutbl, mutability) {
|
match (type_and_mut.mutbl, mutability) {
|
||||||
(ast::Mutability::Mut, chalk_ir::Mutability::Mut) => true,
|
(ast::Mutability::Mut, chalk_ir::Mutability::Mut) => true,
|
||||||
(ast::Mutability::Mut, chalk_ir::Mutability::Not) => false,
|
(ast::Mutability::Mut, chalk_ir::Mutability::Not) => false,
|
||||||
@ -376,17 +376,19 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
|||||||
(ast::Mutability::Not, chalk_ir::Mutability::Not) => true,
|
(ast::Mutability::Not, chalk_ir::Mutability::Not) => true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(&ty::Ref(.., mutability1), Ref(mutability2)) => match (mutability1, mutability2) {
|
(&ty::Ref(.., mutability1), Ref(mutability2, ..)) => {
|
||||||
|
match (mutability1, mutability2) {
|
||||||
(ast::Mutability::Mut, chalk_ir::Mutability::Mut) => true,
|
(ast::Mutability::Mut, chalk_ir::Mutability::Mut) => true,
|
||||||
(ast::Mutability::Mut, chalk_ir::Mutability::Not) => false,
|
(ast::Mutability::Mut, chalk_ir::Mutability::Not) => false,
|
||||||
(ast::Mutability::Not, chalk_ir::Mutability::Mut) => false,
|
(ast::Mutability::Not, chalk_ir::Mutability::Mut) => false,
|
||||||
(ast::Mutability::Not, chalk_ir::Mutability::Not) => true,
|
(ast::Mutability::Not, chalk_ir::Mutability::Not) => true,
|
||||||
},
|
}
|
||||||
(&ty::Opaque(def_id, ..), OpaqueType(opaque_ty_id)) => def_id == opaque_ty_id.0,
|
}
|
||||||
(&ty::FnDef(def_id, ..), FnDef(fn_def_id)) => def_id == fn_def_id.0,
|
(&ty::Opaque(def_id, ..), OpaqueType(opaque_ty_id, ..)) => def_id == opaque_ty_id.0,
|
||||||
|
(&ty::FnDef(def_id, ..), FnDef(fn_def_id, ..)) => def_id == fn_def_id.0,
|
||||||
(&ty::Str, Str) => true,
|
(&ty::Str, Str) => true,
|
||||||
(&ty::Never, Never) => true,
|
(&ty::Never, Never) => true,
|
||||||
(&ty::Closure(def_id, ..), Closure(closure_id)) => def_id == closure_id.0,
|
(&ty::Closure(def_id, ..), Closure(closure_id, _)) => def_id == closure_id.0,
|
||||||
(&ty::Foreign(def_id), Foreign(foreign_def_id)) => def_id == foreign_def_id.0,
|
(&ty::Foreign(def_id), Foreign(foreign_def_id)) => def_id == foreign_def_id.0,
|
||||||
(&ty::Error(..), Error) => false,
|
(&ty::Error(..), Error) => false,
|
||||||
_ => false,
|
_ => false,
|
||||||
@ -506,20 +508,14 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
|||||||
substs: &chalk_ir::Substitution<RustInterner<'tcx>>,
|
substs: &chalk_ir::Substitution<RustInterner<'tcx>>,
|
||||||
) -> chalk_solve::rust_ir::ClosureKind {
|
) -> chalk_solve::rust_ir::ClosureKind {
|
||||||
let kind = &substs.as_slice(&self.interner)[substs.len(&self.interner) - 3];
|
let kind = &substs.as_slice(&self.interner)[substs.len(&self.interner) - 3];
|
||||||
match kind.assert_ty_ref(&self.interner).data(&self.interner) {
|
match kind.assert_ty_ref(&self.interner).kind(&self.interner) {
|
||||||
chalk_ir::TyData::Apply(apply) => match apply.name {
|
chalk_ir::TyKind::Scalar(chalk_ir::Scalar::Int(int_ty)) => match int_ty {
|
||||||
chalk_ir::TypeName::Scalar(scalar) => match scalar {
|
|
||||||
chalk_ir::Scalar::Int(int_ty) => match int_ty {
|
|
||||||
chalk_ir::IntTy::I8 => chalk_solve::rust_ir::ClosureKind::Fn,
|
chalk_ir::IntTy::I8 => chalk_solve::rust_ir::ClosureKind::Fn,
|
||||||
chalk_ir::IntTy::I16 => chalk_solve::rust_ir::ClosureKind::FnMut,
|
chalk_ir::IntTy::I16 => chalk_solve::rust_ir::ClosureKind::FnMut,
|
||||||
chalk_ir::IntTy::I32 => chalk_solve::rust_ir::ClosureKind::FnOnce,
|
chalk_ir::IntTy::I32 => chalk_solve::rust_ir::ClosureKind::FnOnce,
|
||||||
_ => bug!("bad closure kind"),
|
_ => bug!("bad closure kind"),
|
||||||
},
|
},
|
||||||
_ => bug!("bad closure kind"),
|
_ => bug!("bad closure kind"),
|
||||||
},
|
|
||||||
_ => bug!("bad closure kind"),
|
|
||||||
},
|
|
||||||
_ => bug!("bad closure kind"),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -530,24 +526,20 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
|||||||
) -> chalk_ir::Binders<chalk_solve::rust_ir::FnDefInputsAndOutputDatum<RustInterner<'tcx>>>
|
) -> chalk_ir::Binders<chalk_solve::rust_ir::FnDefInputsAndOutputDatum<RustInterner<'tcx>>>
|
||||||
{
|
{
|
||||||
let sig = &substs.as_slice(&self.interner)[substs.len(&self.interner) - 2];
|
let sig = &substs.as_slice(&self.interner)[substs.len(&self.interner) - 2];
|
||||||
match sig.assert_ty_ref(&self.interner).data(&self.interner) {
|
match sig.assert_ty_ref(&self.interner).kind(&self.interner) {
|
||||||
chalk_ir::TyData::Function(f) => {
|
chalk_ir::TyKind::Function(f) => {
|
||||||
let substitution = f.substitution.as_slice(&self.interner);
|
let substitution = f.substitution.as_slice(&self.interner);
|
||||||
let return_type =
|
let return_type =
|
||||||
substitution.last().unwrap().assert_ty_ref(&self.interner).clone();
|
substitution.last().unwrap().assert_ty_ref(&self.interner).clone();
|
||||||
// Closure arguments are tupled
|
// Closure arguments are tupled
|
||||||
let argument_tuple = substitution[0].assert_ty_ref(&self.interner);
|
let argument_tuple = substitution[0].assert_ty_ref(&self.interner);
|
||||||
let argument_types = match argument_tuple.data(&self.interner) {
|
let argument_types = match argument_tuple.kind(&self.interner) {
|
||||||
chalk_ir::TyData::Apply(apply) => match apply.name {
|
chalk_ir::TyKind::Tuple(_len, substitution) => substitution
|
||||||
chalk_ir::TypeName::Tuple(_) => apply
|
|
||||||
.substitution
|
|
||||||
.iter(&self.interner)
|
.iter(&self.interner)
|
||||||
.map(|arg| arg.assert_ty_ref(&self.interner))
|
.map(|arg| arg.assert_ty_ref(&self.interner))
|
||||||
.cloned()
|
.cloned()
|
||||||
.collect(),
|
.collect(),
|
||||||
_ => bug!("Expecting closure FnSig args to be tupled."),
|
_ => bug!("Expecting closure FnSig args to be tupled."),
|
||||||
},
|
|
||||||
_ => bug!("Expecting closure FnSig args to be tupled."),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
chalk_ir::Binders::new(
|
chalk_ir::Binders::new(
|
||||||
@ -637,7 +629,7 @@ fn binders_for<'tcx>(
|
|||||||
bound_vars.iter().map(|arg| match arg.unpack() {
|
bound_vars.iter().map(|arg| match arg.unpack() {
|
||||||
ty::subst::GenericArgKind::Lifetime(_re) => chalk_ir::VariableKind::Lifetime,
|
ty::subst::GenericArgKind::Lifetime(_re) => chalk_ir::VariableKind::Lifetime,
|
||||||
ty::subst::GenericArgKind::Type(_ty) => {
|
ty::subst::GenericArgKind::Type(_ty) => {
|
||||||
chalk_ir::VariableKind::Ty(chalk_ir::TyKind::General)
|
chalk_ir::VariableKind::Ty(chalk_ir::TyVariableKind::General)
|
||||||
}
|
}
|
||||||
ty::subst::GenericArgKind::Const(c) => {
|
ty::subst::GenericArgKind::Const(c) => {
|
||||||
chalk_ir::VariableKind::Const(c.ty.lower_into(interner))
|
chalk_ir::VariableKind::Const(c.ty.lower_into(interner))
|
||||||
|
@ -35,7 +35,7 @@ use rustc_middle::traits::{ChalkEnvironmentAndGoal, ChalkRustInterner as RustInt
|
|||||||
use rustc_middle::ty::fold::TypeFolder;
|
use rustc_middle::ty::fold::TypeFolder;
|
||||||
use rustc_middle::ty::subst::{GenericArg, GenericArgKind, SubstsRef};
|
use rustc_middle::ty::subst::{GenericArg, GenericArgKind, SubstsRef};
|
||||||
use rustc_middle::ty::{
|
use rustc_middle::ty::{
|
||||||
self, Binder, BoundRegion, Region, RegionKind, Ty, TyCtxt, TyKind, TypeFoldable, TypeVisitor,
|
self, Binder, BoundRegion, Region, RegionKind, Ty, TyCtxt, TypeFoldable, TypeVisitor,
|
||||||
};
|
};
|
||||||
use rustc_span::def_id::DefId;
|
use rustc_span::def_id::DefId;
|
||||||
|
|
||||||
@ -239,24 +239,16 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::AliasEq<RustInterner<'tcx>>>
|
|||||||
|
|
||||||
impl<'tcx> LowerInto<'tcx, chalk_ir::Ty<RustInterner<'tcx>>> for Ty<'tcx> {
|
impl<'tcx> LowerInto<'tcx, chalk_ir::Ty<RustInterner<'tcx>>> for Ty<'tcx> {
|
||||||
fn lower_into(self, interner: &RustInterner<'tcx>) -> chalk_ir::Ty<RustInterner<'tcx>> {
|
fn lower_into(self, interner: &RustInterner<'tcx>) -> chalk_ir::Ty<RustInterner<'tcx>> {
|
||||||
use chalk_ir::TyData;
|
|
||||||
use rustc_ast as ast;
|
use rustc_ast as ast;
|
||||||
use TyKind::*;
|
|
||||||
|
|
||||||
let empty = || chalk_ir::Substitution::empty(interner);
|
let int = |i| chalk_ir::TyKind::Scalar(chalk_ir::Scalar::Int(i));
|
||||||
let struct_ty =
|
let uint = |i| chalk_ir::TyKind::Scalar(chalk_ir::Scalar::Uint(i));
|
||||||
|def_id| chalk_ir::TypeName::Adt(chalk_ir::AdtId(interner.tcx.adt_def(def_id)));
|
let float = |f| chalk_ir::TyKind::Scalar(chalk_ir::Scalar::Float(f));
|
||||||
let apply = |name, substitution| {
|
|
||||||
TyData::Apply(chalk_ir::ApplicationTy { name, substitution }).intern(interner)
|
|
||||||
};
|
|
||||||
let int = |i| apply(chalk_ir::TypeName::Scalar(chalk_ir::Scalar::Int(i)), empty());
|
|
||||||
let uint = |i| apply(chalk_ir::TypeName::Scalar(chalk_ir::Scalar::Uint(i)), empty());
|
|
||||||
let float = |f| apply(chalk_ir::TypeName::Scalar(chalk_ir::Scalar::Float(f)), empty());
|
|
||||||
|
|
||||||
match *self.kind() {
|
match *self.kind() {
|
||||||
Bool => apply(chalk_ir::TypeName::Scalar(chalk_ir::Scalar::Bool), empty()),
|
ty::Bool => chalk_ir::TyKind::Scalar(chalk_ir::Scalar::Bool),
|
||||||
Char => apply(chalk_ir::TypeName::Scalar(chalk_ir::Scalar::Char), empty()),
|
ty::Char => chalk_ir::TyKind::Scalar(chalk_ir::Scalar::Char),
|
||||||
Int(ty) => match ty {
|
ty::Int(ty) => match ty {
|
||||||
ast::IntTy::Isize => int(chalk_ir::IntTy::Isize),
|
ast::IntTy::Isize => int(chalk_ir::IntTy::Isize),
|
||||||
ast::IntTy::I8 => int(chalk_ir::IntTy::I8),
|
ast::IntTy::I8 => int(chalk_ir::IntTy::I8),
|
||||||
ast::IntTy::I16 => int(chalk_ir::IntTy::I16),
|
ast::IntTy::I16 => int(chalk_ir::IntTy::I16),
|
||||||
@ -264,7 +256,7 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Ty<RustInterner<'tcx>>> for Ty<'tcx> {
|
|||||||
ast::IntTy::I64 => int(chalk_ir::IntTy::I64),
|
ast::IntTy::I64 => int(chalk_ir::IntTy::I64),
|
||||||
ast::IntTy::I128 => int(chalk_ir::IntTy::I128),
|
ast::IntTy::I128 => int(chalk_ir::IntTy::I128),
|
||||||
},
|
},
|
||||||
Uint(ty) => match ty {
|
ty::Uint(ty) => match ty {
|
||||||
ast::UintTy::Usize => uint(chalk_ir::UintTy::Usize),
|
ast::UintTy::Usize => uint(chalk_ir::UintTy::Usize),
|
||||||
ast::UintTy::U8 => uint(chalk_ir::UintTy::U8),
|
ast::UintTy::U8 => uint(chalk_ir::UintTy::U8),
|
||||||
ast::UintTy::U16 => uint(chalk_ir::UintTy::U16),
|
ast::UintTy::U16 => uint(chalk_ir::UintTy::U16),
|
||||||
@ -272,80 +264,47 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Ty<RustInterner<'tcx>>> for Ty<'tcx> {
|
|||||||
ast::UintTy::U64 => uint(chalk_ir::UintTy::U64),
|
ast::UintTy::U64 => uint(chalk_ir::UintTy::U64),
|
||||||
ast::UintTy::U128 => uint(chalk_ir::UintTy::U128),
|
ast::UintTy::U128 => uint(chalk_ir::UintTy::U128),
|
||||||
},
|
},
|
||||||
Float(ty) => match ty {
|
ty::Float(ty) => match ty {
|
||||||
ast::FloatTy::F32 => float(chalk_ir::FloatTy::F32),
|
ast::FloatTy::F32 => float(chalk_ir::FloatTy::F32),
|
||||||
ast::FloatTy::F64 => float(chalk_ir::FloatTy::F64),
|
ast::FloatTy::F64 => float(chalk_ir::FloatTy::F64),
|
||||||
},
|
},
|
||||||
Adt(def, substs) => apply(struct_ty(def.did), substs.lower_into(interner)),
|
ty::Adt(def, substs) => {
|
||||||
Foreign(def_id) => apply(chalk_ir::TypeName::Foreign(ForeignDefId(def_id)), empty()),
|
chalk_ir::TyKind::Adt(chalk_ir::AdtId(def), substs.lower_into(interner))
|
||||||
Str => apply(chalk_ir::TypeName::Str, empty()),
|
|
||||||
Array(ty, len) => {
|
|
||||||
let value = match len.val {
|
|
||||||
ty::ConstKind::Value(val) => {
|
|
||||||
chalk_ir::ConstValue::Concrete(chalk_ir::ConcreteConst { interned: val })
|
|
||||||
}
|
}
|
||||||
ty::ConstKind::Bound(db, bound) => {
|
ty::Foreign(def_id) => chalk_ir::TyKind::Foreign(ForeignDefId(def_id)),
|
||||||
chalk_ir::ConstValue::BoundVar(chalk_ir::BoundVar::new(
|
ty::Str => chalk_ir::TyKind::Str,
|
||||||
chalk_ir::DebruijnIndex::new(db.as_u32()),
|
ty::Array(ty, len) => {
|
||||||
bound.index(),
|
chalk_ir::TyKind::Array(ty.lower_into(interner), len.lower_into(interner))
|
||||||
))
|
|
||||||
}
|
}
|
||||||
_ => unimplemented!("Const not implemented. {:?}", len.val),
|
ty::Slice(ty) => chalk_ir::TyKind::Slice(ty.lower_into(interner)),
|
||||||
};
|
|
||||||
apply(
|
ty::RawPtr(ptr) => match ptr.mutbl {
|
||||||
chalk_ir::TypeName::Array,
|
ast::Mutability::Mut => {
|
||||||
chalk_ir::Substitution::from_iter(
|
chalk_ir::TyKind::Raw(chalk_ir::Mutability::Mut, ptr.ty.lower_into(interner))
|
||||||
interner,
|
|
||||||
&[
|
|
||||||
chalk_ir::GenericArgData::Ty(ty.lower_into(interner)).intern(interner),
|
|
||||||
chalk_ir::GenericArgData::Const(
|
|
||||||
chalk_ir::ConstData { ty: len.ty.lower_into(interner), value }
|
|
||||||
.intern(interner),
|
|
||||||
)
|
|
||||||
.intern(interner),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
Slice(ty) => apply(
|
ast::Mutability::Not => {
|
||||||
chalk_ir::TypeName::Slice,
|
chalk_ir::TyKind::Raw(chalk_ir::Mutability::Not, ptr.ty.lower_into(interner))
|
||||||
chalk_ir::Substitution::from1(
|
|
||||||
interner,
|
|
||||||
chalk_ir::GenericArgData::Ty(ty.lower_into(interner)).intern(interner),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
RawPtr(ptr) => {
|
|
||||||
let name = match ptr.mutbl {
|
|
||||||
ast::Mutability::Mut => chalk_ir::TypeName::Raw(chalk_ir::Mutability::Mut),
|
|
||||||
ast::Mutability::Not => chalk_ir::TypeName::Raw(chalk_ir::Mutability::Not),
|
|
||||||
};
|
|
||||||
apply(name, chalk_ir::Substitution::from1(interner, ptr.ty.lower_into(interner)))
|
|
||||||
}
|
}
|
||||||
Ref(region, ty, mutability) => {
|
},
|
||||||
let name = match mutability {
|
ty::Ref(region, ty, mutability) => match mutability {
|
||||||
ast::Mutability::Mut => chalk_ir::TypeName::Ref(chalk_ir::Mutability::Mut),
|
ast::Mutability::Mut => chalk_ir::TyKind::Ref(
|
||||||
ast::Mutability::Not => chalk_ir::TypeName::Ref(chalk_ir::Mutability::Not),
|
chalk_ir::Mutability::Mut,
|
||||||
};
|
region.lower_into(interner),
|
||||||
apply(
|
ty.lower_into(interner),
|
||||||
name,
|
|
||||||
chalk_ir::Substitution::from_iter(
|
|
||||||
interner,
|
|
||||||
&[
|
|
||||||
chalk_ir::GenericArgData::Lifetime(region.lower_into(interner))
|
|
||||||
.intern(interner),
|
|
||||||
chalk_ir::GenericArgData::Ty(ty.lower_into(interner)).intern(interner),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
)
|
ast::Mutability::Not => chalk_ir::TyKind::Ref(
|
||||||
|
chalk_ir::Mutability::Not,
|
||||||
|
region.lower_into(interner),
|
||||||
|
ty.lower_into(interner),
|
||||||
|
),
|
||||||
|
},
|
||||||
|
ty::FnDef(def_id, substs) => {
|
||||||
|
chalk_ir::TyKind::FnDef(chalk_ir::FnDefId(def_id), substs.lower_into(interner))
|
||||||
}
|
}
|
||||||
FnDef(def_id, substs) => apply(
|
ty::FnPtr(sig) => {
|
||||||
chalk_ir::TypeName::FnDef(chalk_ir::FnDefId(def_id)),
|
|
||||||
substs.lower_into(interner),
|
|
||||||
),
|
|
||||||
FnPtr(sig) => {
|
|
||||||
let (inputs_and_outputs, binders, _named_regions) =
|
let (inputs_and_outputs, binders, _named_regions) =
|
||||||
collect_bound_vars(interner, interner.tcx, &sig.inputs_and_output());
|
collect_bound_vars(interner, interner.tcx, &sig.inputs_and_output());
|
||||||
TyData::Function(chalk_ir::FnPointer {
|
chalk_ir::TyKind::Function(chalk_ir::FnPointer {
|
||||||
num_binders: binders.len(interner),
|
num_binders: binders.len(interner),
|
||||||
sig: sig.lower_into(interner),
|
sig: sig.lower_into(interner),
|
||||||
substitution: chalk_ir::Substitution::from_iter(
|
substitution: chalk_ir::Substitution::from_iter(
|
||||||
@ -355,61 +314,55 @@ impl<'tcx> LowerInto<'tcx, chalk_ir::Ty<RustInterner<'tcx>>> for Ty<'tcx> {
|
|||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
.intern(interner)
|
|
||||||
}
|
}
|
||||||
Dynamic(predicates, region) => TyData::Dyn(chalk_ir::DynTy {
|
ty::Dynamic(predicates, region) => chalk_ir::TyKind::Dyn(chalk_ir::DynTy {
|
||||||
bounds: predicates.lower_into(interner),
|
bounds: predicates.lower_into(interner),
|
||||||
lifetime: region.lower_into(interner),
|
lifetime: region.lower_into(interner),
|
||||||
})
|
}),
|
||||||
.intern(interner),
|
ty::Closure(def_id, substs) => {
|
||||||
Closure(def_id, substs) => apply(
|
chalk_ir::TyKind::Closure(chalk_ir::ClosureId(def_id), substs.lower_into(interner))
|
||||||
chalk_ir::TypeName::Closure(chalk_ir::ClosureId(def_id)),
|
|
||||||
substs.lower_into(interner),
|
|
||||||
),
|
|
||||||
Generator(_def_id, _substs, _) => unimplemented!(),
|
|
||||||
GeneratorWitness(_) => unimplemented!(),
|
|
||||||
Never => apply(chalk_ir::TypeName::Never, empty()),
|
|
||||||
Tuple(substs) => {
|
|
||||||
apply(chalk_ir::TypeName::Tuple(substs.len()), substs.lower_into(interner))
|
|
||||||
}
|
}
|
||||||
Projection(proj) => TyData::Alias(proj.lower_into(interner)).intern(interner),
|
ty::Generator(_def_id, _substs, _) => unimplemented!(),
|
||||||
Opaque(def_id, substs) => {
|
ty::GeneratorWitness(_) => unimplemented!(),
|
||||||
TyData::Alias(chalk_ir::AliasTy::Opaque(chalk_ir::OpaqueTy {
|
ty::Never => chalk_ir::TyKind::Never,
|
||||||
|
ty::Tuple(substs) => chalk_ir::TyKind::Tuple(substs.len(), substs.lower_into(interner)),
|
||||||
|
ty::Projection(proj) => chalk_ir::TyKind::Alias(proj.lower_into(interner)),
|
||||||
|
ty::Opaque(def_id, substs) => {
|
||||||
|
chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Opaque(chalk_ir::OpaqueTy {
|
||||||
opaque_ty_id: chalk_ir::OpaqueTyId(def_id),
|
opaque_ty_id: chalk_ir::OpaqueTyId(def_id),
|
||||||
substitution: substs.lower_into(interner),
|
substitution: substs.lower_into(interner),
|
||||||
}))
|
}))
|
||||||
.intern(interner)
|
|
||||||
}
|
}
|
||||||
// This should have been done eagerly prior to this, and all Params
|
// This should have been done eagerly prior to this, and all Params
|
||||||
// should have been substituted to placeholders
|
// should have been substituted to placeholders
|
||||||
Param(_) => panic!("Lowering Param when not expected."),
|
ty::Param(_) => panic!("Lowering Param when not expected."),
|
||||||
Bound(db, bound) => TyData::BoundVar(chalk_ir::BoundVar::new(
|
ty::Bound(db, bound) => chalk_ir::TyKind::BoundVar(chalk_ir::BoundVar::new(
|
||||||
chalk_ir::DebruijnIndex::new(db.as_u32()),
|
chalk_ir::DebruijnIndex::new(db.as_u32()),
|
||||||
bound.var.index(),
|
bound.var.index(),
|
||||||
))
|
)),
|
||||||
.intern(interner),
|
ty::Placeholder(_placeholder) => {
|
||||||
Placeholder(_placeholder) => TyData::Placeholder(chalk_ir::PlaceholderIndex {
|
chalk_ir::TyKind::Placeholder(chalk_ir::PlaceholderIndex {
|
||||||
ui: chalk_ir::UniverseIndex { counter: _placeholder.universe.as_usize() },
|
ui: chalk_ir::UniverseIndex { counter: _placeholder.universe.as_usize() },
|
||||||
idx: _placeholder.name.as_usize(),
|
idx: _placeholder.name.as_usize(),
|
||||||
})
|
})
|
||||||
.intern(interner),
|
|
||||||
Infer(_infer) => unimplemented!(),
|
|
||||||
Error(_) => apply(chalk_ir::TypeName::Error, empty()),
|
|
||||||
}
|
}
|
||||||
|
ty::Infer(_infer) => unimplemented!(),
|
||||||
|
ty::Error(_) => chalk_ir::TyKind::Error,
|
||||||
|
}
|
||||||
|
.intern(interner)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> LowerInto<'tcx, Ty<'tcx>> for &chalk_ir::Ty<RustInterner<'tcx>> {
|
impl<'tcx> LowerInto<'tcx, Ty<'tcx>> for &chalk_ir::Ty<RustInterner<'tcx>> {
|
||||||
fn lower_into(self, interner: &RustInterner<'tcx>) -> Ty<'tcx> {
|
fn lower_into(self, interner: &RustInterner<'tcx>) -> Ty<'tcx> {
|
||||||
use chalk_ir::TyData;
|
use chalk_ir::TyKind;
|
||||||
use rustc_ast::ast;
|
use rustc_ast::ast;
|
||||||
|
|
||||||
let kind = match self.data(interner) {
|
let kind = match self.kind(interner) {
|
||||||
TyData::Apply(application_ty) => match application_ty.name {
|
TyKind::Adt(struct_id, substitution) => {
|
||||||
chalk_ir::TypeName::Adt(struct_id) => {
|
ty::Adt(struct_id.0, substitution.lower_into(interner))
|
||||||
ty::Adt(struct_id.0, application_ty.substitution.lower_into(interner))
|
|
||||||
}
|
}
|
||||||
chalk_ir::TypeName::Scalar(scalar) => match scalar {
|
TyKind::Scalar(scalar) => match scalar {
|
||||||
chalk_ir::Scalar::Bool => ty::Bool,
|
chalk_ir::Scalar::Bool => ty::Bool,
|
||||||
chalk_ir::Scalar::Char => ty::Char,
|
chalk_ir::Scalar::Char => ty::Char,
|
||||||
chalk_ir::Scalar::Int(int_ty) => match int_ty {
|
chalk_ir::Scalar::Int(int_ty) => match int_ty {
|
||||||
@ -433,70 +386,50 @@ impl<'tcx> LowerInto<'tcx, Ty<'tcx>> for &chalk_ir::Ty<RustInterner<'tcx>> {
|
|||||||
chalk_ir::FloatTy::F64 => ty::Float(ast::FloatTy::F64),
|
chalk_ir::FloatTy::F64 => ty::Float(ast::FloatTy::F64),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
chalk_ir::TypeName::Array => {
|
TyKind::Array(ty, c) => {
|
||||||
let substs = application_ty.substitution.as_slice(interner);
|
let ty = ty.lower_into(interner);
|
||||||
let ty = substs[0].assert_ty_ref(interner).lower_into(interner);
|
let c = c.lower_into(interner);
|
||||||
let c = substs[1].assert_const_ref(interner).lower_into(interner);
|
|
||||||
ty::Array(ty, interner.tcx.mk_const(c))
|
ty::Array(ty, interner.tcx.mk_const(c))
|
||||||
}
|
}
|
||||||
chalk_ir::TypeName::FnDef(id) => {
|
TyKind::FnDef(id, substitution) => ty::FnDef(id.0, substitution.lower_into(interner)),
|
||||||
ty::FnDef(id.0, application_ty.substitution.lower_into(interner))
|
TyKind::Closure(closure, substitution) => {
|
||||||
|
ty::Closure(closure.0, substitution.lower_into(interner))
|
||||||
}
|
}
|
||||||
chalk_ir::TypeName::Closure(closure) => {
|
TyKind::Generator(..) => unimplemented!(),
|
||||||
ty::Closure(closure.0, application_ty.substitution.lower_into(interner))
|
TyKind::GeneratorWitness(..) => unimplemented!(),
|
||||||
}
|
TyKind::Never => ty::Never,
|
||||||
chalk_ir::TypeName::Generator(_) => unimplemented!(),
|
TyKind::Tuple(_len, substitution) => ty::Tuple(substitution.lower_into(interner)),
|
||||||
chalk_ir::TypeName::GeneratorWitness(_) => unimplemented!(),
|
TyKind::Slice(ty) => ty::Slice(ty.lower_into(interner)),
|
||||||
chalk_ir::TypeName::Never => ty::Never,
|
TyKind::Raw(mutbl, ty) => ty::RawPtr(ty::TypeAndMut {
|
||||||
chalk_ir::TypeName::Tuple(_size) => {
|
ty: ty.lower_into(interner),
|
||||||
ty::Tuple(application_ty.substitution.lower_into(interner))
|
|
||||||
}
|
|
||||||
chalk_ir::TypeName::Slice => ty::Slice(
|
|
||||||
application_ty.substitution.as_slice(interner)[0]
|
|
||||||
.ty(interner)
|
|
||||||
.unwrap()
|
|
||||||
.lower_into(interner),
|
|
||||||
),
|
|
||||||
chalk_ir::TypeName::Raw(mutbl) => ty::RawPtr(ty::TypeAndMut {
|
|
||||||
ty: application_ty.substitution.as_slice(interner)[0]
|
|
||||||
.ty(interner)
|
|
||||||
.unwrap()
|
|
||||||
.lower_into(interner),
|
|
||||||
mutbl: match mutbl {
|
mutbl: match mutbl {
|
||||||
chalk_ir::Mutability::Mut => ast::Mutability::Mut,
|
chalk_ir::Mutability::Mut => ast::Mutability::Mut,
|
||||||
chalk_ir::Mutability::Not => ast::Mutability::Not,
|
chalk_ir::Mutability::Not => ast::Mutability::Not,
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
chalk_ir::TypeName::Ref(mutbl) => ty::Ref(
|
TyKind::Ref(mutbl, lifetime, ty) => ty::Ref(
|
||||||
application_ty.substitution.as_slice(interner)[0]
|
lifetime.lower_into(interner),
|
||||||
.lifetime(interner)
|
ty.lower_into(interner),
|
||||||
.unwrap()
|
|
||||||
.lower_into(interner),
|
|
||||||
application_ty.substitution.as_slice(interner)[1]
|
|
||||||
.ty(interner)
|
|
||||||
.unwrap()
|
|
||||||
.lower_into(interner),
|
|
||||||
match mutbl {
|
match mutbl {
|
||||||
chalk_ir::Mutability::Mut => ast::Mutability::Mut,
|
chalk_ir::Mutability::Mut => ast::Mutability::Mut,
|
||||||
chalk_ir::Mutability::Not => ast::Mutability::Not,
|
chalk_ir::Mutability::Not => ast::Mutability::Not,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
chalk_ir::TypeName::Str => ty::Str,
|
TyKind::Str => ty::Str,
|
||||||
chalk_ir::TypeName::OpaqueType(opaque_ty) => {
|
TyKind::OpaqueType(opaque_ty, substitution) => {
|
||||||
ty::Opaque(opaque_ty.0, application_ty.substitution.lower_into(interner))
|
ty::Opaque(opaque_ty.0, substitution.lower_into(interner))
|
||||||
}
|
}
|
||||||
chalk_ir::TypeName::AssociatedType(assoc_ty) => ty::Projection(ty::ProjectionTy {
|
TyKind::AssociatedType(assoc_ty, substitution) => ty::Projection(ty::ProjectionTy {
|
||||||
substs: application_ty.substitution.lower_into(interner),
|
substs: substitution.lower_into(interner),
|
||||||
item_def_id: assoc_ty.0,
|
item_def_id: assoc_ty.0,
|
||||||
}),
|
}),
|
||||||
chalk_ir::TypeName::Foreign(def_id) => ty::Foreign(def_id.0),
|
TyKind::Foreign(def_id) => ty::Foreign(def_id.0),
|
||||||
chalk_ir::TypeName::Error => unimplemented!(),
|
TyKind::Error => return interner.tcx.ty_error(),
|
||||||
},
|
TyKind::Placeholder(placeholder) => ty::Placeholder(ty::Placeholder {
|
||||||
TyData::Placeholder(placeholder) => ty::Placeholder(ty::Placeholder {
|
|
||||||
universe: ty::UniverseIndex::from_usize(placeholder.ui.counter),
|
universe: ty::UniverseIndex::from_usize(placeholder.ui.counter),
|
||||||
name: ty::BoundVar::from_usize(placeholder.idx),
|
name: ty::BoundVar::from_usize(placeholder.idx),
|
||||||
}),
|
}),
|
||||||
chalk_ir::TyData::Alias(alias_ty) => match alias_ty {
|
TyKind::Alias(alias_ty) => match alias_ty {
|
||||||
chalk_ir::AliasTy::Projection(projection) => ty::Projection(ty::ProjectionTy {
|
chalk_ir::AliasTy::Projection(projection) => ty::Projection(ty::ProjectionTy {
|
||||||
item_def_id: projection.associated_ty_id.0,
|
item_def_id: projection.associated_ty_id.0,
|
||||||
substs: projection.substitution.lower_into(interner),
|
substs: projection.substitution.lower_into(interner),
|
||||||
@ -505,16 +438,16 @@ impl<'tcx> LowerInto<'tcx, Ty<'tcx>> for &chalk_ir::Ty<RustInterner<'tcx>> {
|
|||||||
ty::Opaque(opaque.opaque_ty_id.0, opaque.substitution.lower_into(interner))
|
ty::Opaque(opaque.opaque_ty_id.0, opaque.substitution.lower_into(interner))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
TyData::Function(_quantified_ty) => unimplemented!(),
|
TyKind::Function(_quantified_ty) => unimplemented!(),
|
||||||
TyData::BoundVar(_bound) => ty::Bound(
|
TyKind::BoundVar(_bound) => ty::Bound(
|
||||||
ty::DebruijnIndex::from_usize(_bound.debruijn.depth() as usize),
|
ty::DebruijnIndex::from_usize(_bound.debruijn.depth() as usize),
|
||||||
ty::BoundTy {
|
ty::BoundTy {
|
||||||
var: ty::BoundVar::from_usize(_bound.index),
|
var: ty::BoundVar::from_usize(_bound.index),
|
||||||
kind: ty::BoundTyKind::Anon,
|
kind: ty::BoundTyKind::Anon,
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
TyData::InferenceVar(_, _) => unimplemented!(),
|
TyKind::InferenceVar(_, _) => unimplemented!(),
|
||||||
TyData::Dyn(_) => unimplemented!(),
|
TyKind::Dyn(_) => unimplemented!(),
|
||||||
};
|
};
|
||||||
interner.tcx.mk_ty(kind)
|
interner.tcx.mk_ty(kind)
|
||||||
}
|
}
|
||||||
@ -909,7 +842,7 @@ impl<'tcx> TypeVisitor<'tcx> for BoundVarsCollector<'tcx> {
|
|||||||
ty::Bound(debruijn, bound_ty) if debruijn == self.binder_index => {
|
ty::Bound(debruijn, bound_ty) if debruijn == self.binder_index => {
|
||||||
match self.parameters.entry(bound_ty.var.as_u32()) {
|
match self.parameters.entry(bound_ty.var.as_u32()) {
|
||||||
Entry::Vacant(entry) => {
|
Entry::Vacant(entry) => {
|
||||||
entry.insert(chalk_ir::VariableKind::Ty(chalk_ir::TyKind::General));
|
entry.insert(chalk_ir::VariableKind::Ty(chalk_ir::TyVariableKind::General));
|
||||||
}
|
}
|
||||||
Entry::Occupied(entry) => match entry.get() {
|
Entry::Occupied(entry) => match entry.get() {
|
||||||
chalk_ir::VariableKind::Ty(_) => {}
|
chalk_ir::VariableKind::Ty(_) => {}
|
||||||
|
@ -69,15 +69,15 @@ crate fn evaluate_goal<'tcx>(
|
|||||||
CanonicalVarKind::PlaceholderRegion(_ui) => unimplemented!(),
|
CanonicalVarKind::PlaceholderRegion(_ui) => unimplemented!(),
|
||||||
CanonicalVarKind::Ty(ty) => match ty {
|
CanonicalVarKind::Ty(ty) => match ty {
|
||||||
CanonicalTyVarKind::General(ui) => chalk_ir::WithKind::new(
|
CanonicalTyVarKind::General(ui) => chalk_ir::WithKind::new(
|
||||||
chalk_ir::VariableKind::Ty(chalk_ir::TyKind::General),
|
chalk_ir::VariableKind::Ty(chalk_ir::TyVariableKind::General),
|
||||||
chalk_ir::UniverseIndex { counter: ui.index() },
|
chalk_ir::UniverseIndex { counter: ui.index() },
|
||||||
),
|
),
|
||||||
CanonicalTyVarKind::Int => chalk_ir::WithKind::new(
|
CanonicalTyVarKind::Int => chalk_ir::WithKind::new(
|
||||||
chalk_ir::VariableKind::Ty(chalk_ir::TyKind::Integer),
|
chalk_ir::VariableKind::Ty(chalk_ir::TyVariableKind::Integer),
|
||||||
chalk_ir::UniverseIndex::root(),
|
chalk_ir::UniverseIndex::root(),
|
||||||
),
|
),
|
||||||
CanonicalTyVarKind::Float => chalk_ir::WithKind::new(
|
CanonicalTyVarKind::Float => chalk_ir::WithKind::new(
|
||||||
chalk_ir::VariableKind::Ty(chalk_ir::TyKind::Float),
|
chalk_ir::VariableKind::Ty(chalk_ir::TyVariableKind::Float),
|
||||||
chalk_ir::UniverseIndex::root(),
|
chalk_ir::UniverseIndex::root(),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
@ -97,7 +97,8 @@ crate fn evaluate_goal<'tcx>(
|
|||||||
use chalk_solve::Solver;
|
use chalk_solve::Solver;
|
||||||
let mut solver = chalk_engine::solve::SLGSolver::new(32, None);
|
let mut solver = chalk_engine::solve::SLGSolver::new(32, None);
|
||||||
let db = ChalkRustIrDatabase { interner, reempty_placeholder };
|
let db = ChalkRustIrDatabase { interner, reempty_placeholder };
|
||||||
let solution = chalk_solve::logging::with_tracing_logs(|| solver.solve(&db, &lowered_goal));
|
let solution = solver.solve(&db, &lowered_goal);
|
||||||
|
debug!(?obligation, ?solution, "evaluatate goal");
|
||||||
|
|
||||||
// Ideally, the code to convert *back* to rustc types would live close to
|
// Ideally, the code to convert *back* to rustc types would live close to
|
||||||
// the code to convert *from* rustc types. Right now though, we don't
|
// the code to convert *from* rustc types. Right now though, we don't
|
||||||
|
Loading…
Reference in New Issue
Block a user