Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 81 additions & 78 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions crates/flycheck/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ rust-version = "1.57"
doctest = false

[dependencies]
crossbeam-channel = "0.5.4"
crossbeam-channel = "0.5.5"
tracing = "0.1.35"
cargo_metadata = "0.14.2"
cargo_metadata = "0.15.0"
serde = { version = "1.0.137", features = ["derive"] }
serde_json = "1.0.81"
jod-thread = "0.1.2"
Expand Down
6 changes: 3 additions & 3 deletions crates/hir-def/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ cov-mark = "2.0.0-pre.1"
# We need to freeze the version of the crate, as the raw-api feature is considered unstable
dashmap = { version = "=5.3.4", features = ["raw-api"] }
drop_bomb = "0.1.5"
either = "1.6.1"
either = "1.7.0"
fst = { version = "0.4.7", default-features = false }
hashbrown = { version = "0.12.1", default-features = false }
indexmap = "1.8.2"
indexmap = "1.9.1"
itertools = "0.10.3"
la-arena = { version = "0.3.0", path = "../../lib/la-arena" }
once_cell = "1.12.0"
rustc-hash = "1.1.0"
smallvec = "1.8.0"
smallvec = "1.9.0"
tracing = "0.1.35"

stdx = { path = "../stdx", version = "0.0.0" }
Expand Down
2 changes: 1 addition & 1 deletion crates/hir-expand/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ doctest = false
[dependencies]
cov-mark = "2.0.0-pre.1"
tracing = "0.1.35"
either = "1.6.1"
either = "1.7.0"
rustc-hash = "1.1.0"
la-arena = { version = "0.3.0", path = "../../lib/la-arena" }
itertools = "0.10.3"
Expand Down
10 changes: 5 additions & 5 deletions crates/hir-ty/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ doctest = false
cov-mark = "2.0.0-pre.1"
itertools = "0.10.3"
arrayvec = "0.7.2"
smallvec = "1.8.0"
smallvec = "1.9.0"
ena = "0.14.0"
tracing = "0.1.35"
rustc-hash = "1.1.0"
scoped-tls = "1.0.0"
chalk-solve = { version = "0.82.0", default-features = false }
chalk-ir = "0.82.0"
chalk-recursive = { version = "0.82.0", default-features = false }
chalk-solve = { version = "0.83.0", default-features = false }
chalk-ir = "0.83.0"
chalk-recursive = { version = "0.83.0", default-features = false }
la-arena = { version = "0.3.0", path = "../../lib/la-arena" }
once_cell = "1.12.0"
typed-arena = "2.0.1"
Expand All @@ -37,7 +37,7 @@ limit = { path = "../limit", version = "0.0.0" }
test-utils = { path = "../test-utils" }
expect-test = "1.3.0"
tracing = "0.1.35"
tracing-subscriber = { version = "0.3.11", default-features = false, features = [
tracing-subscriber = { version = "0.3.14", default-features = false, features = [
"env-filter",
"registry",
] }
Expand Down
6 changes: 3 additions & 3 deletions crates/hir-ty/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::iter;

use chalk_ir::{
cast::{Cast, CastTo, Caster},
fold::Fold,
fold::TypeFoldable,
interner::HasInterner,
AdtId, BoundVar, DebruijnIndex, Scalar,
};
Expand Down Expand Up @@ -276,7 +276,7 @@ impl TyBuilder<TypeAliasId> {
}
}

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 {
let param_kinds = b
.binders
Expand All @@ -290,7 +290,7 @@ impl<T: HasInterner<Interner = Interner> + Fold<Interner>> TyBuilder<Binders<T>>
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();
b.substitute(Interner, &subst)
}
Expand Down
48 changes: 24 additions & 24 deletions crates/hir-ty/src/infer/unify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
use std::{fmt, mem, sync::Arc};

use chalk_ir::{
cast::Cast, fold::Fold, interner::HasInterner, zip::Zip, CanonicalVarKind, FloatTy, IntTy,
NoSolution, TyVariableKind, UniverseIndex,
cast::Cast, fold::TypeFoldable, interner::HasInterner, zip::Zip, CanonicalVarKind, FloatTy,
IntTy, NoSolution, TyVariableKind, UniverseIndex,
};
use chalk_solve::infer::ParameterEnaVariableExt;
use ena::unify::UnifyKey;
Expand All @@ -20,12 +20,12 @@ use crate::{
};

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,
t: T,
) -> Canonicalized<T::Result>
) -> Canonicalized<T>
where
T::Result: HasInterner<Interner = Interner>,
T: HasInterner<Interner = Interner>,
{
self.table.canonicalize(t)
}
Expand Down Expand Up @@ -200,12 +200,12 @@ impl<'a> InferenceTable<'a> {
.intern(Interner)
}

pub(crate) fn canonicalize<T: Fold<Interner> + HasInterner<Interner = Interner>>(
pub(crate) fn canonicalize<T: TypeFoldable<Interner> + HasInterner<Interner = Interner>>(
&mut self,
t: T,
) -> Canonicalized<T::Result>
) -> Canonicalized<T>
where
T::Result: HasInterner<Interner = Interner>,
T: HasInterner<Interner = Interner>,
{
// try to resolve obligations before canonicalizing, since this might
// result in new knowledge about variables
Expand Down Expand Up @@ -292,9 +292,9 @@ impl<'a> InferenceTable<'a> {
&mut self,
t: T,
fallback: &dyn Fn(InferenceVar, VariableKind, GenericArg, DebruijnIndex) -> GenericArg,
) -> T::Result
) -> T
where
T: HasInterner<Interner = Interner> + Fold<Interner>,
T: HasInterner<Interner = Interner> + TypeFoldable<Interner>,
{
self.resolve_with_fallback_inner(&mut Vec::new(), t, &fallback)
}
Expand All @@ -310,9 +310,9 @@ impl<'a> InferenceTable<'a> {
)
}

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
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));
subst.apply(canonical.value, Interner)
Expand All @@ -323,9 +323,9 @@ impl<'a> InferenceTable<'a> {
var_stack: &mut Vec<InferenceVar>,
t: T,
fallback: &dyn Fn(InferenceVar, VariableKind, GenericArg, DebruijnIndex) -> GenericArg,
) -> T::Result
) -> T
where
T: HasInterner<Interner = Interner> + Fold<Interner>,
T: HasInterner<Interner = Interner> + TypeFoldable<Interner>,
{
t.fold_with(
&mut resolve::Resolver { table: self, var_stack, fallback },
Expand All @@ -334,9 +334,9 @@ impl<'a> InferenceTable<'a> {
.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
T: HasInterner<Interner = Interner> + Fold<Interner>,
T: HasInterner<Interner = Interner> + TypeFoldable<Interner>,
{
self.resolve_with_fallback(t, &|_, _, d, _| d)
}
Expand Down Expand Up @@ -447,19 +447,19 @@ impl<'a> InferenceTable<'a> {
}
}

pub(crate) fn fudge_inference<T: Fold<Interner>>(
pub(crate) fn fudge_inference<T: TypeFoldable<Interner>>(
&mut self,
f: impl FnOnce(&mut Self) -> T,
) -> T::Result {
use chalk_ir::fold::Folder;
) -> T {
use chalk_ir::fold::TypeFolder;
struct VarFudger<'a, 'b> {
table: &'a mut InferenceTable<'b>,
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;

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
}

Expand Down Expand Up @@ -635,7 +635,7 @@ mod resolve {
};
use chalk_ir::{
cast::Cast,
fold::{Fold, Folder},
fold::{TypeFoldable, TypeFolder},
Fallible, NoSolution,
};
use hir_def::type_ref::ConstScalar;
Expand All @@ -645,13 +645,13 @@ mod resolve {
pub(super) var_stack: &'a mut Vec<InferenceVar>,
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
F: Fn(InferenceVar, VariableKind, GenericArg, DebruijnIndex) -> GenericArg + 'i,
{
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
}

Expand Down
50 changes: 24 additions & 26 deletions crates/hir-ty/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ mod test_db;
use std::sync::Arc;

use chalk_ir::{
fold::{Fold, Shift},
fold::{Shift, TypeFoldable},
interner::HasInterner,
NoSolution,
};
Expand Down Expand Up @@ -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>
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))
}
Expand Down Expand Up @@ -264,14 +264,12 @@ impl CallableSig {
}
}

impl Fold<Interner> for CallableSig {
type Result = CallableSig;

impl TypeFoldable<Interner> for CallableSig {
fn fold_with<E>(
self,
folder: &mut dyn chalk_ir::fold::Folder<Interner, Error = E>,
folder: &mut dyn chalk_ir::fold::TypeFolder<Interner, Error = E>,
outer_binder: DebruijnIndex,
) -> Result<Self::Result, E> {
) -> Result<Self, E> {
let vec = self.params_and_return.to_vec();
let folded = vec.fold_with(folder, outer_binder)?;
Ok(CallableSig { params_and_return: folded.into(), is_varargs: self.is_varargs })
Expand Down Expand Up @@ -300,22 +298,22 @@ pub fn static_lifetime() -> Lifetime {
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,
for_ty: impl FnMut(BoundVar, DebruijnIndex) -> Ty,
for_const: impl FnMut(Ty, BoundVar, DebruijnIndex) -> Const,
) -> T::Result {
use chalk_ir::{fold::Folder, Fallible};
) -> T {
use chalk_ir::{fold::TypeFolder, Fallible};
struct FreeVarFolder<F1, F2>(F1, F2);
impl<
'i,
F1: FnMut(BoundVar, DebruijnIndex) -> Ty + 'i,
F2: FnMut(Ty, BoundVar, DebruijnIndex) -> Const + 'i,
> Folder<Interner> for FreeVarFolder<F1, F2>
> TypeFolder<Interner> for FreeVarFolder<F1, F2>
{
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
}

Expand Down Expand Up @@ -344,11 +342,11 @@ pub(crate) fn fold_free_vars<T: HasInterner<Interner = Interner> + Fold<Interner
.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,
mut for_ty: impl FnMut(Ty, DebruijnIndex) -> Ty,
binders: DebruijnIndex,
) -> T::Result {
) -> T {
fold_tys_and_consts(
t,
|x, d| match x {
Expand All @@ -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,
f: impl FnMut(Either<Ty, Const>, DebruijnIndex) -> Either<Ty, Const>,
binders: DebruijnIndex,
) -> T::Result {
) -> T {
use chalk_ir::{
fold::{Folder, SuperFold},
fold::{TypeFolder, TypeSuperFoldable},
Fallible,
};
struct TyFolder<F>(F);
impl<'i, F: FnMut(Either<Ty, Const>, DebruijnIndex) -> Either<Ty, Const> + 'i> Folder<Interner>
for TyFolder<F>
impl<'i, F: FnMut(Either<Ty, Const>, DebruijnIndex) -> Either<Ty, Const> + 'i>
TypeFolder<Interner> for TyFolder<F>
{
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
}

Expand All @@ -397,22 +395,22 @@ pub(crate) fn fold_tys_and_consts<T: HasInterner<Interner = Interner> + Fold<Int
/// 'Canonicalizes' the `t` by replacing any errors with new variables. Also
/// ensures there are no unbound variables or inference variables anywhere in
/// 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
T: HasInterner<Interner = Interner> + Fold<Interner> + Clone,
T::Result: HasInterner<Interner = Interner>,
T: HasInterner<Interner = Interner> + TypeFoldable<Interner> + Clone,
T: HasInterner<Interner = Interner>,
{
use chalk_ir::{
fold::{Folder, SuperFold},
fold::{TypeFolder, TypeSuperFoldable},
Fallible,
};
struct ErrorReplacer {
vars: usize,
}
impl Folder<Interner> for ErrorReplacer {
impl TypeFolder<Interner> for ErrorReplacer {
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
}

Expand Down
8 changes: 5 additions & 3 deletions crates/hir-ty/src/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ use std::{
};

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::{
adt::StructKind,
Expand Down Expand Up @@ -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
/// 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,
num_vars_to_keep: usize,
) -> T::Result {
) -> T {
crate::fold_free_vars(
s,
|bound, binders| {
Expand Down
Loading