File tree Expand file tree Collapse file tree
compiler/rustc_middle/src/ty Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -586,18 +586,26 @@ impl<'tcx> TypeSuperFoldable<TyCtxt<'tcx>> for ty::Predicate<'tcx> {
586586 self ,
587587 folder : & mut F ,
588588 ) -> Result < Self , F :: Error > {
589+ // This method looks different to `Ty::try_super_fold_with` and `Const::super_fold_with`.
590+ // Why is that? `PredicateKind` provides little scope for optimized folding, unlike
591+ // `TyKind` and `ConstKind` (which have common variants that don't require recursive
592+ // `fold_with` calls on their fields). So we just derive the `TypeFoldable` impl for
593+ // `PredicateKind` and call it here because the derived code is as fast as hand-written
594+ // code would be.
589595 let new = self . kind ( ) . try_fold_with ( folder) ?;
590596 Ok ( folder. cx ( ) . reuse_or_mk_predicate ( self , new) )
591597 }
592598
593599 fn super_fold_with < F : TypeFolder < TyCtxt < ' tcx > > > ( self , folder : & mut F ) -> Self {
600+ // See comment in `Predicate::try_super_fold_with`.
594601 let new = self . kind ( ) . fold_with ( folder) ;
595602 folder. cx ( ) . reuse_or_mk_predicate ( self , new)
596603 }
597604}
598605
599606impl < ' tcx > TypeSuperVisitable < TyCtxt < ' tcx > > for ty:: Predicate < ' tcx > {
600607 fn super_visit_with < V : TypeVisitor < TyCtxt < ' tcx > > > ( & self , visitor : & mut V ) -> V :: Result {
608+ // See comment in `Predicate::try_super_fold_with`.
601609 self . kind ( ) . visit_with ( visitor)
602610 }
603611}
You can’t perform that action at this time.
0 commit comments