dev: Check that we use ///-style doc comments in Rust
(cherry picked from commit 395a4d7a46e8489ca98667fca3db8aebf998a9b6)
This commit is contained in:
parent
37da6411d0
commit
6b438e5398
1 changed files with 20 additions and 0 deletions
20
flake.nix
20
flake.nix
|
|
@ -35,6 +35,26 @@
|
|||
# New configuration for rustfmt
|
||||
pre-commit.settings.settings.rust.cargoManifestPath = "./rust/Cargo.toml";
|
||||
|
||||
# Check that we're using ///-style doc comments in Rust code.
|
||||
#
|
||||
# Unfortunately, rustfmt won't do this for us yet - at least not
|
||||
# without nightly, and it might do too much.
|
||||
pre-commit.settings.hooks.rust-doc-comments = {
|
||||
enable = true;
|
||||
files = ".*.rs$";
|
||||
entry = "${pkgs.writeScript "rust-doc-comments" ''
|
||||
#!${pkgs.runtimeShell}
|
||||
set -uxo pipefail
|
||||
grep -n -C3 --color=always -F '/**' "$@"
|
||||
r=$?
|
||||
set -e
|
||||
if [ $r -eq 0 ]; then
|
||||
echo "Please replace /**-style comments by /// style comments in Rust code."
|
||||
exit 1
|
||||
fi
|
||||
''}";
|
||||
};
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
name = "nix-bindings-devshell";
|
||||
strictDeps = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue