diff --git a/.github/workflows/interactive-examples.yaml b/.github/workflows/interactive-examples.yaml index 516c24f36..059b6ddc3 100644 --- a/.github/workflows/interactive-examples.yaml +++ b/.github/workflows/interactive-examples.yaml @@ -39,7 +39,7 @@ jobs: - name: Configure Rust uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 with: - toolchain: 1.96.1 + toolchain: 1.97.0 targets: wasm32-unknown-unknown - name: Check rust installation run: rustc -vV diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 1742ba7b7..6920286be 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -132,7 +132,7 @@ jobs: - name: Configure Rust uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 with: - toolchain: 1.96.1 + toolchain: 1.97.0 - name: Authorize with crates.io uses: rust-lang/crates-io-auth-action@c6f97d42243bad5fab37ca0427f495c86d5b1a18 # v1.0.5 id: auth diff --git a/.github/workflows/style.yaml b/.github/workflows/style.yaml index 6746ef1cb..a67474431 100644 --- a/.github/workflows/style.yaml +++ b/.github/workflows/style.yaml @@ -15,6 +15,7 @@ on: permissions: {} env: + CARGO_BUILD_WARNINGS: deny CARGO_TERM_COLOR: always CLICOLOR: 1 @@ -33,7 +34,7 @@ jobs: - name: Configure Rust uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 with: - toolchain: 1.96.1 + toolchain: 1.97.0 targets: wasm32-unknown-unknown components: clippy - name: Cache @@ -43,10 +44,6 @@ jobs: cache-bin: false save-if: ${{ github.ref != 'refs/heads/trunk' }} - # Unfortunately, it is not currently possible to mark warnings as errors with cargo check: - # https://github.com/rust-lang/cargo/issues/8424#issuecomment-1915265827 - # The workaround does not work for hoomd-rs because we set rust configuration options. - # # Check all targets in debug and release modes - name: cargo check [native] run: > @@ -56,6 +53,7 @@ jobs: --workspace --all-targets --all-features + --keep-going - name: cargo clippy [native] run: > @@ -65,7 +63,7 @@ jobs: --workspace --all-targets --all-features - -- -Dwarnings + --keep-going # Check the examples in wasm builds with and without webgpu - name: cargo check [wasm32, features="bevy"] @@ -78,6 +76,8 @@ jobs: --lib --examples --target wasm32-unknown-unknown + --keep-going + - name: cargo check [wasm32, features="bevy,webgpu"] run: > cargo check @@ -88,6 +88,7 @@ jobs: --lib --examples --target wasm32-unknown-unknown + --keep-going - name: cargo clippy [wasm32, features="bevy"] run: > @@ -99,7 +100,8 @@ jobs: --lib --examples --target wasm32-unknown-unknown - -- -Dwarnings + --keep-going + - name: cargo clippy [wasm32, features="bevy,webgpu"] run: > cargo clippy @@ -110,7 +112,7 @@ jobs: --lib --examples --target wasm32-unknown-unknown - -- -Dwarnings + --keep-going cargo-fmt: runs-on: ubuntu-24.04 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 24577c575..44d09d3a8 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -54,7 +54,7 @@ jobs: - name: Configure Rust uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 with: - toolchain: 1.96.1 + toolchain: 1.97.0 targets: ${{ matrix.target }} - name: Check rust installation run: rustc -vV diff --git a/hoomd-gsd/src/file_layer.rs b/hoomd-gsd/src/file_layer.rs index effd348ac..d19eb52f1 100644 --- a/hoomd-gsd/src/file_layer.rs +++ b/hoomd-gsd/src/file_layer.rs @@ -1286,7 +1286,7 @@ impl GsdFile { fn get_index(&self, i: u64) -> Result { // get_index is an internal method, assume that any caller has already // called remap() if needed. Verify this in debug builds. - debug_assert!(self.mmap.len() as u64 == self.file_len); + debug_assert_eq!(self.mmap.len() as u64, self.file_len); let start = self.header.index_location + i * INDEX_ENTRY_SIZE; let end = start + INDEX_ENTRY_SIZE; @@ -1439,10 +1439,7 @@ impl GsdFile { return None; } - let id = match self.name_list.name_id.get(name) { - None => return None, - Some(id) => *id, - }; + let id = self.name_list.name_id.get(name)?; // binary search for the index entry let mut l: u64 = 0; @@ -1454,7 +1451,7 @@ impl GsdFile { // We can map an error to None here because the unaddressable index error // would have previously been caught on open or sync. if let Ok(index_entry_m) = self.get_index(m) { - match (index_entry_m.frame, index_entry_m.id).cmp(&(frame, id)) { + match (index_entry_m.frame, index_entry_m.id).cmp(&(frame, *id)) { Ordering::Less => l = m + 1, Ordering::Greater => r = m - 1, Ordering::Equal => return Some(index_entry_m), diff --git a/hoomd-manifold/src/biquaternion.rs b/hoomd-manifold/src/biquaternion.rs index 6ffbf9481..b3249cfc4 100644 --- a/hoomd-manifold/src/biquaternion.rs +++ b/hoomd-manifold/src/biquaternion.rs @@ -852,10 +852,10 @@ mod tests { Complex::new(1.0, 0.0), Complex::new(1.0, 0.0), ]); - assert!(q.components[0] == Complex::new(-1.0, 0.0)); - assert!(q.components[1] == Complex::new(0.0, 1.0)); - assert!(q.components[2] == Complex::new(1.0, 0.0)); - assert!(q.components[3] == Complex::new(1.0, 0.0)); + assert_eq!(q.components[0], Complex::new(-1.0, 0.0)); + assert_eq!(q.components[1], Complex::new(0.0, 1.0)); + assert_eq!(q.components[2], Complex::new(1.0, 0.0)); + assert_eq!(q.components[3], Complex::new(1.0, 0.0)); } #[test] diff --git a/hoomd-mc/src/parallel_sweep.rs b/hoomd-mc/src/parallel_sweep.rs index ee94d295c..82bca8159 100644 --- a/hoomd-mc/src/parallel_sweep.rs +++ b/hoomd-mc/src/parallel_sweep.rs @@ -189,7 +189,7 @@ impl ParallelSweep { self.spaces .resize_with(self.checkerboard.num_spaces(), Vec::default); for space in &mut self.spaces { - space.truncate(0); + space.clear(); } for (body_index, body) in microstate.bodies().iter().enumerate() { let space_index = self diff --git a/hoomd-microstate/src/append.rs b/hoomd-microstate/src/append.rs index 4593b90ce..19becbadd 100644 --- a/hoomd-microstate/src/append.rs +++ b/hoomd-microstate/src/append.rs @@ -320,7 +320,7 @@ mod test { let gsd_file = GsdFile::open(path, Mode::Read)?; - assert!(gsd_file.n_frames() == 1); + assert_eq!(gsd_file.n_frames(), 1); let step = gsd_file.iter_scalars::(0, "configuration/step")?; itertools::assert_equal(step, [1234]); @@ -364,7 +364,7 @@ mod test { let gsd_file = GsdFile::open(path, Mode::Read)?; - assert!(gsd_file.n_frames() == 1); + assert_eq!(gsd_file.n_frames(), 1); let step = gsd_file.iter_scalars::(0, "configuration/step")?; itertools::assert_equal(step, [1234]); @@ -412,7 +412,7 @@ mod test { let gsd_file = GsdFile::open(path, Mode::Read)?; - assert!(gsd_file.n_frames() == 1); + assert_eq!(gsd_file.n_frames(), 1); let step = gsd_file.iter_scalars::(0, "configuration/step")?; itertools::assert_equal(step, [1234]); @@ -465,7 +465,7 @@ mod test { let gsd_file = GsdFile::open(path, Mode::Read)?; - assert!(gsd_file.n_frames() == 1); + assert_eq!(gsd_file.n_frames(), 1); let step = gsd_file.iter_scalars::(0, "configuration/step")?; itertools::assert_equal(step, [1234]); @@ -505,7 +505,7 @@ mod test { let gsd_file = GsdFile::open(path, Mode::Read)?; - assert!(gsd_file.n_frames() == 1); + assert_eq!(gsd_file.n_frames(), 1); let step = gsd_file.iter_scalars::(0, "configuration/step")?; itertools::assert_equal(step, [1234]); @@ -547,7 +547,7 @@ mod test { let gsd_file = GsdFile::open(path, Mode::Read)?; - assert!(gsd_file.n_frames() == 1); + assert_eq!(gsd_file.n_frames(), 1); let step = gsd_file.iter_scalars::(0, "configuration/step")?; itertools::assert_equal(step, [1234]); @@ -612,7 +612,7 @@ mod test { let gsd_file = GsdFile::open(path, Mode::Read)?; - assert!(gsd_file.n_frames() == 1); + assert_eq!(gsd_file.n_frames(), 1); let step = gsd_file.iter_scalars::(0, "configuration/step")?; itertools::assert_equal(step, [1234]); @@ -678,7 +678,7 @@ mod test { let gsd_file = GsdFile::open(path, Mode::Read)?; - assert!(gsd_file.n_frames() == 1); + assert_eq!(gsd_file.n_frames(), 1); let step = gsd_file.iter_scalars::(0, "configuration/step")?; itertools::assert_equal(step, [1234]); @@ -747,7 +747,7 @@ mod test { let gsd_file = GsdFile::open(path, Mode::Read)?; - assert!(gsd_file.n_frames() == 1); + assert_eq!(gsd_file.n_frames(), 1); let step = gsd_file.iter_scalars::(0, "configuration/step")?; itertools::assert_equal(step, [1234]); @@ -755,11 +755,11 @@ mod test { let positions = gsd_file.iter_arrays::(0, "particles/position")?; itertools::assert_equal(positions, [[1.0, 0.0, 0.0], [-1.0, 2.0, 0.0]]); - assert!( + assert_eq!( gsd_file .iter_arrays::(0, "particles/orientation")? - .count() - == 2 + .count(), + 2 ); let dimensions = gsd_file.iter_scalars::(0, "configuration/dimensions")?; @@ -816,7 +816,7 @@ mod test { let gsd_file = GsdFile::open(path, Mode::Read)?; - assert!(gsd_file.n_frames() == 1); + assert_eq!(gsd_file.n_frames(), 1); let step = gsd_file.iter_scalars::(0, "configuration/step")?; itertools::assert_equal(step, [1234]); @@ -824,11 +824,11 @@ mod test { let positions = gsd_file.iter_arrays::(0, "particles/position")?; itertools::assert_equal(positions, [[1.0, 0.0, 0.0], [-1.0, 2.0, 0.0]]); - assert!( + assert_eq!( gsd_file .iter_arrays::(0, "particles/orientation")? - .count() - == 2 + .count(), + 2 ); let dimensions = gsd_file.iter_scalars::(0, "configuration/dimensions")?; @@ -864,7 +864,7 @@ mod test { let gsd_file = GsdFile::open(path, Mode::Read)?; - assert!(gsd_file.n_frames() == 1); + assert_eq!(gsd_file.n_frames(), 1); let step = gsd_file.iter_scalars::(0, "configuration/step")?; itertools::assert_equal(step, [1234]); @@ -908,7 +908,7 @@ mod test { let gsd_file = GsdFile::open(path, Mode::Read)?; - assert!(gsd_file.n_frames() == 1); + assert_eq!(gsd_file.n_frames(), 1); let step = gsd_file.iter_scalars::(0, "configuration/step")?; itertools::assert_equal(step, [1234]); @@ -967,7 +967,7 @@ mod test { let gsd_file = GsdFile::open(path, Mode::Read)?; - assert!(gsd_file.n_frames() == 1); + assert_eq!(gsd_file.n_frames(), 1); let step = gsd_file.iter_scalars::(0, "configuration/step")?; itertools::assert_equal(step, [1234]); @@ -975,11 +975,11 @@ mod test { let positions = gsd_file.iter_arrays::(0, "particles/position")?; itertools::assert_equal(positions, [[1.0, 0.0, 4.0], [-1.0, 2.0, -2.0]]); - assert!( + assert_eq!( gsd_file .iter_arrays::(0, "particles/orientation")? - .count() - == 2 + .count(), + 2 ); let dimensions = gsd_file.iter_scalars::(0, "configuration/dimensions")?; @@ -1036,7 +1036,7 @@ mod test { let gsd_file = GsdFile::open(path, Mode::Read)?; - assert!(gsd_file.n_frames() == 1); + assert_eq!(gsd_file.n_frames(), 1); let step = gsd_file.iter_scalars::(0, "configuration/step")?; itertools::assert_equal(step, [1234]); @@ -1044,11 +1044,11 @@ mod test { let positions = gsd_file.iter_arrays::(0, "particles/position")?; itertools::assert_equal(positions, [[1.0, 0.0, 4.0], [-1.0, 2.0, -2.0]]); - assert!( + assert_eq!( gsd_file .iter_arrays::(0, "particles/orientation")? - .count() - == 2 + .count(), + 2 ); let dimensions = gsd_file.iter_scalars::(0, "configuration/dimensions")?; diff --git a/hoomd-microstate/src/microstate.rs b/hoomd-microstate/src/microstate.rs index 01e7cb7ca..9ebcd4353 100644 --- a/hoomd-microstate/src/microstate.rs +++ b/hoomd-microstate/src/microstate.rs @@ -2025,17 +2025,17 @@ mod tests { ); } - assert!(microstate.bodies().len() == microstate.bodies_sites.len()); + assert_eq!(microstate.bodies().len(), microstate.bodies_sites.len()); for (body, body_sites) in microstate .bodies() .iter() .zip(microstate.bodies_sites.iter()) { - assert!(body.item.sites.len() == body_sites.len()); + assert_eq!(body.item.sites.len(), body_sites.len()); for site_tag in body_sites { let site_index = microstate.site_indices()[*site_tag] .expect("body_sites should be consistent with site_indices"); - assert!(microstate.sites()[site_index].body_tag == body.tag); + assert_eq!(microstate.sites()[site_index].body_tag, body.tag); } } @@ -2225,7 +2225,10 @@ mod tests { .try_build() .expect("the hard-coded bodies should be in the boundary"); - assert!(microstate.add_body(Body::point(Cartesian::from([11.0, -21.0]))) == Ok(0)); + assert_eq!( + microstate.add_body(Body::point(Cartesian::from([11.0, -21.0]))), + Ok(0) + ); let body = µstate.bodies()[0].item; assert_relative_eq!(body.properties.position, [1.0, -1.0].into(), epsilon = 1e-6); @@ -2275,7 +2278,7 @@ mod tests { let site = µstate.sites()[0]; assert_relative_eq!(site.properties.position, [-4.5, 1.0].into(), epsilon = 1e-6); - assert!(microstate.ghosts().len() == 1); + assert_eq!(microstate.ghosts().len(), 1); let ghost = µstate.ghosts()[0]; assert_relative_eq!(ghost.properties.position, [5.5, 1.0].into(), epsilon = 1e-6); @@ -2296,13 +2299,14 @@ mod tests { .try_build() .expect("the hard-coded bodies should be in the boundary"); - assert!( + assert_eq!( microstate.update_body_properties( 0, Point { position: [4.5, 1.0].into() } - ) == Ok(()) + ), + Ok(()) ); let body = µstate.bodies()[0].item; @@ -2311,20 +2315,21 @@ mod tests { let site = µstate.sites()[0]; assert_relative_eq!(site.properties.position, [-4.5, 1.0].into(), epsilon = 1e-6); - assert!(microstate.ghosts().len() == 1); + assert_eq!(microstate.ghosts().len(), 1); let ghost = µstate.ghosts()[0]; assert_relative_eq!(ghost.properties.position, [5.5, 1.0].into(), epsilon = 1e-6); - assert!(ghost.site_tag == site.site_tag); - assert!(ghost.body_tag == site.body_tag); + assert_eq!(ghost.site_tag, site.site_tag); + assert_eq!(ghost.body_tag, site.body_tag); - assert!( + assert_eq!( microstate.update_body_properties( 0, Point { position: [0.0, 0.0].into() } - ) == Ok(()) + ), + Ok(()) ); assert_eq!(microstate.ghosts().len(), 0); diff --git a/hoomd-vector/src/angle.rs b/hoomd-vector/src/angle.rs index 15a349666..3a4a968db 100644 --- a/hoomd-vector/src/angle.rs +++ b/hoomd-vector/src/angle.rs @@ -303,20 +303,20 @@ mod tests { #[test] fn default() { let a = Angle::default(); - assert!(a.theta == 0.0); + assert_eq!(a.theta, 0.0); } #[test] fn identity() { let a = Angle::identity(); - assert!(a.theta == 0.0); + assert_eq!(a.theta, 0.0); } #[rstest(theta => [0.0, 1.0, 2.125, 14.875, -4.5])] fn inverted(theta: f64) { let angle1 = Angle::from(theta); let angle2 = angle1.inverted(); - assert!(angle2.theta == -theta); + assert_eq!(angle2.theta, -theta); assert_relative_eq!(angle1.combine(&angle2), Angle::identity()); } diff --git a/hoomd-vector/src/quaternion.rs b/hoomd-vector/src/quaternion.rs index 726364487..7ff10477d 100644 --- a/hoomd-vector/src/quaternion.rs +++ b/hoomd-vector/src/quaternion.rs @@ -852,8 +852,8 @@ mod tests { #[test] fn from_array() { let q = Quaternion::from([2.0, -3.0, 4.0, 7.0]); - assert!(q.scalar == 2.0); - assert!(q.vector == [-3.0, 4.0, 7.0].into()); + assert_eq!(q.scalar, 2.0); + assert_eq!(q.vector, [-3.0, 4.0, 7.0].into()); } #[test] @@ -950,13 +950,13 @@ mod tests { #[test] fn default() { let a = Versor::default(); - assert!(a.get() == &[1.0, 0.0, 0.0, 0.0].into()); + assert_eq!(a.get(), &[1.0, 0.0, 0.0, 0.0].into()); } #[test] fn identity() { let a = Versor::identity(); - assert!(a.get() == &[1.0, 0.0, 0.0, 0.0].into()); + assert_eq!(a.get(), &[1.0, 0.0, 0.0, 0.0].into()); } #[rstest(