diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2022-01-15 11:20:18 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-15 11:20:18 +0000 |
commit | b02824c6a798a78657568e7d831bd10529d63e37 (patch) | |
tree | 83fd67a961ce521c6350e9c47bcbe3aa94965751 /gcc/rust/parse/rust-parse-impl.h | |
parent | b21caeb3af4313016afeb94a91956e8fc4c2656d (diff) | |
parent | 7d456b882a8f72b6fb3bdb0e71367811770b4413 (diff) | |
download | gcc-b02824c6a798a78657568e7d831bd10529d63e37.zip gcc-b02824c6a798a78657568e7d831bd10529d63e37.tar.gz gcc-b02824c6a798a78657568e7d831bd10529d63e37.tar.bz2 |
Merge #874
874: Track end locus of BlockExpr r=philberty a=dafaust
Capture the closing locus of a block during parsing, and remove the old
hack to get the final statement locus within the block now that it is
properly tracked.
Fixes #864
Co-authored-by: David Faust <david.faust@oracle.com>
Diffstat (limited to 'gcc/rust/parse/rust-parse-impl.h')
-rw-r--r-- | gcc/rust/parse/rust-parse-impl.h | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index f1d376a..aabb15c 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -7347,6 +7347,8 @@ Parser<ManagedTokenSource>::parse_block_expr (AST::AttrVec outer_attrs, return nullptr; } + t = lexer.peek_token (); + if (expr_or_stmt.stmt != nullptr) { stmts.push_back (std::move (expr_or_stmt.stmt)); @@ -7357,10 +7359,10 @@ Parser<ManagedTokenSource>::parse_block_expr (AST::AttrVec outer_attrs, expr = std::move (expr_or_stmt.expr); break; } - - t = lexer.peek_token (); } + Location end_locus = t->get_locus (); + if (!skip_token (RIGHT_CURLY)) { Error error (t->get_locus (), @@ -7378,8 +7380,8 @@ Parser<ManagedTokenSource>::parse_block_expr (AST::AttrVec outer_attrs, return std::unique_ptr<AST::BlockExpr> ( new AST::BlockExpr (std::move (stmts), std::move (expr), - std::move (inner_attrs), std::move (outer_attrs), - locus)); + std::move (inner_attrs), std::move (outer_attrs), locus, + end_locus)); } /* Parses a "grouped" expression (expression in parentheses), used to control |