mirror of
https://github.com/EmbarkStudios/rust-gpu.git
synced 2024-12-11 16:15:40 +00:00
Add rustfmt.toml
with version = "Two"
to enable formatting array patterns.
This commit is contained in:
parent
cfaabbab08
commit
4a987f3eb0
@ -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()
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
&[
|
||||
SpirvValue {
|
||||
kind: SpirvValueKind::Def(format_args_id),
|
||||
..
|
||||
}, _] => format_args_id,
|
||||
},
|
||||
_,
|
||||
] => format_args_id,
|
||||
|
||||
_ => return None,
|
||||
};
|
||||
@ -2503,12 +2506,10 @@ 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)
|
||||
] 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 =>
|
||||
@ -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)),
|
||||
@ -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)),
|
||||
@ -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)),
|
||||
@ -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,
|
||||
}
|
||||
}
|
||||
|
@ -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(_, _) => (),
|
||||
|
@ -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 {
|
||||
[
|
||||
sig @ InstSig {
|
||||
output_type: Some(_),
|
||||
..
|
||||
}] => *sig,
|
||||
},
|
||||
] => *sig,
|
||||
_ => return None,
|
||||
};
|
||||
|
||||
|
@ -500,7 +500,7 @@ impl CodegenArgs {
|
||||
Some(v) => {
|
||||
return Err(rustc_session::getopts::Fail::UnrecognizedOption(
|
||||
v.to_string(),
|
||||
))
|
||||
));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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()
|
||||
|
@ -125,10 +125,11 @@ fn compute_idom(preds: &[Vec<usize>], reachable_blocks: &[bool]) -> Vec<Option<u
|
||||
}
|
||||
}
|
||||
}
|
||||
assert!(idom
|
||||
.iter()
|
||||
assert!(
|
||||
idom.iter()
|
||||
.enumerate()
|
||||
.all(|(i, x)| x.is_some() == reachable_blocks[i]));
|
||||
.all(|(i, x)| x.is_some() == reachable_blocks[i])
|
||||
);
|
||||
idom
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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)"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -649,7 +649,7 @@ fn parse_entry_attrs(
|
||||
format!(
|
||||
"#[spirv({name}(..))] unknown attribute argument {attr_name}"
|
||||
),
|
||||
))
|
||||
));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -463,9 +463,11 @@ mod params {
|
||||
"r8ui" => ImageFormat::R8ui,
|
||||
"r64ui" => ImageFormat::R64ui,
|
||||
"r64i" => ImageFormat::R64i,
|
||||
_ => return Err(
|
||||
_ => {
|
||||
return Err(
|
||||
"Unknown specified image format. Use `type=<type>` instead if this is intentional.",
|
||||
),
|
||||
);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -492,7 +492,7 @@ fn debug_printf_inner(input: DebugPrintfInput) -> TokenStream {
|
||||
return parsing_error(
|
||||
"Unterminated format specifier: missing type after precision",
|
||||
span,
|
||||
)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -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(
|
||||
None => {
|
||||
return parsing_error(
|
||||
"Unterminated format specifier: missing type after fraction precision",
|
||||
span,
|
||||
),
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -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),
|
||||
};
|
||||
@ -543,7 +545,7 @@ fn debug_printf_inner(input: DebugPrintfInput) -> TokenStream {
|
||||
return parsing_error(
|
||||
&format!("Unrecognised vector type specifier: '{ch}'"),
|
||||
span,
|
||||
)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@ -555,7 +557,7 @@ fn debug_printf_inner(input: DebugPrintfInput) -> TokenStream {
|
||||
return parsing_error(
|
||||
&format!("Unrecognised format specifier: '{ch}'"),
|
||||
span,
|
||||
)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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 }
|
||||
}
|
||||
}
|
||||
|
||||
@ -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 }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,11 +57,7 @@ pub fn acos_approx(v: f32) -> f32 {
|
||||
let mut res = -0.155972 * x + 1.56467; // p(x)
|
||||
res *= (1.0f32 - x).sqrt();
|
||||
|
||||
if v >= 0.0 {
|
||||
res
|
||||
} else {
|
||||
PI - res
|
||||
}
|
||||
if v >= 0.0 { res } else { PI - res }
|
||||
}
|
||||
|
||||
pub fn smoothstep(edge0: f32, edge1: f32, x: f32) -> f32 {
|
||||
|
3
rustfmt.toml
Normal file
3
rustfmt.toml
Normal file
@ -0,0 +1,3 @@
|
||||
# HACK(eddyb) needed to format array/slice patterns at all, because it was a
|
||||
# breaking change (see https://github.com/rust-lang/rustfmt/pull/4994).
|
||||
version = "Two"
|
@ -9,9 +9,9 @@ error[E0277]: the trait bound `Image<f32, 0, 2, 0, 0, 1, 0, 4>: HasGather` is no
|
||||
Image<SampledType, 3, DEPTH, ARRAYED, 0, SAMPLED, FORMAT, COMPONENTS>
|
||||
Image<SampledType, 4, DEPTH, ARRAYED, 0, SAMPLED, FORMAT, COMPONENTS>
|
||||
note: required by a bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, spirv_std::::image::{impl#1}::{constant#0}, SAMPLED, FORMAT, COMPONENTS>::gather`
|
||||
--> $SPIRV_STD_SRC/image.rs:200:15
|
||||
--> $SPIRV_STD_SRC/image.rs:197:15
|
||||
|
|
||||
200 | Self: HasGather,
|
||||
197 | Self: HasGather,
|
||||
| ^^^^^^^^^ required by this bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, spirv_std::::image::{impl#1}::{constant#0}, SAMPLED, FORMAT, COMPONENTS>::gather`
|
||||
|
||||
error[E0277]: the trait bound `Image<f32, 2, 2, 0, 0, 1, 0, 4>: HasGather` is not satisfied
|
||||
@ -25,9 +25,9 @@ error[E0277]: the trait bound `Image<f32, 2, 2, 0, 0, 1, 0, 4>: HasGather` is no
|
||||
Image<SampledType, 3, DEPTH, ARRAYED, 0, SAMPLED, FORMAT, COMPONENTS>
|
||||
Image<SampledType, 4, DEPTH, ARRAYED, 0, SAMPLED, FORMAT, COMPONENTS>
|
||||
note: required by a bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, spirv_std::::image::{impl#1}::{constant#0}, SAMPLED, FORMAT, COMPONENTS>::gather`
|
||||
--> $SPIRV_STD_SRC/image.rs:200:15
|
||||
--> $SPIRV_STD_SRC/image.rs:197:15
|
||||
|
|
||||
200 | Self: HasGather,
|
||||
197 | Self: HasGather,
|
||||
| ^^^^^^^^^ required by this bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, spirv_std::::image::{impl#1}::{constant#0}, SAMPLED, FORMAT, COMPONENTS>::gather`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
@ -10,9 +10,9 @@ error[E0277]: the trait bound `Image<f32, 4, 2, 0, 0, 1, 0, 4>: HasQueryLevels`
|
||||
Image<SampledType, 2, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>
|
||||
Image<SampledType, 3, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>
|
||||
note: required by a bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>::query_levels`
|
||||
--> $SPIRV_STD_SRC/image.rs:884:15
|
||||
--> $SPIRV_STD_SRC/image.rs:881:15
|
||||
|
|
||||
884 | Self: HasQueryLevels,
|
||||
881 | Self: HasQueryLevels,
|
||||
| ^^^^^^^^^^^^^^ required by this bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>::query_levels`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -10,9 +10,9 @@ error[E0277]: the trait bound `Image<f32, 4, 2, 0, 0, 1, 0, 4>: HasQueryLevels`
|
||||
Image<SampledType, 2, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>
|
||||
Image<SampledType, 3, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>
|
||||
note: required by a bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>::query_lod`
|
||||
--> $SPIRV_STD_SRC/image.rs:910:15
|
||||
--> $SPIRV_STD_SRC/image.rs:907:15
|
||||
|
|
||||
910 | Self: HasQueryLevels,
|
||||
907 | Self: HasQueryLevels,
|
||||
| ^^^^^^^^^^^^^^ required by this bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>::query_lod`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -15,9 +15,9 @@ error[E0277]: the trait bound `Image<f32, 1, 2, 0, 0, 1, 0, 4>: HasQuerySize` is
|
||||
Image<SampledType, 2, DEPTH, ARRAYED, 0, 2, FORMAT, COMPONENTS>
|
||||
and 6 others
|
||||
note: required by a bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>::query_size`
|
||||
--> $SPIRV_STD_SRC/image.rs:941:15
|
||||
--> $SPIRV_STD_SRC/image.rs:938:15
|
||||
|
|
||||
941 | Self: HasQuerySize,
|
||||
938 | Self: HasQuerySize,
|
||||
| ^^^^^^^^^^^^ required by this bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, MULTISAMPLED, SAMPLED, FORMAT, COMPONENTS>::query_size`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -10,9 +10,9 @@ error[E0277]: the trait bound `Image<f32, 4, 2, 0, 0, 1, 0, 4>: HasQuerySizeLod`
|
||||
Image<SampledType, 2, DEPTH, ARRAYED, 0, SAMPLED, FORMAT, COMPONENTS>
|
||||
Image<SampledType, 3, DEPTH, ARRAYED, 0, SAMPLED, FORMAT, COMPONENTS>
|
||||
note: required by a bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, spirv_std::::image::{impl#7}::{constant#0}, SAMPLED, FORMAT, COMPONENTS>::query_size_lod`
|
||||
--> $SPIRV_STD_SRC/image.rs:985:15
|
||||
--> $SPIRV_STD_SRC/image.rs:982:15
|
||||
|
|
||||
985 | Self: HasQuerySizeLod,
|
||||
982 | Self: HasQuerySizeLod,
|
||||
| ^^^^^^^^^^^^^^^ required by this bound in `Image::<SampledType, DIM, DEPTH, ARRAYED, spirv_std::::image::{impl#7}::{constant#0}, SAMPLED, FORMAT, COMPONENTS>::query_size_lod`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
Loading…
Reference in New Issue
Block a user