diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 42e00442884..6cb8f0e6579 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -1855,15 +1855,7 @@ Parser::parse_macro_invocation_semi ( std::unique_ptr tree = parse_token_tree (); if (tree == nullptr) - { - Error error (t->get_locus (), - "failed to parse token tree for macro invocation semi " - "- found %qs", - t->get_token_description ()); - add_error (std::move (error)); - - return nullptr; - } + return nullptr; token_trees.push_back (std::move (tree)); @@ -2999,8 +2991,9 @@ Parser::parse_function (AST::Visibility vis, else { std::unique_ptr block_expr = parse_block_expr (); - if (block_expr != nullptr) - body = std::move (block_expr); + if (block_expr == nullptr) + return nullptr; + body = std::move (block_expr); } return std::unique_ptr ( @@ -6226,10 +6219,6 @@ Parser::parse_let_stmt (AST::AttrVec outer_attrs, expr = parse_expr (); if (expr == nullptr) { - Error error (lexer.peek_token ()->get_locus (), - "failed to parse expression in let statement"); - add_error (std::move (error)); - skip_after_semicolon (); return nullptr; } @@ -7256,11 +7245,7 @@ Parser::parse_block_expr ( ExprOrStmt expr_or_stmt = parse_stmt_or_expr (); if (expr_or_stmt.is_error ()) { - Error error ( - t->get_locus (), - "failed to parse statement or expression in block expression"); - add_error (std::move (error)); - + skip_after_end_block (); return nullptr; } @@ -7783,14 +7768,7 @@ Parser::parse_if_expr (AST::AttrVec outer_attrs, // parse required block expr std::unique_ptr if_body = parse_block_expr (); if (if_body == nullptr) - { - Error error (lexer.peek_token ()->get_locus (), - "failed to parse if body block expression in if expression"); - add_error (std::move (error)); - - // skip somewhere? - return nullptr; - } + return nullptr; // branch to parse end or else (and then else, else if, or else if let) if (lexer.peek_token ()->get_id () != ELSE) @@ -8113,13 +8091,7 @@ Parser::parse_loop_expr (AST::AttrVec outer_attrs, // parse loop body, which is required std::unique_ptr loop_body = parse_block_expr (); if (loop_body == nullptr) - { - Error error (lexer.peek_token ()->get_locus (), - "could not parse loop body in (infinite) loop expression"); - add_error (std::move (error)); - - return nullptr; - } + return nullptr; return std::unique_ptr ( new AST::LoopExpr (std::move (loop_body), locus, std::move (label), @@ -12198,6 +12170,8 @@ Parser::parse_expr (int right_binding_power, // parse null denotation (unary part of expression) std::unique_ptr expr = null_denotation ({}, null_denotation_restrictions); + if (expr == nullptr) + return nullptr; return left_denotations (std::move (expr), right_binding_power, std::move (outer_attrs), restrictions); diff --git a/gcc/testsuite/rust/compile/braced_macro_arm.rs b/gcc/testsuite/rust/compile/braced_macro_arm.rs index 9bcd1a69c9f..8782cf9f94f 100644 --- a/gcc/testsuite/rust/compile/braced_macro_arm.rs +++ b/gcc/testsuite/rust/compile/braced_macro_arm.rs @@ -7,11 +7,9 @@ macro_rules! m { fn h(c: bool) { match c { - // { dg-error "failed to parse statement or expression in block expression" "" { target *-*-* } .-1 } true => m! {} false => () // { dg-error "exprwithoutblock requires comma after match case expression in match arm \\(if not final case\\)" "" { target *-*-* } .-1 } - // { dg-error "unrecognised token .false. for start of item" "" { target *-*-* } .-2 } }; } diff --git a/gcc/testsuite/rust/compile/issue-407-2.rs b/gcc/testsuite/rust/compile/issue-407-2.rs index 002d998a95e..6dad8612f21 100644 --- a/gcc/testsuite/rust/compile/issue-407-2.rs +++ b/gcc/testsuite/rust/compile/issue-407-2.rs @@ -2,14 +2,8 @@ pub fn loopy() { let mut a = 1; loop { - // { dg-error {failed to parse statement or expression in block expression} "" { target *-*-* } .-1 } if a < 40 { - // { dg-error {failed to parse statement or expression in block expression} "" { target *-*-* } .-1 } a + = 1; // { dg-error "found unexpected token '=' in null denotation" } - // { dg-error {failed to parse statement or expression in block expression} "" { target *-*-* } .-1 } - // { dg-error {failed to parse if body block expression in if expression} "" { target *-*-* } .-2 } - // { dg-error {could not parse loop body in \(infinite\) loop expression} "" { target *-*-* } .-3 } - // { dg-error {unrecognised token 'integer literal' for start of item} "" { target *-*-* } .-4 } } else { break; } diff --git a/gcc/testsuite/rust/compile/issue-407.rs b/gcc/testsuite/rust/compile/issue-407.rs index 9188c2c6b07..3a9dbeba900 100644 --- a/gcc/testsuite/rust/compile/issue-407.rs +++ b/gcc/testsuite/rust/compile/issue-407.rs @@ -2,6 +2,4 @@ fn test() { let mut a = 1; a + = 1; // { dg-error "found unexpected token '=' in null denotation" } - // { dg-error {failed to parse statement or expression in block expression} "" { target *-*-* } .-1 } - // { dg-error {unrecognised token 'integer literal' for start of item} "" { target *-*-* } .-2 } } diff --git a/gcc/testsuite/rust/compile/issue-4162.rs b/gcc/testsuite/rust/compile/issue-4162.rs index 7caf8870c05..ffaa92d9761 100644 --- a/gcc/testsuite/rust/compile/issue-4162.rs +++ b/gcc/testsuite/rust/compile/issue-4162.rs @@ -1,8 +1,6 @@ pub fn main() { while let = 5 // { dg-error "should be at least 1 pattern" "" { target *-*-* } .-1 } - // { dg-error "failed to parse statement or expression in block expression" "" { target *-*-* } .-2 } - // { dg-error "unrecognised token .=. for start of item" "" { target *-*-* } .-3 } {} } diff --git a/gcc/testsuite/rust/compile/issue-867.rs b/gcc/testsuite/rust/compile/issue-867.rs index c61de09d8ab..1aa29b3ed10 100644 --- a/gcc/testsuite/rust/compile/issue-867.rs +++ b/gcc/testsuite/rust/compile/issue-867.rs @@ -1,7 +1,4 @@ fn main() { let _ = 42; let a = _ + 123; // { dg-error "use of '_' is not allowed on the right-side of an assignment" } - // { dg-error {failed to parse expression in let statement} "" { target *-*-* } .-1 } - // { dg-error {failed to parse statement or expression in block expression} "" { target *-*-* } .-2 } - // { dg-error {unrecognised token '\}' for start of item} "" { target *-*-* } .+1 } } diff --git a/gcc/testsuite/rust/compile/raw_ref_op_invalid.rs b/gcc/testsuite/rust/compile/raw_ref_op_invalid.rs index 90e169f30f6..42ec63d7365 100644 --- a/gcc/testsuite/rust/compile/raw_ref_op_invalid.rs +++ b/gcc/testsuite/rust/compile/raw_ref_op_invalid.rs @@ -7,6 +7,4 @@ pub struct Toto { pub fn test(mut toto: Toto) { let _c = &raw toto.u; //{ dg-error "expecting .;. but .identifier. found" "" { target *-*-* } } - //{ dg-excess-errors "Additional errors for parent items" { target *-*-* } } - }