Merge pull request #3607 from topecongiro/issue-3493
Ignore sub-modules when skip-children is used
This commit is contained in:
commit
87565c42ce
@ -101,7 +101,7 @@ fn format_project<T: FormatHandler>(
|
||||
let files = modules::ModResolver::new(
|
||||
context.parse_session.source_map(),
|
||||
directory_ownership.unwrap_or(parse::DirectoryOwnership::UnownedViaMod(false)),
|
||||
input_is_stdin,
|
||||
!(input_is_stdin || config.skip_children()),
|
||||
)
|
||||
.visit_crate(&krate)
|
||||
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
|
||||
|
@ -18,7 +18,7 @@ pub(crate) struct ModResolver<'a, 'b> {
|
||||
source_map: &'b source_map::SourceMap,
|
||||
directory: Directory,
|
||||
file_map: FileModMap<'a>,
|
||||
is_input_stdin: bool,
|
||||
recursive: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -32,7 +32,7 @@ impl<'a, 'b> ModResolver<'a, 'b> {
|
||||
pub(crate) fn new(
|
||||
source_map: &'b source_map::SourceMap,
|
||||
directory_ownership: DirectoryOwnership,
|
||||
is_input_stdin: bool,
|
||||
recursive: bool,
|
||||
) -> Self {
|
||||
ModResolver {
|
||||
directory: Directory {
|
||||
@ -41,7 +41,7 @@ pub(crate) fn new(
|
||||
},
|
||||
file_map: BTreeMap::new(),
|
||||
source_map,
|
||||
is_input_stdin,
|
||||
recursive,
|
||||
}
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ pub(crate) fn visit_crate(mut self, krate: &'a ast::Crate) -> Result<FileModMap<
|
||||
};
|
||||
|
||||
// Skip visiting sub modules when the input is from stdin.
|
||||
if !self.is_input_stdin {
|
||||
if self.recursive {
|
||||
self.visit_mod(&krate.module)?;
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
// rustfmt-skip_children: true
|
||||
|
||||
mod foo ;
|
||||
mod void;
|
||||
|
@ -1,3 +1,4 @@
|
||||
// rustfmt-skip_children: true
|
||||
|
||||
mod foo;
|
||||
mod void;
|
||||
|
Loading…
Reference in New Issue
Block a user