aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/parse/rust-parse-impl.h
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2022-06-20 11:22:11 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2022-06-24 15:11:02 +0200
commitaf7f140f2f17b5290ec09266329bd719a7d49d99 (patch)
tree94356d2fde7a77b6dec1a7e1b9baaf2e0233ac0c /gcc/rust/parse/rust-parse-impl.h
parent5b90f0b3cdbe8b83cd8139d0e1bdb0e8e086e358 (diff)
downloadgcc-af7f140f2f17b5290ec09266329bd719a7d49d99.zip
gcc-af7f140f2f17b5290ec09266329bd719a7d49d99.tar.gz
gcc-af7f140f2f17b5290ec09266329bd719a7d49d99.tar.bz2
ast: Allow disambiguation of ConstGenericArgs to const generic arguments
At the AST level, we might encounter situations where const generic arguments are ambiguous: They could be resolved to either a type or a const expression, as shown in this example: ```rust let a: Foo<N>; // what is N? A type? A const? The parser doesn't know ``` However, when parsing default expressions for const generic parameters, we need to be able to disambiguate to const expressions early: ```rust struct Foo<const N: usize = { M }> { /* ... */ } ``` In that code, `M` could be considered ambiguous: Is it a type? a const? A random non-const variable? What matters is that we disambiguate it to a const generic argument, so that it errors out appropriately in later phases of the compiler. In that case, we need to go from a `ConstArg::Ambiguous("M")` to a `ConstArg::Clear(IdentifierExpr("M"))`. In later passes of the compiler, we will also need to disambiguate to types. But that will be done at the HIR/Resolving level.
Diffstat (limited to 'gcc/rust/parse/rust-parse-impl.h')
0 files changed, 0 insertions, 0 deletions