Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to Rust edition 2021 and version 1.56 #2568

Merged
merged 5 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ jobs:
cargo clippy -p test_readme &&
cargo clippy -p test_reserved &&
cargo clippy -p test_resources &&
cargo clippy -p test_return_handle &&
cargo clippy -p test_return_struct &&
cargo clippy -p test_riddle &&
cargo clippy -p test_simple_component &&
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ jobs:
cargo test -p test_does_not_return &&
cargo test -p test_enums &&
cargo test -p test_error &&
cargo clean &&
cargo test -p test_event &&
cargo clean &&
cargo test -p test_extensions &&
cargo test -p test_handles &&
cargo test -p test_helpers &&
Expand All @@ -116,6 +116,7 @@ jobs:
cargo test -p test_readme &&
cargo test -p test_reserved &&
cargo test -p test_resources &&
cargo test -p test_return_handle &&
cargo test -p test_return_struct &&
cargo test -p test_riddle &&
cargo test -p test_simple_component &&
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows-sys.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
name: Check
strategy:
matrix:
rust: [1.48.0, stable, nightly]
rust: [1.56.0, stable, nightly]
runs-on:
- windows-latest
- ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
name: Check
strategy:
matrix:
rust: [1.48.0, stable, nightly]
rust: [1.56.0, stable, nightly]
runs-on:
- windows-2019
- ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[workspace]
resolver = "2"
members = [
"crates/libs/*",
"crates/samples/windows-sys/*",
Expand Down
4 changes: 2 additions & 2 deletions crates/libs/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
name = "windows-core"
version = "0.50.0"
authors = ["Microsoft"]
edition = "2018"
edition = "2021"
license = "MIT OR Apache-2.0"
description = "Rust for Windows"
repository = "https://github.com/microsoft/windows-rs"
readme = "../../../docs/readme.md"
rust-version = "1.48"
rust-version = "1.56"
categories = ["os::windows-apis"]

[package.metadata.docs.rs]
Expand Down
11 changes: 1 addition & 10 deletions crates/libs/core/src/imp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub use sha1::*;
pub use waiter::*;
pub use weak_ref_count::*;

// This is a workaround since 1.48 does not include `bool::then_some`.
// This is a workaround since 1.56 does not include `bool::then_some`.
pub fn then_some<T>(value: bool, t: T) -> Option<T> {
if value {
Some(t)
Expand All @@ -29,15 +29,6 @@ pub fn then_some<T>(value: bool, t: T) -> Option<T> {
}
}

// This is a workaround since 1.48 does not include `bool::then`.
pub fn then<T, F: FnOnce() -> T>(value: bool, f: F) -> Option<T> {
if value {
Some(f())
} else {
None
}
}

pub fn wide_trim_end(mut wide: &[u16]) -> &[u16] {
while let Some(last) = wide.last() {
match last {
Expand Down
3 changes: 1 addition & 2 deletions crates/libs/core/src/strings/hstring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ impl HSTRING {

fn get_header(&self) -> Option<&Header> {
if let Some(header) = &self.0 {
// TODO: this can be replaced with `as_ref` in future: https://github.com/rust-lang/rust/issues/91822
unsafe { Some(&*(header.as_ptr() as *const Header)) }
unsafe { Some(header.as_ref()) }
} else {
None
}
Expand Down
2 changes: 1 addition & 1 deletion crates/libs/implement/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "windows-implement"
version = "0.48.0"
authors = ["Microsoft"]
edition = "2018"
edition = "2021"
license = "MIT OR Apache-2.0"
description = "The implement macro for the windows crate"
repository = "https://github.com/microsoft/windows-rs"
Expand Down
2 changes: 1 addition & 1 deletion crates/libs/implement/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub fn implement(attributes: proc_macro::TokenStream, original_type: proc_macro:

let tokens = quote! {
#[repr(C)]
struct #impl_ident#generics where #constraints {
struct #impl_ident #generics where #constraints {
identity: *const ::windows::core::IInspectable_Vtbl,
vtables: (#(*const #vtbl_idents,)*),
this: #original_ident::#generics,
Expand Down
2 changes: 1 addition & 1 deletion crates/libs/interface/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "windows-interface"
version = "0.48.0"
edition = "2018"
edition = "2021"
authors = ["Microsoft"]
license = "MIT OR Apache-2.0"
description = "The interface macro for the windows crate"
Expand Down
2 changes: 1 addition & 1 deletion crates/libs/metadata/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "windows-metadata"
version = "0.49.0"
authors = ["Microsoft"]
edition = "2018"
edition = "2021"
license = "MIT OR Apache-2.0"
description = "Windows metadata reader and writer"
repository = "https://github.com/microsoft/windows-rs"
Expand Down
4 changes: 2 additions & 2 deletions crates/libs/sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
name = "windows-sys"
version = "0.48.0"
authors = ["Microsoft"]
edition = "2018"
edition = "2021"
license = "MIT OR Apache-2.0"
description = "Rust for Windows"
repository = "https://github.com/microsoft/windows-rs"
readme = "../../../docs/readme.md"
rust-version = "1.48"
rust-version = "1.56"
categories = ["os::windows-apis"]

[package.metadata.docs.rs]
Expand Down
2 changes: 1 addition & 1 deletion crates/libs/targets/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
name = "windows-targets"
version = "0.48.1"
authors = ["Microsoft"]
edition = "2018"
edition = "2021"
license = "MIT OR Apache-2.0"
description = "Import libs for Windows"
repository = "https://github.com/microsoft/windows-rs"
Expand Down
4 changes: 2 additions & 2 deletions crates/libs/windows/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
name = "windows"
version = "0.48.0"
authors = ["Microsoft"]
edition = "2018"
edition = "2021"
license = "MIT OR Apache-2.0"
description = "Rust for Windows"
repository = "https://github.com/microsoft/windows-rs"
documentation = "https://microsoft.github.io/windows-docs-rs/"
readme = "../../../docs/readme.md"
rust-version = "1.48"
rust-version = "1.56"
categories = ["os::windows-apis"]

[package.metadata.docs.rs]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ where
{
::windows_targets::link!("msajapi.dll" "system" fn AllJoynConnectToBus(connectionspec : ::windows_core::PCWSTR) -> super::super::Foundation:: HANDLE);
let result__ = AllJoynConnectToBus(connectionspec.into_param().abi());
::windows_core::imp::then(!result__.is_invalid(), || result__).ok_or_else(::windows_core::Error::from_win32)
(!result__.is_invalid()).then(|| result__).ok_or_else(::windows_core::Error::from_win32)
}
#[doc = "*Required features: `\"Win32_Devices_AllJoyn\"`, `\"Win32_Foundation\"`, `\"Win32_Security\"`*"]
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security"))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ where
pub unsafe fn BluetoothFindFirstDevice(pbtsp: *const BLUETOOTH_DEVICE_SEARCH_PARAMS, pbtdi: *mut BLUETOOTH_DEVICE_INFO) -> ::windows_core::Result<HBLUETOOTH_DEVICE_FIND> {
::windows_targets::link!("bluetoothapis.dll" "system" fn BluetoothFindFirstDevice(pbtsp : *const BLUETOOTH_DEVICE_SEARCH_PARAMS, pbtdi : *mut BLUETOOTH_DEVICE_INFO) -> HBLUETOOTH_DEVICE_FIND);
let result__ = BluetoothFindFirstDevice(pbtsp, pbtdi);
::windows_core::imp::then(!result__.is_invalid(), || result__).ok_or_else(::windows_core::Error::from_win32)
(!result__.is_invalid()).then(|| result__).ok_or_else(::windows_core::Error::from_win32)
}
#[doc = "*Required features: `\"Win32_Devices_Bluetooth\"`, `\"Win32_Foundation\"`*"]
#[cfg(feature = "Win32_Foundation")]
#[inline]
pub unsafe fn BluetoothFindFirstRadio(pbtfrp: *const BLUETOOTH_FIND_RADIO_PARAMS, phradio: *mut super::super::Foundation::HANDLE) -> ::windows_core::Result<HBLUETOOTH_RADIO_FIND> {
::windows_targets::link!("bluetoothapis.dll" "system" fn BluetoothFindFirstRadio(pbtfrp : *const BLUETOOTH_FIND_RADIO_PARAMS, phradio : *mut super::super::Foundation:: HANDLE) -> HBLUETOOTH_RADIO_FIND);
let result__ = BluetoothFindFirstRadio(pbtfrp, phradio);
::windows_core::imp::then(!result__.is_invalid(), || result__).ok_or_else(::windows_core::Error::from_win32)
(!result__.is_invalid()).then(|| result__).ok_or_else(::windows_core::Error::from_win32)
}
#[doc = "*Required features: `\"Win32_Devices_Bluetooth\"`, `\"Win32_Foundation\"`*"]
#[cfg(feature = "Win32_Foundation")]
Expand Down
Loading