Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustc_codegen_utils: account for 1-indexed anonymous lifetimes in v0 mangling. #63559

Merged
merged 1 commit into from
Aug 17, 2019

Conversation

eddyb
Copy link
Member

@eddyb eddyb commented Aug 14, 2019

I don't really understand why anonymize_late_bound_regions starts with BrAnon(1) instead of BrAnon(0), but it does (maybe @nikomatsakis knows?):

/// Rewrite any late-bound regions so that they are anonymous. Region numbers are
/// assigned starting at 1 and increasing monotonically in the order traversed
/// by the fold operation.
///
/// The chief purpose of this function is to canonicalize regions so that two
/// `FnSig`s or `TraitRef`s which are equivalent up to region naming will become
/// structurally identical. For example, `for<'a, 'b> fn(&'a isize, &'b isize)` and
/// `for<'a, 'b> fn(&'b isize, &'a isize)` will become identical after anonymization.
pub fn anonymize_late_bound_regions<T>(self, sig: &Binder<T>) -> Binder<T>
where T : TypeFoldable<'tcx>,
{
let mut counter = 0;
Binder::bind(self.replace_late_bound_regions(sig, |_| {
counter += 1;
self.mk_region(ty::ReLateBound(ty::INNERMOST, ty::BrAnon(counter)))
}).0)
}

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

@rust-highfive
Copy link
Collaborator

r? @estebank

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 14, 2019
@estebank
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Aug 14, 2019

📌 Commit c1758d5 has been approved by estebank

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 14, 2019
Centril added a commit to Centril/rust that referenced this pull request Aug 15, 2019
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
Centril added a commit to Centril/rust that referenced this pull request Aug 15, 2019
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
Centril added a commit to Centril/rust that referenced this pull request Aug 15, 2019
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
@Centril
Copy link
Contributor

Centril commented Aug 16, 2019

@bors p=1

Centril added a commit to Centril/rust that referenced this pull request Aug 17, 2019
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
Centril added a commit to Centril/rust that referenced this pull request Aug 17, 2019
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
bors added a commit that referenced this pull request Aug 17, 2019
Rollup of 4 pull requests

Successful merges:

 - #62737 (Override Cycle::try_fold)
 - #63505 (Hash the remapped sysroot instead of the original.)
 - #63559 (rustc_codegen_utils: account for 1-indexed anonymous lifetimes in v0 mangling.)
 - #63621 (Modify librustc_llvm to pass -DNDEBUG while compiling.)

Failed merges:

r? @ghost
@bors bors merged commit c1758d5 into rust-lang:master Aug 17, 2019
@eddyb eddyb deleted the v0-mangling-off-by-1 branch August 18, 2019 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants