gccrs: desugar-apit: Add missing visit to function sub items
Ensures nested functions are processed during Argument Position Impl Trait desugaring in gccrs.
This commit adds a necessary visit call within the Argument Position Impl Trait (APIT) desugaring process in gccrs. When desugaring APITs in a function, the compiler must now also visit the function’s internal block and any nested items. This ensures that APITs within inner functions are correctly processed, preventing potential issues where nested structures might be overlooked.
In Details
The DesugarApit::visit method in rust-desugar-apit.cc previously only processed the top-level function containing APITs. This change introduces a call to DefaultASTVisitor::visit for the current function being visited. This ensures that the AST traversal continues into nested functions or other sub-items within the function's body, allowing for the correct desugaring of APITs that might be defined within these nested scopes.
- Argument Position Impl Trait (APIT)
- A Rust feature allowing function parameters to be generic over associated types of traits, specified directly in the argument position. It simplifies trait bounds for function arguments.
- desugaring
- The process of transforming higher-level, more convenient syntax in a programming language into lower-level, more explicit constructs that the compiler can more easily understand and process.
- AST (Abstract Syntax Tree)
- A tree representation of the abstract syntactic structure of source code, used internally by compilers to analyze and transform code.
- nested function
- A function defined inside another function. In Rust, these can capture variables from their enclosing scope.