Skip to content

Commit

Permalink
Work around rustfmt 'rewriting static' bug
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jun 24, 2024
1 parent 060a8ad commit 39a3f75
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
7 changes: 0 additions & 7 deletions examples/output.rustfmt.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion examples/update/update-examples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn main() -> Result<()> {

// Write output.rustfmt.rs
let output_path = manifest_dir.join("..").join("output.rustfmt.rs");
let output_file = File::create(output_path)?;
let output_file = File::create(&output_path)?;
Command::new("rustfmt")
.arg("--edition=2021")
.arg("--config=reorder_imports=false")
Expand All @@ -63,5 +63,12 @@ fn main() -> Result<()> {
.spawn()?
.wait()?;

// Work around https://github.com/rust-lang/rustfmt/issues/6210
let rustfmt_content = fs::read_to_string(&output_path)?;
fs::write(
&output_path,
rustfmt_content.replace("rewriting static\n", ""),
)?;

Ok(())
}

0 comments on commit 39a3f75

Please sign in to comment.