From: Pierre-Emmanuel Patry Date: Tue, 4 Feb 2025 12:53:30 +0000 (+0100) Subject: gccrs: Add warning about default visitor usage X-Git-Tag: basepoints/gcc-16~768 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f4d20fbe6b546aa3028a606043638aeb56fb296f;p=thirdparty%2Fgcc.git 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 --- 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); };