Bump chalk

This commit is contained in:
Laurențiu Nicola 2022-07-03 10:22:10 +03:00
parent e05e6c60a7
commit 78beb4c444
6 changed files with 67 additions and 67 deletions

16
Cargo.lock generated
View File

@ -171,9 +171,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]] [[package]]
name = "chalk-derive" name = "chalk-derive"
version = "0.82.0" version = "0.83.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee9cd790d543c29ce953abcb28d54b9fbaf9c4033bfd3024de99b1aa0f3c3ada" checksum = "83553c2ef7717e58aecdf42dd9e3c876229f5a1f35a16435b5ddc4addef81827"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -183,9 +183,9 @@ dependencies = [
[[package]] [[package]]
name = "chalk-ir" name = "chalk-ir"
version = "0.82.0" version = "0.83.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dddf2c11f9de666c08c7591eb113efcdc740bd8ac602915475b045bcbe7f27a5" checksum = "2dd42107d579d8ec2a5af20a8de62a37524a67bf6a4c0ff08a950068f0bfea91"
dependencies = [ dependencies = [
"bitflags", "bitflags",
"chalk-derive", "chalk-derive",
@ -194,9 +194,9 @@ dependencies = [
[[package]] [[package]]
name = "chalk-recursive" name = "chalk-recursive"
version = "0.82.0" version = "0.83.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a60d5b35598702963ffd145b8bfa0d8d8ae9da3a731e4e0814aa21541b85c2d5" checksum = "c444031541a76c13c145e76d91f1548e9feb2240e7f0c3e77879ceb694994f2d"
dependencies = [ dependencies = [
"chalk-derive", "chalk-derive",
"chalk-ir", "chalk-ir",
@ -207,9 +207,9 @@ dependencies = [
[[package]] [[package]]
name = "chalk-solve" name = "chalk-solve"
version = "0.82.0" version = "0.83.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d99da4fa3b224c07f6c2506e6905bca9d6aad665f11d25364e6818a7ea149215" checksum = "c76f2db19c5e8a3d42340cf5b4d90b8c218750536fca35e2bb285ab6653c0bc8"
dependencies = [ dependencies = [
"chalk-derive", "chalk-derive",
"chalk-ir", "chalk-ir",

View File

@ -18,9 +18,9 @@ ena = "0.14.0"
tracing = "0.1.35" tracing = "0.1.35"
rustc-hash = "1.1.0" rustc-hash = "1.1.0"
scoped-tls = "1.0.0" scoped-tls = "1.0.0"
chalk-solve = { version = "0.82.0", default-features = false } chalk-solve = { version = "0.83.0", default-features = false }
chalk-ir = "0.82.0" chalk-ir = "0.83.0"
chalk-recursive = { version = "0.82.0", default-features = false } chalk-recursive = { version = "0.83.0", default-features = false }
la-arena = { version = "0.3.0", path = "../../lib/la-arena" } la-arena = { version = "0.3.0", path = "../../lib/la-arena" }
once_cell = "1.12.0" once_cell = "1.12.0"
typed-arena = "2.0.1" typed-arena = "2.0.1"

View File

@ -4,7 +4,7 @@
use chalk_ir::{ use chalk_ir::{
cast::{Cast, CastTo, Caster}, cast::{Cast, CastTo, Caster},
fold::Fold, fold::TypeFoldable,
interner::HasInterner, interner::HasInterner,
AdtId, BoundVar, DebruijnIndex, Scalar, AdtId, BoundVar, DebruijnIndex, Scalar,
}; };
@ -276,7 +276,7 @@ pub fn build(self) -> ProjectionTy {
} }
} }
impl<T: HasInterner<Interner = Interner> + Fold<Interner>> TyBuilder<Binders<T>> { impl<T: HasInterner<Interner = Interner> + TypeFoldable<Interner>> TyBuilder<Binders<T>> {
fn subst_binders(b: Binders<T>) -> Self { fn subst_binders(b: Binders<T>) -> Self {
let param_kinds = b let param_kinds = b
.binders .binders
@ -290,7 +290,7 @@ fn subst_binders(b: Binders<T>) -> Self {
TyBuilder::new(b, param_kinds) TyBuilder::new(b, param_kinds)
} }
pub fn build(self) -> <T as Fold<Interner>>::Result { pub fn build(self) -> T {
let (b, subst) = self.build_internal(); let (b, subst) = self.build_internal();
b.substitute(Interner, &subst) b.substitute(Interner, &subst)
} }

View File

@ -3,8 +3,8 @@
use std::{fmt, mem, sync::Arc}; use std::{fmt, mem, sync::Arc};
use chalk_ir::{ use chalk_ir::{
cast::Cast, fold::Fold, interner::HasInterner, zip::Zip, CanonicalVarKind, FloatTy, IntTy, cast::Cast, fold::TypeFoldable, interner::HasInterner, zip::Zip, CanonicalVarKind, FloatTy,
NoSolution, TyVariableKind, UniverseIndex, IntTy, NoSolution, TyVariableKind, UniverseIndex,
}; };
use chalk_solve::infer::ParameterEnaVariableExt; use chalk_solve::infer::ParameterEnaVariableExt;
use ena::unify::UnifyKey; use ena::unify::UnifyKey;
@ -20,12 +20,12 @@
}; };
impl<'a> InferenceContext<'a> { impl<'a> InferenceContext<'a> {
pub(super) fn canonicalize<T: Fold<Interner> + HasInterner<Interner = Interner>>( pub(super) fn canonicalize<T: TypeFoldable<Interner> + HasInterner<Interner = Interner>>(
&mut self, &mut self,
t: T, t: T,
) -> Canonicalized<T::Result> ) -> Canonicalized<T>
where where
T::Result: HasInterner<Interner = Interner>, T: HasInterner<Interner = Interner>,
{ {
self.table.canonicalize(t) self.table.canonicalize(t)
} }
@ -200,12 +200,12 @@ fn fallback_value(&self, iv: InferenceVar, kind: TyVariableKind) -> Ty {
.intern(Interner) .intern(Interner)
} }
pub(crate) fn canonicalize<T: Fold<Interner> + HasInterner<Interner = Interner>>( pub(crate) fn canonicalize<T: TypeFoldable<Interner> + HasInterner<Interner = Interner>>(
&mut self, &mut self,
t: T, t: T,
) -> Canonicalized<T::Result> ) -> Canonicalized<T>
where where
T::Result: HasInterner<Interner = Interner>, T: HasInterner<Interner = Interner>,
{ {
// try to resolve obligations before canonicalizing, since this might // try to resolve obligations before canonicalizing, since this might
// result in new knowledge about variables // result in new knowledge about variables
@ -292,9 +292,9 @@ pub(crate) fn resolve_with_fallback<T>(
&mut self, &mut self,
t: T, t: T,
fallback: &dyn Fn(InferenceVar, VariableKind, GenericArg, DebruijnIndex) -> GenericArg, fallback: &dyn Fn(InferenceVar, VariableKind, GenericArg, DebruijnIndex) -> GenericArg,
) -> T::Result ) -> T
where where
T: HasInterner<Interner = Interner> + Fold<Interner>, T: HasInterner<Interner = Interner> + TypeFoldable<Interner>,
{ {
self.resolve_with_fallback_inner(&mut Vec::new(), t, &fallback) self.resolve_with_fallback_inner(&mut Vec::new(), t, &fallback)
} }
@ -310,9 +310,9 @@ pub(crate) fn fresh_subst(&mut self, binders: &[CanonicalVarKind<Interner>]) ->
) )
} }
pub(crate) fn instantiate_canonical<T>(&mut self, canonical: Canonical<T>) -> T::Result pub(crate) fn instantiate_canonical<T>(&mut self, canonical: Canonical<T>) -> T
where where
T: HasInterner<Interner = Interner> + Fold<Interner> + std::fmt::Debug, T: HasInterner<Interner = Interner> + TypeFoldable<Interner> + std::fmt::Debug,
{ {
let subst = self.fresh_subst(canonical.binders.as_slice(Interner)); let subst = self.fresh_subst(canonical.binders.as_slice(Interner));
subst.apply(canonical.value, Interner) subst.apply(canonical.value, Interner)
@ -323,9 +323,9 @@ fn resolve_with_fallback_inner<T>(
var_stack: &mut Vec<InferenceVar>, var_stack: &mut Vec<InferenceVar>,
t: T, t: T,
fallback: &dyn Fn(InferenceVar, VariableKind, GenericArg, DebruijnIndex) -> GenericArg, fallback: &dyn Fn(InferenceVar, VariableKind, GenericArg, DebruijnIndex) -> GenericArg,
) -> T::Result ) -> T
where where
T: HasInterner<Interner = Interner> + Fold<Interner>, T: HasInterner<Interner = Interner> + TypeFoldable<Interner>,
{ {
t.fold_with( t.fold_with(
&mut resolve::Resolver { table: self, var_stack, fallback }, &mut resolve::Resolver { table: self, var_stack, fallback },
@ -334,9 +334,9 @@ fn resolve_with_fallback_inner<T>(
.expect("fold failed unexpectedly") .expect("fold failed unexpectedly")
} }
pub(crate) fn resolve_completely<T>(&mut self, t: T) -> T::Result pub(crate) fn resolve_completely<T>(&mut self, t: T) -> T
where where
T: HasInterner<Interner = Interner> + Fold<Interner>, T: HasInterner<Interner = Interner> + TypeFoldable<Interner>,
{ {
self.resolve_with_fallback(t, &|_, _, d, _| d) self.resolve_with_fallback(t, &|_, _, d, _| d)
} }
@ -447,19 +447,19 @@ pub(crate) fn resolve_obligations_as_possible(&mut self) {
} }
} }
pub(crate) fn fudge_inference<T: Fold<Interner>>( pub(crate) fn fudge_inference<T: TypeFoldable<Interner>>(
&mut self, &mut self,
f: impl FnOnce(&mut Self) -> T, f: impl FnOnce(&mut Self) -> T,
) -> T::Result { ) -> T {
use chalk_ir::fold::Folder; use chalk_ir::fold::TypeFolder;
struct VarFudger<'a, 'b> { struct VarFudger<'a, 'b> {
table: &'a mut InferenceTable<'b>, table: &'a mut InferenceTable<'b>,
highest_known_var: InferenceVar, highest_known_var: InferenceVar,
} }
impl<'a, 'b> Folder<Interner> for VarFudger<'a, 'b> { impl<'a, 'b> TypeFolder<Interner> for VarFudger<'a, 'b> {
type Error = NoSolution; type Error = NoSolution;
fn as_dyn(&mut self) -> &mut dyn Folder<Interner, Error = Self::Error> { fn as_dyn(&mut self) -> &mut dyn TypeFolder<Interner, Error = Self::Error> {
self self
} }
@ -635,7 +635,7 @@ mod resolve {
}; };
use chalk_ir::{ use chalk_ir::{
cast::Cast, cast::Cast,
fold::{Fold, Folder}, fold::{TypeFoldable, TypeFolder},
Fallible, NoSolution, Fallible, NoSolution,
}; };
use hir_def::type_ref::ConstScalar; use hir_def::type_ref::ConstScalar;
@ -645,13 +645,13 @@ pub(super) struct Resolver<'a, 'b, F> {
pub(super) var_stack: &'a mut Vec<InferenceVar>, pub(super) var_stack: &'a mut Vec<InferenceVar>,
pub(super) fallback: F, pub(super) fallback: F,
} }
impl<'a, 'b, 'i, F> Folder<Interner> for Resolver<'a, 'b, F> impl<'a, 'b, 'i, F> TypeFolder<Interner> for Resolver<'a, 'b, F>
where where
F: Fn(InferenceVar, VariableKind, GenericArg, DebruijnIndex) -> GenericArg + 'i, F: Fn(InferenceVar, VariableKind, GenericArg, DebruijnIndex) -> GenericArg + 'i,
{ {
type Error = NoSolution; type Error = NoSolution;
fn as_dyn(&mut self) -> &mut dyn Folder<Interner, Error = Self::Error> { fn as_dyn(&mut self) -> &mut dyn TypeFolder<Interner, Error = Self::Error> {
self self
} }

View File

@ -33,7 +33,7 @@ macro_rules! eprintln {
use std::sync::Arc; use std::sync::Arc;
use chalk_ir::{ use chalk_ir::{
fold::{Fold, Shift}, fold::{Shift, TypeFoldable},
interner::HasInterner, interner::HasInterner,
NoSolution, NoSolution,
}; };
@ -136,7 +136,7 @@ pub fn param_idx(db: &dyn HirDatabase, id: TypeOrConstParamId) -> Option<usize>
pub(crate) fn wrap_empty_binders<T>(value: T) -> Binders<T> pub(crate) fn wrap_empty_binders<T>(value: T) -> Binders<T>
where where
T: Fold<Interner, Result = T> + HasInterner<Interner = Interner>, T: TypeFoldable<Interner> + HasInterner<Interner = Interner>,
{ {
Binders::empty(Interner, value.shifted_in_from(Interner, DebruijnIndex::ONE)) Binders::empty(Interner, value.shifted_in_from(Interner, DebruijnIndex::ONE))
} }
@ -264,14 +264,12 @@ pub fn ret(&self) -> &Ty {
} }
} }
impl Fold<Interner> for CallableSig { impl TypeFoldable<Interner> for CallableSig {
type Result = CallableSig;
fn fold_with<E>( fn fold_with<E>(
self, self,
folder: &mut dyn chalk_ir::fold::Folder<Interner, Error = E>, folder: &mut dyn chalk_ir::fold::TypeFolder<Interner, Error = E>,
outer_binder: DebruijnIndex, outer_binder: DebruijnIndex,
) -> Result<Self::Result, E> { ) -> Result<Self, E> {
let vec = self.params_and_return.to_vec(); let vec = self.params_and_return.to_vec();
let folded = vec.fold_with(folder, outer_binder)?; let folded = vec.fold_with(folder, outer_binder)?;
Ok(CallableSig { params_and_return: folded.into(), is_varargs: self.is_varargs }) Ok(CallableSig { params_and_return: folded.into(), is_varargs: self.is_varargs })
@ -300,22 +298,22 @@ pub fn static_lifetime() -> Lifetime {
LifetimeData::Static.intern(Interner) LifetimeData::Static.intern(Interner)
} }
pub(crate) fn fold_free_vars<T: HasInterner<Interner = Interner> + Fold<Interner>>( pub(crate) fn fold_free_vars<T: HasInterner<Interner = Interner> + TypeFoldable<Interner>>(
t: T, t: T,
for_ty: impl FnMut(BoundVar, DebruijnIndex) -> Ty, for_ty: impl FnMut(BoundVar, DebruijnIndex) -> Ty,
for_const: impl FnMut(Ty, BoundVar, DebruijnIndex) -> Const, for_const: impl FnMut(Ty, BoundVar, DebruijnIndex) -> Const,
) -> T::Result { ) -> T {
use chalk_ir::{fold::Folder, Fallible}; use chalk_ir::{fold::TypeFolder, Fallible};
struct FreeVarFolder<F1, F2>(F1, F2); struct FreeVarFolder<F1, F2>(F1, F2);
impl< impl<
'i, 'i,
F1: FnMut(BoundVar, DebruijnIndex) -> Ty + 'i, F1: FnMut(BoundVar, DebruijnIndex) -> Ty + 'i,
F2: FnMut(Ty, BoundVar, DebruijnIndex) -> Const + 'i, F2: FnMut(Ty, BoundVar, DebruijnIndex) -> Const + 'i,
> Folder<Interner> for FreeVarFolder<F1, F2> > TypeFolder<Interner> for FreeVarFolder<F1, F2>
{ {
type Error = NoSolution; type Error = NoSolution;
fn as_dyn(&mut self) -> &mut dyn Folder<Interner, Error = Self::Error> { fn as_dyn(&mut self) -> &mut dyn TypeFolder<Interner, Error = Self::Error> {
self self
} }
@ -344,11 +342,11 @@ fn fold_free_var_const(
.expect("fold failed unexpectedly") .expect("fold failed unexpectedly")
} }
pub(crate) fn fold_tys<T: HasInterner<Interner = Interner> + Fold<Interner>>( pub(crate) fn fold_tys<T: HasInterner<Interner = Interner> + TypeFoldable<Interner>>(
t: T, t: T,
mut for_ty: impl FnMut(Ty, DebruijnIndex) -> Ty, mut for_ty: impl FnMut(Ty, DebruijnIndex) -> Ty,
binders: DebruijnIndex, binders: DebruijnIndex,
) -> T::Result { ) -> T {
fold_tys_and_consts( fold_tys_and_consts(
t, t,
|x, d| match x { |x, d| match x {
@ -359,22 +357,22 @@ pub(crate) fn fold_tys<T: HasInterner<Interner = Interner> + Fold<Interner>>(
) )
} }
pub(crate) fn fold_tys_and_consts<T: HasInterner<Interner = Interner> + Fold<Interner>>( pub(crate) fn fold_tys_and_consts<T: HasInterner<Interner = Interner> + TypeFoldable<Interner>>(
t: T, t: T,
f: impl FnMut(Either<Ty, Const>, DebruijnIndex) -> Either<Ty, Const>, f: impl FnMut(Either<Ty, Const>, DebruijnIndex) -> Either<Ty, Const>,
binders: DebruijnIndex, binders: DebruijnIndex,
) -> T::Result { ) -> T {
use chalk_ir::{ use chalk_ir::{
fold::{Folder, SuperFold}, fold::{TypeFolder, TypeSuperFoldable},
Fallible, Fallible,
}; };
struct TyFolder<F>(F); struct TyFolder<F>(F);
impl<'i, F: FnMut(Either<Ty, Const>, DebruijnIndex) -> Either<Ty, Const> + 'i> Folder<Interner> impl<'i, F: FnMut(Either<Ty, Const>, DebruijnIndex) -> Either<Ty, Const> + 'i>
for TyFolder<F> TypeFolder<Interner> for TyFolder<F>
{ {
type Error = NoSolution; type Error = NoSolution;
fn as_dyn(&mut self) -> &mut dyn Folder<Interner, Error = Self::Error> { fn as_dyn(&mut self) -> &mut dyn TypeFolder<Interner, Error = Self::Error> {
self self
} }
@ -397,22 +395,22 @@ fn fold_const(&mut self, c: Const, outer_binder: DebruijnIndex) -> Fallible<Cons
/// 'Canonicalizes' the `t` by replacing any errors with new variables. Also /// 'Canonicalizes' the `t` by replacing any errors with new variables. Also
/// ensures there are no unbound variables or inference variables anywhere in /// ensures there are no unbound variables or inference variables anywhere in
/// the `t`. /// the `t`.
pub fn replace_errors_with_variables<T>(t: &T) -> Canonical<T::Result> pub fn replace_errors_with_variables<T>(t: &T) -> Canonical<T>
where where
T: HasInterner<Interner = Interner> + Fold<Interner> + Clone, T: HasInterner<Interner = Interner> + TypeFoldable<Interner> + Clone,
T::Result: HasInterner<Interner = Interner>, T: HasInterner<Interner = Interner>,
{ {
use chalk_ir::{ use chalk_ir::{
fold::{Folder, SuperFold}, fold::{TypeFolder, TypeSuperFoldable},
Fallible, Fallible,
}; };
struct ErrorReplacer { struct ErrorReplacer {
vars: usize, vars: usize,
} }
impl Folder<Interner> for ErrorReplacer { impl TypeFolder<Interner> for ErrorReplacer {
type Error = NoSolution; type Error = NoSolution;
fn as_dyn(&mut self) -> &mut dyn Folder<Interner, Error = Self::Error> { fn as_dyn(&mut self) -> &mut dyn TypeFolder<Interner, Error = Self::Error> {
self self
} }

View File

@ -12,7 +12,9 @@
}; };
use base_db::CrateId; use base_db::CrateId;
use chalk_ir::{cast::Cast, fold::Fold, fold::Shift, interner::HasInterner, Mutability, Safety}; use chalk_ir::{
cast::Cast, fold::Shift, fold::TypeFoldable, interner::HasInterner, Mutability, Safety,
};
use hir_def::{ use hir_def::{
adt::StructKind, adt::StructKind,
@ -1751,10 +1753,10 @@ pub(crate) fn const_or_path_to_chalk(
/// This replaces any 'free' Bound vars in `s` (i.e. those with indices past /// This replaces any 'free' Bound vars in `s` (i.e. those with indices past
/// num_vars_to_keep) by `TyKind::Unknown`. /// num_vars_to_keep) by `TyKind::Unknown`.
fn fallback_bound_vars<T: Fold<Interner> + HasInterner<Interner = Interner>>( fn fallback_bound_vars<T: TypeFoldable<Interner> + HasInterner<Interner = Interner>>(
s: T, s: T,
num_vars_to_keep: usize, num_vars_to_keep: usize,
) -> T::Result { ) -> T {
crate::fold_free_vars( crate::fold_free_vars(
s, s,
|bound, binders| { |bound, binders| {