rust-lang / log

Logging implementation for Rust
https://docs.rs/log
Apache License 2.0
2.2k stars 254 forks source link

the trait bound `ValueBag<'_>: From<u128>` is not satisfied #500

Closed alecsavvy closed 2 years ago

alecsavvy commented 2 years ago

Hey! Let me know if i'm missing anything for issues or you need more details. This version of log is being pulled in from the lib-p2p lib and is having trouble compiling. I've tried manually updating the macro to add the Into implementation that it requires but it does seem to already be there. Not sure how to troubleshoot this further as it seems like the macro generation just isn't occurring. That's likely not the case, just symptoms.

You can see an implementation for u128 is needed: Into<ValueBag<'_>>` for `u128. In the macro_rules! it's clearly there so i'm not sure what's going on. (full error down below)

impl_to_value_primitive![
385 | |     usize, u8, u16, u32, u64, u128, isize, i8, i16, i32, i64, i128, f32, f64, char, bool,
386 | | ];

System: Macbook Pro 14in, 2021 Apple M1 Pro chip macOS Monterey v12.2.1

It may be possible this is due to the M1 chip but i'm not sure why. It does compile just fine on my intel and ryzen machines. Just a hunch though, I have no real evidence for that claim and it's the only distinct difference I can find at the moment.

Thanks!

❯ cargo build
   Compiling log v0.4.14
   Compiling futures-executor v0.3.21
error[E0277]: the trait bound `ValueBag<'_>: From<u128>` is not satisfied
   --> /Users/alecsavoy/.cargo/registry/src/github.com-1ecc6299db9ec823/log-0.4.14/src/kv/value.rs:364:21
    |
364 |                       Value::from_value_bag(value)
    |                       ^^^^^^^^^^^^^^^^^^^^^ the trait `From<u128>` is not implemented for `ValueBag<'_>`
...
384 | / impl_to_value_primitive![
385 | |     usize, u8, u16, u32, u64, u128, isize, i8, i16, i32, i64, i128, f32, f64, char, bool,
386 | | ];
    | |_- in this macro invocation
    |
    = help: the following implementations were found:
              <ValueBag<'v> as From<&'a ()>>
              <ValueBag<'v> as From<&'a bool>>
              <ValueBag<'v> as From<&'a char>>
              <ValueBag<'v> as From<&'a f32>>
            and 29 others
    = note: required because of the requirements on the impl of `Into<ValueBag<'_>>` for `u128`
note: required by a bound in `value::Value::<'v>::from_value_bag`
   --> /Users/alecsavoy/.cargo/registry/src/github.com-1ecc6299db9ec823/log-0.4.14/src/kv/value.rs:250:12
    |
248 |     fn from_value_bag<T>(value: T) -> Self
    |        -------------- required by a bound in this
249 |     where
250 |         T: Into<ValueBag<'v>>,
    |            ^^^^^^^^^^^^^^^^^^ required by this bound in `value::Value::<'v>::from_value_bag`
    = note: this error originates in the macro `impl_to_value_primitive` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `ValueBag<'_>: From<i128>` is not satisfied
   --> /Users/alecsavoy/.cargo/registry/src/github.com-1ecc6299db9ec823/log-0.4.14/src/kv/value.rs:364:21
    |
364 |                       Value::from_value_bag(value)
    |                       ^^^^^^^^^^^^^^^^^^^^^ the trait `From<i128>` is not implemented for `ValueBag<'_>`
...
384 | / impl_to_value_primitive![
385 | |     usize, u8, u16, u32, u64, u128, isize, i8, i16, i32, i64, i128, f32, f64, char, bool,
386 | | ];
    | |_- in this macro invocation
    |
    = help: the following implementations were found:
              <ValueBag<'v> as From<&'a ()>>
              <ValueBag<'v> as From<&'a bool>>
              <ValueBag<'v> as From<&'a char>>
              <ValueBag<'v> as From<&'a f32>>
            and 29 others
    = note: required because of the requirements on the impl of `Into<ValueBag<'_>>` for `i128`
note: required by a bound in `value::Value::<'v>::from_value_bag`
   --> /Users/alecsavoy/.cargo/registry/src/github.com-1ecc6299db9ec823/log-0.4.14/src/kv/value.rs:250:12
    |
248 |     fn from_value_bag<T>(value: T) -> Self
    |        -------------- required by a bound in this
249 |     where
250 |         T: Into<ValueBag<'v>>,
    |            ^^^^^^^^^^^^^^^^^^ required by this bound in `value::Value::<'v>::from_value_bag`
    = note: this error originates in the macro `impl_to_value_primitive` (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 `log` due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
error: build failed
Thomasdezeeuw commented 2 years ago

This is not something I've seen before. I see you're using v0.4.14, could you try upgrading to 0.4.16?

alecsavvy commented 2 years ago

That did seem to fix it, thanks! For anyone else who comes across this I had to patch the most recent version in.

[patch.crates-io]
log = { git = "https://github.com/rust-lang/log" }
Thomasdezeeuw commented 2 years ago

It should also be fixed in v0.4.16 so adding log to your dependencies should also fix it:

[dependencies]
log =  "0.4.16"
KodrAus commented 2 years ago

Sorry @alecsavvy. This is my bad. That library is an internal implementation detail of log that I gave too loose a version bound to in previous versions.

KodrAus commented 2 years ago

The latest patch of log has been out for a little while now that this should slowly become a non-issue so I'll go ahead and close this one now.