rust/compiler/rustc_borrowck/src
bors 085c24790e Auto merge of #143036 - compiler-errors:no-dyn-star, r=oli-obk
Remove support for `dyn*` from the compiler

This PR removes support for `dyn*` (https://github.com/rust-lang/rust/issues/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](https://github.com/rust-lang/rust/issues/102425#issuecomment-1712604409) 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/rust#102425.

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

Closes rust-lang/rust#116979.
Closes rust-lang/rust#119694.
Closes rust-lang/rust#134591.
Closes rust-lang/rust#104800.
2025-07-01 21:50:21 +00:00
..
constraints Move placeholder handling to a proper preprocessing step 2025-06-03 12:20:15 +02:00
diagnostics mir: Mark Statement and BasicBlockData as #[non_exhaustive] 2025-07-01 07:14:13 +08:00
polonius Use an enum for SCC representatives, plus other code review 2025-06-04 13:26:08 +02:00
region_infer Auto merge of #140466 - amandasystems:move-to-preprocessing-step, r=lcnr 2025-06-05 05:27:41 +00:00
type_check Remove support for dyn* 2025-07-01 19:00:21 +00:00
borrow_set.rs rename BitSet to DenseBitSet 2025-01-11 11:34:01 +00:00
borrowck_errors.rs Use closure parse code 2025-03-06 17:58:32 -03:00
consumers.rs borrowck typeck children together with their parent 2025-04-08 00:34:40 +02:00
dataflow.rs use MixedBitSet for borrows-in-scope computation 2025-06-13 18:01:32 +00:00
def_use.rs Visit place in BackwardIncompatibleDropHint statement 2025-04-13 22:01:54 +00:00
handle_placeholders.rs Use an enum for SCC representatives, plus other code review 2025-06-04 13:26:08 +02:00
lib.rs Init local_names lazily for borrowck diagnostics 2025-06-22 17:16:36 +01:00
member_constraints.rs Greatly simplify lifetime captures in edition 2024 2025-02-22 22:24:52 +00:00
nll.rs Auto merge of #140466 - amandasystems:move-to-preprocessing-step, r=lcnr 2025-06-05 05:27:41 +00:00
path_utils.rs remove borrowck duplicate of std::ops::ControlFlow 2025-01-01 12:13:33 +00:00
place_ext.rs Remove #[macro_use] extern crate tracing from rustc_borrowck. 2024-08-30 17:14:53 +10:00
places_conflict.rs Implement MIR, CTFE, and codegen for unsafe binders 2025-01-31 17:19:53 +00:00
prefixes.rs Implement MIR, CTFE, and codegen for unsafe binders 2025-01-31 17:19:53 +00:00
renumber.rs Squash fold into ty 2025-03-15 06:34:36 +00:00
root_cx.rs borrowck nested items in dead code 2025-05-02 18:45:28 +00:00
session_diagnostics.rs move check_opaque_type_parameter_valid 2025-04-03 11:13:10 +02:00
universal_regions.rs Replace some Option<Span> with Span and use DUMMY_SP instead of None 2025-06-05 14:14:59 +00:00
used_muts.rs Remove unnecessary lifetimes in dataflow structs. 2024-09-09 16:14:18 +10:00