Skip to content

Commit 5318ef3

Browse files
committed
Fix new clippy warnings.
1 parent 6c4e796 commit 5318ef3

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
}
@@ -2871,14 +2864,10 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
28712864
}
28722865
.def(self.span(), self);
28732866
if self.builder.lookup_const(elt).is_some() {
2874-
self.constant_composite(result_type, iter::repeat(elt.def(self)).take(num_elts))
2867+
self.constant_composite(result_type, iter::repeat_n(elt.def(self), num_elts))
28752868
} else {
28762869
self.emit()
2877-
.composite_construct(
2878-
result_type,
2879-
None,
2880-
iter::repeat(elt.def(self)).take(num_elts),
2881-
)
2870+
.composite_construct(result_type, None, iter::repeat_n(elt.def(self), num_elts))
28822871
.unwrap()
28832872
.with_type(result_type)
28842873
}

crates/rustc_codegen_spirv/src/builder/spirv_asm.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
285285
let start = line.as_str();
286286
match line.next()? {
287287
// skip over leading whitespace
288-
ch if ch.is_whitespace() => continue,
288+
ch if ch.is_whitespace() => {}
289289
// lex a string
290290
'"' => {
291291
let mut cooked = String::new();
@@ -328,7 +328,7 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
328328
let end = loop {
329329
let end = line.as_str();
330330
match line.next() {
331-
Some(ch) if !ch.is_whitespace() => continue,
331+
Some(ch) if !ch.is_whitespace() => {}
332332
_ => break end,
333333
}
334334
};
@@ -862,6 +862,8 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {
862862
_ => return None,
863863
}
864864

865+
// HACK(eddyb) clippy false positive, `.ok()` loses information.
866+
#[allow(clippy::manual_ok_err)]
865867
match subst_ty_pat(
866868
self,
867869
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
@@ -1081,22 +1081,21 @@ struct RustcOutput {
10811081
const ARTIFACT_SUFFIX: &str = ".spv.json";
10821082

10831083
fn get_sole_artifact(out: &str) -> Option<PathBuf> {
1084-
let last = out
1085-
.lines()
1086-
.filter_map(|line| {
1087-
if let Ok(line) = serde_json::from_str::<RustcOutput>(line) {
1088-
Some(line)
1089-
} else {
1090-
// Pass through invalid lines
1091-
println!("{line}");
1092-
None
1093-
}
1094-
})
1095-
.filter(|line| line.reason == "compiler-artifact")
1096-
.last()
1097-
.expect("Did not find output file in rustc output");
1084+
let mut last_compiler_artifact = None;
1085+
for line in out.lines() {
1086+
let Ok(msg) = serde_json::from_str::<RustcOutput>(line) else {
1087+
// Pass through invalid lines
1088+
println!("{line}");
1089+
continue;
1090+
};
1091+
if msg.reason == "compiler-artifact" {
1092+
last_compiler_artifact = Some(msg);
1093+
}
1094+
}
1095+
let last_compiler_artifact =
1096+
last_compiler_artifact.expect("Did not find output file in rustc output");
10981097

1099-
let mut filenames = last
1098+
let mut filenames = last_compiler_artifact
11001099
.filenames
11011100
.unwrap()
11021101
.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
@@ -100,14 +100,11 @@ impl CompiledShaderModules {
100100
wanted_entry: &str,
101101
) -> wgpu::ShaderModuleDescriptorSpirV<'a> {
102102
for (name, spv_module) in &self.named_spv_modules {
103-
match name {
104-
Some(name) if name != wanted_entry => continue,
105-
_ => {
106-
return wgpu::ShaderModuleDescriptorSpirV {
107-
label: name.as_deref(),
108-
source: Cow::Borrowed(&spv_module.source),
109-
};
110-
}
103+
if name.as_ref().is_none_or(|name| name == wanted_entry) {
104+
return wgpu::ShaderModuleDescriptorSpirV {
105+
label: name.as_deref(),
106+
source: Cow::Borrowed(&spv_module.source),
107+
};
111108
}
112109
}
113110
unreachable!(

0 commit comments

Comments
 (0)