Skip to content

Commit 2940ef8

Browse files
leon-xdleon-xd
andauthored
refactor: fix collapsable_if lint, rust 1.95 assert_matches destabilization (#643)
Fixes `collapsable_if` lint failing in CI pipelines. The `assert_matches` stabilization that was expected to ship with Rust 1.95.0 was [reverted from the 1.95 beta](rust-lang/rust#154999) due to an [inconsistency in temporary scoping behavior](rust-lang/rust#154406) between `assert_matches!`/`assert_eq!` and their `debug_` variants. We gated `assert_matches` usage based on the nightly compiler warning that the feature was "stable since 1.95.0" (see #612). Since the stabilization was reverted before the actual release, this gate now fires on stable 1.95 and tries to use an unstable API, breaking CI pipelines. This bumps the gate to `1.96.0`. Beta 1.96 currently still has `assert_matches` available, though that may change if the destabilization propagates. --------- Co-authored-by: leon-xd <leondu@microsoft.com>
1 parent 2b992bc commit 2940ef8

3 files changed

Lines changed: 18 additions & 18 deletions

File tree

crates/wdk-build/build.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ fn main() {
1414
// Custom attributes cannot be applied to expressions yet, so separate functions
1515
// are required for `rustversion` conditional compilation: https://github.com/rust-lang/rust/issues/15701
1616
// TODO: Remove the `setup_assert_matches_stabilized_cfg` feature and related
17-
// code once the minimum supported Rust version is 1.95.0 or later.
18-
#[rustversion::since(1.95.0)]
17+
// code once the minimum supported Rust version includes stable
18+
// `assert_matches`. Tracking issue:
19+
// https://github.com/rust-lang/rust/issues/82775
20+
#[rustversion::since(1.96.0)]
1921
fn setup_assert_matches_stabilized_cfg() {
2022
println!("cargo::rustc-cfg=assert_matches_stabilized");
2123
}
2224

23-
#[rustversion::before(1.95.0)]
25+
#[rustversion::before(1.96.0)]
2426
const fn setup_assert_matches_stabilized_cfg() {}

crates/wdk-build/src/bindgen.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,17 +159,15 @@ impl BuilderExt for Builder {
159159
impl ParseCallbacks for WdkCallbacks {
160160
fn generated_name_override(&self, item_info: ItemInfo) -> Option<String> {
161161
// Override the generated name for the WDF function table symbol, since bindgen is unable to currently translate the #define automatically: https://github.com/rust-lang/rust-bindgen/issues/2544
162-
if let Some(wdf_function_table_symbol_name) = &self.wdf_function_table_symbol_name {
163-
if let ItemInfo {
162+
if let Some(wdf_function_table_symbol_name) = &self.wdf_function_table_symbol_name
163+
&& let ItemInfo {
164164
name: item_name,
165165
kind: ItemKind::Var,
166166
..
167167
} = item_info
168-
{
169-
if item_name == wdf_function_table_symbol_name {
170-
return Some("WdfFunctions".to_string());
171-
}
172-
}
168+
&& item_name == wdf_function_table_symbol_name
169+
{
170+
return Some("WdfFunctions".to_string());
173171
}
174172
None
175173
}

crates/wdk-build/src/cargo_make.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -337,14 +337,14 @@ impl ParseCargoArgs for CompilationOptions {
337337
{
338338
"release" => {
339339
// cargo-make release profile sets the `--profile release` flag
340-
if let Some(profile) = &profile {
341-
if profile != "release" {
342-
eprintln!(
343-
"Specifying `--profile release` for cargo-make conflicts with the \
344-
setting `--profile {profile}` to forward to tasks"
345-
);
346-
std::process::exit(CLAP_USAGE_EXIT_CODE);
347-
}
340+
if let Some(profile) = &profile
341+
&& profile != "release"
342+
{
343+
eprintln!(
344+
"Specifying `--profile release` for cargo-make conflicts with the setting \
345+
`--profile {profile}` to forward to tasks"
346+
);
347+
std::process::exit(CLAP_USAGE_EXIT_CODE);
348348
}
349349

350350
append_to_space_delimited_env_var(

0 commit comments

Comments
 (0)