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

Ignore auto traits order #531

Merged
merged 4 commits into from
Jun 17, 2020

Conversation

zaharidichev
Copy link
Contributor

This PR aims to fix #510 by sorting the auto traits defs durgin lowering

Signed-off-by: Zahari Dichev <zaharidichev@gmail.com>
Signed-off-by: Zahari Dichev <zaharidichev@gmail.com>
@zaharidichev zaharidichev requested a review from basil-cow June 17, 2020 13:37
Copy link
Member

@jackh726 jackh726 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, this is purely a chalk-integration fix? I'm not sure it I would prefer a fix that guarantees the order from chalk-solve. Did you take a look at how rustc does it? Does it sort traits during lowering or during trait solving? The difference is crucial.

Either way, I don't think it really makes sense to differentiate between auto and regular traits. Just sort them all. (We do have the condition some that there can only be one regular trait right? That's also crucial.)

// Different order of traits in target and source
// FIXME: this doesn't work because trait object unification
// respects where clause order, which it shouldn't
// Different order of traits in target and sourcex
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I didn't mention it, but I think there is maybe a similar comment elsewhere in the file, the other test you edited...?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it just says, "See above", which I think is still relevant, no ?

@zaharidichev
Copy link
Contributor Author

@jackh726 Rustc does it during ast conversion right here. I assumed this would be the equivalent of it. Does that make sense?

Signed-off-by: Zahari Dichev <zaharidichev@gmail.com>
@zaharidichev zaharidichev force-pushed the zd/ignore-auto-traits-order branch from 3e229c1 to ea8f2fa Compare June 17, 2020 14:42
Copy link
Member

@jackh726 jackh726 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If rustc does this during ast lowering, then this is fine. Remove the printlns and this LGTM. @zaharidichev feel free to merge when those changes are made

chalk-integration/src/lowering.rs Outdated Show resolved Hide resolved
chalk-integration/src/lowering.rs Outdated Show resolved Hide resolved
@basil-cow
Copy link
Contributor

I think we should maybe add some tests for trait object unification?

@jackh726
Copy link
Member

@Areredify what do you mean? Did we miss tests for dyn Unsizing?

Signed-off-by: Zahari Dichev <zaharidichev@gmail.com>
@zaharidichev
Copy link
Contributor Author

@Areredify is this in tests/unify.rs ?

@basil-cow
Copy link
Contributor

basil-cow commented Jun 17, 2020

@jackh726 We didn't, but I would say it's a roundabout way to test unification

@jackh726
Copy link
Member

Ah, I see. Hmm, I think this is fine. It might be worth adding specific tests for unification of all types. But let's do that separately. (Maybe file an issue?)

@zaharidichev
Copy link
Contributor Author

@Areredify I can take the unification tests issue if you provide a pinch of guidance.

@jackh726
Copy link
Member

Let's do that in a separate PR :)

@jackh726 jackh726 merged commit 20de620 into rust-lang:master Jun 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support different trait order in trait object unification
4 participants