Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[regression] cannot declare non-inline module inside a block #71766

Closed
Mark-Simulacrum opened this issue May 1, 2020 · 8 comments
Closed

[regression] cannot declare non-inline module inside a block #71766

Mark-Simulacrum opened this issue May 1, 2020 · 8 comments
Labels
regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Milestone

Comments

@Mark-Simulacrum
Copy link
Member

[INFO] [stdout] error: Cannot declare a non-inline module inside a block unless it has a path attribute
[INFO] [stdout]  --> src/rcalc/lexer.rs:124:1
[INFO] [stdout]   |
[INFO] [stdout] 4 | mod rcalc;
[INFO] [stdout]   | ^^^^^^^^^^
[INFO] [stdout] 
[INFO] [stdout] error: aborting due to previous error

cc @petrochenkov

Possibly related to changes in rustdoc, I believe both cases are inside doctests?

@Mark-Simulacrum Mark-Simulacrum added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. regression-from-stable-to-beta Performance or correctness regression from stable to beta. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels May 1, 2020
@Mark-Simulacrum Mark-Simulacrum added this to the 1.44 milestone May 1, 2020
@petrochenkov petrochenkov self-assigned this May 1, 2020
@petrochenkov
Copy link
Contributor

Bisection points to 57e1da5.

@petrochenkov
Copy link
Contributor

That's #69838 "Expansion-driven outline module parsing".

@petrochenkov
Copy link
Contributor

Minimized:

/// ```
/// mod nonexistent;
/// ```
pub fn in_library_crate() {}
cargo test

Passes on stable, produces error: Cannot declare a non-inline module inside a block unless it has a path attribute on nightly.

@petrochenkov
Copy link
Contributor

So, before #69838 Parser had this option recurse_into_file_modules that silently turned mod foo; into mod foo {}, and rustdoc happened to use it in doctests, and now the option is removed, and rustdoc no longer turns mod foo; into mod foo {}, and rustdoc tries to load it from a file and fails.

@petrochenkov
Copy link
Contributor

Seems acceptable, the regression can only happen in doctests and making doctests behave more like regular Rust code is good.

@petrochenkov petrochenkov added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label May 3, 2020
@petrochenkov petrochenkov removed their assignment May 3, 2020
@Mark-Simulacrum
Copy link
Member Author

To be clear, mod foo; was turned into mod foo {} in blocks, right?

If so I agree that this seems like a bug fix that we should accept. I'm going to cc @rust-lang/lang just in case there's disagreement but it seems obvious to me that we should rather reject mod foo; in blocks than essentially silently ignore it.

@petrochenkov
Copy link
Contributor

Everything in doctests is in a block, AFAIK?

However, if it wasn't, rustdoc would still turn mod foo; to mod foo {} due to the way it called parser for doctests.

@nikomatsakis
Copy link
Contributor

I agree this seems like a bug fix, yes.

@jyn514 jyn514 removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Feb 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression-from-stable-to-beta Performance or correctness regression from stable to beta. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants