Why this trait can't be used as trait object

trait MemPool {
    fn allocate(self: Pin<&mut Self>) -> Result<*mut ListHead, bool>;
    fn deallocate(self: Pin<&mut Self>, head: *mut ListHead);
}

It seems this defination does not volatile the rules

Works for me.

Yes, I messed it up again

Seems it is a rust analyser issue,

the orignal defination is

trait MemPool {
    fn allocate(self: &mut Pin<&mut Self>) -> Result<*mut ListHead, bool>;
    fn deallocate(self: &mut Pin<&mut Self>, head: *mut ListHead);
}

and the error occurs, then I changed it to

trait MemPool {
    fn allocate(self: Pin<&mut Self>) -> Result<*mut ListHead, bool>;
    fn deallocate(self: Pin<&mut Self>, head: *mut ListHead);
}

while keep the implemetation untouched; the error continues -- not about the mismatch of the signature, but still not dynamic compitible.

1 Like

If the error is from rustc, it won't refresh until you save (assuming you have check-on-save enabled).