esp-rs / esp-idf-template

A "Hello, world!" template of a Rust binary crate for the ESP-IDF framework.
380 stars 45 forks source link

Error building; mismatched types #22

Closed alvra closed 2 years ago

alvra commented 2 years ago

When trying to build a project generated by this template for a ESP-32-C3-DevKitC-02, running the current latest nightly, I get the following errors.

I'm guessing the problem is it's somehow targeting x86_64-unknown-linux.

$ cargo generate --vcs none --git https://github.com/esp-rs/esp-idf-template cargo
⚠️   Unable to load config file: /home/username/.cargo/cargo-generate.toml
🤷   Project Name : esp32-test
🔧   Generating template ...
? 🤷   ESP-IDF native build version (v4.3.2 = previous stable, v4.4 = stable, v5✔ 🤷   ESP-IDF native build version (v4.3.2 = previous stable, v4.4 = stable, v5.0 = development; NOTE: applicable only with `cargo build --features native`) · v4.4
✔ 🤷   STD support · true
✔ 🤷   MCU · esp32c3
✔ 🤷   Rust toolchain (beware: nightly works only for esp32c3!) · nightly
[1/9]   Done: .cargo/config.toml
[2/9]   Done: .cargo
[3/9]   Done: .gitignore
[4/9]   Done: Cargo.toml
[5/9]   Done: build.rs
[6/9]   Done: rust-toolchain.toml
[7/9]   Done: sdkconfig.defaults
[8/9]   Done: src/main.rs
[9/9]   Done: src
🔧   Moving generated files into: `/tmp/esp-test`...
💡   Initializing a fresh Git repository
✨   Done! New project created /tmp/esp-test

$ cd esp32-test
$ cargo build
...
error[E0308]: mismatched types
   --> /home/username/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/os/unix/process.rs:166:33
    |
166 |         self.as_inner_mut().uid(id);
    |                                 ^^ expected `u16`, found `u32`
    |
help: you can convert a `u32` to a `u16` and panic if the converted value doesn't fit
    |
166 |         self.as_inner_mut().uid(id.try_into().unwrap());
    |                                   ++++++++++++++++++++

error[E0308]: mismatched types
   --> /home/username/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/os/unix/process.rs:175:33
    |
175 |         self.as_inner_mut().gid(id);
    |                                 ^^ expected `u16`, found `u32`
    |
help: you can convert a `u32` to a `u16` and panic if the converted value doesn't fit
    |
175 |         self.as_inner_mut().gid(id.try_into().unwrap());
    |                                   ++++++++++++++++++++

error[E0308]: mismatched types
   --> /home/username/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/os/unix/process.rs:184:36
    |
184 |         self.as_inner_mut().groups(groups);
    |                                    ^^^^^^ expected `u16`, found `u32`
    |
    = note: expected reference `&[u16]`
               found reference `&[u32]`

error[E0308]: mismatched types
   --> /home/username/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/unix/fd.rs:112:17
    |
112 |                 offset as i64,
    |                 ^^^^^^^^^^^^^ expected `i32`, found `i64`
    |
help: you can convert an `i64` to an `i32` and panic if the converted value doesn't fit
    |
112 |                 (offset as i64).try_into().unwrap(),
    |                 +             +++++++++++++++++++++

error[E0308]: mismatched types
   --> /home/username/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/unix/fd.rs:179:17
    |
179 |                 offset as i64,
    |                 ^^^^^^^^^^^^^ expected `i32`, found `i64`
    |
help: you can convert an `i64` to an `i32` and panic if the converted value doesn't fit
    |
179 |                 (offset as i64).try_into().unwrap(),
    |                 +             +++++++++++++++++++++

error[E0308]: mismatched types
   --> /home/username/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/unix/fs.rs:969:56
    |
969 |         let n = cvt(unsafe { lseek64(self.as_raw_fd(), pos, whence) })?;
    |                                                        ^^^ expected `i32`, found `i64`
    |
help: you can convert an `i64` to an `i32` and panic if the converted value doesn't fit
    |
969 |         let n = cvt(unsafe { lseek64(self.as_raw_fd(), pos.try_into().unwrap(), whence) })?;
    |                                                           ++++++++++++++++++++

For more information about this error, try `rustc --explain E0308`.
error: could not compile `std` due to 6 previous errors
warning: build failed, waiting for other jobs to finish...
MabezDev commented 2 years ago

Duplicate of https://github.com/rust-lang/rust/issues/95924