From: Owen Avery <[email protected]>

gcc/rust/ChangeLog:

        * ast/rust-ast-visitor.cc (DefaultASTVisitor::visit): Visit the
        generic parameters of TraitItemType.
        * expand/rust-expand-visitor.h (is_derive): Remove defunct
        function declaration.
        * hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): Remove
        unnecessary copy.
        * resolve/rust-name-resolver.cc (Resolver::Resolver): Skip
        generating builtins for the old resolver.
        * util/rust-hir-map.cc (Mappings::get_next_node_id): Detect node
        id exhaustion.
        * util/rust-mapping-common.h (MAX_NODEID): Add macro definition.

Signed-off-by: Owen Avery <[email protected]>
---
This change was merged into the gccrs repository and is posted here for
upstream visibility and potential drive-by review, as requested by GCC
release managers.
Each commit email contains a link to its details on github from where you can
find the Pull-Request and associated discussions.


Commit on github: 
https://github.com/Rust-GCC/gccrs/commit/9f4e0804d721956925ca42f8f22513949bc5c16a

The commit has been mentioned in the following pull-request(s):
 - https://github.com/Rust-GCC/gccrs/pull/4332

 gcc/rust/ast/rust-ast-visitor.cc       | 2 ++
 gcc/rust/expand/rust-expand-visitor.h  | 5 -----
 gcc/rust/hir/rust-ast-lower-item.cc    | 2 +-
 gcc/rust/resolve/rust-name-resolver.cc | 4 +---
 gcc/rust/util/rust-hir-map.cc          | 2 ++
 gcc/rust/util/rust-mapping-common.h    | 1 +
 6 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/gcc/rust/ast/rust-ast-visitor.cc b/gcc/rust/ast/rust-ast-visitor.cc
index afdd2b19d..a9e2f053a 100644
--- a/gcc/rust/ast/rust-ast-visitor.cc
+++ b/gcc/rust/ast/rust-ast-visitor.cc
@@ -1029,6 +1029,8 @@ void
 DefaultASTVisitor::visit (AST::TraitItemType &item)
 {
   visit_outer_attrs (item);
+  for (auto &generic : item.get_generic_params ())
+    visit (generic);
   for (auto &bound : item.get_type_param_bounds ())
     visit (bound);
 }
diff --git a/gcc/rust/expand/rust-expand-visitor.h 
b/gcc/rust/expand/rust-expand-visitor.h
index b79eb663c..0f92268ee 100644
--- a/gcc/rust/expand/rust-expand-visitor.h
+++ b/gcc/rust/expand/rust-expand-visitor.h
@@ -27,11 +27,6 @@
 
 namespace Rust {
 
-/**
- * Whether or not an attribute is a derive attribute
- */
-bool is_derive (AST::Attribute &attr);
-
 /**
  * Whether or not an attribute is builtin
  */
diff --git a/gcc/rust/hir/rust-ast-lower-item.cc 
b/gcc/rust/hir/rust-ast-lower-item.cc
index 81815ff22..369f77e70 100644
--- a/gcc/rust/hir/rust-ast-lower-item.cc
+++ b/gcc/rust/hir/rust-ast-lower-item.cc
@@ -451,7 +451,7 @@ ASTLoweringItem::visit (AST::Function &function)
          continue;
        }
 
-      auto param = static_cast<AST::FunctionParam &> (*p);
+      auto &param = static_cast<AST::FunctionParam &> (*p);
 
       auto translated_pattern = std::unique_ptr<HIR::Pattern> (
        ASTLoweringPattern::translate (param.get_pattern ()));
diff --git a/gcc/rust/resolve/rust-name-resolver.cc 
b/gcc/rust/resolve/rust-name-resolver.cc
index dddaa0793..8625a0e4d 100644
--- a/gcc/rust/resolve/rust-name-resolver.cc
+++ b/gcc/rust/resolve/rust-name-resolver.cc
@@ -282,9 +282,7 @@ Resolver::Resolver ()
     label_scope (Scope (mappings.get_current_crate ())),
     macro_scope (Scope (mappings.get_current_crate ())),
     global_type_node_id (UNKNOWN_NODEID), unit_ty_node_id (UNKNOWN_NODEID)
-{
-  generate_builtins ();
-}
+{}
 
 Resolver *
 Resolver::get ()
diff --git a/gcc/rust/util/rust-hir-map.cc b/gcc/rust/util/rust-hir-map.cc
index a6d323e36..0012969eb 100644
--- a/gcc/rust/util/rust-hir-map.cc
+++ b/gcc/rust/util/rust-hir-map.cc
@@ -201,6 +201,8 @@ NodeId
 Mappings::get_next_node_id ()
 {
   auto it = nodeIdIter;
+  if (UNLIKELY (it > MAX_NODEID))
+    rust_fatal_error (UNKNOWN_LOCATION, "out of node ids");
   nodeIdIter++;
   return it;
 }
diff --git a/gcc/rust/util/rust-mapping-common.h 
b/gcc/rust/util/rust-mapping-common.h
index 3cc5a7506..bd9fd733d 100644
--- a/gcc/rust/util/rust-mapping-common.h
+++ b/gcc/rust/util/rust-mapping-common.h
@@ -63,6 +63,7 @@ struct DefId
 
 #define UNKNOWN_CRATENUM ((uint32_t) (UINT32_MAX))
 #define UNKNOWN_NODEID ((uint32_t) (UINT32_MAX))
+#define MAX_NODEID (UNKNOWN_NODEID - 1)
 #define UNKNOWN_HIRID ((uint32_t) (UINT32_MAX))
 #define UNKNOWN_LOCAL_DEFID ((uint32_t) (0))
 #define UNKNOWN_DEFID (DefId{0, 0})

base-commit: 699625596f329afee81ddf240821d38eabf58b57
-- 
2.52.0

Reply via email to