Skip to content

Commit b10c044

Browse files
Remove strip prefix
1 parent bd880bc commit b10c044

File tree

2 files changed

+3
-17
lines changed

2 files changed

+3
-17
lines changed

src/libsyntax/parse/parser.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ use symbol::{Symbol, keywords};
5858
use util::ThinVec;
5959

6060
use std::collections::HashSet;
61-
use std::env;
6261
use std::mem;
6362
use std::path::{Path, PathBuf};
6463
use std::rc::Rc;
@@ -5367,24 +5366,11 @@ impl<'a> Parser<'a> {
53675366
let mut err = self.diagnostic().struct_span_err(id_sp,
53685367
"cannot declare a new module at this location");
53695368
if id_sp != syntax_pos::DUMMY_SP {
5370-
let mut src_path = PathBuf::from(self.sess.codemap().span_to_filename(id_sp));
5369+
let src_path = PathBuf::from(self.sess.codemap().span_to_filename(id_sp));
53715370
if let Some(stem) = src_path.clone().file_stem() {
53725371
let mut dest_path = src_path.clone();
53735372
dest_path.set_file_name(stem);
53745373
dest_path.push("mod.rs");
5375-
if let Ok(cur_dir) = env::current_dir() {
5376-
let tmp = if let (Ok(src_path), Ok(dest_path)) =
5377-
(Path::new(&src_path).strip_prefix(&cur_dir),
5378-
Path::new(&dest_path).strip_prefix(&cur_dir)) {
5379-
Some((src_path.to_path_buf(), dest_path.to_path_buf()))
5380-
} else {
5381-
None
5382-
};
5383-
if let Some(tmp) = tmp {
5384-
src_path = tmp.0;
5385-
dest_path = tmp.1;
5386-
}
5387-
}
53885374
err.span_note(id_sp,
53895375
&format!("maybe move this module `{}` to its own \
53905376
directory via `{}`", src_path.to_string_lossy(),
@@ -5401,7 +5387,7 @@ impl<'a> Parser<'a> {
54015387
} else {
54025388
match paths.result {
54035389
Ok(succ) => Ok(succ),
5404-
Err(err) => Err(self.span_fatal_err(id_sp, &err.err_msg, &err.help_msg)),
5390+
Err(err) => Err(self.span_fatal_err(id_sp, err)),
54055391
}
54065392
}
54075393
}

src/test/compile-fail/invalid-module-declaration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// ignore-tidy-linelength
1212

1313
// error-pattern: cannot declare a new module at this location
14-
// 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`
14+
// error-pattern: maybe move this module
1515

1616
mod auxiliary {
1717
mod foo;

0 commit comments

Comments
 (0)