[COMMITTED 09/43] gccrs: desugar-apit: Add missing visit to function sub items
arthur.cohen@opensrcsec.com
arthur.cohen@opensrcsec.com
Thu Sep 10 08:19:22 GMT 2026
From: Arthur Cohen <arthur.cohen@embecosm.com>
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.
---
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 25c89dc0465..0e5739cd40b 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 00000000000..7a32971db36
--- /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.50.1
More information about the Gcc-rust
mailing list