Skip to content

Commit 7cad314

Browse files
stop descending to avoid duplicated effort
1 parent 906cdbf commit 7cad314

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

compiler/rustc_passes/src/region.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -244,15 +244,10 @@ fn mark_local_terminating_scopes<'tcx>(expr: &'tcx hir::Expr<'tcx>) -> FxHashSet
244244
ops.push((nested_expr, OpTy::Deref));
245245
nested_expr = subexpr;
246246
}
247-
hir::ExprKind::Field(subexpr, _) => {
247+
hir::ExprKind::Field(subexpr, _) | hir::ExprKind::Index(subexpr, _) => {
248248
ops.push((nested_expr, OpTy::Project));
249249
nested_expr = subexpr;
250250
}
251-
hir::ExprKind::Index(subexpr, idxexpr) => {
252-
ops.push((nested_expr, OpTy::Project));
253-
nested_expr = subexpr;
254-
intravisit::walk_expr(self, idxexpr);
255-
}
256251
_ => {
257252
drop(ops);
258253
intravisit::walk_expr(self, expr);
@@ -296,7 +291,9 @@ fn mark_local_terminating_scopes<'tcx>(expr: &'tcx hir::Expr<'tcx>) -> FxHashSet
296291
| hir::ExprKind::Path(..) => self.probe(expr),
297292

298293
// We do not probe into other function bodies or blocks.
299-
hir::ExprKind::Block(..)
294+
hir::ExprKind::If(..)
295+
| hir::ExprKind::Match(..)
296+
| hir::ExprKind::Block(..)
300297
| hir::ExprKind::Closure(..)
301298
| hir::ExprKind::ConstBlock(..) => {}
302299
_ => intravisit::walk_expr(self, expr),

src/test/ui/generator/refined-region-for-local-accesses.rs

+8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ fn assert_send<T: Send>(_: T) {}
77
struct Client;
88

99
impl Client {
10+
fn zero(&self) -> usize {
11+
0
12+
}
13+
1014
fn status(&self) -> i16 {
1115
200
1216
}
@@ -27,6 +31,10 @@ fn main() {
2731
match (&*&x).status() {
2832
_ => yield,
2933
}
34+
let a = [0];
35+
match a[Client.zero()] {
36+
_ => yield,
37+
}
3038
};
3139
assert_send(g);
3240
}

0 commit comments

Comments
 (0)