Skip to content

Commit e0d001e

Browse files
committed
extract parse_external_module
1 parent 75ad1b8 commit e0d001e

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/librustc_parse/parser/module.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,8 @@ impl<'a> Parser<'a> {
4444
let id = self.parse_ident()?;
4545
let (module, mut inner_attrs) = if self.eat(&token::Semi) {
4646
if in_cfg && self.recurse_into_file_modules {
47-
// This mod is in an external file. Let's go get it!
4847
let dir = &self.directory;
49-
submod_path(self.sess, id, &attrs, dir.ownership, &dir.path)
50-
.and_then(|r| eval_src_mod(self.sess, self.cfg_mods, r.path, r.ownership, id))
51-
.map_err(|mut err| err.emit())
52-
.unwrap_or_default()
48+
parse_external_module(self.sess, self.cfg_mods, id, dir.ownership, &dir.path, attrs)
5349
} else {
5450
Default::default()
5551
}
@@ -99,6 +95,20 @@ impl<'a> Parser<'a> {
9995
}
10096
}
10197

98+
fn parse_external_module(
99+
sess: &ParseSess,
100+
cfg_mods: bool,
101+
id: ast::Ident,
102+
ownership: DirectoryOwnership,
103+
dir_path: &Path,
104+
attrs: &[Attribute],
105+
) -> (Mod, Vec<Attribute>) {
106+
submod_path(sess, id, &attrs, ownership, dir_path)
107+
.and_then(|r| eval_src_mod(sess, cfg_mods, r.path, r.ownership, id))
108+
.map_err(|mut err| err.emit())
109+
.unwrap_or_default()
110+
}
111+
102112
/// Reads a module from a source file.
103113
fn eval_src_mod<'a>(
104114
sess: &'a ParseSess,

0 commit comments

Comments
 (0)