]> git.lizzy.rs Git - rust.git/commitdiff
add inline to `TrivialTypeTraversalImpls`
authorlcnr <rust@lcnr.de>
Wed, 5 Oct 2022 16:26:48 +0000 (18:26 +0200)
committerlcnr <rust@lcnr.de>
Mon, 17 Oct 2022 08:54:03 +0000 (10:54 +0200)
compiler/rustc_middle/src/macros.rs
compiler/rustc_middle/src/mir/type_foldable.rs
compiler/rustc_middle/src/mir/type_visitable.rs

index 0e85c60a363028f97befccb8ac51bb3fdf1bfc78..01fe72de61258bfac36a8f780f12ac1f1d3255ba 100644 (file)
@@ -54,13 +54,22 @@ macro_rules! TrivialTypeTraversalImpls {
             impl<$tcx> $crate::ty::fold::TypeFoldable<$tcx> for $ty {
                 fn try_fold_with<F: $crate::ty::fold::FallibleTypeFolder<$tcx>>(
                     self,
-                    _: &mut F
-                ) -> ::std::result::Result<$ty, F::Error> {
+                    _: &mut F,
+                ) -> ::std::result::Result<Self, F::Error> {
                     Ok(self)
                 }
+
+                #[inline]
+                fn fold_with<F: $crate::ty::fold::TypeFolder<$tcx>>(
+                    self,
+                    _: &mut F,
+                ) -> Self {
+                    self
+                }
             }
 
             impl<$tcx> $crate::ty::visit::TypeVisitable<$tcx> for $ty {
+                #[inline]
                 fn visit_with<F: $crate::ty::visit::TypeVisitor<$tcx>>(
                     &self,
                     _: &mut F)
index 4d7d464d7cd90e2bf9e484dca6a2bd4d914bf701..4c0974f86fb35240532d9b9c9dd342c4bf46e627 100644 (file)
     GeneratorSavedLocal,
 }
 
+TrivialTypeTraversalImpls! {
+    for <'tcx> {
+        ConstValue<'tcx>,
+    }
+}
+
 impl<'tcx> TypeFoldable<'tcx> for &'tcx [InlineAsmTemplatePiece] {
     fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, _folder: &mut F) -> Result<Self, F::Error> {
         Ok(self)
@@ -49,9 +55,3 @@ fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, _: &mut F) -> Result<Self, F
         Ok(self)
     }
 }
-
-impl<'tcx> TypeFoldable<'tcx> for ConstValue<'tcx> {
-    fn try_fold_with<F: FallibleTypeFolder<'tcx>>(self, _: &mut F) -> Result<Self, F::Error> {
-        Ok(self)
-    }
-}
index fd3773f22649061c110847c0b9defa07ac5c952b..e7cd497b206a9eacc500ea7f6bf76258e1b0c1a4 100644 (file)
@@ -7,9 +7,3 @@ fn visit_with<V: TypeVisitor<'tcx>>(&self, _: &mut V) -> ControlFlow<V::BreakTy>
         ControlFlow::CONTINUE
     }
 }
-
-impl<'tcx> TypeVisitable<'tcx> for ConstValue<'tcx> {
-    fn visit_with<V: TypeVisitor<'tcx>>(&self, _: &mut V) -> ControlFlow<V::BreakTy> {
-        ControlFlow::CONTINUE
-    }
-}