Skip to content

Commit 2396c20

Browse files
spastorinocuviper
authored andcommitted
Extract orig_opt_local_def_id as a function
(cherry picked from commit fb54758)
1 parent 692bc5b commit 2396c20

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
@@ -499,6 +499,17 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
499499
start
500500
}
501501

502+
/// Given the id of some node in the AST, finds the `LocalDefId` associated with it by the name
503+
/// resolver (if any).
504+
fn orig_opt_local_def_id(&self, node: NodeId) -> Option<LocalDefId> {
505+
self.resolver.node_id_to_def_id.get(&node).map(|local_def_id| *local_def_id)
506+
}
507+
508+
fn orig_local_def_id(&self, node: NodeId) -> LocalDefId {
509+
self.orig_opt_local_def_id(node)
510+
.unwrap_or_else(|| panic!("no entry for node id: `{:?}`", node))
511+
}
512+
502513
/// Given the id of some node in the AST, finds the `LocalDefId` associated with it by the name
503514
/// resolver (if any), after applying any remapping from `get_remapped_def_id`.
504515
///
@@ -513,10 +524,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
513524
/// we would create an opaque type `type FooReturn<'a1> = impl Debug + 'a1`.
514525
/// When lowering the `Debug + 'a` bounds, we add a remapping to map `'a` to `'a1`.
515526
fn opt_local_def_id(&self, node: NodeId) -> Option<LocalDefId> {
516-
self.resolver
517-
.node_id_to_def_id
518-
.get(&node)
519-
.map(|local_def_id| self.get_remapped_def_id(*local_def_id))
527+
self.orig_opt_local_def_id(node).map(|local_def_id| self.get_remapped_def_id(local_def_id))
520528
}
521529

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

0 commit comments

Comments
 (0)