Skip to content

incompletely relating alias args is unsound during vtable creation #140212

@lcnr

Description

@lcnr

cc #140211 the following snippet segfaults :3

trait Id { type This<'a>; } impl<T> Id for T { type This<'a> = T; } trait Trait<T> {} impl<T: Id> Trait<for<'a> fn(T::This<'a>)> for T {} trait Method<T: Id> { fn call_me(&self) where T: Trait<for<'a> fn(T::This<'a>)>; } impl<T, U> Method<U> for T { fn call_me(&self) {} } fn generic<T: Id>(x: &dyn Method<T>) { // Proving `T: Trait<for<'a> fn(T::This<'a>)>` holds. x.call_me(); } fn main() { // Proving `u32: Trait<fn(u32)>` fails due to incompleteness. // We don't add the method to the vtable of `dyn Method`, so // calling it causes UB. generic::<u32>(&()); }

Metadata

Metadata

Labels

I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessP-mediumMedium priorityT-typesRelevant to the types team, which will review and decide on the PR/issue.fixed-by-next-solverFixed by the next-generation trait solver, `-Znext-solver`.

Type

No type

Projects

Status

Completed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions