Skip to content

Commit cf683e6

Browse files
committed
Rename TypeFolderFallible to FallibleTypeFolder
1 parent d79e17d commit cf683e6

File tree

12 files changed

+68
-68
lines changed

12 files changed

+68
-68
lines changed

compiler/rustc_infer/src/infer/resolve.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use super::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
22
use super::{FixupError, FixupResult, InferCtxt, Span};
33
use rustc_middle::mir;
4-
use rustc_middle::ty::fold::{TypeFolder, TypeFolderFallible, TypeVisitor};
4+
use rustc_middle::ty::fold::{FallibleTypeFolder, TypeFolder, TypeVisitor};
55
use rustc_middle::ty::{self, Const, InferConst, Ty, TyCtxt, TypeFoldable};
66

77
use std::ops::ControlFlow;
@@ -192,7 +192,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> {
192192
}
193193
}
194194

195-
impl<'a, 'tcx> TypeFolderFallible<'tcx> for FullTypeResolver<'a, 'tcx> {
195+
impl<'a, 'tcx> FallibleTypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> {
196196
fn try_fold_ty(&mut self, t: Ty<'tcx>) -> Result<Ty<'tcx>, Self::Error> {
197197
if !t.needs_infer() {
198198
Ok(t) // micro-optimize -- if there is nothing in this type that this fold affects...

compiler/rustc_infer/src/traits/structural_impls.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::traits;
22
use crate::traits::project::Normalized;
33
use rustc_middle::ty;
4-
use rustc_middle::ty::fold::{TypeFoldable, TypeFolderFallible, TypeVisitor};
4+
use rustc_middle::ty::fold::{FallibleTypeFolder, TypeFoldable, TypeVisitor};
55

66
use std::fmt;
77
use std::ops::ControlFlow;
@@ -60,7 +60,7 @@ impl<'tcx> fmt::Debug for traits::MismatchedProjectionTypes<'tcx> {
6060
// TypeFoldable implementations.
6161

6262
impl<'tcx, O: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::Obligation<'tcx, O> {
63-
fn try_super_fold_with<F: TypeFolderFallible<'tcx>>(
63+
fn try_super_fold_with<F: FallibleTypeFolder<'tcx>>(
6464
self,
6565
folder: &mut F,
6666
) -> Result<Self, F::Error> {

compiler/rustc_macros/src/type_foldable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub fn type_foldable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::
2525
s.bound_impl(
2626
quote!(::rustc_middle::ty::fold::TypeFoldable<'tcx>),
2727
quote! {
28-
fn try_super_fold_with<__F: ::rustc_middle::ty::fold::TypeFolderFallible<'tcx>>(
28+
fn try_super_fold_with<__F: ::rustc_middle::ty::fold::FallibleTypeFolder<'tcx>>(
2929
self,
3030
__folder: &mut __F
3131
) -> Result<Self, __F::Error> {

compiler/rustc_middle/src/macros.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ macro_rules! TrivialTypeFoldableImpls {
5252
(for <$tcx:lifetime> { $($ty:ty,)+ }) => {
5353
$(
5454
impl<$tcx> $crate::ty::fold::TypeFoldable<$tcx> for $ty {
55-
fn try_super_fold_with<F: $crate::ty::fold::TypeFolderFallible<$tcx>>(
55+
fn try_super_fold_with<F: $crate::ty::fold::FallibleTypeFolder<$tcx>>(
5656
self,
5757
_: &mut F
5858
) -> ::std::result::Result<$ty, F::Error> {
@@ -95,7 +95,7 @@ macro_rules! EnumTypeFoldableImpl {
9595
impl<$($p),*> $crate::ty::fold::TypeFoldable<$tcx> for $s
9696
$(where $($wc)*)*
9797
{
98-
fn try_super_fold_with<V: $crate::ty::fold::TypeFolderFallible<$tcx>>(
98+
fn try_super_fold_with<V: $crate::ty::fold::FallibleTypeFolder<$tcx>>(
9999
self,
100100
folder: &mut V,
101101
) -> ::std::result::Result<Self, V::Error> {

compiler/rustc_middle/src/mir/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::mir::interpret::{Allocation, ConstValue, GlobalAlloc, Scalar};
77
use crate::mir::visit::MirVisitable;
88
use crate::ty::adjustment::PointerCast;
99
use crate::ty::codec::{TyDecoder, TyEncoder};
10-
use crate::ty::fold::{TypeFoldable, TypeFolderFallible, TypeVisitor};
10+
use crate::ty::fold::{FallibleTypeFolder, TypeFoldable, TypeVisitor};
1111
use crate::ty::print::{FmtPrinter, Printer};
1212
use crate::ty::subst::{Subst, SubstsRef};
1313
use crate::ty::{self, List, Ty, TyCtxt};
@@ -2760,7 +2760,7 @@ impl UserTypeProjection {
27602760
TrivialTypeFoldableAndLiftImpls! { ProjectionKind, }
27612761

27622762
impl<'tcx> TypeFoldable<'tcx> for UserTypeProjection {
2763-
fn try_super_fold_with<F: TypeFolderFallible<'tcx>>(
2763+
fn try_super_fold_with<F: FallibleTypeFolder<'tcx>>(
27642764
self,
27652765
folder: &mut F,
27662766
) -> Result<Self, F::Error> {

compiler/rustc_middle/src/mir/type_foldable.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ TrivialTypeFoldableAndLiftImpls! {
1616
}
1717

1818
impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
19-
fn try_super_fold_with<F: TypeFolderFallible<'tcx>>(
19+
fn try_super_fold_with<F: FallibleTypeFolder<'tcx>>(
2020
self,
2121
folder: &mut F,
2222
) -> Result<Self, F::Error> {
@@ -148,7 +148,7 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
148148
}
149149

150150
impl<'tcx> TypeFoldable<'tcx> for GeneratorKind {
151-
fn try_super_fold_with<F: TypeFolderFallible<'tcx>>(self, _: &mut F) -> Result<Self, F::Error> {
151+
fn try_super_fold_with<F: FallibleTypeFolder<'tcx>>(self, _: &mut F) -> Result<Self, F::Error> {
152152
Ok(self)
153153
}
154154

@@ -158,7 +158,7 @@ impl<'tcx> TypeFoldable<'tcx> for GeneratorKind {
158158
}
159159

160160
impl<'tcx> TypeFoldable<'tcx> for Place<'tcx> {
161-
fn try_super_fold_with<F: TypeFolderFallible<'tcx>>(
161+
fn try_super_fold_with<F: FallibleTypeFolder<'tcx>>(
162162
self,
163163
folder: &mut F,
164164
) -> Result<Self, F::Error> {
@@ -175,7 +175,7 @@ impl<'tcx> TypeFoldable<'tcx> for Place<'tcx> {
175175
}
176176

177177
impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<PlaceElem<'tcx>> {
178-
fn try_super_fold_with<F: TypeFolderFallible<'tcx>>(
178+
fn try_super_fold_with<F: FallibleTypeFolder<'tcx>>(
179179
self,
180180
folder: &mut F,
181181
) -> Result<Self, F::Error> {
@@ -188,7 +188,7 @@ impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<PlaceElem<'tcx>> {
188188
}
189189

190190
impl<'tcx> TypeFoldable<'tcx> for Rvalue<'tcx> {
191-
fn try_super_fold_with<F: TypeFolderFallible<'tcx>>(
191+
fn try_super_fold_with<F: FallibleTypeFolder<'tcx>>(
192192
self,
193193
folder: &mut F,
194194
) -> Result<Self, F::Error> {
@@ -292,7 +292,7 @@ impl<'tcx> TypeFoldable<'tcx> for Rvalue<'tcx> {
292292
}
293293

294294
impl<'tcx> TypeFoldable<'tcx> for Operand<'tcx> {
295-
fn try_super_fold_with<F: TypeFolderFallible<'tcx>>(
295+
fn try_super_fold_with<F: FallibleTypeFolder<'tcx>>(
296296
self,
297297
folder: &mut F,
298298
) -> Result<Self, F::Error> {
@@ -312,7 +312,7 @@ impl<'tcx> TypeFoldable<'tcx> for Operand<'tcx> {
312312
}
313313

314314
impl<'tcx> TypeFoldable<'tcx> for PlaceElem<'tcx> {
315-
fn try_super_fold_with<F: TypeFolderFallible<'tcx>>(
315+
fn try_super_fold_with<F: FallibleTypeFolder<'tcx>>(
316316
self,
317317
folder: &mut F,
318318
) -> Result<Self, F::Error> {
@@ -345,7 +345,7 @@ impl<'tcx> TypeFoldable<'tcx> for PlaceElem<'tcx> {
345345
}
346346

347347
impl<'tcx> TypeFoldable<'tcx> for Field {
348-
fn try_super_fold_with<F: TypeFolderFallible<'tcx>>(self, _: &mut F) -> Result<Self, F::Error> {
348+
fn try_super_fold_with<F: FallibleTypeFolder<'tcx>>(self, _: &mut F) -> Result<Self, F::Error> {
349349
Ok(self)
350350
}
351351
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _: &mut V) -> ControlFlow<V::BreakTy> {
@@ -354,7 +354,7 @@ impl<'tcx> TypeFoldable<'tcx> for Field {
354354
}
355355

356356
impl<'tcx> TypeFoldable<'tcx> for GeneratorSavedLocal {
357-
fn try_super_fold_with<F: TypeFolderFallible<'tcx>>(self, _: &mut F) -> Result<Self, F::Error> {
357+
fn try_super_fold_with<F: FallibleTypeFolder<'tcx>>(self, _: &mut F) -> Result<Self, F::Error> {
358358
Ok(self)
359359
}
360360
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _: &mut V) -> ControlFlow<V::BreakTy> {
@@ -363,7 +363,7 @@ impl<'tcx> TypeFoldable<'tcx> for GeneratorSavedLocal {
363363
}
364364

365365
impl<'tcx, R: Idx, C: Idx> TypeFoldable<'tcx> for BitMatrix<R, C> {
366-
fn try_super_fold_with<F: TypeFolderFallible<'tcx>>(self, _: &mut F) -> Result<Self, F::Error> {
366+
fn try_super_fold_with<F: FallibleTypeFolder<'tcx>>(self, _: &mut F) -> Result<Self, F::Error> {
367367
Ok(self)
368368
}
369369
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, _: &mut V) -> ControlFlow<V::BreakTy> {
@@ -372,7 +372,7 @@ impl<'tcx, R: Idx, C: Idx> TypeFoldable<'tcx> for BitMatrix<R, C> {
372372
}
373373

374374
impl<'tcx> TypeFoldable<'tcx> for Constant<'tcx> {
375-
fn try_super_fold_with<F: TypeFolderFallible<'tcx>>(
375+
fn try_super_fold_with<F: FallibleTypeFolder<'tcx>>(
376376
self,
377377
folder: &mut F,
378378
) -> Result<Self, F::Error> {
@@ -390,11 +390,11 @@ impl<'tcx> TypeFoldable<'tcx> for Constant<'tcx> {
390390

391391
impl<'tcx> TypeFoldable<'tcx> for ConstantKind<'tcx> {
392392
#[inline(always)]
393-
fn try_fold_with<F: TypeFolderFallible<'tcx>>(self, folder: &mut F) -> Result<Self, F::Error> {
393+
fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, folder: &mut F) -> Result<Self, F::Error> {
394394
folder.try_fold_mir_const(self)
395395
}
396396

397-
fn try_super_fold_with<F: TypeFolderFallible<'tcx>>(
397+
fn try_super_fold_with<F: FallibleTypeFolder<'tcx>>(
398398
self,
399399
folder: &mut F,
400400
) -> Result<Self, F::Error> {

compiler/rustc_middle/src/ty/fold.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ pub trait TypeFoldable<'tcx>: fmt::Debug + Clone {
6363
self.try_fold_with(folder).into_ok()
6464
}
6565

66-
fn try_super_fold_with<F: TypeFolderFallible<'tcx>>(
66+
fn try_super_fold_with<F: FallibleTypeFolder<'tcx>>(
6767
self,
6868
folder: &mut F,
6969
) -> Result<Self, F::Error>;
7070

71-
fn try_fold_with<F: TypeFolderFallible<'tcx>>(self, folder: &mut F) -> Result<Self, F::Error> {
71+
fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, folder: &mut F) -> Result<Self, F::Error> {
7272
self.try_super_fold_with(folder)
7373
}
7474

@@ -216,8 +216,8 @@ impl TypeFoldable<'tcx> for hir::Constness {
216216
///
217217
/// If this folder is fallible (and therefore its [`Error`][`TypeFolder::Error`]
218218
/// associated type is something other than the default, never),
219-
/// [`TypeFolderFallible`] should be implemented manually; otherwise,
220-
/// a blanket implementation of [`TypeFolderFallible`] will defer to
219+
/// [`FallibleTypeFolder`] should be implemented manually; otherwise,
220+
/// a blanket implementation of [`FallibleTypeFolder`] will defer to
221221
/// the infallible methods of this trait to ensure that the two APIs
222222
/// are coherent.
223223
pub trait TypeFolder<'tcx>: Sized {
@@ -269,7 +269,7 @@ pub trait TypeFolder<'tcx>: Sized {
269269
}
270270
}
271271

272-
/// The `TypeFolderFallible` trait defines the actual *folding*. There is a
272+
/// The `FallibleTypeFolder` trait defines the actual *folding*. There is a
273273
/// method defined for every foldable type. Each of these has a
274274
/// default implementation that does an "identity" fold. Within each
275275
/// identity fold, it should invoke `foo.try_fold_with(self)` to fold each
@@ -278,7 +278,7 @@ pub trait TypeFolder<'tcx>: Sized {
278278
/// A blanket implementation of this trait (that defers to the relevant
279279
/// method of [`TypeFolder`]) is provided for all infallible folders in
280280
/// order to ensure the two APIs are coherent.
281-
pub trait TypeFolderFallible<'tcx>: TypeFolder<'tcx> {
281+
pub trait FallibleTypeFolder<'tcx>: TypeFolder<'tcx> {
282282
fn try_fold_binder<T>(&mut self, t: Binder<'tcx, T>) -> Result<Binder<'tcx, T>, Self::Error>
283283
where
284284
T: TypeFoldable<'tcx>,
@@ -318,7 +318,7 @@ pub trait TypeFolderFallible<'tcx>: TypeFolder<'tcx> {
318318

319319
// Blanket implementation of fallible trait for infallible folders
320320
// delegates to infallible methods to prevent incoherence
321-
impl<'tcx, F> TypeFolderFallible<'tcx> for F
321+
impl<'tcx, F> FallibleTypeFolder<'tcx> for F
322322
where
323323
F: TypeFolder<'tcx, Error = !>,
324324
{

compiler/rustc_middle/src/ty/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//!
1010
//! ["The `ty` module: representing types"]: https://rustc-dev-guide.rust-lang.org/ty.html
1111
12-
pub use self::fold::{TypeFoldable, TypeFolder, TypeFolderFallible, TypeVisitor};
12+
pub use self::fold::{FallibleTypeFolder, TypeFoldable, TypeFolder, TypeVisitor};
1313
pub use self::AssocItemContainer::*;
1414
pub use self::BorrowKind::*;
1515
pub use self::IntVarValue::*;
@@ -1269,7 +1269,7 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for ParamEnv<'tcx> {
12691269
}
12701270

12711271
impl<'tcx> TypeFoldable<'tcx> for ParamEnv<'tcx> {
1272-
fn try_super_fold_with<F: ty::fold::TypeFolderFallible<'tcx>>(
1272+
fn try_super_fold_with<F: ty::fold::FallibleTypeFolder<'tcx>>(
12731273
self,
12741274
folder: &mut F,
12751275
) -> Result<Self, F::Error> {

0 commit comments

Comments
 (0)