]> git.lizzy.rs Git - rust.git/commitdiff
Remove strip prefix
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Sat, 25 Feb 2017 16:08:46 +0000 (17:08 +0100)
committerGuillaume Gomez <guillaume1.gomez@gmail.com>
Mon, 24 Apr 2017 13:16:52 +0000 (15:16 +0200)
src/libsyntax/parse/parser.rs
src/test/compile-fail/invalid-module-declaration.rs

index ac72d21ec4271dd3a1f2a3d128023482eb16a65e..9df791c1c124efb48ee6b096f40bc2aed6aad298 100644 (file)
@@ -58,7 +58,6 @@
 use util::ThinVec;
 
 use std::collections::HashSet;
-use std::env;
 use std::mem;
 use std::path::{Path, PathBuf};
 use std::rc::Rc;
@@ -5367,24 +5366,11 @@ fn submod_path(&mut self,
             let mut err = self.diagnostic().struct_span_err(id_sp,
                 "cannot declare a new module at this location");
             if id_sp != syntax_pos::DUMMY_SP {
-                let mut src_path = PathBuf::from(self.sess.codemap().span_to_filename(id_sp));
+                let src_path = PathBuf::from(self.sess.codemap().span_to_filename(id_sp));
                 if let Some(stem) = src_path.clone().file_stem() {
                     let mut dest_path = src_path.clone();
                     dest_path.set_file_name(stem);
                     dest_path.push("mod.rs");
-                    if let Ok(cur_dir) = env::current_dir() {
-                        let tmp = if let (Ok(src_path), Ok(dest_path)) =
-                            (Path::new(&src_path).strip_prefix(&cur_dir),
-                             Path::new(&dest_path).strip_prefix(&cur_dir)) {
-                            Some((src_path.to_path_buf(), dest_path.to_path_buf()))
-                        } else {
-                            None
-                        };
-                        if let Some(tmp) = tmp {
-                            src_path = tmp.0;
-                            dest_path = tmp.1;
-                        }
-                    }
                     err.span_note(id_sp,
                                   &format!("maybe move this module `{}` to its own \
                                             directory via `{}`", src_path.to_string_lossy(),
@@ -5401,7 +5387,7 @@ fn submod_path(&mut self,
         } else {
             match paths.result {
                 Ok(succ) => Ok(succ),
-                Err(err) => Err(self.span_fatal_err(id_sp, &err.err_msg, &err.help_msg)),
+                Err(err) => Err(self.span_fatal_err(id_sp, err)),
             }
         }
     }
index 658fa0a65c47f0a1865367d48aa9848bd56d2660..c15cfb8cc8e220f6b02f5b3c187ec33399dbbf88 100644 (file)
@@ -11,7 +11,7 @@
 // ignore-tidy-linelength
 
 // error-pattern: cannot declare a new module at this location
-// error-pattern: maybe move this module `src/test/compile-fail/auxiliary/foo/bar.rs` to its own directory via `src/test/compile-fail/auxiliary/foo/bar/mod.rs`
+// error-pattern: maybe move this module
 
 mod auxiliary {
     mod foo;