Skip to content

Commit fb54758

Browse files
committed
Extract orig_opt_local_def_id as a function
1 parent 4b8f431 commit fb54758

File tree

1 file changed

+12
-4
lines changed
  • compiler/rustc_ast_lowering/src

1 file changed

+12
-4
lines changed

compiler/rustc_ast_lowering/src/lib.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,17 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
506506
start
507507
}
508508

509+
/// Given the id of some node in the AST, finds the `LocalDefId` associated with it by the name
510+
/// resolver (if any).
511+
fn orig_opt_local_def_id(&self, node: NodeId) -> Option<LocalDefId> {
512+
self.resolver.node_id_to_def_id.get(&node).map(|local_def_id| *local_def_id)
513+
}
514+
515+
fn orig_local_def_id(&self, node: NodeId) -> LocalDefId {
516+
self.orig_opt_local_def_id(node)
517+
.unwrap_or_else(|| panic!("no entry for node id: `{:?}`", node))
518+
}
519+
509520
/// Given the id of some node in the AST, finds the `LocalDefId` associated with it by the name
510521
/// resolver (if any), after applying any remapping from `get_remapped_def_id`.
511522
///
@@ -520,10 +531,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
520531
/// we would create an opaque type `type FooReturn<'a1> = impl Debug + 'a1`.
521532
/// When lowering the `Debug + 'a` bounds, we add a remapping to map `'a` to `'a1`.
522533
fn opt_local_def_id(&self, node: NodeId) -> Option<LocalDefId> {
523-
self.resolver
524-
.node_id_to_def_id
525-
.get(&node)
526-
.map(|local_def_id| self.get_remapped_def_id(*local_def_id))
534+
self.orig_opt_local_def_id(node).map(|local_def_id| self.get_remapped_def_id(local_def_id))
527535
}
528536

529537
fn local_def_id(&self, node: NodeId) -> LocalDefId {

0 commit comments

Comments
 (0)