-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Remove support for dyn*
from the compiler
#143036
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
base: master
Are you sure you want to change the base?
Conversation
r? @SparrowLii rustbot has assigned @SparrowLii. Use |
Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri Some changes occurred in src/tools/rustfmt cc @rust-lang/rustfmt HIR ty lowering was modified cc @fmease Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 There are changes to the cc @jieyouxu Some changes occurred in compiler/rustc_codegen_ssa Some changes occurred to constck cc @fee1-dead Some changes occurred in src/tools/clippy cc @rust-lang/clippy Some changes occurred to the CTFE machinery Some changes occurred in compiler/rustc_sanitizers cc @rcvalle The Miri subtree was changed cc @rust-lang/miri This PR changes a file inside |
This comment has been minimized.
This comment has been minimized.
443ab20
to
965c86a
Compare
This seems reasonable. We learned some things from the experiment, but it was also a pretty invasive change so it makes sense not to keep paying the upkeep. If we need it again in the future, we know how to do it. |
Thanks to @compiler-errors for the detailed write-up about this in the PR description. That too will be helpful to any future efforts. |
…-obk Remove support for `dyn*` from the compiler This PR removes support for `dyn*` (rust-lang#102425), which are a currently un-RFC'd experiment that was opened a few years ago to explore a component that we thought was necessary for AFIDT (async fn in dyn trait). It doesn't seem like we are going to need `dyn*` types -- even in an not-exposed-to-the-user way[^1] -- for us to implement AFIDT. Given that AFIDT was the original motivating purpose of `dyn*` types, I don't really see a compelling reason to have to maintain their implementation in the compiler. [^1]: Compared to, e.g., generators whih are an unstable building block we use to implement stable syntax like `async {}`. We've learned quite a lot from `dyn*`, but I think at this point its current behavior leads to more questions than answers. For example, `dyn*` support today remains somewhat fragile; it ICEs in many cases where the current "normal" `dyn Trait` types rely on their unsizedness for their vtable-based implementation to be sound I wouldn't be surprised if it's unsound in other ways, though I didn't play around with it too much. See the examples below. ```rust #![feature(dyn_star)] trait Foo { fn hello(self); } impl Foo for usize { fn hello(self) { println!("hello, world"); } } fn main() { let x: dyn* Foo = 1usize; x.hello(); } ``` And: ```rust #![feature(dyn_star)] trait Trait { type Out where Self: Sized; } fn main() { let x: <dyn* Trait as Trait>::Out; } ``` ...and probably many more problems having to do with the intersection of dyn-compatibility and `Self: Sized` bounds that I was too lazy to look into like: * GATs * Methods with invalid signatures * Associated consts Generally, `dyn*` types also end up getting in the way of working with [normal `dyn` types](rust-lang#102425 (comment)) to an extent that IMO outweighs the benefit of experimentation. I recognize that there are probably other, more creative usages of `dyn*` that are orthogonal to AFIDT. However, I think any work along those lines should first have to think through some of the more fundamental interactions between `dyn*` and dyn-compatibility before we think about reimplementing them in the type system. --- I'm planning on removing the `DynKind` enum and the `PointerLike` built-in trait from the compiler after this PR lands. Closes rust-lang#102425. cc `@eholk` `@rust-lang/lang` `@rust-lang/types` Closes rust-lang#116979. Closes rust-lang#119694. Closes rust-lang#134591. Closes rust-lang#104800.
Rollup of 6 pull requests Successful merges: - #142270 (Rustdoc js: even more typechecking improvements) - #142420 (Report infer ty errors during hir ty lowering) - #142818 (Port `#[used]` to new attribute parsing infrastructure) - #143020 (codegen_fn_attrs: make comment more precise) - #143036 (Remove support for `dyn*` from the compiler) - #143060 (Only args in main diag are saved and restored without removing the newly added ones) r? `@ghost` `@rustbot` modify labels: rollup
I wonder if it's the one which failed in #143081? |
This PR removes support for
dyn*
(#102425), which are a currently un-RFC'd experiment that was opened a few years ago to explore a component that we thought was necessary for AFIDT (async fn in dyn trait).It doesn't seem like we are going to need
dyn*
types -- even in an not-exposed-to-the-user way1 -- for us to implement AFIDT. Given that AFIDT was the original motivating purpose ofdyn*
types, I don't really see a compelling reason to have to maintain their implementation in the compiler.We've learned quite a lot from
dyn*
, but I think at this point its current behavior leads to more questions than answers. For example,dyn*
support today remains somewhat fragile; it ICEs in many cases where the current "normal"dyn Trait
types rely on their unsizedness for their vtable-based implementation to be sound I wouldn't be surprised if it's unsound in other ways, though I didn't play around with it too much. See the examples below.And:
...and probably many more problems having to do with the intersection of dyn-compatibility and
Self: Sized
bounds that I was too lazy to look into like:Generally,
dyn*
types also end up getting in the way of working with normaldyn
types to an extent that IMO outweighs the benefit of experimentation.I recognize that there are probably other, more creative usages of
dyn*
that are orthogonal to AFIDT. However, I think any work along those lines should first have to think through some of the more fundamental interactions betweendyn*
and dyn-compatibility before we think about reimplementing them in the type system.I'm planning on removing the
DynKind
enum and thePointerLike
built-in trait from the compiler after this PR lands.Closes #102425.
cc @eholk @rust-lang/lang @rust-lang/types
Closes #116979.
Closes #119694.
Closes #134591.
Closes #104800.
Footnotes
Compared to, e.g., generators whih are an unstable building block we use to implement stable syntax like
async {}
. ↩