From patchwork Tue Jul 18 05:27:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Miguel Ojeda X-Patchwork-Id: 121770 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1523908vqt; Mon, 17 Jul 2023 22:40:32 -0700 (PDT) X-Google-Smtp-Source: APBJJlFWNu2gDpOnbmEgfVzpN9F2dYNXffXdlusM0oEwPfX4c9rDfhED6MFcLKprPj6EXPeVRT3/ X-Received: by 2002:aa7:d7c7:0:b0:51d:d27a:6d3 with SMTP id e7-20020aa7d7c7000000b0051dd27a06d3mr14059093eds.11.1689658832142; Mon, 17 Jul 2023 22:40:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689658832; cv=none; d=google.com; s=arc-20160816; b=DcjrWgKEiJ5PYOqrtZr8RXHL65CIi1kDR1ZKbh7jnBsdC7iYkNPNbGTTTYUXH2QKVC Dhlijn4hx6aL9n7DhJYz+iRLgOATNNdei7YQcdcob164Fnry9vcCtqYQC41uOxCLzz1x xIgv+dyPDEKz1gE5CD7COuMzwWmaeDT8knciQSBq9UjxvwP54ahFuwqLG7NqkHd10T4/ 8Ku86V3b3m1uEbioODDRojoBLTrESSw4z8sLaJvb4XjlywZPzmkjrfQiD8rVKIyQMIQO 5bb1PqbkHeLR3nrsjmOD5umEfSriFLYcVAR6GhOjyqYO20hgBWdTKXCVzm5I/6xJdUpV yTcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=zSWHJoCAb587D9DpuZcu608xr0FVZVYTtGLWN1GUwv0=; fh=sNoURHT8T47P/uuVfUjgohnTnSVLEBtLq27Xmg/STNc=; b=rZblcJhF65AZavbwRRKeLWqaVOk6EZGJKbP76Qzfo+L8pNEkvcw/I0c8jEFlIqumZX zBMaSRoun+GR/nMW2LEo+wVUwX2xfyawIR2eoRKplmkTBKvx4wcfDK3hkBoaEO1k0IQF e2XiP7klzyT5D96th83oRO7dbkLrM05C6UGdFJW/5QDJ3y1khxMYRGN+uq8fS/AGRaOD dQyd55kwKi2tbE7Gx8NW555XZfi3jeeuh4kPXbj9ZADTrHu2RCva4M8bGxU1stzKbyxC gbyhaeFq0dKI6lU7ZEHEbIKepTqilFC2kmiEZoWwZmXsKUh6HgxM924GagX+Z092z79U e1AQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tV+phARw; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i8-20020aa7c708000000b0051dd50eb02bsi714711edq.5.2023.07.17.22.40.08; Mon, 17 Jul 2023 22:40:32 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=tV+phARw; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230322AbjGRF2l (ORCPT + 99 others); Tue, 18 Jul 2023 01:28:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230306AbjGRF2f (ORCPT ); Tue, 18 Jul 2023 01:28:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B76810EB; Mon, 17 Jul 2023 22:28:32 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B317D612E6; Tue, 18 Jul 2023 05:28:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37C5AC433C7; Tue, 18 Jul 2023 05:28:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689658111; bh=+k0YeMe4IQGy7ZoqQp5D1RAO3qnqR7osUcj8pqI8Br4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tV+phARwLbThccff0pXskdDqdJjjBy0Bk0U6M49OpFLWrcbBJ/qJRxaDwyHomJLi0 k10sqhmbFO7nj9PN8a50+zgAEa07sD3yeRt5xn2/XCQXqQ7KQ0iO/AadWvmVkDyREF c9B5aHaajJSUiVNp0K3VVGuNdCzB7tw1YEa8JkReBvf4XRLwkkM1InFKlTC+R5WNZN FO5e02eE4CAQcPt+24ruW8ij39NR3ZKQFjz0LoiO81GwapqGpbpshWpS/brXUlUuls BQsfwEbqbsifsJgxNYt7gkwqbcyi3C3YyhQfou10lzRQj1rXF1g1nbfLg/A3tGohDA rTxkssQz1tOVQ== From: Miguel Ojeda To: David Gow , Brendan Higgins , Miguel Ojeda , Wedson Almeida Filho , Alex Gaynor Cc: Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Alice Ryhl , Andreas Hindborg , kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Martin Rodriguez Reboredo , Vincenzo Palazzo Subject: [PATCH v2 3/7] rust: str: make doctests compilable/testable Date: Tue, 18 Jul 2023 07:27:48 +0200 Message-ID: <20230718052752.1045248-4-ojeda@kernel.org> In-Reply-To: <20230718052752.1045248-1-ojeda@kernel.org> References: <20230718052752.1045248-1-ojeda@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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: INBOX X-GMAIL-THRID: 1771735699379827193 X-GMAIL-MSGID: 1771735699379827193 Rust documentation tests are going to be build/run-tested with the KUnit integration added in a future patch, thus update them to make them compilable/testable so that we may start enforcing it. Reviewed-by: Björn Roy Baron Reviewed-by: Alice Ryhl Reviewed-by: Martin Rodriguez Reboredo Reviewed-by: Vincenzo Palazzo Reviewed-by: David Gow Signed-off-by: Miguel Ojeda --- rust/kernel/str.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rust/kernel/str.rs b/rust/kernel/str.rs index c9dd3bf59e34..c41607b2e4fe 100644 --- a/rust/kernel/str.rs +++ b/rust/kernel/str.rs @@ -213,6 +213,7 @@ impl fmt::Display for CStr { /// /// ``` /// # use kernel::c_str; + /// # use kernel::fmt; /// # use kernel::str::CStr; /// # use kernel::str::CString; /// let penguin = c_str!("🐧"); @@ -241,6 +242,7 @@ impl fmt::Debug for CStr { /// /// ``` /// # use kernel::c_str; + /// # use kernel::fmt; /// # use kernel::str::CStr; /// # use kernel::str::CString; /// let penguin = c_str!("🐧"); @@ -529,7 +531,7 @@ fn write_str(&mut self, s: &str) -> fmt::Result { /// # Examples /// /// ``` -/// use kernel::str::CString; +/// use kernel::{str::CString, fmt}; /// /// let s = CString::try_from_fmt(fmt!("{}{}{}", "abc", 10, 20)).unwrap(); /// assert_eq!(s.as_bytes_with_nul(), "abc1020\0".as_bytes());