https://gcc.gnu.org/g:b3bcaeba113d5b32885a0be6022f9a4e72d6eece
commit b3bcaeba113d5b32885a0be6022f9a4e72d6eece Author: Pierre-Emmanuel Patry <pierre-emmanuel.pa...@embecosm.com> Date: Tue Feb 4 13:53:30 2025 +0100 Add warning about default visitor usage 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.pa...@embecosm.com> Diff: --- gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc index 61e9ea4a928c..768154de0a1a 100644 --- a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc +++ b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc @@ -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); };