Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp556098pxb; Fri, 16 Apr 2021 12:05:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5lDmaBsdyGcfiY2AI/d/yoPGfCmSbr3pz8gYfJLxtHX/XzWYVUGYZlsUTCJoEASpm46Yk X-Received: by 2002:a17:906:37c9:: with SMTP id o9mr9631891ejc.285.1618599939160; Fri, 16 Apr 2021 12:05:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618599939; cv=none; d=google.com; s=arc-20160816; b=uyv1Q1u7lTt3HN62hoN1ulY04Awiv6uTIPrwDOfd6+8stcslw9VBbQPTzChBrmdOYH c8ibqi4c9KOq3LgjNfRHyPqEnRJVaA3mSGqrhcdWlQU9c2di4W0+9GocXi33togAj0p9 yTvqzYj7OJFs5vlD95DchX35FGiH8QBYhpBhy04pT36Pz8Oi3Oq2pXjE9O2giehHO50K FZRD/OBxMyMKDzEL6nMqaSdTLprntgBbsgh6g5qcU4lagUqDff8+JzT5mgjBd/ObAWMr SyDsXaZB0+jC/d0tPEkp394jBwTANALHCLvlc2JGn6LGIstj1AbK7PTSmhqxdNhYfQqn uosQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=9B3zLmsWW5JKnyeoXM62mq4ssLBBmbVfc6OxFpsrw9I=; b=NMi4SR4RUCv61wAqHg5yLMhOveBUdf39Q5IApZffai1LeAR1hko5ngBPJpi654XZY1 +F4Yb86pHVcMyaOj+x9Feq59Gqeit/guA9RW20YxGR9nzloVKJ1U/lFXaOdVqpiWLAiZ fR+rNXIEDin/0bOnwJabAFfvFH7oRwg3TgSllVhSkPqP7aNtXcPhwQRVZgHJoS+CoDrC Vfnh39DH2F0iHoheb/73N1ATcCSXKQdt1I51RVsLiQ7v1rIgk4m/XhB7enIyJwc8eiWv OuQ7GegmmMSIir95HQIxH3vDFUiyvf2K/F6Xjp5BSbNvVP4kphj6l5t3afwsc1zFyStw +P7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hdcPyZUn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p18si5308310ejg.216.2021.04.16.12.05.16; Fri, 16 Apr 2021 12:05:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hdcPyZUn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243698AbhDPRsJ (ORCPT + 99 others); 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-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-kernel@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