From patchwork Mon Apr 14 20:00:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benno Lossin X-Patchwork-Id: 14050982 Received: from mail-4316.protonmail.ch (mail-4316.protonmail.ch [185.70.43.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 612B21D618A for ; Mon, 14 Apr 2025 20:00:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.70.43.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744660814; cv=none; b=IQvrbds+2nHAZrMONBaQFb3CmoAIRxOMgrKnkF433eCQ6ihe6RF4/BnOLe2ijb1K5MxIFjOoVMrIp/+6w3shlY4XQy8IcCbbsuglGCJMLxzDAG3n2YwHu2yez7NsUGZU1FiXis8C/9oxkuKwsZVGPaVQPr0IBA8rnPT/FUXHn5M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744660814; c=relaxed/simple; bh=onkGD7IMGYYTDQ1k9EeiYgsn35bofu/HwOQD6cSvNlQ=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Chj/q971jJLub7rogEnmMhGjZvDGaehg1O68110gNRdu9D0WJ4YqoeRNNLxWznXeQGvLw7vumf0xDMHlHS0R4/mXBaEwNZ4PZop4XLWq3yxM3A7rup7KltPqXYHHwz/1ERAnIZKhIdBQ047lunXteHi8DtVNe2p4V5lrfVC0tG8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me; spf=pass smtp.mailfrom=proton.me; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b=mTZbbvq5; arc=none smtp.client-ip=185.70.43.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=proton.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b="mTZbbvq5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1744660810; x=1744920010; bh=1rLZ1Gjo2Q6wANcQPpDmCfAuAi8w2svdSSCbs+ToqpE=; 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=mTZbbvq5/fjWisurh/tWftCph+iFfW+F2Zbfski/3fZLRTsoPgDxklkWPTmR8X7tF Kqk+5e8Q6yomyKMdbHtq5Fl7fpkTtv6e0WhxBhJUThSRzgPT/FCESh3CUBQ9AYgbQ2 0xxYJHCMHk6nEe/R2re+yIxn7K8qSYe7bQWfUJ0LfXEqJI0rp1sPAS22Cy4Uc3GxXi muy03U0TWjyIfy6/HhoEghPDP3kaeWCXno+MxDH3Uz8zcvJQTj3wvy12Rsb17NRNjr KPiBEfyygmNyxbkwiEwgPAYi0LGiFYpldxcE9CHQSjFM+oWuWqnzjjQECwaOQA3/fE R6Y2Up7msnHDw== Date: Mon, 14 Apr 2025 20:00:03 +0000 To: Benno Lossin , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Fiona Behrens From: Benno Lossin Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] rust: pin-init: internal: skip rustfmt formatting of kernel-only module Message-ID: <20250414195928.129040-2-benno.lossin@proton.me> In-Reply-To: <20250414195928.129040-1-benno.lossin@proton.me> References: <20250414195928.129040-1-benno.lossin@proton.me> Feedback-ID: 71780778:user:proton X-Pm-Message-ID: 3121d4f810d1bc5aa2915236284e3cc2c00020a5 Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The `quote` module only is available in the kernel and thus running `cargo fmt` or `rustfmt internal/src/lib.rs` in the user-space repository [1] results in: error: couldn't read `~/pin-init/internal/src/../../../macros/quote.rs`: No such file or directory (os error 2) --> ~/pin-init/internal/src/lib.rs:25:1 | 25 | mod quote; | ^^^^^^^^^^ Error writing files: failed to resolve mod `quote`: ~/pin-init/internal/src/../../../macros/quote.rs does not exist Thus mark it with `rustfmt::skip` when compiling without kernel support. Link: https://github.com/Rust-for-Linux/pin-init [1] Link: https://github.com/Rust-for-Linux/pin-init/pull/33/commits/a6caf1945e51da38761aab4dffa56e63e2baa218 Signed-off-by: Benno Lossin Reviewed-by: Christian Schrefl --- rust/pin-init/internal/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/rust/pin-init/internal/src/lib.rs b/rust/pin-init/internal/src/lib.rs index babe5e878550..56aa9ecc1e1a 100644 --- a/rust/pin-init/internal/src/lib.rs +++ b/rust/pin-init/internal/src/lib.rs @@ -22,6 +22,7 @@ #[cfg(kernel)] #[path = "../../../macros/quote.rs"] #[macro_use] +#[cfg_attr(not(kernel), rustfmt::skip)] mod quote; #[cfg(not(kernel))] #[macro_use] From patchwork Mon Apr 14 20:00:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benno Lossin X-Patchwork-Id: 14050983 Received: from mail-10629.protonmail.ch (mail-10629.protonmail.ch [79.135.106.29]) (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 4DC9F1E9B06; Mon, 14 Apr 2025 20:00:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=79.135.106.29 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744660837; cv=none; b=B5dv1HEEZPc49Yv6tQyGNTX21IfOobr6SLJ7SES3+l4kSCr4ZGXmAx0oaW86ceo6bTdUdqDsERSfYz8HLBIY0NYAsg+lCjHNvVHkjVVdPM9/+vnj1Pgw8X7LE2JzkBGv4sQOTHUKr9d0Noa4CQJvOxf2ZRZFQPkzOEaBQxqIBX4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744660837; c=relaxed/simple; bh=TWJ0okZW+8/GK3f4fqiOFElTdvZJl4UY9KYhobizbVs=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SINQJyynpW1q+gkiXtPV2AmEuqW1o7mgnnMATbdMYl9YPXet7xQRunOMCNhjOSKa/FywvtyFvhT7jG//51i+PMby+3cuQrH8QssBel2p89Xcl8VKRFJ+h3maiyZGgDdfhBBHCf+GP+7NMH4QQERI0gAw5sXPMCyLjFrm3y5aLlQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me; spf=pass smtp.mailfrom=proton.me; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b=j1gEZYUc; arc=none smtp.client-ip=79.135.106.29 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=proton.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b="j1gEZYUc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1744660827; x=1744920027; bh=zdtxYtqOEBxCKBn2U8h77Y7hXVQ5/IOFpb5ARHsBxT4=; 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=j1gEZYUcGNfLJw8kPfqcTnWKmNKhKyKNW5rwBoPRyaXuC/NbC7tcKxeBVo/J5W0Os s4vchkdra+QT3/qfBedFLQGHqSEonT3iee2joc0s8P20CvIfh5PO+e6W4HEDJhr4P3 tjNtG5iKZWqSyIiVOeUOUIcvXQ8GNlKLEs4szrHjaXiltncZoaO7PpvxV+n0WMjIPm uXQF1STuO/BB7UEmxKQu3MSgL4ddu94EcJnmdRX8o/GF6zq2Pd5+hvRjspsx1gSYWD +c1vE0U5mEiwqAsRgsSC7479cirwUrPqsCCLPEFOYty9bCe3gby+snjqoCo0WKnwaB 1zt+LzAmqQdpw== Date: Mon, 14 Apr 2025 20:00:20 +0000 To: Benno Lossin , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Fiona Behrens From: Benno Lossin Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] rust: pin-init: examples: conditionally enable `feature(lint_reasons)` Message-ID: <20250414195928.129040-3-benno.lossin@proton.me> In-Reply-To: <20250414195928.129040-1-benno.lossin@proton.me> References: <20250414195928.129040-1-benno.lossin@proton.me> Feedback-ID: 71780778:user:proton X-Pm-Message-ID: 124e4f129cbc0e3b05ca4734ec9e8509fcbb28f0 Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 `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 Signed-off-by: Benno Lossin --- rust/pin-init/examples/linked_list.rs | 1 + rust/pin-init/examples/mutex.rs | 1 + rust/pin-init/examples/pthread_mutex.rs | 2 ++ rust/pin-init/examples/static_init.rs | 1 + 4 files changed, 5 insertions(+) diff --git a/rust/pin-init/examples/linked_list.rs b/rust/pin-init/examples/linked_list.rs index 6d7eb0a0ec0d..0bbc7b8d83a1 100644 --- a/rust/pin-init/examples/linked_list.rs +++ b/rust/pin-init/examples/linked_list.rs @@ -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, diff --git a/rust/pin-init/examples/mutex.rs b/rust/pin-init/examples/mutex.rs index 073bb79341d1..3e3630780c96 100644 --- a/rust/pin-init/examples/mutex.rs +++ b/rust/pin-init/examples/mutex.rs @@ -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::{ diff --git a/rust/pin-init/examples/pthread_mutex.rs b/rust/pin-init/examples/pthread_mutex.rs index 9164298c44c0..f020dd266506 100644 --- a/rust/pin-init/examples/pthread_mutex.rs +++ b/rust/pin-init/examples/pthread_mutex.rs @@ -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")] diff --git a/rust/pin-init/examples/static_init.rs b/rust/pin-init/examples/static_init.rs index 3487d761aa26..48531413ab94 100644 --- a/rust/pin-init/examples/static_init.rs +++ b/rust/pin-init/examples/static_init.rs @@ -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}, From patchwork Mon Apr 14 20:00:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benno Lossin X-Patchwork-Id: 14050984 Received: from mail-24417.protonmail.ch (mail-24417.protonmail.ch [109.224.244.17]) (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 E012C1EF380; Mon, 14 Apr 2025 20:00:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=109.224.244.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744660839; cv=none; b=L4XuixtbFeEAxtovmLhrbLlQLOjPkP9Kl/MvTMBBifR9uNSKK9yJvDbwHc40gtrSeOs5DHHqq6f+5B8TgNs3ZEJb3UNnA8m6swFpgFmdnJepkmXhI0fkT7LskOZw5XwgGW3BwD10S49OsasR+UXXPhYZOMd9P9G752VLfu+T9qY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744660839; c=relaxed/simple; bh=HRIs4FcYNBo/gPStxbe2bQzkhruNBS1+wehDnlCQTGE=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kF2a7u3hXo5xsSHLI8jotux4ZQaH8AI0S+5P3L5juImj+oDPD4nTwwji7tmvRSNHfS0W6OpZeRRojp0UYog1ubjlRkvAACIjLFiK0XenEXcLjnlEbkZVo3DAlSyhEwgysHwhs6+fARpifcrkEQm90TaUe87IKmGHrpINwp5oO0E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me; spf=pass smtp.mailfrom=proton.me; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b=RzzQ1yQ7; arc=none smtp.client-ip=109.224.244.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=proton.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=proton.me header.i=@proton.me header.b="RzzQ1yQ7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1744660835; x=1744920035; bh=OQ9/Gjm99d4oeAYMbDxnJSkRL5ElNUBWZlWMMBiHLjw=; 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=RzzQ1yQ7aEZkOpSuJa+37b2ta6zHXHLFNwWgVBHzrwKpmyXhJYV5MdboRqdTP1E2t 1Xvb9+XZgV5jACH5KUh+o0IkzOTFCfrYVPTD40ZDzwSCc5URILr851reVUsITLMSSY XhD2T5zZt1hbGJsMjn0R4UZoGrp17qLlxQiaEzs6EK6H+6JRqocX8YcA03maJz0gmp kgn3m5rebXzBcInokERBuvRMG2WGwcxM5dDf31TGuGWpbEOy8bL0BO+pOqsrkxGns7 T4eQ/4IICgmCKMowWRJm3DwvCq1rA1kEH+m7wieqTmRt/4N4ZQ8Vz6yqP7iCGmtoZ8 iOU58BD7yyRaQ== Date: Mon, 14 Apr 2025 20:00:31 +0000 To: Benno Lossin , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Fiona Behrens From: Benno Lossin Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] rust: pin-init: examples: use `allow` instead of `expect` Message-ID: <20250414195928.129040-4-benno.lossin@proton.me> In-Reply-To: <20250414195928.129040-1-benno.lossin@proton.me> References: <20250414195928.129040-1-benno.lossin@proton.me> Feedback-ID: 71780778:user:proton X-Pm-Message-ID: 8a8217c05dba5f60d7cbc00d8d47260c22e3295a Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Rust 1.78 doesn't emit a `dead_code` error on the annotated element, resulting in the `unfulfilled_lint_expectations` error. Rust 1.85 does emit the `dead_code` error, so we still need an `allow`. Link: https://github.com/Rust-for-Linux/pin-init/pull/33/commits/0e28cbb895bd29f896a59b40e8ed506ea7bef13c Signed-off-by: Benno Lossin --- rust/pin-init/examples/pthread_mutex.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/pin-init/examples/pthread_mutex.rs b/rust/pin-init/examples/pthread_mutex.rs index f020dd266506..e28a0bfd4179 100644 --- a/rust/pin-init/examples/pthread_mutex.rs +++ b/rust/pin-init/examples/pthread_mutex.rs @@ -42,7 +42,7 @@ fn drop(self: Pin<&mut Self>) { #[derive(Debug)] pub enum Error { - #[expect(dead_code)] + #[allow(dead_code)] IO(std::io::Error), Alloc, }