Skip to content

chore: adopt assert_matches! in tests once it reaches stable #329

Description

@acgetchell

Summary

Adopt the standard‑library assert_matches! / debug_assert_matches! macros in unit and integration tests once they actually reach a stable Rust release.

Background

Issue #324 (MSRV bump to Rust 1.95) listed this task:

Replace manual pattern‑matching assertions in tests with assert_matches!

The stabilization PR (rust‑lang/rust#137487, "Stabilize assert_matches") was tagged milestone 1.95.0, but did not actually ship stable in rustc 1.95.0. The shipped library source for the 1.95.0 toolchain still carries:

#[unstable(feature = "assert_matches", issue = "82775")]
#[allow_internal_unstable(panic_internals)]
#[rustc_macro_transparency = "semiopaque"]
pub macro assert_matches { ... }

In the same file, cfg_select! did ship stable (#[stable(feature = "cfg_select", since = "1.95.0")]), confirming this is an assert_matches!‑specific slip, not a toolchain packaging issue.

Upstream tracking issue: rust‑lang/rust#82775.

Scope

Once assert_matches! lands on a stable release and our MSRV reaches that release, convert the 228 existing assert!(matches!(...)) call sites across the codebase:

  • Integration tests (3 files, ~13 sites)
    • tests/large_scale_debug.rs
    • tests/insert_with_statistics.rs
    • tests/tds_orientation.rs
  • Unit tests in src/ (28 files, ~215 sites); highest‑density:
    • src/core/tds.rs (~45)
    • src/core/triangulation.rs (~32)
    • src/core/algorithms/locate.rs (~16)
    • src/geometry/util/conversions.rs (~13)
    • src/core/algorithms/flips.rs (~12)
    • src/topology/traits/global_topology_model.rs (~11)

The mechanical transformation is:

// before
assert!(matches!(expr, Pat));
assert!(matches!(expr, Pat), "msg {ctx}");
assert!(matches!(expr, Pat { x, .. } if x > 0));

// after
assert_matches!(expr, Pat);
assert_matches!(expr, Pat, "msg {ctx}");
assert_matches!(expr, Pat { x, .. } if x > 0);

Import path (per 1.95 beta/stable docs once it lands):

use std::assert_matches;

Cases to leave alone (no direct replacement):

  • assert!(!matches!(...)) — no assert_not_matches! exists; keep as‑is.
  • Occurrences inside doc comments — keep aligned with whichever form the code uses at that time.

Tasks

  • Confirm which stable release actually stabilizes assert_matches! / debug_assert_matches!
  • Bump MSRV (separate issue) to that release
  • Sweep integration tests in tests/
  • Sweep unit tests in src/
  • Run just ci to verify
  • Close out the corresponding bullet in chore: update MSRV to Rust 1.95.0 #324

References

  • chore: update MSRV to Rust 1.95.0 #324 — MSRV bump to Rust 1.95.0
  • rust‑lang/rust#82775 — tracking issue
  • rust‑lang/rust#137487 — stabilization PR (milestone 1.95.0; did not land in 1.95.0 stable)

Metadata

Metadata

Assignees

No one assigned

    Labels

    refactorCode restructuring without behavior changerustPull requests that update rust codetestingIssues that come up in testing

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions