diff --git a/gcc/rust/ast/rust-path.h b/gcc/rust/ast/rust-path.h index 2df1506923d7..1bbac6883e1c 100644 --- a/gcc/rust/ast/rust-path.h +++ b/gcc/rust/ast/rust-path.h @@ -727,9 +727,9 @@ class PathInExpression : public Pattern, public ExprWithoutBlock } // Creates an error state path in expression. - static PathInExpression create_error () + static PathInExpression create_error (location_t locus = UNDEF_LOCATION) { - return PathInExpression ({}, {}, UNDEF_LOCATION); + return PathInExpression ({}, {}, locus); } // Returns whether path in expression is in an error state. diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index aff81448deae..0fd29cbf3247 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -6713,9 +6713,8 @@ Parser::parse_path_in_expression () AST::PathExprSegment initial_segment = parse_path_expr_segment (); if (initial_segment.is_error ()) { - // skip after somewhere? - // don't necessarily throw error but yeah - return AST::PathInExpression::create_error (); + rust_error_at (locus, "expected identifier"); + return AST::PathInExpression::create_error (locus); } segments.push_back (std::move (initial_segment)); @@ -10444,7 +10443,7 @@ Parser::parse_pattern () { lexer.skip_token (); alts.push_back (parse_pattern_no_alt ()); - } + } while (lexer.peek_token ()->get_id () == PIPE); diff --git a/gcc/testsuite/rust/compile/paamayim-nekudotayim.rs b/gcc/testsuite/rust/compile/paamayim-nekudotayim.rs new file mode 100644 index 000000000000..59f80feb6452 --- /dev/null +++ b/gcc/testsuite/rust/compile/paamayim-nekudotayim.rs @@ -0,0 +1,5 @@ +// http://phpsadness.com/sad/1 +fn main() { + ::; + // { dg-error "expected identifier" "" { target *-*-* } .-1 } +}