diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-01-21 22:24:23 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-21 22:24:23 +0000 |
commit | 6c9e57efa5474cfe5d0440e1022ee3c4a8400199 (patch) | |
tree | 9336a5c60138f53b3d83c4e8064ab4f5897d7c13 /gcc/rust/ast | |
parent | 8c96ccceb27e96246ff474800c3d7350445bd6e9 (diff) | |
parent | e77f051369efce4207c965ab2b69c5d9867c5846 (diff) | |
download | gcc-6c9e57efa5474cfe5d0440e1022ee3c4a8400199.zip gcc-6c9e57efa5474cfe5d0440e1022ee3c4a8400199.tar.gz gcc-6c9e57efa5474cfe5d0440e1022ee3c4a8400199.tar.bz2 |
Merge #883
883: Extract AsyncConstStatus to be a shared enum between AST and HIR r=philberty a=philberty
This allows us to reuse the same enum and fix the uninitilized warning
as it has already been setup before hand in the AST.
Fixes #875
Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Diffstat (limited to 'gcc/rust/ast')
-rw-r--r-- | gcc/rust/ast/rust-ast-full-test.cc | 4 | ||||
-rw-r--r-- | gcc/rust/ast/rust-item.h | 59 | ||||
-rw-r--r-- | gcc/rust/ast/rust-type.h | 2 |
3 files changed, 17 insertions, 48 deletions
diff --git a/gcc/rust/ast/rust-ast-full-test.cc b/gcc/rust/ast/rust-ast-full-test.cc index 8780853..91bd6a5 100644 --- a/gcc/rust/ast/rust-ast-full-test.cc +++ b/gcc/rust/ast/rust-ast-full-test.cc @@ -2288,10 +2288,10 @@ FunctionQualifiers::as_string () const case NONE: // do nothing break; - case CONST: + case CONST_FN: str += "const "; break; - case ASYNC: + case ASYNC_FN: str += "async "; break; default: diff --git a/gcc/rust/ast/rust-item.h b/gcc/rust/ast/rust-item.h index ad503cf..1829358 100644 --- a/gcc/rust/ast/rust-item.h +++ b/gcc/rust/ast/rust-item.h @@ -21,6 +21,7 @@ #include "rust-ast.h" #include "rust-path.h" +#include "rust-common.h" namespace Rust { namespace AST { @@ -487,12 +488,6 @@ struct FunctionQualifiers public: /* Whether the function is neither const nor async, const only, or async * only. */ - enum AsyncConstStatus - { - NONE, - CONST, - ASYNC - }; private: AsyncConstStatus const_status; @@ -705,34 +700,17 @@ protected: // A method (function belonging to a type) class Method : public InherentImplItem, public TraitImplItem { - // moved from impl items for consistency std::vector<Attribute> outer_attrs; Visibility vis; - FunctionQualifiers qualifiers; Identifier method_name; - - // bool has_generics; - // Generics generic_params; - std::vector<std::unique_ptr<GenericParam>> generic_params; // inlined - + std::vector<std::unique_ptr<GenericParam>> generic_params; SelfParam self_param; - - // bool has_params; - // FunctionParams function_params; - std::vector<FunctionParam> function_params; // inlined - - // bool has_return_type; - // FunctionReturnType return_type; - std::unique_ptr<Type> return_type; // inlined - - // bool has_where_clause; + std::vector<FunctionParam> function_params; + std::unique_ptr<Type> return_type; WhereClause where_clause; - std::unique_ptr<BlockExpr> function_body; - Location locus; - NodeId node_id; public: @@ -746,7 +724,7 @@ public: // Creates an error state method. static Method create_error () { - return Method ("", FunctionQualifiers (FunctionQualifiers::NONE, true), + return Method ("", FunctionQualifiers (NONE, true), std::vector<std::unique_ptr<GenericParam>> (), SelfParam::create_error (), std::vector<FunctionParam> (), nullptr, WhereClause::create_empty (), nullptr, @@ -904,6 +882,8 @@ public: Location get_locus () const override final { return locus; } + FunctionQualifiers get_qualifiers () { return qualifiers; } + protected: /* Use covariance to implement clone function as returning this object * rather than base */ @@ -1439,11 +1419,6 @@ protected: } }; -// Parameters used in a function - TODO inline? -/*struct FunctionParams { - std::vector<FunctionParam> function_params; -};*/ - class LetStmt; // Rust function declaration AST node @@ -1451,23 +1426,11 @@ class Function : public VisItem, public InherentImplItem, public TraitImplItem { FunctionQualifiers qualifiers; Identifier function_name; - - // bool has_generics; - // Generics generic_params; - std::vector<std::unique_ptr<GenericParam>> generic_params; // inlined - - // bool has_function_params; - // FunctionParams function_params; - std::vector<FunctionParam> function_params; // inlined - - // bool has_function_return_type; + std::vector<std::unique_ptr<GenericParam>> generic_params; + std::vector<FunctionParam> function_params; std::unique_ptr<Type> return_type; - - // bool has_where_clause; WhereClause where_clause; - std::unique_ptr<BlockExpr> function_body; - Location locus; public: @@ -2841,6 +2804,8 @@ public: // TODO: is this better? Or is a "vis_block" better? WhereClause &get_where_clause () { return where_clause; } + + FunctionQualifiers get_qualifiers () { return qualifiers; } }; // Actual trait item function declaration within traits @@ -3067,6 +3032,8 @@ public: SelfParam &get_self_param () { return self_param; } const SelfParam &get_self_param () const { return self_param; } + + FunctionQualifiers get_qualifiers () { return qualifiers; } }; // Actual trait item method declaration within traits diff --git a/gcc/rust/ast/rust-type.h b/gcc/rust/ast/rust-type.h index 2414b60..9f7fb54 100644 --- a/gcc/rust/ast/rust-type.h +++ b/gcc/rust/ast/rust-type.h @@ -928,6 +928,8 @@ public: return return_type; } + FunctionQualifiers get_function_qualifiers () { return function_qualifiers; } + protected: /* Use covariance to implement clone function as returning this object rather * than base */ |