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

Allow Trait inheritance with cycles on associated types #79209

Merged
merged 28 commits into from
Nov 29, 2020

Conversation

spastorino
Copy link
Member

@spastorino spastorino commented Nov 19, 2020

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 19, 2020
Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

I thought I had some good creative ideas for tests but as I look at it, most of them are kind of the same as the tests you already have.

I guess I think we should test some scenarios that ARE still ambiguous, e.g.

trait Foo { type Item; }
trait Bar<T> { type Item; }
trait Baz: Foo + Bar<Self::Item> { }

compiler/rustc_typeck/src/astconv/mod.rs Outdated Show resolved Hide resolved
compiler/rustc_typeck/src/astconv/mod.rs Outdated Show resolved Hide resolved
compiler/rustc_typeck/src/check/fn_ctxt/mod.rs Outdated Show resolved Hide resolved
compiler/rustc_typeck/src/collect.rs Outdated Show resolved Hide resolved
compiler/rustc_typeck/src/astconv/mod.rs Outdated Show resolved Hide resolved
compiler/rustc_typeck/src/collect.rs Outdated Show resolved Hide resolved
/// Ensures that the super-predicates of the trait with a `DefId`
/// of `trait_def_id` are converted and stored. This also ensures that
/// the transitive super-predicates are converted.
fn super_predicates_that_define_assoc_type(
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm so this is a query... it's a bit unusual in that most query providers either operate on local def-ids or external def-ids but not both. (The typical strategy, in other words, would be to define this query by encoding it into the metadata.) But that seems kind of silly here, I don't see a reason to encode more into the metadata. So this setup is probably ok. But I feel like we have to be sure to setup the provider also for external crates or we will see ICEs -- I'm a bit surprised our tests aren't encountering them yet, actually.

@spastorino spastorino force-pushed the trait-inheritance-self branch 4 times, most recently from 7ce0390 to 3be4aaf Compare November 23, 2020 15:42
@bors
Copy link
Contributor

bors commented Nov 23, 2020

☔ The latest upstream changes (presumably #79345) made this pull request unmergeable. Please resolve the merge conflicts.

Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:

@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author

@spastorino spastorino force-pushed the trait-inheritance-self branch 2 times, most recently from 34c5526 to 1401166 Compare November 23, 2020 19:48
Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

Can you add a test like

trait Foo<T> { }
trait Bar { type A; type B; }
trait Baz: Bar<B = u32> + Foo<Self::A> { }

I want to be sure that we correctly handle predicates like Bar<B = u32>, which can also define an assoc type (A, in this case)

compiler/rustc_typeck/src/astconv/mod.rs Show resolved Hide resolved
compiler/rustc_infer/src/traits/util.rs Outdated Show resolved Hide resolved
compiler/rustc_infer/src/traits/util.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/query/mod.rs Outdated Show resolved Hide resolved
compiler/rustc_typeck/src/collect.rs Outdated Show resolved Hide resolved
compiler/rustc_typeck/src/collect.rs Outdated Show resolved Hide resolved
compiler/rustc_typeck/src/collect.rs Outdated Show resolved Hide resolved
@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Nov 25, 2020

📌 Commit 84f6b861433e61ab0de27980a9b9266ca4fff1ac has been approved by nikomatsakis

@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 Nov 25, 2020
@nikomatsakis
Copy link
Contributor

@bors rollup=never

@bors
Copy link
Contributor

bors commented Nov 25, 2020

⌛ Testing commit 84f6b861433e61ab0de27980a9b9266ca4fff1ac with merge 4c9eee42b3766d927e66c92c378b3d55a7f3023f...

@bors
Copy link
Contributor

bors commented Nov 25, 2020

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 25, 2020
@spastorino
Copy link
Member Author

@bors retry

@bors bors removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 26, 2020
@bors bors added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 27, 2020
@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Nov 28, 2020

📌 Commit ada7c1f has been approved by nikomatsakis

@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 Nov 28, 2020
@bors
Copy link
Contributor

bors commented Nov 28, 2020

⌛ Testing commit ada7c1f with merge 60e4bbf0e17aa931e8b32579c31da2024d5e9890...

@bors
Copy link
Contributor

bors commented Nov 28, 2020

💥 Test timed out

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 28, 2020
@spastorino
Copy link
Member Author

@bors retry

@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 Nov 29, 2020
@bors
Copy link
Contributor

bors commented Nov 29, 2020

⌛ Testing commit ada7c1f with merge 349b3b3...

@bors
Copy link
Contributor

bors commented Nov 29, 2020

☀️ Test successful - checks-actions
Approved by: nikomatsakis
Pushing 349b3b3 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 29, 2020
@bors bors merged commit 349b3b3 into rust-lang:master Nov 29, 2020
@rustbot rustbot added this to the 1.50.0 milestone Nov 29, 2020
spastorino added a commit to spastorino/rust that referenced this pull request Dec 2, 2020
…self, r=nikomatsakis"

This reverts commit 349b3b3, reversing
changes made to b776d1c.
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 3, 2020
…elf, r=Mark-Simulacrum

Revert "Auto merge of rust-lang#79209

r? `@nikomatsakis`

This has caused some issues (rust-lang#79560) so better to revert and try to come up with a proper fix without rush.
@rylev
Copy link
Member

rylev commented Dec 3, 2020

@spastorino FYI: there was a minor perf regression from this PR. I'm still getting used to telling whether something is noise, but a 2% change on packed-simd seems like it's probably an actual regression (albeit a small one).
//cc @Mark-Simulacrum

edit: just noticed this was reverted in #79637

@camelid camelid added A-associated-items Area: Associated items (types, constants & functions) A-traits Area: Trait system labels Dec 3, 2020
m-ou-se added a commit to m-ou-se/rust that referenced this pull request Jan 16, 2021
… r=nikomatsakis

Allow Trait inheritance with cycles on associated types take 2

This reverts the revert of rust-lang#79209 and fixes the ICEs that's occasioned by that PR exposing some problems that are addressed in rust-lang#80648 and rust-lang#79811.
For easier review I'd say, check only the last commit, the first one is just a revert of the revert of rust-lang#79209 which was already approved.

This also could be considered part or the actual fix of rust-lang#79560 but I guess for that to be closed and fixed completely we would need to land rust-lang#80648 and rust-lang#79811 too.

r? `@nikomatsakis`
cc `@Aaron1011`
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Feb 9, 2021
… r=nikomatsakis

Allow Trait inheritance with cycles on associated types take 2

This reverts the revert of rust-lang#79209 and fixes the ICEs that's occasioned by that PR exposing some problems that are addressed in rust-lang#80648 and rust-lang#79811.
For easier review I'd say, check only the last commit, the first one is just a revert of the revert of rust-lang#79209 which was already approved.

This also could be considered part or the actual fix of rust-lang#79560 but I guess for that to be closed and fixed completely we would need to land rust-lang#80648 and rust-lang#79811 too.

r? `@nikomatsakis`
cc `@Aaron1011`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items (types, constants & functions) A-traits Area: Trait system merged-by-bors This PR was explicitly merged by bors. 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.

Trait inheritance gives unexpected compile error when inherited traits use associated types defined in trait
7 participants