summaryrefslogtreecommitdiffstats
path: root/third_party/rust/leb128/format
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/rust/leb128/format')
-rwxr-xr-xthird_party/rust/leb128/format33
1 files changed, 33 insertions, 0 deletions
diff --git a/third_party/rust/leb128/format b/third_party/rust/leb128/format
new file mode 100755
index 0000000000..7221f10c74
--- /dev/null
+++ b/third_party/rust/leb128/format
@@ -0,0 +1,33 @@
+#!/usr/bin/env bash
+
+# Usage:
+# ./format
+#
+# Run `rustfmt` on all the Rust source files in this project, modifying them in
+# place. Usually, one would use `cargo fmt` for this task, but that seems to be
+# broken for me at the moment.
+
+RUSTFMT=""
+
+function maybe_set() {
+ if [[ $RUSTFMT == "" && -f "$1" ]]; then
+ RUSTFMT="$1"
+ fi
+}
+
+maybe_set ~/.multirust/toolchains/nightly/cargo/bin/rustfmt
+maybe_set ~/.cargo/bin/rustfmt
+maybe_set $(which rustfmt)
+
+if [[ $RUSTFMT == "" ]]; then
+ echo "$0: error: could not find an appropriate rustfmt binary!"
+ exit 1
+fi
+
+echo "$0: using rustfmt=$RUSTFMT"
+
+cd $(dirname $0)
+RUST_FILES=$(find src -type f -name '*.rs')
+
+$RUSTFMT -v --write-mode replace $RUST_FILES 2>&1 \
+ | xargs -I '{}' echo "rustfmt: {}"