Closed
Description
trait Supertrait<T> {
fn _print_numbers(&self, mem: &[usize; 100]) {
println!("{mem:?}");
}
}
impl<T> Supertrait<T> for () {}
trait Trait<T, U>: Supertrait<T> + Supertrait<U> {
fn say_hello(&self, _: &usize) {
println!("Hello!");
}
}
impl<T, U> Trait<T, U> for () {}
fn main() {
(&() as &'static dyn for<'a> Trait<&'static (), &'a ()>
as &'static dyn Trait<&'static (), &'static ()>)
.say_hello(&0);
}
example output (shortened):
[0, 2338324182462507040, 7738151096083899748, 438881233243824, 439624262586284, 439667212259195, 439765996507179…
so apparently, we're calling _print_numbers
actually, because the vtable of dyn for<'a> Trait<&'static (), &'a ()>
and dyn Trait<&'static (), &'static ()>
aren't compatible.
@rustbot label I-unsound, T-compiler, A-trait-objects, A-coercions, A-higher-ranked
This code example is technically a regression, starting to misbehave somewhere between 1.55
and 1.56
(haven't further bisected yet…)
Metadata
Metadata
Assignees
Labels
Area: implicit and explicit `expr as Type` coercionsArea: trait objects, vtable layoutArea: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)Category: 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.Relevant to the types team, which will review and decide on the PR/issue.
Type
Projects
Status
Completed