about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2020-03-07 19:41:24 +0100
committerMazdak Farrokhzad <twingoow@gmail.com>2020-03-18 15:08:25 +0100
commit803de3188c59ecc782db46e3fc9e9f668e260be9 (patch)
tree866e9501e9da160235cd51dde25b9d272740c0a5
parent2db5d49d4791723b5335d5b66a0e2c304bf37d4c (diff)
downloadrust-803de3188c59ecc782db46e3fc9e9f668e260be9.tar.gz
rust-803de3188c59ecc782db46e3fc9e9f668e260be9.zip
submod_path: use id.span
-rw-r--r--src/librustc_parse/parser/module.rs12
-rw-r--r--src/test/ui/directory_ownership/macro-expanded-mod.rs6
-rw-r--r--src/test/ui/directory_ownership/macro-expanded-mod.stderr9
3 files changed, 11 insertions, 16 deletions
diff --git a/src/librustc_parse/parser/module.rs b/src/librustc_parse/parser/module.rs
index c426b073a05..45387999196 100644
--- a/src/librustc_parse/parser/module.rs
+++ b/src/librustc_parse/parser/module.rs
@@ -45,14 +45,13 @@ impl<'a> Parser<'a> {
     pub(super) fn parse_item_mod(&mut self, attrs: &mut Vec<Attribute>) -> PResult<'a, ItemInfo> {
         let in_cfg = crate::config::process_configure_mod(self.sess, self.cfg_mods, attrs);
 
-        let id_span = self.token.span;
         let id = self.parse_ident()?;
         let (module, mut inner_attrs) = if self.eat(&token::Semi) {
             if in_cfg && self.recurse_into_file_modules {
                 // This mod is in an external file. Let's go get it!
                 let ModulePathSuccess { path, directory_ownership } =
-                    self.submod_path(id, &attrs, id_span)?;
-                self.eval_src_mod(path, directory_ownership, id.to_string(), id_span)?
+                    self.submod_path(id, &attrs)?;
+                self.eval_src_mod(path, directory_ownership, id.to_string(), id.span)?
             } else {
                 (ast::Mod { inner: DUMMY_SP, items: Vec::new(), inline: false }, Vec::new())
             }
@@ -99,7 +98,6 @@ impl<'a> Parser<'a> {
         &mut self,
         id: ast::Ident,
         outer_attrs: &[Attribute],
-        id_sp: Span,
     ) -> PResult<'a, ModulePathSuccess> {
         if let Some(path) = Parser::submod_path_from_attr(outer_attrs, &self.directory.path) {
             let directory_ownership = match path.file_name().and_then(|s| s.to_str()) {
@@ -125,10 +123,10 @@ impl<'a> Parser<'a> {
 
         match self.directory.ownership {
             DirectoryOwnership::Owned { .. } => {
-                paths.result.map_err(|err| self.span_fatal_err(id_sp, err))
+                paths.result.map_err(|err| self.span_fatal_err(id.span, err))
             }
-            DirectoryOwnership::UnownedViaBlock => self.error_decl_mod_in_block(id_sp, paths),
-            DirectoryOwnership::UnownedViaMod => self.error_cannot_declare_mod_here(id_sp, paths),
+            DirectoryOwnership::UnownedViaBlock => self.error_decl_mod_in_block(id.span, paths),
+            DirectoryOwnership::UnownedViaMod => self.error_cannot_declare_mod_here(id.span, paths),
         }
     }
 
diff --git a/src/test/ui/directory_ownership/macro-expanded-mod.rs b/src/test/ui/directory_ownership/macro-expanded-mod.rs
index 376c1a9cd66..1066a2ba712 100644
--- a/src/test/ui/directory_ownership/macro-expanded-mod.rs
+++ b/src/test/ui/directory_ownership/macro-expanded-mod.rs
@@ -1,7 +1,9 @@
 // Test that macro-expanded non-inline modules behave correctly
 
 macro_rules! mod_decl {
-    ($i:ident) => { mod $i; } //~ ERROR Cannot declare a non-inline module inside a block
+    ($i:ident) => {
+        mod $i;
+    };
 }
 
 mod macro_expanded_mod_helper {
@@ -9,5 +11,5 @@ mod macro_expanded_mod_helper {
 }
 
 fn main() {
-    mod_decl!(foo);
+    mod_decl!(foo); //~ ERROR Cannot declare a non-inline module inside a block
 }
diff --git a/src/test/ui/directory_ownership/macro-expanded-mod.stderr b/src/test/ui/directory_ownership/macro-expanded-mod.stderr
index c7780c869d6..d9d8a8ffed7 100644
--- a/src/test/ui/directory_ownership/macro-expanded-mod.stderr
+++ b/src/test/ui/directory_ownership/macro-expanded-mod.stderr
@@ -1,13 +1,8 @@
 error: Cannot declare a non-inline module inside a block unless it has a path attribute
-  --> $DIR/macro-expanded-mod.rs:4:25
+  --> $DIR/macro-expanded-mod.rs:14:15
    |
-LL |     ($i:ident) => { mod $i; }
-   |                         ^^
-...
 LL |     mod_decl!(foo);
-   |     --------------- in this macro invocation
-   |
-   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
+   |               ^^^
 
 error: aborting due to previous error