diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2023-02-15 16:53:41 +0100 |
---|---|---|
committer | CohenArthur <arthur.cohen@embecosm.com> | 2023-02-23 13:54:18 +0000 |
commit | f60c15f5099349ccc04a697e4d37154c371253a3 (patch) | |
tree | 7453ed1d10bce6cb8238198b3af61ceedd28ac16 /gcc/tree-vectorizer.h | |
parent | 918851ad2c965cef63dd0cb0be01f80a80d6c9c7 (diff) | |
download | gcc-f60c15f5099349ccc04a697e4d37154c371253a3.zip gcc-f60c15f5099349ccc04a697e4d37154c371253a3.tar.gz gcc-f60c15f5099349ccc04a697e4d37154c371253a3.tar.bz2 |
parser: Add parsing of auto traits
This adds enough handling to start parsing `auto` traits but not handle
them in the AST, lowering phase or HIR yet.
The feature is named `optin_builtin_traits` in Rust 1.49 but changes to
`auto_traits` later down the line. So we'll need to take care of this later
on.
Finally, this also changes the way the lexer detects if a string is a
keyword or not. We relied on a call to `std::lower_bound` to figure
out if a string was contained in an array or not, and this ended up
causing issues when adding new keywords. We can instead switch to a
simple hashmap and search for the key. The code *might* be less
optimized (unsure) but it is definitely simpler and easier to read.
Fixes #1814
gcc/rust/ChangeLog:
* ast/rust-item.h (class Trait): Add `has_auto` field.
* checks/errors/rust-feature.cc: Add handling for `feature(optin_builtin_traits)`
* checks/errors/rust-feature.h: Likewise.
* lex/rust-lex.cc: Fix keyword classification using hashmap.
* lex/rust-token.h: Add `auto` keyword token.
* parse/rust-parse-impl.h (Parser::parse_vis_item): Parse auto traits
on `auto` keyword.
gcc/testsuite/ChangeLog:
* rust/compile/auto_trait_invalid.rs: New test.
* rust/compile/auto_trait_valid.rs: New test.
Diffstat (limited to 'gcc/tree-vectorizer.h')
0 files changed, 0 insertions, 0 deletions