https://gcc.gnu.org/g:d2f16edd69680b5be924caea5893ec21e3271e5c

commit r16-4888-gd2f16edd69680b5be924caea5893ec21e3271e5c
Author: 0xllx0 <[email protected]>
Date:   Fri Oct 3 03:17:54 2025 +0000

    gccrs: fix: add early return for empty module file
    
    Converts an assert into an early return during AST parsing.
    
    Resolves: Rust-GCC/gccrs#4145
    
    gcc/rust/ChangeLog:
    
            * ast/rust-ast.cc (Module::process_file_path): empty module early 
return
    
    Signed-off-by: Elle Rhumsaa <[email protected]>

Diff:
---
 gcc/rust/ast/rust-ast.cc | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/gcc/rust/ast/rust-ast.cc b/gcc/rust/ast/rust-ast.cc
index a4b256c9e67f..4e81de85be42 100644
--- a/gcc/rust/ast/rust-ast.cc
+++ b/gcc/rust/ast/rust-ast.cc
@@ -3363,7 +3363,13 @@ void
 Module::process_file_path ()
 {
   rust_assert (kind == Module::ModuleKind::UNLOADED);
-  rust_assert (module_file.empty ());
+
+  if (!module_file.empty ())
+    {
+      rust_error_at (locus, "error handling module file for %qs",
+                    module_name.as_string ().c_str ());
+      return;
+    }
 
   // This corresponds to the path of the file 'including' the module. So the
   // file that contains the 'mod <file>;' directive

Reply via email to