[gcc r14-7825] gccrs: Replace Location with location_t in parsing and macro expansion

Arthur Cohen cohenarthur@gcc.gnu.org
Tue Jan 16 18:01:47 GMT 2024


https://gcc.gnu.org/g:80c68893f446bf883c67dd78c317b5c0f0f55f4f

commit r14-7825-g80c68893f446bf883c67dd78c317b5c0f0f55f4f
Author: Owen Avery <powerboat9.gamer@gmail.com>
Date:   Mon Jul 10 16:21:36 2023 -0400

    gccrs: Replace Location with location_t in parsing and macro expansion
    
    gcc/rust/ChangeLog:
    
            * expand/rust-derive-clone.cc: Replace Location with location_t.
            * expand/rust-derive-clone.h: Likewise.
            * expand/rust-derive-copy.cc: Likewise.
            * expand/rust-derive-copy.h: Likewise.
            * expand/rust-derive.cc: Likewise.
            * expand/rust-derive.h: Likewise.
            * expand/rust-macro-builtins.cc: Likewise.
            * expand/rust-macro-builtins.h: Likewise.
            * expand/rust-macro-expand.cc: Likewise.
            * parse/rust-parse-impl.h: Likewise.
            * parse/rust-parse.cc: Likewise.
            * parse/rust-parse.h: Likewise.
    
    Signed-off-by: Owen Avery <powerboat9.gamer@gmail.com>

Diff:
---
 gcc/rust/expand/rust-derive-clone.cc   |  2 +-
 gcc/rust/expand/rust-derive-clone.h    |  2 +-
 gcc/rust/expand/rust-derive-copy.cc    |  3 +-
 gcc/rust/expand/rust-derive-copy.h     |  2 +-
 gcc/rust/expand/rust-derive.cc         |  2 +-
 gcc/rust/expand/rust-derive.h          |  4 +-
 gcc/rust/expand/rust-macro-builtins.cc | 39 ++++++++-------
 gcc/rust/expand/rust-macro-builtins.h  | 33 ++++++-------
 gcc/rust/expand/rust-macro-expand.cc   |  2 +-
 gcc/rust/parse/rust-parse-impl.h       | 86 +++++++++++++++++-----------------
 gcc/rust/parse/rust-parse.cc           |  4 +-
 gcc/rust/parse/rust-parse.h            | 32 ++++++-------
 12 files changed, 108 insertions(+), 103 deletions(-)

diff --git a/gcc/rust/expand/rust-derive-clone.cc b/gcc/rust/expand/rust-derive-clone.cc
index 34886b25146..964602b98b9 100644
--- a/gcc/rust/expand/rust-derive-clone.cc
+++ b/gcc/rust/expand/rust-derive-clone.cc
@@ -87,7 +87,7 @@ DeriveClone::clone_impl (std::unique_ptr<TraitImplItem> &&clone_fn,
 
 // TODO: Create new `make_qualified_call` helper function
 
-DeriveClone::DeriveClone (Location loc)
+DeriveClone::DeriveClone (location_t loc)
   : DeriveVisitor (loc), expanded (nullptr)
 {}
 
diff --git a/gcc/rust/expand/rust-derive-clone.h b/gcc/rust/expand/rust-derive-clone.h
index e1fadc79163..dcb88f9468a 100644
--- a/gcc/rust/expand/rust-derive-clone.h
+++ b/gcc/rust/expand/rust-derive-clone.h
@@ -27,7 +27,7 @@ namespace AST {
 class DeriveClone : DeriveVisitor
 {
 public:
-  DeriveClone (Location loc);
+  DeriveClone (location_t loc);
 
   std::unique_ptr<AST::Item> go (Item &item);
 
diff --git a/gcc/rust/expand/rust-derive-copy.cc b/gcc/rust/expand/rust-derive-copy.cc
index 51a6599ac27..ffac7fd20b2 100644
--- a/gcc/rust/expand/rust-derive-copy.cc
+++ b/gcc/rust/expand/rust-derive-copy.cc
@@ -22,7 +22,8 @@
 namespace Rust {
 namespace AST {
 
-DeriveCopy::DeriveCopy (Location loc) : DeriveVisitor (loc), expanded (nullptr)
+DeriveCopy::DeriveCopy (location_t loc)
+  : DeriveVisitor (loc), expanded (nullptr)
 {}
 
 std::unique_ptr<AST::Item>
diff --git a/gcc/rust/expand/rust-derive-copy.h b/gcc/rust/expand/rust-derive-copy.h
index 0e1e2076066..f02b6716adc 100644
--- a/gcc/rust/expand/rust-derive-copy.h
+++ b/gcc/rust/expand/rust-derive-copy.h
@@ -27,7 +27,7 @@ namespace AST {
 class DeriveCopy : DeriveVisitor
 {
 public:
-  DeriveCopy (Location loc);
+  DeriveCopy (location_t loc);
 
   std::unique_ptr<Item> go (Item &);
 
diff --git a/gcc/rust/expand/rust-derive.cc b/gcc/rust/expand/rust-derive.cc
index 1a7413b359b..7b8f404b1db 100644
--- a/gcc/rust/expand/rust-derive.cc
+++ b/gcc/rust/expand/rust-derive.cc
@@ -23,7 +23,7 @@
 namespace Rust {
 namespace AST {
 
-DeriveVisitor::DeriveVisitor (Location loc)
+DeriveVisitor::DeriveVisitor (location_t loc)
   : loc (loc), builder (AstBuilder (loc))
 {}
 
diff --git a/gcc/rust/expand/rust-derive.h b/gcc/rust/expand/rust-derive.h
index 01f3f024712..f315f060ef8 100644
--- a/gcc/rust/expand/rust-derive.h
+++ b/gcc/rust/expand/rust-derive.h
@@ -38,9 +38,9 @@ public:
 				       BuiltinMacro to_derive);
 
 protected:
-  DeriveVisitor (Location loc);
+  DeriveVisitor (location_t loc);
 
-  Location loc;
+  location_t loc;
   AstBuilder builder;
 
 private:
diff --git a/gcc/rust/expand/rust-macro-builtins.cc b/gcc/rust/expand/rust-macro-builtins.cc
index 82bb8d8cd16..57949ad3392 100644
--- a/gcc/rust/expand/rust-macro-builtins.cc
+++ b/gcc/rust/expand/rust-macro-builtins.cc
@@ -75,7 +75,7 @@ const BiMap<std::string, BuiltinMacro> MacroBuiltin::builtins = {{
 }};
 
 std::unordered_map<
-  std::string, std::function<AST::Fragment (Location, AST::MacroInvocData &)>>
+  std::string, std::function<AST::Fragment (location_t, AST::MacroInvocData &)>>
   MacroBuiltin::builtin_transcribers = {
     {"assert", MacroBuiltin::assert_handler},
     {"file", MacroBuiltin::file_handler},
@@ -221,7 +221,7 @@ macro_end_token (AST::DelimTokenTree &invoc_token_tree,
 
 /* Expand and then extract a string literal from the macro */
 static std::unique_ptr<AST::LiteralExpr>
-try_extract_string_literal_from_fragment (const Location &parent_locus,
+try_extract_string_literal_from_fragment (const location_t &parent_locus,
 					  std::unique_ptr<AST::Expr> &node)
 {
   auto maybe_lit = static_cast<AST::LiteralExpr *> (node.get ());
@@ -287,7 +287,7 @@ try_expand_many_expr (Parser<MacroInvocLexer> &parser,
 std::unique_ptr<AST::Expr>
 parse_single_string_literal (BuiltinMacro kind,
 			     AST::DelimTokenTree &invoc_token_tree,
-			     Location invoc_locus, MacroExpander *expander)
+			     location_t invoc_locus, MacroExpander *expander)
 {
   MacroInvocLexer lex (invoc_token_tree.to_token_stream ());
   Parser<MacroInvocLexer> parser (lex);
@@ -372,7 +372,7 @@ source_relative_path (std::string path, location_t locus)
    FIXME: platform specific.  */
 
 std::vector<uint8_t>
-load_file_bytes (Location invoc_locus, const char *filename)
+load_file_bytes (location_t invoc_locus, const char *filename)
 {
   RAIIFile file_wrap (filename);
   if (file_wrap.get_raw () == nullptr)
@@ -399,7 +399,8 @@ load_file_bytes (Location invoc_locus, const char *filename)
 } // namespace
 
 AST::Fragment
-MacroBuiltin::assert_handler (Location invoc_locus, AST::MacroInvocData &invoc)
+MacroBuiltin::assert_handler (location_t invoc_locus,
+			      AST::MacroInvocData &invoc)
 {
   rust_debug ("assert!() called");
 
@@ -407,7 +408,7 @@ MacroBuiltin::assert_handler (Location invoc_locus, AST::MacroInvocData &invoc)
 }
 
 AST::Fragment
-MacroBuiltin::file_handler (Location invoc_locus, AST::MacroInvocData &)
+MacroBuiltin::file_handler (location_t invoc_locus, AST::MacroInvocData &)
 {
   auto current_file = LOCATION_FILE (invoc_locus);
   auto file_str = AST::SingleASTNode (make_string (invoc_locus, current_file));
@@ -418,7 +419,7 @@ MacroBuiltin::file_handler (Location invoc_locus, AST::MacroInvocData &)
 }
 
 AST::Fragment
-MacroBuiltin::column_handler (Location invoc_locus, AST::MacroInvocData &)
+MacroBuiltin::column_handler (location_t invoc_locus, AST::MacroInvocData &)
 {
   auto current_column = LOCATION_COLUMN (invoc_locus);
 
@@ -436,7 +437,7 @@ MacroBuiltin::column_handler (Location invoc_locus, AST::MacroInvocData &)
    &'static [u8; N].  */
 
 AST::Fragment
-MacroBuiltin::include_bytes_handler (Location invoc_locus,
+MacroBuiltin::include_bytes_handler (location_t invoc_locus,
 				     AST::MacroInvocData &invoc)
 {
   /* Get target filename from the macro invocation, which is treated as a path
@@ -496,7 +497,7 @@ MacroBuiltin::include_bytes_handler (Location invoc_locus,
    expression of type &'static str.  */
 
 AST::Fragment
-MacroBuiltin::include_str_handler (Location invoc_locus,
+MacroBuiltin::include_str_handler (location_t invoc_locus,
 				   AST::MacroInvocData &invoc)
 {
   /* Get target filename from the macro invocation, which is treated as a path
@@ -581,7 +582,7 @@ MacroBuiltin::include_str_handler (Location invoc_locus,
 /* Expand builtin macro compile_error!("error"), which forces a compile error
    during the compile time. */
 AST::Fragment
-MacroBuiltin::compile_error_handler (Location invoc_locus,
+MacroBuiltin::compile_error_handler (location_t invoc_locus,
 				     AST::MacroInvocData &invoc)
 {
   auto lit_expr
@@ -642,7 +643,8 @@ MacroBuiltin::compile_error_handler (Location invoc_locus,
 // Do we split the two passes of parsing the token tree and then expanding it?
 // Can we do that easily?
 AST::Fragment
-MacroBuiltin::concat_handler (Location invoc_locus, AST::MacroInvocData &invoc)
+MacroBuiltin::concat_handler (location_t invoc_locus,
+			      AST::MacroInvocData &invoc)
 {
   auto invoc_token_tree = invoc.get_delim_tok_tree ();
   MacroInvocLexer lex (invoc_token_tree.to_token_stream ());
@@ -706,7 +708,7 @@ MacroBuiltin::concat_handler (Location invoc_locus, AST::MacroInvocData &invoc)
 /* Expand builtin macro env!(), which inspects an environment variable at
    compile time. */
 AST::Fragment
-MacroBuiltin::env_handler (Location invoc_locus, AST::MacroInvocData &invoc)
+MacroBuiltin::env_handler (location_t invoc_locus, AST::MacroInvocData &invoc)
 {
   auto invoc_token_tree = invoc.get_delim_tok_tree ();
   MacroInvocLexer lex (invoc_token_tree.to_token_stream ());
@@ -780,7 +782,7 @@ MacroBuiltin::env_handler (Location invoc_locus, AST::MacroInvocData &invoc)
 }
 
 AST::Fragment
-MacroBuiltin::cfg_handler (Location invoc_locus, AST::MacroInvocData &invoc)
+MacroBuiltin::cfg_handler (location_t invoc_locus, AST::MacroInvocData &invoc)
 {
   // only parse if not already parsed
   if (!invoc.is_parsed ())
@@ -822,7 +824,8 @@ MacroBuiltin::cfg_handler (Location invoc_locus, AST::MacroInvocData &invoc)
  scope compile time. */
 
 AST::Fragment
-MacroBuiltin::include_handler (Location invoc_locus, AST::MacroInvocData &invoc)
+MacroBuiltin::include_handler (location_t invoc_locus,
+			       AST::MacroInvocData &invoc)
 {
   /* Get target filename from the macro invocation, which is treated as a path
      relative to the include!-ing file (currently being compiled).  */
@@ -891,7 +894,7 @@ MacroBuiltin::include_handler (Location invoc_locus, AST::MacroInvocData &invoc)
 }
 
 AST::Fragment
-MacroBuiltin::line_handler (Location invoc_locus, AST::MacroInvocData &)
+MacroBuiltin::line_handler (location_t invoc_locus, AST::MacroInvocData &)
 {
   auto current_line = LOCATION_LINE (invoc_locus);
 
@@ -906,7 +909,7 @@ MacroBuiltin::line_handler (Location invoc_locus, AST::MacroInvocData &)
 }
 
 AST::Fragment
-MacroBuiltin::stringify_handler (Location invoc_locus,
+MacroBuiltin::stringify_handler (location_t invoc_locus,
 				 AST::MacroInvocData &invoc)
 {
   std::string content;
@@ -936,7 +939,7 @@ MacroBuiltin::stringify_handler (Location invoc_locus,
 }
 
 AST::Fragment
-MacroBuiltin::sorry (Location invoc_locus, AST::MacroInvocData &invoc)
+MacroBuiltin::sorry (location_t invoc_locus, AST::MacroInvocData &invoc)
 {
   rust_sorry_at (invoc_locus, "unimplemented builtin macro: %qs",
 		 invoc.get_path ().as_string ().c_str ());
@@ -945,7 +948,7 @@ MacroBuiltin::sorry (Location invoc_locus, AST::MacroInvocData &invoc)
 }
 
 AST::Fragment
-MacroBuiltin::proc_macro_builtin (Location invoc_locus,
+MacroBuiltin::proc_macro_builtin (location_t invoc_locus,
 				  AST::MacroInvocData &invoc)
 {
   rust_error_at (invoc_locus, "cannot invoke derive macro: %qs",
diff --git a/gcc/rust/expand/rust-macro-builtins.h b/gcc/rust/expand/rust-macro-builtins.h
index 87b6a1ed9da..3bde262018f 100644
--- a/gcc/rust/expand/rust-macro-builtins.h
+++ b/gcc/rust/expand/rust-macro-builtins.h
@@ -118,51 +118,52 @@ class MacroBuiltin
 {
 public:
   static const BiMap<std::string, BuiltinMacro> builtins;
-  static std::unordered_map<
-    std::string, std::function<AST::Fragment (Location, AST::MacroInvocData &)>>
+  static std::unordered_map<std::string, std::function<AST::Fragment (
+					   location_t, AST::MacroInvocData &)>>
     builtin_transcribers;
 
-  static AST::Fragment assert_handler (Location invoc_locus,
+  static AST::Fragment assert_handler (location_t invoc_locus,
 				       AST::MacroInvocData &invoc);
 
-  static AST::Fragment file_handler (Location invoc_locus,
+  static AST::Fragment file_handler (location_t invoc_locus,
 				     AST::MacroInvocData &invoc);
 
-  static AST::Fragment column_handler (Location invoc_locus,
+  static AST::Fragment column_handler (location_t invoc_locus,
 				       AST::MacroInvocData &invoc);
 
-  static AST::Fragment include_bytes_handler (Location invoc_locus,
+  static AST::Fragment include_bytes_handler (location_t invoc_locus,
 					      AST::MacroInvocData &invoc);
 
-  static AST::Fragment include_str_handler (Location invoc_locus,
+  static AST::Fragment include_str_handler (location_t invoc_locus,
 					    AST::MacroInvocData &invoc);
 
-  static AST::Fragment stringify_handler (Location invoc_locus,
+  static AST::Fragment stringify_handler (location_t invoc_locus,
 					  AST::MacroInvocData &invoc);
 
-  static AST::Fragment compile_error_handler (Location invoc_locus,
+  static AST::Fragment compile_error_handler (location_t invoc_locus,
 					      AST::MacroInvocData &invoc);
 
-  static AST::Fragment concat_handler (Location invoc_locus,
+  static AST::Fragment concat_handler (location_t invoc_locus,
 				       AST::MacroInvocData &invoc);
 
-  static AST::Fragment env_handler (Location invoc_locus,
+  static AST::Fragment env_handler (location_t invoc_locus,
 				    AST::MacroInvocData &invoc);
 
-  static AST::Fragment cfg_handler (Location invoc_locus,
+  static AST::Fragment cfg_handler (location_t invoc_locus,
 				    AST::MacroInvocData &invoc);
 
-  static AST::Fragment include_handler (Location invoc_locus,
+  static AST::Fragment include_handler (location_t invoc_locus,
 					AST::MacroInvocData &invoc);
 
-  static AST::Fragment line_handler (Location invoc_locus,
+  static AST::Fragment line_handler (location_t invoc_locus,
 				     AST::MacroInvocData &invoc);
 
-  static AST::Fragment sorry (Location invoc_locus, AST::MacroInvocData &invoc);
+  static AST::Fragment sorry (location_t invoc_locus,
+			      AST::MacroInvocData &invoc);
 
   /* Builtin procedural macros do not work directly on tokens, but still need a
    * builtin transcriber to be considered proper builtin macros */
-  static AST::Fragment proc_macro_builtin (Location, AST::MacroInvocData &);
+  static AST::Fragment proc_macro_builtin (location_t, AST::MacroInvocData &);
 };
 } // namespace Rust
 
diff --git a/gcc/rust/expand/rust-macro-expand.cc b/gcc/rust/expand/rust-macro-expand.cc
index 28868afa2af..09c8fc5b0ea 100644
--- a/gcc/rust/expand/rust-macro-expand.cc
+++ b/gcc/rust/expand/rust-macro-expand.cc
@@ -30,7 +30,7 @@
 namespace Rust {
 
 AST::Fragment
-MacroExpander::expand_decl_macro (Location invoc_locus,
+MacroExpander::expand_decl_macro (location_t invoc_locus,
 				  AST::MacroInvocData &invoc,
 				  AST::MacroRulesDefinition &rules_def,
 				  bool semicolon)
diff --git a/gcc/rust/parse/rust-parse-impl.h b/gcc/rust/parse/rust-parse-impl.h
index 3476128184c..d8d82b36391 100644
--- a/gcc/rust/parse/rust-parse-impl.h
+++ b/gcc/rust/parse/rust-parse-impl.h
@@ -485,7 +485,7 @@ Parser<ManagedTokenSource>::parse_inner_attributes ()
 
 // Parse a inner or outer doc comment into an doc attribute
 template <typename ManagedTokenSource>
-std::tuple<AST::SimplePath, std::unique_ptr<AST::AttrInput>, Location>
+std::tuple<AST::SimplePath, std::unique_ptr<AST::AttrInput>, location_t>
 Parser<ManagedTokenSource>::parse_doc_comment ()
 {
   const_TokenPtr token = lexer.peek_token ();
@@ -556,7 +556,7 @@ Parser<ManagedTokenSource>::parse_inner_attribute ()
 
 // Parses the body of an attribute (inner or outer).
 template <typename ManagedTokenSource>
-std::tuple<AST::SimplePath, std::unique_ptr<AST::AttrInput>, Location>
+std::tuple<AST::SimplePath, std::unique_ptr<AST::AttrInput>, location_t>
 Parser<ManagedTokenSource>::parse_attribute_body ()
 {
   location_t locus = lexer.peek_token ()->get_locus ();
@@ -918,7 +918,7 @@ Parser<ManagedTokenSource>::parse_delim_token_tree ()
 {
   const_TokenPtr t = lexer.peek_token ();
   lexer.skip_token ();
-  Location initial_loc = t->get_locus ();
+  location_t initial_loc = t->get_locus ();
 
   // save delim type to ensure it is reused later
   AST::DelimType delim_type = AST::PARENS;
@@ -1425,7 +1425,7 @@ Parser<ManagedTokenSource>::parse_macro_rules_def (AST::AttrVec outer_attrs)
       return nullptr;
     }
   lexer.skip_token ();
-  Location macro_locus = t->get_locus ();
+  location_t macro_locus = t->get_locus ();
 
   if (!skip_token (EXCLAM))
     {
@@ -1588,7 +1588,7 @@ Parser<ManagedTokenSource>::parse_decl_macro_def (AST::Visibility vis,
       return nullptr;
     }
   lexer.skip_token ();
-  Location macro_locus = t->get_locus ();
+  location_t macro_locus = t->get_locus ();
 
   // parse macro name
   const_TokenPtr ident_tok = expect_token (IDENTIFIER);
@@ -1619,7 +1619,7 @@ Parser<ManagedTokenSource>::parse_decl_macro_def (AST::Visibility vis,
 	  return nullptr;
 	}
 
-      Location transcriber_loc = lexer.peek_token ()->get_locus ();
+      location_t transcriber_loc = lexer.peek_token ()->get_locus ();
       AST::DelimTokenTree delim_tok_tree = parse_delim_token_tree ();
       AST::MacroTranscriber transcriber (delim_tok_tree, transcriber_loc);
 
@@ -1734,7 +1734,7 @@ std::unique_ptr<AST::MacroInvocation>
 Parser<ManagedTokenSource>::parse_macro_invocation_semi (
   AST::AttrVec outer_attrs)
 {
-  Location macro_locus = lexer.peek_token ()->get_locus ();
+  location_t macro_locus = lexer.peek_token ()->get_locus ();
   AST::SimplePath path = parse_simple_path ();
 
   if (!skip_token (EXCLAM))
@@ -1767,7 +1767,7 @@ Parser<ManagedTokenSource>::parse_macro_invocation_semi (
 
       return nullptr;
     }
-  Location tok_tree_locus = t->get_locus ();
+  location_t tok_tree_locus = t->get_locus ();
   lexer.skip_token ();
 
   // parse actual token trees
@@ -1878,7 +1878,7 @@ Parser<ManagedTokenSource>::parse_macro_invocation (AST::AttrVec outer_attrs)
   // parse internal delim token tree
   AST::DelimTokenTree delim_tok_tree = parse_delim_token_tree ();
 
-  Location macro_locus = macro_path.get_locus ();
+  location_t macro_locus = macro_path.get_locus ();
 
   return AST::MacroInvocation::Regular (
     AST::MacroInvocData (std::move (macro_path), std::move (delim_tok_tree)),
@@ -1905,7 +1905,7 @@ Parser<ManagedTokenSource>::parse_macro_rule ()
     }
 
   // parse transcriber (this is just a delim token tree)
-  Location token_tree_loc = lexer.peek_token ()->get_locus ();
+  location_t token_tree_loc = lexer.peek_token ()->get_locus ();
   AST::MacroTranscriber transcriber (parse_delim_token_tree (), token_tree_loc);
 
   return AST::MacroRule (std::move (matcher), std::move (transcriber), locus);
@@ -2114,7 +2114,7 @@ template <typename ManagedTokenSource>
 std::unique_ptr<AST::MacroMatchFragment>
 Parser<ManagedTokenSource>::parse_macro_match_fragment ()
 {
-  Location fragment_locus = lexer.peek_token ()->get_locus ();
+  location_t fragment_locus = lexer.peek_token ()->get_locus ();
   skip_token (DOLLAR_SIGN);
 
   Identifier ident;
@@ -6114,7 +6114,7 @@ Parser<ManagedTokenSource>::parse_named_function_param (
   std::string name;
 
   const_TokenPtr t = lexer.peek_token ();
-  Location name_location = t->get_locus ();
+  location_t name_location = t->get_locus ();
   switch (t->get_id ())
     {
     case IDENTIFIER:
@@ -6666,7 +6666,7 @@ Parser<ManagedTokenSource>::parse_type_path_segment ()
 // Parses a function call representation inside a type path.
 template <typename ManagedTokenSource>
 AST::TypePathFunction
-Parser<ManagedTokenSource>::parse_type_path_function (Location id_location)
+Parser<ManagedTokenSource>::parse_type_path_function (location_t id_location)
 {
   if (!skip_token (LEFT_PAREN))
     {
@@ -6819,7 +6819,7 @@ Parser<ManagedTokenSource>::parse_path_expr_segment ()
 template <typename ManagedTokenSource>
 AST::QualifiedPathInExpression
 Parser<ManagedTokenSource>::parse_qualified_path_in_expression (
-  Location pratt_parsed_loc)
+  location_t pratt_parsed_loc)
 {
   /* Note: the Rust grammar is defined in such a way that it is impossible to
    * determine whether a prospective qualified path is a
@@ -6901,7 +6901,7 @@ Parser<ManagedTokenSource>::parse_qualified_path_in_expression (
 template <typename ManagedTokenSource>
 AST::QualifiedPathType
 Parser<ManagedTokenSource>::parse_qualified_path_type (
-  Location pratt_parsed_loc)
+  location_t pratt_parsed_loc)
 {
   location_t locus = pratt_parsed_loc;
   /* TODO: should this actually be error? is there anywhere where this could
@@ -7335,7 +7335,7 @@ Parser<ManagedTokenSource>::parse_expr_stmt (AST::AttrVec outer_attrs,
 template <typename ManagedTokenSource>
 std::unique_ptr<AST::BlockExpr>
 Parser<ManagedTokenSource>::parse_block_expr (AST::AttrVec outer_attrs,
-					      Location pratt_parsed_loc)
+					      location_t pratt_parsed_loc)
 {
   location_t locus = pratt_parsed_loc;
   if (locus == UNKNOWN_LOCATION)
@@ -7382,7 +7382,7 @@ Parser<ManagedTokenSource>::parse_block_expr (AST::AttrVec outer_attrs,
 	}
     }
 
-  Location end_locus = t->get_locus ();
+  location_t end_locus = t->get_locus ();
 
   if (!skip_token (RIGHT_CURLY))
     {
@@ -7639,7 +7639,7 @@ Parser<ManagedTokenSource>::parse_literal_expr (AST::AttrVec outer_attrs)
 template <typename ManagedTokenSource>
 std::unique_ptr<AST::ReturnExpr>
 Parser<ManagedTokenSource>::parse_return_expr (AST::AttrVec outer_attrs,
-					       Location pratt_parsed_loc)
+					       location_t pratt_parsed_loc)
 {
   location_t locus = pratt_parsed_loc;
   if (locus == UNKNOWN_LOCATION)
@@ -7664,7 +7664,7 @@ Parser<ManagedTokenSource>::parse_return_expr (AST::AttrVec outer_attrs,
 template <typename ManagedTokenSource>
 std::unique_ptr<AST::BreakExpr>
 Parser<ManagedTokenSource>::parse_break_expr (AST::AttrVec outer_attrs,
-					      Location pratt_parsed_loc)
+					      location_t pratt_parsed_loc)
 {
   location_t locus = pratt_parsed_loc;
   if (locus == UNKNOWN_LOCATION)
@@ -7695,7 +7695,7 @@ Parser<ManagedTokenSource>::parse_break_expr (AST::AttrVec outer_attrs,
 template <typename ManagedTokenSource>
 std::unique_ptr<AST::ContinueExpr>
 Parser<ManagedTokenSource>::parse_continue_expr (AST::AttrVec outer_attrs,
-						 Location pratt_parsed_loc)
+						 location_t pratt_parsed_loc)
 {
   location_t locus = pratt_parsed_loc;
   if (locus == UNKNOWN_LOCATION)
@@ -7745,7 +7745,7 @@ Parser<ManagedTokenSource>::parse_loop_label (const_TokenPtr tok)
 template <typename ManagedTokenSource>
 std::unique_ptr<AST::IfExpr>
 Parser<ManagedTokenSource>::parse_if_expr (AST::AttrVec outer_attrs,
-					   Location pratt_parsed_loc)
+					   location_t pratt_parsed_loc)
 {
   // TODO: make having outer attributes an error?
   location_t locus = pratt_parsed_loc;
@@ -7903,7 +7903,7 @@ Parser<ManagedTokenSource>::parse_if_expr (AST::AttrVec outer_attrs,
 template <typename ManagedTokenSource>
 std::unique_ptr<AST::IfLetExpr>
 Parser<ManagedTokenSource>::parse_if_let_expr (AST::AttrVec outer_attrs,
-					       Location pratt_parsed_loc)
+					       location_t pratt_parsed_loc)
 {
   // TODO: make having outer attributes an error?
   location_t locus = pratt_parsed_loc;
@@ -8090,7 +8090,7 @@ template <typename ManagedTokenSource>
 std::unique_ptr<AST::LoopExpr>
 Parser<ManagedTokenSource>::parse_loop_expr (AST::AttrVec outer_attrs,
 					     AST::LoopLabel label,
-					     Location pratt_parsed_loc)
+					     location_t pratt_parsed_loc)
 {
   location_t locus = pratt_parsed_loc;
   if (locus == UNKNOWN_LOCATION)
@@ -8134,7 +8134,7 @@ template <typename ManagedTokenSource>
 std::unique_ptr<AST::WhileLoopExpr>
 Parser<ManagedTokenSource>::parse_while_loop_expr (AST::AttrVec outer_attrs,
 						   AST::LoopLabel label,
-						   Location pratt_parsed_loc)
+						   location_t pratt_parsed_loc)
 {
   location_t locus = pratt_parsed_loc;
   if (locus == UNKNOWN_LOCATION)
@@ -8410,7 +8410,7 @@ Parser<ManagedTokenSource>::parse_labelled_loop_expr (const_TokenPtr tok,
 template <typename ManagedTokenSource>
 std::unique_ptr<AST::MatchExpr>
 Parser<ManagedTokenSource>::parse_match_expr (AST::AttrVec outer_attrs,
-					      Location pratt_parsed_loc)
+					      location_t pratt_parsed_loc)
 {
   location_t locus = pratt_parsed_loc;
   if (locus == UNKNOWN_LOCATION)
@@ -8695,8 +8695,8 @@ Parser<ManagedTokenSource>::parse_async_block_expr (AST::AttrVec outer_attrs)
 // Parses an unsafe block expression.
 template <typename ManagedTokenSource>
 std::unique_ptr<AST::UnsafeBlockExpr>
-Parser<ManagedTokenSource>::parse_unsafe_block_expr (AST::AttrVec outer_attrs,
-						     Location pratt_parsed_loc)
+Parser<ManagedTokenSource>::parse_unsafe_block_expr (
+  AST::AttrVec outer_attrs, location_t pratt_parsed_loc)
 {
   location_t locus = pratt_parsed_loc;
   if (locus == UNKNOWN_LOCATION)
@@ -8727,7 +8727,7 @@ Parser<ManagedTokenSource>::parse_unsafe_block_expr (AST::AttrVec outer_attrs,
 template <typename ManagedTokenSource>
 std::unique_ptr<AST::ArrayExpr>
 Parser<ManagedTokenSource>::parse_array_expr (AST::AttrVec outer_attrs,
-					      Location pratt_parsed_loc)
+					      location_t pratt_parsed_loc)
 {
   location_t locus = pratt_parsed_loc;
   if (locus == UNKNOWN_LOCATION)
@@ -8903,7 +8903,7 @@ Parser<ManagedTokenSource>::parse_closure_param ()
 	}
     }
 
-  Location loc = pattern->get_locus ();
+  location_t loc = pattern->get_locus ();
   return AST::ClosureParam (std::move (pattern), loc, std::move (type),
 			    std::move (outer_attrs));
 }
@@ -8912,7 +8912,7 @@ Parser<ManagedTokenSource>::parse_closure_param ()
 template <typename ManagedTokenSource>
 std::unique_ptr<AST::ExprWithoutBlock>
 Parser<ManagedTokenSource>::parse_grouped_or_tuple_expr (
-  AST::AttrVec outer_attrs, Location pratt_parsed_loc)
+  AST::AttrVec outer_attrs, location_t pratt_parsed_loc)
 {
   // adjustment to allow Pratt parsing to reuse function without copy-paste
   location_t locus = pratt_parsed_loc;
@@ -9390,7 +9390,7 @@ Parser<ManagedTokenSource>::parse_paren_prefixed_type ()
    * virtual method abuse, as it was copied from the rustc implementation (in
    * which types are reified due to tagged union), after a more OOP attempt by
    * me failed. */
-  Location left_delim_locus = lexer.peek_token ()->get_locus ();
+  location_t left_delim_locus = lexer.peek_token ()->get_locus ();
 
   // skip left delim
   lexer.skip_token ();
@@ -9520,7 +9520,7 @@ template <typename ManagedTokenSource>
 std::unique_ptr<AST::Type>
 Parser<ManagedTokenSource>::parse_for_prefixed_type ()
 {
-  Location for_locus = lexer.peek_token ()->get_locus ();
+  location_t for_locus = lexer.peek_token ()->get_locus ();
   // parse for lifetimes in type
   std::vector<AST::LifetimeParam> for_lifetimes = parse_for_lifetimes ();
 
@@ -9650,7 +9650,7 @@ Parser<ManagedTokenSource>::parse_bare_function_type (
   std::vector<AST::LifetimeParam> for_lifetimes)
 {
   // TODO: pass in for lifetime location as param
-  Location best_try_locus = lexer.peek_token ()->get_locus ();
+  location_t best_try_locus = lexer.peek_token ()->get_locus ();
 
   AST::FunctionQualifiers qualifiers = parse_function_qualifiers ();
 
@@ -10168,7 +10168,7 @@ Parser<ManagedTokenSource>::parse_paren_prefixed_type_no_bounds ()
    * considered a trait bound, not a parenthesised type, so that it can still
    * be used in type param bounds. */
 
-  Location left_paren_locus = lexer.peek_token ()->get_locus ();
+  location_t left_paren_locus = lexer.peek_token ()->get_locus ();
 
   // skip left delim
   lexer.skip_token ();
@@ -10364,7 +10364,7 @@ std::unique_ptr<AST::RangePatternBound>
 Parser<ManagedTokenSource>::parse_range_pattern_bound ()
 {
   const_TokenPtr range_lower = lexer.peek_token ();
-  Location range_lower_locus = range_lower->get_locus ();
+  location_t range_lower_locus = range_lower->get_locus ();
 
   // get lit type
   switch (range_lower->get_id ())
@@ -10478,7 +10478,7 @@ template <typename ManagedTokenSource>
 std::unique_ptr<AST::Pattern>
 Parser<ManagedTokenSource>::parse_pattern ()
 {
-  Location start_locus = lexer.peek_token ()->get_locus ();
+  location_t start_locus = lexer.peek_token ()->get_locus ();
 
   /* skip optional starting pipe */
   maybe_skip_token (PIPE);
@@ -10767,7 +10767,7 @@ template <typename ManagedTokenSource>
 std::unique_ptr<AST::Pattern>
 Parser<ManagedTokenSource>::parse_grouped_or_tuple_pattern ()
 {
-  Location paren_locus = lexer.peek_token ()->get_locus ();
+  location_t paren_locus = lexer.peek_token ()->get_locus ();
   skip_token (LEFT_PAREN);
 
   // detect '..' token (ranged with no lower range)
@@ -10961,7 +10961,7 @@ template <typename ManagedTokenSource>
 std::unique_ptr<AST::SlicePattern>
 Parser<ManagedTokenSource>::parse_slice_pattern ()
 {
-  Location square_locus = lexer.peek_token ()->get_locus ();
+  location_t square_locus = lexer.peek_token ()->get_locus ();
   std::vector<std::unique_ptr<AST::Pattern>> patterns;
   skip_token (LEFT_SQUARE);
 
@@ -12582,7 +12582,7 @@ Parser<ManagedTokenSource>::left_denotation (const_TokenPtr tok,
     {
       // FIXME: allow for outer attributes to be applied
       case QUESTION_MARK: {
-	Location left_locus = left->get_locus ();
+	location_t left_locus = left->get_locus ();
 	// error propagation expression - unary postfix
 	return std::unique_ptr<AST::ErrorPropagationExpr> (
 	  new AST::ErrorPropagationExpr (std::move (left),
@@ -14081,7 +14081,7 @@ Parser<ManagedTokenSource>::parse_macro_invocation_partial (
 
   rust_debug ("successfully parsed macro invocation (via partial)");
 
-  Location macro_locus = converted_path.get_locus ();
+  location_t macro_locus = converted_path.get_locus ();
 
   return AST::MacroInvocation::Regular (
     AST::MacroInvocData (std::move (converted_path), std::move (tok_tree)),
@@ -14108,7 +14108,7 @@ Parser<ManagedTokenSource>::parse_struct_expr_struct_partial (
 
   // branch based on next token
   const_TokenPtr t = lexer.peek_token ();
-  Location path_locus = path.get_locus ();
+  location_t path_locus = path.get_locus ();
   switch (t->get_id ())
     {
     case RIGHT_CURLY:
@@ -14171,7 +14171,7 @@ Parser<ManagedTokenSource>::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 ();
+	    location_t dot_dot_location = lexer.peek_token ()->get_locus ();
 	    lexer.skip_token ();
 
 	    // parse required struct base expr
@@ -14270,7 +14270,7 @@ Parser<ManagedTokenSource>::parse_struct_expr_tuple_partial (
       return nullptr;
     }
 
-  Location path_locus = path.get_locus ();
+  location_t path_locus = path.get_locus ();
 
   auto pathExpr = std::unique_ptr<AST::PathInExpression> (
     new AST::PathInExpression (std::move (path)));
diff --git a/gcc/rust/parse/rust-parse.cc b/gcc/rust/parse/rust-parse.cc
index 6d67e78169f..56b9769b492 100644
--- a/gcc/rust/parse/rust-parse.cc
+++ b/gcc/rust/parse/rust-parse.cc
@@ -128,7 +128,7 @@ get_front_ptr (const std::vector<std::unique_ptr<T>> &values)
 static bool
 peculiar_fragment_match_compatible_fragment (
   const AST::MacroFragSpec &last_spec, const AST::MacroFragSpec &spec,
-  Location match_locus)
+  location_t match_locus)
 {
   static std::unordered_map<AST::MacroFragSpec::Kind,
 			    std::vector<AST::MacroFragSpec::Kind>>
@@ -231,7 +231,7 @@ peculiar_fragment_match_compatible (const AST::MacroMatchFragment &last_match,
 	 WHILE,
 	 YIELD}}};
 
-  Location error_locus = match.get_match_locus ();
+  location_t error_locus = match.get_match_locus ();
   std::string kind_str = "fragment";
   auto &allowed_toks = follow_set[last_match.get_frag_spec ().get_kind ()];
 
diff --git a/gcc/rust/parse/rust-parse.h b/gcc/rust/parse/rust-parse.h
index b8913afe8fc..904b5028a75 100644
--- a/gcc/rust/parse/rust-parse.h
+++ b/gcc/rust/parse/rust-parse.h
@@ -139,7 +139,7 @@ public:
 
   std::unique_ptr<AST::BlockExpr>
   parse_block_expr (AST::AttrVec outer_attrs = AST::AttrVec (),
-		    Location pratt_parsed_loc = UNKNOWN_LOCATION);
+		    location_t pratt_parsed_loc = UNKNOWN_LOCATION);
 
   std::unique_ptr<AST::Item> parse_item (bool called_from_statement);
   std::unique_ptr<AST::Pattern> parse_pattern ();
@@ -167,7 +167,7 @@ public:
   std::unique_ptr<AST::IdentifierPattern> parse_identifier_pattern ();
   std::unique_ptr<AST::Token> parse_identifier_or_keyword_token ();
   std::unique_ptr<AST::TokenTree> parse_token_tree ();
-  std::tuple<AST::SimplePath, std::unique_ptr<AST::AttrInput>, Location>
+  std::tuple<AST::SimplePath, std::unique_ptr<AST::AttrInput>, location_t>
   parse_attribute_body ();
   AST::AttrVec parse_inner_attributes ();
   std::unique_ptr<AST::MacroInvocation>
@@ -192,7 +192,7 @@ private:
   AST::AttrVec parse_outer_attributes ();
   AST::Attribute parse_outer_attribute ();
   std::unique_ptr<AST::AttrInput> parse_attr_input ();
-  std::tuple<AST::SimplePath, std::unique_ptr<AST::AttrInput>, Location>
+  std::tuple<AST::SimplePath, std::unique_ptr<AST::AttrInput>, location_t>
   parse_doc_comment ();
 
   // Path-related
@@ -210,9 +210,9 @@ private:
   // When given a pratt_parsed_loc, use it as the location of the
   // first token parsed in the expression (the parsing of that first
   // token should be skipped).
-  parse_qualified_path_in_expression (Location pratt_parsed_loc
+  parse_qualified_path_in_expression (location_t pratt_parsed_loc
 				      = UNKNOWN_LOCATION);
-  AST::QualifiedPathType parse_qualified_path_type (Location pratt_parsed_loc
+  AST::QualifiedPathType parse_qualified_path_type (location_t pratt_parsed_loc
 						    = UNKNOWN_LOCATION);
   AST::QualifiedPathInType parse_qualified_path_in_type ();
 
@@ -565,18 +565,18 @@ private:
   // token should be skipped).
   std::unique_ptr<AST::IfExpr>
   parse_if_expr (AST::AttrVec outer_attrs = AST::AttrVec (),
-		 Location pratt_parsed_loc = UNKNOWN_LOCATION);
+		 location_t pratt_parsed_loc = UNKNOWN_LOCATION);
   std::unique_ptr<AST::IfLetExpr>
   parse_if_let_expr (AST::AttrVec outer_attrs = AST::AttrVec (),
-		     Location pratt_parsed_loc = UNKNOWN_LOCATION);
+		     location_t pratt_parsed_loc = UNKNOWN_LOCATION);
   std::unique_ptr<AST::LoopExpr>
   parse_loop_expr (AST::AttrVec outer_attrs = AST::AttrVec (),
 		   AST::LoopLabel label = AST::LoopLabel::error (),
-		   Location pratt_parsed_loc = UNKNOWN_LOCATION);
+		   location_t pratt_parsed_loc = UNKNOWN_LOCATION);
   std::unique_ptr<AST::WhileLoopExpr>
   parse_while_loop_expr (AST::AttrVec outer_attrs = AST::AttrVec (),
 			 AST::LoopLabel label = AST::LoopLabel::error (),
-			 Location pratt_parsed_loc = UNKNOWN_LOCATION);
+			 location_t pratt_parsed_loc = UNKNOWN_LOCATION);
   std::unique_ptr<AST::WhileLetLoopExpr>
   parse_while_let_loop_expr (AST::AttrVec outer_attrs = AST::AttrVec (),
 			     AST::LoopLabel label = AST::LoopLabel::error ());
@@ -585,7 +585,7 @@ private:
 		       AST::LoopLabel label = AST::LoopLabel::error ());
   std::unique_ptr<AST::MatchExpr>
   parse_match_expr (AST::AttrVec outer_attrs = AST::AttrVec (),
-		    Location pratt_parsed_loc = UNKNOWN_LOCATION);
+		    location_t pratt_parsed_loc = UNKNOWN_LOCATION);
   AST::MatchArm parse_match_arm ();
   std::vector<std::unique_ptr<AST::Pattern> >
   parse_match_arm_patterns (TokenId end_token_id);
@@ -606,22 +606,22 @@ private:
   // token should be skipped).
   std::unique_ptr<AST::ReturnExpr>
   parse_return_expr (AST::AttrVec outer_attrs = AST::AttrVec (),
-		     Location pratt_parsed_loc = UNKNOWN_LOCATION);
+		     location_t pratt_parsed_loc = UNKNOWN_LOCATION);
   std::unique_ptr<AST::BreakExpr>
   parse_break_expr (AST::AttrVec outer_attrs = AST::AttrVec (),
-		    Location pratt_parsed_loc = UNKNOWN_LOCATION);
+		    location_t pratt_parsed_loc = UNKNOWN_LOCATION);
   std::unique_ptr<AST::ContinueExpr>
   parse_continue_expr (AST::AttrVec outer_attrs = AST::AttrVec (),
-		       Location pratt_parsed_loc = UNKNOWN_LOCATION);
+		       location_t pratt_parsed_loc = UNKNOWN_LOCATION);
   std::unique_ptr<AST::UnsafeBlockExpr>
   parse_unsafe_block_expr (AST::AttrVec outer_attrs = AST::AttrVec (),
-			   Location pratt_parsed_loc = UNKNOWN_LOCATION);
+			   location_t pratt_parsed_loc = UNKNOWN_LOCATION);
   std::unique_ptr<AST::ArrayExpr>
   parse_array_expr (AST::AttrVec outer_attrs = AST::AttrVec (),
-		    Location pratt_parsed_loc = UNKNOWN_LOCATION);
+		    location_t pratt_parsed_loc = UNKNOWN_LOCATION);
   std::unique_ptr<AST::ExprWithoutBlock>
   parse_grouped_or_tuple_expr (AST::AttrVec outer_attrs = AST::AttrVec (),
-			       Location pratt_parsed_loc = UNKNOWN_LOCATION);
+			       location_t pratt_parsed_loc = UNKNOWN_LOCATION);
   std::unique_ptr<AST::StructExprField> parse_struct_expr_field ();
   bool will_be_expr_with_block ();


More information about the Gcc-cvs mailing list