public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] Merge #1315 Date: Tue, 21 Jun 2022 10:33:24 +0000 (GMT) [thread overview] Message-ID: <20220621103324.919BD383F956@sourceware.org> (raw) https://gcc.gnu.org/g:848a1a28b91d105ff4f21cc9993befbcecb3e39d commit 848a1a28b91d105ff4f21cc9993befbcecb3e39d Merge: d4a0780073b 0dbfdb5cfc5 Author: bors[bot] <26634292+bors[bot]@users.noreply.github.com> Date: Fri Jun 17 07:12:29 2022 +0000 Merge #1315 1315: Add base for parsing const generic application r=CohenArthur a=CohenArthur 1. Refactor const generic declaration The default value for const generics now benefits from using the same function as parsing a regular const generic expression 2. `Parser::parse_type` should not always add errors In the case that we are parsing a const generic and not a type, we should not emit bogus errors from `parse_type` such as "unexpected token in type: LITERAL". Thus, we add a flag to the function to not always add errors to the error table 3. Figure out how to deal with ambiguities In the following cases, parsing is ambiguous: ```rust let a: Foo<N>; ``` What is N? Is it a type to be used as a generic argument? Is it a const value to be used for a const generic argument? We need to keep both possibilities and differentiate later during typechecking. We need to figure out if it would be better to keep the ambiguity in our future `ConstGenericArg` type (something like Kind::ConstVarOrType) or modify our current `AST::Type` to maybe get differentiated later as a const variable, which seems more annoying. Finally, since the const evaluation is not implemented yet, we are getting some bogus errors in the testcase. This commit simply serves as a necessary base: parsing const generics before we can apply them. Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com> Diff: gcc/rust/ast/rust-path.h | 2 + gcc/rust/parse/rust-parse-impl.h | 159 +++++++++++++++---------- gcc/rust/parse/rust-parse.h | 3 +- gcc/testsuite/rust/compile/const_generics_3.rs | 26 ++++ 4 files changed, 128 insertions(+), 62 deletions(-)
reply other threads:[~2022-06-21 10:33 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220621103324.919BD383F956@sourceware.org \ --to=tschwinge@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).