-
Notifications
You must be signed in to change notification settings - Fork 889
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
fmt no longer finds modules inside inline modules #4874
Comments
Beta (
|
We haven't really had any changes on our end, much less anything that touched the mod resolver. Could you please run |
|
Thanks! Have a theory, will test it out later today |
Bisecting was a bit tricky since it was just a "rustfmt update", but 612e8d5 looks suspicious. Let us know if you need any help. |
thanks @ehuss in the ast prior to any kind of expansion, the bar mod item here would have a loaded/inline::yes kind wouldn't it? mod bar {
mod baz;
} if so it's probably an issue here. i'm stuck at work for several more hours but if anyone wants to take a pass at it in the interim i'd probably start looking here on that first arm Lines 320 to 325 in 6495024
|
Yea, from my understanding of rust-lang/rust@4a88165, it is loaded/inline::Yes. So maybe something like this could work: --- a/src/modules.rs
+++ b/src/modules.rs
@@ -318,7 +318,7 @@ impl<'ast, 'sess, 'c> ModResolver<'ast, 'sess> {
self.directory = directory;
}
match (sub_mod.ast_mod_kind, sub_mod.items) {
- (Some(Cow::Borrowed(ast::ModKind::Loaded(items, ast::Inline::No, _))), _) => {
+ (Some(Cow::Borrowed(ast::ModKind::Loaded(items, ast::Inline::Yes, _))), _) => {
self.visit_mod_from_ast(&items)
}
(Some(Cow::Owned(..)), Cow::Owned(items)) => self.visit_mod_outside_ast(items), However, from what I can tell, rustfmt does not format post-expansion loaded modules. I'm not too familiar with rustfmt, but is it known or intended that does not work? For example: macro_rules! foo {
() => {
mod foo;
};
}
foo! {} Here, |
You are correct and yes it's known/expected. There's a few exceptions, such as Probably a couple options for extending support for those types of cases, but I'd expect it to be a sizeable undertaking that'd be a relatively low priority compared to some other items on our backlog. |
…ion, r=Mark-Simulacrum rustfmt: load nested out-of-line mods correctly This should address rust-lang/rustfmt#4874 r? `@Mark-Simulacrum` Decided to make the change directly in tree here for expediency/to minimize any potential backporting issues, and because there's some subtree sync items I need to get resolved before pulling from r-l/rustfmt
The fix has been applied in the rustc repo and should be in the latest nightly so going to close |
If this affects beta or stable versions (i.e. not just nightly) then should it remain open (at least until there's a decision about whether to backport the thing to beta/stable)? That is the policy we use for or maybe the point is that the real bug needs to be tracked on the rustc repo, not the rustfmt repo... hmm. |
We've always closed our issues as they are fixed in source, and don't base our issue status on release/channel propagation upstream. In my opinion backport nominations/status are far better handled in rustc and I don't want to attempt to try to duplicate/mirror that here. Although I'd personally encourage proceeding with the backport, that's a separate concern from the bug being fixed, and whether or not backporting happens is obviously a decision outside our control.
No, development and maintenance of rustfmt happens here and our issues need to continue to be managed here as well. I'm not sure if it makes sense to have a separate tracking-like issue in rustc for the backporting piece, but I don't want to bifurcate our issue tracker across two repos. |
…rk-Simulacrum rustfmt: load nested out-of-line mods correctly This should address rust-lang#4874 r? `@Mark-Simulacrum` Decided to make the change directly in tree here for expediency/to minimize any potential backporting issues, and because there's some subtree sync items I need to get resolved before pulling from r-l/rustfmt
Problem
cargo fmt
no longer processes modules that are referenced in an inline mod.Steps
crate tree:
src/main.rs:
src/foo.rs:
mod qux;
src/foo/qux.rs: empty
src/bar/baz.rs: empty
Stable is fine:
Nightly is broken:
Notes
Output of
cargo version
:cargo 1.54.0-nightly (44456677b 2021-06-12)
cargo 1.52.0 (69767412a 2021-04-21)
Rust via rustup 1.24.3, Arch Linux.
The text was updated successfully, but these errors were encountered: