Skip to content

Commit 0210f83

Browse files
authored
Rollup merge of rust-lang#84343 - camsteffen:closure-tree, r=varkor
Remove `ScopeTree::closure_tree` Seems to be dead code since rust-lang#50649.
2 parents f82badd + c9c14d0 commit 0210f83

File tree

3 files changed

+2
-47
lines changed

3 files changed

+2
-47
lines changed

compiler/rustc_middle/src/middle/region.rs

-31
Original file line numberDiff line numberDiff line change
@@ -235,18 +235,6 @@ pub struct ScopeTree {
235235
/// escape into 'static and should have no local cleanup scope.
236236
rvalue_scopes: FxHashMap<hir::ItemLocalId, Option<Scope>>,
237237

238-
/// Encodes the hierarchy of fn bodies. Every fn body (including
239-
/// closures) forms its own distinct region hierarchy, rooted in
240-
/// the block that is the fn body. This map points from the ID of
241-
/// that root block to the ID of the root block for the enclosing
242-
/// fn, if any. Thus the map structures the fn bodies into a
243-
/// hierarchy based on their lexical mapping. This is used to
244-
/// handle the relationships between regions in a fn and in a
245-
/// closure defined by that fn. See the "Modeling closures"
246-
/// section of the README in infer::region_constraints for
247-
/// more details.
248-
closure_tree: FxHashMap<hir::ItemLocalId, hir::ItemLocalId>,
249-
250238
/// If there are any `yield` nested within a scope, this map
251239
/// stores the `Span` of the last one and its index in the
252240
/// postorder of the Visitor traversal on the HIR.
@@ -356,23 +344,6 @@ impl ScopeTree {
356344
self.destruction_scopes.get(&n).cloned()
357345
}
358346

359-
/// Records that `sub_closure` is defined within `sup_closure`. These IDs
360-
/// should be the ID of the block that is the fn body, which is
361-
/// also the root of the region hierarchy for that fn.
362-
pub fn record_closure_parent(
363-
&mut self,
364-
sub_closure: hir::ItemLocalId,
365-
sup_closure: hir::ItemLocalId,
366-
) {
367-
debug!(
368-
"record_closure_parent(sub_closure={:?}, sup_closure={:?})",
369-
sub_closure, sup_closure
370-
);
371-
assert!(sub_closure != sup_closure);
372-
let previous = self.closure_tree.insert(sub_closure, sup_closure);
373-
assert!(previous.is_none());
374-
}
375-
376347
pub fn record_var_scope(&mut self, var: hir::ItemLocalId, lifetime: Scope) {
377348
debug!("record_var_scope(sub={:?}, sup={:?})", var, lifetime);
378349
assert!(var != lifetime.item_local_id());
@@ -474,7 +445,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for ScopeTree {
474445
ref var_map,
475446
ref destruction_scopes,
476447
ref rvalue_scopes,
477-
ref closure_tree,
478448
ref yield_in_scope,
479449
} = *self;
480450

@@ -488,7 +458,6 @@ impl<'a> HashStable<StableHashingContext<'a>> for ScopeTree {
488458
var_map.hash_stable(hcx, hasher);
489459
destruction_scopes.hash_stable(hcx, hasher);
490460
rvalue_scopes.hash_stable(hcx, hasher);
491-
closure_tree.hash_stable(hcx, hasher);
492461
yield_in_scope.hash_stable(hcx, hasher);
493462
}
494463
}

compiler/rustc_passes/src/region.rs

+1-14
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,6 @@ use std::mem;
2323

2424
#[derive(Debug, Copy, Clone)]
2525
pub struct Context {
26-
/// The root of the current region tree. This is typically the id
27-
/// of the innermost fn body. Each fn forms its own disjoint tree
28-
/// in the region hierarchy. These fn bodies are themselves
29-
/// arranged into a tree. See the "Modeling closures" section of
30-
/// the README in `rustc_trait_selection::infer::region_constraints`
31-
/// for more details.
32-
root_id: Option<hir::ItemLocalId>,
33-
3426
/// The scope that contains any new variables declared, plus its depth in
3527
/// the scope tree.
3628
var_parent: Option<(Scope, ScopeDepth)>,
@@ -743,11 +735,6 @@ impl<'tcx> Visitor<'tcx> for RegionResolutionVisitor<'tcx> {
743735
let outer_pessimistic_yield = mem::replace(&mut self.pessimistic_yield, false);
744736
self.terminating_scopes.insert(body.value.hir_id.local_id);
745737

746-
if let Some(root_id) = self.cx.root_id {
747-
self.scope_tree.record_closure_parent(body.value.hir_id.local_id, root_id);
748-
}
749-
self.cx.root_id = Some(body.value.hir_id.local_id);
750-
751738
self.enter_scope(Scope { id: body.value.hir_id.local_id, data: ScopeData::CallSite });
752739
self.enter_scope(Scope { id: body.value.hir_id.local_id, data: ScopeData::Arguments });
753740

@@ -824,7 +811,7 @@ fn region_scope_tree(tcx: TyCtxt<'_>, def_id: DefId) -> &ScopeTree {
824811
tcx,
825812
scope_tree: ScopeTree::default(),
826813
expr_and_pat_count: 0,
827-
cx: Context { root_id: None, parent: None, var_parent: None },
814+
cx: Context { parent: None, var_parent: None },
828815
terminating_scopes: Default::default(),
829816
pessimistic_yield: false,
830817
fixup_scopes: vec![],

compiler/rustc_trait_selection/src/traits/object_safety.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,7 @@ fn virtual_call_violation_for_method<'tcx>(
439439
return Some(MethodViolationCode::WhereClauseReferencesSelf);
440440
}
441441

442-
let receiver_ty =
443-
tcx.liberate_late_bound_regions(method.def_id, sig.map_bound(|sig| sig.inputs()[0]));
442+
let receiver_ty = tcx.liberate_late_bound_regions(method.def_id, sig.input(0));
444443

445444
// Until `unsized_locals` is fully implemented, `self: Self` can't be dispatched on.
446445
// However, this is already considered object-safe. We allow it as a special case here.

0 commit comments

Comments
 (0)