From patchwork Fri Feb 24 10:53:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asahi Lina X-Patchwork-Id: 61258 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp836957wrd; Fri, 24 Feb 2023 03:01:45 -0800 (PST) X-Google-Smtp-Source: AK7set/5L5VKstb9iFA6uRay0OJlTn13EHBUYRBHJRr5dsYW6XT7Aoq4VfRLFTDJjB6uGEVDHYOv X-Received: by 2002:a05:6402:516b:b0:4ac:b32e:b65 with SMTP id d11-20020a056402516b00b004acb32e0b65mr16389281ede.3.1677236505216; Fri, 24 Feb 2023 03:01:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677236505; cv=none; d=google.com; s=arc-20160816; b=j4E5XRKxRgcXr0BnYfSLfGXIGCKLCUk5fFZJfZ2hpkGYE1ALcDkTp/jVivHHsTcMB5 2G0Dv+U9vS0wkXT5nlNkiF0bBPyhoKUeG1NYpupfgOtypfK3Bm1QKIMvzEkW3wZIl0A8 MdOlLEFgXetbOqugKAmV2XqFeTsY+l5W7eW0Hxy0NZyR3n4hS35hl3xzIqtlNtatjjJH CNjvAd+eV4+kwbZQFitYNlOPWD1UvDtU5tZxapoJqt0AWxC6QgWTUktnTYoDeCSHFuc2 XPgkgnfNGO0NnsPit/ZVjq0+uTJ+Svu67fMbW0cMgHP6+nhnq5oLWO7AZYm/VaBqVmrh w34Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=mdddpQs0/EgOX4R0v6PAJaoU90wWq2OTYVG/0XQ5IUQ=; b=ZQYh/M3O5zeqZcpzZS3rfRudOgNhmQUH0ToVI4U0O8IvNV7CSa0po/pRnliKngDK6G ow61XXbwOnEqJQKdalIUIZI2tQqk50Mc1DCqCqJ1oAIY46Fe2DlLuuJoKPVhdkaQq/g4 qR5UxeR9heF3xJjXtuuOzQ7Wbwe8BrIGYQi6kGm1MiiTaxzkOxqSSH+1PU5eZc3+UADr sIjzl/pKIpvOKUDQe1R6DfnwZwskxNNUUDihZnO50XeAJDYlQhqZu5MXf3xtEj6Eg64D H2UcxN4YGZgzgaI9SzoUvZyUFAI8BF+mWJQ/vPqV/Z4iaBQsMKKLYxnuUMQFLb3a6pu4 ZNlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@asahilina.net header.s=default header.b="oa1/MEii"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=asahilina.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h20-20020a50ed94000000b004acbe83b837si3498296edr.213.2023.02.24.03.01.05; Fri, 24 Feb 2023 03:01:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@asahilina.net header.s=default header.b="oa1/MEii"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=asahilina.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230008AbjBXKxu (ORCPT + 99 others); Fri, 24 Feb 2023 05:53:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229709AbjBXKxq (ORCPT ); Fri, 24 Feb 2023 05:53:46 -0500 Received: from mail.marcansoft.com (marcansoft.com [212.63.210.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8B2D30E0; Fri, 24 Feb 2023 02:53:45 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: linasend@asahilina.net) by mail.marcansoft.com (Postfix) with ESMTPSA id 44C634206F; Fri, 24 Feb 2023 10:53:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=asahilina.net; s=default; t=1677236024; bh=sJXKzM9ye5UpmrgbyuuthZgT+KWJTloP+4kPhG+KQ/k=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=oa1/MEiiXrg9mbqpHfbEKIp8g2n5RxkQB42j1wGBzAU51cFkRJi7ueQBGd/e59Brl 7GoMcsyCOveOh/QgTpe9MahflHSAX3d67TWE2Fkll+LVpC7TmLb2WlFNCThlREjzLD 6GUpv6nT76QR2+qiaVjO8JIWMCYT5kO15bKsbjxwjSY0wh0Cev51ebn/OijewbwjpB /2qDSDR9e03ZKD8m6EG42hw0Jst6DA4Y7tLPtc2WHipqK3rY5QbcvsFPcLPsQM58bK yhVVjgcSEvXz0Lox/JZZk/8axll9MDYOPzV8hitLUmGKRjGCHDuyNKJzDhgwlbFUDR G8/MIhnVT3HKA== From: Asahi Lina Date: Fri, 24 Feb 2023 19:53:13 +0900 Subject: [PATCH 1/5] rust: Add a Sealed trait MIME-Version: 1.0 Message-Id: <20230224-rust-iopt-rtkit-v1-1-49ced3391295@asahilina.net> References: <20230224-rust-iopt-rtkit-v1-0-49ced3391295@asahilina.net> In-Reply-To: <20230224-rust-iopt-rtkit-v1-0-49ced3391295@asahilina.net> To: Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Will Deacon , Robin Murphy , Joerg Roedel , Hector Martin , Sven Peter , Arnd Bergmann , Greg Kroah-Hartman Cc: "Rafael J. Wysocki" , Alyssa Rosenzweig , Neal Gompa , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, Asahi Lina X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1677236013; l=780; i=lina@asahilina.net; s=20230221; h=from:subject:message-id; bh=sJXKzM9ye5UpmrgbyuuthZgT+KWJTloP+4kPhG+KQ/k=; b=2N7EOf9lvtQl1KnhDXXm0FkvG4Na7dWKbQBTLsMk8jqk7B7Y4WPfN/hlCBMv3CBOdYjE0fIKU E+XrQbtCkZPD7FsAJAXaDP50Tbk5LoTqUkrE+GslcgajYZk1801LH+S X-Developer-Key: i=lina@asahilina.net; a=ed25519; pk=Qn8jZuOtR1m5GaiDfTrAoQ4NE1XoYVZ/wmt5YtXWFC4= X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758709945878925873?= X-GMAIL-MSGID: =?utf-8?q?1758709945878925873?= Some traits exposed by the kernel crate may not be intended to be implemented by downstream modules. Add a Sealed trait to allow avoiding this using the sealed trait pattern. Signed-off-by: Asahi Lina --- rust/kernel/lib.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rust/kernel/lib.rs b/rust/kernel/lib.rs index 223564f9f0cc..82dff6f4cf60 100644 --- a/rust/kernel/lib.rs +++ b/rust/kernel/lib.rs @@ -46,6 +46,11 @@ pub use macros; #[doc(hidden)] pub use build_error::build_error; +pub(crate) mod private { + #[allow(unreachable_pub)] + pub trait Sealed {} +} + /// Prefix to appear before log messages printed from within the `kernel` crate. const __LOG_PREFIX: &[u8] = b"rust_kernel\0";