Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion gcc/rust/ast/rust-ast.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions gcc/testsuite/rust/compile/issue-4145.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// { dg-excess-errors "warnings" }

struct S {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure on the exact decorators needed here, or if this test should go into the xfail directory. The test is expected to fail compilation, just with an error message instead of an ICE.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grep for dg-error in the testsuite directory -- that should give you some nice examples for expecting error messages

field: [u8; {
#[path = "outer/inner.rs"]
// { dg-warning "error handling module file for .inner." "#4145" { xfail *-*-* } .+1 }
mod inner;
// OK
0
}],
}

fn main() {}
Loading