@@ -3213,9 +3213,10 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
32133213 PatKind :: Or ( ref ps) => {
32143214 // Check the consistency of this or-pattern and
32153215 // then add all bindings to the larger map.
3216- let ( bm, np) = self . compute_and_check_or_pat_binding_map ( ps) ;
3217- binding_map. extend ( bm) ;
3218- is_never_pat |= np;
3216+ match self . compute_and_check_or_pat_binding_map ( ps) {
3217+ Ok ( bm) => binding_map. extend ( bm) ,
3218+ Err ( IsNeverPattern ) => is_never_pat = true ,
3219+ }
32193220 return false ;
32203221 }
32213222 PatKind :: Never => is_never_pat = true ,
@@ -3249,7 +3250,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
32493250 fn compute_and_check_or_pat_binding_map (
32503251 & mut self ,
32513252 pats : & [ P < Pat > ] ,
3252- ) -> ( FxIndexMap < Ident , BindingInfo > , bool ) {
3253+ ) -> Result < FxIndexMap < Ident , BindingInfo > , IsNeverPattern > {
32533254 let mut missing_vars = FxIndexMap :: default ( ) ;
32543255 let mut inconsistent_vars = FxIndexMap :: default ( ) ;
32553256
@@ -3314,12 +3315,16 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
33143315 }
33153316
33163317 // 5) Bubble up the final binding map.
3317- let is_never_pat = not_never_pats. is_empty ( ) ;
3318- let mut binding_map = FxIndexMap :: default ( ) ;
3319- for ( bm, _) in not_never_pats {
3320- binding_map. extend ( bm) ;
3318+ if not_never_pats. is_empty ( ) {
3319+ // All the patterns are never patterns, so the whole or-pattern is one too.
3320+ Err ( IsNeverPattern )
3321+ } else {
3322+ let mut binding_map = FxIndexMap :: default ( ) ;
3323+ for ( bm, _) in not_never_pats {
3324+ binding_map. extend ( bm) ;
3325+ }
3326+ Ok ( binding_map)
33213327 }
3322- ( binding_map, is_never_pat)
33233328 }
33243329
33253330 /// Check the consistency of bindings wrt or-patterns and never patterns.
0 commit comments