https://gcc.gnu.org/g:3aac3dfec915b2bbb8da7db9be86f5b8a2c49511

commit r16-2883-g3aac3dfec915b2bbb8da7db9be86f5b8a2c49511
Author: Owen Avery <powerboat9.ga...@gmail.com>
Date:   Sat May 24 14:32:10 2025 -0400

    gccrs: Move AST desugaring into expansion phase
    
    This fixes some issues with name resolution 2.0.
    
    gcc/rust/ChangeLog:
    
            * rust-session-manager.cc (Session::compile_crate): Move
            AST desugaring to...
            (Session::expansion): ...here and add a final TopLevel pass
            afterwards.
    
    gcc/testsuite/ChangeLog:
    
            * rust/compile/nr2/exclude: Remove entries.
    
    Signed-off-by: Owen Avery <powerboat9.ga...@gmail.com>

Diff:
---
 gcc/rust/rust-session-manager.cc       | 18 ++++++++++++++----
 gcc/testsuite/rust/compile/nr2/exclude |  4 ----
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc
index da11a6e57c27..dbb3b47b8627 100644
--- a/gcc/rust/rust-session-manager.cc
+++ b/gcc/rust/rust-session-manager.cc
@@ -619,10 +619,6 @@ Session::compile_crate (const char *filename)
 
   expansion (parsed_crate, name_resolution_ctx);
 
-  AST::DesugarForLoops ().go (parsed_crate);
-  AST::DesugarQuestionMark ().go (parsed_crate);
-  AST::DesugarApit ().go (parsed_crate);
-
   rust_debug ("\033[0;31mSUCCESSFULLY FINISHED EXPANSION \033[0m");
   if (options.dump_option_enabled (CompileOptions::EXPANSION_DUMP))
     {
@@ -986,6 +982,20 @@ Session::expansion (AST::Crate &crate, 
Resolver2_0::NameResolutionContext &ctx)
       rust_error_at (range, "reached recursion limit");
     }
 
+  // handle AST desugaring
+  if (!saw_errors ())
+    {
+      AST::DesugarForLoops ().go (crate);
+      AST::DesugarQuestionMark ().go (crate);
+      AST::DesugarApit ().go (crate);
+
+      // HACK: we may need a final TopLevel pass
+      // however, this should not count towards the recursion limit
+      // and we don't need a full Early pass
+      if (flag_name_resolution_2_0)
+       Resolver2_0::TopLevel (ctx).go (crate);
+    }
+
   // error reporting - check unused macros, get missing fragment specifiers
 
   // build test harness
diff --git a/gcc/testsuite/rust/compile/nr2/exclude 
b/gcc/testsuite/rust/compile/nr2/exclude
index b67d0e50a8a3..82faf1ae0ce4 100644
--- a/gcc/testsuite/rust/compile/nr2/exclude
+++ b/gcc/testsuite/rust/compile/nr2/exclude
@@ -1,8 +1,4 @@
 issue-3315-2.rs
 torture/alt_patterns1.rs
-issue-1487.rs
-issue-2015.rs
-issue-3454.rs
-impl_trait_generic_arg.rs
 issue-3642.rs
 # please don't delete the trailing newline

Reply via email to