Skip to content

Commit 87565c4

Browse files
authored
Merge pull request #3607 from topecongiro/issue-3493
Ignore sub-modules when skip-children is used
2 parents eea8af0 + 788a4cb commit 87565c4

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

src/formatting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ fn format_project<T: FormatHandler>(
101101
let files = modules::ModResolver::new(
102102
context.parse_session.source_map(),
103103
directory_ownership.unwrap_or(parse::DirectoryOwnership::UnownedViaMod(false)),
104-
input_is_stdin,
104+
!(input_is_stdin || config.skip_children()),
105105
)
106106
.visit_crate(&krate)
107107
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;

src/modules.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub(crate) struct ModResolver<'a, 'b> {
1818
source_map: &'b source_map::SourceMap,
1919
directory: Directory,
2020
file_map: FileModMap<'a>,
21-
is_input_stdin: bool,
21+
recursive: bool,
2222
}
2323

2424
#[derive(Clone)]
@@ -32,7 +32,7 @@ impl<'a, 'b> ModResolver<'a, 'b> {
3232
pub(crate) fn new(
3333
source_map: &'b source_map::SourceMap,
3434
directory_ownership: DirectoryOwnership,
35-
is_input_stdin: bool,
35+
recursive: bool,
3636
) -> Self {
3737
ModResolver {
3838
directory: Directory {
@@ -41,7 +41,7 @@ impl<'a, 'b> ModResolver<'a, 'b> {
4141
},
4242
file_map: BTreeMap::new(),
4343
source_map,
44-
is_input_stdin,
44+
recursive,
4545
}
4646
}
4747

@@ -57,7 +57,7 @@ impl<'a, 'b> ModResolver<'a, 'b> {
5757
};
5858

5959
// Skip visiting sub modules when the input is from stdin.
60-
if !self.is_input_stdin {
60+
if self.recursive {
6161
self.visit_mod(&krate.module)?;
6262
}
6363

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
// rustfmt-skip_children: true
22

33
mod foo ;
4+
mod void;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
// rustfmt-skip_children: true
22

33
mod foo;
4+
mod void;

0 commit comments

Comments
 (0)