mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-01-18 13:24:36 +01:00
930f5fbf9a
This avoids `rustfmt` failing on Rust files generated by dependent crates in `target`, eg ``` + rustfmt --edition 2021 --check ./target/debug/build/thiserror-8230374e07b5c05a/out/probe.rs Diff in /home/matt/rust-lightning-3/target/debug/build/thiserror-8230374e07b5c05a/out/probe.rs at line 1: - #![feature(provide_any)] +#![feature(provide_any)] - use std::any::{Demand, Provider}; +use std::any::{Demand, Provider}; - fn _f<'a, P: Provider>(p: &'a P, demand: &mut Demand<'a>) { - p.provide(demand); - } +fn _f<'a, P: Provider>(p: &'a P, demand: &mut Demand<'a>) { + p.provide(demand); +} ```
22 lines
595 B
Bash
Executable File
22 lines
595 B
Bash
Executable File
#!/bin/bash
|
|
set -eo pipefail
|
|
|
|
export LC_ALL=C
|
|
|
|
# Generate initial exclusion list
|
|
#find . -name '*.rs' -type f |sort >rustfmt_excluded_files
|
|
|
|
# The +rustversion syntax only works with rustup-installed rust toolchains,
|
|
# not with any distro-provided ones. Thus, we check for a rustup install and
|
|
# only pass +1.63.0 if we find one.
|
|
VERS=""
|
|
[ "$(which rustup)" != "" ] && VERS="+1.63.0"
|
|
|
|
# Run fmt
|
|
TMP_FILE=$(mktemp)
|
|
git ls-files | grep '.rs$' | sort >"$TMP_FILE"
|
|
for file in $(comm -23 "$TMP_FILE" rustfmt_excluded_files); do
|
|
echo "Formatting $file..."
|
|
rustfmt $VERS --edition 2021 "$file"
|
|
done
|