@@ -186,30 +186,10 @@ impl<'tcx> MatchVisitor<'_, 'tcx> {
186186 // Fourth, check for unreachable arms.
187187 let matrix = check_arms ( & mut cx, & inlined_arms, source) ;
188188
189- // FIXME: getting the type using `node_type` means that if `f` has output type `!`, we
190- // get `scrut_ty = !` instead of `bool` in the following:
191- // ```
192- // fn from(never: !) -> usize {
193- // match never {
194- // true => 1,
195- // false => 0,
196- // }
197- // }
198- // ```
199- // If we use `expr_ty_adjusted` instead, then the following breaks, because we get
200- // `scrut_ty = ()` instead of `!`.
201- // ```
202- // fn from(never: !) -> usize {
203- // match never {}
204- // }
205- // ```
206- // As a workaround, we retrieve the type from the match arms when possible.
207- let scrut_ty = self . tables . node_type ( scrut. hir_id ) ;
208- let scrut_ty = inlined_arms. iter ( ) . map ( |( p, _, _) | p. ty ) . next ( ) . unwrap_or ( scrut_ty) ;
209-
210189 // Fifth, check if the match is exhaustive.
211190 // Note: An empty match isn't the same as an empty matrix for diagnostics purposes,
212191 // since an empty matrix can occur when there are arms, if those arms all have guards.
192+ let scrut_ty = self . tables . expr_ty_adjusted ( scrut) ;
213193 let is_empty_match = inlined_arms. is_empty ( ) ;
214194 check_exhaustive ( & mut cx, scrut_ty, scrut. span , & matrix, scrut. hir_id , is_empty_match) ;
215195 }
0 commit comments