This code checks that receiver_is_dispatchable
is correctly implemented.
This is somewhat subtle. In general, we want to forbid
references to Self
in the argument and return types,
since the value of Self
is erased. However, there is one
exception: it is ok to reference Self
in order to access
an associated type of the current trait, since we retain
the value of those associated types in the object type
itself.
Returns Some(_)
if this item makes the containing trait dyn-incompatible.
Returns the dyn-compatibility violations that affect HIR ty lowering.
We say a method is vtable safe if it can be invoked on a trait
object. Note that object-safe traits can have some
non-vtable-safe methods, so long as they require Self: Sized
or
otherwise ensure that they cannot be used when Self = Trait
.
Creates the object type for the current trait. For example,
if the current trait is Deref
, then this will be
dyn Deref<Target = Self::Target> + 'static
.
Performs a type instantiation to produce the version of receiver_ty
when Self = self_ty
.
For example, for receiver_ty = Rc<Self>
and self_ty = Foo
, returns Rc<Foo>
.
Checks the method’s receiver (the self
argument) can be dispatched on when Self
is a
trait object. We require that DispatchableFromDyn
be implemented for the receiver type
in the following way:
Returns Some(_)
if this method cannot be called on a trait
object; this does not necessarily imply that the enclosing trait
is dyn-incompatible, because the method might have a where clause
Self: Sized
.