From 73a08d360b88313e47f2f1cc44979faaa4385f0d Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Mon, 20 Oct 2025 16:32:40 +0200 Subject: [PATCH] feat: add support for specifying rustfmt `--edition` flag via generator options fixes https://github.com/varlink/rust/issues/124 --- varlink_generator/src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/varlink_generator/src/lib.rs b/varlink_generator/src/lib.rs index ab44a34..8507ecf 100644 --- a/varlink_generator/src/lib.rs +++ b/varlink_generator/src/lib.rs @@ -81,6 +81,7 @@ pub struct GeneratorOptions { pub string_type: Option<&'static str>, pub preamble: Option, pub generate_async: bool, + pub fmt_edition: Option<&'static str>, } impl<'short, 'long: 'short> ToRustString<'short, 'long> for VType<'long> { @@ -1317,6 +1318,7 @@ pub fn cargo_build_tosource + ?Sized>(input_path: &T, rustfmt: bo /// true, /// &varlink_generator::GeneratorOptions { /// int_type: Some("i128"), +/// fmt_edition: Some("2021"), /// ..Default::default() /// }, /// ); @@ -1368,8 +1370,10 @@ pub fn cargo_build_tosource_options + ?Sized>( } if rustfmt { + let edition = options.fmt_edition.unwrap_or("2018"); if let Err(e) = Command::new("rustfmt") - .arg("--edition=2018") + .arg("--edition") + .arg(edition) .arg(rust_path.to_str().unwrap()) .output() {