mirror of
https://gcc.gnu.org/git/gcc.git
synced 2026-02-22 20:01:22 -05:00
gccrs: parser: Parse RangeFullExpr without erroring out
gcc/rust/ChangeLog: * parse/rust-parse-impl.h: Allow parsing full range expressions without erroring out. gcc/testsuite/ChangeLog: * rust/compile/parse_range.rs: New test.
This commit is contained in:
@@ -14112,9 +14112,13 @@ std::unique_ptr<AST::RangeExpr>
|
||||
Parser<ManagedTokenSource>::parse_nud_range_exclusive_expr (
|
||||
const_TokenPtr tok, AST::AttrVec outer_attrs ATTRIBUTE_UNUSED)
|
||||
{
|
||||
auto restrictions = ParseRestrictions ();
|
||||
restrictions.expr_can_be_null = true;
|
||||
|
||||
// FIXME: this probably parses expressions accidently or whatever
|
||||
// try parsing RHS (as tok has already been consumed in parse_expression)
|
||||
std::unique_ptr<AST::Expr> right = parse_expr (LBP_DOT_DOT, AST::AttrVec ());
|
||||
std::unique_ptr<AST::Expr> right
|
||||
= parse_expr (LBP_DOT_DOT, AST::AttrVec (), restrictions);
|
||||
|
||||
Location locus = tok->get_locus ();
|
||||
|
||||
|
||||
9
gcc/testsuite/rust/compile/parse_range.rs
Normal file
9
gcc/testsuite/rust/compile/parse_range.rs
Normal file
@@ -0,0 +1,9 @@
|
||||
// { dg-additional-options "-fsyntax-only" }
|
||||
|
||||
fn main() {
|
||||
let a = [1, 2, 3, 4];
|
||||
let _ = a[0..];
|
||||
let _ = a[..3];
|
||||
let _ = a[0..3];
|
||||
let _ = a[..];
|
||||
}
|
||||
Reference in New Issue
Block a user