Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement the object-safety checks for arbitrary_self_types: part 1
For a trait method to be considered object-safe, the receiver type must satisfy certain properties: first, we need to be able to get the vtable to so we can look up the method, and second, we need to convert the receiver from the version where `Self=dyn Trait`, to the version where `Self=T`, `T` being some unknown, `Sized` type that implements `Trait`. To check that the receiver satisfies those properties, we use the following query: forall (U) { if (Self: Unsize<U>) { Receiver[Self => U]: CoerceSized<Receiver> } } where `Receiver` is the receiver type of the method (e.g. `Rc<Self>`), and `Receiver[Self => U]` is the receiver type where `Self = U`, e.g. `Rc<U>`. forall queries like this aren’t implemented in the trait system yet, so for now we are using a bit of a hack — see the code for explanation.
- Loading branch information
Showing
1 changed file
with
144 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters