From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by sourceware.org (Postfix) with ESMTPS id 266F23851C2B for ; Thu, 2 Sep 2021 13:23:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 266F23851C2B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-ed1-x532.google.com with SMTP id s25so2922684edw.0 for ; Thu, 02 Sep 2021 06:23:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1ew+hV16SXbNuzp70vA9nw5yLusaRcnbCUipDfDbdCs=; b=CjEG++mTZV3adt7qQNuUh2aZrJlb1M5br2+yb0qIHm3GDjrw52VqQ+rNk0WpRyOmcl 5Y4AxLLMrEYbLTLYiHabo5yPhB74Mz2FIyEj5xofP07hSgLR02SSl2pMp1LaAUkyCGyh TOkDuj6gGpHm6JKn7qaaMeY73awWY+8jlgCI0CTIS0tciEvDcUdnD1Azz0JoXg/u6VA8 fcuFjF3ptuKTO19ibNV9o9IV5T3Fjwdg9FeHdt2FGfdGMRG/e2xHYRZpfHaWTjzOmTmC T1NLI3TIbDgQSXv+zytOVszv6CnCsLG820d2GBhXUgs2tk4WLmvZYAICnFhbBsPgMyko x8Zw== 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=1ew+hV16SXbNuzp70vA9nw5yLusaRcnbCUipDfDbdCs=; b=TzzJCaXiKWZtBveDmCAYjLDKBtnyNh4w+lr2yHUEHgJ4aIkE36K5Tw1w+0YriWuosI LoPZd/ejhuocR7p+/sjFokrlpaw0quOSu/emDLRr3aLgmxSURBNXIrPpnhdHoF8EPPZM O/yJ7x8FbeUlKh56BoKH7uoV40dsN9WRwA1CKaRHkzzMYZ+I236OKI4mQM4qElZiYk91 PuPVhpVViV31qRjCGzT2kww/A+WsyE9QqMRUcAID8N6zJi51DtVNHL2Iu8ZMOT6MDauW uXdcm3PfhtWm0J0rTdwjmyGd8BS7OJPue/WtMfjw7zi3qRG13Px7nnztiRXKcAjKg3vk JLlA== X-Gm-Message-State: AOAM532mUXFprTG1rgL8ENDYll9QPVJZs2dLd5JhhHO2+7vdmTW0GVt3 A5zAEf79ZYGKWbjU2kbNCvhA1+QZDdB2mwZX/EeMeb9B4tOytApH X-Google-Smtp-Source: ABdhPJwCqn5/JR0R94GtMVHa+LdkNvRiMvrCUA8mxEPYC2h4LwRp+PDSTteBWeFIvT2NjSzwk1LbKOsF4l66z85fmLU= X-Received: by 2002:aa7:d303:: with SMTP id p3mr3616399edq.184.1630589024267; Thu, 02 Sep 2021 06:23:44 -0700 (PDT) MIME-Version: 1.0 References: <20210901001542.160965-1-mark@klomp.org> In-Reply-To: From: Philip Herron Date: Thu, 2 Sep 2021 14:23:33 +0100 Message-ID: Subject: Re: Cleanup some StructExpr related classes To: Mark Wielaard Cc: gcc-rust@gcc.gnu.org Content-Type: multipart/alternative; boundary="00000000000091065f05cb0317c3" X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-rust@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: gcc-rust mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Sep 2021 13:23:55 -0000 --00000000000091065f05cb0317c3 Content-Type: text/plain; charset="UTF-8" Hi Mark, I've been reviewing your branch a bit and noticed this commit https://code.wildebeest.org/git/user/mjw/gccrs/commit/?h=enums&id=84d27b926e09ef44dd94be20c97d72bd4b865c40 which I really like. I wasn't sure what was the best way to interact with the AST which contained unique_ptr's to things so I initially added little lambda's but these don't really help anything at all other than make it more confusing to work with. So feel free to create patches to remove those. I also noticed quite a few test cases already are these compiling? And did you have to add much to the rust-gcc.cc wrapper for the enum type? Thanks, --Phil On Wed, 1 Sept 2021 at 20:24, Mark Wielaard wrote: > Hi, > > On Wed, Sep 01, 2021 at 11:11:46AM +0100, Philip Herron wrote: > > This is fantastic work Mar. This brings us closer to the AST structures > of > > rustc and does simplify a lot of the analysis within the compiler. > > https://doc.rust-lang.org/nightly/reference/expressions/struct-expr.html > > The reference does change from time to time. The older one did > describe various constructs that the newer does and for some it still > has comments saying some construct doesn't really construct, like the > tuple expression, which is simply a call (constructor) expression. I > don't know if there is some kind of change log for the Rust reference. > > Note that there are some more StructExpr cleanups at: > https://github.com/Rust-GCC/gccrs/pull/405 > Which might be nice to finish. > > > I agree the HIR cleanup will also help reduce a lot of duplication of > code > > and visitors. It might mean we get alot of enum stuff for free > potentially. > > Potentially yes, but in practice enum item variants are different > enough to require lots of new code. I have patches for the parser, > resolver, and ast-hir-lowering and working on type-checking. One > tricky issue is that references to an enum item are paths with the > enum name first and the enum item second (Enum::Item). Which is > somewhat more complex than the IdentifierExpr. Another is that a > struct has one constructor, an enum has multiple (depending on the > enum item variant). So you need to add variants to the ADTType. > > Work in progress at > https://code.wildebeest.org/git/user/mjw/gccrs/log/?h=enums > cleaned up patches (that I hope are correct) at > https://code.wildebeest.org/git/user/mjw/gccrs/log/?h=enums2 > > Cheers, > > Mark > > --00000000000091065f05cb0317c3 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Mark,

I've been revie= wing your branch a bit and noticed this commit https://code.wildebeest.org/git/user/mjw/gccrs/comm= it/?h=3Denums&id=3D84d27b926e09ef44dd94be20c97d72bd4b865c40 which I= really like. I wasn't sure what was the best way to interact with the = AST which contained unique_ptr's to things so I initially added little = lambda's but these don't really help anything at all other than mak= e it more confusing to work with. So feel free to create patches to remove = those.

I also noticed quite a few test cases already are = these compiling? And did you have to add much to the rust-gcc.cc wrapper fo= r the enum type?

Thanks,
--Phil
<= /div>

On Wed, 1 Sept 2021 at 20:24, Mark Wielaard <mark@klomp.org> wrote:
Hi,

On Wed, Sep 01, 2021 at 11:11:46AM +0100, Philip Herron wrote:
> This is fantastic work Mar. This brings us closer to the AST structure= s of
> rustc and does simplify a lot of the analysis within the compiler.
> https://doc.rust-lang.o= rg/nightly/reference/expressions/struct-expr.html

The reference does change from time to time. The older one did
describe various constructs that the newer does and for some it still
has comments saying some construct doesn't really construct, like the tuple expression, which is simply a call (constructor) expression.=C2=A0 I<= br> don't know if there is some kind of change log for the Rust reference.<= br>
Note that there are some more StructExpr cleanups at:
https://github.com/Rust-GCC/gccrs/pull/405
Which might be nice to finish.

> I agree the HIR cleanup will also help reduce a lot of duplication of = code
> and visitors. It might mean we get alot of enum stuff for free potenti= ally.

Potentially yes, but in practice enum item variants are different
enough to require lots of new code. I have patches for the parser,
resolver, and ast-hir-lowering and working on type-checking. One
tricky issue is that references to an enum item are paths with the
enum name first and the enum item second (Enum::Item). Which is
somewhat more complex than the IdentifierExpr. Another is that a
struct has one constructor, an enum has multiple (depending on the
enum item variant). So you need to add variants to the ADTType.

Work in progress at
https://code.wildebeest.org/git/user/mj= w/gccrs/log/?h=3Denums
cleaned up patches (that I hope are correct) at
https://code.wildebeest.org/git/user/m= jw/gccrs/log/?h=3Denums2

Cheers,

Mark

--00000000000091065f05cb0317c3--