aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/rust/ast/rust-expr.h9
-rw-r--r--gcc/rust/hir/rust-ast-lower-expr.h2
-rw-r--r--gcc/rust/hir/tree/rust-hir-expr.h8
-rw-r--r--gcc/rust/parse/rust-parse-impl.h5
4 files changed, 12 insertions, 12 deletions
diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h
index 2f46fee..3f3ed5c 100644
--- a/gcc/rust/ast/rust-expr.h
+++ b/gcc/rust/ast/rust-expr.h
@@ -4225,7 +4225,6 @@ private:
// inlined from MatchArmGuard
std::unique_ptr<Expr> guard_expr;
- // TODO: should this store location data?
Location locus;
public:
@@ -4234,9 +4233,8 @@ public:
// Constructor for match arm with a guard expression
MatchArm (std::vector<std::unique_ptr<Pattern> > match_arm_patterns,
- std::unique_ptr<Expr> guard_expr = nullptr,
- std::vector<Attribute> outer_attrs = std::vector<Attribute> (),
- Location locus = Location ())
+ Location locus, std::unique_ptr<Expr> guard_expr = nullptr,
+ std::vector<Attribute> outer_attrs = std::vector<Attribute> ())
: outer_attrs (std::move (outer_attrs)),
match_arm_patterns (std::move (match_arm_patterns)),
guard_expr (std::move (guard_expr)), locus (locus)
@@ -4285,7 +4283,8 @@ public:
// Creates a match arm in an error state.
static MatchArm create_error ()
{
- return MatchArm (std::vector<std::unique_ptr<Pattern> > ());
+ Location locus = Location ();
+ return MatchArm (std::vector<std::unique_ptr<Pattern> > (), locus);
}
std::string as_string () const;
diff --git a/gcc/rust/hir/rust-ast-lower-expr.h b/gcc/rust/hir/rust-ast-lower-expr.h
index 8cd4fb5..1aa21bd 100644
--- a/gcc/rust/hir/rust-ast-lower-expr.h
+++ b/gcc/rust/hir/rust-ast-lower-expr.h
@@ -693,7 +693,7 @@ public:
match_arm_patterns.push_back (std::unique_ptr<HIR::Pattern> (ptrn));
}
- HIR::MatchArm arm (std::move (match_arm_patterns),
+ HIR::MatchArm arm (std::move (match_arm_patterns), expr.get_locus (),
std::unique_ptr<HIR::Expr> (kase_guard_expr),
match_case.get_arm ().get_outer_attrs ());
diff --git a/gcc/rust/hir/tree/rust-hir-expr.h b/gcc/rust/hir/tree/rust-hir-expr.h
index 89b9f64..3267d01 100644
--- a/gcc/rust/hir/tree/rust-hir-expr.h
+++ b/gcc/rust/hir/tree/rust-hir-expr.h
@@ -3721,9 +3721,8 @@ public:
// Constructor for match arm with a guard expression
MatchArm (std::vector<std::unique_ptr<Pattern> > match_arm_patterns,
- std::unique_ptr<Expr> guard_expr = nullptr,
- AST::AttrVec outer_attrs = AST::AttrVec (),
- Location locus = Location ())
+ Location locus, std::unique_ptr<Expr> guard_expr = nullptr,
+ AST::AttrVec outer_attrs = AST::AttrVec ())
: outer_attrs (std::move (outer_attrs)),
match_arm_patterns (std::move (match_arm_patterns)),
guard_expr (std::move (guard_expr)), locus (locus)
@@ -3770,7 +3769,8 @@ public:
// Creates a match arm in an error state.
static MatchArm create_error ()
{
- return MatchArm (std::vector<std::unique_ptr<Pattern> > ());
+ Location locus = Location ();
+ return MatchArm (std::vector<std::unique_ptr<Pattern> > (), locus);
}
std::string as_string () const;
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index 0e39e48..6d393b0 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -8560,8 +8560,9 @@ Parser<ManagedTokenSource>::parse_match_arm ()
// DEBUG
rust_debug ("successfully parsed match arm");
- return AST::MatchArm (std::move (match_arm_patterns), std::move (guard_expr),
- std::move (outer_attrs));
+ return AST::MatchArm (std::move (match_arm_patterns),
+ lexer.peek_token ()->get_locus (),
+ std::move (guard_expr), std::move (outer_attrs));
}
/* Parses the patterns used in a match arm. End token id is the id of the token