Require foldability part of interner item bounds, remove redundant where clauses
This commit is contained in:
parent
08c7ff2264
commit
6439c7fe23
3 changed files with 20 additions and 49 deletions
|
@ -296,10 +296,7 @@ impl<Infcx: InferCtxtLike<Interner = I>, I: Interner> TypeFolder<I>
|
||||||
Region::new_anon_bound(self.interner(), self.binder_index, var)
|
Region::new_anon_bound(self.interner(), self.binder_index, var)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_ty(&mut self, t: I::Ty) -> I::Ty
|
fn fold_ty(&mut self, t: I::Ty) -> I::Ty {
|
||||||
where
|
|
||||||
I::Ty: TypeSuperFoldable<I>,
|
|
||||||
{
|
|
||||||
let kind = match t.kind() {
|
let kind = match t.kind() {
|
||||||
ty::Infer(i) => match i {
|
ty::Infer(i) => match i {
|
||||||
ty::TyVar(vid) => {
|
ty::TyVar(vid) => {
|
||||||
|
@ -378,10 +375,7 @@ impl<Infcx: InferCtxtLike<Interner = I>, I: Interner> TypeFolder<I>
|
||||||
Ty::new_anon_bound(self.interner(), self.binder_index, var)
|
Ty::new_anon_bound(self.interner(), self.binder_index, var)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_const(&mut self, c: I::Const) -> I::Const
|
fn fold_const(&mut self, c: I::Const) -> I::Const {
|
||||||
where
|
|
||||||
I::Const: TypeSuperFoldable<I>,
|
|
||||||
{
|
|
||||||
// We could canonicalize all consts with static types, but the only ones we
|
// We could canonicalize all consts with static types, but the only ones we
|
||||||
// *really* need to worry about are the ones that we end up putting into `CanonicalVarKind`
|
// *really* need to worry about are the ones that we end up putting into `CanonicalVarKind`
|
||||||
// since canonical vars can't reference other canonical vars.
|
// since canonical vars can't reference other canonical vars.
|
||||||
|
|
|
@ -136,31 +136,21 @@ pub trait TypeFolder<I: Interner>: FallibleTypeFolder<I, Error = Never> {
|
||||||
t.super_fold_with(self)
|
t.super_fold_with(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_ty(&mut self, t: I::Ty) -> I::Ty
|
fn fold_ty(&mut self, t: I::Ty) -> I::Ty {
|
||||||
where
|
|
||||||
I::Ty: TypeSuperFoldable<I>,
|
|
||||||
{
|
|
||||||
t.super_fold_with(self)
|
t.super_fold_with(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
// The default region folder is a no-op because `Region` is non-recursive
|
// The default region folder is a no-op because `Region` is non-recursive
|
||||||
// and has no `super_fold_with` method to call. That also explains the
|
// and has no `super_fold_with` method to call.
|
||||||
// lack of `I::Region: TypeSuperFoldable<I>` bound on this method.
|
|
||||||
fn fold_region(&mut self, r: I::Region) -> I::Region {
|
fn fold_region(&mut self, r: I::Region) -> I::Region {
|
||||||
r
|
r
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_const(&mut self, c: I::Const) -> I::Const
|
fn fold_const(&mut self, c: I::Const) -> I::Const {
|
||||||
where
|
|
||||||
I::Const: TypeSuperFoldable<I>,
|
|
||||||
{
|
|
||||||
c.super_fold_with(self)
|
c.super_fold_with(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_predicate(&mut self, p: I::Predicate) -> I::Predicate
|
fn fold_predicate(&mut self, p: I::Predicate) -> I::Predicate {
|
||||||
where
|
|
||||||
I::Predicate: TypeSuperFoldable<I>,
|
|
||||||
{
|
|
||||||
p.super_fold_with(self)
|
p.super_fold_with(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -185,31 +175,21 @@ pub trait FallibleTypeFolder<I: Interner>: Sized {
|
||||||
t.try_super_fold_with(self)
|
t.try_super_fold_with(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_fold_ty(&mut self, t: I::Ty) -> Result<I::Ty, Self::Error>
|
fn try_fold_ty(&mut self, t: I::Ty) -> Result<I::Ty, Self::Error> {
|
||||||
where
|
|
||||||
I::Ty: TypeSuperFoldable<I>,
|
|
||||||
{
|
|
||||||
t.try_super_fold_with(self)
|
t.try_super_fold_with(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
// The default region folder is a no-op because `Region` is non-recursive
|
// The default region folder is a no-op because `Region` is non-recursive
|
||||||
// and has no `super_fold_with` method to call. That also explains the
|
// and has no `super_fold_with` method to call.
|
||||||
// lack of `I::Region: TypeSuperFoldable<I>` bound on this method.
|
|
||||||
fn try_fold_region(&mut self, r: I::Region) -> Result<I::Region, Self::Error> {
|
fn try_fold_region(&mut self, r: I::Region) -> Result<I::Region, Self::Error> {
|
||||||
Ok(r)
|
Ok(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_fold_const(&mut self, c: I::Const) -> Result<I::Const, Self::Error>
|
fn try_fold_const(&mut self, c: I::Const) -> Result<I::Const, Self::Error> {
|
||||||
where
|
|
||||||
I::Const: TypeSuperFoldable<I>,
|
|
||||||
{
|
|
||||||
c.try_super_fold_with(self)
|
c.try_super_fold_with(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_fold_predicate(&mut self, p: I::Predicate) -> Result<I::Predicate, Self::Error>
|
fn try_fold_predicate(&mut self, p: I::Predicate) -> Result<I::Predicate, Self::Error> {
|
||||||
where
|
|
||||||
I::Predicate: TypeSuperFoldable<I>,
|
|
||||||
{
|
|
||||||
p.try_super_fold_with(self)
|
p.try_super_fold_with(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -234,10 +214,7 @@ where
|
||||||
Ok(self.fold_binder(t))
|
Ok(self.fold_binder(t))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_fold_ty(&mut self, t: I::Ty) -> Result<I::Ty, Never>
|
fn try_fold_ty(&mut self, t: I::Ty) -> Result<I::Ty, Never> {
|
||||||
where
|
|
||||||
I::Ty: TypeSuperFoldable<I>,
|
|
||||||
{
|
|
||||||
Ok(self.fold_ty(t))
|
Ok(self.fold_ty(t))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,17 +222,11 @@ where
|
||||||
Ok(self.fold_region(r))
|
Ok(self.fold_region(r))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_fold_const(&mut self, c: I::Const) -> Result<I::Const, Never>
|
fn try_fold_const(&mut self, c: I::Const) -> Result<I::Const, Never> {
|
||||||
where
|
|
||||||
I::Const: TypeSuperFoldable<I>,
|
|
||||||
{
|
|
||||||
Ok(self.fold_const(c))
|
Ok(self.fold_const(c))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn try_fold_predicate(&mut self, p: I::Predicate) -> Result<I::Predicate, Never>
|
fn try_fold_predicate(&mut self, p: I::Predicate) -> Result<I::Predicate, Never> {
|
||||||
where
|
|
||||||
I::Predicate: TypeSuperFoldable<I>,
|
|
||||||
{
|
|
||||||
Ok(self.fold_predicate(p))
|
Ok(self.fold_predicate(p))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,13 @@ pub trait Interner: Sized + Copy {
|
||||||
type PlaceholderRegion: Copy + Debug + Hash + Eq + PlaceholderLike;
|
type PlaceholderRegion: Copy + Debug + Hash + Eq + PlaceholderLike;
|
||||||
|
|
||||||
// Predicates
|
// Predicates
|
||||||
type Predicate: Copy + Debug + Hash + Eq + TypeSuperVisitable<Self> + Flags;
|
type Predicate: Copy
|
||||||
|
+ Debug
|
||||||
|
+ Hash
|
||||||
|
+ Eq
|
||||||
|
+ TypeSuperVisitable<Self>
|
||||||
|
+ TypeSuperFoldable<Self>
|
||||||
|
+ Flags;
|
||||||
type TraitPredicate: Copy + Debug + Hash + Eq;
|
type TraitPredicate: Copy + Debug + Hash + Eq;
|
||||||
type RegionOutlivesPredicate: Copy + Debug + Hash + Eq;
|
type RegionOutlivesPredicate: Copy + Debug + Hash + Eq;
|
||||||
type TypeOutlivesPredicate: Copy + Debug + Hash + Eq;
|
type TypeOutlivesPredicate: Copy + Debug + Hash + Eq;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue