From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8CB69C43461 for ; Fri, 16 Apr 2021 17:47:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 73C1E613C0 for ; Fri, 16 Apr 2021 17:47:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243683AbhDPRsJ (ORCPT ); Fri, 16 Apr 2021 13:48:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235563AbhDPRsI (ORCPT ); Fri, 16 Apr 2021 13:48:08 -0400 Received: from mail-yb1-xb2b.google.com (mail-yb1-xb2b.google.com [IPv6:2607:f8b0:4864:20::b2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE233C061574; Fri, 16 Apr 2021 10:47:43 -0700 (PDT) Received: by mail-yb1-xb2b.google.com with SMTP id c195so30995859ybf.9; Fri, 16 Apr 2021 10:47:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=9B3zLmsWW5JKnyeoXM62mq4ssLBBmbVfc6OxFpsrw9I=; b=hdcPyZUnuJB055x0jdoEeJrjGBSst+PTFbMj7iIqIkrtWwKEUAL/YVdX2GFEh6SsZU 8WnfOHuG3US0GLHO3t7mRdptyFSOC3HNdtyOAutUEs/zw21sq5+h0oSsd1CGV71oiBmy 9mI4rLxxTFdvbytHIaSOfiVecGSrq9SJONPZdPlKRt4s12EZbTpnC1OmGvTXlBHHlBTd rlaec/DMmHKTjbfdCxn3pm4z+Rv3rjVSxwGnw7m39LDA66AllX2JXRUM0a76go1f+Zcg JFP2QbyIiuouH5IsTOsjDnlU7QBrlKxRkIkF+GSHB+gyyJRmeafavZFcQNxUapwZO3RW CLcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=9B3zLmsWW5JKnyeoXM62mq4ssLBBmbVfc6OxFpsrw9I=; b=CDG2MKLvYyTMGHOe6xqQdIi3DS42pZS/8Hn9PBUm/l45DPF/X0RFIjptexp/28Gtn8 aeIYVvaDk4fKYDBBeBhdegog7Tt3+Rf80hlNBsTxcrYTZpHzI6Ccmn5TLy/Y99iKEtF9 2tTkpo8HjurGk8Y+/qPGnM30jahHOaVRdmXkqu17/mPfcsKvo7AW3C4JuB/Lg+3bIYYo 5A/NGsvLjqTwPuziCyjFRRLUCnMIBGiUbv2YAXkwQi7AjORtEMbJcWpkQQeMWdkbdbVk 2lOeRHDhD+3FcjsyTOyUBcyk+Dfj5V1eNjKhRHXpo9qnUk22crou8c7IkB6t9YCXAVTc S6qw== X-Gm-Message-State: AOAM5330GCoEOqSAmQpQzxvo84xAiu19nnoR2xDP72kxJQJMRXFFjX6g 5y/rihZDt+VHbwwuuR0WnNDc4lRhu0IoMrKWyQ8= X-Google-Smtp-Source: ABdhPJzeRdmS95ayxhHbmPvr3HkEAHY/TbsX02E5nIbHerewe4bZjGqCyv67ELdtn+0Xhv0lZ2rxo0wxExt5A/CiwNM= X-Received: by 2002:a25:bfc9:: with SMTP id q9mr360954ybm.33.1618595263104; Fri, 16 Apr 2021 10:47:43 -0700 (PDT) MIME-Version: 1.0 References: <20210414184604.23473-1-ojeda@kernel.org> <20210414184604.23473-5-ojeda@kernel.org> In-Reply-To: From: Miguel Ojeda Date: Fri, 16 Apr 2021 19:47:32 +0200 Message-ID: Subject: Re: [PATCH 04/13] Kbuild: Rust support To: Linus Torvalds Cc: Peter Zijlstra , Miguel Ojeda , Greg Kroah-Hartman , rust-for-linux@vger.kernel.org, Linux Kbuild mailing list , "open list:DOCUMENTATION" , Linux Kernel Mailing List , Alex Gaynor , Geoffrey Thomas , Finn Behrens , Adam Bratschi-Kaye , Wedson Almeida Filho , Michael Ellerman Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-doc@vger.kernel.org On Fri, Apr 16, 2021 at 7:05 PM Linus Torvalds wrote: > > Typical Rust error handling should match the regular kernel > IS_ERR/ERR_PTR/PTR_ERR model fairly well, although the syntax is > fairly different (and it's not limited to pointers). Yeah, exactly. We already have a `KernelResult` type which is a `Result`, where `Error` is a wrapper for the usual kernel int errors. So, for instance, a function that can either fail or return `Data` would have a declaration like: pub fn foo() -> KernelResult A caller that needs to handle the error can use pattern matching or one of the methods in `Result`. And if they only need to bubble the error up, they can use the ? operator: pub fn bar() -> KernelResult { let data = foo()?; // `data` is already a `Data` here, not a `KernelResult` } Cheers, Miguel