From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-24416.protonmail.ch (mail-24416.protonmail.ch [109.224.244.16]) (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 71CED2566CC for ; Tue, 25 Mar 2025 11:57:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=109.224.244.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742903849; cv=none; b=bILPvpQvi3NBOed+FCGxk8botM9fGYjJs9jhzT9NJfTxFIfrsvgu3HCARpMxtjHwwE/3Kq5NAfZo1Fa7DWWHHAHxz24wb18YbugrFdXNEstnxUJeS5RdcHIv/QEQb5vTsWkG633TkeAOk5C7hS4xrLLCIO84N0aWKu948stGTn4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742903849; c=relaxed/simple; bh=rLQI/6fN0QaLeCKW9O3VtH5UCERFGDVomzdGR8mNhlg=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YwbQO8GYu1513tRiIiNymulFc8tJIl5GJfJeZ1Zcy6ymUiGfo33TMxE69vebS1zTPXH0DodOvEiK8ish71myPyW0My3PTQ0+adZH/PA1Ea93LRXCRYUaeNDM/F1/Ksjf7JB0BCQNGHcoOLaPIkPVmNMs2ZvL0c6zyisHjJd4kFI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pm.me; spf=pass smtp.mailfrom=pm.me; dkim=pass (2048-bit key) header.d=pm.me header.i=@pm.me header.b=c/Jlzl29; arc=none smtp.client-ip=109.224.244.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=pm.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pm.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pm.me header.i=@pm.me header.b="c/Jlzl29" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail3; t=1742903845; x=1743163045; bh=taOLR4DIcs8sPK6pnTo5SoNNIDGeCkilbyXwLsZy6oY=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=c/Jlzl294w+/SCmJs0l8SvHDGDb+OHmpykVJ9uakEoHQQTmc9K28tl8Llqjk6z3S2 2JEdv8psLdsS8mEjhrANihwCZUP4JXxIM26Q2kPEZJVRU7mggwCiIlGyHFbqR0S6zv jOwrr+QsWDJVwhd/TFaGlwpsYx0ePD5oQz+l4pZRnPDpzPWYJ1WZ/OZJUQOa1j6/mD abdNNo2EvLzKTiXK4jKLnDqrUL8iPRLptWvDGcGlcs9I+QbJ0G1YbUiLoJvzaRYs+d NQDVyAYEU5ml4LJXk/za/5/032B0ip4fCpSnbqHK/tQmlGRPot3UGtQ3MDFUU+1chX TqWCF+BG7RTJg== Date: Tue, 25 Mar 2025 11:57:19 +0000 To: Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Asahi Lina From: Oliver Mangold Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Oliver Mangold Subject: [PATCH v9 4/5] rust: kbuild: provide `RUSTC_HAS_DO_NOT_RECOMMEND` symbol Message-ID: <20250325-unique-ref-v9-4-e91618c1de26@pm.me> In-Reply-To: <20250325-unique-ref-v9-0-e91618c1de26@pm.me> References: <20250325-unique-ref-v9-0-e91618c1de26@pm.me> Feedback-ID: 31808448:user:proton X-Pm-Message-ID: 494c905c3523f6e9620cce5c54fd3b8a18a34a23 Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Miguel Ojeda 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: https://github.com/rust-lang/rust/pull/132056 [1] Link: https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-d= iagnosticdo_not_recommend-attribute [2] Link: https://lore.kernel.org/rust-for-linux/CANiq72mYfhuRWkjomb1vOMMPOaxvd= S6qjfVLAwxUw6ecdqyh2A@mail.gmail.com/ Signed-off-by: Miguel Ojeda Signed-off-by: Oliver Mangold --- init/Kconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/init/Kconfig b/init/Kconfig index 324c2886b2ea31e84d6ff221338a1effa06298f2..6dd58788636ef26e017f704b2c0= 088401f28943c 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -132,6 +132,9 @@ config CC_HAS_COUNTED_BY config RUSTC_HAS_COERCE_POINTEE =09def_bool RUSTC_VERSION >=3D 108400 =20 +config RUSTC_HAS_DO_NOT_RECOMMEND +=09def_bool RUSTC_VERSION >=3D 108500 + config PAHOLE_VERSION =09int =09default $(shell,$(srctree)/scripts/pahole-version.sh $(PAHOLE)) --=20 2.49.0