@@ -653,6 +653,45 @@ impl<'a, 'tcx> WfPredicates<'a, 'tcx> {
653653 }
654654 }
655655 }
656+
657+ fn check_pat ( & mut self , subty : Ty < ' tcx > , pat : ty:: Pattern < ' tcx > ) {
658+ let tcx = self . tcx ( ) ;
659+ match * pat {
660+ ty:: PatternKind :: Range { start, end } => {
661+ let mut check = |c| {
662+ let cause = self . cause ( ObligationCauseCode :: Misc ) ;
663+ self . out . push ( traits:: Obligation :: with_depth (
664+ tcx,
665+ cause. clone ( ) ,
666+ self . recursion_depth ,
667+ self . param_env ,
668+ ty:: Binder :: dummy ( ty:: PredicateKind :: Clause (
669+ ty:: ClauseKind :: ConstArgHasType ( c, subty) ,
670+ ) ) ,
671+ ) ) ;
672+ if !tcx. features ( ) . generic_pattern_types ( ) {
673+ if c. has_param ( ) {
674+ if self . span . is_dummy ( ) {
675+ self . tcx ( )
676+ . dcx ( )
677+ . delayed_bug ( "feature error should be reported elsewhere, too" ) ;
678+ } else {
679+ feature_err (
680+ & self . tcx ( ) . sess ,
681+ sym:: generic_pattern_types,
682+ self . span ,
683+ "wraparound pattern type ranges cause monomorphization time errors" ,
684+ )
685+ . emit ( ) ;
686+ }
687+ }
688+ }
689+ } ;
690+ check ( start) ;
691+ check ( end) ;
692+ }
693+ }
694+ }
656695}
657696
658697impl < ' a , ' tcx > TypeVisitor < TyCtxt < ' tcx > > for WfPredicates < ' a , ' tcx > {
@@ -707,41 +746,7 @@ impl<'a, 'tcx> TypeVisitor<TyCtxt<'tcx>> for WfPredicates<'a, 'tcx> {
707746
708747 ty:: Pat ( subty, pat) => {
709748 self . require_sized ( subty, ObligationCauseCode :: Misc ) ;
710- match * pat {
711- ty:: PatternKind :: Range { start, end } => {
712- let mut check = |c| {
713- let cause = self . cause ( ObligationCauseCode :: Misc ) ;
714- self . out . push ( traits:: Obligation :: with_depth (
715- tcx,
716- cause. clone ( ) ,
717- self . recursion_depth ,
718- self . param_env ,
719- ty:: Binder :: dummy ( ty:: PredicateKind :: Clause (
720- ty:: ClauseKind :: ConstArgHasType ( c, subty) ,
721- ) ) ,
722- ) ) ;
723- if !tcx. features ( ) . generic_pattern_types ( ) {
724- if c. has_param ( ) {
725- if self . span . is_dummy ( ) {
726- self . tcx ( ) . dcx ( ) . delayed_bug (
727- "feature error should be reported elsewhere, too" ,
728- ) ;
729- } else {
730- feature_err (
731- & self . tcx ( ) . sess ,
732- sym:: generic_pattern_types,
733- self . span ,
734- "wraparound pattern type ranges cause monomorphization time errors" ,
735- )
736- . emit ( ) ;
737- }
738- }
739- }
740- } ;
741- check ( start) ;
742- check ( end) ;
743- }
744- }
749+ self . check_pat ( subty, pat) ;
745750 }
746751
747752 ty:: Tuple ( tys) => {
0 commit comments