Skip to content

Commit

Permalink
exclude generated code from rustfmt using attribute
Browse files Browse the repository at this point in the history
instead of deleting it before running cargo fmt
  • Loading branch information
wfraser committed Jan 13, 2025
1 parent f7f8751 commit cb9e9c2
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 5 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/cargo-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,9 @@ jobs:
rustup component add rustfmt --toolchain nightly
- name: Run rustfmt
# Delete the generated code so it doesn't get formatted.
# We'll be re-running the generator later, so this is okay.
run: |
rm -rf src/generated
echo "// empty module for rustfmt" > src/generated.rs
echo "// empty module for rustfmt" > tests/generated.rs
rustup run nightly cargo fmt --check
rm src/generated.rs
rm tests/generated.rs
- name: Set up Python
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ mod client_helpers;
pub mod oauth2;

// You need to run the Stone generator to create this module.
#[rustfmt::skip]
mod generated;
pub use generated::*;

Expand Down
1 change: 1 addition & 0 deletions tests/generated_tests.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![warn(rust_2018_idioms)]

#[rustfmt::skip]
mod generated; // You need to run the Stone generator to create this module.

0 comments on commit cb9e9c2

Please sign in to comment.