Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp661790pxb; Fri, 16 Apr 2021 15:10:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwtcXZ2uBOYQLtWRm8HX/uqJfW03Egnee44+dkcW8B7SyhZQVmOKKij3/l7BciZC5cdIaEe X-Received: by 2002:a05:6402:1ad9:: with SMTP id ba25mr12523599edb.264.1618611010367; Fri, 16 Apr 2021 15:10:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618611010; cv=none; d=google.com; s=arc-20160816; b=zbNvMlf9eLHuhXxEpP79w2v6MrpERKJNVVgC+eA2FkSM32/Ibd+DdzmR3F1AIgBPtO W8mrcijEu/zRMFlmgtG9uAksXQwaF6vBUHw3bd+uVkILvrAu/51YzRpbqz/7wUko2d2w F6LKbbsWOhTjdiMO3P13iXFui+REQPCbx4Ihqqv6E3L3ZpUSyOYmAAc8Q1PCzE6BFGWk EAX+lNMDceFpLN7T7noeilHyRUzpMSlP5EW8Kci7Tk3EHyYxboSYGgFhrd3d+9Hhp1j3 SsqBOgvSNIiA3obnP9lfmVp4Mzrr9+1vor2QzrHeXtxcd938iMwIi7CFMEhHDVtlKklK /WLw== 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=udsjYFmKZpzpPEZQ/S94m1J5JpuvU1EmGzVJfAa7Om8=; b=JC79UWWT2jPW5WDYldcKXxeIaga54ne0oBMW0+CEG5kg8q2YW4NQeGRB7JH4YUQxY7 C/buIAPpA4lgj69PS8nWL/eNIYZ2Amu6iSR8gbtvELHDcJIKP//pu8jspzWNWD3vAVqf sD0LDCXn8WZ6OyyjjhLTpsqYql+r5m/Ref21NtAMdartbj4axN5qHboKagsfGvgJ54WI CbjdEVx0/XXeRnyat0QRj4vRkvfAw5m3CWfJuJc0DgO/5pVAWx63zix3strRNWmiIRpL 2wBH6EyT6Bp6V/xq5XWgCpWLz8Fm460z7ShtG1KiKWEe87DhqZP7bIEKJut7m70453rQ Bgrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=EosPrWTw; 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 nd5si5693080ejc.395.2021.04.16.15.09.47; Fri, 16 Apr 2021 15:10:10 -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=EosPrWTw; 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 S1344220AbhDPVWj (ORCPT + 99 others); Fri, 16 Apr 2021 17:22:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344236AbhDPVV6 (ORCPT ); Fri, 16 Apr 2021 17:21:58 -0400 Received: from mail-yb1-xb2a.google.com (mail-yb1-xb2a.google.com [IPv6:2607:f8b0:4864:20::b2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44FF8C061344; Fri, 16 Apr 2021 14:19:29 -0700 (PDT) Received: by mail-yb1-xb2a.google.com with SMTP id n12so31607189ybf.8; Fri, 16 Apr 2021 14:19:29 -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=udsjYFmKZpzpPEZQ/S94m1J5JpuvU1EmGzVJfAa7Om8=; b=EosPrWTw2GhguQ2HMV+cpFl/54oW1S4zmr0H6Z19xIAq8cU8Ub7uO0q4nQJtoyDVvK BNqH90kAcYN+mw5cr4HGgxGG+iJGmV4cALQryNtFoHePwef1ZBT3WZigxR2u2XzyID7Y FtENA/IG+gQ+zeJ6zH2YdrU+qKGAPR0s8lhip+Vpw4vNuMV+2D2wdts7ehDxz0UES6H4 l4fvpS8suXEog7ap3jlfQ0Xh4KOLjFaYu3p7hSp7QcjjOsG8VFx8Qr4mwG/NZitsEk7L pRcdqgY1Iw0tQF5BDyjGmlQw08P9lXHmjJ5Q0dPeFAD9IEr3E316XmQ10pJ36U1McKEH ToRQ== 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=udsjYFmKZpzpPEZQ/S94m1J5JpuvU1EmGzVJfAa7Om8=; b=WdpT+jFBsWQRQ819ZrHvu+RIVCQZ6P3/aI4uXeNhips7Orx0XP5xfsJw0s2WikOY0L LVzK/8ZOWcvKvm6dYnxXTsEduDbbDjceYc3JVFya+lQ9P5dd4/zwIQXvnQJWqc3IQng/ OPd03p0iJMEf1Lhs3lA8OZIoFfnMr9MivkaoBKNT8taHb3ENJ0MJtrmXjEq1lDBy1huI VlOgAD6P65sennUFm8Ut5WPB5k3wOqcTGfqf1xR/uEO6k42Urw0xzCV4sTL+vZ06qjez s6b0sadOrmxHIjE2Vt5J9rItfnGUkUtXxgWQtFyRcnu6CkziQkC8WIoQsYsrhQVjnaeX XrDA== X-Gm-Message-State: AOAM533mtfUVJMZUwgqIIoU1Vx3iohlS4kTf7VzgddxIYqhF2Do51FT9 0ALxOPUr3WEk2I15QmHL8DV+Fra6pcb9JpH3+5M= X-Received: by 2002:a25:7909:: with SMTP id u9mr1528074ybc.22.1618607969202; Fri, 16 Apr 2021 14:19:29 -0700 (PDT) MIME-Version: 1.0 References: <20210414184604.23473-1-ojeda@kernel.org> <20210414184604.23473-5-ojeda@kernel.org> <20210416202215.GA11236@1wt.eu> In-Reply-To: <20210416202215.GA11236@1wt.eu> From: Miguel Ojeda Date: Fri, 16 Apr 2021 23:19:18 +0200 Message-ID: Subject: Re: [PATCH 04/13] Kbuild: Rust support To: Willy Tarreau Cc: Al Viro , Linus Torvalds , 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 10:22 PM Willy Tarreau wrote: > > So it simply does the equivalent of: > > struct result { > int status; > int error; > }; Not exactly, it is more like a tagged union, as Connor mentioned. However, and this is the critical bit: it is a compile-time error to access the inactive variants (in safe code). In C, it is on you to keep track which one is the current one. > kill_foo(); // only for rust, C doesn't need it Please note that `kill_foo()` is not needed in Rust -- it was an example of possible cleanup (since Al mentioned resources/cleanup) using RAII. Cheers, Miguel