@@ -744,7 +744,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
744
744
/// Note: it is possible to get `isize/usize::MAX+1` here, as explained in the doc for
745
745
/// [`IntRange::split`]. This cannot be represented as a `Const`, so we represent it with
746
746
/// `PosInfinity`.
747
- pub ( crate ) fn hoist_pat_range_bdy (
747
+ fn hoist_pat_range_bdy (
748
748
& self ,
749
749
miint : MaybeInfiniteInt ,
750
750
ty : RevealedTy < ' tcx > ,
@@ -775,7 +775,7 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
775
775
}
776
776
777
777
/// 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 > {
779
779
use MaybeInfiniteInt :: * ;
780
780
let cx = self ;
781
781
let kind = if matches ! ( ( range. lo, range. hi) , ( NegInfinity , PosInfinity ) ) {
@@ -811,9 +811,17 @@ impl<'p, 'tcx: 'p> RustcPatCtxt<'p, 'tcx> {
811
811
812
812
Pat { ty : ty. inner ( ) , span : DUMMY_SP , kind }
813
813
}
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
+
814
822
/// Convert back to a `thir::Pat` for diagnostic purposes. This panics for patterns that don't
815
823
/// 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 > {
817
825
let cx = self ;
818
826
let is_wildcard = |pat : & Pat < ' _ > | matches ! ( pat. kind, PatKind :: Wild ) ;
819
827
let mut subpatterns = pat. iter_fields ( ) . map ( |p| Box :: new ( cx. hoist_witness_pat ( p) ) ) ;
0 commit comments