https://gcc.gnu.org/g:94085d2f30d0e39d23640cba74c499b004cda260

commit r16-4823-g94085d2f30d0e39d23640cba74c499b004cda260
Author: Pierre-Emmanuel Patry <[email protected]>
Date:   Tue Aug 26 12:55:02 2025 +0200

    gccrs: Do not dump the AST if the parser emit errors
    
    gcc/rust/ChangeLog:
    
            * rust-session-manager.cc (Session::compile_crate): Move the AST 
dump
            after parser error check.
    
    Signed-off-by: Pierre-Emmanuel Patry <[email protected]>

Diff:
---
 gcc/rust/rust-session-manager.cc | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc
index 386aa65b966e..e99fd6b8c0ce 100644
--- a/gcc/rust/rust-session-manager.cc
+++ b/gcc/rust/rust-session-manager.cc
@@ -548,10 +548,6 @@ Session::compile_crate (const char *filename)
   handle_crate_name (filename, *ast_crate.get ());
 
   // dump options except lexer dump
-  if (options.dump_option_enabled (CompileOptions::AST_DUMP_PRETTY))
-    {
-      dump_ast_pretty (*ast_crate.get ());
-    }
   if (options.dump_option_enabled (CompileOptions::TARGET_OPTION_DUMP))
     {
       options.target_data.dump_target_options ();
@@ -560,6 +556,11 @@ Session::compile_crate (const char *filename)
   if (saw_errors ())
     return;
 
+  if (options.dump_option_enabled (CompileOptions::AST_DUMP_PRETTY))
+    {
+      dump_ast_pretty (*ast_crate.get ());
+    }
+
   // setup the mappings for this AST
   CrateNum current_crate = mappings.get_current_crate ();
   AST::Crate &parsed_crate

Reply via email to