public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] Merge #1315
@ 2022-06-21 10:33 Thomas Schwinge
0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-21 10:33 UTC (permalink / raw)
To: gcc-cvs
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(-)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-21 10:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-21 10:33 [gcc/devel/rust/master] Merge #1315 Thomas Schwinge
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).