Closed as duplicate of#57893
Closed as duplicate of#57893
Description
I tried this code:
use std::fmt::Display;
trait Trait{
type Associated;
}
impl<T: ?Sized> Trait for T {
type Associated = Box<dyn Display>;
}
fn foo<T: ?Sized>(_: <T as Trait>::Associated) {}
fn main() {
let x = "Hello World".to_string();
foo::<dyn Trait<Associated = &str>>( &x );
}
I expected to see this happen: mismatched types:expected “Box<dyn Display>”, found “&str”.
Instead, this happened: The code compiles successfully but encounters a segmentation fault at runtime.
Program returned: 139
Program stderr
Program terminated with signal: SIGSEGV
Demo: godbolt permalink
Demo: on current playground
Meta
rustc --version --verbose
:
rustc 1.88.0-nightly (0fe8f3454 2025-04-10)
Metadata
Metadata
Assignees
Labels
Area: Type systemCategory: This is a bug.Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustcIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.