Skip to content

Commit d18e606

Browse files
committed
Move label res map into per-owner tables
1 parent 319f91a commit d18e606

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

compiler/rustc_ast_lowering/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ impl PerOwnerResolver<'_> {
256256

257257
/// Obtains resolution for a label with the given `NodeId`.
258258
fn get_label_res(&self, id: NodeId) -> Option<NodeId> {
259-
self.general.label_res_map.get(&id).copied()
259+
self.item.label_res_map.get(&id).copied()
260260
}
261261

262262
/// Obtains resolution for a lifetime with the given `NodeId`.

compiler/rustc_middle/src/ty/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ pub struct ResolverGlobalCtxt {
191191
pub struct PerOwnerResolverData {
192192
pub legacy_const_generic_args: FxHashMap<DefId, Option<Vec<usize>>>,
193193
pub node_id_to_def_id: NodeMap<LocalDefId>,
194+
/// Resolutions for labels (node IDs of their corresponding blocks or loops).
195+
pub label_res_map: NodeMap<ast::NodeId>,
194196
/// The id of the owner
195197
pub id: ast::NodeId,
196198
}
@@ -199,6 +201,7 @@ impl PerOwnerResolverData {
199201
pub fn new(id: ast::NodeId) -> Self {
200202
Self {
201203
node_id_to_def_id: Default::default(),
204+
label_res_map: Default::default(),
202205
legacy_const_generic_args: Default::default(),
203206
id,
204207
}
@@ -213,8 +216,6 @@ pub struct ResolverAstLowering {
213216
pub partial_res_map: NodeMap<hir::def::PartialRes>,
214217
/// Resolutions for import nodes, which have multiple resolutions in different namespaces.
215218
pub import_res_map: NodeMap<hir::def::PerNS<Option<Res<ast::NodeId>>>>,
216-
/// Resolutions for labels (node IDs of their corresponding blocks or loops).
217-
pub label_res_map: NodeMap<ast::NodeId>,
218219
/// Resolutions for lifetimes.
219220
pub lifetimes_res_map: NodeMap<LifetimeRes>,
220221
/// Lifetime parameters that lowering will have to introduce.

compiler/rustc_resolve/src/lib.rs

-4
Original file line numberDiff line numberDiff line change
@@ -1073,8 +1073,6 @@ pub struct Resolver<'ra, 'tcx> {
10731073
import_res_map: NodeMap<PerNS<Option<Res>>>,
10741074
/// An import will be inserted into this map if it has been used.
10751075
import_use_map: FxHashMap<Import<'ra>, Used>,
1076-
/// Resolutions for labels (node IDs of their corresponding blocks or loops).
1077-
label_res_map: NodeMap<NodeId>,
10781076
/// Resolutions for lifetimes.
10791077
lifetimes_res_map: NodeMap<LifetimeRes>,
10801078
/// Lifetime parameters that lowering will have to introduce.
@@ -1499,7 +1497,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
14991497
partial_res_map: Default::default(),
15001498
import_res_map: Default::default(),
15011499
import_use_map: Default::default(),
1502-
label_res_map: Default::default(),
15031500
lifetimes_res_map: Default::default(),
15041501
extra_lifetime_params_map: Default::default(),
15051502
extern_crate_map: Default::default(),
@@ -1705,7 +1702,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
17051702
owners: self.owners,
17061703
partial_res_map: self.partial_res_map,
17071704
import_res_map: self.import_res_map,
1708-
label_res_map: self.label_res_map,
17091705
lifetimes_res_map: self.lifetimes_res_map,
17101706
extra_lifetime_params_map: self.extra_lifetime_params_map,
17111707
next_node_id: self.next_node_id,

compiler/rustc_resolve/src/macros.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -518,10 +518,15 @@ impl<'ra, 'tcx> ResolverExpand for Resolver<'ra, 'tcx> {
518518
let old_id = old.id;
519519
if old.id == DUMMY_NODE_ID {
520520
if cfg!(debug_assertions) {
521-
let PerOwnerResolverData { node_id_to_def_id, id: _, legacy_const_generic_args } =
522-
old;
521+
let PerOwnerResolverData {
522+
node_id_to_def_id,
523+
id: _,
524+
legacy_const_generic_args,
525+
label_res_map,
526+
} = old;
523527
assert!(node_id_to_def_id.is_empty());
524528
assert!(legacy_const_generic_args.is_empty());
529+
assert!(label_res_map.is_empty());
525530
}
526531
} else {
527532
assert!(self.owners.insert(old.id, old).is_none());

0 commit comments

Comments
 (0)