diff options
| author | Santiago Pastorino <spastorino@gmail.com> | 2022-08-03 17:32:24 -0300 |
|---|---|---|
| committer | Santiago Pastorino <spastorino@gmail.com> | 2022-08-04 11:26:59 -0300 |
| commit | 11e00f502aa87cef30b715bb68f03ab4ca3208a7 (patch) | |
| tree | 71cd8a8d90fc414052a892dcd72514986fa3a02d | |
| parent | c946cdceb4213485ebbe7ab8c61c1f9f6a52f535 (diff) | |
| download | rust-11e00f502aa87cef30b715bb68f03ab4ca3208a7.tar.gz rust-11e00f502aa87cef30b715bb68f03ab4ca3208a7.zip | |
Add comments on with_remapping
| -rw-r--r-- | compiler/rustc_ast_lowering/src/lib.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 0e701abd605..dc2d6d5883b 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -557,6 +557,16 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { debug_assert!(_old.is_none()) } + /// Installs the remapping `remap` in scope while `f` is being executed. + /// This causes references to the `LocalDefId` keys to be changed to + /// refer to the values instead. + /// + /// The remapping is used when one piece of AST expands to multiple + /// pieces of HIR. For example, the function `fn foo<'a>(...) -> impl Debug + 'a`, + /// expands to both a function definition (`foo`) and a TAIT for the return value, + /// both of which have a lifetime parameter `'a`. The remapping allows us to + /// rewrite the `'a` in the return value to refer to the + /// `'a` declared on the TAIT, instead of the function. fn with_remapping<R>( &mut self, remap: FxHashMap<LocalDefId, LocalDefId>, |
