-
Notifications
You must be signed in to change notification settings - Fork 14k
Open
Labels
A-dyn-compatibilityArea: Dyn compatibility (formerly: object safety)Area: Dyn compatibility (formerly: object safety)C-bugCategory: This is a bug.Category: This is a bug.F-arbitrary_self_types`#![feature(arbitrary_self_types)]``#![feature(arbitrary_self_types)]`F-dispatch_from_dyn`#![feature(dispatch_from_dyn)]``#![feature(dispatch_from_dyn)]`T-langRelevant to the language teamRelevant to the language teamT-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.This issue may need triage. Remove it if it has been sufficiently triaged.
Description
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.
Meta
Tested on the playground with version 1.93.0-nightly (2025-11-18 3d461af2a23456a2676a)
Metadata
Metadata
Assignees
Labels
A-dyn-compatibilityArea: Dyn compatibility (formerly: object safety)Area: Dyn compatibility (formerly: object safety)C-bugCategory: This is a bug.Category: This is a bug.F-arbitrary_self_types`#![feature(arbitrary_self_types)]``#![feature(arbitrary_self_types)]`F-dispatch_from_dyn`#![feature(dispatch_from_dyn)]``#![feature(dispatch_from_dyn)]`T-langRelevant to the language teamRelevant to the language teamT-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.This issue may need triage. Remove it if it has been sufficiently triaged.