[gccrs COMMIT 2/2] desugar-apit: Add missing visit to function sub items

[email protected]
Newsgroups gmane.comp.gcc.rust,gmane.comp.gcc.patches
Message-ID <[email protected]>
From: Arthur Cohen <[email protected]>

When desugaring the Argument Position Impl Traits of a function, we still need to visit that
function's block and its items as it may contain other inner functions with other APITs.

gcc/rust/ChangeLog:

	* ast/rust-desugar-apit.cc (DesugarApit::visit): Call DefaultASTVisitor::visit
	on the function we're currently visiting.

gcc/testsuite/ChangeLog:

	* rust/compile/apit-in-inner-fn.rs: New test.
---
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/016d4b958629cf944231fc56d6a4699d30f06467

The commit has NOT been mentioned in any issue.

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

 gcc/rust/ast/rust-desugar-apit.cc              |  3 +++
 gcc/testsuite/rust/compile/apit-in-inner-fn.rs | 17 +++++++++++++++++
 2 files changed, 20 insertions(+)
 create mode 100644 gcc/testsuite/rust/compile/apit-in-inner-fn.rs

diff --git a/gcc/rust/ast/rust-desugar-apit.cc b/gcc/rust/ast/rust-desugar-apit.cc
index 25c89dc04..0e5739cd4 100644
--- a/gcc/rust/ast/rust-desugar-apit.cc
+++ b/gcc/rust/ast/rust-desugar-apit.cc
@@ -17,6 +17,7 @@
 // <http://www.gnu.org/licenses/>.
 
 #include "rust-desugar-apit.h"
+#include "rust-ast-visitor.h"
 #include "rust-ast.h"
 #include "rust-type.h"
 
@@ -524,6 +525,8 @@ DesugarApit::visit (AST::Function &function)
 				    function.get_generic_params ());
       processor.go (implicit_generics);
     }
+
+  DefaultASTVisitor::visit (function);
 }
 
 } // namespace AST
diff --git a/gcc/testsuite/rust/compile/apit-in-inner-fn.rs b/gcc/testsuite/rust/compile/apit-in-inner-fn.rs
new file mode 100644
index 000000000..7a32971db
--- /dev/null
+++ b/gcc/testsuite/rust/compile/apit-in-inner-fn.rs
@@ -0,0 +1,17 @@
+#![feature(no_core)]
+#![feature(lang_items)]
+#![feature(rustc_attrs)]
+#![no_core]
+
+#[lang = "sized"]
+trait Sized {}
+
+trait Foo {}
+
+pub struct Bar;
+
+impl Bar {
+    pub fn foo(b: impl Foo) {
+        fn inner(a: impl Foo) {}
+    }
+}
-- 
2.54.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.