From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B57E2346E4C; Fri, 16 Jan 2026 05:00:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768539652; cv=none; b=HdFpurBYe2BC/7OJLKUXsUfEFJGD6fWMnMWVzC6K4BKoWA8BgPnQ55CVCcWraH4AOR/AUY3GoJNMwnnFPtK7hQiFbkHXUBaCEQ6eC6gdfE3kq0AJIReeghtUvnh0bpP3IdjjxAFT2iixIqV5XHVIc4wbZNDQK5gv4gFIeAlnh54= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768539652; c=relaxed/simple; bh=xSptFaBZ/Dy9J1LxiE5xyKBnbnA4K005bsuBlQwSzdc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=RGKgEv9luXf9+NQFQVA0AozQnFkx02l11IvhyghnMof84AXNTo4HJK75gxS7XSPNMiNds7KYGsIb2a9eWaElNJVTkA+tIa4m6wkmn5y6RQdyZXdzMODUh8ulQXUCC88n6DHOoi7k7EVQa04Ym7U/KkfQC2WuhSmCS6blLLlaYLM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eqI1kM87; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eqI1kM87" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 98074C116C6; Fri, 16 Jan 2026 05:00:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768539652; bh=xSptFaBZ/Dy9J1LxiE5xyKBnbnA4K005bsuBlQwSzdc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=eqI1kM87ra5XPhHD+gzZ9ZLCwxmr3Ap+6tr+veXwQVeOr0dNQkS677oxFC+Et47fE dJS/xVxYl3ZW0a/LdIvtMmQQYdY918oqjox0s6zWJeCn0vhSfHg4Mel4xygvuw7X5+ bpSzQmfRmtMEnNl20e7y6HhCCTP2eVC5ikZGs9fZAzF1X8EV1buTs/w66BK6iHEwmo x6qNCi4kLU/bqp84B4Pfdi1Rd+IFfHcHh3jlMyWzBrEUxZoq8wUCcBp+w95jOC/+7J LphKeRVkzXVG9PBklURl9pJQZ3uzhkS3oSMvxolIShrjV2ryAMkzGjMOaowmmzscM4 4Dgacl6kXevKg== Date: Thu, 15 Jan 2026 22:00:46 -0700 From: Nathan Chancellor To: Miguel Ojeda Cc: Nicolas Schier , Boqun Feng , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , rust-for-linux@vger.kernel.org, linux-kbuild@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] rust: kbuild: give `--config-path` to `rustfmt` in `.rsi` target Message-ID: <20260116050046.GA1452322@ax162> References: <20260115183832.46595-1-ojeda@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260115183832.46595-1-ojeda@kernel.org> 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 > Fixes: 2f7ab1267dc9 ("Kbuild: add Rust support") > Cc: stable@vger.kernel.org > Signed-off-by: Miguel Ojeda Reviewed-by: Nathan Chancellor 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 >