@@ -253,18 +253,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
253253 // diverging expression (e.g. it arose from desugaring of `try { return }`),
254254 // we skip issuing a warning because it is autogenerated code.
255255 ExprKind :: Call ( ..) if expr. span . is_desugaring ( DesugaringKind :: TryBlock ) => { }
256- ExprKind :: Call ( callee, _) => {
257- let emit_warning = if let ExprKind :: Path ( ref qpath) = callee. kind {
258- // Do not emit a warning for a call to a constructor.
259- let res = self . typeck_results . borrow ( ) . qpath_res ( qpath, callee. hir_id ) ;
260- !matches ! ( res, Res :: Def ( DefKind :: Ctor ( ..) , _) )
261- } else {
262- true
263- } ;
264- if emit_warning {
265- self . warn_if_unreachable ( expr. hir_id , callee. span , "call" )
266- }
267- }
256+ ExprKind :: Call ( callee, _) => self . warn_if_unreachable ( expr. hir_id , callee. span , "call" ) ,
268257 ExprKind :: MethodCall ( segment, ..) => {
269258 self . warn_if_unreachable ( expr. hir_id , segment. ident . span , "call" )
270259 }
@@ -281,7 +270,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
281270 if ty. is_never ( ) {
282271 // Any expression that produces a value of type `!` must have diverged.
283272 self . diverges . set ( Diverges :: Always ( DivergeReason :: Other , expr) ) ;
284- } else if expr_may_be_uninhabited ( expr ) && self . ty_is_uninhabited ( ty) {
273+ } else if self . ty_is_uninhabited ( ty) {
285274 // This expression produces a value of uninhabited type.
286275 // This means it has diverged somehow.
287276 self . diverges . set ( Diverges :: Always ( DivergeReason :: Uninhabited , expr) ) ;
@@ -3236,42 +3225,3 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
32363225 self . tcx . types . usize
32373226 }
32383227}
3239-
3240- fn expr_may_be_uninhabited ( expr : & hir:: Expr < ' _ > ) -> bool {
3241- match expr. kind {
3242- ExprKind :: Call ( ..)
3243- | ExprKind :: MethodCall ( ..)
3244- | ExprKind :: Cast ( ..)
3245- | ExprKind :: Unary ( hir:: UnOp :: Deref , _)
3246- | ExprKind :: Field ( ..)
3247- | ExprKind :: Path ( ..)
3248- | ExprKind :: Struct ( ..) => true ,
3249- ExprKind :: ConstBlock ( ..)
3250- | ExprKind :: Array ( ..)
3251- | ExprKind :: Tup ( ..)
3252- | ExprKind :: Binary ( ..)
3253- | ExprKind :: Unary ( hir:: UnOp :: Neg | hir:: UnOp :: Not , _)
3254- | ExprKind :: Lit ( ..)
3255- | ExprKind :: Type ( ..)
3256- | ExprKind :: DropTemps ( ..)
3257- | ExprKind :: OffsetOf ( ..)
3258- | ExprKind :: Let ( ..)
3259- | ExprKind :: If ( ..)
3260- | ExprKind :: Loop ( ..)
3261- | ExprKind :: Match ( ..)
3262- | ExprKind :: Closure ( ..)
3263- | ExprKind :: Block ( ..)
3264- | ExprKind :: Assign ( ..)
3265- | ExprKind :: AssignOp ( ..)
3266- | ExprKind :: Index ( ..)
3267- | ExprKind :: AddrOf ( ..)
3268- | ExprKind :: Break ( ..)
3269- | ExprKind :: Continue ( ..)
3270- | ExprKind :: Ret ( ..)
3271- | ExprKind :: Become ( ..)
3272- | ExprKind :: InlineAsm ( ..)
3273- | ExprKind :: Repeat ( ..)
3274- | ExprKind :: Yield ( ..)
3275- | ExprKind :: Err ( _) => false ,
3276- }
3277- }
0 commit comments