Skip to content

Receiver and DispatchFromDyn probably shouldn't be dyn-compatible? #149094

@theemathas

Description

@theemathas

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-dyn-compatibilityArea: Dyn compatibility (formerly: object safety)C-bugCategory: This is a bug.F-arbitrary_self_types`#![feature(arbitrary_self_types)]`F-dispatch_from_dyn`#![feature(dispatch_from_dyn)]`T-langRelevant to the language teamT-typesRelevant to the types team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions