Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d4a5588

Browse files
authoredMay 15, 2019
Rollup merge of rust-lang#60174 - matthewjasper:add-match-arm-scopes, r=pnkfelix
Add match arm scopes and other scope fixes * Add drop and lint scopes for match arms. * Lint attributes are now respected on match arms. * Make sure we emit a StorageDead if we diverge when initializing a temporary. * Adjust MIR pretty printing of scopes for locals. * Don't generate duplicate lint scopes for `let statements`. * Add some previously missing fake borrows for matches. closes rust-lang#46525 cc @rust-lang/compiler
2 parents e7dd3eb + 5b5255d commit d4a5588

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+726
-276
lines changed
 

‎src/librustc/cfg/construct.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
419419
for arm in arms {
420420
// Add an exit node for when we've visited all the
421421
// patterns and the guard (if there is one) in the arm.
422-
let arm_exit = self.add_dummy_node(&[]);
422+
let bindings_exit = self.add_dummy_node(&[]);
423423

424424
for pat in &arm.pats {
425425
// Visit the pattern, coming from the discriminant exit
@@ -453,14 +453,16 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
453453

454454
// Add an edge from the exit of this pattern to the
455455
// exit of the arm
456-
self.add_contained_edge(pat_exit, arm_exit);
456+
self.add_contained_edge(pat_exit, bindings_exit);
457457
}
458458

459459
// Visit the body of this arm
460-
let body_exit = self.expr(&arm.body, arm_exit);
460+
let body_exit = self.expr(&arm.body, bindings_exit);
461+
462+
let arm_exit = self.add_ast_node(arm.hir_id.local_id, &[body_exit]);
461463

462464
// Link the body to the exit of the expression
463-
self.add_contained_edge(body_exit, expr_exit);
465+
self.add_contained_edge(arm_exit, expr_exit);
464466
}
465467

466468
expr_exit

‎src/librustc/hir/intravisit.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,7 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) {
11021102
}
11031103

11041104
pub fn walk_arm<'v, V: Visitor<'v>>(visitor: &mut V, arm: &'v Arm) {
1105+
visitor.visit_id(arm.hir_id);
11051106
walk_list!(visitor, visit_pat, &arm.pats);
11061107
if let Some(ref g) = arm.guard {
11071108
match g {

0 commit comments

Comments
 (0)
Please sign in to comment.