rust-av / dav1d-rs

libdav1d rust bindings
MIT License
37 stars 16 forks source link

Clippy warns about `Arc<InnerPicture>` #95

Closed philn closed 6 months ago

philn commented 6 months ago
error: usage of an `Arc` that is not `Send` and `Sync`                                                                                                                                                             
   --> src/lib.rs:416:28                                                                                                                                                                                           
    |                                                                                                                                                                                                              
416 |                     inner: Arc::new(inner),                                                                                                                                                                  
    |                            ^^^^^^^^^^^^^^^                                                                                                                                                                   
    |                                                                                                                                                                                                              
    = note: `Arc<InnerPicture>` is not `Send` and `Sync` as:                                                                                                                                                       
    = note: - the trait `Send` is not implemented for `InnerPicture`                                                                                                                                               
    = note: - the trait `Sync` is not implemented for `InnerPicture`                                                                                                                                               
    = help: consider using an `Rc` instead. `Arc` does not provide benefits for non `Send` and `Sync` types                                                                                                        
    = note: if you intend to use `Arc` with `Send` and `Sync` traits                                                                                                                                               
    = note: wrap the inner type with a `Mutex` or implement `Send` and `Sync` for `InnerPicture`                                                                                                                   
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#arc_with_non_send_sync                                                                                         
    = note: `-D clippy::arc-with-non-send-sync` implied by `-D warnings`                                                                                                                                           
    = help: to override `-D warnings` add `#[allow(clippy::arc_with_non_send_sync)]`

We could either implement Send+Sync for InnerPicture, or wrap it in a Rc<>. afaik the picture data is immutable.

sdroege commented 6 months ago

Yes this can simply be Send+Sync. Preparing PR.

sdroege commented 6 months ago

Also I forgot to mention. The change the clippy suggested would've caused the Send+Sync impls on Picture / Plane to be wrong and usage of those types across threads would've been unsound.

lu-zero commented 6 months ago

Worth reporting, IMHO.