Skip to content
Snippets Groups Projects
  1. Aug 18, 2023
    • Raphaël Gomès's avatar
      rust: make `Revision` a newtype · 4c5f6e95
      Raphaël Gomès authored
      This change is the one we've been building towards during this series.
      The aim is to make `Revision` mean more than a simple integer, holding
      the information that it is valid for a given revlog index.
      While this still allows for programmer error, since creating a revision
      directly and querying a different index with a "checked" revision are
      still possible, the friction created by the newtype will hopefully make
      us think twice about which type to use.
      
      Enough of the Rust ecosystem relies on the newtype pattern to be
      efficiently optimized away (even compiler in codegen tests¹), so I'm not
      worried about this being a fundamental problem.
      
      [1] https://github.com/rust-lang/rust/blob/7a70647f195f6b0a0f1ebd72b1542ba91a32f43a/tests/codegen/vec-in-place.rs#L47
      4c5f6e95
  2. Jan 10, 2023
  3. May 19, 2021
    • Simon Sapin's avatar
      rust: Add type annotation to fix inference on Rust Nightly · 402bd66c
      Simon Sapin authored
      When compiling with Rust Nightly, the im-rs crate silently makes use of the
      experimental language feature for trait impl specialization. This apperently
      changes public its APIs in subtle ways such that type inference of some user
      code can fail where it succeeds when specialization is disabled.
      
      This made Mercurial’s Rust unit tests have compilation errors on Nightly.
      
      I have not managed to find the exactl root cause, but I wrote down my findings
      so far at https://github.com/bodil/im-rs/issues/188
      
      This adds type annotation to make unit tests rely less on type inference
      and work around the issue.
      
      Differential Revision: https://phab.mercurial-scm.org/D10742
      402bd66c
  4. Jan 11, 2021
    • Simon Sapin's avatar
      copies-rust: add a macro-based unit-testing framework · fa21633a
      Simon Sapin authored
      `compare_values`, `merge_copies_dict`, and `CombineChangesetCopies`
      are APIs whose signatures involve non-trivial types.
      Calling them directly in unit tests would involve a lot of verbose
      setup code that obscures the meaningful parts of a given test case.
      
      This adds a macro-based test-harness with pseudo-syntax to tersely
      create arguments and expected return values in the correct types.
      
      For now there is only one (not particularly meaningful) test case
      per tested function, just to exercize the macros.
      
      Differential Revision: https://phab.mercurial-scm.org/D10071
      fa21633a
Loading