Skip to content

Commit e0b5a82

Browse files
committed
Make FilePermissions constructible from mode_t without requiring cast to u32
I didn't find anywhere that the previous impl is being used. This should fix the following error on platforms where libc::mode_t != u32, such as aarch64-apple-darwin (u16). error[E0308]: mismatched types --> library/std/src/sys/pal/unix/fs/tests.rs:61:64 | 61 | assert_eq!(format!("{:?}", FilePermissions::from_inner(libc::S_IFREG | mode)), expected); | --------------------------- ^^^^^^^^^^^^^^^^^^^^ expected `u32`, found `u16` | arguments to this function are incorrect | note: associated function defined here --> library/std/src/sys_common/mod.rs:80:8 | 80 | fn from_inner(inner: Inner) -> Self; | ^^^^^^^^^^ help: you can convert a `u16` to a `u32` | 61 | assert_eq!(format!("{:?}", FilePermissions::from_inner((libc::S_IFREG | mode).into())), expected);
1 parent aa4165b commit e0b5a82

File tree

1 file changed

+3
-3
lines changed
  • library/std/src/sys/pal/unix

1 file changed

+3
-3
lines changed

library/std/src/sys/pal/unix/fs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -685,9 +685,9 @@ impl fmt::Debug for FileType {
685685
}
686686
}
687687

688-
impl FromInner<u32> for FilePermissions {
689-
fn from_inner(mode: u32) -> FilePermissions {
690-
FilePermissions { mode: mode as mode_t }
688+
impl FromInner<mode_t> for FilePermissions {
689+
fn from_inner(mode: mode_t) -> FilePermissions {
690+
FilePermissions { mode }
691691
}
692692
}
693693

0 commit comments

Comments
 (0)