Skip to content

Commit a51c494

Browse files
committed
Auto merge of rust-lang#143036 - compiler-errors:no-dyn-star, r=oli-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.
2 parents 4793fd1 + eeaa63f commit a51c494

File tree

1 file changed

+0
-4
lines changed

1 file changed

+0
-4
lines changed

clippy_utils/src/qualify_min_const_fn.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,6 @@ fn check_rvalue<'tcx>(
175175
Rvalue::Cast(CastKind::PointerExposeProvenance, _, _) => {
176176
Err((span, "casting pointers to ints is unstable in const fn".into()))
177177
},
178-
Rvalue::Cast(CastKind::PointerCoercion(PointerCoercion::DynStar, _), _, _) => {
179-
// FIXME(dyn-star)
180-
unimplemented!()
181-
},
182178
Rvalue::Cast(CastKind::Transmute, _, _) => Err((
183179
span,
184180
"transmute can attempt to turn pointers into integers, so is unstable in const fn".into(),

0 commit comments

Comments
 (0)