X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustc%2Fcfg%2Fconstruct.rs;h=0464b2f3454d3a769212479805bcb3ecb4b6c74e;hb=62b359094f0dcebdb03e4bbc0e4934ce38d8623a;hp=1b97480920321d6fafad010285a19ff258e95394;hpb=3c7704367714a136ad40711b6d6b8f5691333f6b;p=rust.git diff --git a/src/librustc/cfg/construct.rs b/src/librustc/cfg/construct.rs index 1b974809203..0464b2f3454 100644 --- a/src/librustc/cfg/construct.rs +++ b/src/librustc/cfg/construct.rs @@ -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>(&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 @@ -556,7 +555,10 @@ fn add_exiting_edge(&mut self, target_scope: region::Scope, to_index: CFGIndex) { let mut data = CFGEdgeData { exiting_scopes: vec![] }; - let mut scope = region::Scope::Node(from_expr.hir_id.local_id); + let mut scope = region::Scope { + id: from_expr.hir_id.local_id, + data: region::ScopeData::Node + }; let region_scope_tree = self.tcx.region_scope_tree(self.owner_def_id); while scope != target_scope { data.exiting_scopes.push(scope.item_local_id()); @@ -585,18 +587,24 @@ 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 { - let scope_id = self.tcx.hir.node_to_hir_id(loop_id).local_id; - return (region::Scope::Node(scope_id), match scope_cf_kind { + 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, + data: region::ScopeData::Node + }; + return (scope, match scope_cf_kind { ScopeCfKind::Break => b.break_index, ScopeCfKind::Continue => bug!("can't continue to block"), }); } } for l in &self.loop_scopes { - if l.loop_id == self.tcx.hir.node_to_hir_id(loop_id).local_id { - let scope_id = self.tcx.hir.node_to_hir_id(loop_id).local_id; - return (region::Scope::Node(scope_id), match scope_cf_kind { + 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, + data: region::ScopeData::Node + }; + return (scope, match scope_cf_kind { ScopeCfKind::Break => l.break_index, ScopeCfKind::Continue => l.continue_index, });