-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Stdin build silently ignores non-inline mod items #65601
Copy link
Copy link
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTC-bugCategory: This is a bug.Category: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTArea: The lexing & parsing of Rust source code to an ASTC-bugCategory: This is a bug.Category: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
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
modstatement 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_modulesflag 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.