Skip to content

Commit 11e00f5

Browse files
committed
Add comments on with_remapping
1 parent c946cdc commit 11e00f5

File tree

1 file changed

+10
-0
lines changed
  • compiler/rustc_ast_lowering/src

1 file changed

+10
-0
lines changed

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,16 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
557557
debug_assert!(_old.is_none())
558558
}
559559

560+
/// Installs the remapping `remap` in scope while `f` is being executed.
561+
/// This causes references to the `LocalDefId` keys to be changed to
562+
/// refer to the values instead.
563+
///
564+
/// The remapping is used when one piece of AST expands to multiple
565+
/// pieces of HIR. For example, the function `fn foo<'a>(...) -> impl Debug + 'a`,
566+
/// expands to both a function definition (`foo`) and a TAIT for the return value,
567+
/// both of which have a lifetime parameter `'a`. The remapping allows us to
568+
/// rewrite the `'a` in the return value to refer to the
569+
/// `'a` declared on the TAIT, instead of the function.
560570
fn with_remapping<R>(
561571
&mut self,
562572
remap: FxHashMap<LocalDefId, LocalDefId>,

0 commit comments

Comments
 (0)