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

Improve error message on missing Immutable #1296

Open
3 tasks
Tracked by #251
joshlf opened this issue May 18, 2024 · 0 comments
Open
3 tasks
Tracked by #251

Improve error message on missing Immutable #1296

joshlf opened this issue May 18, 2024 · 0 comments
Labels
blocked-on-rust Blocked on a Rust feature landing or stabilizing

Comments

@joshlf
Copy link
Member

joshlf commented May 18, 2024

Progress

Original text

Per #1288 (comment):

The compiler errors when a type is missing Immutable are somewhat misleading, although I'm not sure there's much zerocopy can do about this. An example where the compiler recommends adding a reference rather than implementing Immutable (some were even more confusing than this):

error[E0277]: the trait bound `virtio::wl::CtrlVfdNewDmabuf: zerocopy::Immutable` is not satisfied                                          
   --> devices/src/virtio/wl.rs:317:20                                                                                                      
    |                                                                                                                                       
317 |         .write_obj(ctrl_vfd_new_dmabuf)                                                                                               
    |          --------- ^^^^^^^^^^^^^^^^^^^ the trait `zerocopy::Immutable` is not implemented for `virtio::wl::CtrlVfdNewDmabuf`          
    |          |                                                                                                                            
    |          required by a bound introduced by this call                                                                                  
    |                                                                                                                                       
note: required by a bound in `virtio::descriptor_utils::Writer::write_obj`                                                                  
   --> devices/src/virtio/descriptor_utils.rs:536:25                                                                                        
    |                                                                                                                                       
536 |     pub fn write_obj<T: Immutable + IntoBytes>(&mut self, val: T) -> io::Result<()> {                                                 
    |                         ^^^^^^^^^ required by this bound in `Writer::write_obj`                                                       
help: consider borrowing here                                                                                                               
    |                                                                                                                                       
317 |         .write_obj(&ctrl_vfd_new_dmabuf)                                                                                              
    |                    +                                                                                                                  
317 |         .write_obj(&mut ctrl_vfd_new_dmabuf)                                                                                          
    |                    ++++                                                

Taking the compiler's suggestion results in a different error with a recommendation to remove the reference (back to the original code).

It appears that this is a compiler issue: rust-lang/rust#130563

@joshlf joshlf mentioned this issue Jul 1, 2024
87 tasks
joshlf added a commit that referenced this issue Sep 19, 2024
joshlf added a commit that referenced this issue Sep 19, 2024
joshlf added a commit that referenced this issue Sep 19, 2024
joshlf added a commit that referenced this issue Sep 19, 2024
github-merge-queue bot pushed a commit that referenced this issue Sep 19, 2024
@joshlf joshlf added the blocked-on-rust Blocked on a Rust feature landing or stabilizing label Oct 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked-on-rust Blocked on a Rust feature landing or stabilizing
Projects
None yet
Development

No branches or pull requests

1 participant