# HG changeset patch # User Raphaël Gomès # Date 1571235383 -10800 # Node ID 98d996a138defcb43e3f5bc27f159c5b277bd3ee # Parent 63d440bef72aa7e8c65783423ccce8130b810051 rust-cross-platform: remove `unimplemented!` to get compile-time errors We should get a compile-time error that there is missing functionality for the targeted platform instead of the program breaking at runtime. Differential Revision: https://phab.mercurial-scm.org/D7107 diff -r 63d440bef72a -r 98d996a138de rust/hg-core/src/utils/files.rs --- a/rust/hg-core/src/utils/files.rs Fri Oct 11 00:18:34 2019 -0700 +++ b/rust/hg-core/src/utils/files.rs Wed Oct 16 17:16:23 2019 +0300 @@ -21,12 +21,9 @@ use std::os::unix::ffi::OsStrExt; os_str = std::ffi::OsStr::from_bytes(bytes); } - #[cfg(windows)] - { - // TODO: convert from Windows MBCS (ANSI encoding) to WTF8. - // Perhaps, the return type would have to be Result. - unimplemented!() - } + // TODO Handle other platforms + // TODO: convert from WTF8 to Windows MBCS (ANSI encoding). + // Perhaps, the return type would have to be Result. Path::new(os_str) } diff -r 63d440bef72a -r 98d996a138de rust/hg-core/src/utils/hg_path.rs --- a/rust/hg-core/src/utils/hg_path.rs Fri Oct 11 00:18:34 2019 -0700 +++ b/rust/hg-core/src/utils/hg_path.rs Wed Oct 16 17:16:23 2019 +0300 @@ -258,11 +258,8 @@ use std::os::unix::ffi::OsStrExt; os_str = std::ffi::OsStr::from_bytes(&hg_path.as_ref().as_bytes()); } - #[cfg(windows)] - { - // TODO: convert from Windows MBCS (ANSI encoding) to WTF8. - unimplemented!(); - } + // TODO Handle other platforms + // TODO: convert from WTF8 to Windows MBCS (ANSI encoding). Ok(os_str.to_os_string()) } @@ -281,11 +278,9 @@ use std::os::unix::ffi::OsStrExt; buf = HgPathBuf::from_bytes(&os_string.as_ref().as_bytes()); } - #[cfg(windows)] - { - // TODO: convert from WTF8 to Windows MBCS (ANSI encoding). - unimplemented!(); - } + // TODO Handle other platforms + // TODO: convert from WTF8 to Windows MBCS (ANSI encoding). + buf.check_state()?; Ok(buf) } @@ -300,11 +295,9 @@ use std::os::unix::ffi::OsStrExt; buf = HgPathBuf::from_bytes(&os_str.as_bytes()); } - #[cfg(windows)] - { - // TODO: convert from WTF8 to Windows MBCS (ANSI encoding). - unimplemented!(); - } + // TODO Handle other platforms + // TODO: convert from WTF8 to Windows MBCS (ANSI encoding). + buf.check_state()?; Ok(buf) }