aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust
diff options
context:
space:
mode:
authorArthur Cohen <arthur.cohen@embecosm.com>2022-02-17 15:48:46 +0100
committerArthur Cohen <arthur.cohen@embecosm.com>2022-02-18 09:08:07 +0100
commit9e524a7f5a5a7abd7aaf3891ea4eca6f0f84fd36 (patch)
tree2750acaf6188d124a3f4364022e1b587e2dd07bd /gcc/rust
parent63538444fbce73fff2948e3357939b520f59afb8 (diff)
downloadgcc-9e524a7f5a5a7abd7aaf3891ea4eca6f0f84fd36.zip
gcc-9e524a7f5a5a7abd7aaf3891ea4eca6f0f84fd36.tar.gz
gcc-9e524a7f5a5a7abd7aaf3891ea4eca6f0f84fd36.tar.bz2
closure-arg: Add location info on arg name
Diffstat (limited to 'gcc/rust')
-rw-r--r--gcc/rust/ast/rust-expr.h13
-rw-r--r--gcc/rust/parse/rust-parse-impl.h4
2 files changed, 10 insertions, 7 deletions
diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h
index 7994aed..7336db2 100644
--- a/gcc/rust/ast/rust-expr.h
+++ b/gcc/rust/ast/rust-expr.h
@@ -2134,8 +2134,7 @@ private:
// bool has_type_given;
std::unique_ptr<Type> type;
-
- // TODO: should this store location data?
+ Location locus;
public:
// Returns whether the type of the parameter has been given.
@@ -2144,11 +2143,12 @@ public:
bool has_outer_attrs () const { return !outer_attrs.empty (); }
// Constructor for closure parameter
- ClosureParam (std::unique_ptr<Pattern> param_pattern,
+ ClosureParam (std::unique_ptr<Pattern> param_pattern, Location locus,
std::unique_ptr<Type> param_type = nullptr,
std::vector<Attribute> outer_attrs = {})
: outer_attrs (std::move (outer_attrs)),
- pattern (std::move (param_pattern)), type (std::move (param_type))
+ pattern (std::move (param_pattern)), type (std::move (param_type)),
+ locus (locus)
{}
// Copy constructor required due to cloning as a result of unique_ptrs
@@ -2189,7 +2189,10 @@ public:
bool is_error () const { return pattern == nullptr; }
// Creates an error state closure parameter.
- static ClosureParam create_error () { return ClosureParam (nullptr); }
+ static ClosureParam create_error ()
+ {
+ return ClosureParam (nullptr, Location ());
+ }
std::string as_string () const;
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index 445acad..6498f3c 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -8895,8 +8895,8 @@ Parser<ManagedTokenSource>::parse_closure_param ()
}
}
- return AST::ClosureParam (std::move (pattern), std::move (type),
- std::move (outer_attrs));
+ return AST::ClosureParam (std::move (pattern), pattern->get_locus (),
+ std::move (type), std::move (outer_attrs));
}
// Parses a grouped or tuple expression (disambiguates).