From patchwork Tue Sep 10 12:07:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gary Guo X-Patchwork-Id: 13798404 Received: from CWXP265CU008.outbound.protection.outlook.com (mail-ukwestazon11020111.outbound.protection.outlook.com [52.101.195.111]) (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 0382D18DF97; Tue, 10 Sep 2024 12:09:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.195.111 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725970156; cv=fail; b=L7z61FPoEX37dEkYKxDYV77m3M3PfDL89NYBvxvIVQ7turWe7E7EMN62emC2ssHCxB6ORRQ2Jgbqy5SSfFJIXRPTModSWslWV8OSXPu8bNraTSwcN+TD+XUQSOPiA9AWTnDbFKSE0OOZv39kWx3psq+C6GQi5OOWSdH2bQlDcZA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725970156; c=relaxed/simple; bh=RJTbUEQrpEi7JL9JV242l5a1M0uvUgQtoZeGFUoGfa8=; h=From:To:Cc:Subject:Date:Message-ID:Content-Type:MIME-Version; b=rau/Jb6qO9NaWERcDps1n02hWJi/aCoc1Ivnx8+26o7WFoF22ZrdTA+z/dy4hv2CIObHQ5ryxqzY94p+jYFk6TIsWWRflb/liAsEQr6rcsO1AErLnVrBMc25/hZjXJv7okQlJy8yhPue0AVQ3ohCHI3hEmNgDdQEPEzyOz4dMnA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=garyguo.net; spf=pass smtp.mailfrom=garyguo.net; dkim=pass (1024-bit key) header.d=garyguo.net header.i=@garyguo.net header.b=HkF10VhP; arc=fail smtp.client-ip=52.101.195.111 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=garyguo.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=garyguo.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=garyguo.net header.i=@garyguo.net header.b="HkF10VhP" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qu872HUJplKd7hXtuM5taHJ5GZue6pQ8vPA10vBSmBqZJCW+6UrIwfJK0Uxnhnu2CtHb3HqPhyOlrcQdrrnabEsnaUtKSOQ6Odx7mqlKXvCaEUuiGlGFE70NrUitT3Y5sT40O3jQr4A3Jaj1IWj9bHa5coGunNSwJbPZCzeUowtjriAU2NeoRB4ryE/3nVV/9AUi2XNiO4W0je8Owb7tu/IPuKrTzlVoasc0vq3IZ7nP4BArDhQS7S2uTmwLqK3+lSXE0T8EQkOjfr3IRx0Rzk8G0PU22SlxsnhssiF8o0wHUl9h5Xhf3Csj4edEM4Uo8i/om3uEnFrs0hrBPRA/wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=r8U+ltVPTcbgcHAhNrq4yoooAF4W0f3Q9A3RyQ+YZxk=; b=ImYjIWYQhynmOIHl8qso9JeSTPCoYo3uTRSQVHeuB5W0xCHxamq07oFFTRECR5lhO3A7vP+au4syJ+IIRFxLTZDMhD7Ao3DTsuKQTjiVuAw0uLkjsqSFkiaW5WeRzuCrjsmK4sryLgOzI+dPqTxRmpqDRUPeVif75gKA35Je/MmO9oYnsC+i9sre5Tr1+RJ6eMy0UVvQa00Gwl9eWbiMBcAENEVjicadychLBtuv0uXBZK0XeO7iqji7NCONG+JeYyiHjQWfuHYadhRVyccVrQbRNUnSpzHxDSfr0QjCJ63fjNAHv45oPRk6pdQl16fbythxfGaoAhxG1lPDuldlEQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=garyguo.net; dmarc=pass action=none header.from=garyguo.net; dkim=pass header.d=garyguo.net; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=garyguo.net; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=r8U+ltVPTcbgcHAhNrq4yoooAF4W0f3Q9A3RyQ+YZxk=; b=HkF10VhPTNEu/0hPu3pRIrqmN7U1UzbjNcA3Gsjn3fhHSv87+2tde2kS4gttOM3VndrqU0DeIHHIP1v2+RLWKPmT6TevaI8rPJcS4q7SBadsOt/+W+j9vCi+RA3Lu2OPNjK6S9PemBZ1ba3s7rYl55xZ8uDOqA8V7bAMYrLk5Dw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=garyguo.net; Received: from LO2P265MB5183.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:253::10) by LO6P265MB6826.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:326::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7939.23; Tue, 10 Sep 2024 12:09:08 +0000 Received: from LO2P265MB5183.GBRP265.PROD.OUTLOOK.COM ([fe80::1818:a2bf:38a7:a1e7]) by LO2P265MB5183.GBRP265.PROD.OUTLOOK.COM ([fe80::1818:a2bf:38a7:a1e7%4]) with mapi id 15.20.7939.022; Tue, 10 Sep 2024 12:09:08 +0000 From: Gary Guo To: Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Masahiro Yamada , Nathan Chancellor , Nicolas Schier , Danilo Krummrich , FUJITA Tomonori , Valentin Obst , Martin Rodriguez Reboredo , Alex Mantel Cc: Adrian Taylor , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org Subject: [PATCH] rust: enable arbitrary_self_types and remove `Receiver` Date: Tue, 10 Sep 2024 13:07:01 +0100 Message-ID: <20240910120721.107877-1-gary@garyguo.net> X-Mailer: git-send-email 2.44.1 X-ClientProxiedBy: PA7P264CA0363.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:37c::21) To LO2P265MB5183.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:253::10) Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LO2P265MB5183:EE_|LO6P265MB6826:EE_ X-MS-Office365-Filtering-Correlation-Id: 55c45351-b94f-47aa-c8da-08dcd1915f6d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|7416014|921020; X-Microsoft-Antispam-Message-Info: RnxxJ1D+76GficdtK7pKmF1WFOgvmTh+VJUtlhV+MqlZeQld8kbgQBPHQZ/KLGaVaF7niIG5orIoly8OIaJ98ly2IqubTIoqH66Lz8KCMxMEJvH+Ea/oMMvHcZLQOb/8y2qxdlsC0ws/lQmJft8AXbED5VY0DqDyCLzrVipKsh6fLqFVSXWzRiP2Ox/Cm+ZhOmsY7SsoHt/pUwUVo/eEXcxTsrJadRp0mYxVAJj/b1KW0P5klDpLnzbubvFg4miPa53gWNy/Jt+uTrexMztDoeMSe/6WH9Yk0PCZNXJrIfh8aSql6Xyexe4IEKhZ7FWr2F/AxAK5vm2n7xWAgqnBQ+IWXc+tEpSLROXVRqAhUWuP8A9cvi9EzuMvr6zGoq0gaMAuB6Wx4RsbXSKt6f+/Iu0fc7Wz5s1NmxTgXPWbynv/a3qEucumjchaa7HlAwS2/4GiDKEso8/XncvPjKvOmmB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(366016)(1800799024)(376014)(7416014)(921020);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hjserKxlUjhmJKLmKDe7Jl76rcTUzGwA51gnYuLlO84Av2L+ERqGYiITipg/zTK0/UpjVAcFt1Jf+8OQ3VitoNXWyAfHriChbhWf7p+iiyTpMcJXUxg12h9cfuYHoPgYxEAq0hmR/2T//02WvsG4zkLzH6A9j55RVzUNbfa8X2MkjUdNxZdTc3JF7abfXlSrE2mSwEtPNv2opQYWgvri2cD8ov4oyJOBrWKe2OUTZaSiwzHoEtVTr8lqBrJjhMdSjoo0xpNOAP0zR1tbF+lKtWkOQQ12I96CDDhSMpe1Zy5S349QlcEMNjvV6wpwyp3UNFXxT1wCsLQsEWP7siS8HQtzJnv/l92yDsK8ioMnHk6BycpPuclJUXYPVO/pJJ9mWKHTgPSAKDDoFUcdmza23fg2mswPoxLbCNsB99lKZ6/1iU9PlYQ1fUXtSzggLT1U5IQKABwQfqY8IZW+NlIGLEKl/aFZaZQfqLJqYUee8GEEBzF/jHo6oro8IL1XTCT3OyF0uYS1CXZHotNYM4fTCF21e0Ao+pJRztQBomhTVVqxl1zvh2vBZaGQJycXuCUfyQ6fF7rhWiJD3aJL0DREN1gzM+t/LBFQro+6eiYJUhgOHICoS3pkDBkgD292CsxTLBLdHc+Wu0IKxu/ZUndwS3nO/QftnzKhykX7/1+uC3q0ZsopO12QbGj8H8k/yhmVCY9Y0bKdb5HI/FE3XfjEX/Khv/WtvHGQOZWtRsDGxDOuE7a2OpX6QP70zDduOABpU6hqAA/pVAcKy3KTX7UAkvjueYrWLc3eDQ1xp8yOm9KS840PIOcSrdAvqfw742KpLRU3yppYb/wlkMvr/M+8BeMDOsDcc9p6vGYCzhDpn+WXjauAKPgHHBzMHpldzCfw9oAL4Tp39/ObWKaGwLwbakTnOTzTJ9eGv7TXKZHbJBadyeammD0yc6lWIIBUg3Xd5+d69pGE2Bx0OAUxg1duynVpuXanxKdPFuC2bZWWXllXAeU74zYmL78fEOj9y5IcBi2/1mcLuj/Zn6k3rGIsO1bvUNP9KpkNEBHcCmnxQ2vRLljdeUU7t/fSp1lpEtfSq0ghWY77aorsUWzawzmuiUd5B8OpktZUMVK8e/EDlole83lK/RxfS8HLWBfrbWh7kLTZITwVjMu45pQcP+fXYQJpUylnoSRITQIb4VWELUSO5M/PXIkql7Ch9pdAu/ImmyniYIsx1bCVtAbtfwsleJB5Uh6zyyk7TrC6GQ+RhWCP8Ro40608PaGqusGPnRj6+EqWITd834S03scce8dG0V+GWuJjAdHNBHiRL3ooGC4/OMpbySfclre4CZ8DpgRB6iCW/qTSUqv+NwjWeaMiQfxrHlcPSLXJZD0Gg4irICDgvhimZR3fuQtNKf7O0THSf6Sw3lfe9/rA3dLgxDWOyXAoczGFRJ0qT9reesh0qbbBGo7ZkhdDlwSZP5I7wWNaS23inqjghCag9Gx3+MG8j4/mjvNTc2GBYV1cNKQ1o0Qq1XISdppdI/oy/3KJph/NGg7OjlOOne6aAjJ4G1TNK47CNNY84Ou0ofzejA/oHwCP+E/NC6IJObU8/tKcvKWn X-OriginatorOrg: garyguo.net X-MS-Exchange-CrossTenant-Network-Message-Id: 55c45351-b94f-47aa-c8da-08dcd1915f6d X-MS-Exchange-CrossTenant-AuthSource: LO2P265MB5183.GBRP265.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2024 12:09:08.3054 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bbc898ad-b10f-4e10-8552-d9377b823d45 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: xaavHlCCf3Vbkl9yGatdXXIXUrqLf+JD8/uWNQsCp8PI3MGCLVB3lx0Z/+GjTPKak7OohAGJscCibezY5QcenA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: LO6P265MB6826 The `arbitrary_self_types` RFC [1] is accepted and the feature is being worked on [2]. As part of the RFC, a new `Receiver` trait is to be added, and it will be automatically implemented for all types that have `Deref` implementation. This is different from the existing `Receiver` trait that we use, which is a custom implementation that opts-in a type into being used as receiver. To prepare us for the change, remove the `Receiver` implementation and the associated feature. To still allow `Arc` and others to be used as method receivers, turn on `arbitrary_self_types` feature instead. Cc: Adrian Taylor Link: https://github.com/rust-lang/rfcs/pull/3519 [1] Link: https://github.com/rust-lang/rust/issues/44874 [2] Signed-off-by: Gary Guo --- rust/kernel/lib.rs | 2 +- rust/kernel/list/arc.rs | 3 --- rust/kernel/sync/arc.rs | 6 ------ scripts/Makefile.build | 2 +- 4 files changed, 2 insertions(+), 11 deletions(-) base-commit: 93dc3be19450447a3a7090bd1dfb9f3daac3e8d2 diff --git a/rust/kernel/lib.rs b/rust/kernel/lib.rs index f10b06a78b9d5..35a65a085bce5 100644 --- a/rust/kernel/lib.rs +++ b/rust/kernel/lib.rs @@ -12,10 +12,10 @@ //! do so first instead of bypassing this crate. #![no_std] +#![feature(arbitrary_self_types)] #![feature(coerce_unsized)] #![feature(dispatch_from_dyn)] #![feature(new_uninit)] -#![feature(receiver_trait)] #![feature(unsize)] // Ensure conditional compilation based on the kernel configuration works; diff --git a/rust/kernel/list/arc.rs b/rust/kernel/list/arc.rs index d801b9dc6291d..3483d8c232c4f 100644 --- a/rust/kernel/list/arc.rs +++ b/rust/kernel/list/arc.rs @@ -441,9 +441,6 @@ fn as_ref(&self) -> &Arc { } } -// This is to allow [`ListArc`] (and variants) to be used as the type of `self`. -impl core::ops::Receiver for ListArc where T: ListArcSafe + ?Sized {} - // This is to allow coercion from `ListArc` to `ListArc` if `T` can be converted to the // dynamically-sized type (DST) `U`. impl core::ops::CoerceUnsized> for ListArc diff --git a/rust/kernel/sync/arc.rs b/rust/kernel/sync/arc.rs index 3021f30fd822f..28743a7c74a84 100644 --- a/rust/kernel/sync/arc.rs +++ b/rust/kernel/sync/arc.rs @@ -171,9 +171,6 @@ unsafe fn container_of(ptr: *const T) -> NonNull> { } } -// This is to allow [`Arc`] (and variants) to be used as the type of `self`. -impl core::ops::Receiver for Arc {} - // This is to allow coercion from `Arc` to `Arc` if `T` can be converted to the // dynamically-sized type (DST) `U`. impl, U: ?Sized> core::ops::CoerceUnsized> for Arc {} @@ -480,9 +477,6 @@ pub struct ArcBorrow<'a, T: ?Sized + 'a> { _p: PhantomData<&'a ()>, } -// This is to allow [`ArcBorrow`] (and variants) to be used as the type of `self`. -impl core::ops::Receiver for ArcBorrow<'_, T> {} - // This is to allow `ArcBorrow` to be dispatched on when `ArcBorrow` can be coerced into // `ArcBorrow`. impl, U: ?Sized> core::ops::DispatchFromDyn> diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 72b1232b1f7d9..56b8c72687255 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -263,7 +263,7 @@ $(obj)/%.lst: $(obj)/%.c FORCE # Compile Rust sources (.rs) # --------------------------------------------------------------------------- -rust_allowed_features := new_uninit +rust_allowed_features := arbitrary_self_types,new_uninit # `--out-dir` is required to avoid temporaries being created by `rustc` in the # current working directory, which may be not accessible in the out-of-tree