rust: fix build errors on darwin
authorDan Villiom Podlaski Christiansen <danchr@gmail.com>
Thu, 30 Dec 2021 13:25:44 +0100
changeset 48525 d6c53b40b078
parent 48524 6bd42f9bc97e
child 48526 04688c51f81f
rust: fix build errors on darwin I'm not all _that_ versed in Rust, but I think the root cause is that some constants are u16 rather than u32 on Darwin. I checked that the code still compiles on the latest Ubuntu. Differential Revision: https://phab.mercurial-scm.org/D11955
rust/hg-core/src/dirstate_tree/on_disk.rs
--- a/rust/hg-core/src/dirstate_tree/on_disk.rs	Tue Jan 04 14:21:22 2022 -0500
+++ b/rust/hg-core/src/dirstate_tree/on_disk.rs	Thu Dec 30 13:25:44 2021 +0100
@@ -399,7 +399,7 @@
         } else {
             0o644
         };
-        file_type | permisions
+        (file_type | permisions).into()
     }
 
     fn mtime(&self) -> Result<TruncatedTimestamp, DirstateV2ParseError> {
@@ -505,8 +505,8 @@
         flags.set(Flags::P1_TRACKED, p1_tracked);
         flags.set(Flags::P2_INFO, p2_info);
         let size = if let Some((m, s)) = mode_size_opt {
-            let exec_perm = m & libc::S_IXUSR != 0;
-            let is_symlink = m & libc::S_IFMT == libc::S_IFLNK;
+            let exec_perm = m & (libc::S_IXUSR as u32) != 0;
+            let is_symlink = m & (libc::S_IFMT as u32) == libc::S_IFLNK as u32;
             flags.set(Flags::MODE_EXEC_PERM, exec_perm);
             flags.set(Flags::MODE_IS_SYMLINK, is_symlink);
             flags.insert(Flags::HAS_MODE_AND_SIZE);