From 46e8bf357ccd9bb0cf45b1f2f104fb1b72798a1a Mon Sep 17 00:00:00 2001 From: Philip Herron Date: Fri, 27 Aug 2021 18:17:30 +0100 Subject: Qualified paths have a mandatory initial segment Qualified path in type's initial segment is mandatory (+) any other segments are optional after the fact. see https://doc.rust-lang.org/reference/paths.html#qualified-paths This change makes the AST have a mandatory field for the initial segment the segment list now only contains the optional remaining segments. --- gcc/rust/parse/rust-parse-impl.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'gcc/rust/parse/rust-parse-impl.h') diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h index 8ee9e42..1c0644d 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -6742,10 +6742,6 @@ Parser::parse_qualified_path_in_type () return AST::QualifiedPathInType::create_error (); } - // parse path segments - std::vector> segments; - segments.reserve (1); - // parse initial required segment if (!expect_token (SCOPE_RESOLUTION)) { @@ -6765,9 +6761,9 @@ Parser::parse_qualified_path_in_type () return AST::QualifiedPathInType::create_error (); } - segments.push_back (std::move (initial_segment)); // parse optional segments (as long as scope resolution operator exists) + std::vector> segments; const_TokenPtr t = lexer.peek_token (); while (t->get_id () == SCOPE_RESOLUTION) { @@ -6796,6 +6792,7 @@ Parser::parse_qualified_path_in_type () segments.shrink_to_fit (); return AST::QualifiedPathInType (std::move (qual_path_type), + std::move (initial_segment), std::move (segments), locus); } -- cgit v1.1