Skip to content

Commit d18ed20

Browse files
committed
parse: nix unused root_module_name.
1 parent 38114ff commit d18ed20

File tree

5 files changed

+7
-22
lines changed

5 files changed

+7
-22
lines changed

src/librustc_builtin_macros/source_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ pub fn expand_include<'cx>(
110110
return DummyResult::any(sp);
111111
}
112112
};
113-
let p = new_sub_parser_from_file(cx.parse_sess(), &file, None, sp);
113+
let p = new_sub_parser_from_file(cx.parse_sess(), &file, sp);
114114

115115
// If in the included file we have e.g., `mod bar;`,
116116
// then the path of `bar.rs` should be relative to the directory of `file`.

src/librustc_expand/mbe/macro_rules.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,6 @@ fn generic_extension<'cx>(
259259
}
260260

261261
let mut p = Parser::new(sess, tts, false, None);
262-
p.root_module_name =
263-
cx.current_expansion.module.mod_path.last().map(|id| id.to_string());
264262
p.last_type_ascription = cx.current_expansion.prior_type_ascription;
265263

266264
// Let the context choose how to interpret the result.

src/librustc_expand/module.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,8 @@ crate fn parse_external_mod(
5959
*pop_mod_stack = true; // We have pushed, so notify caller.
6060
drop(included_mod_stack);
6161

62-
// Actually parse the external file as amodule.
63-
let mut p0 = new_sub_parser_from_file(sess, &mp.path, Some(id.to_string()), span);
64-
let mut module = p0.parse_mod(&token::Eof)?;
62+
// Actually parse the external file as a module.
63+
let mut module = new_sub_parser_from_file(sess, &mp.path, span).parse_mod(&token::Eof)?;
6564
module.0.inline = false;
6665
module
6766
};

src/librustc_parse/lib.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,18 +120,11 @@ pub fn maybe_new_parser_from_file<'a>(
120120
maybe_source_file_to_parser(sess, file)
121121
}
122122

123-
/// Given a session, a crate config, a path, and a span, add
124-
/// the file at the given path to the `source_map`, and returns a parser.
123+
/// Given a session, a path, and a span,
124+
/// add the file at the given path to the `source_map`, and returns a parser.
125125
/// On an error, uses the given span as the source of the problem.
126-
pub fn new_sub_parser_from_file<'a>(
127-
sess: &'a ParseSess,
128-
path: &Path,
129-
module_name: Option<String>,
130-
sp: Span,
131-
) -> Parser<'a> {
132-
let mut p = source_file_to_parser(sess, file_to_source_file(sess, path, Some(sp)));
133-
p.root_module_name = module_name;
134-
p
126+
pub fn new_sub_parser_from_file<'a>(sess: &'a ParseSess, path: &Path, sp: Span) -> Parser<'a> {
127+
source_file_to_parser(sess, file_to_source_file(sess, path, Some(sp)))
135128
}
136129

137130
/// Given a `source_file` and config, returns a parser.

src/librustc_parse/parser/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,6 @@ pub struct Parser<'a> {
8888
/// The previous token.
8989
pub prev_token: Token,
9090
restrictions: Restrictions,
91-
/// Name of the root module this parser originated from. If `None`, then the
92-
/// name is not known. This does not change while the parser is descending
93-
/// into modules, and sub-parsers have new values for this name.
94-
pub root_module_name: Option<String>,
9591
expected_tokens: Vec<TokenType>,
9692
token_cursor: TokenCursor,
9793
desugar_doc_comments: bool,
@@ -350,7 +346,6 @@ impl<'a> Parser<'a> {
350346
token: Token::dummy(),
351347
prev_token: Token::dummy(),
352348
restrictions: Restrictions::empty(),
353-
root_module_name: None,
354349
expected_tokens: Vec::new(),
355350
token_cursor: TokenCursor {
356351
frame: TokenCursorFrame::new(DelimSpan::dummy(), token::NoDelim, &tokens),

0 commit comments

Comments
 (0)