From 060a8adf6e6ba7586fe5eb3d9081c602a5ea3da8 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 23 Jun 2024 19:29:44 -0700 Subject: [PATCH 1/2] Update rustfmt output to nightly-2024-06-24 --- examples/output.rustfmt.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/examples/output.rustfmt.rs b/examples/output.rustfmt.rs index 3c7181d..82cc2cb 100644 --- a/examples/output.rustfmt.rs +++ b/examples/output.rustfmt.rs @@ -1,3 +1,10 @@ +rewriting static +rewriting static +rewriting static +rewriting static +rewriting static +rewriting static +rewriting static use crate::cmp::Ordering; use crate::fmt::{self, Write as FmtWrite}; use crate::hash; From 39a3f750187f63b395bdff1d38da75a8bfe0f242 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 23 Jun 2024 19:28:00 -0700 Subject: [PATCH 2/2] Work around rustfmt 'rewriting static' bug --- examples/output.rustfmt.rs | 7 ------- examples/update/update-examples.rs | 9 ++++++++- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/output.rustfmt.rs b/examples/output.rustfmt.rs index 82cc2cb..3c7181d 100644 --- a/examples/output.rustfmt.rs +++ b/examples/output.rustfmt.rs @@ -1,10 +1,3 @@ -rewriting static -rewriting static -rewriting static -rewriting static -rewriting static -rewriting static -rewriting static use crate::cmp::Ordering; use crate::fmt::{self, Write as FmtWrite}; use crate::hash; diff --git a/examples/update/update-examples.rs b/examples/update/update-examples.rs index f6a0d23..0be9527 100644 --- a/examples/update/update-examples.rs +++ b/examples/update/update-examples.rs @@ -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") @@ -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(()) }