Skip to content

Commit

Permalink
Rename TypeFolderFallible to FallibleTypeFolder
Browse files Browse the repository at this point in the history
  • Loading branch information
eggyal committed Dec 2, 2021
1 parent d79e17d commit cf683e6
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 68 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_infer/src/infer/resolve.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::type_variable::{TypeVariableOrigin, TypeVariableOriginKind};
use super::{FixupError, FixupResult, InferCtxt, Span};
use rustc_middle::mir;
use rustc_middle::ty::fold::{TypeFolder, TypeFolderFallible, TypeVisitor};
use rustc_middle::ty::fold::{FallibleTypeFolder, TypeFolder, TypeVisitor};
use rustc_middle::ty::{self, Const, InferConst, Ty, TyCtxt, TypeFoldable};

use std::ops::ControlFlow;
Expand Down Expand Up @@ -192,7 +192,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> {
}
}

impl<'a, 'tcx> TypeFolderFallible<'tcx> for FullTypeResolver<'a, 'tcx> {
impl<'a, 'tcx> FallibleTypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> {
fn try_fold_ty(&mut self, t: Ty<'tcx>) -> Result<Ty<'tcx>, Self::Error> {
if !t.needs_infer() {
Ok(t) // micro-optimize -- if there is nothing in this type that this fold affects...
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_infer/src/traits/structural_impls.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::traits;
use crate::traits::project::Normalized;
use rustc_middle::ty;
use rustc_middle::ty::fold::{TypeFoldable, TypeFolderFallible, TypeVisitor};
use rustc_middle::ty::fold::{FallibleTypeFolder, TypeFoldable, TypeVisitor};

use std::fmt;
use std::ops::ControlFlow;
Expand Down Expand Up @@ -60,7 +60,7 @@ impl<'tcx> fmt::Debug for traits::MismatchedProjectionTypes<'tcx> {
// TypeFoldable implementations.

impl<'tcx, O: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::Obligation<'tcx, O> {
fn try_super_fold_with<F: TypeFolderFallible<'tcx>>(
fn try_super_fold_with<F: FallibleTypeFolder<'tcx>>(
self,
folder: &mut F,
) -> Result<Self, F::Error> {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_macros/src/type_foldable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub fn type_foldable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::
s.bound_impl(
quote!(::rustc_middle::ty::fold::TypeFoldable<'tcx>),
quote! {
fn try_super_fold_with<__F: ::rustc_middle::ty::fold::TypeFolderFallible<'tcx>>(
fn try_super_fold_with<__F: ::rustc_middle::ty::fold::FallibleTypeFolder<'tcx>>(
self,
__folder: &mut __F
) -> Result<Self, __F::Error> {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ macro_rules! TrivialTypeFoldableImpls {
(for <$tcx:lifetime> { $($ty:ty,)+ }) => {
$(
impl<$tcx> $crate::ty::fold::TypeFoldable<$tcx> for $ty {
fn try_super_fold_with<F: $crate::ty::fold::TypeFolderFallible<$tcx>>(
fn try_super_fold_with<F: $crate::ty::fold::FallibleTypeFolder<$tcx>>(
self,
_: &mut F
) -> ::std::result::Result<$ty, F::Error> {
Expand Down Expand Up @@ -95,7 +95,7 @@ macro_rules! EnumTypeFoldableImpl {
impl<$($p),*> $crate::ty::fold::TypeFoldable<$tcx> for $s
$(where $($wc)*)*
{
fn try_super_fold_with<V: $crate::ty::fold::TypeFolderFallible<$tcx>>(
fn try_super_fold_with<V: $crate::ty::fold::FallibleTypeFolder<$tcx>>(
self,
folder: &mut V,
) -> ::std::result::Result<Self, V::Error> {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::mir::interpret::{Allocation, ConstValue, GlobalAlloc, Scalar};
use crate::mir::visit::MirVisitable;
use crate::ty::adjustment::PointerCast;
use crate::ty::codec::{TyDecoder, TyEncoder};
use crate::ty::fold::{TypeFoldable, TypeFolderFallible, TypeVisitor};
use crate::ty::fold::{FallibleTypeFolder, TypeFoldable, TypeVisitor};
use crate::ty::print::{FmtPrinter, Printer};
use crate::ty::subst::{Subst, SubstsRef};
use crate::ty::{self, List, Ty, TyCtxt};
Expand Down Expand Up @@ -2760,7 +2760,7 @@ impl UserTypeProjection {
TrivialTypeFoldableAndLiftImpls! { ProjectionKind, }

impl<'tcx> TypeFoldable<'tcx> for UserTypeProjection {
fn try_super_fold_with<F: TypeFolderFallible<'tcx>>(
fn try_super_fold_with<F: FallibleTypeFolder<'tcx>>(
self,
folder: &mut F,
) -> Result<Self, F::Error> {
Expand Down
26 changes: 13 additions & 13 deletions compiler/rustc_middle/src/mir/type_foldable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ TrivialTypeFoldableAndLiftImpls! {
}

impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
fn try_super_fold_with<F: TypeFolderFallible<'tcx>>(
fn try_super_fold_with<F: FallibleTypeFolder<'tcx>>(
self,
folder: &mut F,
) -> Result<Self, F::Error> {
Expand Down Expand Up @@ -148,7 +148,7 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
}

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

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

impl<'tcx> TypeFoldable<'tcx> for Place<'tcx> {
fn try_super_fold_with<F: TypeFolderFallible<'tcx>>(
fn try_super_fold_with<F: FallibleTypeFolder<'tcx>>(
self,
folder: &mut F,
) -> Result<Self, F::Error> {
Expand All @@ -175,7 +175,7 @@ impl<'tcx> TypeFoldable<'tcx> for Place<'tcx> {
}

impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<PlaceElem<'tcx>> {
fn try_super_fold_with<F: TypeFolderFallible<'tcx>>(
fn try_super_fold_with<F: FallibleTypeFolder<'tcx>>(
self,
folder: &mut F,
) -> Result<Self, F::Error> {
Expand All @@ -188,7 +188,7 @@ impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List<PlaceElem<'tcx>> {
}

impl<'tcx> TypeFoldable<'tcx> for Rvalue<'tcx> {
fn try_super_fold_with<F: TypeFolderFallible<'tcx>>(
fn try_super_fold_with<F: FallibleTypeFolder<'tcx>>(
self,
folder: &mut F,
) -> Result<Self, F::Error> {
Expand Down Expand Up @@ -292,7 +292,7 @@ impl<'tcx> TypeFoldable<'tcx> for Rvalue<'tcx> {
}

impl<'tcx> TypeFoldable<'tcx> for Operand<'tcx> {
fn try_super_fold_with<F: TypeFolderFallible<'tcx>>(
fn try_super_fold_with<F: FallibleTypeFolder<'tcx>>(
self,
folder: &mut F,
) -> Result<Self, F::Error> {
Expand All @@ -312,7 +312,7 @@ impl<'tcx> TypeFoldable<'tcx> for Operand<'tcx> {
}

impl<'tcx> TypeFoldable<'tcx> for PlaceElem<'tcx> {
fn try_super_fold_with<F: TypeFolderFallible<'tcx>>(
fn try_super_fold_with<F: FallibleTypeFolder<'tcx>>(
self,
folder: &mut F,
) -> Result<Self, F::Error> {
Expand Down Expand Up @@ -345,7 +345,7 @@ impl<'tcx> TypeFoldable<'tcx> for PlaceElem<'tcx> {
}

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

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

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

impl<'tcx> TypeFoldable<'tcx> for Constant<'tcx> {
fn try_super_fold_with<F: TypeFolderFallible<'tcx>>(
fn try_super_fold_with<F: FallibleTypeFolder<'tcx>>(
self,
folder: &mut F,
) -> Result<Self, F::Error> {
Expand All @@ -390,11 +390,11 @@ impl<'tcx> TypeFoldable<'tcx> for Constant<'tcx> {

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

fn try_super_fold_with<F: TypeFolderFallible<'tcx>>(
fn try_super_fold_with<F: FallibleTypeFolder<'tcx>>(
self,
folder: &mut F,
) -> Result<Self, F::Error> {
Expand Down
14 changes: 7 additions & 7 deletions compiler/rustc_middle/src/ty/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ pub trait TypeFoldable<'tcx>: fmt::Debug + Clone {
self.try_fold_with(folder).into_ok()
}

fn try_super_fold_with<F: TypeFolderFallible<'tcx>>(
fn try_super_fold_with<F: FallibleTypeFolder<'tcx>>(
self,
folder: &mut F,
) -> Result<Self, F::Error>;

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

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

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

// Blanket implementation of fallible trait for infallible folders
// delegates to infallible methods to prevent incoherence
impl<'tcx, F> TypeFolderFallible<'tcx> for F
impl<'tcx, F> FallibleTypeFolder<'tcx> for F
where
F: TypeFolder<'tcx, Error = !>,
{
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//!
//! ["The `ty` module: representing types"]: https://rustc-dev-guide.rust-lang.org/ty.html

pub use self::fold::{TypeFoldable, TypeFolder, TypeFolderFallible, TypeVisitor};
pub use self::fold::{FallibleTypeFolder, TypeFoldable, TypeFolder, TypeVisitor};
pub use self::AssocItemContainer::*;
pub use self::BorrowKind::*;
pub use self::IntVarValue::*;
Expand Down Expand Up @@ -1269,7 +1269,7 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for ParamEnv<'tcx> {
}

impl<'tcx> TypeFoldable<'tcx> for ParamEnv<'tcx> {
fn try_super_fold_with<F: ty::fold::TypeFolderFallible<'tcx>>(
fn try_super_fold_with<F: ty::fold::FallibleTypeFolder<'tcx>>(
self,
folder: &mut F,
) -> Result<Self, F::Error> {
Expand Down
Loading

0 comments on commit cf683e6

Please sign in to comment.