@@ -977,62 +977,13 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
977977 }
978978
979979 hir:: ExprKind :: Call ( ref f, ref args) => {
980- let m = self . ir . tcx . parent_module ( expr. hir_id ) . to_def_id ( ) ;
981- let ty = self . typeck_results . expr_ty ( expr) ;
982- let succ = if self . ir . tcx . is_ty_uninhabited_from ( m, ty, self . param_env ) {
983- if let LiveNodeKind :: ExprNode ( succ_span, succ_id) = self . ir . lnks [ succ] {
984- self . warn_about_unreachable (
985- expr. span ,
986- ty,
987- succ_span,
988- succ_id,
989- "expression" ,
990- ) ;
991- } else if let LiveNodeKind :: VarDefNode ( succ_span, succ_id) = self . ir . lnks [ succ]
992- {
993- self . warn_about_unreachable (
994- expr. span ,
995- ty,
996- succ_span,
997- succ_id,
998- "definition" ,
999- ) ;
1000- }
1001- self . exit_ln
1002- } else {
1003- succ
1004- } ;
980+ let succ = self . check_is_ty_uninhabited ( expr, succ) ;
1005981 let succ = self . propagate_through_exprs ( args, succ) ;
1006982 self . propagate_through_expr ( & f, succ)
1007983 }
1008984
1009985 hir:: ExprKind :: MethodCall ( .., ref args, _) => {
1010- let m = self . ir . tcx . parent_module ( expr. hir_id ) . to_def_id ( ) ;
1011- let ty = self . typeck_results . expr_ty ( expr) ;
1012- let succ = if self . ir . tcx . is_ty_uninhabited_from ( m, ty, self . param_env ) {
1013- if let LiveNodeKind :: ExprNode ( succ_span, succ_id) = self . ir . lnks [ succ] {
1014- self . warn_about_unreachable (
1015- expr. span ,
1016- ty,
1017- succ_span,
1018- succ_id,
1019- "expression" ,
1020- ) ;
1021- } else if let LiveNodeKind :: VarDefNode ( succ_span, succ_id) = self . ir . lnks [ succ]
1022- {
1023- self . warn_about_unreachable (
1024- expr. span ,
1025- ty,
1026- succ_span,
1027- succ_id,
1028- "definition" ,
1029- ) ;
1030- }
1031- self . exit_ln
1032- } else {
1033- succ
1034- } ;
1035-
986+ let succ = self . check_is_ty_uninhabited ( expr, succ) ;
1036987 self . propagate_through_exprs ( args, succ)
1037988 }
1038989
@@ -1305,6 +1256,25 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
13051256 ln
13061257 }
13071258
1259+ fn check_is_ty_uninhabited ( & mut self , expr : & Expr < ' _ > , succ : LiveNode ) -> LiveNode {
1260+ let ty = self . typeck_results . expr_ty ( expr) ;
1261+ let m = self . ir . tcx . parent_module ( expr. hir_id ) . to_def_id ( ) ;
1262+ if self . ir . tcx . is_ty_uninhabited_from ( m, ty, self . param_env ) {
1263+ match self . ir . lnks [ succ] {
1264+ LiveNodeKind :: ExprNode ( succ_span, succ_id) => {
1265+ self . warn_about_unreachable ( expr. span , ty, succ_span, succ_id, "expression" ) ;
1266+ }
1267+ LiveNodeKind :: VarDefNode ( succ_span, succ_id) => {
1268+ self . warn_about_unreachable ( expr. span , ty, succ_span, succ_id, "definition" ) ;
1269+ }
1270+ _ => { }
1271+ } ;
1272+ self . exit_ln
1273+ } else {
1274+ succ
1275+ }
1276+ }
1277+
13081278 fn warn_about_unreachable (
13091279 & mut self ,
13101280 orig_span : Span ,
0 commit comments