@@ -244,18 +244,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
244244 // diverging expression (e.g. it arose from desugaring of `try { return }`),
245245 // we skip issuing a warning because it is autogenerated code.
246246 ExprKind :: Call ( ..) if expr. span . is_desugaring ( DesugaringKind :: TryBlock ) => { }
247- ExprKind :: Call ( callee, _) => {
248- let emit_warning = if let ExprKind :: Path ( ref qpath) = callee. kind {
249- // Do not emit a warning for a call to a constructor.
250- let res = self . typeck_results . borrow ( ) . qpath_res ( qpath, callee. hir_id ) ;
251- !matches ! ( res, Res :: Def ( DefKind :: Ctor ( ..) , _) )
252- } else {
253- true
254- } ;
255- if emit_warning {
256- self . warn_if_unreachable ( expr. hir_id , callee. span , "call" )
257- }
258- }
247+ ExprKind :: Call ( callee, _) => self . warn_if_unreachable ( expr. hir_id , callee. span , "call" ) ,
259248 ExprKind :: MethodCall ( segment, ..) => {
260249 self . warn_if_unreachable ( expr. hir_id , segment. ident . span , "call" )
261250 }
@@ -272,7 +261,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
272261 if ty. is_never ( ) {
273262 // Any expression that produces a value of type `!` must have diverged.
274263 self . diverges . set ( Diverges :: Always ( DivergeReason :: Other , expr. span ) ) ;
275- } else if expr_may_be_uninhabited ( expr ) && self . ty_is_uninhabited ( ty) {
264+ } else if self . ty_is_uninhabited ( ty) {
276265 // This expression produces a value of uninhabited type.
277266 // This means it has diverged somehow.
278267 self . diverges
@@ -3481,42 +3470,3 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
34813470 self . tcx . types . usize
34823471 }
34833472}
3484-
3485- fn expr_may_be_uninhabited ( expr : & hir:: Expr < ' _ > ) -> bool {
3486- match expr. kind {
3487- ExprKind :: Call ( ..)
3488- | ExprKind :: MethodCall ( ..)
3489- | ExprKind :: Cast ( ..)
3490- | ExprKind :: Unary ( hir:: UnOp :: Deref , _)
3491- | ExprKind :: Field ( ..)
3492- | ExprKind :: Path ( ..)
3493- | ExprKind :: Struct ( ..) => true ,
3494- ExprKind :: ConstBlock ( ..)
3495- | ExprKind :: Array ( ..)
3496- | ExprKind :: Tup ( ..)
3497- | ExprKind :: Binary ( ..)
3498- | ExprKind :: Unary ( hir:: UnOp :: Neg | hir:: UnOp :: Not , _)
3499- | ExprKind :: Lit ( ..)
3500- | ExprKind :: Type ( ..)
3501- | ExprKind :: DropTemps ( ..)
3502- | ExprKind :: OffsetOf ( ..)
3503- | ExprKind :: Let ( ..)
3504- | ExprKind :: If ( ..)
3505- | ExprKind :: Loop ( ..)
3506- | ExprKind :: Match ( ..)
3507- | ExprKind :: Closure ( ..)
3508- | ExprKind :: Block ( ..)
3509- | ExprKind :: Assign ( ..)
3510- | ExprKind :: AssignOp ( ..)
3511- | ExprKind :: Index ( ..)
3512- | ExprKind :: AddrOf ( ..)
3513- | ExprKind :: Break ( ..)
3514- | ExprKind :: Continue ( ..)
3515- | ExprKind :: Ret ( ..)
3516- | ExprKind :: Become ( ..)
3517- | ExprKind :: InlineAsm ( ..)
3518- | ExprKind :: Repeat ( ..)
3519- | ExprKind :: Yield ( ..)
3520- | ExprKind :: Err ( _) => false ,
3521- }
3522- }
0 commit comments