diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2023-02-15 16:53:41 +0100 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-01-16 18:13:36 +0100 |
commit | 221281052df7f6fe5f742f5029c262d22d45031d (patch) | |
tree | af43d313f2b08dbf4b395d42eb7718e2cb32d1b2 /gcc/tree-loop-distribution.cc | |
parent | f8770d18f595ee6c533d49d330b0bfacafcbbaf4 (diff) | |
download | gcc-221281052df7f6fe5f742f5029c262d22d45031d.zip gcc-221281052df7f6fe5f742f5029c262d22d45031d.tar.gz gcc-221281052df7f6fe5f742f5029c262d22d45031d.tar.bz2 |
gccrs: 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-loop-distribution.cc')
0 files changed, 0 insertions, 0 deletions