Skip to content

Commit 31f8afa

Browse files
ojedaAndreas Hindborg
authored andcommitted
LIST: [PATCH v10 4/5] rust: kbuild: provide RUSTC_HAS_DO_NOT_RECOMMEND symbol
Rust 1.85.0 (current stable version) stabilized [1] `#[diagnostic::do_not_recommend]` [2]. In order to use it across all supported Rust versions, introduce a new Kconfig symbol for it. This allows to perform conditional compilation based on it, e.g. on the use site to enable the attribute: #[cfg_attr(RUSTC_HAS_DO_NOT_RECOMMEND, diagnostic::do_not_recommend)] impl A for i32 {} An alternative would have been to `allow` the following warning: #![allow(unknown_or_malformed_diagnostic_attributes)] However, that would lose the checking for typos across all versions, which we do not want to lose. One can also use the Kconfig symbol to allow the warning in older compilers instead, to avoid repeating the `cfg_attr` line above in all use sites: #![cfg_attr( not(RUSTC_HAS_DO_NOT_RECOMMEND), expect(unknown_or_malformed_diagnostic_attributes) )] That still loses the checking for typos in older versions, but we still keep it in newer ones, thus we should still catch mistakes eventually. In this case we can promote it to `expect` as shown above, so that we do not forget to remove these lines if we stop using the attribute somewhere. Link: rust-lang/rust#132056 [1] Link: https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-diagnosticdo_not_recommend-attribute [2] Link: https://lore.kernel.org/rust-for-linux/CANiq72mYfhuRWkjomb1vOMMPOaxvdS6qjfVLAwxUw6ecdqyh2A@mail.gmail.com/ Signed-off-by: Miguel Ojeda <ojeda@kernel.org> Signed-off-by: Oliver Mangold <oliver.mangold@pm.me> Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org> Link: https://lore.kernel.org/r/20250502-unique-ref-v10-4-25de64c0307f@pm.me
1 parent 0f26fde commit 31f8afa

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

‎init/Kconfig‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ config RUSTC_HAS_COERCE_POINTEE
153153
config RUSTC_HAS_UNNECESSARY_TRANSMUTES
154154
def_bool RUSTC_VERSION >= 108800
155155

156+
config RUSTC_HAS_DO_NOT_RECOMMEND
157+
def_bool RUSTC_VERSION >= 108500
158+
156159
config PAHOLE_VERSION
157160
int
158161
default $(shell,$(srctree)/scripts/pahole-version.sh $(PAHOLE))

0 commit comments

Comments
 (0)