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 take 2 #80732

Merged
merged 4 commits into from
Feb 9, 2021

Conversation

spastorino
Copy link
Member

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

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

r? @nikomatsakis
cc @Aaron1011

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 5, 2021
@jyn514
Copy link
Member

jyn514 commented Jan 5, 2021

@bors try

So people can easily install this with https://github.com/kennytm/rustup-toolchain-install-master (#79560 (comment))

@bors
Copy link
Contributor

bors commented Jan 5, 2021

⌛ Trying commit 958a97b56a7cfdaa35b032fbaa49385c5d08dfe8 with merge c963187c6f959417cbb13a33e9eaea4607696fc4...

@spastorino
Copy link
Member Author

@jyn514 yeah that's great. I've force pushed but all I've changed there is the test I've added to be check-pass instead of build-pass, so don't worry about that.

@camelid camelid added A-traits Area: Trait system T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 6, 2021
@spastorino
Copy link
Member Author

spastorino commented Jan 6, 2021

@nikomatsakis, now that this is tested, should be ready for review/merge.

@nikomatsakis
Copy link
Contributor

nikomatsakis commented Jan 16, 2021

Just to make sure I understand the situation:

  • changing from Ident to Symbol basically works around the hygiene problems we encountered
  • but once Add disambiugator to ExpnData #79811 lands, we wouldn't have had those problems in the first place?

Is there a test for the new ICEs we encountered? I couldn't quite tell.

If all that is correct, r=me.

@bors delegate+

@bors
Copy link
Contributor

bors commented Jan 16, 2021

✌️ @spastorino can now approve this pull request

@spastorino
Copy link
Member Author

@nikomatsakis what you've said is correct. About the test check the second commit (the one that's not the revert) and at the end you'll find the test.

@spastorino
Copy link
Member Author

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Jan 16, 2021

📌 Commit 455a0e1 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 Jan 16, 2021
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`
@lnicola lnicola mentioned this pull request Jan 17, 2021
@lnicola
Copy link
Member

lnicola commented Jan 17, 2021

@jyn514 what commit should I use with rustup-toolchain-install-master? Neither 03c0e58 nor 455a0e1 work.

@m-ou-se
Copy link
Member

m-ou-se commented Jan 17, 2021

@lnicola That only works for commits that have been built by bors. Try the commits mentioned in #80732 (comment).

@lnicola
Copy link
Member

lnicola commented Jan 17, 2021

@spastorino this introduces an error while compiling salsa:

error[E0221]: ambiguous associated type `Group` in bounds of `Q`
   --> src/interned.rs:466:57
    |
466 |             <<Q as QueryDb<'_>>::DynDb as HasQueryGroup<Q::Group>>::group_storage(db);
    |                                                         ^^^^^^^^ ambiguous associated type `Group`
    | 
   ::: src/lib.rs:431:5
    |
431 |     type Group: plumbing::QueryGroup<GroupStorage = Self::GroupStorage>;
    |     --------------------------------------------------------------------
    |     |
    |     ambiguous `Group` from `for<'d> QueryDb<'d>`
    |     ambiguous `Group` from `for<'d> QueryDb<'d>`
    |
help: use fully qualified syntax to disambiguate
    |
466 |             <<Q as QueryDb<'_>>::DynDb as HasQueryGroup<<Q as for<'d> QueryDb<'d>>::Group>>::group_storage(db);
    |                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: use fully qualified syntax to disambiguate
    |
466 |             <<Q as QueryDb<'_>>::DynDb as HasQueryGroup<<Q as for<'d> QueryDb<'d>>::Group>>::group_storage(db);
    |                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0221]: ambiguous associated type `Group` in bounds of `Q`
   --> src/interned.rs:478:57
    |
478 |             <<Q as QueryDb<'_>>::DynDb as HasQueryGroup<Q::Group>>::group_storage(db);
    |                                                         ^^^^^^^^ ambiguous associated type `Group`
    | 
   ::: src/lib.rs:431:5
    |
431 |     type Group: plumbing::QueryGroup<GroupStorage = Self::GroupStorage>;
    |     --------------------------------------------------------------------
    |     |
    |     ambiguous `Group` from `for<'d> QueryDb<'d>`
    |     ambiguous `Group` from `for<'d> QueryDb<'d>`
    |
help: use fully qualified syntax to disambiguate
    |
478 |             <<Q as QueryDb<'_>>::DynDb as HasQueryGroup<<Q as for<'d> QueryDb<'d>>::Group>>::group_storage(db);
    |                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: use fully qualified syntax to disambiguate
    |
478 |             <<Q as QueryDb<'_>>::DynDb as HasQueryGroup<<Q as for<'d> QueryDb<'d>>::Group>>::group_storage(db);
    |                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0221]: ambiguous associated type `Group` in bounds of `Q`
   --> src/interned.rs:490:57
    |
490 |             <<Q as QueryDb<'_>>::DynDb as HasQueryGroup<Q::Group>>::group_storage(db);
    |                                                         ^^^^^^^^ ambiguous associated type `Group`
    | 
   ::: src/lib.rs:431:5
    |
431 |     type Group: plumbing::QueryGroup<GroupStorage = Self::GroupStorage>;
    |     --------------------------------------------------------------------
    |     |
    |     ambiguous `Group` from `for<'d> QueryDb<'d>`
    |     ambiguous `Group` from `for<'d> QueryDb<'d>`
    |
help: use fully qualified syntax to disambiguate
    |
490 |             <<Q as QueryDb<'_>>::DynDb as HasQueryGroup<<Q as for<'d> QueryDb<'d>>::Group>>::group_storage(db);
    |                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: use fully qualified syntax to disambiguate
    |
490 |             <<Q as QueryDb<'_>>::DynDb as HasQueryGroup<<Q as for<'d> QueryDb<'d>>::Group>>::group_storage(db);
    |                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0221]: ambiguous associated type `Group` in bounds of `Q`
   --> src/interned.rs:512:57
    |
512 |             <<Q as QueryDb<'_>>::DynDb as HasQueryGroup<Q::Group>>::group_storage(db);
    |                                                         ^^^^^^^^ ambiguous associated type `Group`
    | 
   ::: src/lib.rs:431:5
    |
431 |     type Group: plumbing::QueryGroup<GroupStorage = Self::GroupStorage>;
    |     --------------------------------------------------------------------
    |     |
    |     ambiguous `Group` from `for<'d> QueryDb<'d>`
    |     ambiguous `Group` from `for<'d> QueryDb<'d>`
    |
help: use fully qualified syntax to disambiguate
    |
512 |             <<Q as QueryDb<'_>>::DynDb as HasQueryGroup<<Q as for<'d> QueryDb<'d>>::Group>>::group_storage(db);
    |                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: use fully qualified syntax to disambiguate
    |
512 |             <<Q as QueryDb<'_>>::DynDb as HasQueryGroup<<Q as for<'d> QueryDb<'d>>::Group>>::group_storage(db);
    |                                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0221`.
error: could not compile `salsa`

Do you know if that is intended? The two suggestions seem identical. Or is it a single suggestion printed twice?

@m-ou-se
Copy link
Member

m-ou-se commented Jan 17, 2021

@bors r-

That failed in this rollup: #81102 (comment)

(Thanks @lnicola for figuring it out!)

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jan 17, 2021
@spastorino spastorino force-pushed the trait-inheritance-self2 branch 2 times, most recently from 149e8ab to fae509c Compare February 2, 2021 20:56
@spastorino
Copy link
Member Author

Have just changed back to Ident given that @Aaron1011 has fixed the original underlying issue.

@lnicola can you tell me how to reproduce the salsa issue? or better said, do you have an MCVE for it?.

@lnicola
Copy link
Member

lnicola commented Feb 3, 2021

@spastorino try this, it was a pain to minimize:

pub struct LookupInternedStorage;

impl<Q> QueryStorageOps<Q> for LookupInternedStorage
where
    Q: Query,
    for<'d> Q: QueryDb<'d>,
{
    fn fmt_index(&self, db: &<Q as QueryDb<'_>>::DynDb) {
        <<Q as QueryDb<'_>>::DynDb as HasQueryGroup<Q::Group>>::group_storage(db);
    }
}

pub trait HasQueryGroup<G>
{
    fn group_storage(&self);
}

pub trait QueryStorageOps<Q>
where
    Q: Query,
{
    fn fmt_index(&self, db: &<Q as QueryDb<'_>>::DynDb);
}

pub trait QueryDb<'d> {
    type DynDb: HasQueryGroup<Self::Group> + 'd;
    type Group;
}

pub trait Query: for<'d> QueryDb<'d> {
}
$ cargo +c963187c6f959417cbb13a33e9eaea4607696fc4 build
   Compiling salsa-min v0.1.0 (/home/grayshade/salsa-min)
error[E0221]: ambiguous associated type `Group` in bounds of `Q`
  --> src/main.rs:9:53
   |
9  |         <<Q as QueryDb<'_>>::DynDb as HasQueryGroup<Q::Group>>::group_storage(db);
   |                                                     ^^^^^^^^ ambiguous associated type `Group`
...
30 |     type Group;
   |     -----------
   |     |
   |     ambiguous `Group` from `for<'d> QueryDb<'d>`
   |     ambiguous `Group` from `for<'d> QueryDb<'d>`
   |
help: use fully qualified syntax to disambiguate
   |
9  |         <<Q as QueryDb<'_>>::DynDb as HasQueryGroup<<Q as for<'d> QueryDb<'d>>::Group>>::group_storage(db);
   |                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: use fully qualified syntax to disambiguate
   |
9  |         <<Q as QueryDb<'_>>::DynDb as HasQueryGroup<<Q as for<'d> QueryDb<'d>>::Group>>::group_storage(db);
   |                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to previous error

For more information about this error, try `rustc --explain E0221`.
error: could not compile `salsa-min`

To learn more, run the command again with --verbose.

$ cargo +stable check
    Finished dev [unoptimized + debuginfo] target(s) in 0.19s

@bors
Copy link
Contributor

bors commented Feb 5, 2021

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

@rust-log-analyzer

This comment has been minimized.

…itance-self, r=Mark-Simulacrum"

This reverts commit b4def89, reversing
changes made to 7dc1e85.
An ICE happened when certain code is compiled in incremental compilation
mode and there are two `Ident`s that have the same `StableHash` value
but are considered different by `Eq` and `Hash`.

The `Ident` issue is now fixed.
@spastorino spastorino force-pushed the trait-inheritance-self2 branch 3 times, most recently from 6f3b0b4 to c01c135 Compare February 8, 2021 16:02
@spastorino
Copy link
Member Author

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Feb 8, 2021

📌 Commit 8d17c6a 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 8, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 9, 2021
Rollup of 11 pull requests

Successful merges:

 - rust-lang#72209 (Add checking for no_mangle to unsafe_code lint)
 - rust-lang#80732 (Allow Trait inheritance with cycles on associated types take 2)
 - rust-lang#81697 (Add "every" as a doc alias for "all".)
 - rust-lang#81826 (Prefer match over combinators to make some Box methods inlineable)
 - rust-lang#81834 (Resolve typedef in HashMap lldb pretty-printer only if possible)
 - rust-lang#81841 ([rustbuild] Output rustdoc-json-types docs )
 - rust-lang#81849 (Expand the docs for ops::ControlFlow a bit)
 - rust-lang#81876 (parser: Fix panic in 'const impl' recovery)
 - rust-lang#81882 (:arrow_up: rust-analyzer)
 - rust-lang#81888 (Fix pretty printer macro_rules with semicolon.)
 - rust-lang#81896 (Remove outdated comment in windows' mutex.rs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 44e526b into rust-lang:master Feb 9, 2021
@rustbot rustbot added this to the 1.52.0 milestone Feb 9, 2021
@pthariensflame
Copy link
Contributor

Does this need relnotes?

@nikomatsakis
Copy link
Contributor

I don't think it really needs relnotes, it's basically a minor bugfix that probably doesn't rise to that level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-traits Area: Trait system S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.