eurotools / eurochef

Rust crates and utilities for Eurocom EngineX(T) files.
MIT License
13 stars 2 forks source link

'Mismatched types' error when building eurochef-cli #29

Closed applecuckoo closed 6 months ago

applecuckoo commented 6 months ago

Hi! I was trying to install Eurochef, so I got Rust set up and ran cargo install --git https://github.com/eurotools/eurochef.git. I ended up with a mismatched types error which I have stored in this gist for brevity. From the debug log it seems that these two lines are problematic: https://github.com/eurotools/eurochef/blob/774c7c5d6e1029523b76a346f5b658fdfde54997/eurochef-edb/src/map.rs#L176 https://github.com/eurotools/eurochef/blob/774c7c5d6e1029523b76a346f5b658fdfde54997/eurochef-edb/src/anim.rs#L49 My guess is that these are simple bug fixes, but I won't send in a PR since I'm not fluent in Rust.

cohaereo commented 6 months ago

I can't reproduce this issue locally, can you run cargo version and send the output?

FYI there are binary releases available https://github.com/eurotools/eurochef/releases/tag/v0.0.1-beta%2B20230626144235

applecuckoo commented 6 months ago

Cargo version is 1.74.1 (ecb9851af 2023-10-18). Thanks for the binaries, but I use Linux so that's why I'm building from source.

cohaereo commented 6 months ago

Eurochef is meant to be compiled with the nightly rust toolchain. Try using that

rustup toolchain install nightly
rustup default nightly
applecuckoo commented 6 months ago

@cohaereo It's still erroring out:

error[E0308]: mismatched types
  --> eurochef-edb/src/anim.rs:49:48
   |
49 | ...rgs(&skin_data_ptr, parts_count))]
   |        ^^^^^^^^^^^^^^ expected `(&EXRelPtr, u32)`, found `&EXRelPtr`
   |
   = note:  expected tuple `(&EXRelPtr, u32)`
           found reference `&EXRelPtr`

error[E0308]: mismatched types
   --> eurochef-edb/src/anim.rs:49:43
    |
42  | #[binrw]
    | -------- arguments to this function are incorrect
...
49  |     #[br(parse_with(parse_late_skindata), args(&skin_data_ptr, parts_co...
    |                                           ^^^^ expected a tuple with 1 element, found one with 2 elements
    |
    = note: expected tuple `((&EXRelPtr, u32),)`
               found tuple `((&EXRelPtr, u32), u32)`
help: the return type of this call is `((&EXRelPtr, u32), u32)` due to the type of the argument passed
   --> eurochef-edb/src/anim.rs:42:1
    |
42  | #[binrw]
    | ^^^^^^^^
...
49  |     #[br(parse_with(parse_late_skindata), args(&skin_data_ptr, parts_co...
    |                                           ---- this argument influences the return type of `binrw`
note: function defined here
   --> /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/binrw-0.11.2/src/private.rs:107:8
    |
107 | pub fn parse_function_args_type_hint<R, Res, Args, F>(_: F, a: Args) ->...
    |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    = note: this error originates in the attribute macro `binrw` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0308]: mismatched types
   --> eurochef-edb/src/map.rs:174:51
    |
174 |     #[br(parse_with = parse_trigdata_values, args(trig_flags))]
    |                                                   ^^^^^^^^^^ expected `(u32,)`, found `u32`
    |
    = note: expected tuple `(u32,)`
                found type `u32`
help: use a trailing comma to create a tuple with one element
    |
174 |     #[br(parse_with = parse_trigdata_values, args((trig_flags,)))]
    |                                                   +          ++

error[E0308]: mismatched types
   --> eurochef-edb/src/map.rs:176:49
    |
176 |     #[br(parse_with = parse_trigdata_link, args(trig_flags))]
    |                                                 ^^^^^^^^^^ expected `(u32,)`, found `u32`
    |
    = note: expected tuple `(u32,)`
                found type `u32`
help: use a trailing comma to create a tuple with one element
    |
176 |     #[br(parse_with = parse_trigdata_link, args((trig_flags,)))]
    |                                                 +          ++

For more information about this error, try `rustc --explain E0308`.
   Compiling gltf v1.4.0
error: could not compile `eurochef-edb` (lib) due to 4 previous errors
warning: build failed, waiting for other jobs to finish...
error: failed to compile `eurochef-cli v0.1.0 (https://github.com/eurotools/eurochef.git#a2b6d502)`, intermediate artifacts can be found at `/tmp/cargo-installECAMjF`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.
cohaereo commented 6 months ago

Problem is I cannot reproduce this error. Applying the fixes your rustc is suggesting causes an error on my end.

cohaereo commented 6 months ago

Scratch that, I just managed to reproduce it by updating binrw. It seems like for some reason cargo pulled in a newer version of binrw (1.11.2) than specified in the project files (1.11.0). This means that the binrw maintainer performed a breaking change on a minor change version, shame on them 😕

Anyway, i'm going to update binrw and fix the issue

applecuckoo commented 6 months ago

I had a dig around and found the binrw changelog for 0.11.2 and there were only two 'bug fixes' mentioned. I'll leave it to you to decide if that qualifies as a bug fix :-)

cohaereo commented 6 months ago

@applecuckoo I've pushed the fix, try it now

applecuckoo commented 6 months ago

@cohaereo Welp, still doesn't work. Now it spits out 16 different errors! The log is here.

cohaereo commented 6 months ago

Your Rust installation seems to be downloading newer packages than the ones specified in the lock file.

cohaereo commented 6 months ago

Either way, I've updated the gltf package and fixed the build errors, try once more

applecuckoo commented 6 months ago

All I had to do was add the --locked flag and the build compiled without any errors. It does warn that warning: package 'hermit-abi v0.3.1' in Cargo.lock is yanked in registry 'crates-io', consider running without --locked. Should I be concerned?

cohaereo commented 6 months ago

Shouldn't be an issue if it compiled

applecuckoo commented 6 months ago

Alright then, I'll close the issue.