mozilla / mp4parse-rust

Parser for ISO Base Media Format aka video/mp4 written in Rust.
Mozilla Public License 2.0
404 stars 62 forks source link

Doesn't build with nightly #405

Closed johnrichardrinehart closed 1 year ago

johnrichardrinehart commented 1 year ago

Description

$ rustc --version                                                                       
rustc 1.71.0-nightly (ce5919fce 2023-05-15)
$ cargo --version      
cargo 1.71.0-nightly (13413c64f 2023-05-10)
error[E0277]: cannot multiply `u64` by `NonZeroU8`
    --> /home/john/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mp4parse-0.12.0/src/lib.rs:2547:62
     |
2547 |                 static_assertions::const_assert!(<$lhs>::MAX * <$rhs>::MAX <= <$output>::MAX);
     |                                                              ^ no implementation for `u64 * NonZeroU8`
...
2557 | impl_mul!((U8, std::num::NonZeroU8) => (U16, u16));
     | -------------------------------------------------- in this macro invocation
     |
     = help: the trait `Mul<NonZeroU8>` is not implemented for `u64`
     = help: the following other types implement trait `Mul<Rhs>`:
               <&'a u64 as Mul<u64>>
               <&u64 as Mul<&u64>>
               <u64 as Mul<&u64>>
               <u64 as Mul>
     = note: this error originates in the macro `impl_mul` (in Nightly builds, run with -Z macro-backtrace for more info)

note: erroneous constant used
    --> /home/john/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mp4parse-0.12.0/src/lib.rs:2557:1
     |
2557 | impl_mul!((U8, std::num::NonZeroU8) => (U16, u16));
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = note: this note originates in the macro `static_assertions::const_assert` which comes from the expansion of the macro `impl_mul` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: cannot multiply `u64` by `NonZeroU8`
    --> /home/john/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mp4parse-0.12.0/src/lib.rs:2547:62
     |
2547 |                 static_assertions::const_assert!(<$lhs>::MAX * <$rhs>::MAX <= <$output>::MAX);
     |                                                              ^ no implementation for `u64 * NonZeroU8`
...
2558 | impl_mul!((U32, std::num::NonZeroU8) => (U32MulU8, u64));
     | -------------------------------------------------------- in this macro invocation
     |
     = help: the trait `Mul<NonZeroU8>` is not implemented for `u64`
     = help: the following other types implement trait `Mul<Rhs>`:
               <&'a u64 as Mul<u64>>
               <&u64 as Mul<&u64>>
               <u64 as Mul<&u64>>
               <u64 as Mul>
     = note: this error originates in the macro `impl_mul` (in Nightly builds, run with -Z macro-backtrace for more info)

note: erroneous constant used
    --> /home/john/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mp4parse-0.12.0/src/lib.rs:2558:1
     |
2558 | impl_mul!((U32, std::num::NonZeroU8) => (U32MulU8, u64));
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = note: this note originates in the macro `static_assertions::const_assert` which comes from the expansion of the macro `impl_mul` (in Nightly builds, run with -Z macro-backtrace for more info)

Update: Some Cargo.toml hacking on my end fixed this. For nightly users, it'd be nice if a new release could be cut. It looks like it should ameliorate this.

For future readers: I had to add

 mp4parse = "0.12.0"

and

[patch.crates-io]
mp4parse = { path = "/some/dir/code/repos/forks/mp4parse-rust/mp4parse" }

to my Cargo.toml as an explicit dependency (this crate is only a transitive (grandchild) dependency for my project). Then, I had to patch this repo:

diff --git a/mp4parse/Cargo.toml b/mp4parse/Cargo.toml
index 05086a0..b950f9e 100644
--- a/mp4parse/Cargo.toml
+++ b/mp4parse/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "mp4parse"
-version = "0.17.0"
+version = "0.12.0"
 authors = [
   "Ralph Giles <giles@mozilla.com>",
   "Matthew Gregan <kinetik@flim.org>",
fintelia commented 1 year ago

The crates.io version doesn't compile on beta and will also break on stable once rustc 1.70 is released.

The underlying rustc change seems to be https://github.com/rust-lang/rust/issues/89065. It should be fixed by the patch in https://github.com/mozilla/mp4parse-rust/pull/376, but no version of mp4parse has been published to crates.io since that was merged.

johnrichardrinehart commented 1 year ago

Ah, you're right. Thanks for linking that. I can confirm that https://github.com/mozilla/mp4parse-rust/pull/376/commits/8d58b2d5fc7f552d585964354d8269bcca3d9251 (merged a long time ago) fixes the nightly build.