Closed
Description
Found in #57893 (comment)
trait SuperTrait {
type A;
type B;
}
trait Trait: SuperTrait<A = <Self as SuperTrait>::B> {}
fn transmute<A, B>(x: A) -> B {
// why does rustc not complain about
// the type `dyn Trait<A = A, B = B>` ?!?
foo::<A, B, dyn Trait<A = A, B = B>>(x)
}
fn foo<A, B, T: ?Sized>(x: T::A) -> B
where
T: Trait<B = B>,
{
x
}
static X: u8 = 0;
fn main() {
let x = transmute::<&u8, &[u8; 1_000_000]>(&X);
println!("{:?}", x[100_000]);
}
Errors:
Compiling playground v0.0.1 (/playground)
Finished dev [unoptimized + debuginfo] target(s) in 1.13s
Running `target/debug/playground`
timeout: the monitored command dumped core
/playground/tools/entrypoint.sh: line 11: 7 Segmentation fault timeout --signal=KILL ${timeout} "$@"
@rustbot modify labels: T-compiler, C-bug, A-traits, A-dst, A-associated-items, A-typesystem
and please add “I-unsound 💥”
Metadata
Metadata
Assignees
Labels
Area: Dynamically-sized types (DSTs)Area: Associated items (types, constants & functions)Area: Trait systemArea: Type systemCategory: This is a bug.Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessHigh priorityRelevant to the compiler team, which will review and decide on the PR/issue.