Currently, Receiver and DispatchFromDyn are dyn-compatible. This is a way to produce a type that implements those two traits without going through the "normal procedures" of making an impl. This is rather strange. Should we make them dyn-incompatible?
As far as I can tell, I can't cause ICEs or unsoundness with this. dyn Receiver seems to function "correctly", such as in the below code, which compiles and runs without errors:
#![feature(arbitrary_self_types)]
use std::ops::Receiver;
trait Trait {
fn foo(self: &dyn Receiver<Target=Self>);
}
struct Thing;
impl Trait for Thing {
fn foo(self: &dyn Receiver<Target=Self>) {
println!("huh???");
}
}
fn main() {
let x = Box::new(Thing);
let y: &dyn Receiver<Target=Thing> = &x;
y.foo();
}
Meanwhile, my attempt to abuse dyn DispatchFromDyn merely caused a cycle error due to the type ouroboros required.
cc @dingxiangfei2009
Meta
Tested on the playground with version 1.93.0-nightly (2025-11-18 3d461af2a23456a2676a)
Currently,
ReceiverandDispatchFromDynare dyn-compatible. This is a way to produce a type that implements those two traits without going through the "normal procedures" of making animpl. This is rather strange. Should we make them dyn-incompatible?As far as I can tell, I can't cause ICEs or unsoundness with this.
dyn Receiverseems to function "correctly", such as in the below code, which compiles and runs without errors:Meanwhile, my attempt to abuse
dyn DispatchFromDynmerely caused a cycle error due to the type ouroboros required.cc @dingxiangfei2009
Meta
Tested on the playground with version
1.93.0-nightly (2025-11-18 3d461af2a23456a2676a)