From d1c4be045fa2f30a0823e1238fb62ffd72968d15 Mon Sep 17 00:00:00 2001 From: Techassi Date: Thu, 3 Apr 2025 16:07:16 +0200 Subject: [PATCH] chore(template): Template Rust edition in rustfmt config --- config/versions.yaml | 4 ++++ template/.vscode/settings.json.j2 | 2 ++ template/{rustfmt.toml => rustfmt.toml.j2} | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) rename template/{rustfmt.toml => rustfmt.toml.j2} (92%) diff --git a/config/versions.yaml b/config/versions.yaml index 5d7f1abf..b99dfc7a 100644 --- a/config/versions.yaml +++ b/config/versions.yaml @@ -9,6 +9,10 @@ rust_version: 1.85.0 # used in the operator-rs repository. rust_nightly_version: nightly-2025-01-15 +# This edition is mostly used for rustfmt commands and the rustfmt config file. The edition should +# be kept in line with the edition in the operator-rs repository. +rust_edition: 2024 + # IMPORTANT # If you change the Hadolint version here, make sure to also change the hook # refs in the local and templated .pre-commit-config.yaml files. diff --git a/template/.vscode/settings.json.j2 b/template/.vscode/settings.json.j2 index 46954211..670ffe48 100644 --- a/template/.vscode/settings.json.j2 +++ b/template/.vscode/settings.json.j2 @@ -2,6 +2,8 @@ "rust-analyzer.rustfmt.overrideCommand": [ "rustfmt", "+{[rust_nightly_version}]", + "--edition", + "{[rust_edition}]", "--" ], } diff --git a/template/rustfmt.toml b/template/rustfmt.toml.j2 similarity index 92% rename from template/rustfmt.toml rename to template/rustfmt.toml.j2 index 07217b21..2ae67801 100644 --- a/template/rustfmt.toml +++ b/template/rustfmt.toml.j2 @@ -2,7 +2,7 @@ # It's also ok to use the stable toolchain by simple running "cargo fmt", but using the nigthly formatter is prefered. # https://doc.rust-lang.org/nightly/edition-guide/rust-2024/rustfmt-style-edition.html -style_edition = "2024" +style_edition = "{[rust_edition}]" imports_granularity = "Crate" group_imports = "StdExternalCrate" reorder_impl_items = true