Skip to content
This repository was archived by the owner on Oct 31, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion crates/rustc_codegen_spirv/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ fn check_toolchain_version() -> Result<(), Box<dyn Error>> {
return Err(Box::<dyn Error>::from(format!(
"error: building from local source while `REQUIRED_RUST_TOOLCHAIN` (defined in `{}`) doesn't match `{}`",
file!(),
std::path::Path::new("../../rust-toolchain.toml").canonicalize()?.display()
std::path::Path::new("../../rust-toolchain.toml")
.canonicalize()?
.display()
)));
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/rustc_codegen_spirv/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ pub(crate) fn provide(providers: &mut Providers) {
if hide_niche {
layout = tcx.mk_layout(LayoutS {
largest_niche: None,
..clone_layout(layout.0 .0)
..clone_layout(layout.0.0)
});
}

Expand Down
34 changes: 17 additions & 17 deletions crates/rustc_codegen_spirv/src/builder/builder_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2397,10 +2397,13 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
// HACK(eddyb) this is basically a `try` block.
let remove_format_args_if_possible = || -> Option<()> {
let format_args_id = match args {
&[SpirvValue {
kind: SpirvValueKind::Def(format_args_id),
..
}, _] => format_args_id,
&[
SpirvValue {
kind: SpirvValueKind::Def(format_args_id),
..
},
_,
] => format_args_id,

_ => return None,
};
Expand Down Expand Up @@ -2503,15 +2506,13 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {

let (rt_args_slice_ptr_id, rt_args_count) = match try_rev_take(3)?[..] {
[
// HACK(eddyb) comment works around `rustfmt` array bugs.
Inst::Call(call_ret_id, callee_id, ref call_args),
Inst::Store(st_dst_id, st_val_id),
Inst::Load(ld_val_id, ld_src_id),
]
if self.fmt_args_new_fn_ids.borrow().contains(&callee_id)
&& call_ret_id == st_val_id
&& st_dst_id == ld_src_id
&& ld_val_id == format_args_id =>
] if self.fmt_args_new_fn_ids.borrow().contains(&callee_id)
&& call_ret_id == st_val_id
&& st_dst_id == ld_src_id
&& ld_val_id == format_args_id =>
{
require_local_var(st_dst_id)?;
match call_args[..] {
Expand Down Expand Up @@ -2565,7 +2566,6 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
{
let rt_arg_var_id = match init_of_rt_arg_var_insts[..] {
[
// HACK(eddyb) comment works around `rustfmt` array bugs.
Inst::Bitcast(b, _),
Inst::Bitcast(a, _),
Inst::AccessChain(a_ptr, a_base_ptr, SpirvConst::U32(0)),
Expand All @@ -2587,7 +2587,6 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
copy_from_rt_arg_var_to_rt_args_array_insts.split_at(4);
let (a, b) = match copy_loads[..] {
[
// HACK(eddyb) comment works around `rustfmt` array bugs.
Inst::AccessChain(a_ptr, a_base_ptr, SpirvConst::U32(0)),
Inst::Load(a_ld_val, a_ld_src),
Inst::AccessChain(b_ptr, b_base_ptr, SpirvConst::U32(1)),
Expand All @@ -2601,8 +2600,11 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
};
match copy_stores[..] {
[
// HACK(eddyb) comment works around `rustfmt` array bugs.
Inst::InBoundsAccessChain(array_slot_ptr, array_base_ptr, SpirvConst::U32(array_idx)),
Inst::InBoundsAccessChain(
array_slot_ptr,
array_base_ptr,
SpirvConst::U32(array_idx),
),
Inst::AccessChain(a_ptr, a_base_ptr, SpirvConst::U32(0)),
Inst::Store(a_st_dst, a_st_val),
Inst::AccessChain(b_ptr, b_base_ptr, SpirvConst::U32(1)),
Expand All @@ -2611,9 +2613,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
&& array_idx as usize == rt_arg_idx
&& [a_base_ptr, b_base_ptr] == [array_slot_ptr; 2]
&& (a, b) == (a_st_val, b_st_val)
&& (a_ptr, b_ptr) == (a_st_dst, b_st_dst) =>
{
}
&& (a_ptr, b_ptr) == (a_st_dst, b_st_dst) => {}
_ => return None,
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
return SpirvValue {
kind: SpirvValueKind::IllegalTypeUsed(result_type),
ty: result_type,
}
};
}
// PassMode::Pair is identical to PassMode::Direct - it's returned as a struct
PassMode::Direct(_) | PassMode::Pair(_, _) => (),
Expand Down
10 changes: 6 additions & 4 deletions crates/rustc_codegen_spirv/src/builder/spirv_asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -719,10 +719,12 @@ impl<'cx, 'tcx> Builder<'cx, 'tcx> {

// FIXME(eddyb) try multiple signatures until one fits.
let mut sig = match instruction_signatures(instruction.class.opcode)? {
[sig @ InstSig {
output_type: Some(_),
..
}] => *sig,
[
sig @ InstSig {
output_type: Some(_),
..
},
] => *sig,
_ => return None,
};

Expand Down
8 changes: 4 additions & 4 deletions crates/rustc_codegen_spirv/src/codegen_cx/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,10 +487,10 @@ impl<'tcx> CodegenCx<'tcx> {
*offset += size;
} else {
assert_eq!(
offset.bytes_usize(),
alloc.inner().len(),
"create_const_alloc must consume all bytes of an Allocation after an unsized struct"
);
offset.bytes_usize(),
alloc.inner().len(),
"create_const_alloc must consume all bytes of an Allocation after an unsized struct"
);
}
self.constant_composite(ty, values.into_iter())
}
Expand Down
2 changes: 1 addition & 1 deletion crates/rustc_codegen_spirv/src/codegen_cx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ impl CodegenArgs {
Some(v) => {
return Err(rustc_session::getopts::Fail::UnrecognizedOption(
v.to_string(),
))
));
}
};

Expand Down
6 changes: 1 addition & 5 deletions crates/rustc_codegen_spirv/src/custom_decorations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,11 +472,7 @@ impl<'a> SpanRegenerator<'a> {
})
.unwrap_or(false);

if sf_src_matches {
Some(sf)
} else {
None
}
if sf_src_matches { Some(sf) } else { None }
});
}
file.as_deref()
Expand Down
9 changes: 5 additions & 4 deletions crates/rustc_codegen_spirv/src/linker/mem2reg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,11 @@ fn compute_idom(preds: &[Vec<usize>], reachable_blocks: &[bool]) -> Vec<Option<u
}
}
}
assert!(idom
.iter()
.enumerate()
.all(|(i, x)| x.is_some() == reachable_blocks[i]));
assert!(
idom.iter()
.enumerate()
.all(|(i, x)| x.is_some() == reachable_blocks[i])
);
idom
}

Expand Down
2 changes: 1 addition & 1 deletion crates/rustc_codegen_spirv/src/linker/specializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1276,7 +1276,7 @@ impl<'a, S: Specialization> InferCx<'a, S> {
return Ok(Match {
ambiguous: true,
..Match::default()
})
});
}
InferOperand::Var(_) => return Err(Unapplicable),
InferOperand::Instance(instance) => instance,
Expand Down
10 changes: 5 additions & 5 deletions crates/rustc_codegen_spirv/src/linker/spirt_passes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,11 @@ const _: () = {
use spirt::{func_at::*, visit::*, *};

impl<
'a,
S,
VCR: FnMut(&mut S, FuncAt<'a, ControlRegion>),
VCN: FnMut(&mut S, FuncAt<'a, ControlNode>),
> Visitor<'a> for VisitAllControlRegionsAndNodes<S, VCR, VCN>
'a,
S,
VCR: FnMut(&mut S, FuncAt<'a, ControlRegion>),
VCN: FnMut(&mut S, FuncAt<'a, ControlNode>),
> Visitor<'a> for VisitAllControlRegionsAndNodes<S, VCR, VCN>
{
// FIXME(eddyb) this is excessive, maybe different kinds of
// visitors should exist for module-level and func-level?
Expand Down
4 changes: 3 additions & 1 deletion crates/rustc_codegen_spirv/src/linker/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,9 @@ fn type_mismatch() {
let result = assemble_and_link(&[&a, &b]);
assert_eq!(
result.err().as_deref(),
Some("error: Types mismatch for \"foo\"\n |\n = note: import type: (TypeFloat)\n = note: export type: (TypeInt)")
Some(
"error: Types mismatch for \"foo\"\n |\n = note: import type: (TypeFloat)\n = note: export type: (TypeInt)"
)
);
}

Expand Down
2 changes: 1 addition & 1 deletion crates/rustc_codegen_spirv/src/symbols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ fn parse_entry_attrs(
format!(
"#[spirv({name}(..))] unknown attribute argument {attr_name}"
),
))
));
}
}
} else {
Expand Down
8 changes: 5 additions & 3 deletions crates/spirv-std/macros/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,9 +463,11 @@ mod params {
"r8ui" => ImageFormat::R8ui,
"r64ui" => ImageFormat::R64ui,
"r64i" => ImageFormat::R64i,
_ => return Err(
"Unknown specified image format. Use `type=<type>` instead if this is intentional.",
),
_ => {
return Err(
"Unknown specified image format. Use `type=<type>` instead if this is intentional.",
);
}
})
}

Expand Down
20 changes: 11 additions & 9 deletions crates/spirv-std/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ fn debug_printf_inner(input: DebugPrintfInput) -> TokenStream {
return parsing_error(
"Unterminated format specifier: missing type after precision",
span,
)
);
}
};

Expand All @@ -506,17 +506,19 @@ fn debug_printf_inner(input: DebugPrintfInput) -> TokenStream {
return parsing_error(
"Unterminated format specifier: missing type after decimal point",
span,
)
);
}
};

while ch.is_ascii_digit() {
ch = match chars.next() {
Some(ch) => ch,
None => return parsing_error(
"Unterminated format specifier: missing type after fraction precision",
span,
),
None => {
return parsing_error(
"Unterminated format specifier: missing type after fraction precision",
span,
);
}
};
}
}
Expand All @@ -527,7 +529,7 @@ fn debug_printf_inner(input: DebugPrintfInput) -> TokenStream {
Some('3') => 3,
Some('4') => 4,
Some(ch) => {
return parsing_error(&format!("Invalid width for vector: {ch}"), span)
return parsing_error(&format!("Invalid width for vector: {ch}"), span);
}
None => return parsing_error("Missing vector dimensions specifier", span),
};
Expand All @@ -543,7 +545,7 @@ fn debug_printf_inner(input: DebugPrintfInput) -> TokenStream {
return parsing_error(
&format!("Unrecognised vector type specifier: '{ch}'"),
span,
)
);
}
};

Expand All @@ -555,7 +557,7 @@ fn debug_printf_inner(input: DebugPrintfInput) -> TokenStream {
return parsing_error(
&format!("Unrecognised format specifier: '{ch}'"),
span,
)
);
}
};

Expand Down
12 changes: 2 additions & 10 deletions crates/spirv-std/shared/src/image_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ pub enum Arrayed {

impl From<bool> for Arrayed {
fn from(val: bool) -> Self {
if val {
Self::True
} else {
Self::False
}
if val { Self::True } else { Self::False }
}
}

Expand Down Expand Up @@ -102,11 +98,7 @@ pub enum Multisampled {

impl From<bool> for Multisampled {
fn from(val: bool) -> Self {
if val {
Self::True
} else {
Self::False
}
if val { Self::True } else { Self::False }
}
}

Expand Down
Loading