Skip to content

Commit cbd86da

Browse files
committed
fix: add early return for empty module file
Converts an assert into an early return during AST parsing. Resolves: #4145 gcc/rust/ChangeLog: * ast/rust-ast.cc (Module::process_file_path): empty module early return Signed-off-by: Elle Rhumsaa <[email protected]>
1 parent 32ce955 commit cbd86da

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

gcc/rust/ast/rust-ast.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3363,7 +3363,13 @@ void
33633363
Module::process_file_path ()
33643364
{
33653365
rust_assert (kind == Module::ModuleKind::UNLOADED);
3366-
rust_assert (module_file.empty ());
3366+
3367+
if (module_file.empty ())
3368+
{
3369+
rust_error_at (locus, "error handling module file for %qs",
3370+
module_name.as_string ().c_str ());
3371+
return;
3372+
}
33673373

33683374
// This corresponds to the path of the file 'including' the module. So the
33693375
// file that contains the 'mod <file>;' directive

0 commit comments

Comments
 (0)