From f4d20fbe6b546aa3028a606043638aeb56fb296f Mon Sep 17 00:00:00 2001 From: Pierre-Emmanuel Patry Date: Tue, 4 Feb 2025 13:53:30 +0100 Subject: [PATCH] gccrs: 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 --- 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 4c6664f104b..305286970c7 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); }; -- 2.47.2