From 4f9fe856a25ab29345b90e7725509e9ee38a37be Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:41 +0200 Subject: Adding upstream version 1.69.0+dfsg1. Signed-off-by: Daniel Baumann --- compiler/rustc_middle/src/ty/structural_impls.rs | 446 ++++++++--------------- 1 file changed, 153 insertions(+), 293 deletions(-) (limited to 'compiler/rustc_middle/src/ty/structural_impls.rs') diff --git a/compiler/rustc_middle/src/ty/structural_impls.rs b/compiler/rustc_middle/src/ty/structural_impls.rs index 7d4d35b7f..ef643531b 100644 --- a/compiler/rustc_middle/src/ty/structural_impls.rs +++ b/compiler/rustc_middle/src/ty/structural_impls.rs @@ -1,6 +1,7 @@ -//! This module contains implements of the `Lift` and `TypeFoldable` -//! traits for various types in the Rust compiler. Most are written by -//! hand, though we've recently added some macros and proc-macros to help with the tedium. +//! This module contains implementations of the `Lift`, `TypeFoldable` and +//! `TypeVisitable` traits for various types in the Rust compiler. Most are +//! written by hand, though we've recently added some macros and proc-macros +//! to help with the tedium. use crate::mir::interpret; use crate::mir::{Field, ProjectionKind}; @@ -8,12 +9,11 @@ use crate::ty::fold::{FallibleTypeFolder, TypeFoldable, TypeSuperFoldable}; use crate::ty::print::{with_no_trimmed_paths, FmtPrinter, Printer}; use crate::ty::visit::{TypeSuperVisitable, TypeVisitable, TypeVisitor}; use crate::ty::{self, AliasTy, InferConst, Lift, Term, TermKind, Ty, TyCtxt}; -use rustc_data_structures::functor::IdFunctor; use rustc_hir::def::Namespace; use rustc_index::vec::{Idx, IndexVec}; +use rustc_target::abi::TyAndLayout; use std::fmt; -use std::mem::ManuallyDrop; use std::ops::ControlFlow; use std::rc::Rc; use std::sync::Arc; @@ -147,6 +147,7 @@ impl<'tcx> fmt::Debug for ty::Predicate<'tcx> { impl<'tcx> fmt::Debug for ty::Clause<'tcx> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match *self { + ty::Clause::ConstArgHasType(ct, ty) => write!(f, "ConstArgHasType({ct:?}, {ty:?})"), ty::Clause::Trait(ref a) => a.fmt(f), ty::Clause::RegionOutlives(ref pair) => pair.fmt(f), ty::Clause::TypeOutlives(ref pair) => pair.fmt(f), @@ -176,6 +177,7 @@ impl<'tcx> fmt::Debug for ty::PredicateKind<'tcx> { write!(f, "TypeWellFormedFromEnv({:?})", ty) } ty::PredicateKind::Ambiguous => write!(f, "Ambiguous"), + ty::PredicateKind::AliasEq(t1, t2) => write!(f, "AliasEq({t1:?}, {t2:?})"), } } } @@ -193,16 +195,27 @@ impl<'tcx> fmt::Debug for AliasTy<'tcx> { // Atomic structs // // For things that don't carry any arena-allocated data (and are -// copy...), just add them to this list. +// copy...), just add them to one of these lists as appropriat. -TrivialTypeTraversalAndLiftImpls! { +// For things for which the type library provides traversal implementations +// for all Interners, we only need to provide a Lift implementation: +CloneLiftImpls! { (), bool, usize, - ::rustc_target::abi::VariantIdx, + u16, u32, u64, String, + rustc_type_ir::DebruijnIndex, +} + +// For things about which the type library does not know, or does not +// provide any traversal implementations, we need to provide both a Lift +// implementation and traversal implementations (the latter only for +// TyCtxt<'_> interners). +TrivialTypeTraversalAndLiftImpls! { + ::rustc_target::abi::VariantIdx, crate::middle::region::Scope, crate::ty::FloatTy, ::rustc_ast::InlineAsmOptions, @@ -238,6 +251,7 @@ TrivialTypeTraversalAndLiftImpls! { crate::ty::AssocKind, crate::ty::AliasKind, crate::ty::Placeholder, + crate::ty::Placeholder, crate::ty::ClosureKind, crate::ty::FreeRegion, crate::ty::InferTy, @@ -249,11 +263,11 @@ TrivialTypeTraversalAndLiftImpls! { crate::ty::UniverseIndex, crate::ty::Variance, ::rustc_span::Span, + ::rustc_span::symbol::Ident, ::rustc_errors::ErrorGuaranteed, Field, interpret::Scalar, rustc_target::abi::Size, - rustc_type_ir::DebruijnIndex, ty::BoundVar, ty::Placeholder, } @@ -356,281 +370,106 @@ impl<'a, 'tcx> Lift<'tcx> for ty::ParamEnv<'a> { } /////////////////////////////////////////////////////////////////////////// -// TypeFoldable implementations. +// Traversal implementations. /// AdtDefs are basically the same as a DefId. -impl<'tcx> TypeFoldable<'tcx> for ty::AdtDef<'tcx> { - fn try_fold_with>(self, _folder: &mut F) -> Result { +impl<'tcx> TypeFoldable> for ty::AdtDef<'tcx> { + fn try_fold_with>>( + self, + _folder: &mut F, + ) -> Result { Ok(self) } } -impl<'tcx> TypeVisitable<'tcx> for ty::AdtDef<'tcx> { - fn visit_with>(&self, _visitor: &mut V) -> ControlFlow { +impl<'tcx> TypeVisitable> for ty::AdtDef<'tcx> { + fn visit_with>>( + &self, + _visitor: &mut V, + ) -> ControlFlow { ControlFlow::Continue(()) } } -impl<'tcx, T: TypeFoldable<'tcx>, U: TypeFoldable<'tcx>> TypeFoldable<'tcx> for (T, U) { - fn try_fold_with>( +impl<'tcx, T: TypeFoldable>> TypeFoldable> for ty::Binder<'tcx, T> { + fn try_fold_with>>( self, folder: &mut F, - ) -> Result<(T, U), F::Error> { - Ok((self.0.try_fold_with(folder)?, self.1.try_fold_with(folder)?)) + ) -> Result { + folder.try_fold_binder(self) } } -impl<'tcx, T: TypeVisitable<'tcx>, U: TypeVisitable<'tcx>> TypeVisitable<'tcx> for (T, U) { - fn visit_with>(&self, visitor: &mut V) -> ControlFlow { - self.0.visit_with(visitor)?; - self.1.visit_with(visitor) +impl<'tcx, T: TypeVisitable>> TypeVisitable> for ty::Binder<'tcx, T> { + fn visit_with>>(&self, visitor: &mut V) -> ControlFlow { + visitor.visit_binder(self) } } -impl<'tcx, A: TypeFoldable<'tcx>, B: TypeFoldable<'tcx>, C: TypeFoldable<'tcx>> TypeFoldable<'tcx> - for (A, B, C) -{ - fn try_fold_with>( +impl<'tcx, T: TypeFoldable>> TypeSuperFoldable> for ty::Binder<'tcx, T> { + fn try_super_fold_with>>( self, folder: &mut F, - ) -> Result<(A, B, C), F::Error> { - Ok(( - self.0.try_fold_with(folder)?, - self.1.try_fold_with(folder)?, - self.2.try_fold_with(folder)?, - )) + ) -> Result { + self.try_map_bound(|ty| ty.try_fold_with(folder)) } } -impl<'tcx, A: TypeVisitable<'tcx>, B: TypeVisitable<'tcx>, C: TypeVisitable<'tcx>> - TypeVisitable<'tcx> for (A, B, C) +impl<'tcx, T: TypeVisitable>> TypeSuperVisitable> + for ty::Binder<'tcx, T> { - fn visit_with>(&self, visitor: &mut V) -> ControlFlow { - self.0.visit_with(visitor)?; - self.1.visit_with(visitor)?; - self.2.visit_with(visitor) + fn super_visit_with>>( + &self, + visitor: &mut V, + ) -> ControlFlow { + self.as_ref().skip_binder().visit_with(visitor) } } -EnumTypeTraversalImpl! { - impl<'tcx, T> TypeFoldable<'tcx> for Option { - (Some)(a), - (None), - } where T: TypeFoldable<'tcx> -} -EnumTypeTraversalImpl! { - impl<'tcx, T> TypeVisitable<'tcx> for Option { - (Some)(a), - (None), - } where T: TypeVisitable<'tcx> -} - -EnumTypeTraversalImpl! { - impl<'tcx, T, E> TypeFoldable<'tcx> for Result { - (Ok)(a), - (Err)(a), - } where T: TypeFoldable<'tcx>, E: TypeFoldable<'tcx>, -} -EnumTypeTraversalImpl! { - impl<'tcx, T, E> TypeVisitable<'tcx> for Result { - (Ok)(a), - (Err)(a), - } where T: TypeVisitable<'tcx>, E: TypeVisitable<'tcx>, -} - -impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Rc { - fn try_fold_with>( - mut self, +impl<'tcx> TypeFoldable> for &'tcx ty::List> { + fn try_fold_with>>( + self, folder: &mut F, ) -> Result { - // We merely want to replace the contained `T`, if at all possible, - // so that we don't needlessly allocate a new `Rc` or indeed clone - // the contained type. - unsafe { - // First step is to ensure that we have a unique reference to - // the contained type, which `Rc::make_mut` will accomplish (by - // allocating a new `Rc` and cloning the `T` only if required). - // This is done *before* casting to `Rc>` so that - // panicking during `make_mut` does not leak the `T`. - Rc::make_mut(&mut self); - - // Casting to `Rc>` is safe because `ManuallyDrop` - // is `repr(transparent)`. - let ptr = Rc::into_raw(self).cast::>(); - let mut unique = Rc::from_raw(ptr); - - // Call to `Rc::make_mut` above guarantees that `unique` is the - // sole reference to the contained value, so we can avoid doing - // a checked `get_mut` here. - let slot = Rc::get_mut_unchecked(&mut unique); - - // Semantically move the contained type out from `unique`, fold - // it, then move the folded value back into `unique`. Should - // folding fail, `ManuallyDrop` ensures that the "moved-out" - // value is not re-dropped. - let owned = ManuallyDrop::take(slot); - let folded = owned.try_fold_with(folder)?; - *slot = ManuallyDrop::new(folded); - - // Cast back to `Rc`. - Ok(Rc::from_raw(Rc::into_raw(unique).cast())) - } + ty::util::fold_list(self, folder, |tcx, v| tcx.mk_poly_existential_predicates(v)) } } -impl<'tcx, T: TypeVisitable<'tcx>> TypeVisitable<'tcx> for Rc { - fn visit_with>(&self, visitor: &mut V) -> ControlFlow { - (**self).visit_with(visitor) - } -} - -impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Arc { - fn try_fold_with>( - mut self, +impl<'tcx> TypeFoldable> for &'tcx ty::List> { + fn try_fold_with>>( + self, folder: &mut F, ) -> Result { - // We merely want to replace the contained `T`, if at all possible, - // so that we don't needlessly allocate a new `Arc` or indeed clone - // the contained type. - unsafe { - // First step is to ensure that we have a unique reference to - // the contained type, which `Arc::make_mut` will accomplish (by - // allocating a new `Arc` and cloning the `T` only if required). - // This is done *before* casting to `Arc>` so that - // panicking during `make_mut` does not leak the `T`. - Arc::make_mut(&mut self); - - // Casting to `Arc>` is safe because `ManuallyDrop` - // is `repr(transparent)`. - let ptr = Arc::into_raw(self).cast::>(); - let mut unique = Arc::from_raw(ptr); - - // Call to `Arc::make_mut` above guarantees that `unique` is the - // sole reference to the contained value, so we can avoid doing - // a checked `get_mut` here. - let slot = Arc::get_mut_unchecked(&mut unique); - - // Semantically move the contained type out from `unique`, fold - // it, then move the folded value back into `unique`. Should - // folding fail, `ManuallyDrop` ensures that the "moved-out" - // value is not re-dropped. - let owned = ManuallyDrop::take(slot); - let folded = owned.try_fold_with(folder)?; - *slot = ManuallyDrop::new(folded); - - // Cast back to `Arc`. - Ok(Arc::from_raw(Arc::into_raw(unique).cast())) - } - } -} - -impl<'tcx, T: TypeVisitable<'tcx>> TypeVisitable<'tcx> for Arc { - fn visit_with>(&self, visitor: &mut V) -> ControlFlow { - (**self).visit_with(visitor) - } -} - -impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Box { - fn try_fold_with>(self, folder: &mut F) -> Result { - self.try_map_id(|value| value.try_fold_with(folder)) - } -} - -impl<'tcx, T: TypeVisitable<'tcx>> TypeVisitable<'tcx> for Box { - fn visit_with>(&self, visitor: &mut V) -> ControlFlow { - (**self).visit_with(visitor) - } -} - -impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Vec { - fn try_fold_with>(self, folder: &mut F) -> Result { - self.try_map_id(|t| t.try_fold_with(folder)) - } -} - -impl<'tcx, T: TypeVisitable<'tcx>> TypeVisitable<'tcx> for Vec { - fn visit_with>(&self, visitor: &mut V) -> ControlFlow { - self.iter().try_for_each(|t| t.visit_with(visitor)) - } -} - -impl<'tcx, T: TypeVisitable<'tcx>> TypeVisitable<'tcx> for &[T] { - fn visit_with>(&self, visitor: &mut V) -> ControlFlow { - self.iter().try_for_each(|t| t.visit_with(visitor)) - } -} - -impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for Box<[T]> { - fn try_fold_with>(self, folder: &mut F) -> Result { - self.try_map_id(|t| t.try_fold_with(folder)) - } -} - -impl<'tcx, T: TypeVisitable<'tcx>> TypeVisitable<'tcx> for Box<[T]> { - fn visit_with>(&self, visitor: &mut V) -> ControlFlow { - self.iter().try_for_each(|t| t.visit_with(visitor)) + ty::util::fold_list(self, folder, |tcx, v| tcx.mk_const_list(v)) } } -impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder<'tcx, T> { - fn try_fold_with>(self, folder: &mut F) -> Result { - folder.try_fold_binder(self) - } -} - -impl<'tcx, T: TypeVisitable<'tcx>> TypeVisitable<'tcx> for ty::Binder<'tcx, T> { - fn visit_with>(&self, visitor: &mut V) -> ControlFlow { - visitor.visit_binder(self) - } -} - -impl<'tcx, T: TypeFoldable<'tcx>> TypeSuperFoldable<'tcx> for ty::Binder<'tcx, T> { - fn try_super_fold_with>( +impl<'tcx> TypeFoldable> for &'tcx ty::List { + fn try_fold_with>>( self, folder: &mut F, ) -> Result { - self.try_map_bound(|ty| ty.try_fold_with(folder)) + ty::util::fold_list(self, folder, |tcx, v| tcx.mk_projs(v)) } } -impl<'tcx, T: TypeVisitable<'tcx>> TypeSuperVisitable<'tcx> for ty::Binder<'tcx, T> { - fn super_visit_with>(&self, visitor: &mut V) -> ControlFlow { - self.as_ref().skip_binder().visit_with(visitor) - } -} - -impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List> { - fn try_fold_with>(self, folder: &mut F) -> Result { - ty::util::fold_list(self, folder, |tcx, v| tcx.intern_poly_existential_predicates(v)) - } -} - -impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List> { - fn try_fold_with>(self, folder: &mut F) -> Result { - ty::util::fold_list(self, folder, |tcx, v| tcx.mk_const_list(v.iter())) - } -} - -impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List { - fn try_fold_with>(self, folder: &mut F) -> Result { - ty::util::fold_list(self, folder, |tcx, v| tcx.intern_projs(v)) - } -} - -impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> { - fn try_fold_with>(self, folder: &mut F) -> Result { +impl<'tcx> TypeFoldable> for Ty<'tcx> { + fn try_fold_with>>( + self, + folder: &mut F, + ) -> Result { folder.try_fold_ty(self) } } -impl<'tcx> TypeVisitable<'tcx> for Ty<'tcx> { - fn visit_with>(&self, visitor: &mut V) -> ControlFlow { +impl<'tcx> TypeVisitable> for Ty<'tcx> { + fn visit_with>>(&self, visitor: &mut V) -> ControlFlow { visitor.visit_ty(*self) } } -impl<'tcx> TypeSuperFoldable<'tcx> for Ty<'tcx> { - fn try_super_fold_with>( +impl<'tcx> TypeSuperFoldable> for Ty<'tcx> { + fn try_super_fold_with>>( self, folder: &mut F, ) -> Result { @@ -654,6 +493,9 @@ impl<'tcx> TypeSuperFoldable<'tcx> for Ty<'tcx> { ty::Generator(did, substs.try_fold_with(folder)?, movability) } ty::GeneratorWitness(types) => ty::GeneratorWitness(types.try_fold_with(folder)?), + ty::GeneratorWitnessMIR(did, substs) => { + ty::GeneratorWitnessMIR(did, substs.try_fold_with(folder)?) + } ty::Closure(did, substs) => ty::Closure(did, substs.try_fold_with(folder)?), ty::Alias(kind, data) => ty::Alias(kind, data.try_fold_with(folder)?), @@ -672,12 +514,15 @@ impl<'tcx> TypeSuperFoldable<'tcx> for Ty<'tcx> { | ty::Foreign(..) => return Ok(self), }; - Ok(if *self.kind() == kind { self } else { folder.tcx().mk_ty(kind) }) + Ok(if *self.kind() == kind { self } else { folder.interner().mk_ty_from_kind(kind) }) } } -impl<'tcx> TypeSuperVisitable<'tcx> for Ty<'tcx> { - fn super_visit_with>(&self, visitor: &mut V) -> ControlFlow { +impl<'tcx> TypeSuperVisitable> for Ty<'tcx> { + fn super_visit_with>>( + &self, + visitor: &mut V, + ) -> ControlFlow { match self.kind() { ty::RawPtr(ref tm) => tm.visit_with(visitor), ty::Array(typ, sz) => { @@ -699,6 +544,7 @@ impl<'tcx> TypeSuperVisitable<'tcx> for Ty<'tcx> { } ty::Generator(_did, ref substs, _) => substs.visit_with(visitor), ty::GeneratorWitness(ref types) => types.visit_with(visitor), + ty::GeneratorWitnessMIR(_did, ref substs) => substs.visit_with(visitor), ty::Closure(_did, ref substs) => substs.visit_with(visitor), ty::Alias(_, ref data) => data.visit_with(visitor), @@ -719,20 +565,23 @@ impl<'tcx> TypeSuperVisitable<'tcx> for Ty<'tcx> { } } -impl<'tcx> TypeFoldable<'tcx> for ty::Region<'tcx> { - fn try_fold_with>(self, folder: &mut F) -> Result { +impl<'tcx> TypeFoldable> for ty::Region<'tcx> { + fn try_fold_with>>( + self, + folder: &mut F, + ) -> Result { folder.try_fold_region(self) } } -impl<'tcx> TypeVisitable<'tcx> for ty::Region<'tcx> { - fn visit_with>(&self, visitor: &mut V) -> ControlFlow { +impl<'tcx> TypeVisitable> for ty::Region<'tcx> { + fn visit_with>>(&self, visitor: &mut V) -> ControlFlow { visitor.visit_region(*self) } } -impl<'tcx> TypeSuperFoldable<'tcx> for ty::Region<'tcx> { - fn try_super_fold_with>( +impl<'tcx> TypeSuperFoldable> for ty::Region<'tcx> { + fn try_super_fold_with>>( self, _folder: &mut F, ) -> Result { @@ -740,116 +589,127 @@ impl<'tcx> TypeSuperFoldable<'tcx> for ty::Region<'tcx> { } } -impl<'tcx> TypeSuperVisitable<'tcx> for ty::Region<'tcx> { - fn super_visit_with>(&self, _visitor: &mut V) -> ControlFlow { +impl<'tcx> TypeSuperVisitable> for ty::Region<'tcx> { + fn super_visit_with>>( + &self, + _visitor: &mut V, + ) -> ControlFlow { ControlFlow::Continue(()) } } -impl<'tcx> TypeFoldable<'tcx> for ty::Predicate<'tcx> { - fn try_fold_with>(self, folder: &mut F) -> Result { +impl<'tcx> TypeFoldable> for ty::Predicate<'tcx> { + fn try_fold_with>>( + self, + folder: &mut F, + ) -> Result { folder.try_fold_predicate(self) } } -impl<'tcx> TypeVisitable<'tcx> for ty::Predicate<'tcx> { - fn visit_with>(&self, visitor: &mut V) -> ControlFlow { +impl<'tcx> TypeVisitable> for ty::Predicate<'tcx> { + fn visit_with>>(&self, visitor: &mut V) -> ControlFlow { visitor.visit_predicate(*self) } - - #[inline] - fn has_vars_bound_at_or_above(&self, binder: ty::DebruijnIndex) -> bool { - self.outer_exclusive_binder() > binder - } - - #[inline] - fn has_type_flags(&self, flags: ty::TypeFlags) -> bool { - self.flags().intersects(flags) - } } -impl<'tcx> TypeSuperFoldable<'tcx> for ty::Predicate<'tcx> { - fn try_super_fold_with>( +impl<'tcx> TypeSuperFoldable> for ty::Predicate<'tcx> { + fn try_super_fold_with>>( self, folder: &mut F, ) -> Result { let new = self.kind().try_fold_with(folder)?; - Ok(folder.tcx().reuse_or_mk_predicate(self, new)) + Ok(folder.interner().reuse_or_mk_predicate(self, new)) } } -impl<'tcx> TypeSuperVisitable<'tcx> for ty::Predicate<'tcx> { - fn super_visit_with>(&self, visitor: &mut V) -> ControlFlow { +impl<'tcx> TypeSuperVisitable> for ty::Predicate<'tcx> { + fn super_visit_with>>( + &self, + visitor: &mut V, + ) -> ControlFlow { self.kind().visit_with(visitor) } } -impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List> { - fn try_fold_with>(self, folder: &mut F) -> Result { - ty::util::fold_list(self, folder, |tcx, v| tcx.intern_predicates(v)) - } -} - -impl<'tcx, T: TypeFoldable<'tcx>, I: Idx> TypeFoldable<'tcx> for IndexVec { - fn try_fold_with>(self, folder: &mut F) -> Result { - self.try_map_id(|x| x.try_fold_with(folder)) - } -} - -impl<'tcx, T: TypeVisitable<'tcx>, I: Idx> TypeVisitable<'tcx> for IndexVec { - fn visit_with>(&self, visitor: &mut V) -> ControlFlow { - self.iter().try_for_each(|t| t.visit_with(visitor)) +impl<'tcx> TypeFoldable> for &'tcx ty::List> { + fn try_fold_with>>( + self, + folder: &mut F, + ) -> Result { + ty::util::fold_list(self, folder, |tcx, v| tcx.mk_predicates(v)) } } -impl<'tcx> TypeFoldable<'tcx> for ty::Const<'tcx> { - fn try_fold_with>(self, folder: &mut F) -> Result { +impl<'tcx> TypeFoldable> for ty::Const<'tcx> { + fn try_fold_with>>( + self, + folder: &mut F, + ) -> Result { folder.try_fold_const(self) } } -impl<'tcx> TypeVisitable<'tcx> for ty::Const<'tcx> { - fn visit_with>(&self, visitor: &mut V) -> ControlFlow { +impl<'tcx> TypeVisitable> for ty::Const<'tcx> { + fn visit_with>>(&self, visitor: &mut V) -> ControlFlow { visitor.visit_const(*self) } } -impl<'tcx> TypeSuperFoldable<'tcx> for ty::Const<'tcx> { - fn try_super_fold_with>( +impl<'tcx> TypeSuperFoldable> for ty::Const<'tcx> { + fn try_super_fold_with>>( self, folder: &mut F, ) -> Result { let ty = self.ty().try_fold_with(folder)?; let kind = self.kind().try_fold_with(folder)?; if ty != self.ty() || kind != self.kind() { - Ok(folder.tcx().mk_const(kind, ty)) + Ok(folder.interner().mk_const(kind, ty)) } else { Ok(self) } } } -impl<'tcx> TypeSuperVisitable<'tcx> for ty::Const<'tcx> { - fn super_visit_with>(&self, visitor: &mut V) -> ControlFlow { +impl<'tcx> TypeSuperVisitable> for ty::Const<'tcx> { + fn super_visit_with>>( + &self, + visitor: &mut V, + ) -> ControlFlow { self.ty().visit_with(visitor)?; self.kind().visit_with(visitor) } } -impl<'tcx> TypeFoldable<'tcx> for InferConst<'tcx> { - fn try_fold_with>(self, _folder: &mut F) -> Result { +impl<'tcx> TypeFoldable> for InferConst<'tcx> { + fn try_fold_with>>( + self, + _folder: &mut F, + ) -> Result { Ok(self) } } -impl<'tcx> TypeVisitable<'tcx> for InferConst<'tcx> { - fn visit_with>(&self, _visitor: &mut V) -> ControlFlow { +impl<'tcx> TypeVisitable> for InferConst<'tcx> { + fn visit_with>>( + &self, + _visitor: &mut V, + ) -> ControlFlow { ControlFlow::Continue(()) } } -impl<'tcx> TypeSuperVisitable<'tcx> for ty::UnevaluatedConst<'tcx> { - fn super_visit_with>(&self, visitor: &mut V) -> ControlFlow { +impl<'tcx> TypeSuperVisitable> for ty::UnevaluatedConst<'tcx> { + fn super_visit_with>>( + &self, + visitor: &mut V, + ) -> ControlFlow { self.substs.visit_with(visitor) } } + +impl<'tcx> TypeVisitable> for TyAndLayout<'tcx, Ty<'tcx>> { + fn visit_with>>(&self, visitor: &mut V) -> ControlFlow { + visitor.visit_ty(self.ty) + } +} -- cgit v1.2.3