Skip to content

Commit 3a5b794

Browse files
committed
Rename visit_mod and simplify arguments
1 parent f0b1898 commit 3a5b794

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

src/modules.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use thiserror::Error;
1111

1212
use crate::attr::MetaVisitor;
1313
use crate::config::FileName;
14-
use crate::items::is_mod_decl;
1514
use crate::parse::parser::{
1615
Directory, DirectoryOwnership, ModError, ModulePathSuccess, Parser, ParserError,
1716
};
@@ -179,36 +178,37 @@ impl<'ast, 'sess> ModResolver<'ast, 'sess> {
179178
for item in items {
180179
if is_cfg_if(item) {
181180
self.visit_cfg_if(item)?;
182-
} else if let ast::ItemKind::Mod(_, sub_mod_kind) = &item.kind {
183-
self.visit_sub_mod(&item, Module::new(item.span, Some(sub_mod_kind), &[], &[]))?;
181+
} else if let ast::ItemKind::Mod(_, mod_kind) = &item.kind {
182+
self.visit_mod(&item, mod_kind)?;
184183
}
185184
}
186185
Ok(())
187186
}
188187

189-
fn visit_sub_mod(
188+
fn visit_mod(
190189
&mut self,
191190
item: &'ast ast::Item,
192-
sub_mod: Module<'ast>,
191+
mod_kind: &'ast ast::ModKind,
193192
) -> Result<(), ModuleResolutionError> {
194193
if contains_skip(&item.attrs) {
195194
return Ok(());
196195
}
197-
if is_mod_decl(item) {
198-
// mod foo;
199-
// Look for an extern file.
200-
let Some(kind) = self.find_external_module(item)? else {
201-
return Ok(());
202-
};
203-
self.insert_sub_mod(kind.clone())?;
204-
self.visit_sub_mod_inner(kind)?;
205-
} else {
206-
// An internal module (`mod foo { /* ... */ }`);
207-
let directory = self.inline_mod_directory(item.ident, &item.attrs);
208-
self.with_directory(directory, |this| {
209-
this.visit_sub_mod_after_directory_update(sub_mod)
210-
})?;
211-
};
196+
match mod_kind {
197+
ast::ModKind::Loaded(items, ast::Inline::Yes, _) => {
198+
// An internal module (`mod foo { /* ... */ }`);
199+
let directory = self.inline_mod_directory(item.ident, &item.attrs);
200+
self.with_directory(directory, |this| this.visit_items(items))?;
201+
}
202+
_ => {
203+
// mod foo;
204+
// Look for an extern file.
205+
let Some(kind) = self.find_external_module(item)? else {
206+
return Ok(());
207+
};
208+
self.insert_sub_mod(kind.clone())?;
209+
self.visit_sub_mod_inner(kind)?;
210+
}
211+
}
212212
Ok(())
213213
}
214214

0 commit comments

Comments
 (0)