Skip to content

Commit ea436b1

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 4db0cf7 commit ea436b1

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
@@ -3383,7 +3383,13 @@ void
33833383
Module::process_file_path ()
33843384
{
33853385
rust_assert (kind == Module::ModuleKind::UNLOADED);
3386-
rust_assert (module_file.empty ());
3386+
3387+
if (module_file.empty ())
3388+
{
3389+
rust_error_at (locus, "error handling module file for %qs",
3390+
module_name.as_string ().c_str ());
3391+
return;
3392+
}
33873393

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

0 commit comments

Comments
 (0)