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

Make dyn* casts into a coercion, allow dyn* upcasting #101832

Merged
merged 4 commits into from
Oct 15, 2022

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Sep 14, 2022

I know that dyn* is likely not going to be a feature exposed to surface Rust, but this makes it slightly more ergonomic to write tests for these types anyways. ... and this was just fun to implement anyways.

  1. Make dyn* into a coercion instead of a cast
  2. Enable dyn* upcasting since we basically get it for free
  3. Simplify some of the cast checking code since we're using the coercion path now

r? @eholk but feel free to reassign
cc @nikomatsakis and @tmandry who might care about making dyn* casts into a coercion

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Sep 14, 2022
@rustbot
Copy link
Collaborator

rustbot commented Sep 14, 2022

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

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

@eholk eholk left a comment

Choose a reason for hiding this comment

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

Looks good to me. I added a few questions and suggestions, but feel free to accept the suggestions or not and r=me.

compiler/rustc_typeck/src/check/coercion.rs Outdated Show resolved Hide resolved
src/test/ui/dyn-star/const.rs Show resolved Hide resolved
compiler/rustc_codegen_ssa/src/base.rs Show resolved Hide resolved
compiler/rustc_codegen_ssa/src/base.rs Outdated Show resolved Hide resolved
compiler/rustc_codegen_ssa/src/base.rs Outdated Show resolved Hide resolved
@bors
Copy link
Contributor

bors commented Sep 15, 2022

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

@crlf0710 crlf0710 added the F-dyn_star `#![feature(dyn_star)]` label Sep 17, 2022
@compiler-errors compiler-errors 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-review Status: Awaiting review from the assignee but also interested parties. labels Sep 26, 2022
@compiler-errors
Copy link
Member Author

@eholk had to move things around so would appreciate another review, addressed the nits + added the test you asked for.

@rustbot ready

@rustbot rustbot 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 Oct 14, 2022
cx.const_ptrcast(meth::get_vtable(cx, source, data.principal()), vtable_ptr_ty)
}
_ => bug!("unsized_info: invalid unsizing {:?} -> {:?}", source, target),
}
}

// Returns the vtable pointer type of a `dyn` or `dyn*` type
Copy link
Member

Choose a reason for hiding this comment

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

This will need to be implemented in cg_clif too.

@eholk
Copy link
Contributor

eholk commented Oct 14, 2022

Looks good to me, thanks!

@bors r+

@bors
Copy link
Contributor

bors commented Oct 14, 2022

📌 Commit 8c7e836 has been approved by eholk

It is now in the queue for this repository.

@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 Oct 14, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Oct 15, 2022
…holk

Make `dyn*` casts into a coercion, allow `dyn*` upcasting

I know that `dyn*` is likely not going to be a feature exposed to surface Rust, but this makes it slightly more ergonomic to write tests for these types anyways. ... and this was just fun to implement anyways.

1. Make `dyn*` into a coercion instead of a cast
2. Enable `dyn*` upcasting since we basically get it for free
3. Simplify some of the cast checking code since we're using the coercion path now

r? `@eholk` but feel free to reassign
cc `@nikomatsakis` and `@tmandry` who might care about making `dyn*` casts into a coercion
@bors
Copy link
Contributor

bors commented Oct 15, 2022

⌛ Testing commit 8c7e836 with merge b15e2c1...

@bors
Copy link
Contributor

bors commented Oct 15, 2022

☀️ Test successful - checks-actions
Approved by: eholk
Pushing b15e2c1 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Oct 15, 2022
@bors bors merged commit b15e2c1 into rust-lang:master Oct 15, 2022
@rustbot rustbot added this to the 1.66.0 milestone Oct 15, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (b15e2c1): comparison URL.

Overall result: ❌ regressions - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean1 range count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
1.3% [1.3%, 1.3%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

This benchmark run did not return any relevant results for this metric.

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean1 range count2
Regressions ❌
(primary)
2.5% [1.8%, 3.1%] 2
Regressions ❌
(secondary)
2.9% [2.9%, 2.9%] 1
Improvements ✅
(primary)
-4.6% [-4.6%, -4.6%] 1
Improvements ✅
(secondary)
-2.5% [-2.5%, -2.5%] 1
All ❌✅ (primary) 0.1% [-4.6%, 3.1%] 3

Footnotes

  1. the arithmetic mean of the percent change 2

  2. number of relevant changes 2

@bjorn3
Copy link
Member

bjorn3 commented Oct 23, 2022

Implemented in cg_clif as of bjorn3/rustc_codegen_cranelift@342bac9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-dyn_star `#![feature(dyn_star)]` 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. 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.

8 participants