-
Notifications
You must be signed in to change notification settings - Fork 111
fix!: specify rust version & edition to wdk-default bindgen::builder #314
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
Conversation
|
I have created an issue to the Switching from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the project’s Rust version, edition handling, and bindgen configuration to align with Rust 2024 and the latest toolchain. Key changes include:
- Enhancements in crates/wdk-build/src/bindgen.rs to convert cargo_metadata editions to bindgen’s RustEdition and to set the rust target and edition on the builder.
- Updates to Cargo.toml and workspace manifests that bump dependency versions, update the resolver, and specify the MSRV.
- Adjustments to crates/wdk-sys and crates/wdk-build/src/cargo_make.rs to support the new nightly feature configuration and updated target kind checks.
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| crates/wdk-build/src/bindgen.rs | Introduced BindgenRustEditionWrapper, added get_rust_target and get_rust_edition functions, and updated builder configuration. |
| Cargo.toml | Upgraded dependency versions, updated resolver, and specified a new rust-version. |
| crates/wdk-sys/Cargo.toml | Expanded nightly feature configuration. |
| crates/wdk-build/src/lib.rs | Updated ConfigError variants with clearer error messages. |
| crates/wdk-build/Cargo.toml | Declared rust-version and semver workspace settings, and added nightly feature. |
| crates/wdk-build/src/cargo_make.rs | Modified target kind check for cdylib using cargo_metadata enum. |
Comments suppressed due to low confidence (2)
crates/wdk-build/src/bindgen.rs:190
- Consider adding unit tests for 'get_rust_target' to validate its behavior under both nightly and stable toolchain configurations, ensuring the correct Rust target is selected.
fn get_rust_target() -> Result<bindgen::RustTarget, ConfigError> {
crates/wdk-build/src/bindgen.rs:223
- Consider adding unit tests for 'get_rust_edition' to ensure that the conversion from cargo metadata editions to bindgen's RustEdition is handled correctly, including error cases for unsupported editions.
fn get_rust_edition() -> Result<bindgen::RustEdition, ConfigError> {
wmmc88
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the Rust toolchain configuration for wdk-build by specifying a new MSRV and Rust edition for bindgen, while updating several dependencies to support these changes. Key changes include:
- Bumping versions for rust-bindgen, cargo-metadata, semver, and thiserror, and adding MSRV via rust-version.
- Adding new logic to determine the Rust target and edition for bindgen in wdk-build.
- Adjusting dependencies in Cargo.toml files (including nightly features) to support the updated configuration.
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| crates/wdk-sys/Cargo.toml | Updated nightly dependencies to include wdk-build/nightly |
| crates/wdk-build/src/lib.rs | Added new error variants and updated error messages in ConfigError |
| crates/wdk-build/src/cargo_make.rs | Updated target matching to use cargo_metadata’s TargetKind enum |
| crates/wdk-build/src/bindgen.rs | Added functions for determining rust target/edition and adjusted builder usage |
| crates/wdk-build/Cargo.toml | Enabled rust-version and semver at the workspace level |
| Cargo.toml | Upgraded dependency versions and bumped resolver version |
Comments suppressed due to low confidence (2)
crates/wdk-build/src/bindgen.rs:194
- The documentation comment references
ConfigError::SemverErrorwhile the actual variant is namedRustVersionParseError. Update the comment to match the correct error variant.
// Returns `ConfigError::MsrvNotSupportedByBindgen` if the MSRV is not supported by bindgen, or `ConfigError::SemverError` if the MSRV cannot be parsed as a semver version.
crates/wdk-build/src/bindgen.rs:251
- [nitpick] The variable name 'wdk_sys_cargo_metadata' might be misleading as it pertains to the 'wdk-build' package. Consider renaming it to 'wdk_build_metadata' for clarity.
let wdk_sys_cargo_metadata = MetadataCommand::new().exec()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the rust-version and rust edition configuration for the wdk-default bindgen builder to support Rust 2024 features and enforce an updated MSRV.
- Specifies the rust version in Cargo manifests and adjusts the cargo resolver version.
- Updates dependencies (bindgen, cargo_metadata, semver, thiserror) to support new rust edition and nightly features.
- Enhances error handling and configuration in the wdk-build crate, including improved target and edition determination.
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| crates/wdk-sys/Cargo.toml | Updated the nightly feature list to also include wdk-build/nightly. |
| crates/wdk-build/src/lib.rs | Modified error variants and improved documentation for configuration errors. |
| crates/wdk-build/src/cargo_make.rs | Adjusted target kind comparison to use the cargo_metadata enum rather than raw string literal. |
| crates/wdk-build/src/bindgen.rs | Added functions for Rust target and edition retrieval with enhanced error handling. |
| crates/wdk-build/Cargo.toml | Introduced rust-version and semver workspace settings along with a new nightly feature. |
| Cargo.toml | Upgraded resolver and dependency versions to align with the new configuration settings. |
Comments suppressed due to low confidence (2)
crates/wdk-build/src/cargo_make.rs:980
- Ensure that the usage of cargo_metadata::TargetKind::CDyLib matches the expected target kind value, as this change from string comparison may lead to unexpected mismatches if the enum value differs from the previous literal.
.any(|target| target.kind.contains(&cargo_metadata::TargetKind::CDyLib))
crates/wdk-build/src/bindgen.rs:191
- The documentation references
ConfigError::SemverError, but the implemented variant isRustVersionParseError. Please update the documentation to reflect the correct error variant.
/// Returns `ConfigError::MsrvNotSupportedByBindgen` if the MSRV is not supported by bindgen, or `ConfigError::SemverError` if the MSRV cannot be parsed as a
…icrosoft#314) Signed-off-by: Leon Durrenberger <[email protected]> Co-authored-by: leon-xd <[email protected]>
BREAKING CHANGES:
rust-versionto virtual manifest, currently set to1.82.01.84.0Overview
With the introduction of Rust 2024,
bindgenimplemented new options for supporting different editions of Rust.bindgen's default behavior is to generate Rust code for the latest edition and toolchain.We need to overwrite this default behavior with whatever edition
wdk-builduses, as we would like to manually update from 2021 -> 2024. This PR also introduces logic to specify the rust version & toolchain tobindgen.Files changed
cargo.tomlrust-version, set to1.82.01.84.0resolverto3bindgento0.71.0forBuilder::rust-editioncargo-metadatato0.19.2forEdition::E2024semvercratethiserrorto2.0.12forcargo-metadataversion dependencycrates/wdk-build/cargo.tomlcrates/wdk-build/src/bindgen.rsimpl TryFromfor conversion betweencargo-metadataandbindgenrust edition enumsfn get_rust_targetdetermines proper rust version/toolchain forbindgenfn get_rust_editiondetermines proper rust edition forbindgenwdk_defaultcrates/wdk-build/src/cargo_make.rscargo-metadatacrates/wdk-build/src/lib.rsConfigErrorvariants for new errors thrown by updated code