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 C275541B357; Wed, 4 Feb 2026 15:25:07 +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=1770218707; cv=none; b=dnIwVXycceDznlq1P8DrLDeZ1Ej310EZzuVQZJ/b+l0TYuSikMYINjQoUOHpQaa80YJwtmjtBgnY7ng6L02LBUayiONvUzAMFCda3RVXu5xCdjykXBORYQkbiILcQ85poaII2k9v+cbmXowTJu2KGK+64v1hOm2T/wb32ILXTvw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770218707; c=relaxed/simple; bh=6GTDv+QoSOIbE3p62gHoiAD7M7113sHKZ5J/yKS9zWo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g2jCS6GqG99QkQhru1yev6NfpDI4vtgUMZX4AE2WtiyNC62mTGHtphd4eIx2La/NsjYl6K7h2YkulPDUyC9EiFP7EcHXYyrxlD1fcW+RY2ZSTgo0r3MnGZNjBgpz3SYbFJfQhVQZt/nDQcmkP1sxSoBVPF4E6XDm19wi4raTMUU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=VoG8ZUvE; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="VoG8ZUvE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3457DC4CEF7; Wed, 4 Feb 2026 15:25:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1770218707; bh=6GTDv+QoSOIbE3p62gHoiAD7M7113sHKZ5J/yKS9zWo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VoG8ZUvEF3wkRrC1AOkyFHY2zhBYI0w3t3rNs5eG0Z6GjmntCOcjsCtd0yY/sSc9/ pFNUBCKpNcBaQCFQxKJFEYnExyxCjqn4Ylv5/dDihWDFD6s5GGTBKpqaS4kpCX2iPm UHOvOQJ0v9kFueL56lvHadyhQ6M0fdBAdAFa9C7U= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Alice Ryhl , Nathan Chancellor , Gary Guo , Miguel Ojeda Subject: [PATCH 6.12 37/87] rust: kbuild: give `--config-path` to `rustfmt` in `.rsi` target Date: Wed, 4 Feb 2026 15:40:35 +0100 Message-ID: <20260204143848.248539299@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260204143846.906385641@linuxfoundation.org> References: <20260204143846.906385641@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Miguel Ojeda commit af20ae33e7dd949f2e770198e74ac8f058cb299d upstream. `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 Reviewed-by: Nathan Chancellor Reviewed-by: Gary Guo Link: https://patch.msgid.link/20260115183832.46595-1-ojeda@kernel.org Signed-off-by: Miguel Ojeda Signed-off-by: Greg Kroah-Hartman --- scripts/Makefile.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -286,7 +286,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)