From 205a9cbf9e2c2940e6715fa69be89765af582d29 Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Thu, 17 Feb 2022 15:03:28 +0100 Subject: fn-arg: Add location on parameter name --- gcc/rust/parse/rust-parse-impl.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (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 784e6d1..3d1f58b 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -5993,6 +5993,7 @@ Parser::parse_named_function_param ( std::string name; const_TokenPtr t = lexer.peek_token (); + Location name_location = t->get_locus (); switch (t->get_id ()) { case IDENTIFIER: @@ -6028,7 +6029,7 @@ Parser::parse_named_function_param ( } return AST::NamedFunctionParam (std::move (name), std::move (param_type), - std::move (outer_attrs)); + std::move (outer_attrs), name_location); } // Parses a statement (will further disambiguate any statement). -- cgit v1.1 From c6daece64782fd5f03f573b4633d1826794a9f8a Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Thu, 17 Feb 2022 15:27:52 +0100 Subject: array-values: Add location info --- gcc/rust/parse/rust-parse-impl.h | 6 +++--- 1 file changed, 3 insertions(+), 3 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 3d1f58b..c4a5080 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -8739,7 +8739,7 @@ Parser::parse_array_expr (AST::AttrVec outer_attrs, std::vector> exprs; auto array_elems - = Rust::make_unique (std::move (exprs)); + = Rust::make_unique (std::move (exprs), locus); return Rust::make_unique (std::move (array_elems), std::move (inner_attrs), std::move (outer_attrs), locus); @@ -8799,7 +8799,7 @@ Parser::parse_array_expr (AST::AttrVec outer_attrs, skip_token (RIGHT_SQUARE); std::unique_ptr array_elems ( - new AST::ArrayElemsValues (std::move (exprs))); + new AST::ArrayElemsValues (std::move (exprs), locus)); return std::unique_ptr ( new AST::ArrayExpr (std::move (array_elems), std::move (inner_attrs), @@ -8841,7 +8841,7 @@ Parser::parse_array_expr (AST::AttrVec outer_attrs, exprs.shrink_to_fit (); std::unique_ptr array_elems ( - new AST::ArrayElemsValues (std::move (exprs))); + new AST::ArrayElemsValues (std::move (exprs), locus)); return std::unique_ptr ( new AST::ArrayExpr (std::move (array_elems), std::move (inner_attrs), -- cgit v1.1 From d120c9db1811752e543ef8c231c1501a63dfcea2 Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Thu, 17 Feb 2022 15:36:21 +0100 Subject: array-copy-init: Add location info --- gcc/rust/parse/rust-parse-impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (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 c4a5080..8703ecb 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -8782,7 +8782,7 @@ Parser::parse_array_expr (AST::AttrVec outer_attrs, std::unique_ptr copied_array_elems ( new AST::ArrayElemsCopied (std::move (initial_expr), - std::move (copy_amount))); + std::move (copy_amount), locus)); return std::unique_ptr ( new AST::ArrayExpr (std::move (copied_array_elems), std::move (inner_attrs), -- cgit v1.1 From 63538444fbce73fff2948e3357939b520f59afb8 Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Thu, 17 Feb 2022 15:41:28 +0100 Subject: struct-base: Add location info on `..` token --- gcc/rust/parse/rust-parse-impl.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (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 8703ecb..445acad 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -14441,6 +14441,7 @@ Parser::parse_struct_expr_struct_partial ( AST::StructBase struct_base = AST::StructBase::error (); if (lexer.peek_token ()->get_id () == DOT_DOT) { + Location dot_dot_location = lexer.peek_token ()->get_locus (); lexer.skip_token (); // parse required struct base expr @@ -14458,7 +14459,8 @@ Parser::parse_struct_expr_struct_partial ( // DEBUG: rust_debug ("struct/enum expr - parsed and validated base expr"); - struct_base = AST::StructBase (std::move (base_expr)); + struct_base + = AST::StructBase (std::move (base_expr), dot_dot_location); // DEBUG: rust_debug ("assigned struct base to new struct base "); -- cgit v1.1 From 9e524a7f5a5a7abd7aaf3891ea4eca6f0f84fd36 Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Thu, 17 Feb 2022 15:48:46 +0100 Subject: closure-arg: Add location info on arg name --- gcc/rust/parse/rust-parse-impl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 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 445acad..6498f3c 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -8895,8 +8895,8 @@ Parser::parse_closure_param () } } - return AST::ClosureParam (std::move (pattern), std::move (type), - std::move (outer_attrs)); + return AST::ClosureParam (std::move (pattern), pattern->get_locus (), + std::move (type), std::move (outer_attrs)); } // Parses a grouped or tuple expression (disambiguates). -- cgit v1.1 From ef06769781a76eaa0de6fb500bebb8473e549f7e Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Thu, 17 Feb 2022 16:14:01 +0100 Subject: path-id: Add location info on path identifier --- gcc/rust/parse/rust-parse-impl.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 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 6498f3c..3ff1229 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -706,29 +706,29 @@ Parser::parse_path_ident_segment () case IDENTIFIER: lexer.skip_token (); - return AST::PathIdentSegment (t->get_str ()); + return AST::PathIdentSegment (t->get_str (), t->get_locus ()); case SUPER: lexer.skip_token (); - return AST::PathIdentSegment ("super"); + return AST::PathIdentSegment ("super", t->get_locus ()); case SELF: lexer.skip_token (); - return AST::PathIdentSegment ("self"); + return AST::PathIdentSegment ("self", t->get_locus ()); case SELF_ALIAS: lexer.skip_token (); - return AST::PathIdentSegment ("Self"); + return AST::PathIdentSegment ("Self", t->get_locus ()); case CRATE: lexer.skip_token (); - return AST::PathIdentSegment ("crate"); + return AST::PathIdentSegment ("crate", t->get_locus ()); case DOLLAR_SIGN: if (lexer.peek_token (1)->get_id () == CRATE) { lexer.skip_token (1); - return AST::PathIdentSegment ("$crate"); + return AST::PathIdentSegment ("$crate", t->get_locus ()); } gcc_fallthrough (); default: @@ -14613,8 +14613,10 @@ Parser::parse_path_in_expression_pratt (const_TokenPtr tok) AST::GenericArgs generic_args = parse_path_generic_args (); - initial_segment = AST::PathExprSegment (initial_str, tok->get_locus (), - std::move (generic_args)); + initial_segment + = AST::PathExprSegment (AST::PathIdentSegment (initial_str, + tok->get_locus ()), + tok->get_locus (), std::move (generic_args)); } if (initial_segment.is_error ()) { -- cgit v1.1 From 425ebda24393eb4f40190228b7ef4b69e6253251 Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Thu, 17 Feb 2022 16:27:58 +0100 Subject: type-path-fn: Add location info on start of Fn token --- gcc/rust/parse/rust-parse-impl.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 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 3ff1229..c35595c 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -6436,7 +6436,8 @@ Parser::parse_type_path_segment () } case LEFT_PAREN: { // parse type path function - AST::TypePathFunction type_path_function = parse_type_path_function (); + AST::TypePathFunction type_path_function + = parse_type_path_function (locus); if (type_path_function.is_error ()) { @@ -6462,7 +6463,7 @@ Parser::parse_type_path_segment () // Parses a function call representation inside a type path. template AST::TypePathFunction -Parser::parse_type_path_function () +Parser::parse_type_path_function (Location id_location) { if (!skip_token (LEFT_PAREN)) { @@ -6508,7 +6509,8 @@ Parser::parse_type_path_function () std::unique_ptr return_type = parse_function_return_type (); inputs.shrink_to_fit (); - return AST::TypePathFunction (std::move (inputs), std::move (return_type)); + return AST::TypePathFunction (std::move (inputs), id_location, + std::move (return_type)); } // Parses a path inside an expression that allows generic arguments. -- cgit v1.1 From 0e15b89839170cb6c9115cfc57310af2170423a0 Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Thu, 17 Feb 2022 16:36:34 +0100 Subject: struct pattern: Add location on struct name --- gcc/rust/parse/rust-parse-impl.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 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 c35595c..2260a95 100644 --- a/gcc/rust/parse/rust-parse-impl.h +++ b/gcc/rust/parse/rust-parse-impl.h @@ -10603,7 +10603,8 @@ Parser::parse_pattern () } return std::unique_ptr ( - new AST::StructPattern (std::move (path), std::move (elems))); + new AST::StructPattern (std::move (path), t->get_locus (), + std::move (elems))); } default: // assume path in expression @@ -11057,7 +11058,8 @@ Parser::parse_ident_leading_pattern () rust_debug ("successfully parsed struct pattern"); return std::unique_ptr ( - new AST::StructPattern (std::move (path), std::move (elems))); + new AST::StructPattern (std::move (path), initial_tok->get_locus (), + std::move (elems))); } case DOT_DOT_EQ: case ELLIPSIS: { -- cgit v1.1