diff --git a/Cargo.lock b/Cargo.lock index f545ba4785712..6ceab61897791 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5767,6 +5767,8 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" dependencies = [ "winapi", ] diff --git a/Cargo.toml b/Cargo.toml index fe3845cab3a59..862dea709237b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -109,7 +109,3 @@ path = "third_party/rust/mio-0.6.23" [patch.crates-io.prost-derive] path = "third_party/rust/prost-derive" - -# Patched to work around https://github.com/rust-lang/rust/issues/88576 -[patch.crates-io.winapi-util] -path = "third_party/rust/winapi-util" diff --git a/build/moz.configure/rust.configure b/build/moz.configure/rust.configure index b9d24654f89b4..6a3930ae96574 100644 --- a/build/moz.configure/rust.configure +++ b/build/moz.configure/rust.configure @@ -153,10 +153,10 @@ def cargo_info(cargo): ) -@depends(rustc_info, cargo_info) +@depends(rustc_info, cargo_info, target) @imports(_from="mozboot.util", _import="MINIMUM_RUST_VERSION") @imports(_from="textwrap", _import="dedent") -def rust_compiler(rustc_info, cargo_info): +def rust_compiler(rustc_info, cargo_info, target): if not rustc_info: die( dedent( @@ -203,6 +203,19 @@ def rust_compiler(rustc_info, cargo_info): ) ) + if target.kernel == "WINNT" and (version.major, version.minor) == (1, 56): + die( + dedent( + """\ + Rust compiler 1.56.* is not supported for Windows builds. + + Use a newer or an older version. + + See https://github.com/rust-lang/rust/issues/88576. + """ + ) + ) + if not cargo_info: die( dedent( diff --git a/third_party/rust/winapi-util/src/win.rs b/third_party/rust/winapi-util/src/win.rs index 6ad18ff588d0d..9c77c0da626be 100644 --- a/third_party/rust/winapi-util/src/win.rs +++ b/third_party/rust/winapi-util/src/win.rs @@ -101,16 +101,13 @@ struct HandleRefInner(Option); impl Drop for HandleRefInner { fn drop(&mut self) { - self.0.take().map(|f| f.into_raw_handle()); + self.0.take().unwrap().into_raw_handle(); } } impl AsRawHandle for HandleRef { fn as_raw_handle(&self) -> RawHandle { - match (self.0).0.as_ref() { - Some(f) => f.as_raw_handle(), - None => std::ptr::null_mut(), - } + self.as_file().as_raw_handle() } } @@ -162,11 +159,7 @@ impl HandleRef { /// is a valid handle. The caller must ensure this is true before invoking /// this constructor. pub unsafe fn from_raw_handle(handle: RawHandle) -> HandleRef { - HandleRef(HandleRefInner(if handle.is_null() { - None - } else { - Some(File::from_raw_handle(handle)) - })) + HandleRef(HandleRefInner(Some(File::from_raw_handle(handle)))) } /// Return this handle as a standard `File` reference.