Skip to content

Commit 7b5e554

Browse files
committed
Instruct rustfmt to use --edition 2024
This is necessary in order for `rustfmt` to understand our (relatively-new) usages of rust `c"C Strings"`. However, the word `gen` has been promoted to a keyword in 2024 edition, which borks `rustfmt` in a different way. Fixing this requires that we have a version of bindgen with rust-lang/rust-bindgen#3100, which, of course, has not been released yet. So I don't know where to go next.
1 parent e35a74a commit 7b5e554

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

pgrx-bindgen/src/build.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,9 +1197,28 @@ fn rust_fmt(path: &Path) -> eyre::Result<()> {
11971197
// We shouldn't hit this path in a case where we care about it, but... just
11981198
// in case we probably should respect RUSTFMT.
11991199
let rustfmt = env_tracked("RUSTFMT").unwrap_or_else(|| "rustfmt".into());
1200-
let out = run_command(Command::new(rustfmt).arg(path).current_dir("."), "[bindings_diff]");
1200+
let mut command = Command::new(rustfmt);
1201+
command.arg(path).args(&["--edition", "2024"]).current_dir(".");
1202+
1203+
let out = run_command(&mut command, "[bindings_diff]");
12011204
match out {
1202-
Ok(_) => Ok(()),
1205+
Ok(output) if output.status.success() => Ok(()),
1206+
Ok(output) => {
1207+
let rustfmt_output = format!(
1208+
r#"Problems running rustfmt: {command:?}:
1209+
{}
1210+
{}"#,
1211+
String::from_utf8_lossy(&output.stdout),
1212+
String::from_utf8_lossy(&output.stderr)
1213+
);
1214+
1215+
for line in rustfmt_output.lines() {
1216+
println!("cargo:warning={}", line);
1217+
}
1218+
1219+
// we won't fail the build because rustfmt failed
1220+
Ok(())
1221+
}
12031222
Err(e)
12041223
if e.downcast_ref::<std::io::Error>()
12051224
.ok_or(eyre!("Couldn't downcast error ref"))?

0 commit comments

Comments
 (0)