* Re: [PATCH] rust: kbuild: give `--config-path` to `rustfmt` in `.rsi` target
2026-01-15 18:38 [PATCH] rust: kbuild: give `--config-path` to `rustfmt` in `.rsi` target Miguel Ojeda
@ 2026-01-16 5:00 ` Nathan Chancellor
2026-01-16 11:45 ` Miguel Ojeda
2026-01-16 11:43 ` Gary Guo
2026-01-18 19:43 ` Miguel Ojeda
2 siblings, 1 reply; 6+ messages in thread
From: Nathan Chancellor @ 2026-01-16 5:00 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Nicolas Schier, Boqun Feng, Gary Guo, Björn Roy Baron,
Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross,
Danilo Krummrich, rust-for-linux, linux-kbuild, stable
On Thu, Jan 15, 2026 at 07:38:32PM +0100, Miguel Ojeda wrote:
> `rustfmt` is configured via the `.rustfmt.toml` file in the source tree,
> and we apply `rustfmt` to the macro expanded sources generated by the
> `.rsi` target.
>
> However, under an `O=` pointing to an external folder (i.e. not just
> a subdir), `rustfmt` will not find the file when checking the parent
> folders. Since the edition is configured in this file, this can lead to
> errors when it encounters newer syntax, e.g.
>
> error: expected one of `!`, `.`, `::`, `;`, `?`, `where`, `{`, or an operator, found `"rust_minimal"`
> --> samples/rust/rust_minimal.rsi:29:49
> |
> 28 | impl ::kernel::ModuleMetadata for RustMinimal {
> | - while parsing this item list starting here
> 29 | const NAME: &'static ::kernel::str::CStr = c"rust_minimal";
> | ^^^^^^^^^^^^^^ expected one of 8 possible tokens
> 30 | }
> | - the item list ends here
> |
> = note: you may be trying to write a c-string literal
> = note: c-string literals require Rust 2021 or later
> = help: pass `--edition 2024` to `rustc`
> = note: for more on editions, read https://doc.rust-lang.org/edition-guide
>
> A workaround is to use `RUSTFMT=n`, which is documented in the `Makefile`
> help for cases where macro expanded source may happen to break `rustfmt`
> for other reasons, but this is not one of those cases.
>
> One solution would be to pass `--edition`, but we want `rustfmt` to
> use the entire configuration, even if currently we essentially use the
> default configuration.
>
> Thus explicitly give the path to the config file to `rustfmt` instead.
>
> Reported-by: Alice Ryhl <aliceryhl@google.com>
> Fixes: 2f7ab1267dc9 ("Kbuild: add Rust support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
I assume you will take this via the Rust tree?
> ---
> scripts/Makefile.build | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> index 5037f4715d74..0c838c467c76 100644
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -356,7 +356,7 @@ $(obj)/%.o: $(obj)/%.rs FORCE
> quiet_cmd_rustc_rsi_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@
> cmd_rustc_rsi_rs = \
> $(rust_common_cmd) -Zunpretty=expanded $< >$@; \
> - command -v $(RUSTFMT) >/dev/null && $(RUSTFMT) $@
> + command -v $(RUSTFMT) >/dev/null && $(RUSTFMT) --config-path $(srctree)/.rustfmt.toml $@
>
> $(obj)/%.rsi: $(obj)/%.rs FORCE
> +$(call if_changed_dep,rustc_rsi_rs)
>
> base-commit: 74e15ac34b098934895fd27655d098971d2b43d9
> --
> 2.52.0
>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] rust: kbuild: give `--config-path` to `rustfmt` in `.rsi` target
2026-01-16 5:00 ` Nathan Chancellor
@ 2026-01-16 11:45 ` Miguel Ojeda
0 siblings, 0 replies; 6+ messages in thread
From: Miguel Ojeda @ 2026-01-16 11:45 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Miguel Ojeda, Nicolas Schier, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, rust-for-linux, linux-kbuild,
stable
On Fri, Jan 16, 2026 at 6:00 AM Nathan Chancellor <nathan@kernel.org> wrote:
>
> Reviewed-by: Nathan Chancellor <nathan@kernel.org>
>
> I assume you will take this via the Rust tree?
Yeah, either way is fine, but I can put it in `rust-fixes` since I
will send a PR in a few days.
Thanks!
Cheers,
Miguel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] rust: kbuild: give `--config-path` to `rustfmt` in `.rsi` target
2026-01-15 18:38 [PATCH] rust: kbuild: give `--config-path` to `rustfmt` in `.rsi` target Miguel Ojeda
2026-01-16 5:00 ` Nathan Chancellor
@ 2026-01-16 11:43 ` Gary Guo
2026-01-18 19:43 ` Miguel Ojeda
2 siblings, 0 replies; 6+ messages in thread
From: Gary Guo @ 2026-01-16 11:43 UTC (permalink / raw)
To: Miguel Ojeda, Nathan Chancellor, Nicolas Schier
Cc: Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin,
Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich,
rust-for-linux, linux-kbuild, stable
On Thu Jan 15, 2026 at 6:38 PM GMT, Miguel Ojeda wrote:
> `rustfmt` is configured via the `.rustfmt.toml` file in the source tree,
> and we apply `rustfmt` to the macro expanded sources generated by the
> `.rsi` target.
>
> However, under an `O=` pointing to an external folder (i.e. not just
> a subdir), `rustfmt` will not find the file when checking the parent
> folders. Since the edition is configured in this file, this can lead to
> errors when it encounters newer syntax, e.g.
>
> error: expected one of `!`, `.`, `::`, `;`, `?`, `where`, `{`, or an operator, found `"rust_minimal"`
> --> samples/rust/rust_minimal.rsi:29:49
> |
> 28 | impl ::kernel::ModuleMetadata for RustMinimal {
> | - while parsing this item list starting here
> 29 | const NAME: &'static ::kernel::str::CStr = c"rust_minimal";
> | ^^^^^^^^^^^^^^ expected one of 8 possible tokens
> 30 | }
> | - the item list ends here
> |
> = note: you may be trying to write a c-string literal
> = note: c-string literals require Rust 2021 or later
> = help: pass `--edition 2024` to `rustc`
> = note: for more on editions, read https://doc.rust-lang.org/edition-guide
>
> A workaround is to use `RUSTFMT=n`, which is documented in the `Makefile`
> help for cases where macro expanded source may happen to break `rustfmt`
> for other reasons, but this is not one of those cases.
>
> One solution would be to pass `--edition`, but we want `rustfmt` to
> use the entire configuration, even if currently we essentially use the
> default configuration.
>
> Thus explicitly give the path to the config file to `rustfmt` instead.
>
> Reported-by: Alice Ryhl <aliceryhl@google.com>
> Fixes: 2f7ab1267dc9 ("Kbuild: add Rust support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Reviewed-by: Gary Guo <gary@garyguo.net>
> ---
> scripts/Makefile.build | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] rust: kbuild: give `--config-path` to `rustfmt` in `.rsi` target
2026-01-15 18:38 [PATCH] rust: kbuild: give `--config-path` to `rustfmt` in `.rsi` target Miguel Ojeda
2026-01-16 5:00 ` Nathan Chancellor
2026-01-16 11:43 ` Gary Guo
@ 2026-01-18 19:43 ` Miguel Ojeda
2026-01-18 21:27 ` Alice Ryhl
2 siblings, 1 reply; 6+ messages in thread
From: Miguel Ojeda @ 2026-01-18 19:43 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Nathan Chancellor, Nicolas Schier, Boqun Feng, Gary Guo,
Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl,
Trevor Gross, Danilo Krummrich, rust-for-linux, linux-kbuild,
stable
On Thu, Jan 15, 2026 at 7:38 PM Miguel Ojeda <ojeda@kernel.org> wrote:
>
> `rustfmt` is configured via the `.rustfmt.toml` file in the source tree,
> and we apply `rustfmt` to the macro expanded sources generated by the
> `.rsi` target.
>
> However, under an `O=` pointing to an external folder (i.e. not just
> a subdir), `rustfmt` will not find the file when checking the parent
> folders. Since the edition is configured in this file, this can lead to
> errors when it encounters newer syntax, e.g.
>
> error: expected one of `!`, `.`, `::`, `;`, `?`, `where`, `{`, or an operator, found `"rust_minimal"`
> --> samples/rust/rust_minimal.rsi:29:49
> |
> 28 | impl ::kernel::ModuleMetadata for RustMinimal {
> | - while parsing this item list starting here
> 29 | const NAME: &'static ::kernel::str::CStr = c"rust_minimal";
> | ^^^^^^^^^^^^^^ expected one of 8 possible tokens
> 30 | }
> | - the item list ends here
> |
> = note: you may be trying to write a c-string literal
> = note: c-string literals require Rust 2021 or later
> = help: pass `--edition 2024` to `rustc`
> = note: for more on editions, read https://doc.rust-lang.org/edition-guide
>
> A workaround is to use `RUSTFMT=n`, which is documented in the `Makefile`
> help for cases where macro expanded source may happen to break `rustfmt`
> for other reasons, but this is not one of those cases.
>
> One solution would be to pass `--edition`, but we want `rustfmt` to
> use the entire configuration, even if currently we essentially use the
> default configuration.
>
> Thus explicitly give the path to the config file to `rustfmt` instead.
>
> Reported-by: Alice Ryhl <aliceryhl@google.com>
> Fixes: 2f7ab1267dc9 ("Kbuild: add Rust support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Applied to `rust-fixes` -- thanks everyone!
Cheers,
Miguel
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] rust: kbuild: give `--config-path` to `rustfmt` in `.rsi` target
2026-01-18 19:43 ` Miguel Ojeda
@ 2026-01-18 21:27 ` Alice Ryhl
0 siblings, 0 replies; 6+ messages in thread
From: Alice Ryhl @ 2026-01-18 21:27 UTC (permalink / raw)
To: Miguel Ojeda
Cc: Miguel Ojeda, Nathan Chancellor, Nicolas Schier, Boqun Feng,
Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg,
Trevor Gross, Danilo Krummrich, rust-for-linux, linux-kbuild,
stable
On Sun, Jan 18, 2026 at 8:43 PM Miguel Ojeda
<miguel.ojeda.sandonis@gmail.com> wrote:
>
> On Thu, Jan 15, 2026 at 7:38 PM Miguel Ojeda <ojeda@kernel.org> wrote:
> >
> > `rustfmt` is configured via the `.rustfmt.toml` file in the source tree,
> > and we apply `rustfmt` to the macro expanded sources generated by the
> > `.rsi` target.
> >
> > However, under an `O=` pointing to an external folder (i.e. not just
> > a subdir), `rustfmt` will not find the file when checking the parent
> > folders. Since the edition is configured in this file, this can lead to
> > errors when it encounters newer syntax, e.g.
> >
> > error: expected one of `!`, `.`, `::`, `;`, `?`, `where`, `{`, or an operator, found `"rust_minimal"`
> > --> samples/rust/rust_minimal.rsi:29:49
> > |
> > 28 | impl ::kernel::ModuleMetadata for RustMinimal {
> > | - while parsing this item list starting here
> > 29 | const NAME: &'static ::kernel::str::CStr = c"rust_minimal";
> > | ^^^^^^^^^^^^^^ expected one of 8 possible tokens
> > 30 | }
> > | - the item list ends here
> > |
> > = note: you may be trying to write a c-string literal
> > = note: c-string literals require Rust 2021 or later
> > = help: pass `--edition 2024` to `rustc`
> > = note: for more on editions, read https://doc.rust-lang.org/edition-guide
> >
> > A workaround is to use `RUSTFMT=n`, which is documented in the `Makefile`
> > help for cases where macro expanded source may happen to break `rustfmt`
> > for other reasons, but this is not one of those cases.
> >
> > One solution would be to pass `--edition`, but we want `rustfmt` to
> > use the entire configuration, even if currently we essentially use the
> > default configuration.
> >
> > Thus explicitly give the path to the config file to `rustfmt` instead.
> >
> > Reported-by: Alice Ryhl <aliceryhl@google.com>
> > Fixes: 2f7ab1267dc9 ("Kbuild: add Rust support")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
>
> Applied to `rust-fixes` -- thanks everyone!
Thanks Miguel for looking into this.
Alice
^ permalink raw reply [flat|nested] 6+ messages in thread