rust: pin-init: examples: conditionally enable `feature(lint_reasons)`
authorBenno Lossin <benno.lossin@proton.me>
Mon, 14 Apr 2025 20:00:20 +0000 (20:00 +0000)
committerBenno Lossin <benno.lossin@proton.me>
Mon, 21 Apr 2025 21:19:12 +0000 (23:19 +0200)
`lint_reasons` is unstable in Rust 1.80 and earlier, enable it
conditionally in the examples to allow compiling them with older
compilers.

Link: https://github.com/Rust-for-Linux/pin-init/pull/33/commits/ec494fe686b0a97d5b59b5be5a42d3858038ea6a
Link: https://lore.kernel.org/all/20250414195928.129040-3-benno.lossin@proton.me
Signed-off-by: Benno Lossin <benno.lossin@proton.me>
rust/pin-init/examples/linked_list.rs
rust/pin-init/examples/mutex.rs
rust/pin-init/examples/pthread_mutex.rs
rust/pin-init/examples/static_init.rs

index 6d7eb0a0ec0dfd9a0d75d4b4ede8ab1555dee4c0..0bbc7b8d83a122c694a1ef202b92cfaf214be608 100644 (file)
@@ -2,6 +2,7 @@
 
 #![allow(clippy::undocumented_unsafe_blocks)]
 #![cfg_attr(feature = "alloc", feature(allocator_api))]
+#![cfg_attr(not(RUSTC_LINT_REASONS_IS_STABLE), feature(lint_reasons))]
 
 use core::{
     cell::Cell,
index 073bb79341d154ec359164275c90859655d80476..3e3630780c96ed7ba3a08da96fe32f41d2f0999e 100644 (file)
@@ -2,6 +2,7 @@
 
 #![allow(clippy::undocumented_unsafe_blocks)]
 #![cfg_attr(feature = "alloc", feature(allocator_api))]
+#![cfg_attr(not(RUSTC_LINT_REASONS_IS_STABLE), feature(lint_reasons))]
 #![allow(clippy::missing_safety_doc)]
 
 use core::{
index 5ac22f1880d2f7be7b16c22d17c19c9b8b867757..074ebf485a97f40101f0170f91b94600076ee5d8 100644 (file)
@@ -3,6 +3,8 @@
 // inspired by <https://github.com/nbdd0121/pin-init/blob/trunk/examples/pthread_mutex.rs>
 #![allow(clippy::undocumented_unsafe_blocks)]
 #![cfg_attr(feature = "alloc", feature(allocator_api))]
+#![cfg_attr(not(RUSTC_LINT_REASONS_IS_STABLE), feature(lint_reasons))]
+
 #[cfg(not(windows))]
 mod pthread_mtx {
     #[cfg(feature = "alloc")]
index 3487d761aa2621745e1cefdf7a8eea1b8879b4ac..48531413ab94513e1e0b690fb25fb46e16361b9b 100644 (file)
@@ -2,6 +2,7 @@
 
 #![allow(clippy::undocumented_unsafe_blocks)]
 #![cfg_attr(feature = "alloc", feature(allocator_api))]
+#![cfg_attr(not(RUSTC_LINT_REASONS_IS_STABLE), feature(lint_reasons))]
 
 use core::{
     cell::{Cell, UnsafeCell},