Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6790602rwr; Tue, 2 May 2023 05:46:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7am3e4YFW7PBVa7kuj7IwONY/NLGmAhLa5PwWgfja+8Xc4KlPtCQobrhp+J7T4FI0QvIx/ X-Received: by 2002:a17:903:2285:b0:1aa:f536:b1e2 with SMTP id b5-20020a170903228500b001aaf536b1e2mr8228048plh.62.1683031565671; Tue, 02 May 2023 05:46:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683031565; cv=none; d=google.com; s=arc-20160816; b=lpcY/gqsAS/TNlIQWUc+Kebi9Cwn9qh/0VwfvgeBFX7znME0BYhpPfvgWpZkJhilGQ OhdTO65PI3Cn44aIzeGV2DFk2hhpCRd8ftBZpiuWJEfJ71ED0MNvmpfXKkSRkrca91YU /8Peh4iiwz3lQYksV+m4iTIeAvxeVtTnZ28vgYu1YNP9bfNEHEngltxMjcw85CclJ3+v 69aOMoMfASAAvyjPRkgqRf+H99/ME7C9mX5qE5MEdIw2DZAsa7r5jjQAOuNzrGU/noIo HnSacBZImy3O/yfDChM14CgenPGOuwK2RC+9mvW5kn0xCojbNO4gWSVu4l1b2/v0LJbw AidQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=ADtw/qW1A9BDeVMPTl0uodglbiJnCrGJeTfJlSlwBKg=; b=cIeC8XgtZpVJGdbvEwTPjdkObBJbzIRdio61+yp5kwLoy2RGNCNVIurFnZdilG3wAH XC/QNxpekYCcjbCPFVixpemmhobOCPeunLX+P8RNx+DEGUxAbxYXtmtUvQHR0WUoPZPD jnh9hPE3qy4AQAJd09T8o66QvOuPVe7T2nNagQULrbRWw90gyBlaHypvTVKw3o7LsmII XcLu2er/98KxXth6CA800EWY+B0yW/aLguOoOSWNgI59xDBwaEV6nt2FQREbI/AJSXM3 ze06IGBwvenxJ/pHg59TczO8nAmifFjE+k9ggoRqOXdXfPQs/QhRg+cdfQbI2gI3f+y0 QR8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=lRfYJWOz; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s22-20020a170902b19600b001aadba392b7si7169178plr.517.2023.05.02.05.45.51; Tue, 02 May 2023 05:46:05 -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=@google.com header.s=20221208 header.b=lRfYJWOz; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233909AbjEBMkv (ORCPT + 99 others); Tue, 2 May 2023 08:40:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233721AbjEBMku (ORCPT ); Tue, 2 May 2023 08:40:50 -0400 Received: from mail-ed1-x54a.google.com (mail-ed1-x54a.google.com [IPv6:2a00:1450:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 772DD59D0 for ; Tue, 2 May 2023 05:40:47 -0700 (PDT) Received: by mail-ed1-x54a.google.com with SMTP id 4fb4d7f45d1cf-50bcaaeaec0so1780066a12.2 for ; Tue, 02 May 2023 05:40:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683031246; x=1685623246; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=ADtw/qW1A9BDeVMPTl0uodglbiJnCrGJeTfJlSlwBKg=; b=lRfYJWOz4yXMl4kx4LfEGKhFornexgFZ/Pzr37hrHOqVYHHpYkdPbpSnnCMSkD7gE9 tNNzh3nS+kfLmd5nCFeXPqcvbh5ujRqoww7VqTHgr6zPziQA2Lw+YEw5Qb7sdjVurQok o5lHwpagAes7lc7Rpz3w1bCyXkg+VC1sj2qLGS6PMJXio9kkOFIqwBlRyy/0EIe0SGZ0 3UiLeNvXApuYs9vCwKwPyVJkGkI3qfl7yx3aC6ihkrqR7n2eEgqgyXQm5qAvoanfUkvG cCNZ4EQpl0aHc6TP7bgtLHeuK02F7M9uZLmnaDPV4GegmHN3m2CGIctOY00bdWgTSRIp 4/Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683031246; x=1685623246; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=ADtw/qW1A9BDeVMPTl0uodglbiJnCrGJeTfJlSlwBKg=; b=R5Nlal06kl+8glnNlslbCLc2H1yyONKNrl3QWS2QkshWP2AySB/FQp89ZHoAWm8pg9 Js0ArDsrr1VoiO8rPprzI5QxUkbuRktXX3229m5XGL3B86yWec6XwqBp36i9JakCzxJc ism1ZXMch/Bdgm28rjgQrCE8woVb2mbJpbf8p2+flBXbVcqRiVxB2L0gLHi7saoNFp+/ 8k0Ijz//Obpi+J0i/W5s3SKb4isuDfB4aT+TecHY7Q+gZHIy0ue/x7ty6y0fOBp590CW chY9oJSO9WnwzPTrCdtEaHyzB7Qr+9MYFS5lsauw75o/itCQsOoBefRUT6fw+vlnQRU8 ipjg== X-Gm-Message-State: AC+VfDwy87xbqnv8/kkT+YPjgGTEDrbBuXXfvX6QlMG/LsRMTgzADYEC p5Dda0XNNw9x5yGUdv1iVy+YZwMacesgOAY= X-Received: from aliceryhl.c.googlers.com ([fda3:e722:ac3:cc00:31:98fb:c0a8:6c8]) (user=aliceryhl job=sendgmr) by 2002:a50:9fe3:0:b0:50b:c83b:22d8 with SMTP id c90-20020a509fe3000000b0050bc83b22d8mr2063829edf.3.1683031242984; Tue, 02 May 2023 05:40:42 -0700 (PDT) Date: Tue, 2 May 2023 12:40:15 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.40.1.495.gc816e09b53d-goog Message-ID: <20230502124015.356001-1-aliceryhl@google.com> Subject: [PATCH] rust: error: allow specifying error type on `Result` From: Alice Ryhl To: Miguel Ojeda , Wedson Almeida Filho , Alex Gaynor Cc: Boqun Feng , Gary Guo , "=?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?=" , Benno Lossin , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Alice Ryhl Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL 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 Currently, if the `kernel::error::Result` type is in scope (which is often is, since it's in the kernel's prelude), you cannot write `Result` when you want to use a different error type than `kernel::error::Error`. To solve this we change the error type from being hard-coded to just being a default generic parameter. This still lets you write `Result` when you just want to use the `Error` error type, but also lets you write `Result` when necessary. Signed-off-by: Alice Ryhl --- rust/kernel/error.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/kernel/error.rs b/rust/kernel/error.rs index 5f4114b30b94..01dd4d2f63d2 100644 --- a/rust/kernel/error.rs +++ b/rust/kernel/error.rs @@ -177,7 +177,7 @@ impl From for Error { /// Note that even if a function does not return anything when it succeeds, /// it should still be modeled as returning a `Result` rather than /// just an [`Error`]. -pub type Result = core::result::Result; +pub type Result = core::result::Result; /// Converts an integer as returned by a C kernel function to an error if it's negative, and /// `Ok(())` otherwise. base-commit: ea76e08f4d901a450619831a255e9e0a4c0ed162 -- 2.40.1.495.gc816e09b53d-goog