@@ -230,18 +230,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
230
230
// diverging expression (e.g. it arose from desugaring of `try { return }`),
231
231
// we skip issuing a warning because it is autogenerated code.
232
232
ExprKind :: Call ( ..) if expr. span . is_desugaring ( DesugaringKind :: TryBlock ) => { }
233
- ExprKind :: Call ( callee, _) => {
234
- let emit_warning = if let ExprKind :: Path ( ref qpath) = callee. kind {
235
- // Do not emit a warning for a call to a constructor.
236
- let res = self . typeck_results . borrow ( ) . qpath_res ( qpath, callee. hir_id ) ;
237
- !matches ! ( res, Res :: Def ( DefKind :: Ctor ( ..) , _) )
238
- } else {
239
- true
240
- } ;
241
- if emit_warning {
242
- self . warn_if_unreachable ( expr. hir_id , callee. span , "call" )
243
- }
244
- }
233
+ ExprKind :: Call ( callee, _) => self . warn_if_unreachable ( expr. hir_id , callee. span , "call" ) ,
245
234
ExprKind :: MethodCall ( segment, ..) => {
246
235
self . warn_if_unreachable ( expr. hir_id , segment. ident . span , "call" )
247
236
}
@@ -258,7 +247,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
258
247
if ty. is_never ( ) {
259
248
// Any expression that produces a value of type `!` must have diverged.
260
249
self . diverges . set ( Diverges :: Always ( DivergeReason :: Other , expr. span ) ) ;
261
- } else if expr_may_be_uninhabited ( expr ) && self . ty_is_uninhabited ( ty) {
250
+ } else if self . ty_is_uninhabited ( ty) {
262
251
// This expression produces a value of uninhabited type.
263
252
// This means it has diverged somehow.
264
253
self . diverges
@@ -3554,42 +3543,3 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
3554
3543
self . tcx . types . usize
3555
3544
}
3556
3545
}
3557
-
3558
- fn expr_may_be_uninhabited ( expr : & hir:: Expr < ' _ > ) -> bool {
3559
- match expr. kind {
3560
- ExprKind :: Call ( ..)
3561
- | ExprKind :: MethodCall ( ..)
3562
- | ExprKind :: Cast ( ..)
3563
- | ExprKind :: Unary ( hir:: UnOp :: Deref , _)
3564
- | ExprKind :: Field ( ..)
3565
- | ExprKind :: Path ( ..)
3566
- | ExprKind :: Struct ( ..) => true ,
3567
- ExprKind :: ConstBlock ( ..)
3568
- | ExprKind :: Array ( ..)
3569
- | ExprKind :: Tup ( ..)
3570
- | ExprKind :: Binary ( ..)
3571
- | ExprKind :: Unary ( hir:: UnOp :: Neg | hir:: UnOp :: Not , _)
3572
- | ExprKind :: Lit ( ..)
3573
- | ExprKind :: Type ( ..)
3574
- | ExprKind :: DropTemps ( ..)
3575
- | ExprKind :: OffsetOf ( ..)
3576
- | ExprKind :: Let ( ..)
3577
- | ExprKind :: If ( ..)
3578
- | ExprKind :: Loop ( ..)
3579
- | ExprKind :: Match ( ..)
3580
- | ExprKind :: Closure ( ..)
3581
- | ExprKind :: Block ( ..)
3582
- | ExprKind :: Assign ( ..)
3583
- | ExprKind :: AssignOp ( ..)
3584
- | ExprKind :: Index ( ..)
3585
- | ExprKind :: AddrOf ( ..)
3586
- | ExprKind :: Break ( ..)
3587
- | ExprKind :: Continue ( ..)
3588
- | ExprKind :: Ret ( ..)
3589
- | ExprKind :: Become ( ..)
3590
- | ExprKind :: InlineAsm ( ..)
3591
- | ExprKind :: Repeat ( ..)
3592
- | ExprKind :: Yield ( ..)
3593
- | ExprKind :: Err ( _) => false ,
3594
- }
3595
- }
0 commit comments