diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 2d06db9ace..a9fbd074aa 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -16,7 +16,7 @@ jobs: name: Check strategy: matrix: - rust: [1.56.0, stable, nightly] + rust: [1.62.0, stable, nightly] runs-on: - windows-2019 - ubuntu-latest diff --git a/crates/libs/core/Cargo.toml b/crates/libs/core/Cargo.toml index 7c4a333c56..76844d0374 100644 --- a/crates/libs/core/Cargo.toml +++ b/crates/libs/core/Cargo.toml @@ -3,7 +3,7 @@ name = "windows-core" version = "0.52.0" authors = ["Microsoft"] edition = "2021" -rust-version = "1.56" +rust-version = "1.62" license = "MIT OR Apache-2.0" description = "Rust for Windows" repository = "https://github.com/microsoft/windows-rs" diff --git a/crates/libs/core/src/imp/mod.rs b/crates/libs/core/src/imp/mod.rs index d5093fd2f3..1dd08527e1 100644 --- a/crates/libs/core/src/imp/mod.rs +++ b/crates/libs/core/src/imp/mod.rs @@ -20,15 +20,6 @@ pub use sha1::*; pub use waiter::*; pub use weak_ref_count::*; -// This is a workaround since 1.56 does not include `bool::then_some`. -pub fn then_some(value: bool, t: T) -> Option { - if value { - Some(t) - } else { - None - } -} - pub fn wide_trim_end(mut wide: &[u16]) -> &[u16] { while let Some(last) = wide.last() { match last { diff --git a/crates/libs/core/src/imp/weak_ref_count.rs b/crates/libs/core/src/imp/weak_ref_count.rs index 1f6a70a28a..30f25ea8f9 100644 --- a/crates/libs/core/src/imp/weak_ref_count.rs +++ b/crates/libs/core/src/imp/weak_ref_count.rs @@ -13,11 +13,11 @@ impl WeakRefCount { } pub fn add_ref(&self) -> u32 { - self.0.fetch_update(Ordering::Relaxed, Ordering::Relaxed, |count_or_pointer| then_some(!is_weak_ref(count_or_pointer), count_or_pointer + 1)).map(|u| u as u32 + 1).unwrap_or_else(|pointer| unsafe { TearOff::decode(pointer).strong_count.add_ref() }) + self.0.fetch_update(Ordering::Relaxed, Ordering::Relaxed, |count_or_pointer| bool::then_some(!is_weak_ref(count_or_pointer), count_or_pointer + 1)).map(|u| u as u32 + 1).unwrap_or_else(|pointer| unsafe { TearOff::decode(pointer).strong_count.add_ref() }) } pub fn release(&self) -> u32 { - self.0.fetch_update(Ordering::Release, Ordering::Relaxed, |count_or_pointer| then_some(!is_weak_ref(count_or_pointer), count_or_pointer - 1)).map(|u| u as u32 - 1).unwrap_or_else(|pointer| unsafe { + self.0.fetch_update(Ordering::Release, Ordering::Relaxed, |count_or_pointer| bool::then_some(!is_weak_ref(count_or_pointer), count_or_pointer - 1)).map(|u| u as u32 - 1).unwrap_or_else(|pointer| unsafe { let tear_off = TearOff::decode(pointer); let remaining = tear_off.strong_count.release(); @@ -222,7 +222,7 @@ impl TearOff { .fetch_update(Ordering::Acquire, Ordering::Relaxed, |count| { // Attempt to acquire a strong reference count to stabilize the object for the duration // of the `QueryInterface` call. - then_some(count != 0, count + 1) + bool::then_some(count != 0, count + 1) }) .map(|_| { // Let the object respond to the upgrade query. diff --git a/crates/libs/windows/Cargo.toml b/crates/libs/windows/Cargo.toml index 5a8f549a1c..b16b3c1e2c 100644 --- a/crates/libs/windows/Cargo.toml +++ b/crates/libs/windows/Cargo.toml @@ -4,7 +4,7 @@ name = "windows" version = "0.52.0" authors = ["Microsoft"] edition = "2021" -rust-version = "1.56" +rust-version = "1.62" license = "MIT OR Apache-2.0" description = "Rust for Windows" repository = "https://github.com/microsoft/windows-rs"