diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-08-17 11:13:45 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-08-17 11:13:45 +0200 |
| commit | a053baefebb56b59bd6c40a3ca0726efc18f4209 (patch) | |
| tree | 9e2ce2113c54731fea9051ebedf67d7647bba973 /src/librustc_codegen_utils | |
| parent | 5e597875b73e651c5dea200754489f426bc39596 (diff) | |
| parent | c1758d5918b8c5e99b34c83e83266dc5f79b0da7 (diff) | |
| download | rust-a053baefebb56b59bd6c40a3ca0726efc18f4209.tar.gz rust-a053baefebb56b59bd6c40a3ca0726efc18f4209.zip | |
Rollup merge of #63559 - eddyb:v0-mangling-off-by-1, r=estebank
rustc_codegen_utils: account for 1-indexed anonymous lifetimes in v0 mangling. I don't really understand why `anonymize_late_bound_regions` starts with `BrAnon(1)` instead of `BrAnon(0)`, but it does (maybe @nikomatsakis knows?): https://github.com/rust-lang/rust/blob/c43d03a19f326f4a323569328cc501e86eb6d22e/src/librustc/ty/fold.rs#L696-L712 Thankfully, the mangling format and demangler implementations are fine, and I just needed to offset the anonymized lifetime indices by `1` to get the correct mangling. cc @alexcrichton @michaelwoerister
Diffstat (limited to 'src/librustc_codegen_utils')
| -rw-r--r-- | src/librustc_codegen_utils/symbol_names/v0.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/librustc_codegen_utils/symbol_names/v0.rs b/src/librustc_codegen_utils/symbol_names/v0.rs index 47601da8b7b..8d6a1d757e0 100644 --- a/src/librustc_codegen_utils/symbol_names/v0.rs +++ b/src/librustc_codegen_utils/symbol_names/v0.rs @@ -198,10 +198,14 @@ impl SymbolMangler<'tcx> { let lifetimes = regions.into_iter().map(|br| { match br { - ty::BrAnon(i) => i + 1, + ty::BrAnon(i) => { + // FIXME(eddyb) for some reason, `anonymize_late_bound_regions` starts at `1`. + assert_ne!(i, 0); + i - 1 + }, _ => bug!("symbol_names: non-anonymized region `{:?}` in `{:?}`", br, value), } - }).max().unwrap_or(0); + }).max().map_or(0, |max| max + 1); self.push_opt_integer_62("G", lifetimes as u64); lifetime_depths.end += lifetimes; @@ -297,6 +301,10 @@ impl Printer<'tcx> for SymbolMangler<'tcx> { // Late-bound lifetimes use indices starting at 1, // see `BinderLevel` for more details. ty::ReLateBound(debruijn, ty::BrAnon(i)) => { + // FIXME(eddyb) for some reason, `anonymize_late_bound_regions` starts at `1`. + assert_ne!(i, 0); + let i = i - 1; + let binder = &self.binders[self.binders.len() - 1 - debruijn.index()]; let depth = binder.lifetime_depths.start + i; |
