Skip to content

Commit

Permalink
stop descending to avoid duplicated effort
Browse files Browse the repository at this point in the history
  • Loading branch information
dingxiangfei2009 committed Feb 12, 2022
1 parent 906cdbf commit 7cad314
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
11 changes: 4 additions & 7 deletions compiler/rustc_passes/src/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,10 @@ fn mark_local_terminating_scopes<'tcx>(expr: &'tcx hir::Expr<'tcx>) -> FxHashSet
ops.push((nested_expr, OpTy::Deref));
nested_expr = subexpr;
}
hir::ExprKind::Field(subexpr, _) => {
hir::ExprKind::Field(subexpr, _) | hir::ExprKind::Index(subexpr, _) => {
ops.push((nested_expr, OpTy::Project));
nested_expr = subexpr;
}
hir::ExprKind::Index(subexpr, idxexpr) => {
ops.push((nested_expr, OpTy::Project));
nested_expr = subexpr;
intravisit::walk_expr(self, idxexpr);
}
_ => {
drop(ops);
intravisit::walk_expr(self, expr);
Expand Down Expand Up @@ -296,7 +291,9 @@ fn mark_local_terminating_scopes<'tcx>(expr: &'tcx hir::Expr<'tcx>) -> FxHashSet
| hir::ExprKind::Path(..) => self.probe(expr),

// We do not probe into other function bodies or blocks.
hir::ExprKind::Block(..)
hir::ExprKind::If(..)
| hir::ExprKind::Match(..)
| hir::ExprKind::Block(..)
| hir::ExprKind::Closure(..)
| hir::ExprKind::ConstBlock(..) => {}
_ => intravisit::walk_expr(self, expr),
Expand Down
8 changes: 8 additions & 0 deletions src/test/ui/generator/refined-region-for-local-accesses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ fn assert_send<T: Send>(_: T) {}
struct Client;

impl Client {
fn zero(&self) -> usize {
0
}

fn status(&self) -> i16 {
200
}
Expand All @@ -27,6 +31,10 @@ fn main() {
match (&*&x).status() {
_ => yield,
}
let a = [0];
match a[Client.zero()] {
_ => yield,
}
};
assert_send(g);
}

0 comments on commit 7cad314

Please sign in to comment.