@@ -230,18 +230,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
230230 // diverging expression (e.g. it arose from desugaring of `try { return }`),
231231 // we skip issuing a warning because it is autogenerated code.
232232 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" ) ,
245234 ExprKind :: MethodCall ( segment, ..) => {
246235 self . warn_if_unreachable ( expr. hir_id , segment. ident . span , "call" )
247236 }
@@ -258,7 +247,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
258247 if ty. is_never ( ) {
259248 // Any expression that produces a value of type `!` must have diverged.
260249 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) {
262251 // This expression produces a value of uninhabited type.
263252 // This means it has diverged somehow.
264253 self . diverges
@@ -3554,42 +3543,3 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
35543543 self . tcx . types . usize
35553544 }
35563545}
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