Skip to content

Commit 92afdee

Browse files
authored
Fix clippy and formatting post-Rust 1.87. (#13)
Formatting-wise we've seen something similar in Rust-GPU, and it has to do with the adoption of `style_edition = "2024"` in `rustfmt.toml` before that had some "last-minute" changes. Hopefully CI passes with the change from nightly to stable (nightly was used due to rustfmt previously).
2 parents 5c42614 + 6015fd6 commit 92afdee

File tree

15 files changed

+185
-143
lines changed

15 files changed

+185
-143
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@ jobs:
1818
submodules: true
1919
- uses: actions-rs/toolchain@v1
2020
with:
21-
# FIXME(eddyb) `style_edition = "2024"` in `rustfmt.toml` is what keeps
22-
# this on `nightly`, should switch to `stable` when that stabilizes.
23-
toolchain: nightly
24-
# HACK(eddyb) use `nightly` by default without breaking the ability to
21+
toolchain: stable
22+
# HACK(eddyb) use `stable` by default without breaking the ability to
2523
# temporarily bypass it through `rust-toolchain.toml`.
2624
default: true
2725
override: false
@@ -63,7 +61,7 @@ jobs:
6361
override: true
6462
# NOTE(eddyb) this is the simplest way found so far to get `glslang`.
6563
- name: Prepare Vulkan SDK
66-
uses: humbletim/[email protected].0
64+
uses: humbletim/[email protected].1
6765
with:
6866
vulkan-query-version: 1.3.250.0
6967
vulkan-components: Glslang SPIRV-Tools

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fn main() {
77
std::env::current_dir().unwrap().join("khronos-spec/SPIRV-Headers/include/spirv/unified1");
88
println!("cargo:rerun-if-changed={}", khr_spv_include_dir.display());
99

10-
if !std::fs::metadata(&khr_spv_include_dir).map_or(false, |m| m.is_dir()) {
10+
if !std::fs::metadata(&khr_spv_include_dir).is_ok_and(|m| m.is_dir()) {
1111
eprintln!(" error: {} is not a directory", khr_spv_include_dir.display());
1212
eprintln!(" help: git submodules are required to build from a git checkout");
1313
eprintln!(" help: run `git submodule update --init`");

src/cfg.rs

Lines changed: 52 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,20 @@ impl ControlFlowGraph {
8484
func_def_body: &FuncDefBody,
8585
) -> impl DoubleEndedIterator<Item = Region> {
8686
let mut post_order = SmallVec::<[_; 8]>::new();
87-
self.traverse_whole_func(func_def_body, &mut TraversalState {
88-
incoming_edge_counts: EntityOrientedDenseMap::new(),
87+
self.traverse_whole_func(
88+
func_def_body,
89+
&mut TraversalState {
90+
incoming_edge_counts: EntityOrientedDenseMap::new(),
8991

90-
pre_order_visit: |_| {},
91-
post_order_visit: |region| post_order.push(region),
92+
pre_order_visit: |_| {},
93+
post_order_visit: |region| post_order.push(region),
9294

93-
// NOTE(eddyb) this doesn't impact semantics, but combined with
94-
// the final reversal, it should keep targets in the original
95-
// order in the cases when they didn't get deduplicated.
96-
reverse_targets: true,
97-
});
95+
// NOTE(eddyb) this doesn't impact semantics, but combined with
96+
// the final reversal, it should keep targets in the original
97+
// order in the cases when they didn't get deduplicated.
98+
reverse_targets: true,
99+
},
100+
);
98101
post_order.into_iter().rev()
99102
}
100103
}
@@ -906,10 +909,13 @@ impl DeferredEdgeBundleSet {
906909
Err(new_deferred) => {
907910
assert!(new_deferred.edge_bundle.target == target);
908911
assert!(matches!(new_deferred.condition, LazyCond::True));
909-
(None, DeferredEdgeBundleSet::Always {
910-
target,
911-
edge_bundle: new_deferred.edge_bundle.with_target(()),
912-
})
912+
(
913+
None,
914+
DeferredEdgeBundleSet::Always {
915+
target,
916+
edge_bundle: new_deferred.edge_bundle.with_target(()),
917+
},
918+
)
913919
}
914920
}
915921
}
@@ -918,14 +924,17 @@ impl DeferredEdgeBundleSet {
918924
for (i, (&target, deferred)) in target_to_deferred.iter_mut().enumerate() {
919925
// HACK(eddyb) "take" `deferred` so it can be passed to
920926
// `matches` (and put back if that returned `Err`).
921-
let taken_deferred = mem::replace(deferred, DeferredEdgeBundle {
922-
condition: LazyCond::False,
923-
edge_bundle: IncomingEdgeBundle {
924-
target: Default::default(),
925-
accumulated_count: Default::default(),
926-
target_inputs: Default::default(),
927+
let taken_deferred = mem::replace(
928+
deferred,
929+
DeferredEdgeBundle {
930+
condition: LazyCond::False,
931+
edge_bundle: IncomingEdgeBundle {
932+
target: Default::default(),
933+
accumulated_count: Default::default(),
934+
target_inputs: Default::default(),
935+
},
927936
},
928-
});
937+
);
929938

930939
match matches(taken_deferred.with_target(target)) {
931940
Ok(x) => {
@@ -1111,13 +1120,16 @@ impl<'a> Structurizer<'a> {
11111120
// in the general case (but special-cased because this is very
11121121
// close to being structurizable, just needs a bit of plumbing).
11131122
let mut control_inst_on_exit_from = EntityOrientedDenseMap::new();
1114-
control_inst_on_exit_from.insert(self.func_def_body.body, ControlInst {
1115-
attrs: AttrSet::default(),
1116-
kind: ControlInstKind::Unreachable,
1117-
inputs: [].into_iter().collect(),
1118-
targets: [].into_iter().collect(),
1119-
target_inputs: FxIndexMap::default(),
1120-
});
1123+
control_inst_on_exit_from.insert(
1124+
self.func_def_body.body,
1125+
ControlInst {
1126+
attrs: AttrSet::default(),
1127+
kind: ControlInstKind::Unreachable,
1128+
inputs: [].into_iter().collect(),
1129+
targets: [].into_iter().collect(),
1130+
target_inputs: FxIndexMap::default(),
1131+
},
1132+
);
11211133
self.func_def_body.unstructured_cfg = Some(ControlFlowGraph {
11221134
control_inst_on_exit_from,
11231135
loop_merge_to_loop_header: Default::default(),
@@ -1133,13 +1145,15 @@ impl<'a> Structurizer<'a> {
11331145

11341146
_ => {
11351147
// Repair all the regions that remain unclaimed, including the body.
1136-
let structurize_region_state = mem::take(&mut self.structurize_region_state)
1137-
.into_iter()
1138-
.chain([(self.func_def_body.body, StructurizeRegionState::Ready {
1139-
accumulated_backedge_count: IncomingEdgeCount::default(),
1148+
let structurize_region_state =
1149+
mem::take(&mut self.structurize_region_state).into_iter().chain([(
1150+
self.func_def_body.body,
1151+
StructurizeRegionState::Ready {
1152+
accumulated_backedge_count: IncomingEdgeCount::default(),
11401153

1141-
region_deferred_edges: func_body_deferred_edges,
1142-
})]);
1154+
region_deferred_edges: func_body_deferred_edges,
1155+
},
1156+
)]);
11431157
for (target, state) in structurize_region_state {
11441158
if let StructurizeRegionState::Ready { region_deferred_edges, .. } = state {
11451159
self.rebuild_cfg_from_unclaimed_region_deferred_edges(
@@ -1537,11 +1551,13 @@ impl<'a> Structurizer<'a> {
15371551
.map(|backedge| backedge.accumulated_count)
15381552
.unwrap_or_default();
15391553

1540-
let old_state =
1541-
self.structurize_region_state.insert(region, StructurizeRegionState::Ready {
1554+
let old_state = self.structurize_region_state.insert(
1555+
region,
1556+
StructurizeRegionState::Ready {
15421557
accumulated_backedge_count,
15431558
region_deferred_edges: deferred_edges,
1544-
});
1559+
},
1560+
);
15451561
if !matches!(old_state, Some(StructurizeRegionState::InProgress)) {
15461562
unreachable!(
15471563
"cfg::Structurizer::structurize_region: \

src/cfgssa.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,13 @@ impl<'a, BlockId: Copy + Eq + Hash, DefId: Copy + Eq + Hash, DefType: Copy>
228228
.map(|block_id| BlockIdx(self.def_map.blocks_by_id.get_index_of(&block_id).unwrap()));
229229

230230
if self.blocks[target_block_idx].preds.insert(source_block_idx) {
231-
self.add_uses_to(source_block_idx, AddUsesSource::PropagateBackwardsAcrossEdge {
232-
target: target_block_idx,
233-
only_dirty: false,
234-
});
231+
self.add_uses_to(
232+
source_block_idx,
233+
AddUsesSource::PropagateBackwardsAcrossEdge {
234+
target: target_block_idx,
235+
only_dirty: false,
236+
},
237+
);
235238
}
236239
}
237240

@@ -240,10 +243,13 @@ impl<'a, BlockId: Copy + Eq + Hash, DefId: Copy + Eq + Hash, DefType: Copy>
240243
for i in 0..self.blocks[block_idx].preds.len() {
241244
let pred_block_idx = self.blocks[block_idx].preds[i];
242245

243-
self.add_uses_to(pred_block_idx, AddUsesSource::PropagateBackwardsAcrossEdge {
244-
target: block_idx,
245-
only_dirty: true,
246-
});
246+
self.add_uses_to(
247+
pred_block_idx,
248+
AddUsesSource::PropagateBackwardsAcrossEdge {
249+
target: block_idx,
250+
only_dirty: true,
251+
},
252+
);
247253
}
248254
self.blocks[block_idx].dirty_chunks.clear();
249255
}
@@ -452,6 +458,8 @@ mod data {
452458

453459
// HACK(eddyb) most of the need for this arises from avoidance of
454460
// `unsafe` code (i.e. `MaybeUninit<V>` could suffice in most cases).
461+
// FIXME(eddyb) figure out if keeping this around is useful at all.
462+
#[allow(unused)]
455463
pub enum WrapNonDefaultValueInOption {}
456464
impl<V> ValueStorage<V> for WrapNonDefaultValueInOption {
457465
type Slot = Option<V>;

src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
// HACK(eddyb) using `(struct.Context.html)` to link `Context`, not `context::Context`.
5252
//! * [`Context`](struct.Context.html): handles interning ([`Type`]s, [`Const`]s, etc.) and allocating entity handles
5353
//! * [`Module`]: owns [`Func`]s and [`GlobalVar`]s (rooted by [`exports`](Module::exports))
54-
//! * [`FuncDefBody`]: owns [`Region`]s and [DataInst]s (rooted by [`body`](FuncDefBody::body))
54+
//! * [`FuncDefBody`]: owns [`Region`]s and [`DataInst`]s (rooted by [`body`](FuncDefBody::body))
5555
//!
5656
//! ##### Utilities and passes
5757
//! * [`print`](mod@print): pretty-printer with (styled and hyperlinked) HTML output
@@ -99,7 +99,6 @@
9999
clippy::map_err_ignore,
100100
clippy::map_flatten,
101101
clippy::map_unwrap_or,
102-
clippy::match_on_vec_items,
103102
clippy::match_same_arms,
104103
clippy::match_wild_err_arm,
105104
clippy::match_wildcard_for_single_variants,

src/print/mod.rs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1824,9 +1824,10 @@ impl Print for spv::Dialect {
18241824
printer.pretty_spv_print_tokens_for_operand({
18251825
let mut tokens = spv::print::operand_from_imms(cap_imms(cap));
18261826
tokens.tokens.drain(..tokens.tokens.len() - 1);
1827-
assert!(matches!(tokens.tokens[..], [
1828-
spv::print::Token::EnumerandName(_)
1829-
]));
1827+
assert!(matches!(
1828+
tokens.tokens[..],
1829+
[spv::print::Token::EnumerandName(_)]
1830+
));
18301831
tokens
18311832
})
18321833
});
@@ -1955,8 +1956,12 @@ impl Print for spv::ModuleDebugInfo {
19551956
printer.pretty_string_literal(
19561957
&printer.cx[file],
19571958
),
1958-
pretty::join_space(":", [printer
1959-
.pretty_string_literal(contents)]),
1959+
pretty::join_space(
1960+
":",
1961+
[printer.pretty_string_literal(
1962+
contents,
1963+
)],
1964+
),
19601965
])
19611966
})
19621967
.map(|entry| {
@@ -2597,7 +2602,7 @@ impl Print for ConstDef {
25972602
Some(format!("{float:?}")).filter(|s| {
25982603
s.parse::<FLOAT>()
25992604
.map(float_to_bits)
2600-
.map_or(false, |roundtrip_bits| roundtrip_bits == bits)
2605+
.is_ok_and(|roundtrip_bits| roundtrip_bits == bits)
26012606
})
26022607
}
26032608

@@ -3050,10 +3055,13 @@ impl Print for FuncAt<'_, Node> {
30503055
let (inputs_header, body_suffix) = if !inputs.is_empty() {
30513056
let input_decls_and_uses =
30523057
inputs.iter().enumerate().map(|(input_idx, input)| {
3053-
(input, Value::RegionInput {
3054-
region: *body,
3055-
input_idx: input_idx.try_into().unwrap(),
3056-
})
3058+
(
3059+
input,
3060+
Value::RegionInput {
3061+
region: *body,
3062+
input_idx: input_idx.try_into().unwrap(),
3063+
},
3064+
)
30573065
});
30583066
(
30593067
pretty::join_comma_sep(

src/print/multiversion.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ impl Versions<pretty::FragmentPostLayout> {
196196
.iter()
197197
.zip(anchor_aligner.merged_columns())
198198
.flat_map(|(&(_, repeat_count), column)| {
199-
iter::repeat(column).take(repeat_count)
199+
iter::repeat_n(column, repeat_count)
200200
})
201201
.peekable();
202202

@@ -246,7 +246,7 @@ impl Versions<pretty::FragmentPostLayout> {
246246
}
247247
line
248248
}
249-
other.map_or(false, |other| {
249+
other.is_some_and(|other| {
250250
strip_indents(line) != strip_indents(other)
251251
})
252252
};
@@ -518,10 +518,7 @@ impl<'a> AnchorAligner<'a> {
518518
// Figure out which side has to wait, to align an upcoming anchor.
519519
let (old_at_anchor, new_at_anchor) =
520520
next_anchor.map_or((false, false), |(anchor_old, anchor_new)| {
521-
(
522-
old_line_idx.map_or(false, |old| old == anchor_old),
523-
new_line_idx.map_or(false, |new| new == anchor_new),
524-
)
521+
(old_line_idx == Some(anchor_old), new_line_idx == Some(anchor_new))
525522
});
526523
let old_line = if old_at_anchor && !new_at_anchor {
527524
// Pausing "old", waiting for "new".

src/qptr/analyze.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ impl UsageMerger<'_> {
323323
// complex it may be (notably, this is needed for nested arrays).
324324
if b.max_size
325325
.and_then(|b_max_size| b_max_size.checked_add(b_offset_in_a_element))
326-
.map_or(false, |b_in_a_max_size| b_in_a_max_size <= a_stride.get())
326+
.is_some_and(|b_in_a_max_size| b_in_a_max_size <= a_stride.get())
327327
{
328328
// FIXME(eddyb) this in-place merging dance only needed due to `Rc`.
329329
({
@@ -402,7 +402,7 @@ impl UsageMerger<'_> {
402402
))
403403
.rev()
404404
.take_while(|(a_sub_offset, a_sub_usage)| {
405-
a_sub_usage.max_size.map_or(true, |a_sub_max_size| {
405+
a_sub_usage.max_size.is_none_or(|a_sub_max_size| {
406406
a_sub_offset.checked_add(a_sub_max_size).unwrap() > b_offset_in_a
407407
})
408408
});
@@ -585,7 +585,7 @@ impl MemTypeLayout {
585585
entries.iter().all(|(&sub_offset, sub_usage)| {
586586
// FIXME(eddyb) maybe this overflow should be propagated up,
587587
// as a sign that `usage` is malformed?
588-
usage_offset.checked_add(sub_offset).map_or(false, |combined_offset| {
588+
usage_offset.checked_add(sub_offset).is_some_and(|combined_offset| {
589589
// NOTE(eddyb) the reason this is only applicable to
590590
// offset `0` is that *in all other cases*, every
591591
// individual `OffsetBase` requires its own type, to
@@ -924,7 +924,7 @@ impl<'a> InferUsage<'a> {
924924
));
925925
}
926926
};
927-
if data_inst_def.output_type.map_or(false, is_qptr) {
927+
if data_inst_def.output_type.is_some_and(is_qptr) {
928928
if let Some(usage) = output_usage {
929929
usage_or_err_attrs_to_attach
930930
.push((Value::DataInstOutput(data_inst), usage));

0 commit comments

Comments
 (0)