]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: fix: add early return for empty module file
author0xllx0 <github+elle@weathered-steel.dev>
Fri, 3 Oct 2025 03:17:54 +0000 (03:17 +0000)
committerArthur Cohen <arthur.cohen@embecosm.com>
Thu, 30 Oct 2025 20:30:55 +0000 (21:30 +0100)
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 <elle@weathered-steel.dev>
gcc/rust/ast/rust-ast.cc

index a4b256c9e67febe83e30ced42f3f73e8034bd30d..4e81de85be42a57c62887c229290e36204cb62ca 100644 (file)
@@ -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