]> git.lizzy.rs Git - rust.git/commitdiff
parse: nix unused `root_module_name`.
authorMazdak Farrokhzad <twingoow@gmail.com>
Sat, 21 Mar 2020 21:51:03 +0000 (22:51 +0100)
committerMazdak Farrokhzad <twingoow@gmail.com>
Sat, 21 Mar 2020 21:51:03 +0000 (22:51 +0100)
src/librustc_builtin_macros/source_util.rs
src/librustc_expand/mbe/macro_rules.rs
src/librustc_expand/module.rs
src/librustc_parse/lib.rs
src/librustc_parse/parser/mod.rs

index 718498f04b94ed56fbc63665559eb8cddb3a0367..3dfc5709b9103e9981bbd85344f2546e67ffbd25 100644 (file)
@@ -110,7 +110,7 @@ pub fn expand_include<'cx>(
             return DummyResult::any(sp);
         }
     };
-    let p = new_sub_parser_from_file(cx.parse_sess(), &file, None, sp);
+    let p = new_sub_parser_from_file(cx.parse_sess(), &file, sp);
 
     // If in the included file we have e.g., `mod bar;`,
     // then the path of `bar.rs` should be relative to the directory of `file`.
index 3de2169f1142e41560a76cdee472263724fbd08a..b6b69400bad434b323ae061548d26f085408268e 100644 (file)
@@ -259,8 +259,6 @@ fn generic_extension<'cx>(
                 }
 
                 let mut p = Parser::new(sess, tts, false, None);
-                p.root_module_name =
-                    cx.current_expansion.module.mod_path.last().map(|id| id.to_string());
                 p.last_type_ascription = cx.current_expansion.prior_type_ascription;
 
                 // Let the context choose how to interpret the result.
index 2d5e4d4e8894d8127dba4811a8f706ab5fadfc1e..a73e2a1355e6f3699a669b7519295b45f0403633 100644 (file)
@@ -59,9 +59,8 @@ pub struct ModulePathSuccess {
         *pop_mod_stack = true; // We have pushed, so notify caller.
         drop(included_mod_stack);
 
-        // Actually parse the external file as amodule.
-        let mut p0 = new_sub_parser_from_file(sess, &mp.path, Some(id.to_string()), span);
-        let mut module = p0.parse_mod(&token::Eof)?;
+        // Actually parse the external file as a module.
+        let mut module = new_sub_parser_from_file(sess, &mp.path, span).parse_mod(&token::Eof)?;
         module.0.inline = false;
         module
     };
index 58db7d286e7e65b003d71817fed6f7080d7ce677..112c733a81b8713739910c833e608db7682aa1f6 100644 (file)
@@ -120,18 +120,11 @@ 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.
+/// Given a session, 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
+pub fn new_sub_parser_from_file<'a>(sess: &'a ParseSess, path: &Path, sp: Span) -> Parser<'a> {
+    source_file_to_parser(sess, file_to_source_file(sess, path, Some(sp)))
 }
 
 /// Given a `source_file` and config, returns a parser.
index bb6793d08aa270dc24200d69cf5cc16e7fd0f4ea..b987813e38d982f88e88623593144f6cfa625a14 100644 (file)
@@ -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 @@ pub fn new(
             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),