Skip to content

Commit

Permalink
Develop using latest stable Rust
Browse files Browse the repository at this point in the history
The latest Clippy has a lint that checks that calls follow MSRV. It's
not perfect - it misses some cases like trait items, `Arc::default()`
for example. Spellbook is not changed often enough that it should be a
pain point however.

Also Spellbook is not meant to increase MSRV without good reason (unlike
an application like Helix) so eventually it will run further behind on
Rust versions than rust-analyzer supports. The MSRV CI will catch actual
violations not caught by Clippy before a release.
  • Loading branch information
the-mikedavis committed Feb 4, 2025
1 parent 1a61e13 commit 10f0feb
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 24 deletions.
1 change: 0 additions & 1 deletion .envrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
watch_file flake.lock
watch_file rust-toolchain.toml

# try to use flakes, if it fails use normal nix (ie. shell.nix)
use flake || use nix
Expand Down
12 changes: 0 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ jobs:
- name: Checkout sources
uses: actions/checkout@v4

- name: Remove the rust-toolchain.toml
# `rustup` will attempt to use the toolchain from
# the file which will conflict with the custom versions
# we use in the matrix.
run: rm rust-toolchain.toml

- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
Expand All @@ -44,9 +38,6 @@ jobs:
- name: Checkout sources
uses: actions/checkout@v4

- name: Remove the rust-toolchain.toml
run: rm rust-toolchain.toml

- name: Install MSRV toolchain
uses: dtolnay/rust-toolchain@master
with:
Expand All @@ -67,9 +58,6 @@ jobs:
- name: Checkout sources
uses: actions/checkout@v4

- name: Remove the rust-toolchain.toml
run: rm rust-toolchain.toml

- name: Install MSRV toolchain
uses: dtolnay/rust-toolchain@master
with:
Expand Down
12 changes: 5 additions & 7 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ New to contributing to projects on GitHub? GitHub provides [getting started docu

## Installing Rust

To build and test Spellbook you will need a Rust compiler and the `cargo` command. [rustup](https://rustup.rs/) is the recommended way to install Rust. It manages versions and components of Rust like cargo and clippy and it will install the expected versions of each component specified in the `rust-toolchain.toml` file in the root of the repository. Install `rustup` as [the Rust documentation recommends](https://www.rust-lang.org/tools/install).

You may also install Rust through a system package manager but it might not be the version pinned in `rust-toolchain.toml`. Also see the [MSRV](#msrv) section below.
To build and test Spellbook you will need a Rust compiler and the `cargo` command. [rustup](https://rustup.rs/) is the recommended way to install Rust: it manages versions and components and tools of Rust like `cargo`, `clippy` and `rust-analyzer`. Install `rustup` as [the Rust documentation recommends](https://www.rust-lang.org/tools/install).

If you use [Nix or NixOS](https://nixos.org/) you can use the [flake](https://nixos.wiki/wiki/flakes) via `nix develop` or `shell.nix` via `nix-shell` in the repository root to spawn a shell with the necessary dependencies. Using Nix is entirely optional and is only provided for convenience.

## MSRV

Spellbook keeps an intentionally low <b>m</b>inimum <b>s</b>upported <b>R</b>ust <b>v</b>ersion for the sake of easy compatibility with consuming applications.

The MSRV should never rise higher than allowed by [Mozilla's Firefox MSRV policy](https://firefox-source-docs.mozilla.org/writing-rust-code/update-policy.html) and should lag behind by as many more versions as is practical.
The MSRV should never rise higher than allowed by [Mozilla's Firefox MSRV policy](https://firefox-source-docs.mozilla.org/writing-rust-code/update-policy.html) and should lag behind by as many more versions as is practical. The current MSRV can be found in `Cargo.toml` under the `package.rust-version` key.

## Linting

Expand All @@ -37,7 +35,7 @@ The testsuite has three parts:

* Unit tests. These are in `src/**.rs` in `test` modules at the end of each file.
* Doc tests. These are in markdown codefences in documentation comments (comments starting with `///`).
* "Legacy" tests. These tests live under `tests/legacy/` and are run by `tests/legacy.rs`. These cases are ported originally from the Hunspell codebase and should not be added to unless an equivalent test exists upstream in Hunspell or Nuspell.
* "Legacy" tests. These tests live under `tests/legacy/` and are run by `tests/legacy.rs`. These cases are ported originally from the Hunspell codebase and should not be modified or expanded unless an equivalent test exists upstream in Hunspell or Nuspell.

### Adding a test case

Expand All @@ -51,8 +49,8 @@ You can generate a human readable coverage report using [`cargo-llvm-cov`](https
cargo llvm-cov --html test
```

For this to work you also need `llvm-tools-preview`. This component is specified in `rust-toolchain.toml` so it should be installed by `rustup`. `cargo-llvm-cov` and `llvm-tools-preview` are included in the Nix development shell for convenience.
For this to work you also need `llvm-tools-preview` which can be installed by `rustup`. `cargo-llvm-cov` and `llvm-tools-preview` are included in the Nix development shell for convenience.

## Benchmarking

There are a few benchmarks in the `examples/` directory built with [`brunch`](https://github.com/Blobfolio/brunch). The main benchmark to pay attention to is `bench-api` which covers some common cases of Spellbook usage. Run `cargo run --release --example bench-api` before and after a change to see the difference in timings. Note that the timing each benchmark might vary slightly between runs: the timing of a case swaying plus or minus 5% is not unusual. Run the benchmark multiple times to get a feel for how a change impacted performance.
There are a few benchmarks in the `examples/` directory which use the nightly benchmarking feature. When using Rustup, use `cargo +nightly bench` before and after a change to see the difference in timings. Note that the timing each benchmark might vary slightly between runs: the timing of a case swaying plus or minus 5% is not unusual. Run the benchmark multiple times to get a feel for how a change impacted performance.
2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
inherit system;
overlays = [ rust-overlay.overlays.default ];
};
toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
toolchain = pkgs.rust-bin.stable.latest.default;
in
pkgs.mkShell {
nativeBuildInputs = with pkgs; [
Expand Down
3 changes: 0 additions & 3 deletions rust-toolchain.toml

This file was deleted.

0 comments on commit 10f0feb

Please sign in to comment.