@@ -744,7 +744,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
744744 /// Note: it is possible to get `isize/usize::MAX+1` here, as explained in the doc for
745745 /// [`IntRange::split`]. This cannot be represented as a `Const`, so we represent it with
746746 /// `PosInfinity`.
747- pub ( crate ) fn hoist_pat_range_bdy (
747+ fn hoist_pat_range_bdy (
748748 & self ,
749749 miint : MaybeInfiniteInt ,
750750 ty : RevealedTy < ' tcx > ,
@@ -775,7 +775,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
775775 }
776776
777777 /// Convert back to a `thir::Pat` for diagnostic purposes.
778- pub ( crate ) fn hoist_pat_range ( & self , range : & IntRange , ty : RevealedTy < ' tcx > ) -> Pat < ' tcx > {
778+ fn hoist_pat_range ( & self , range : & IntRange , ty : RevealedTy < ' tcx > ) -> Pat < ' tcx > {
779779 use MaybeInfiniteInt :: * ;
780780 let cx = self ;
781781 let kind = if matches ! ( ( range. lo, range. hi) , ( NegInfinity , PosInfinity ) ) {
@@ -811,9 +811,17 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
811811
812812 Pat { ty : ty. inner ( ) , span : DUMMY_SP , kind }
813813 }
814+
815+ /// Prints a [`WitnessPat`] to an owned string, for diagnostic purposes.
816+ pub fn print_witness_pat ( & self , pat : & WitnessPat < ' p , ' tcx > ) -> String {
817+ // This works by converting the witness pattern back to a `thir::Pat`
818+ // and then printing that, but callers don't need to know that.
819+ self . hoist_witness_pat ( pat) . to_string ( )
820+ }
821+
814822 /// Convert back to a `thir::Pat` for diagnostic purposes. This panics for patterns that don't
815823 /// appear in diagnostics, like float ranges.
816- pub fn hoist_witness_pat ( & self , pat : & WitnessPat < ' p , ' tcx > ) -> Pat < ' tcx > {
824+ fn hoist_witness_pat ( & self , pat : & WitnessPat < ' p , ' tcx > ) -> Pat < ' tcx > {
817825 let cx = self ;
818826 let is_wildcard = |pat : & Pat < ' _ > | matches ! ( pat. kind, PatKind :: Wild ) ;
819827 let mut subpatterns = pat. iter_fields ( ) . map ( |p| Box :: new ( cx. hoist_witness_pat ( p) ) ) ;
0 commit comments