Skip to content

0.9.9: error[E0308]: mismatched types #616

@yurivict

Description

@yurivict
error[E0308]: mismatched types
  --> src/fs/metadata.rs:85:55
   |
85 |                 let sflag = SFlag::from_bits_truncate(metadata_mode);
   |                             ------------------------- ^^^^^^^^^^^^^ expected `u16`, found `u32`
   |                             |
   |                             arguments to this function are incorrect
   |
note: associated function defined here
  --> /wrkdirs/usr/ports/sysutils/joshuto/work/joshuto-0.9.9/cargo-crates/nix-0.30.1/src/sys/stat.rs:14:1
   |
14 | / libc_bitflags!(
15 | |     /// "File type" flags for `mknod` and related functions.
16 | |     pub struct SFlag: mode_t {
17 | |         S_IFIFO;
...  |
26 | | );
   | |_^
   = note: this error originates in the macro `$crate::__impl_bitflags` which comes from the expansion of the macro `libc_bitflags` (in Nightly builds, run with -Z macro-backtrace for more info)
help: you can convert a `u32` to a `u16` and panic if the converted value doesn't fit
   |
85 |                 let sflag = SFlag::from_bits_truncate(metadata_mode.try_into().unwrap());
   |                                                                    ++++++++++++++++++++

error[E0308]: mismatched types
  --> src/fs/metadata.rs:91:53
   |
91 |                 let mode = Mode::from_bits_truncate(metadata_mode);
   |                            ------------------------ ^^^^^^^^^^^^^ expected `u16`, found `u32`
   |                            |
   |                            arguments to this function are incorrect
   |
note: associated function defined here
  --> /wrkdirs/usr/ports/sysutils/joshuto/work/joshuto-0.9.9/cargo-crates/nix-0.30.1/src/sys/stat.rs:28:1
   |
28 | / libc_bitflags! {
29 | |     /// "File mode / permissions" flags.
30 | |     pub struct Mode: mode_t {
31 | |         /// Read, write and execute for owner.
...  |
61 | | }
   | |_^
   = note: this error originates in the macro `$crate::__impl_bitflags` which comes from the expansion of the macro `libc_bitflags` (in Nightly builds, run with -Z macro-backtrace for more info)
help: you can convert a `u32` to a `u16` and panic if the converted value doesn't fit
   |
91 |                 let mode = Mode::from_bits_truncate(metadata_mode.try_into().unwrap());
   |                                                                  ++++++++++++++++++++

rust-1.91.1
FreeBSD 15 STABLE

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions