Stdin build silently ignores non-inline mod items #65601
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-parser
Area: The parsing of Rust source code to an AST
C-bug
Category: This is a bug.
E-needs-test
Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Missing external modules don't report a build error when a crate is built from stdin.
Expected: When parsing an external submodule from stdin, a compiler error (or warning) is emitted noting that external submodules are not supported for stdio crates.
Actual: No diagnostics are emitted and an empty submodule is implicitly inserted.
Generally if a
mod
statement references a file which does not exist, an E0583 compile error will be emitted. However, when building a crate from stdin, no relative filesystem is present, yet no compile errors are emitted, even with explicit#[path="x"]
attributes. Instead they are implicitly substituted with empty inline modules.I'm not super familiar with rustc, so this might not be handy, but I'm guessing this is caused by the
Parser::recurse_into_file_modules
flag being unset when parsing from a string rather than a file (rustc_interface::passes::parse
->syntax::parse::parse_crate_from_source_str
->syntax::parse::new_parser_from_source_str
), leading to a dummy module being inserted rather than trying to access the filesystem or emit an error during the parse.The text was updated successfully, but these errors were encountered: