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

Refactor vtable format for upcoming trait_upcasting feature. #86461

Merged
merged 4 commits into from
Jul 24, 2021

Conversation

crlf0710
Copy link
Member

@crlf0710 crlf0710 commented Jun 19, 2021

This modifies vtable format:

  1. reordering occurrence order of methods coming from different traits
  2. include VPtrs for supertraits where this vtable cannot be directly reused during trait upcasting.
    Also, during codegen, the vtables corresponding to these newly included VPtr will be requested and generated.

For the cases where this vtable can directly used, now the super trait vtable has exactly the same content to some prefix of this one.

r? @bjorn3
cc @RalfJung
cc @rust-lang/wg-traits

@crlf0710 crlf0710 added the F-trait_upcasting `#![feature(trait_upcasting)]` label Jun 19, 2021
@rust-highfive
Copy link
Collaborator

Some changes occured to the CTFE / Miri engine

cc @rust-lang/miri

Some changes occured to rustc_codegen_cranelift

cc @bjorn3

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 19, 2021
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@crlf0710
Copy link
Member Author

So it seems there's still something wrong with the subst_supertrait related part...

@rust-log-analyzer

This comment has been minimized.

@RalfJung
Copy link
Member

reordering components

To be clear, the 3 default components are still in the same place? If those move around, we'll have to adjust some CTFE and Miri tests.

@RalfJung
Copy link
Member

Also, so far nothing is using those new components yet, right?

@crlf0710
Copy link
Member Author

  1. Yes, the three default components location are not changed at all.
  2. Yes, currently there's nothing that reads the newly added VPtrs embedded within the vtable. This is not covered by any tests yet, will be covered by the trait_upcasting unit tests.
  3. Some methods will be moved to using another slot within the vtable. I think this is covered by existing unit tests.

@RalfJung
Copy link
Member

Okay, 👍 from the Miri/CTFE side then.

Yes, currently there's nothing that reads the newly added VPtrs embedded within the vtable. This is not covered by any tests yet, will be covered by the trait_upcasting unit tests.

If this required codegen changes (which I assume it will), then Miri will also need updating. I'm happy to help with that. :)

@crlf0710
Copy link
Member Author

@RalfJung It will. Let's resume this discussion on Zulip: https://rust-lang.zulipchat.com/#narrow/stream/144729-wg-traits/topic/object.20upcasting .

@crlf0710
Copy link
Member Author

Blocked on #86475 and after that this change will be smaller.

@crlf0710 crlf0710 added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 28, 2021
@bors
Copy link
Contributor

bors commented Jun 29, 2021

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

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@crlf0710 crlf0710 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Jun 30, 2021
@crlf0710
Copy link
Member Author

crlf0710 commented Jul 1, 2021

#86475 has landed and this is unblocked.

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.

r=me but:

  • can we include the examples from the documentation as tests?
  • it'd be good to see a test with methods that cannot be called (because of irreconcilable where clauses)

compiler/rustc_middle/src/ty/vtable.rs Outdated Show resolved Hide resolved
@nikomatsakis
Copy link
Contributor

@bors delegate+

@bors
Copy link
Contributor

bors commented Jul 21, 2021

✌️ @crlf0710 can now approve this pull request

@crlf0710
Copy link
Member Author

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Jul 22, 2021

📌 Commit fbb353a 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 Jul 22, 2021
@bors
Copy link
Contributor

bors commented Jul 23, 2021

⌛ Testing commit fbb353a with merge 48e11d475136cc2161215b068c1f6b3182116276...

@bors
Copy link
Contributor

bors commented Jul 23, 2021

💔 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 Jul 23, 2021
@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@crlf0710
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 Jul 23, 2021
@bors
Copy link
Contributor

bors commented Jul 24, 2021

⌛ Testing commit fbb353a with merge f9b95f9...

@bors
Copy link
Contributor

bors commented Jul 24, 2021

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 24, 2021
@bors bors merged commit f9b95f9 into rust-lang:master Jul 24, 2021
@rustbot rustbot added this to the 1.56.0 milestone Jul 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-trait_upcasting `#![feature(trait_upcasting)]` 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.

10 participants