-
- Notifications
You must be signed in to change notification settings - Fork 14.3k
Closed
Closed
Copy link
Labels
A-coherenceArea: CoherenceArea: CoherenceA-dyn-traitArea: trait objects, vtable layoutArea: trait objects, vtable layoutC-bugCategory: This is a bug.Category: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-highHigh priorityHigh priorityT-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.
Description
I tried this code:
trait Sup<T> { type Assoc; } impl<T> Sup<T> for () { type Assoc = T; } impl<T, U> Dyn<T, U> for () {} trait Dyn<A, B>: Sup<A, Assoc = A> + Sup<B, Assoc = B> {} trait Trait { type Assoc; } impl Trait for dyn Dyn<(), ()> { type Assoc = &'static str; } impl<A, B> Trait for dyn Dyn<A, B> { type Assoc = usize; } fn call<A, B>(x: usize) -> <dyn Dyn<A, B> as Trait>::Assoc { x } fn main() { let x: &'static str = call::<(), ()>(0xDEADBEEF); println!("{x}"); }I expected to see this happen: It does not work.
Instead, this happened: Segfault
Meta
rustc --version --verbose:
rustc 1.85.0-nightly (a47555110 2024-11-22) lcnrfmease and jieyouxu
Metadata
Metadata
Assignees
Labels
A-coherenceArea: CoherenceArea: CoherenceA-dyn-traitArea: trait objects, vtable layoutArea: trait objects, vtable layoutC-bugCategory: This is a bug.Category: This is a bug.I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-highHigh priorityHigh priorityT-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.
Type
Projects
Status
Completed