diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-02-17 16:27:58 +0100 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-02-18 09:10:52 +0100 |
commit | 425ebda24393eb4f40190228b7ef4b69e6253251 (patch) | |
tree | 89c1f6d2a8d74a8392f410c901c5385f5b6bdda0 /gcc | |
parent | ef06769781a76eaa0de6fb500bebb8473e549f7e (diff) | |
download | gcc-425ebda24393eb4f40190228b7ef4b69e6253251.zip gcc-425ebda24393eb4f40190228b7ef4b69e6253251.tar.gz gcc-425ebda24393eb4f40190228b7ef4b69e6253251.tar.bz2 |
type-path-fn: Add location info on start of Fn token
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/ast/rust-path.h | 15 | ||||
-rw-r--r-- | gcc/rust/parse/rust-parse-impl.h | 8 | ||||
-rw-r--r-- | gcc/rust/parse/rust-parse.h | 2 |
3 files changed, 16 insertions, 9 deletions
diff --git a/gcc/rust/ast/rust-path.h b/gcc/rust/ast/rust-path.h index cff3b09..ed37f40 100644 --- a/gcc/rust/ast/rust-path.h +++ b/gcc/rust/ast/rust-path.h @@ -541,11 +541,13 @@ private: // FIXME: think of better way to mark as invalid than taking up storage bool is_invalid; - // TODO: should this have location info? + Location locus; protected: // Constructor only used to create invalid type path functions. - TypePathFunction (bool is_invalid) : is_invalid (is_invalid) {} + TypePathFunction (bool is_invalid, Location locus) + : is_invalid (is_invalid), locus (locus) + {} public: // Returns whether the return type of the function has been specified. @@ -558,13 +560,16 @@ public: bool is_error () const { return is_invalid; } // Creates an error state function. - static TypePathFunction create_error () { return TypePathFunction (true); } + static TypePathFunction create_error () + { + return TypePathFunction (true, Location ()); + } // Constructor - TypePathFunction (std::vector<std::unique_ptr<Type> > inputs, + TypePathFunction (std::vector<std::unique_ptr<Type> > inputs, Location locus, std::unique_ptr<Type> type = nullptr) : inputs (std::move (inputs)), return_type (std::move (type)), - is_invalid (false) + is_invalid (false), locus (locus) {} // Copy constructor with clone diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 3ff1229..c35595c 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -6436,7 +6436,8 @@ Parser<ManagedTokenSource>::parse_type_path_segment () } case LEFT_PAREN: { // parse type path function - AST::TypePathFunction type_path_function = parse_type_path_function (); + AST::TypePathFunction type_path_function + = parse_type_path_function (locus); if (type_path_function.is_error ()) { @@ -6462,7 +6463,7 @@ Parser<ManagedTokenSource>::parse_type_path_segment () // Parses a function call representation inside a type path. template <typename ManagedTokenSource> AST::TypePathFunction -Parser<ManagedTokenSource>::parse_type_path_function () +Parser<ManagedTokenSource>::parse_type_path_function (Location id_location) { if (!skip_token (LEFT_PAREN)) { @@ -6508,7 +6509,8 @@ Parser<ManagedTokenSource>::parse_type_path_function () std::unique_ptr<AST::Type> return_type = parse_function_return_type (); inputs.shrink_to_fit (); - return AST::TypePathFunction (std::move (inputs), std::move (return_type)); + return AST::TypePathFunction (std::move (inputs), id_location, + std::move (return_type)); } // Parses a path inside an expression that allows generic arguments. diff --git a/gcc/rust/parse/rust-parse.h b/gcc/rust/parse/rust-parse.h index 5ee7b4e..17440d5 100644 --- a/gcc/rust/parse/rust-parse.h +++ b/gcc/rust/parse/rust-parse.h @@ -139,7 +139,7 @@ private: AST::PathIdentSegment parse_path_ident_segment (); AST::GenericArgs parse_path_generic_args (); AST::GenericArgsBinding parse_generic_args_binding (); - AST::TypePathFunction parse_type_path_function (); + AST::TypePathFunction parse_type_path_function (Location locus); AST::PathExprSegment parse_path_expr_segment (); AST::QualifiedPathInExpression // When given a pratt_parsed_loc, use it as the location of the |