Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp10268551rwp; Thu, 20 Jul 2023 18:05:05 -0700 (PDT) X-Google-Smtp-Source: APBJJlFnoGd0LP+EimviWGzUTFTQj8JjjHNpMC5MlBD24QDceU6ebOMwylVmI6gWW2daAnKwSWh3 X-Received: by 2002:a17:903:41cb:b0:1b3:d6c8:7008 with SMTP id u11-20020a17090341cb00b001b3d6c87008mr627041ple.57.1689901505074; Thu, 20 Jul 2023 18:05:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689901505; cv=none; d=google.com; s=arc-20160816; b=XjLvi7tCG1BvbVnztAWYH/fX32lWERsQwLsasABnsIXD7Wixe+ZP7o1uMGrpBS8Vq8 +6Mp6lHl9ZtYxf7/af5DquAkMLorAmHPiBjpzu1RzaJSjgH3W6RwFtd8rNPUMushMoji AB6d63PIPJoXpqn2WP5jld/JmlK4HG+KYoeFPBwnKNI2qBiNDRMjOKf1Blh72lSUNb46 IPxNE31h19VCr98O09lXhB5PY/zJk5iZSYWbCE3yQide8f3JDRvA2YnT6B6haGuIxBye XznozNBaoNfspfmZ1jHedI3DZ92w5IGk0UvtDgzh4PSqWMco6J9/ZKmma5XWZsbDdOEy ilVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=fFIBwtmo2IIbiaxwKJGeWrtXlnHB7ucvw4QiyNqWMKM=; fh=M48Nkp047DQ57qG9/TGfMDIe12Tt7gV48cIFqTE5RcU=; b=mYwWvLJgl3hnFXEO6Wq95J5oap98KLH+k3MFeLKzLbtezjN11O1NYO5ydcDLms5jYL x2US+Kr7+zIvNtFosl7BqJo70zeNJljdrXgcNNTc5ONdJKuJoNwhrI69Ypi9Hun4AOT4 i3+NfwCa3PO8khxfTx3APvDJV7TRLbLrTnrjRhEav8hMbGzornbHL5JIxtKDolqMdh1i FJXBC8g/3JBRrgHiLCfm6yqtH4gvVFF2TXmsdYMluStFYMYnW/ftrn7A+qPLTGAUebIP /lkrWdDCfKwmBY5sWnCXJxTeBSbZmQTV/XeKfcSHC1dQHWNtCIaFnUfzp2/uvDU28egD eY6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=AgDHG+aP; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d11-20020a170903230b00b001b89b77ce99si2141076plh.458.2023.07.20.18.04.44; Thu, 20 Jul 2023 18:05: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=@gmail.com header.s=20221208 header.b=AgDHG+aP; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230038AbjGUAZy (ORCPT + 99 others); Thu, 20 Jul 2023 20:25:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230003AbjGUAZo (ORCPT ); Thu, 20 Jul 2023 20:25:44 -0400 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94D5B30EA; Thu, 20 Jul 2023 17:25:19 -0700 (PDT) Received: by mail-oi1-x22f.google.com with SMTP id 5614622812f47-3a37909a64eso952361b6e.1; Thu, 20 Jul 2023 17:25:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689899118; x=1690503918; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=fFIBwtmo2IIbiaxwKJGeWrtXlnHB7ucvw4QiyNqWMKM=; b=AgDHG+aPobDVWwpkGdmJ4jWljkAyKr7gH0LrLyhn7+Jp7Cw87ZYdFOmtiZarT6mdjL yEPVyQdjSXgp+gq1oXxngeaGn1aqTlIrYYOQSudkxsI8OHljGw70fTMobH0hItNbgpuR 77rr1YlT5/aSwPSxYHoBns/bUNj2Sj2sih0fnMrO3yZBDAozPoQGBUDeEqyCmqOMuh8t x9p0rKhbq+S0mFBZW169Ej/6lePLEK/UPzIqGuF0XOLw+uFYANW5+8a4dYd+4bDwOadE nZhNOKuaBydaUeBeJfbao0bD4iib63Y/5LWUkZq06Zp3MLcINWk8fpx+Af4SP903OUfS PCqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689899118; x=1690503918; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fFIBwtmo2IIbiaxwKJGeWrtXlnHB7ucvw4QiyNqWMKM=; b=KZWvwMRdmRj1HUGRAsZeVCQULXcBLXHpg6dh05wz1y7WqU2nER54j+3aJRge9Fe8S0 SSCJYNVn80wHVgdiZDpfXKS/WOplr/qtcF9MtBw5DlRTm6vG25I8ujr/qRgOaqkHohdL fRdXsY3KLzzTT2W56kVgGahS7aCtk0FELOnunuGDiDxvFBM6NhG/Xn9P1mZXFTG07ya1 W4FhCzY5XU4GT628CgzIgCiWnKqgVpeUPIlH6dAZelNEjmRAGBo/KWUphnShNFJv0O9u NlUtiMVBesXuev/WW8Ye2Q6rxoKL3SMpGuCoec+4+XVOOnajbYAkx4xD3McMffoPpe7R DbSg== X-Gm-Message-State: ABy/qLaMDSFS5uy1NoRBJep7Bfx+N18OONeXb6oUPg5j/nCpLYZcOLHS I1sf7Hf6ymDNTq/69126IWw= X-Received: by 2002:a05:6808:1409:b0:39e:5892:8539 with SMTP id w9-20020a056808140900b0039e58928539mr586637oiv.9.1689899118692; Thu, 20 Jul 2023 17:25:18 -0700 (PDT) Received: from [192.168.54.90] (static.220.238.itcsa.net. [190.15.220.238]) by smtp.gmail.com with ESMTPSA id t25-20020a056808159900b0039ee1de4e6esm928210oiw.38.2023.07.20.17.25.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 20 Jul 2023 17:25:18 -0700 (PDT) Message-ID: <41d543d4-ab21-d10f-f484-4d5360fed7c2@gmail.com> Date: Wed, 19 Jul 2023 16:07:56 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 05/12] rust: init: make initializer values inaccessible after initializing Content-Language: en-US To: Benno Lossin , Miguel Ojeda , Wedson Almeida Filho , Alex Gaynor Cc: Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Alice Ryhl , Andreas Hindborg , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org References: <20230719141918.543938-1-benno.lossin@proton.me> <20230719141918.543938-6-benno.lossin@proton.me> From: Martin Rodriguez Reboredo In-Reply-To: <20230719141918.543938-6-benno.lossin@proton.me> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00,DATE_IN_PAST_24_48, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 On 7/19/23 11:20, Benno Lossin wrote: > Previously the init macros would create a local variable with the name > and hygiene of the field that is being initialized to store the value of > the field. This would override any user defined variables. For example: > ``` > struct Foo { > a: usize, > b: usize, > } > let a = 10; > let foo = init!(Foo{ > a: a + 1, // This creates a local variable named `a`. > b: a, // This refers to that variable! > }); > let foo = Box::init!(foo)?; > assert_eq!(foo.a, 11); > assert_eq!(foo.b, 11); > ``` > > This patch changes this behavior, so the above code would panic at the > last assertion, since `b` would have value 10. > > Signed-off-by: Benno Lossin > --- > [...] Reviewed-by: Martin Rodriguez Reboredo