-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Fix indeterminism in ty::TraitObject representation. #36425
Fix indeterminism in ty::TraitObject representation. #36425
Conversation
r? @nrc (rust_highfive has picked a reviewer for you, use r? to override) |
@@ -1303,7 +1303,11 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { | |||
} | |||
|
|||
pub fn mk_trait(self, mut obj: TraitObject<'tcx>) -> Ty<'tcx> { | |||
obj.projection_bounds.sort_by(|a, b| a.sort_key().cmp(&b.sort_key())); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extra whitespace
@michaelwoerister I believe the extra logic in |
Thanks for the investigation and fix @michaelwoerister! |
Yes. |
03cee05
to
338943a
Compare
@michaelwoerister It might be a good idea at this point to fix |
@eddyb Can't we just do exactly the same as we do when computing the symbol hash? That seems to work pretty well, so far. I'll look into it tomorrow. |
@michaelwoerister The symbol hash is a gross hack that dumps type metadata into strings and hashes that with sha2. The new The immediate result of this PR is that the sorting of trait object projections is no longer necessary, and since I believe that all TyTrait(ref data) => {
self.def_id(data.principal.def_id());
self.hash(data.builtin_bounds);
} |
I don't think it's 'gross' Sha2 is not necessary, probably, but how is it more thorough? On 12.09.2016 19:22, Eduard-Mihai Burtescu wrote:
|
@michaelwoerister I only meant that the new |
…ay that is stable across compilation sessions and crate boundaries.
@@ -453,17 +453,6 @@ impl<'a, 'gcx, 'tcx> TypeVisitor<'tcx> for TypeIdHasher<'a, 'gcx, 'tcx> { | |||
// Hash region and builtin bounds. | |||
data.region_bound.visit_with(self); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and data.principal.visit_with(self);
above it are unnecessary because automatic recursion will hit them anyway.
5009d71
to
377c3e1
Compare
r? @eddyb |
@bors r+ |
📌 Commit 7ec9b81 has been approved by |
⌛ Testing commit 7ec9b81 with merge fdb4f63... |
💔 Test failed - auto-win-msvc-64-opt-rustbuild |
@bors: retry On Tue, Sep 13, 2016 at 7:33 PM, bors notifications@github.com wrote:
|
…bounds, r=eddyb Fix indeterminism in ty::TraitObject representation. Make sure that projection bounds in `ty::TraitObject` are sorted in a way that is stable across compilation sessions and crate boundaries. This PR + moves `DefPathHashes` up into `librustc` so it can be used there to create a stable sort key for `DefId`s, + changes `PolyExistentialProjection::sort_key()` to take advantage of the above, + and removes the unused `PolyProjectionPredicate::sort_key()` and `ProjectionTy::sort_key()` methods. Fixes rust-lang#36155
Make sure that projection bounds in
ty::TraitObject
are sorted in a way that is stable across compilation sessions and crate boundaries.This PR
DefPathHashes
up intolibrustc
so it can be used there to create a stable sort key forDefId
s,PolyExistentialProjection::sort_key()
to take advantage of the above,PolyProjectionPredicate::sort_key()
andProjectionTy::sort_key()
methods.Fixes #36155