Skip to content
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: 2 additions & 2 deletions crates/rustc_codegen_spirv/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ use std::{env, fs, mem};
/// `cargo publish`. We need to figure out a way to do this properly, but let's hardcode it for now :/
//const REQUIRED_RUST_TOOLCHAIN: &str = include_str!("../../rust-toolchain.toml");
const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain]
channel = "nightly-2025-06-23"
channel = "nightly-2025-06-30"
components = ["rust-src", "rustc-dev", "llvm-tools"]
# commit_hash = be19eda0dc4c22c5cf5f1b48fd163acf9bd4b0a6"#;
# commit_hash = 35f6036521777bdc0dcea1f980be4c192962a168"#;

fn rustc_output(arg: &str) -> Result<String, Box<dyn Error>> {
let rustc = env::var("RUSTC").unwrap_or_else(|_| "rustc".into());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3035,7 +3035,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
todo!()
}

fn filter_landing_pad(&mut self, _pers_fn: Self::Function) -> (Self::Value, Self::Value) {
fn filter_landing_pad(&mut self, _pers_fn: Self::Function) {
todo!()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
Some(size) => size,
None => return self.load_err(original_type, result_type),
};
if element_size_bytes.bytes() % 4 != 0 {
if !element_size_bytes.bytes().is_multiple_of(4) {
return self.load_err(original_type, result_type);
}
let element_size_words = (element_size_bytes.bytes() / 4) as u32;
Expand Down Expand Up @@ -148,7 +148,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
.iter()
.zip(field_offsets)
.map(|(&field_type, byte_offset)| {
if byte_offset.bytes() % 4 != 0 {
if !byte_offset.bytes().is_multiple_of(4) {
return None;
}
let word_offset = (byte_offset.bytes() / 4) as u32;
Expand Down Expand Up @@ -276,7 +276,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
Some(size) => size,
None => return self.store_err(original_type, value),
};
if element_size_bytes.bytes() % 4 != 0 {
if !element_size_bytes.bytes().is_multiple_of(4) {
return self.store_err(original_type, value);
}
let element_size_words = (element_size_bytes.bytes() / 4) as u32;
Expand Down Expand Up @@ -343,7 +343,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
..
} => {
for (index, byte_offset) in field_offsets.iter().enumerate() {
if byte_offset.bytes() % 4 != 0 {
if !byte_offset.bytes().is_multiple_of(4) {
return self.store_err(original_type, value);
}
let word_offset = (byte_offset.bytes() / 4) as u32;
Expand Down
1 change: 0 additions & 1 deletion crates/rustc_codegen_spirv/src/linker/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ fn link_with_linker_opts(
Default::default(),
Default::default(),
target,
Default::default(),
rustc_interface::util::rustc_version_str().unwrap_or("unknown"),
Default::default(),
&rustc_driver_impl::USING_INTERNAL_FEATURES,
Expand Down
2 changes: 1 addition & 1 deletion crates/spirv-std/src/byte_addressable_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub struct ByteAddressableBuffer<T> {

fn bounds_check<T>(data: &[u32], byte_index: u32) {
let sizeof = mem::size_of::<T>() as u32;
if byte_index % 4 != 0 {
if !byte_index.is_multiple_of(4) {
panic!("`byte_index` should be a multiple of 4");
}
let last_byte = byte_index + sizeof;
Expand Down
2 changes: 1 addition & 1 deletion examples/shaders/compute-shader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub fn collatz(mut n: u32) -> Option<u32> {
return None;
}
while n != 1 {
n = if n % 2 == 0 {
n = if n.is_multiple_of(2) {
n / 2
} else {
// Overflow? (i.e. 3*n + 1 > 0xffff_ffff)
Expand Down
4 changes: 2 additions & 2 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[toolchain]
channel = "nightly-2025-06-23"
channel = "nightly-2025-06-30"
components = ["rust-src", "rustc-dev", "llvm-tools"]
# commit_hash = be19eda0dc4c22c5cf5f1b48fd163acf9bd4b0a6
# commit_hash = 35f6036521777bdc0dcea1f980be4c192962a168

# Whenever changing the nightly channel, update the commit hash above, and
# change `REQUIRED_RUST_TOOLCHAIN` in `crates/rustc_codegen_spirv/build.rs` too.
4 changes: 2 additions & 2 deletions tests/difftests/bin/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ impl Runner {
match output_type {
OutputType::Raw => output1 == output2,
OutputType::F32 => {
if output1.len() % 4 != 0 {
if !output1.len().is_multiple_of(4) {
return false;
}

Expand Down Expand Up @@ -527,7 +527,7 @@ impl Runner {
}
}
OutputType::F64 => {
if output1.len() % 8 != 0 {
if !output1.len().is_multiple_of(8) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/difftests/lib/src/scaffold/compute/wgpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ impl ComputeBackend for WgpuBackend {
buffers: Vec<BufferConfig>,
) -> anyhow::Result<Vec<Vec<u8>>> {
// Convert bytes to u32 words
if spirv_bytes.len() % 4 != 0 {
if !spirv_bytes.len().is_multiple_of(4) {
anyhow::bail!("SPIR-V binary length is not a multiple of 4");
}
let spirv_words: Vec<u32> = bytemuck::cast_slice(spirv_bytes).to_vec();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl WgpuShader for RustComputeShader {
) -> anyhow::Result<(wgpu::ShaderModule, Option<String>)> {
let (shader_bytes, entry_point) = self.spirv_bytes()?;

if shader_bytes.len() % 4 != 0 {
if !shader_bytes.len().is_multiple_of(4) {
anyhow::bail!("SPIR-V binary length is not a multiple of 4");
}
let shader_words: Vec<u32> = bytemuck::cast_slice(&shader_bytes).to_vec();
Expand Down