Skip to content

Commit 7a0f1a2

Browse files
committed
Fix new clippy warnings.
1 parent 1e6d631 commit 7a0f1a2

File tree

9 files changed

+41
-56
lines changed

9 files changed

+41
-56
lines changed

crates/rustc_codegen_spirv/src/builder/builder_methods.rs

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,7 @@ fn memset_dynamic_scalar(
139139
.def(builder.span(), builder);
140140
let composite = builder
141141
.emit()
142-
.composite_construct(
143-
composite_type,
144-
None,
145-
iter::repeat(fill_var).take(byte_width),
146-
)
142+
.composite_construct(composite_type, None, iter::repeat_n(fill_var, byte_width))
147143
.unwrap();
148144
let result_type = if is_float {
149145
SpirvType::Float(byte_width as u32 * 8)
@@ -252,18 +248,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
252248
let elem_pat = self.memset_const_pattern(&self.lookup_type(element), fill_byte);
253249
self.constant_composite(
254250
ty.def(self.span(), self),
255-
iter::repeat(elem_pat).take(count as usize),
251+
iter::repeat_n(elem_pat, count as usize),
256252
)
257253
.def(self)
258254
}
259255
SpirvType::Array { element, count } => {
260256
let elem_pat = self.memset_const_pattern(&self.lookup_type(element), fill_byte);
261257
let count = self.builder.lookup_const_scalar(count).unwrap() as usize;
262-
self.constant_composite(
263-
ty.def(self.span(), self),
264-
iter::repeat(elem_pat).take(count),
265-
)
266-
.def(self)
258+
self.constant_composite(ty.def(self.span(), self), iter::repeat_n(elem_pat, count))
259+
.def(self)
267260
}
268261
SpirvType::RuntimeArray { .. } => {
269262
self.fatal("memset on runtime arrays not implemented yet")
@@ -308,7 +301,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
308301
.composite_construct(
309302
ty.def(self.span(), self),
310303
None,
311-
iter::repeat(elem_pat).take(count),
304+
iter::repeat_n(elem_pat, count),
312305
)
313306
.unwrap()
314307
}
@@ -318,7 +311,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
318311
.composite_construct(
319312
ty.def(self.span(), self),
320313
None,
321-
iter::repeat(elem_pat).take(count as usize),
314+
iter::repeat_n(elem_pat, count as usize),
322315
)
323316
.unwrap()
324317
}
@@ -2806,14 +2799,10 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
28062799
}
28072800
.def(self.span(), self);
28082801
if self.builder.lookup_const(elt).is_some() {
2809-
self.constant_composite(result_type, iter::repeat(elt.def(self)).take(num_elts))
2802+
self.constant_composite(result_type, iter::repeat_n(elt.def(self), num_elts))
28102803
} else {
28112804
self.emit()
2812-
.composite_construct(
2813-
result_type,
2814-
None,
2815-
iter::repeat(elt.def(self)).take(num_elts),
2816-
)
2805+
.composite_construct(result_type, None, iter::repeat_n(elt.def(self), num_elts))
28172806
.unwrap()
28182807
.with_type(result_type)
28192808
}

crates/rustc_codegen_spirv/src/builder/spirv_asm.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
211211
let start = line.as_str();
212212
match line.next()? {
213213
// skip over leading whitespace
214-
ch if ch.is_whitespace() => continue,
214+
ch if ch.is_whitespace() => {}
215215
// lex a string
216216
'"' => {
217217
let mut cooked = String::new();
@@ -254,7 +254,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
254254
let end = loop {
255255
let end = line.as_str();
256256
match line.next() {
257-
Some(ch) if !ch.is_whitespace() => continue,
257+
Some(ch) if !ch.is_whitespace() => {}
258258
_ => break end,
259259
}
260260
};
@@ -788,6 +788,8 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
788788
_ => return None,
789789
}
790790

791+
// HACK(eddyb) clippy false positive, `.ok()` loses information.
792+
#[allow(clippy::manual_ok_err)]
791793
match subst_ty_pat(
792794
self,
793795
sig.output_type.unwrap(),

crates/rustc_codegen_spirv/src/codegen_cx/declare.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fn attrs_to_spirv(attrs: &CodegenFnAttrs) -> FunctionControl {
2626
match attrs.inline {
2727
InlineAttr::None => (),
2828
InlineAttr::Hint | InlineAttr::Always | InlineAttr::Force { .. } => {
29-
control.insert(FunctionControl::INLINE)
29+
control.insert(FunctionControl::INLINE);
3030
}
3131
InlineAttr::Never => control.insert(FunctionControl::DONT_INLINE),
3232
}

crates/rustc_codegen_spirv/src/linker/destructure_composites.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ pub fn destructure_composites(function: &mut Function) {
5151
rewrite_rules.get(&origin_id).map_or(origin_id, |id| *id),
5252
);
5353
*inst = Instruction::new(Op::Nop, None, None, vec![]);
54-
continue;
5554
}
5655
}
5756
}

crates/spirv-builder/src/lib.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,22 +1074,21 @@ struct RustcOutput {
10741074
const ARTIFACT_SUFFIX: &str = ".spv.json";
10751075

10761076
fn get_sole_artifact(out: &str) -> Option<PathBuf> {
1077-
let last = out
1078-
.lines()
1079-
.filter_map(|line| {
1080-
if let Ok(line) = serde_json::from_str::<RustcOutput>(line) {
1081-
Some(line)
1082-
} else {
1083-
// Pass through invalid lines
1084-
println!("{line}");
1085-
None
1086-
}
1087-
})
1088-
.filter(|line| line.reason == "compiler-artifact")
1089-
.last()
1090-
.expect("Did not find output file in rustc output");
1077+
let mut last_compiler_artifact = None;
1078+
for line in out.lines() {
1079+
let Ok(msg) = serde_json::from_str::<RustcOutput>(line) else {
1080+
// Pass through invalid lines
1081+
println!("{line}");
1082+
continue;
1083+
};
1084+
if msg.reason == "compiler-artifact" {
1085+
last_compiler_artifact = Some(msg);
1086+
}
1087+
}
1088+
let last_compiler_artifact =
1089+
last_compiler_artifact.expect("Did not find output file in rustc output");
10911090

1092-
let mut filenames = last
1091+
let mut filenames = last_compiler_artifact
10931092
.filenames
10941093
.unwrap()
10951094
.into_iter()

crates/spirv-std/macros/src/image.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ impl Parse for ImageType {
218218

219219
if input.peek(syn::Token![,]) {
220220
input.parse::<syn::Token![,]>()?;
221-
continue;
222221
} else {
223222
break;
224223
}

crates/spirv-std/macros/src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,20 +109,20 @@ use std::fmt::Write;
109109
/// ## Arguments
110110
///
111111
/// - `dimensionality` — Dimensionality of an image.
112-
/// Accepted values: `1D`, `2D`, `3D`, `rect`, `cube`, `subpass`.
112+
/// Accepted values: `1D`, `2D`, `3D`, `rect`, `cube`, `subpass`.
113113
/// - `type` — The sampled type of an image, mutually exclusive with `format`,
114-
/// when set the image format is unknown.
115-
/// Accepted values: `f32`, `f64`, `u8`, `u16`, `u32`, `u64`, `i8`, `i16`, `i32`, `i64`.
114+
/// when set the image format is unknown.
115+
/// Accepted values: `f32`, `f64`, `u8`, `u16`, `u32`, `u64`, `i8`, `i16`, `i32`, `i64`.
116116
/// - `format` — The image format of the image, mutually exclusive with `type`.
117-
/// Accepted values: Snake case versions of [`ImageFormat`].
117+
/// Accepted values: Snake case versions of [`ImageFormat`].
118118
/// - `sampled` — Whether it is known that the image will be used with a sampler.
119-
/// Accepted values: `true` or `false`. Default: `unknown`.
119+
/// Accepted values: `true` or `false`. Default: `unknown`.
120120
/// - `multisampled` — Whether the image contains multisampled content.
121-
/// Accepted values: `true` or `false`. Default: `false`.
121+
/// Accepted values: `true` or `false`. Default: `false`.
122122
/// - `arrayed` — Whether the image contains arrayed content.
123-
/// Accepted values: `true` or `false`. Default: `false`.
123+
/// Accepted values: `true` or `false`. Default: `false`.
124124
/// - `depth` — Whether it is known that the image is a depth image.
125-
/// Accepted values: `true` or `false`. Default: `unknown`.
125+
/// Accepted values: `true` or `false`. Default: `unknown`.
126126
///
127127
/// [`ImageFormat`]: spirv_std_types::image_params::ImageFormat
128128
///

examples/runners/ash/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ pub fn main() {
151151
#[allow(deprecated)]
152152
event_loop
153153
.run(move |event, event_loop_window_target| match event {
154-
Event::AboutToWait { .. } => {
154+
Event::AboutToWait => {
155155
match compiler_receiver.try_recv() {
156156
Err(TryRecvError::Empty) => {
157157
if ctx.rendering_paused {

examples/runners/wgpu/src/lib.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,11 @@ impl CompiledShaderModules {
9999
wanted_entry: &str,
100100
) -> wgpu::ShaderModuleDescriptorSpirV<'a> {
101101
for (name, spv_module) in &self.named_spv_modules {
102-
match name {
103-
Some(name) if name != wanted_entry => continue,
104-
_ => {
105-
return wgpu::ShaderModuleDescriptorSpirV {
106-
label: name.as_deref(),
107-
source: Cow::Borrowed(&spv_module.source),
108-
};
109-
}
102+
if name.as_ref().is_none_or(|name| name == wanted_entry) {
103+
return wgpu::ShaderModuleDescriptorSpirV {
104+
label: name.as_deref(),
105+
source: Cow::Borrowed(&spv_module.source),
106+
};
110107
}
111108
}
112109
unreachable!(

0 commit comments

Comments
 (0)