Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6439c7f

Browse files
Require foldability part of interner item bounds, remove redundant where clauses
1 parent 08c7ff2 commit 6439c7f

File tree

3 files changed

+20
-49
lines changed

3 files changed

+20
-49
lines changed

‎compiler/rustc_next_trait_solver/src/canonicalizer.rs‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,7 @@ impl<Infcx: InferCtxtLike<Interner = I>, I: Interner> TypeFolder<I>
296296
Region::new_anon_bound(self.interner(), self.binder_index, var)
297297
}
298298

299-
fn fold_ty(&mut self, t: I::Ty) -> I::Ty
300-
where
301-
I::Ty: TypeSuperFoldable<I>,
302-
{
299+
fn fold_ty(&mut self, t: I::Ty) -> I::Ty {
303300
let kind = match t.kind() {
304301
ty::Infer(i) => match i {
305302
ty::TyVar(vid) => {
@@ -378,10 +375,7 @@ impl<Infcx: InferCtxtLike<Interner = I>, I: Interner> TypeFolder<I>
378375
Ty::new_anon_bound(self.interner(), self.binder_index, var)
379376
}
380377

381-
fn fold_const(&mut self, c: I::Const) -> I::Const
382-
where
383-
I::Const: TypeSuperFoldable<I>,
384-
{
378+
fn fold_const(&mut self, c: I::Const) -> I::Const {
385379
// We could canonicalize all consts with static types, but the only ones we
386380
// *really* need to worry about are the ones that we end up putting into `CanonicalVarKind`
387381
// since canonical vars can't reference other canonical vars.

‎compiler/rustc_type_ir/src/fold.rs‎

Lines changed: 11 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -136,31 +136,21 @@ pub trait TypeFolder<I: Interner>: FallibleTypeFolder<I, Error = Never> {
136136
t.super_fold_with(self)
137137
}
138138

139-
fn fold_ty(&mut self, t: I::Ty) -> I::Ty
140-
where
141-
I::Ty: TypeSuperFoldable<I>,
142-
{
139+
fn fold_ty(&mut self, t: I::Ty) -> I::Ty {
143140
t.super_fold_with(self)
144141
}
145142

146143
// The default region folder is a no-op because `Region` is non-recursive
147-
// and has no `super_fold_with` method to call. That also explains the
148-
// lack of `I::Region: TypeSuperFoldable<I>` bound on this method.
144+
// and has no `super_fold_with` method to call.
149145
fn fold_region(&mut self, r: I::Region) -> I::Region {
150146
r
151147
}
152148

153-
fn fold_const(&mut self, c: I::Const) -> I::Const
154-
where
155-
I::Const: TypeSuperFoldable<I>,
156-
{
149+
fn fold_const(&mut self, c: I::Const) -> I::Const {
157150
c.super_fold_with(self)
158151
}
159152

160-
fn fold_predicate(&mut self, p: I::Predicate) -> I::Predicate
161-
where
162-
I::Predicate: TypeSuperFoldable<I>,
163-
{
153+
fn fold_predicate(&mut self, p: I::Predicate) -> I::Predicate {
164154
p.super_fold_with(self)
165155
}
166156
}
@@ -185,31 +175,21 @@ pub trait FallibleTypeFolder<I: Interner>: Sized {
185175
t.try_super_fold_with(self)
186176
}
187177

188-
fn try_fold_ty(&mut self, t: I::Ty) -> Result<I::Ty, Self::Error>
189-
where
190-
I::Ty: TypeSuperFoldable<I>,
191-
{
178+
fn try_fold_ty(&mut self, t: I::Ty) -> Result<I::Ty, Self::Error> {
192179
t.try_super_fold_with(self)
193180
}
194181

195182
// The default region folder is a no-op because `Region` is non-recursive
196-
// and has no `super_fold_with` method to call. That also explains the
197-
// lack of `I::Region: TypeSuperFoldable<I>` bound on this method.
183+
// and has no `super_fold_with` method to call.
198184
fn try_fold_region(&mut self, r: I::Region) -> Result<I::Region, Self::Error> {
199185
Ok(r)
200186
}
201187

202-
fn try_fold_const(&mut self, c: I::Const) -> Result<I::Const, Self::Error>
203-
where
204-
I::Const: TypeSuperFoldable<I>,
205-
{
188+
fn try_fold_const(&mut self, c: I::Const) -> Result<I::Const, Self::Error> {
206189
c.try_super_fold_with(self)
207190
}
208191

209-
fn try_fold_predicate(&mut self, p: I::Predicate) -> Result<I::Predicate, Self::Error>
210-
where
211-
I::Predicate: TypeSuperFoldable<I>,
212-
{
192+
fn try_fold_predicate(&mut self, p: I::Predicate) -> Result<I::Predicate, Self::Error> {
213193
p.try_super_fold_with(self)
214194
}
215195
}
@@ -234,28 +214,19 @@ where
234214
Ok(self.fold_binder(t))
235215
}
236216

237-
fn try_fold_ty(&mut self, t: I::Ty) -> Result<I::Ty, Never>
238-
where
239-
I::Ty: TypeSuperFoldable<I>,
240-
{
217+
fn try_fold_ty(&mut self, t: I::Ty) -> Result<I::Ty, Never> {
241218
Ok(self.fold_ty(t))
242219
}
243220

244221
fn try_fold_region(&mut self, r: I::Region) -> Result<I::Region, Never> {
245222
Ok(self.fold_region(r))
246223
}
247224

248-
fn try_fold_const(&mut self, c: I::Const) -> Result<I::Const, Never>
249-
where
250-
I::Const: TypeSuperFoldable<I>,
251-
{
225+
fn try_fold_const(&mut self, c: I::Const) -> Result<I::Const, Never> {
252226
Ok(self.fold_const(c))
253227
}
254228

255-
fn try_fold_predicate(&mut self, p: I::Predicate) -> Result<I::Predicate, Never>
256-
where
257-
I::Predicate: TypeSuperFoldable<I>,
258-
{
229+
fn try_fold_predicate(&mut self, p: I::Predicate) -> Result<I::Predicate, Never> {
259230
Ok(self.fold_predicate(p))
260231
}
261232
}

‎compiler/rustc_type_ir/src/interner.rs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,13 @@ pub trait Interner: Sized + Copy {
8585
type PlaceholderRegion: Copy + Debug + Hash + Eq + PlaceholderLike;
8686

8787
// Predicates
88-
type Predicate: Copy + Debug + Hash + Eq + TypeSuperVisitable<Self> + Flags;
88+
type Predicate: Copy
89+
+ Debug
90+
+ Hash
91+
+ Eq
92+
+ TypeSuperVisitable<Self>
93+
+ TypeSuperFoldable<Self>
94+
+ Flags;
8995
type TraitPredicate: Copy + Debug + Hash + Eq;
9096
type RegionOutlivesPredicate: Copy + Debug + Hash + Eq;
9197
type TypeOutlivesPredicate: Copy + Debug + Hash + Eq;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /