diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-06-14 18:44:26 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-14 18:44:26 +0000 |
commit | 44f2de02d478b5d3defa5f091ee6504fa5d2e2e6 (patch) | |
tree | 70e5218f2506d14b681238d3d20cdcf3e69605cb /gcc/rust/ast | |
parent | 61e95a9bf6d4e8cc4de7b2d2b4c1ac989fa76836 (diff) | |
parent | 8e22742c9ad844d5e6dd348f6f7d8fa2ef064de4 (diff) | |
download | gcc-44f2de02d478b5d3defa5f091ee6504fa5d2e2e6.zip gcc-44f2de02d478b5d3defa5f091ee6504fa5d2e2e6.tar.gz gcc-44f2de02d478b5d3defa5f091ee6504fa5d2e2e6.tar.bz2 |
Merge #1312
1312: Refactor generic parameter parsing and report order errors r=CohenArthur a=CohenArthur
Closes #1311
This allows us to parse lifetimes and types (and later const generics)
in any order without necessarily erroring out for the wrong reason. It also simplifies the
code greatly and makes it easier to modify.
This also removes an unused duplicate `parse_generic_params` function
Co-authored-by: Arthur Cohen <arthur.cohen@embecosm.com>
Diffstat (limited to 'gcc/rust/ast')
-rw-r--r-- | gcc/rust/ast/rust-ast.h | 11 | ||||
-rw-r--r-- | gcc/rust/ast/rust-item.h | 2 |
2 files changed, 13 insertions, 0 deletions
diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h index 8f5657f..2d7d31a 100644 --- a/gcc/rust/ast/rust-ast.h +++ b/gcc/rust/ast/rust-ast.h @@ -1255,6 +1255,13 @@ protected: class GenericParam { public: + enum class Kind + { + Lifetime, + Type, + Const, + }; + virtual ~GenericParam () {} // Unique pointer custom clone function @@ -1269,6 +1276,8 @@ public: virtual Location get_locus () const = 0; + virtual Kind get_kind () const = 0; + NodeId get_node_id () { return node_id; } protected: @@ -1322,6 +1331,8 @@ public: Location get_locus () const override final { return locus; } + Kind get_kind () const override final { return Kind::Lifetime; } + protected: /* Use covariance to implement clone function as returning this object rather * than base */ diff --git a/gcc/rust/ast/rust-item.h b/gcc/rust/ast/rust-item.h index 6d953fb..94ffffb 100644 --- a/gcc/rust/ast/rust-item.h +++ b/gcc/rust/ast/rust-item.h @@ -132,6 +132,8 @@ public: Location get_locus () const override final { return locus; } + Kind get_kind () const override final { return Kind::Type; } + void accept_vis (ASTVisitor &vis) override; // TODO: is this better? Or is a "vis_block" better? |