]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Add warning about default visitor usage
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Tue, 4 Feb 2025 12:53:30 +0000 (13:53 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Mon, 24 Mar 2025 12:07:02 +0000 (13:07 +0100)
We already lost some time on this unusual pattern, a comment will
hopefully prevent this from happening again.

gcc/rust/ChangeLog:

* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): Add
warning about current code.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc

index 4c6664f104b4936fdaa7be8288bf3cdfee8b8cc9..305286970c7f90e6a7082a3a3ace29fb9e7fc30f 100644 (file)
@@ -110,6 +110,8 @@ TopLevel::visit (AST::InherentImpl &impl)
     insert_or_error_out (Identifier ("Self", impl.get_type ().get_locus ()),
                         impl.get_type (), Namespace::Types);
 
+    // We do want to visit with the default visitor instead of default resolver
+    // because we don't want to insert the scope twice.
     AST::DefaultASTVisitor::visit (impl);
   };
 
@@ -123,6 +125,8 @@ TopLevel::visit (AST::TraitImpl &impl)
     insert_or_error_out (Identifier ("Self", impl.get_type ().get_locus ()),
                         impl.get_type (), Namespace::Types);
 
+    // We do want to visit using the default visitor instead of default resolver
+    // because we don't want to insert the scope twice.
     AST::DefaultASTVisitor::visit (impl);
   };