Skip to content

Commit 9042f42

Browse files
authored
rustfmt cleanup (#2553)
Closes #2540 * test-one: use prettyplease to format generated code * contributing: note the prettyplease change, state that it is an optional dependency of bindgen, not bindgen-cli
1 parent df439e9 commit 9042f42

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

CONTRIBUTING.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,18 @@ There are also some integration tests in the `./bindgen-integration` crate, whic
104104
generate bindings to some C++ code, and then uses the bindings, asserting that
105105
values are what we expect them to be, both on the Rust and C++ side.
106106

107-
The generated and expected bindings are run through `rustfmt` before they are
108-
compared. Make sure you have `rustfmt` up to date:
109-
110-
```
111-
$ rustup update nightly
112-
$ rustup component add rustfmt --toolchain nightly
113-
```
107+
The generated and expected bindings are formatted with [prettyplease] before they are
108+
compared. It is a default (but optional) dependency of `bindgen`,
109+
so be sure to keep that in mind
110+
(if you built `bindgen` with the `--no-default-features` option of Cargo).
111+
Note also that `rustfmt` formatting is disabled for the `bindgen-tests/tests/expectations/`
112+
directory tree, which helps avoid failing ui tests.
114113

115114
Note: running `cargo test` from the root directory of `bindgen`'s repository does not
116115
automatically test the generated bindings or run the integration tests.
117116
These steps must be performed manually when needed.
118117

118+
119119
### Testing Bindings Generation
120120

121121
To regenerate bindings from the corpus of test headers in `bindgen-tests/tests/headers` and
@@ -576,3 +576,6 @@ $ git push --tags upstream # To publish the tag
576576
### Create a new release on Github
577577

578578
See [Releasing projects on Github](https://docs.github.com/en/repositories/releasing-projects-on-github)
579+
580+
581+
[prettyplease]: https://github.com/dtolnay/prettyplease

bindgen-tests/tests/test-one.sh

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,18 @@ TEST_BINDINGS_BINARY=$(mktemp -t bindings.XXXXXX)
4545
FLAGS="$(grep "// bindgen-flags: " "$TEST" || echo)"
4646
FLAGS="${FLAGS/\/\/ bindgen\-flags:/}"
4747
# Prepend the default flags added in test.rs's `create_bindgen_builder`.
48-
FLAGS="--rustfmt-bindings --with-derive-default --raw-line '' --raw-line '#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]' --raw-line '' $FLAGS"
48+
FLAGS="--with-derive-default --raw-line '' --raw-line '#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]' --raw-line '' $FLAGS"
4949

5050

5151
eval ../target/debug/bindgen \
5252
"\"$TEST\"" \
5353
--emit-ir \
5454
--emit-ir-graphviz ir.dot \
5555
--emit-clang-ast \
56+
--formatter prettyplease \
5657
-o "\"$BINDINGS\"" \
5758
$FLAGS
5859

59-
rustup run nightly rustfmt "$BINDINGS" || true
60-
6160
dot -Tpng ir.dot -o ir.png
6261

6362
echo
@@ -80,8 +79,6 @@ EXPECTED=${TEST/headers/expectations\/tests}
8079
EXPECTED=${EXPECTED/.hpp/.rs}
8180
EXPECTED=${EXPECTED/.h/.rs}
8281

83-
rustup run nightly rustfmt "$EXPECTED" || true
84-
8582
# Don't exit early if there is a diff.
8683
diff -U8 "$EXPECTED" "$BINDINGS" || true
8784

0 commit comments

Comments
 (0)