about summary refs log tree commit diff
path: root/src/librustc_parse
diff options
context:
space:
mode:
Diffstat (limited to 'src/librustc_parse')
-rw-r--r--src/librustc_parse/lib.rs23
-rw-r--r--src/librustc_parse/parser/mod.rs5
2 files changed, 5 insertions, 23 deletions
diff --git a/src/librustc_parse/lib.rs b/src/librustc_parse/lib.rs
index 58db7d286e7..13fb85db847 100644
--- a/src/librustc_parse/lib.rs
+++ b/src/librustc_parse/lib.rs
@@ -50,7 +50,7 @@ macro_rules! panictry_buffer {
 }
 
 pub fn parse_crate_from_file<'a>(input: &Path, sess: &'a ParseSess) -> PResult<'a, ast::Crate> {
-    let mut parser = new_parser_from_file(sess, input);
+    let mut parser = new_parser_from_file(sess, input, None);
     parser.parse_crate_mod()
 }
 
@@ -58,7 +58,7 @@ pub fn parse_crate_attrs_from_file<'a>(
     input: &Path,
     sess: &'a ParseSess,
 ) -> PResult<'a, Vec<ast::Attribute>> {
-    let mut parser = new_parser_from_file(sess, input);
+    let mut parser = new_parser_from_file(sess, input, None);
     parser.parse_inner_attributes()
 }
 
@@ -106,8 +106,9 @@ pub fn maybe_new_parser_from_source_str(
 }
 
 /// Creates a new parser, handling errors as appropriate if the file doesn't exist.
-pub fn new_parser_from_file<'a>(sess: &'a ParseSess, path: &Path) -> Parser<'a> {
-    source_file_to_parser(sess, file_to_source_file(sess, path, None))
+/// If a span is given, that is used on an error as the as the source of the problem.
+pub fn new_parser_from_file<'a>(sess: &'a ParseSess, path: &Path, sp: Option<Span>) -> Parser<'a> {
+    source_file_to_parser(sess, file_to_source_file(sess, path, sp))
 }
 
 /// Creates a new parser, returning buffered diagnostics if the file doesn't exist,
@@ -120,20 +121,6 @@ pub fn maybe_new_parser_from_file<'a>(
     maybe_source_file_to_parser(sess, file)
 }
 
-/// Given a session, a crate config, a path, and a span, add
-/// the file at the given path to the `source_map`, and returns a parser.
-/// On an error, uses the given span as the source of the problem.
-pub fn new_sub_parser_from_file<'a>(
-    sess: &'a ParseSess,
-    path: &Path,
-    module_name: Option<String>,
-    sp: Span,
-) -> Parser<'a> {
-    let mut p = source_file_to_parser(sess, file_to_source_file(sess, path, Some(sp)));
-    p.root_module_name = module_name;
-    p
-}
-
 /// Given a `source_file` and config, returns a parser.
 fn source_file_to_parser(sess: &ParseSess, source_file: Lrc<SourceFile>) -> Parser<'_> {
     panictry_buffer!(&sess.span_diagnostic, maybe_source_file_to_parser(sess, source_file))
diff --git a/src/librustc_parse/parser/mod.rs b/src/librustc_parse/parser/mod.rs
index bb6793d08aa..b987813e38d 100644
--- a/src/librustc_parse/parser/mod.rs
+++ b/src/librustc_parse/parser/mod.rs
@@ -88,10 +88,6 @@ pub struct Parser<'a> {
     /// The previous token.
     pub prev_token: Token,
     restrictions: Restrictions,
-    /// Name of the root module this parser originated from. If `None`, then the
-    /// name is not known. This does not change while the parser is descending
-    /// into modules, and sub-parsers have new values for this name.
-    pub root_module_name: Option<String>,
     expected_tokens: Vec<TokenType>,
     token_cursor: TokenCursor,
     desugar_doc_comments: bool,
@@ -350,7 +346,6 @@ impl<'a> Parser<'a> {
             token: Token::dummy(),
             prev_token: Token::dummy(),
             restrictions: Restrictions::empty(),
-            root_module_name: None,
             expected_tokens: Vec::new(),
             token_cursor: TokenCursor {
                 frame: TokenCursorFrame::new(DelimSpan::dummy(), token::NoDelim, &tokens),