zakarumych / gpu-alloc

Implementation agnostic memory allocator for Vulkan-like APIs
Other
86 stars 18 forks source link

the trait bound `&mut u32: Value` is not satisfied #56

Closed 0x57e11a closed 3 years ago

0x57e11a commented 3 years ago

I'm using this crate from a dependency (iced -> iced_wgpu -> wgpu -> wgpu-core -> gpu-alloc), and am getting an issue trying to compile my project, during compilation, the following errors are thrown in gpu-alloc:

   Compiling gpu-alloc v0.3.0
error[E0277]: the trait bound `&mut u32: Value` is not satisfied
   --> C:\Users\boop\.cargo\registry\src\github.com-1ecc6299db9ec823\gpu-alloc-0.3.0\src\buddy.rs:317:37
    |
317 |     #[cfg_attr(feature = "tracing", tracing::instrument(skip(self, device)))]
    |                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |                                     |
    |                                     the trait `Value` is not implemented for `&mut u32`
    |                                     help: consider removing the leading `&`-reference
    |
    = help: the following implementations were found:
              <u32 as Value>
    = note: `Value` is implemented for `&u32`, but not for `&mut u32`
    = note: required for the cast to the object type `dyn Value`
    = note: this error originates in the macro `$crate::valueset` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `&mut u32: Value` is not satisfied
   --> C:\Users\boop\.cargo\registry\src\github.com-1ecc6299db9ec823\gpu-alloc-0.3.0\src\buddy.rs:422:37
    |
422 |     #[cfg_attr(feature = "tracing", tracing::instrument(skip(self, device)))]
    |                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |                                     |
    |                                     the trait `Value` is not implemented for `&mut u32`
    |                                     help: consider removing the leading `&`-reference
    |
    = help: the following implementations were found:
              <u32 as Value>
    = note: `Value` is implemented for `&u32`, but not for `&mut u32`
    = note: required for the cast to the object type `dyn Value`
    = note: this error originates in the macro `$crate::valueset` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `&mut u32: Value` is not satisfied
  --> C:\Users\boop\.cargo\registry\src\github.com-1ecc6299db9ec823\gpu-alloc-0.3.0\src\linear.rs:83:37
   |
83 |     #[cfg_attr(feature = "tracing", tracing::instrument(skip(self, device)))]
   |                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |                                     |
   |                                     the trait `Value` is not implemented for `&mut u32`
   |                                     help: consider removing the leading `&`-reference
   |
   = help: the following implementations were found:
             <u32 as Value>
   = note: `Value` is implemented for `&u32`, but not for `&mut u32`
   = note: required for the cast to the object type `dyn Value`
   = note: this error originates in the macro `$crate::valueset` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `&mut u32: Value` is not satisfied
   --> C:\Users\boop\.cargo\registry\src\github.com-1ecc6299db9ec823\gpu-alloc-0.3.0\src\linear.rs:179:37
    |
179 |     #[cfg_attr(feature = "tracing", tracing::instrument(skip(self, device)))]
    |                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |                                     |
    |                                     the trait `Value` is not implemented for `&mut u32`
    |                                     help: consider removing the leading `&`-reference
    |
    = help: the following implementations were found:
              <u32 as Value>
    = note: `Value` is implemented for `&u32`, but not for `&mut u32`
    = note: required for the cast to the object type `dyn Value`
    = note: this error originates in the macro `$crate::valueset` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0277`.        
error: could not compile `gpu-alloc` due to 4 previous errors
warning: build failed, waiting for other jobs to finish...
error: build failed

If there's an obvious fix, I'm sorry, I'm newer to rust, so...

zakarumych commented 3 years ago

Hi! Thank you for reporting the issue. I found that tracing::Value is implemented for &mut T where T: Value which means it is implemented for &mut u32. But this implementation was added only in tracing 0.1.27, published 11 days ago. Probably you can fix the issue by running cargo update to update all dependencies. Hopefully no other dependency would block tracing from updating.

In the same time I should specify tracing 0.1.27 as minimal supporting version so that others would not hit same issue again.

0x57e11a commented 3 years ago

It appears iced_wgpu uses 0.7.1 instead of 0.10.2 😅

zakarumych commented 3 years ago

Yes. wgpu is version is bit outdated. But the problem is with tracing crate (actually tracing-core). Check what version of tracing-core is used. Look into Cargo.lock file. It should be at least 0.1.19. If lower - run cargo update. If that doesn't help - look what blocks the upgrade.