diff options
| author | Alan Egerton <eggyal@gmail.com> | 2023-02-10 15:51:28 +0000 |
|---|---|---|
| committer | Alan Egerton <eggyal@gmail.com> | 2023-02-13 10:24:50 +0000 |
| commit | 9fa6bb2aa0d076cffac5699643eb5f473b6eba16 (patch) | |
| tree | fd9258b5bdfe9c1342354f871d43a8741ba0e68d /compiler/rustc_middle/src/macros.rs | |
| parent | 9783fcc13b8362d8cc5ddca1bc1d5b8714b1177e (diff) | |
| download | rust-9fa6bb2aa0d076cffac5699643eb5f473b6eba16.tar.gz rust-9fa6bb2aa0d076cffac5699643eb5f473b6eba16.zip | |
Make atomic structural impls generic over Interner
Diffstat (limited to 'compiler/rustc_middle/src/macros.rs')
| -rw-r--r-- | compiler/rustc_middle/src/macros.rs | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/compiler/rustc_middle/src/macros.rs b/compiler/rustc_middle/src/macros.rs index 08cf12559d7..e096be16677 100644 --- a/compiler/rustc_middle/src/macros.rs +++ b/compiler/rustc_middle/src/macros.rs @@ -100,11 +100,35 @@ macro_rules! TrivialTypeTraversalImpls { }; ($($ty:ty,)+) => { - TrivialTypeTraversalImpls! { - for <'tcx> { - $($ty,)+ + $( + impl<I: $crate::ty::Interner> $crate::ty::fold::ir::TypeFoldable<I> for $ty { + fn try_fold_with<F: $crate::ty::fold::ir::FallibleTypeFolder<I>>( + self, + _: &mut F, + ) -> ::std::result::Result<Self, F::Error> { + Ok(self) + } + + #[inline] + fn fold_with<F: $crate::ty::fold::ir::TypeFolder<I>>( + self, + _: &mut F, + ) -> Self { + self + } } - } + + impl<I: $crate::ty::Interner> $crate::ty::visit::ir::TypeVisitable<I> for $ty { + #[inline] + fn visit_with<F: $crate::ty::visit::ir::TypeVisitor<I>>( + &self, + _: &mut F) + -> ::std::ops::ControlFlow<F::BreakTy> + { + ::std::ops::ControlFlow::Continue(()) + } + } + )+ }; } @@ -121,10 +145,10 @@ macro_rules! EnumTypeTraversalImpl { (impl<$($p:tt),*> TypeFoldable<$tcx:tt> for $s:path { $($variants:tt)* } $(where $($wc:tt)*)*) => { - impl<$($p),*> $crate::ty::fold::ir::TypeFoldable<$crate::ty::TyCtxt<$tcx>> for $s + impl<$($p),*> $crate::ty::fold::ir::TypeFoldable<$tcx> for $s $(where $($wc)*)* { - fn try_fold_with<V: $crate::ty::fold::FallibleTypeFolder<$tcx>>( + fn try_fold_with<V: $crate::ty::fold::ir::FallibleTypeFolder<$tcx>>( self, folder: &mut V, ) -> ::std::result::Result<Self, V::Error> { @@ -136,10 +160,10 @@ macro_rules! EnumTypeTraversalImpl { (impl<$($p:tt),*> TypeVisitable<$tcx:tt> for $s:path { $($variants:tt)* } $(where $($wc:tt)*)*) => { - impl<$($p),*> $crate::ty::visit::ir::TypeVisitable<$crate::ty::TyCtxt<$tcx>> for $s + impl<$($p),*> $crate::ty::visit::ir::TypeVisitable<$tcx> for $s $(where $($wc)*)* { - fn visit_with<V: $crate::ty::visit::TypeVisitor<$tcx>>( + fn visit_with<V: $crate::ty::visit::ir::TypeVisitor<$tcx>>( &self, visitor: &mut V, ) -> ::std::ops::ControlFlow<V::BreakTy> { |
