]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/cfg/construct.rs
Check for uninhabitedness instead of never
[rust.git] / src / librustc / cfg / construct.rs
index 6b9c0aac52e79b370af16a0af500f90e56020828..0464b2f3454d3a769212479805bcb3ecb4b6c74e 100644 (file)
@@ -53,7 +53,7 @@ pub fn construct<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
     let body_exit;
 
     // Find the tables for this body.
-    let owner_def_id = tcx.hir.local_def_id(tcx.hir.body_owner(body.id()));
+    let owner_def_id = tcx.hir().local_def_id(tcx.hir().body_owner(body.id()));
     let tables = tcx.typeck_tables_of(owner_def_id);
 
     let mut cfg_builder = CFGBuilder {
@@ -109,7 +109,7 @@ fn block(&mut self, blk: &hir::Block, pred: CFGIndex) -> CFGIndex {
     }
 
     fn stmt(&mut self, stmt: &hir::Stmt, pred: CFGIndex) -> CFGIndex {
-        let hir_id = self.tcx.hir.node_to_hir_id(stmt.node.id());
+        let hir_id = self.tcx.hir().node_to_hir_id(stmt.node.id());
         match stmt.node {
             hir::StmtKind::Decl(ref decl, _) => {
                 let exit = self.decl(&decl, pred);
@@ -379,7 +379,7 @@ fn expr(&mut self, expr: &hir::Expr, pred: CFGIndex) -> CFGIndex {
             }
 
             hir::ExprKind::Index(ref l, ref r) |
-            hir::ExprKind::Binary(_, ref l, ref r) => { // NB: && and || handled earlier
+            hir::ExprKind::Binary(_, ref l, ref r) => { // N.B., && and || handled earlier
                 self.straightline(expr, pred, [l, r].iter().map(|&e| &**e))
             }
 
@@ -415,8 +415,7 @@ fn call<'b, I: Iterator<Item=&'b hir::Expr>>(&mut self,
             args: I) -> CFGIndex {
         let func_or_rcvr_exit = self.expr(func_or_rcvr, pred);
         let ret = self.straightline(call_expr, func_or_rcvr_exit, args);
-        // FIXME(canndrew): This is_never should probably be an is_uninhabited.
-        if self.tables.expr_ty(call_expr).is_never() {
+        if self.tables.expr_ty(call_expr).conservative_is_uninhabited() {
             self.add_unreachable_node()
         } else {
             ret
@@ -588,9 +587,9 @@ fn find_scope_edge(&self,
         match destination.target_id {
             Ok(loop_id) => {
                 for b in &self.breakable_block_scopes {
-                    if b.block_expr_id == self.tcx.hir.node_to_hir_id(loop_id).local_id {
+                    if b.block_expr_id == self.tcx.hir().node_to_hir_id(loop_id).local_id {
                         let scope = region::Scope {
-                            id: self.tcx.hir.node_to_hir_id(loop_id).local_id,
+                            id: self.tcx.hir().node_to_hir_id(loop_id).local_id,
                             data: region::ScopeData::Node
                         };
                         return (scope, match scope_cf_kind {
@@ -600,9 +599,9 @@ fn find_scope_edge(&self,
                     }
                 }
                 for l in &self.loop_scopes {
-                    if l.loop_id == self.tcx.hir.node_to_hir_id(loop_id).local_id {
+                    if l.loop_id == self.tcx.hir().node_to_hir_id(loop_id).local_id {
                         let scope = region::Scope {
-                            id: self.tcx.hir.node_to_hir_id(loop_id).local_id,
+                            id: self.tcx.hir().node_to_hir_id(loop_id).local_id,
                             data: region::ScopeData::Node
                         };
                         return (scope, match scope_cf_kind {