rust-vmm / vm-virtio

virtio implementation
Apache License 2.0
372 stars 89 forks source link

Relax implicit `Sized` trait bound for the `M` parameter of queue trait methods #152

Open alexandruag opened 2 years ago

alexandruag commented 2 years ago

Traits such as QueueStateT have many methods which take a generic M: GuestMemory type parameter, and expect a &M argument. However, due to how implicit trait bounds work in Rust, those M: GuestMemory are actually M: GuestMemory + Sized, even if M doesn't actually have to be Sized to pass a reference to it. Callers of these methods have to propagate the Sized bound to any type parameters they have standing for M, which makes things unnecessarily restrictive overall. Fix this by explicitly adding a + ?Sized negative bound where applicable for the M generic type parameter of queue traits.