Skip to content

Commit 906cdbf

Browse files
simplify tracking and opt for build-pass testing
1 parent 4097274 commit 906cdbf

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

compiler/rustc_middle/src/middle/region.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,10 @@ impl ScopeTree {
368368
}
369369

370370
pub fn record_local_access_scope(&mut self, var: hir::ItemLocalId, proposed_lifetime: Scope) {
371-
debug!("record_local_access_scope(sub={:?}, sup={:?})", var, proposed_lifetime);
371+
debug!(
372+
"record_local_access_scope(var={:?}, proposed_lifetime={:?})",
373+
var, proposed_lifetime
374+
);
372375
let mut id = Scope { id: var, data: ScopeData::Node };
373376

374377
while let Some(&(p, _)) = self.parent_map.get(&id) {
@@ -385,6 +388,7 @@ impl ScopeTree {
385388
}
386389

387390
pub fn record_eager_scope(&mut self, var: hir::ItemLocalId, proposed_lifetime: Scope) {
391+
debug!("record_eager_scope(var={:?}, proposed_lifetime={:?})", var, proposed_lifetime);
388392
if let Some(destruction) = self.temporary_scope(var) {
389393
if self.is_subscope_of(destruction, proposed_lifetime) {
390394
// If the current temporary scope is already a subset of the proposed region,

compiler/rustc_passes/src/region.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ fn mark_local_terminating_scopes<'tcx>(expr: &'tcx hir::Expr<'tcx>) -> FxHashSet
219219
Ref,
220220
Deref,
221221
Project,
222-
Local,
223222
}
224223
// Here we are looking for a chain of access to extract a place reference for
225224
// a local variable.
@@ -233,7 +232,8 @@ fn mark_local_terminating_scopes<'tcx>(expr: &'tcx hir::Expr<'tcx>) -> FxHashSet
233232
_,
234233
hir::Path { res: hir::def::Res::Local(_), .. },
235234
)) => {
236-
ops.push((nested_expr, OpTy::Local));
235+
// We have reached the end of the access path
236+
// because a local variable access is encountered
237237
break;
238238
}
239239
hir::ExprKind::AddrOf(_, _, subexpr) => {
@@ -261,9 +261,7 @@ fn mark_local_terminating_scopes<'tcx>(expr: &'tcx hir::Expr<'tcx>) -> FxHashSet
261261
}
262262
}
263263
let mut ref_level = SmallVec::<[_; 4]>::new();
264-
let mut ops_iter = ops.into_iter().rev();
265-
ops_iter.next().unwrap();
266-
for (expr, op) in ops_iter {
264+
for (expr, op) in ops.into_iter().rev() {
267265
match op {
268266
OpTy::Ref => {
269267
ref_level.push(expr);
@@ -279,9 +277,6 @@ fn mark_local_terminating_scopes<'tcx>(expr: &'tcx hir::Expr<'tcx>) -> FxHashSet
279277
// These temporaries must stay alive even after the field access.
280278
ref_level.clear();
281279
}
282-
OpTy::Local => {
283-
panic!("unexpected encounter of Local")
284-
}
285280
}
286281
}
287282
self.locals.insert(expr.hir_id.local_id);

src/test/ui/async-await/issue-69663-lingering-local-borrows.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// edition:2018
2-
// run-pass
2+
// build-pass
33

44
use std::ops::Index;
55

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// edition:2018
2-
// run-pass
2+
// build-pass
33
#![feature(generators, generator_trait, negative_impls)]
44

55
fn assert_send<T: Send>(_: T) {}

0 commit comments

Comments
 (0)