From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id 919BD383F956; Tue, 21 Jun 2022 10:33:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 919BD383F956 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] Merge #1315 X-Act-Checkin: gcc X-Git-Author: bors[bot] <26634292+bors[bot]@users.noreply.github.com> X-Git-Refname: refs/heads/devel/rust/master X-Git-Oldrev: d4a0780073bfaf96d72427d5138b74ef257ed625 X-Git-Newrev: 848a1a28b91d105ff4f21cc9993befbcecb3e39d Message-Id: <20220621103324.919BD383F956@sourceware.org> Date: Tue, 21 Jun 2022 10:33:24 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Jun 2022 10:33:24 -0000 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; ``` 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 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(-)