Skip to content

Commit 75203ee

Browse files
committed
Remove unecessary references to TypeFolder::Error
1 parent 6ac6866 commit 75203ee

File tree

1 file changed

+15
-21
lines changed
  • compiler/rustc_middle/src/ty

1 file changed

+15
-21
lines changed

compiler/rustc_middle/src/ty/fold.rs

+15-21
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ pub trait TypeFoldable<'tcx>: fmt::Debug + Clone {
8686
/// A convenient alternative to `try_fold_with` for use with infallible
8787
/// folders. Do not override this method, to ensure coherence with
8888
/// `try_fold_with`.
89-
fn fold_with<F: TypeFolder<'tcx, Error = !>>(self, folder: &mut F) -> Self {
89+
fn fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
9090
self.try_fold_with(folder).into_ok()
9191
}
9292

@@ -216,7 +216,7 @@ pub trait TypeSuperFoldable<'tcx>: TypeFoldable<'tcx> {
216216
/// A convenient alternative to `try_super_fold_with` for use with
217217
/// infallible folders. Do not override this method, to ensure coherence
218218
/// with `try_super_fold_with`.
219-
fn super_fold_with<F: TypeFolder<'tcx, Error = !>>(self, folder: &mut F) -> Self {
219+
fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
220220
self.try_super_fold_with(folder).into_ok()
221221
}
222222

@@ -229,16 +229,13 @@ pub trait TypeSuperFoldable<'tcx>: TypeFoldable<'tcx> {
229229
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy>;
230230
}
231231

232-
/// This trait is implemented for every folding traversal. There is a fold
233-
/// method defined for every type of interest. Each such method has a default
234-
/// that does an "identity" fold. Implementations of these methods often fall
235-
/// back to a `super_fold_with` method if the primary argument doesn't
236-
/// satisfy a particular condition.
232+
/// This trait is implemented for every infallible folding traversal. There is
233+
/// a fold method defined for every type of interest. Each such method has a
234+
/// default that does an "identity" fold. Implementations of these methods
235+
/// often fall back to a `super_fold_with` method if the primary argument
236+
/// doesn't satisfy a particular condition.
237237
///
238-
/// If this folder is fallible (and therefore its [`Error`][`TypeFolder::Error`]
239-
/// associated type is something other than the default `!`) then
240-
/// [`FallibleTypeFolder`] should be implemented manually. Otherwise,
241-
/// a blanket implementation of [`FallibleTypeFolder`] will defer to
238+
/// A blanket implementation of [`FallibleTypeFolder`] will defer to
242239
/// the infallible methods of this trait to ensure that the two APIs
243240
/// are coherent.
244241
pub trait TypeFolder<'tcx>: FallibleTypeFolder<'tcx, Error = !> {
@@ -341,43 +338,40 @@ where
341338
TypeFolder::tcx(self)
342339
}
343340

344-
fn try_fold_binder<T>(&mut self, t: Binder<'tcx, T>) -> Result<Binder<'tcx, T>, Self::Error>
341+
fn try_fold_binder<T>(&mut self, t: Binder<'tcx, T>) -> Result<Binder<'tcx, T>, !>
345342
where
346343
T: TypeFoldable<'tcx>,
347344
{
348345
Ok(self.fold_binder(t))
349346
}
350347

351-
fn try_fold_ty(&mut self, t: Ty<'tcx>) -> Result<Ty<'tcx>, Self::Error> {
348+
fn try_fold_ty(&mut self, t: Ty<'tcx>) -> Result<Ty<'tcx>, !> {
352349
Ok(self.fold_ty(t))
353350
}
354351

355-
fn try_fold_region(&mut self, r: ty::Region<'tcx>) -> Result<ty::Region<'tcx>, Self::Error> {
352+
fn try_fold_region(&mut self, r: ty::Region<'tcx>) -> Result<ty::Region<'tcx>, !> {
356353
Ok(self.fold_region(r))
357354
}
358355

359-
fn try_fold_const(&mut self, c: ty::Const<'tcx>) -> Result<ty::Const<'tcx>, Self::Error> {
356+
fn try_fold_const(&mut self, c: ty::Const<'tcx>) -> Result<ty::Const<'tcx>, !> {
360357
Ok(self.fold_const(c))
361358
}
362359

363360
fn try_fold_unevaluated(
364361
&mut self,
365362
c: ty::Unevaluated<'tcx>,
366-
) -> Result<ty::Unevaluated<'tcx>, Self::Error> {
363+
) -> Result<ty::Unevaluated<'tcx>, !> {
367364
Ok(self.fold_unevaluated(c))
368365
}
369366

370-
fn try_fold_predicate(
371-
&mut self,
372-
p: ty::Predicate<'tcx>,
373-
) -> Result<ty::Predicate<'tcx>, Self::Error> {
367+
fn try_fold_predicate(&mut self, p: ty::Predicate<'tcx>) -> Result<ty::Predicate<'tcx>, !> {
374368
Ok(self.fold_predicate(p))
375369
}
376370

377371
fn try_fold_mir_const(
378372
&mut self,
379373
c: mir::ConstantKind<'tcx>,
380-
) -> Result<mir::ConstantKind<'tcx>, Self::Error> {
374+
) -> Result<mir::ConstantKind<'tcx>, !> {
381375
Ok(self.fold_mir_const(c))
382376
}
383377
}

0 commit comments

Comments
 (0)