Skip to content

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Jun 26, 2025

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 of dyn* 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.

#![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:

#![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 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 #102425.

cc @eholk @rust-lang/lang @rust-lang/types

Closes #116979.
Closes #119694.
Closes #134591.
Closes #104800.

Footnotes

  1. Compared to, e.g., generators whih are an unstable building block we use to implement stable syntax like async {}.

@rustbot
Copy link
Collaborator

rustbot commented Jun 26, 2025

r? @SparrowLii

rustbot has assigned @SparrowLii.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-tidy Area: The tidy tool PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Jun 26, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jun 26, 2025

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 tidy tool.

cc @jieyouxu

Some changes occurred in compiler/rustc_codegen_ssa

cc @WaffleLapkin

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

cc @RalfJung, @oli-obk, @lcnr

Some changes occurred in compiler/rustc_sanitizers

cc @rcvalle

The Miri subtree was changed

cc @rust-lang/miri

This PR changes a file inside tests/crashes. If a crash was fixed, please move into the corresponding ui subdir and add 'Fixes #' to the PR description to autoclose the issue upon merge.

@rust-log-analyzer

This comment has been minimized.

@matthiaskrgr
Copy link
Member

And thus, after almost 3 years, the Rust Dynasty came to an end.

I guess #134591 and #104800 can also be marked as fixed/closed then?

@cyrgani cyrgani added the F-dyn_star `#![feature(dyn_star)]` label Jun 26, 2025
@oli-obk
Copy link
Contributor

oli-obk commented Jun 26, 2025

r? @oli-obk

@bors r+

@bors
Copy link
Collaborator

bors commented Jun 26, 2025

📌 Commit 965c86a has been approved by oli-obk

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 Jun 26, 2025
@eholk
Copy link
Contributor

eholk commented Jun 26, 2025

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.

@traviscross
Copy link
Contributor

traviscross commented Jun 26, 2025

Thanks to @compiler-errors for the detailed write-up about this in the PR description. That too will be helpful to any future efforts.

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Jun 27, 2025
…-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.
bors added a commit that referenced this pull request Jun 27, 2025
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
@GuillaumeGomez
Copy link
Member

I wonder if it's the one which failed in #143081?

@workingjubilee
Copy link
Member

This is proving bitrotty.

@bors p=1

bors added a commit that referenced this pull request Jun 27, 2025
Rollup of 9 pull requests

Successful merges:

 - #139858 (New const traits syntax)
 - #140809 (Reduce special casing for the panic runtime)
 - #142730 (suggest declaring modules when file found but module not defined)
 - #142806 (Normalize before computing ConstArgHasType goal in new solver)
 - #143046 (const validation: properly ignore zero-sized UnsafeCell)
 - #143092 (const checks for lifetime-extended temporaries: avoid 'top-level scope' terminology)
 - #143096 (tag_for_variant: properly pass TypingEnv)
 - #143104 (hir_analysis: prohibit `dyn PointeeSized`)
 - #143106 (gce: don't ICE on non-local const)

Failed merges:

 - #143036 (Remove support for `dyn*` from the compiler)

r? `@ghost`
`@rustbot` modify labels: rollup
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Jun 28, 2025
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#139858 (New const traits syntax)
 - rust-lang/rust#140809 (Reduce special casing for the panic runtime)
 - rust-lang/rust#142730 (suggest declaring modules when file found but module not defined)
 - rust-lang/rust#142806 (Normalize before computing ConstArgHasType goal in new solver)
 - rust-lang/rust#143046 (const validation: properly ignore zero-sized UnsafeCell)
 - rust-lang/rust#143092 (const checks for lifetime-extended temporaries: avoid 'top-level scope' terminology)
 - rust-lang/rust#143096 (tag_for_variant: properly pass TypingEnv)
 - rust-lang/rust#143104 (hir_analysis: prohibit `dyn PointeeSized`)
 - rust-lang/rust#143106 (gce: don't ICE on non-local const)

Failed merges:

 - rust-lang/rust#143036 (Remove support for `dyn*` from the compiler)

r? `@ghost`
`@rustbot` modify labels: rollup
@compiler-errors
Copy link
Member Author

@bors r=oli-obk

@bors
Copy link
Collaborator

bors commented Jul 1, 2025

📌 Commit 2516c33 has been approved by oli-obk

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 1, 2025
@bors
Copy link
Collaborator

bors commented Jul 1, 2025

⌛ Testing commit 2516c33 with merge 085c247...

@bors
Copy link
Collaborator

bors commented Jul 2, 2025

☀️ Test successful - checks-actions
Approved by: oli-obk
Pushing 085c247 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 2, 2025
@bors bors merged commit 085c247 into rust-lang:master Jul 2, 2025
11 checks passed
@rustbot rustbot added this to the 1.90.0 milestone Jul 2, 2025
Copy link
Contributor

github-actions bot commented Jul 2, 2025

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 71e4c00 (parent) -> 085c247 (this PR)

Test differences

Show 126 test diffs

Stage 1

  • [crashes] tests/crashes/116979.rs: pass -> [missing] (J0)
  • [crashes] tests/crashes/119694.rs: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/align.rs#normal: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/align.rs#over_aligned: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/async-block-dyn-star.rs: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/box.rs#current: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/box.rs#next: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/cell.rs: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs#current: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs#next: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/check-size-at-cast-polymorphic.rs: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/check-size-at-cast.rs: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/const-and-static.rs: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/const.rs: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/dispatch-on-pin-mut.rs: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/dont-unsize-coerce-dyn-star.rs: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/drop.rs: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/dyn-async-trait.rs: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/dyn-pointer-like.rs: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/dyn-star-to-dyn.rs: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/dyn-to-rigid.rs: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/enum-cast.rs: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/error.rs: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/feature-gate-dyn_star.rs: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/float-as-dyn-star.rs: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/gated-span.rs: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/illegal.rs: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/issue-102430.rs: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/make-dyn-star.rs: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/method.rs: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/no-explicit-dyn-star-cast.rs: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/no-explicit-dyn-star.rs: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/no-implicit-dyn-star.rs: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/no-unsize-coerce-dyn-trait.rs: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/param-env-region-infer.rs#current: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/pointer-like-impl-rules.rs: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/return.rs: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/syntax.rs: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/thin.rs#next: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/thin.rs#old: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/union.rs: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/unsize-into-ref-dyn-star.rs: pass -> [missing] (J0)
  • [ui] tests/ui/dyn-star/upcast.rs: pass -> [missing] (J0)
  • [ui] tests/ui/traits/dyn-star-drop-principal.rs: pass -> [missing] (J0)
  • [ui] tests/ui/traits/trait-upcasting/dyn-to-dyn-star.rs: pass -> [missing] (J0)

Stage 2

  • [ui] tests/ui/dyn-star/align.rs#normal: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/align.rs#over_aligned: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/async-block-dyn-star.rs: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/box.rs#current: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/box.rs#next: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/cell.rs: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs#current: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs#next: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/check-size-at-cast-polymorphic.rs: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/check-size-at-cast.rs: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/const-and-static.rs: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/const.rs: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/dispatch-on-pin-mut.rs: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/dont-unsize-coerce-dyn-star.rs: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/drop.rs: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/dyn-async-trait.rs: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/dyn-pointer-like.rs: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/dyn-star-to-dyn.rs: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/dyn-to-rigid.rs: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/enum-cast.rs: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/error.rs: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/feature-gate-dyn_star.rs: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/gated-span.rs: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/illegal.rs: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/issue-102430.rs: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/make-dyn-star.rs: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/method.rs: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/no-explicit-dyn-star-cast.rs: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/no-explicit-dyn-star.rs: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/no-implicit-dyn-star.rs: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/no-unsize-coerce-dyn-trait.rs: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/param-env-region-infer.rs#current: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/pointer-like-impl-rules.rs: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/return.rs: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/syntax.rs: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/thin.rs#next: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/thin.rs#old: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/union.rs: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/unsize-into-ref-dyn-star.rs: pass -> [missing] (J1)
  • [ui] tests/ui/dyn-star/upcast.rs: pass -> [missing] (J1)
  • [ui] tests/ui/traits/dyn-star-drop-principal.rs: pass -> [missing] (J1)
  • [ui] tests/ui/traits/trait-upcasting/dyn-to-dyn-star.rs: pass -> [missing] (J1)
  • [crashes] tests/crashes/116979.rs: pass -> [missing] (J2)
  • [ui] tests/ui/dyn-star/float-as-dyn-star.rs: ignore (only executed when the architecture is x86_64) -> [missing] (J3)
  • [crashes] tests/crashes/119694.rs: pass -> [missing] (J4)
  • [crashes] tests/crashes/116979.rs: ignore (ignored if rustc wasn't built with debug assertions) -> [missing] (J5)
  • [ui] tests/ui/dyn-star/float-as-dyn-star.rs: pass -> [missing] (J6)

Additionally, 34 doctest diffs were found. These are ignored, as they are noisy.

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 085c24790e591948f788fd294ca3f9858313741c --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-x86_64-apple: 12321.5s -> 8389.3s (-31.9%)
  2. x86_64-gnu-nopt: 9874.3s -> 7540.8s (-23.6%)
  3. dist-apple-various: 8408.6s -> 6843.0s (-18.6%)
  4. dist-aarch64-apple: 6362.9s -> 5324.9s (-16.3%)
  5. mingw-check-1: 1628.5s -> 1864.6s (14.5%)
  6. dist-ohos-aarch64: 4139.7s -> 4628.4s (11.8%)
  7. i686-gnu-2: 5562.0s -> 6197.0s (11.4%)
  8. x86_64-gnu-llvm-19-2: 5520.0s -> 6102.7s (10.6%)
  9. x86_64-gnu-miri: 4621.4s -> 5081.4s (10.0%)
  10. mingw-check-tidy: 68.7s -> 75.5s (9.9%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (085c247): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

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

Max RSS (memory usage)

Results (primary -1.4%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.4% [-1.4%, -1.4%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -1.4% [-1.4%, -1.4%] 1

Cycles

Results (primary -0.2%, secondary 4.8%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
1.2% [1.2%, 1.2%] 1
Regressions ❌
(secondary)
8.3% [0.9%, 17.2%] 10
Improvements ✅
(primary)
-1.0% [-1.1%, -0.9%] 2
Improvements ✅
(secondary)
-2.3% [-3.4%, -0.7%] 5
All ❌✅ (primary) -0.2% [-1.1%, 1.2%] 3

Binary size

Results (secondary -0.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.0% [-0.0%, -0.0%] 1
All ❌✅ (primary) - - 0

Bootstrap: 463.343s -> 462.05s (-0.28%)
Artifact size: 372.24 MiB -> 372.27 MiB (0.01%)

tautschnig added a commit to tautschnig/kani that referenced this pull request Jul 4, 2025
Relevant upstream PRs:
- rust-lang/rust#143214 (Remove let_chains
  unstable feature)
- rust-lang/rust#143036 (Remove support for
  `dyn*` from the compiler)

The latter was tracked as an unsupported feature in Kani, whereby we can
resolve one of our own issues as well.

Resolves: model-checking#4196
Resolves: model-checking#1784
github-merge-queue bot pushed a commit to model-checking/kani that referenced this pull request Jul 10, 2025
Relevant upstream PRs:
- rust-lang/rust#143214 (Remove let_chains
unstable feature)
- rust-lang/rust#143036 (Remove support for
`dyn*` from the compiler)

The latter was tracked as an unsupported feature in Kani, whereby we can
resolve one of our own issues as well.

Resolves: #4196
Resolves: #1784

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 and MIT licenses.
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request Jul 10, 2025
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#139858 (New const traits syntax)
 - rust-lang/rust#140809 (Reduce special casing for the panic runtime)
 - rust-lang/rust#142730 (suggest declaring modules when file found but module not defined)
 - rust-lang/rust#142806 (Normalize before computing ConstArgHasType goal in new solver)
 - rust-lang/rust#143046 (const validation: properly ignore zero-sized UnsafeCell)
 - rust-lang/rust#143092 (const checks for lifetime-extended temporaries: avoid 'top-level scope' terminology)
 - rust-lang/rust#143096 (tag_for_variant: properly pass TypingEnv)
 - rust-lang/rust#143104 (hir_analysis: prohibit `dyn PointeeSized`)
 - rust-lang/rust#143106 (gce: don't ICE on non-local const)

Failed merges:

 - rust-lang/rust#143036 (Remove support for `dyn*` from the compiler)

r? `@ghost`
`@rustbot` modify labels: rollup
flip1995 pushed a commit to flip1995/rust that referenced this pull request Jul 10, 2025
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.
@fmease fmease mentioned this pull request Sep 17, 2025
fmease added a commit to fmease/rust that referenced this pull request Sep 18, 2025
Clean up `ty::Dynamic`

1. As a follow-up to PR rust-lang#143036, remove `DynKind` entirely.
2. Inside HIR ty lowering, consolidate modules `dyn_compatibility` and `lint` into `dyn_trait`
   * `dyn_compatibility` wasn't about dyn compatibility itself, it's about lowering trait object types
   * `lint` contained dyn-Trait-specific diagnostics+lints only
Zalathar added a commit to Zalathar/rust that referenced this pull request Sep 18, 2025
Clean up `ty::Dynamic`

1. As a follow-up to PR rust-lang#143036, remove `DynKind` entirely.
2. Inside HIR ty lowering, consolidate modules `dyn_compatibility` and `lint` into `dyn_trait`
   * `dyn_compatibility` wasn't about dyn compatibility itself, it's about lowering trait object types
   * `lint` contained dyn-Trait-specific diagnostics+lints only
rust-timer added a commit that referenced this pull request Sep 18, 2025
Rollup merge of #146664 - fmease:clean-up-dyn, r=jdonszelmann

Clean up `ty::Dynamic`

1. As a follow-up to PR #143036, remove `DynKind` entirely.
2. Inside HIR ty lowering, consolidate modules `dyn_compatibility` and `lint` into `dyn_trait`
   * `dyn_compatibility` wasn't about dyn compatibility itself, it's about lowering trait object types
   * `lint` contained dyn-Trait-specific diagnostics+lints only
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tidy Area: The tidy tool F-dyn_star `#![feature(dyn_star)]` merged-by-bors This PR was explicitly merged by bors. PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)
Projects
None yet