Skip to content

Commit 50461ef

Browse files
Remove strip prefix
1 parent 970154e commit 50461ef

File tree

2 files changed

+3
-17
lines changed

2 files changed

+3
-17
lines changed

src/libsyntax/parse/parser.rs

+2-16
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ use symbol::{Symbol, keywords};
5757
use util::ThinVec;
5858

5959
use std::collections::HashSet;
60-
use std::env;
6160
use std::mem;
6261
use std::path::{Path, PathBuf};
6362
use std::rc::Rc;
@@ -5133,24 +5132,11 @@ impl<'a> Parser<'a> {
51335132
let mut err = self.diagnostic().struct_span_err(id_sp,
51345133
"cannot declare a new module at this location");
51355134
if id_sp != syntax_pos::DUMMY_SP {
5136-
let mut src_path = PathBuf::from(self.sess.codemap().span_to_filename(id_sp));
5135+
let src_path = PathBuf::from(self.sess.codemap().span_to_filename(id_sp));
51375136
if let Some(stem) = src_path.clone().file_stem() {
51385137
let mut dest_path = src_path.clone();
51395138
dest_path.set_file_name(stem);
51405139
dest_path.push("mod.rs");
5141-
if let Ok(cur_dir) = env::current_dir() {
5142-
let tmp = if let (Ok(src_path), Ok(dest_path)) =
5143-
(Path::new(&src_path).strip_prefix(&cur_dir),
5144-
Path::new(&dest_path).strip_prefix(&cur_dir)) {
5145-
Some((src_path.to_path_buf(), dest_path.to_path_buf()))
5146-
} else {
5147-
None
5148-
};
5149-
if let Some(tmp) = tmp {
5150-
src_path = tmp.0;
5151-
dest_path = tmp.1;
5152-
}
5153-
}
51545140
err.span_note(id_sp,
51555141
&format!("maybe move this module `{}` to its own \
51565142
directory via `{}`", src_path.to_string_lossy(),
@@ -5167,7 +5153,7 @@ impl<'a> Parser<'a> {
51675153
} else {
51685154
match paths.result {
51695155
Ok(succ) => Ok(succ),
5170-
Err(err) => Err(self.span_fatal_err(id_sp, &err.err_msg, &err.help_msg)),
5156+
Err(err) => Err(self.span_fatal_err(id_sp, err)),
51715157
}
51725158
}
51735159
}

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

+1-1
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)