Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
alexandruag opened this issue Mar 11, 2022 · 0 comments
Assignees

Comments

@alexandruag
Copy link
Collaborator

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.

@alexandruag alexandruag self-assigned this Mar 11, 2022
alexandruag added a commit to alexandruag/vm-virtio that referenced this issue Mar 18, 2022
This commit also introduces a relaxation of the trait bound on the
generic type parameter `M` for `QueueStateT::avail_idx` (i.e. it no
longer has to be `Sized`, as it was implicitly the case before). This
change reduces the number of trait bounds that have to be explicitly
propagated to the newly introduced methods. We should apply a similar
update to the rest of the interface as well (tracked by rust-vmm#152).

Signed-off-by: Alexandru Agache <[email protected]>
alexandruag added a commit to alexandruag/vm-virtio that referenced this issue Mar 30, 2022
This commit also introduces a relaxation of the trait bound on the
generic type parameter `M` for `QueueStateT::avail_idx` (i.e. it no
longer has to be `Sized`, as it was implicitly the case before). This
change reduces the number of trait bounds that have to be explicitly
propagated to the newly introduced methods. We should apply a similar
update to the rest of the interface as well (tracked by rust-vmm#152).

Signed-off-by: Alexandru Agache <[email protected]>
jiangliu pushed a commit that referenced this issue Mar 30, 2022
This commit also introduces a relaxation of the trait bound on the
generic type parameter `M` for `QueueStateT::avail_idx` (i.e. it no
longer has to be `Sized`, as it was implicitly the case before). This
change reduces the number of trait bounds that have to be explicitly
propagated to the newly introduced methods. We should apply a similar
update to the rest of the interface as well (tracked by #152).

Signed-off-by: Alexandru Agache <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant