From patchwork Thu Oct 5 21:05:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miguel Ojeda X-Patchwork-Id: 149031 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2016:b0:403:3b70:6f57 with SMTP id fe22csp566675vqb; Thu, 5 Oct 2023 14:06:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHubBpCAp9LTKyX0uIAlzbV4aZVM+wEMB+AvzpfQlin0hctwftshzuw1/RRckO+7nYYz4BV X-Received: by 2002:a05:6a20:5485:b0:143:f4dd:dfae with SMTP id i5-20020a056a20548500b00143f4dddfaemr7346695pzk.43.1696540015224; Thu, 05 Oct 2023 14:06:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696540015; cv=none; d=google.com; s=arc-20160816; b=XL7xm6tJXbI+0slu9Zx3lAf7gSx+IeHTw33EJHni84bpqfrU6Bw28w8aancD5yu4o8 KtXAqQ9NGSbYVLirHhaMLKR8TcOSNajZzNxKsyztPPW+egW1xp4+aSFCZPtMuM3XQspr Vkhp1tONyk1ykOJZflTakwxZkWZg10xsXomnT6itBty9nUNZsKc1Nij9GGjbDpJedXKj 3u8NwasiFdKbe/tcV9eBPo259VP6pdRMC4wwNCJpOwNJF34wk/bNWM0uTm2Qc90NqHoz FTUyp2YMTGZsHKvxqYMt7tzbHHCalAw+rzEy25+OFx1pTwNoU49LGu1XoVT6W6XQIeA4 IQeA== 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=Hwe4StUr/jqoSZku6LGtzN4oPj947McjZU4ZwOxI0Go=; fh=au7aoxhxwiGjd3un8PPv3AApc8jH8uW5iTGRpBKg8nc=; b=FDGSxOsyH4SgbFS5GRLKsYw7FBO6l1Yz7SGIvys1gHbJ+faPIfnxPzBeQG5BvereyD bEDtegPI7R329tuwS+L1rKszkfmkYWNxBFXMFBATlRlUIxVNj7GCuW7fvu3TbQZEmuJE a+sY/j5nLsExvr7VHjEMQm6laSwzm4Z48QXRZL/Oqx1i23x51X3Ew9Qc2YX3xHEQoCnh PZZjGCPAogxVgkRBmAQg94VMSDLTjF3+QVMq4haO5pJdM95zIxQGvdxWTIM+HK+S60Z3 I2/FAPIRQfD4WSw44IlT53uVKf5TM54xMfPbS47zyH8ZtwBYKPpVvBFTaP9dIwARio7U 2apw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ss+OX7Sh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id b18-20020a656692000000b0056c297d163asi2173625pgw.523.2023.10.05.14.06.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 14:06:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ss+OX7Sh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id DF8688301528; Thu, 5 Oct 2023 14:06:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231828AbjJEVGa (ORCPT + 18 others); Thu, 5 Oct 2023 17:06:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229852AbjJEVG2 (ORCPT ); Thu, 5 Oct 2023 17:06:28 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51BD193 for ; Thu, 5 Oct 2023 14:06:26 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 291AAC433C9; Thu, 5 Oct 2023 21:06:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696539986; bh=qOUKIAiTh0O8Uv4d8SH+C2EBhe15SUCFuHgeJkj8nGo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ss+OX7ShDShHRvKvbDoKbBv/UKoDuGOabQmFEhc/WAfNzMKrUpyNgS/LDvY+b09EU KW0Z4EiStk/ehgmYwEmMg+UEYP6ZkMdZoz7KQ1JUd7ppKyooRLt43dmOnm+sOLlAj4 sgvL1a8hNEa/+pK0cRwinEzC2pCb4UfEuWtSQX66f6Wnimv9yBijvpG8PH/EF4zIcY QwnfixNMVLViZVk3fOnu1ipkzndYZhNriCNI0hgjuTYJca2Wwvl/NHSS0TSLqweOIq IRHLDR/2v+2RZLm00kg81qulD/gZltGyNvUBbiS4dpAXKbILQtuEeMFLIN3rgMXlXz 69WgsBYgdspXw== From: Miguel Ojeda To: Miguel Ojeda , Wedson Almeida Filho , Alex Gaynor Cc: Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: [PATCH 1/3] rust: task: remove redundant explicit link Date: Thu, 5 Oct 2023 23:05:53 +0200 Message-ID: <20231005210556.466856-2-ojeda@kernel.org> In-Reply-To: <20231005210556.466856-1-ojeda@kernel.org> References: <20231005210556.466856-1-ojeda@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 05 Oct 2023 14:06:46 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778951143015941298 X-GMAIL-MSGID: 1778951143015941298 Starting with Rust 1.73.0, `rustdoc` detects redundant explicit links with its new lint `redundant_explicit_links` [1]: error: redundant explicit link target --> rust/kernel/task.rs:85:21 | 85 | /// [`current`](crate::current) macro because it is safe. | --------- ^^^^^^^^^^^^^^ explicit target is redundant | | | because label contains path that resolves to same destination | = note: when a link's destination is not specified, the label is used to resolve intra-doc links = note: `-D rustdoc::redundant-explicit-links` implied by `-D warnings` help: remove explicit link target | 85 | /// [`current`] macro because it is safe. In order to avoid the warning in the compiler upgrade commit, make it an intra-doc link as the tool suggests. Link: https://github.com/rust-lang/rust/pull/113167 [1] Signed-off-by: Miguel Ojeda Reviewed-by: Martin Rodriguez Reboredo Reviewed-by: Finn Behrens Reviewed-by: Alice Ryhl Reviewed-by: Vincenzo Palazzo --- rust/kernel/task.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/kernel/task.rs b/rust/kernel/task.rs index 7eda15e5f1b3..b2299bc7ac1f 100644 --- a/rust/kernel/task.rs +++ b/rust/kernel/task.rs @@ -82,7 +82,7 @@ impl Task { /// Returns a task reference for the currently executing task/thread. /// /// The recommended way to get the current task/thread is to use the - /// [`current`](crate::current) macro because it is safe. + /// [`current`] macro because it is safe. /// /// # Safety /// From patchwork Thu Oct 5 21:05:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miguel Ojeda X-Patchwork-Id: 149032 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2016:b0:403:3b70:6f57 with SMTP id fe22csp566866vqb; Thu, 5 Oct 2023 14:07:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHXzTZ+pWSfhOkE0vLK2uboV+ksOMTmUYXmgf/WJsaCLW9RONbFwodW9RGJgFPOFSbfrM5K X-Received: by 2002:a05:6830:134e:b0:6b9:5734:135f with SMTP id r14-20020a056830134e00b006b95734135fmr6396166otq.28.1696540040548; Thu, 05 Oct 2023 14:07:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696540040; cv=none; d=google.com; s=arc-20160816; b=oLA24pugHgdze6BEL7u3AYko8+DJyJY9I63LgqrXxqbcG2K2xcbf4xIOw4sAYQF1Mn ZCRShbTEIJs5vpueA8Ej5XsAlDT9ndCXIMpDYjvLJrJd1H8z/s1Ke09L6xGRg72rq0r1 KbuAqsystmuCWFjj4CW0bAZziH6QBAoRlyVuvFGUFovLxZd5btLspwl/8FSU9LDyJm5i IygTw5q+c9j+CSaRo0faUPYZeF0xhls+yDAltJW51rlz4CMFdwq/8D7KIto/BQM/thCE oby80kLgXY+cT9rhxh7zgJGGhxVBkCjMRIZ1El6uMCnQN78FMMpkUL+rKGouqtwpBlwg s9/w== 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=Lz8aTxUWpZN6Rd7/GjcFCGrQPDqbA89Q0G6O9kSX0Yg=; fh=au7aoxhxwiGjd3un8PPv3AApc8jH8uW5iTGRpBKg8nc=; b=gvjPVGiqsASrVs8oKXMMJggzoqTCSw+EsCU+WbxTo5uhO9buFji28WuVNHaxBEkDPN xNmqD+wBq3te+vnQqRJJPNO0ZFToVRBHOvjHxxO4OFpZUZRSZ0DR5zj4+28pGwcUz6pn oc5bd1DXz+tZ3Rp8rN39ToKeJVk7CgVw49D9CE6i5QE+ApZIKGsV8xABC4Z6cIpYBWq0 Z4zUAvLlSWgFqI32FUdRBps/OrJxLM6dnUvg7WsEjgj6ozYQ1QcIGqUaPVacj9QA7fu5 WJMzCsuXuxab9FM+XEq7aTn8H+7e8nZm1ZHav2tGJsJB/EmggPAC4yXqtZsqOS4TihXg ZkQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pTVigqeP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id m190-20020a6326c7000000b0056b024a4dd0si2237672pgm.614.2023.10.05.14.07.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 14:07:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pTVigqeP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 19AD1830152F; Thu, 5 Oct 2023 14:07:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231859AbjJEVGf (ORCPT + 18 others); Thu, 5 Oct 2023 17:06:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231841AbjJEVGb (ORCPT ); Thu, 5 Oct 2023 17:06:31 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1FB3D9 for ; Thu, 5 Oct 2023 14:06:29 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E193C433C7; Thu, 5 Oct 2023 21:06:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696539989; bh=IgnQ6UponHD7jSbFHw/8nSE/0v3lOdZL01VrkmoEWNs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pTVigqePQVgAUvofgawoF4pXU1khefVIcRhUaE6EHw8QVre55UrKUxmvtvPsRn0TN r9c2a1hZQXYcwB4kDn5MpFuqITHIE3m1mYZlVoOibIxq9ISrbWKLQhh7dJUh7djA2F XVUCTXYAei48w+IWUlhMZlcFUYNgSNFGAmv0U3AzaaVNSCnorI61XMEQuQfAPBjybZ jALxqZ2TsDrogKhpRykPUK1xLhxlxw3RlOTegKboVip5QMTJ0jjJM5GGfYxXzFKMTc /PQ6A7AWO099ZFZLraaIllvNOedS03hlmQAR35aDJT82Rh5+wFzkzFOS7Rajmvd4Bv jomQrL5ePPWhQ== From: Miguel Ojeda To: Miguel Ojeda , Wedson Almeida Filho , Alex Gaynor Cc: Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: [PATCH 2/3] rust: print: use explicit link in documentation Date: Thu, 5 Oct 2023 23:05:54 +0200 Message-ID: <20231005210556.466856-3-ojeda@kernel.org> In-Reply-To: <20231005210556.466856-1-ojeda@kernel.org> References: <20231005210556.466856-1-ojeda@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 05 Oct 2023 14:07:18 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778951169347429020 X-GMAIL-MSGID: 1778951169347429020 The future `rustdoc` in the Rust 1.73.0 upgrade requires an explicit link for `pr_info!`: error: unresolved link to `pr_info` --> rust/kernel/print.rs:395:63 | 395 | /// Use only when continuing a previous `pr_*!` macro (e.g. [`pr_info!`]). | ^^^^^^^^ no item named `pr_info` in scope | = note: `macro_rules` named `pr_info` exists in this crate, but it is not in scope at this link's location = note: `-D rustdoc::broken-intra-doc-links` implied by `-D warnings` Thus do so to avoid a broken link while upgrading. Signed-off-by: Miguel Ojeda Reviewed-by: Martin Rodriguez Reboredo Reviewed-by: Finn Behrens Reviewed-by: Alice Ryhl Reviewed-by: Vincenzo Palazzo --- rust/kernel/print.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/rust/kernel/print.rs b/rust/kernel/print.rs index 8009184bf6d7..f48926e3e9fe 100644 --- a/rust/kernel/print.rs +++ b/rust/kernel/print.rs @@ -399,6 +399,7 @@ macro_rules! pr_debug ( /// Mimics the interface of [`std::print!`]. See [`core::fmt`] and /// `alloc::format!` for information about the formatting syntax. /// +/// [`pr_info!`]: crate::pr_info! /// [`pr_cont`]: https://www.kernel.org/doc/html/latest/core-api/printk-basics.html#c.pr_cont /// [`std::print!`]: https://doc.rust-lang.org/std/macro.print.html /// From patchwork Thu Oct 5 21:05:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miguel Ojeda X-Patchwork-Id: 149033 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2016:b0:403:3b70:6f57 with SMTP id fe22csp566937vqb; Thu, 5 Oct 2023 14:07:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHgO89XwgSd4H8CzIGz7MLZC14/h9LxsH2am6TU0GMvZYxfRhjp0M6C4NWd7FRViSAvX7Tu X-Received: by 2002:a05:6e02:12e3:b0:34d:ff6c:3e22 with SMTP id l3-20020a056e0212e300b0034dff6c3e22mr7859078iln.20.1696540050891; Thu, 05 Oct 2023 14:07:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696540050; cv=none; d=google.com; s=arc-20160816; b=phui/EHjDm0VYWzbhVEHPT0ifkTHrkUEJcb0h/yIoyxmDBU7iQi1ePvVB+lWY+0SX9 knyWeL/FBeMNdgwj9fu+oXk7Q5em+/wmeD73H5NxCvt3C3Efm8cbNoyzy+YBku1/BDPJ 1ux3PgRESgjN9gS0YlkE5BUBodkqMqcjGY5GCbM8qopSK7fLtdwQVV/NC9c3GFnQnGvT 7lKRMqhtLChVg5TzpsdwFgzUvdRaVRyQCv9fHj+jrfHyluUrqp34BBc53RMUQ4aN4yUF Bs/teBFGumiGUhsmakZEaLy72u2fpteWRYultHiQ2qYgI6M+La+zirExN+3CVYCLPQwB 7faA== 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=oeoOJ/a6+0W5yzMLNOiRXhAt8LrZCGt1xKXxb2YMa/g=; fh=9zEu/FhO/fwKg64jwKpNJdNUUCeOzZWWD4ipWCX029o=; b=RS80u0uGoabzsVnQAw7kZq2ezUoKVpBY1+pOsNr67tEStQV0Em19fjWPSiZZBVx/q5 4H+5k7MjO1Gc1BITT429Tw46A5IJiA7RIdhR8zwRmYnabP+li6ThjeNt8Gl9llH9pxph WMCouWyi8tg9KpWfomw6ybuDlXfB/k3GH7DBi1t8MZVPOIK7eaGbY3JzhwIbgtyGxehM uapSn4sl440EsNYjy4Y5X5pTCOHzuUoV0X5daMz9I5I/xzdIAl5xeq3m0Gig4y3EgNEe oaux9SXOkMMrF6ER1RsUjHlPVn73WYaZjgpfSEUbROE+QW6KuNeWbiyXKC0I/BG9HU/l R/9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uo6uaorc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id bg26-20020a056a02011a00b0058988d985f4si249248pgb.384.2023.10.05.14.07.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 14:07:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uo6uaorc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 22981802FA3D; Thu, 5 Oct 2023 14:07:27 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231747AbjJEVGn (ORCPT + 18 others); Thu, 5 Oct 2023 17:06:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231948AbjJEVGi (ORCPT ); Thu, 5 Oct 2023 17:06:38 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C36D0FA; Thu, 5 Oct 2023 14:06:34 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32E1BC433C9; Thu, 5 Oct 2023 21:06:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696539993; bh=nJDLT1TLu7k+3W/mJBdiP5fMzpCb0i21tjNuXJX5EVk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uo6uaorc6En2tbarjjGJdbDPvq215l/xrgbaFU5MuwUad/3pMvIyVdEKvmeS3vgbg nLzoiQKzChkux2s05TPLxa8X4WNfN9FeicPjUcRT5COEyTGcIhsiDf6fdpadBdAjT3 t+2n4563wDnuVNVeTy1mpxyi0YV7L8P5LCFAgMvRB0FI02e14aefLe1OddyoUWl7oh J8xJV7U0RuszS3EU25JB1WGGISKkYO4k12Th800tiv3TWohQJDiZY49cDRQHuz4TPX 5V9XL0CGEGh0/vRCnMKMvU/qwkBNsruJwWoRzaYUt2ni2g5R+jKfVNQ1gNWDuz4sLn /WoVm3/2GS20A== From: Miguel Ojeda To: Miguel Ojeda , Wedson Almeida Filho , Alex Gaynor Cc: Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Jonathan Corbet , workflows@vger.kernel.org, linux-doc@vger.kernel.org Subject: [PATCH 3/3] rust: upgrade to Rust 1.73.0 Date: Thu, 5 Oct 2023 23:05:55 +0200 Message-ID: <20231005210556.466856-4-ojeda@kernel.org> In-Reply-To: <20231005210556.466856-1-ojeda@kernel.org> References: <20231005210556.466856-1-ojeda@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 05 Oct 2023 14:07:27 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778951180367729381 X-GMAIL-MSGID: 1778951180367729381 This is the next upgrade to the Rust toolchain, from 1.72.1 to 1.73.0 (i.e. the latest) [1]. See the upgrade policy [2] and the comments on the first upgrade in commit 3ed03f4da06e ("rust: upgrade to Rust 1.68.2"). # Unstable features No unstable features (that we use) were stabilized. Therefore, the only unstable feature allowed to be used outside the `kernel` crate is still `new_uninit`, though other code to be upstreamed may increase the list. Please see [3] for details. # Required changes For the upgrade, the following changes are required: - Allow `internal_features` for `feature(compiler_builtins)` since now Rust warns about using internal compiler and standard library features (similar to how it also warns about incomplete ones) [4]. - A cleanup for a documentation link thanks to a new `rustdoc` lint. See previous commits for details. - A need to make an intra-doc link to a macro explicit, due to a change in behavior in `rustdoc`. See previous commits for details. # `alloc` upgrade and reviewing The vast majority of changes are due to our `alloc` fork being upgraded at once. There are two kinds of changes to be aware of: the ones coming from upstream, which we should follow as closely as possible, and the updates needed in our added fallible APIs to keep them matching the newer infallible APIs coming from upstream. Instead of taking a look at the diff of this patch, an alternative approach is reviewing a diff of the changes between upstream `alloc` and the kernel's. This allows to easily inspect the kernel additions only, especially to check if the fallible methods we already have still match the infallible ones in the new version coming from upstream. Another approach is reviewing the changes introduced in the additions in the kernel fork between the two versions. This is useful to spot potentially unintended changes to our additions. To apply these approaches, one may follow steps similar to the following to generate a pair of patches that show the differences between upstream Rust and the kernel (for the subset of `alloc` we use) before and after applying this patch: # Get the difference with respect to the old version. git -C rust checkout $(linux/scripts/min-tool-version.sh rustc) git -C linux ls-tree -r --name-only HEAD -- rust/alloc | cut -d/ -f3- | grep -Fv README.md | xargs -IPATH cp rust/library/alloc/src/PATH linux/rust/alloc/PATH git -C linux diff --patch-with-stat --summary -R > old.patch git -C linux restore rust/alloc # Apply this patch. git -C linux am rust-upgrade.patch # Get the difference with respect to the new version. git -C rust checkout $(linux/scripts/min-tool-version.sh rustc) git -C linux ls-tree -r --name-only HEAD -- rust/alloc | cut -d/ -f3- | grep -Fv README.md | xargs -IPATH cp rust/library/alloc/src/PATH linux/rust/alloc/PATH git -C linux diff --patch-with-stat --summary -R > new.patch git -C linux restore rust/alloc Now one may check the `new.patch` to take a look at the additions (first approach) or at the difference between those two patches (second approach). For the latter, a side-by-side tool is recommended. Link: https://github.com/rust-lang/rust/blob/stable/RELEASES.md#version-1730-2023-10-05 [1] Link: https://rust-for-linux.com/rust-version-policy [2] Link: https://github.com/Rust-for-Linux/linux/issues/2 [3] Link: https://github.com/rust-lang/compiler-team/issues/596 [4] Signed-off-by: Miguel Ojeda Reviewed-by: Martin Rodriguez Reboredo Reviewed-by: Alice Ryhl Reviewed-by: Vincenzo Palazzo --- Documentation/process/changes.rst | 2 +- rust/alloc/alloc.rs | 22 -------------- rust/alloc/boxed.rs | 48 ++++++++++++++++++++----------- rust/alloc/lib.rs | 5 ++-- rust/alloc/raw_vec.rs | 30 ++++++++++++------- rust/alloc/vec/mod.rs | 4 +-- rust/alloc/vec/spec_extend.rs | 8 +++--- rust/compiler_builtins.rs | 1 + scripts/min-tool-version.sh | 2 +- 9 files changed, 63 insertions(+), 59 deletions(-) diff --git a/Documentation/process/changes.rst b/Documentation/process/changes.rst index 731cc104c56f..bb96ca0f774b 100644 --- a/Documentation/process/changes.rst +++ b/Documentation/process/changes.rst @@ -31,7 +31,7 @@ you probably needn't concern yourself with pcmciautils. ====================== =============== ======================================== GNU C 5.1 gcc --version Clang/LLVM (optional) 11.0.0 clang --version -Rust (optional) 1.72.1 rustc --version +Rust (optional) 1.73.0 rustc --version bindgen (optional) 0.65.1 bindgen --version GNU make 3.82 make --version bash 4.2 bash --version diff --git a/rust/alloc/alloc.rs b/rust/alloc/alloc.rs index 51821feb20b1..8cb4a31cf6e5 100644 --- a/rust/alloc/alloc.rs +++ b/rust/alloc/alloc.rs @@ -6,11 +6,7 @@ #[cfg(not(test))] use core::intrinsics; -#[cfg(all(bootstrap, not(test)))] -use core::intrinsics::{min_align_of_val, size_of_val}; -#[cfg(all(bootstrap, not(test)))] -use core::ptr::Unique; #[cfg(not(test))] use core::ptr::{self, NonNull}; @@ -339,23 +335,6 @@ unsafe fn exchange_malloc(size: usize, align: usize) -> *mut u8 { } } -#[cfg(all(bootstrap, not(test)))] -#[lang = "box_free"] -#[inline] -// This signature has to be the same as `Box`, otherwise an ICE will happen. -// When an additional parameter to `Box` is added (like `A: Allocator`), this has to be added here as -// well. -// For example if `Box` is changed to `struct Box(Unique, A)`, -// this function has to be changed to `fn box_free(Unique, A)` as well. -unsafe fn box_free(ptr: Unique, alloc: A) { - unsafe { - let size = size_of_val(ptr.as_ref()); - let align = min_align_of_val(ptr.as_ref()); - let layout = Layout::from_size_align_unchecked(size, align); - alloc.deallocate(From::from(ptr.cast()), layout) - } -} - // # Allocation error handler #[cfg(not(no_global_oom_handling))] @@ -415,7 +394,6 @@ pub unsafe fn __rdl_oom(size: usize, _align: usize) -> ! { static __rust_alloc_error_handler_should_panic: u8; } - #[allow(unused_unsafe)] if unsafe { __rust_alloc_error_handler_should_panic != 0 } { panic!("memory allocation of {size} bytes failed") } else { diff --git a/rust/alloc/boxed.rs b/rust/alloc/boxed.rs index bdab710f7737..9620eba17268 100644 --- a/rust/alloc/boxed.rs +++ b/rust/alloc/boxed.rs @@ -159,12 +159,12 @@ use core::iter::FusedIterator; use core::marker::Tuple; use core::marker::Unsize; -use core::mem; +use core::mem::{self, SizedTypeProperties}; use core::ops::{ CoerceUnsized, Deref, DerefMut, DispatchFromDyn, Generator, GeneratorState, Receiver, }; use core::pin::Pin; -use core::ptr::{self, Unique}; +use core::ptr::{self, NonNull, Unique}; use core::task::{Context, Poll}; #[cfg(not(no_global_oom_handling))] @@ -483,8 +483,12 @@ pub fn try_new_uninit_in(alloc: A) -> Result, A>, AllocE where A: Allocator, { - let layout = Layout::new::>(); - let ptr = alloc.allocate(layout)?.cast(); + let ptr = if T::IS_ZST { + NonNull::dangling() + } else { + let layout = Layout::new::>(); + alloc.allocate(layout)?.cast() + }; unsafe { Ok(Box::from_raw_in(ptr.as_ptr(), alloc)) } } @@ -553,8 +557,12 @@ pub fn try_new_zeroed_in(alloc: A) -> Result, A>, AllocE where A: Allocator, { - let layout = Layout::new::>(); - let ptr = alloc.allocate_zeroed(layout)?.cast(); + let ptr = if T::IS_ZST { + NonNull::dangling() + } else { + let layout = Layout::new::>(); + alloc.allocate_zeroed(layout)?.cast() + }; unsafe { Ok(Box::from_raw_in(ptr.as_ptr(), alloc)) } } @@ -679,14 +687,16 @@ pub fn new_zeroed_slice(len: usize) -> Box<[mem::MaybeUninit]> { #[unstable(feature = "allocator_api", issue = "32838")] #[inline] pub fn try_new_uninit_slice(len: usize) -> Result]>, AllocError> { - unsafe { + let ptr = if T::IS_ZST || len == 0 { + NonNull::dangling() + } else { let layout = match Layout::array::>(len) { Ok(l) => l, Err(_) => return Err(AllocError), }; - let ptr = Global.allocate(layout)?; - Ok(RawVec::from_raw_parts_in(ptr.as_mut_ptr() as *mut _, len, Global).into_box(len)) - } + Global.allocate(layout)?.cast() + }; + unsafe { Ok(RawVec::from_raw_parts_in(ptr.as_ptr(), len, Global).into_box(len)) } } /// Constructs a new boxed slice with uninitialized contents, with the memory @@ -711,14 +721,16 @@ pub fn try_new_uninit_slice(len: usize) -> Result]>, Al #[unstable(feature = "allocator_api", issue = "32838")] #[inline] pub fn try_new_zeroed_slice(len: usize) -> Result]>, AllocError> { - unsafe { + let ptr = if T::IS_ZST || len == 0 { + NonNull::dangling() + } else { let layout = match Layout::array::>(len) { Ok(l) => l, Err(_) => return Err(AllocError), }; - let ptr = Global.allocate_zeroed(layout)?; - Ok(RawVec::from_raw_parts_in(ptr.as_mut_ptr() as *mut _, len, Global).into_box(len)) - } + Global.allocate_zeroed(layout)?.cast() + }; + unsafe { Ok(RawVec::from_raw_parts_in(ptr.as_ptr(), len, Global).into_box(len)) } } } @@ -1223,7 +1235,9 @@ fn drop(&mut self) { unsafe { let layout = Layout::for_value_raw(ptr.as_ptr()); - self.1.deallocate(From::from(ptr.cast()), layout) + if layout.size() != 0 { + self.1.deallocate(From::from(ptr.cast()), layout); + } } } } @@ -2173,7 +2187,7 @@ pub fn downcast(self: Box) -> Result, Box = self; ::downcast(err).map_err(|s| unsafe { // Reapply the `Send` marker. - mem::transmute::, Box>(s) + Box::from_raw(Box::into_raw(s) as *mut (dyn Error + Send)) }) } } @@ -2187,7 +2201,7 @@ pub fn downcast(self: Box) -> Result, Box let err: Box = self; ::downcast(err).map_err(|s| unsafe { // Reapply the `Send + Sync` marker. - mem::transmute::, Box>(s) + Box::from_raw(Box::into_raw(s) as *mut (dyn Error + Send + Sync)) }) } } diff --git a/rust/alloc/lib.rs b/rust/alloc/lib.rs index 115fcb053e73..73b9ffd845d9 100644 --- a/rust/alloc/lib.rs +++ b/rust/alloc/lib.rs @@ -60,7 +60,7 @@ // To run alloc tests without x.py without ending up with two copies of alloc, Miri needs to be // able to "empty" this crate. See . -// rustc itself never sets the feature, so this line has no affect there. +// rustc itself never sets the feature, so this line has no effect there. #![cfg(any(not(feature = "miri-test-libstd"), test, doctest))] // #![allow(unused_attributes)] @@ -90,6 +90,8 @@ #![warn(missing_docs)] #![allow(explicit_outlives_requirements)] #![warn(multiple_supertrait_upcastable)] +#![cfg_attr(not(bootstrap), allow(internal_features))] +#![cfg_attr(not(bootstrap), allow(rustdoc::redundant_explicit_links))] // // Library features: // tidy-alphabetical-start @@ -139,7 +141,6 @@ #![feature(maybe_uninit_uninit_array_transpose)] #![feature(pattern)] #![feature(pointer_byte_offsets)] -#![feature(provide_any)] #![feature(ptr_internals)] #![feature(ptr_metadata)] #![feature(ptr_sub_ptr)] diff --git a/rust/alloc/raw_vec.rs b/rust/alloc/raw_vec.rs index 65d5ce15828e..a7425582a323 100644 --- a/rust/alloc/raw_vec.rs +++ b/rust/alloc/raw_vec.rs @@ -471,16 +471,26 @@ fn shrink(&mut self, cap: usize) -> Result<(), TryReserveError> { let (ptr, layout) = if let Some(mem) = self.current_memory() { mem } else { return Ok(()) }; // See current_memory() why this assert is here let _: () = const { assert!(mem::size_of::() % mem::align_of::() == 0) }; - let ptr = unsafe { - // `Layout::array` cannot overflow here because it would have - // overflowed earlier when capacity was larger. - let new_size = mem::size_of::().unchecked_mul(cap); - let new_layout = Layout::from_size_align_unchecked(new_size, layout.align()); - self.alloc - .shrink(ptr, layout, new_layout) - .map_err(|_| AllocError { layout: new_layout, non_exhaustive: () })? - }; - self.set_ptr_and_cap(ptr, cap); + + // If shrinking to 0, deallocate the buffer. We don't reach this point + // for the T::IS_ZST case since current_memory() will have returned + // None. + if cap == 0 { + unsafe { self.alloc.deallocate(ptr, layout) }; + self.ptr = Unique::dangling(); + self.cap = 0; + } else { + let ptr = unsafe { + // `Layout::array` cannot overflow here because it would have + // overflowed earlier when capacity was larger. + let new_size = mem::size_of::().unchecked_mul(cap); + let new_layout = Layout::from_size_align_unchecked(new_size, layout.align()); + self.alloc + .shrink(ptr, layout, new_layout) + .map_err(|_| AllocError { layout: new_layout, non_exhaustive: () })? + }; + self.set_ptr_and_cap(ptr, cap); + } Ok(()) } } diff --git a/rust/alloc/vec/mod.rs b/rust/alloc/vec/mod.rs index a4e9a5002a6d..209a88cfe598 100644 --- a/rust/alloc/vec/mod.rs +++ b/rust/alloc/vec/mod.rs @@ -216,7 +216,7 @@ /// /// # Indexing /// -/// The `Vec` type allows to access values by index, because it implements the +/// The `Vec` type allows access to values by index, because it implements the /// [`Index`] trait. An example will be more explicit: /// /// ``` @@ -3263,7 +3263,7 @@ pub fn extract_if(&mut self, filter: F) -> ExtractIf<'_, T, F, A> /// [`copy_from_slice`]: slice::copy_from_slice #[cfg(not(no_global_oom_handling))] #[stable(feature = "extend_ref", since = "1.2.0")] -impl<'a, T: Copy + 'a, A: Allocator + 'a> Extend<&'a T> for Vec { +impl<'a, T: Copy + 'a, A: Allocator> Extend<&'a T> for Vec { fn extend>(&mut self, iter: I) { self.spec_extend(iter.into_iter()) } diff --git a/rust/alloc/vec/spec_extend.rs b/rust/alloc/vec/spec_extend.rs index a6a735201e59..ada919537446 100644 --- a/rust/alloc/vec/spec_extend.rs +++ b/rust/alloc/vec/spec_extend.rs @@ -77,7 +77,7 @@ fn try_spec_extend(&mut self, mut iterator: IntoIter) -> Result<(), TryReserv } #[cfg(not(no_global_oom_handling))] -impl<'a, T: 'a, I, A: Allocator + 'a> SpecExtend<&'a T, I> for Vec +impl<'a, T: 'a, I, A: Allocator> SpecExtend<&'a T, I> for Vec where I: Iterator, T: Clone, @@ -87,7 +87,7 @@ impl<'a, T: 'a, I, A: Allocator + 'a> SpecExtend<&'a T, I> for Vec } } -impl<'a, T: 'a, I, A: Allocator + 'a> TrySpecExtend<&'a T, I> for Vec +impl<'a, T: 'a, I, A: Allocator> TrySpecExtend<&'a T, I> for Vec where I: Iterator, T: Clone, @@ -98,7 +98,7 @@ impl<'a, T: 'a, I, A: Allocator + 'a> TrySpecExtend<&'a T, I> for Vec } #[cfg(not(no_global_oom_handling))] -impl<'a, T: 'a, A: Allocator + 'a> SpecExtend<&'a T, slice::Iter<'a, T>> for Vec +impl<'a, T: 'a, A: Allocator> SpecExtend<&'a T, slice::Iter<'a, T>> for Vec where T: Copy, { @@ -108,7 +108,7 @@ fn spec_extend(&mut self, iterator: slice::Iter<'a, T>) { } } -impl<'a, T: 'a, A: Allocator + 'a> TrySpecExtend<&'a T, slice::Iter<'a, T>> for Vec +impl<'a, T: 'a, A: Allocator> TrySpecExtend<&'a T, slice::Iter<'a, T>> for Vec where T: Copy, { diff --git a/rust/compiler_builtins.rs b/rust/compiler_builtins.rs index fb8ac3f211de..bba2922c6ef7 100644 --- a/rust/compiler_builtins.rs +++ b/rust/compiler_builtins.rs @@ -19,6 +19,7 @@ //! [`compiler_builtins`]: https://github.com/rust-lang/compiler-builtins //! [`compiler-rt`]: https://compiler-rt.llvm.org/ +#![allow(internal_features)] #![feature(compiler_builtins)] #![compiler_builtins] #![no_builtins] diff --git a/scripts/min-tool-version.sh b/scripts/min-tool-version.sh index dc819612ff6a..fd5ffdb81bab 100755 --- a/scripts/min-tool-version.sh +++ b/scripts/min-tool-version.sh @@ -31,7 +31,7 @@ llvm) fi ;; rustc) - echo 1.72.1 + echo 1.73.0 ;; bindgen) echo 0.65.1