public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] type-path-fn: Add location info on start of Fn token
@ 2022-06-08 12:08 Thomas Schwinge
0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-08 12:08 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:425ebda24393eb4f40190228b7ef4b69e6253251
commit 425ebda24393eb4f40190228b7ef4b69e6253251
Author: Arthur Cohen <arthur.cohen@embecosm.com>
Date: Thu Feb 17 16:27:58 2022 +0100
type-path-fn: Add location info on start of Fn token
Diff:
---
gcc/rust/ast/rust-path.h | 15 ++++++++++-----
gcc/rust/parse/rust-parse-impl.h | 8 +++++---
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 cff3b09d994..ed37f400dc5 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 3ff122977fd..c35595c29d7 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 5ee7b4e6c85..17440d50f28 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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-08 12:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 12:08 [gcc/devel/rust/master] type-path-fn: Add location info on start of Fn token Thomas Schwinge
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).