Skip to content

Conversation

crlf0710
Copy link
Member

This is the second part of trait upcasting coercion implementation.

Currently this is blocked on #86264 .

The third part might be implemented using unsafety checking

r? @bjorn3

@rust-highfive
Copy link
Contributor

Some changes occured to rustc_codegen_cranelift

cc @bjorn3

Some changes occured to the CTFE / Miri engine

cc @rust-lang/miri

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 27, 2021
@crlf0710 crlf0710 added S-blocked Status: Blocked on something else such as an RFC or other implementation work. F-trait_upcasting `#![feature(trait_upcasting)]` and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 27, 2021
@crlf0710 crlf0710 changed the title Trait upcasting coercion part2 Trait upcasting coercion (part2) Jul 27, 2021
@rust-log-analyzer

This comment has been minimized.

@crlf0710 crlf0710 force-pushed the trait_upcasting_part2 branch from 522611b to cf6db18 Compare July 27, 2021 15:29
@bors
Copy link
Collaborator

bors commented Jul 27, 2021

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

@crlf0710
Copy link
Member Author

#86264 has landed, now this is unblocked. I'll address the review comments very soon, and add more tests.

@crlf0710 crlf0710 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Jul 31, 2021
@crlf0710 crlf0710 force-pushed the trait_upcasting_part2 branch from cf6db18 to aaba84e Compare July 31, 2021 15:20
@crlf0710 crlf0710 added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 31, 2021
@crlf0710 crlf0710 requested review from RalfJung and bjorn3 July 31, 2021 15:26
@crlf0710
Copy link
Member Author

Rebased, addressed the review comments and pull in some tests and document from previous work. This is ready for review again now.

.expect("unsized_info: missing principal trait for trait upcasting coercion");
let principal_b = data_b
.principal()
.expect("unsized_info: missing principal trait for trait upcasting coercion");
Copy link
Member

Choose a reason for hiding this comment

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

Isn't the principal non-existent when the trait object only consists of traits like Send, Sync or Sized?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, if the principal is non-existent, either it's not upcasting coercion, like &dyn Send+Sync to &dyn Send will be a simple case (and will take the early return code path), or it will be rejected by type-checking, like dyn Foo + Send to dyn Send will be rejected.

I added some comments within the code to clarify.

@crlf0710 crlf0710 force-pushed the trait_upcasting_part2 branch from aaba84e to 4e22b21 Compare August 1, 2021 09:35
@crlf0710
Copy link
Member Author

crlf0710 commented Aug 1, 2021

Thanks for the comments! Updated.

@crlf0710
Copy link
Member Author

crlf0710 commented Aug 2, 2021

@RalfJung Thanks for the review! I've addressed the comments.

Copy link
Member

@bjorn3 bjorn3 left a comment

Choose a reason for hiding this comment

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

The codegen part LGTM apart from a minor nit. I will leave @RalfJung to approve the miri part. I don't see any obvious problems with the trait selection code, but given that I am not familiar with it, maybe @nikomatsakis want to take a look?

@crlf0710 crlf0710 force-pushed the trait_upcasting_part2 branch from 2e69d6c to f99a37e Compare August 2, 2021 15:15
@crlf0710
Copy link
Member Author

crlf0710 commented Aug 2, 2021

Updated and addressed the comments.

For the trait selection related stuff, I think niko has been and will be on vacation in the next two weeks. if it's possible i'd prefer more detailed review of this part be defered a little, and we'll revisit it after this FIXME is solved.

@crlf0710 crlf0710 requested a review from RalfJung August 2, 2021 15:33
@RalfJung
Copy link
Member

RalfJung commented Aug 2, 2021

👍 for the Miri engine changes.

Copy link
Member

@bjorn3 bjorn3 left a comment

Choose a reason for hiding this comment

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

For the trait selection related stuff, I think niko has been and will be on vacation in the next two weeks. if it's possible i'd prefer more detailed review of this part be defered a little, and we'll revisit it after this FIXME is solved.

Sure. r=me with the nit resolved.

@crlf0710 crlf0710 force-pushed the trait_upcasting_part2 branch from f99a37e to 3cb625e Compare August 2, 2021 17:14
@crlf0710
Copy link
Member Author

crlf0710 commented Aug 2, 2021

@bjorn3 Updated with the comment above addressed!

@bjorn3
Copy link
Member

bjorn3 commented Aug 2, 2021

@bors r+

@bors
Copy link
Collaborator

bors commented Aug 2, 2021

📌 Commit 3cb625e has been approved by bjorn3

@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 Aug 2, 2021
@bors
Copy link
Collaborator

bors commented Aug 3, 2021

⌛ Testing commit 3cb625e with merge c6bc102...

@bors
Copy link
Collaborator

bors commented Aug 3, 2021

☀️ Test successful - checks-actions
Approved by: bjorn3
Pushing c6bc102 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 3, 2021
@bors bors merged commit c6bc102 into rust-lang:master Aug 3, 2021
@rustbot rustbot added this to the 1.56.0 milestone Aug 3, 2021
bjorn3 pushed a commit to bjorn3/rust that referenced this pull request Aug 6, 2021
Trait upcasting coercion (part2)

This is the second part of trait upcasting coercion implementation.

Currently this is blocked on rust-lang#86264 .

The third part might be implemented using unsafety checking

r? `@bjorn3`
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Aug 6, 2021
…jorn3

Sync rustc_codegen_cranelift

05677b6 removes two assertions that should have been removed in rust-lang#87515. They are no longer correct and trigger while compiling the sysroot.

r? `@ghost`

`@rustbot` label +A-codegen +A-cranelift +T-compiler
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.

8 participants