Skip to content

Rollup of 15 pull requests #41539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 40 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
a42c025
Add bootstrap support for android
malbarbo Apr 18, 2017
c49d090
Specify behavior of `write_all` for `ErrorKind::Interrupted` errors
tbu- Apr 21, 2017
e1afddc
Haiku: fix initial platform support
jessicah Apr 22, 2017
f8c6436
Step::replace_one should put a one, not a zero (Issue #41492)
scottmcm Apr 24, 2017
f852e3f
use the word 'length' in Vec::len's docs
steveklabnik Apr 24, 2017
e482529
Fix invalid module suggestion
GuillaumeGomez Dec 9, 2016
bd880bc
Add tests for module suggestions
GuillaumeGomez Jan 3, 2017
b10c044
Remove strip prefix
GuillaumeGomez Feb 25, 2017
0d63f13
Haiku: add missing cases of using LIBRARY_PATH
jessicah Apr 24, 2017
957d51a
Fix a copy-paste error in `Instant::sub_duration`
tbu- Apr 24, 2017
70e6739
Adds rust-windbg.cmd script
AndrewGaspar Feb 20, 2017
a765dca
Add internal accessor methods to io::{Chain, Take}.
SergioBenitez Apr 22, 2017
aab87e3
Add more_io_inner_methods feature to unstable book.
SergioBenitez Apr 22, 2017
76397ae
Reference tracking issue for more_io_inner_methods.
SergioBenitez Apr 24, 2017
c168d8b
Add cautions to io::get_mut method documentation.
SergioBenitez Apr 24, 2017
93d57d6
Pass `--format-version 1` to `cargo metadata`.
kennytm Apr 17, 2017
00dff0a
Support AddressSanitizer and ThreadSanitizer on x86_64-apple-darwin.
kennytm Apr 17, 2017
86747a9
Force link with an absolute rpath when using sanitizer on macOS.
kennytm Apr 20, 2017
3b33913
appveyor: Upgrade to gcc for mingw 6.3.0
alexcrichton Apr 20, 2017
ca96892
Clean up TcpStream example
steveklabnik Apr 25, 2017
dce33e9
Clarify the doc index
steveklabnik Apr 25, 2017
696df71
Clarify "side effect" in peek's docs
steveklabnik Apr 25, 2017
3f97b2a
Add ui tests
GuillaumeGomez Apr 24, 2017
164fd69
Do not check if libclang_rt.?san_*_dynamic.dylib is an unstable crate.
kennytm Apr 25, 2017
19b7272
Fix up vec guarnatee around capacity
steveklabnik Apr 25, 2017
c4db48c
Rollup merge of #39983 - AndrewGaspar:rust-windbg, r=brson
Apr 25, 2017
e7d78e7
Rollup merge of #41352 - kennytm:macos-sanitizers, r=alexcrichton
Apr 25, 2017
81e1281
Rollup merge of #41370 - malbarbo:android-bootstrap, r=alexcrichton
Apr 25, 2017
38fb097
Rollup merge of #41420 - alexcrichton:mingw-6.3.0, r=petrochenkov
Apr 25, 2017
2af895c
Rollup merge of #41442 - tbu-:pr_writeall_interrupted, r=aturon
Apr 25, 2017
f7ad2df
Rollup merge of #41456 - jessicah:haiku-support, r=alexcrichton
Apr 25, 2017
9e6641a
Rollup merge of #41463 - SergioBenitez:master, r=alexcrichton
Apr 25, 2017
adbca82
Rollup merge of #41493 - scottmcm:fix-step-replace, r=sfackler
Apr 25, 2017
7a910ad
Rollup merge of #41500 - steveklabnik:gh37866, r=frewsxcv
Apr 25, 2017
5f9eb73
Rollup merge of #41501 - GuillaumeGomez:invalid_module_location, r=js…
Apr 25, 2017
1eb4e5a
Rollup merge of #41518 - tbu-:pr_fix_cp_error, r=sfackler
Apr 25, 2017
f8b265e
Rollup merge of #41526 - steveklabnik:gh35950, r=GuillaumeGomez
Apr 25, 2017
f52af0b
Rollup merge of #41527 - steveklabnik:gh41285, r=frewsxcv
Apr 25, 2017
72dc0f0
Rollup merge of #41528 - steveklabnik:gh33269, r=frewsxcv
Apr 25, 2017
8ccf0e8
Rollup merge of #41535 - steveklabnik:gh37746, r=alexcrichton
Apr 25, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ use tokenstream::{self, Delimited, ThinTokenStream, TokenTree, TokenStream};
use symbol::{Symbol, keywords};
use util::ThinVec;

use std::cmp;
use std::collections::HashSet;
use std::{cmp, mem, slice};
use std::mem;
use std::path::{self, Path, PathBuf};
use std::slice;

bitflags! {
flags Restrictions: u8 {
Expand Down Expand Up @@ -5363,24 +5365,25 @@ impl<'a> Parser<'a> {
}
let mut err = self.diagnostic().struct_span_err(id_sp,
"cannot declare a new module at this location");
let this_module = match self.directory.path.file_name() {
Some(file_name) => file_name.to_str().unwrap().to_owned(),
None => self.root_module_name.as_ref().unwrap().clone(),
};
err.span_note(id_sp,
&format!("maybe move this module `{0}` to its own directory \
via `{0}{1}mod.rs`",
this_module,
path::MAIN_SEPARATOR));
if id_sp != syntax_pos::DUMMY_SP {
let src_path = PathBuf::from(self.sess.codemap().span_to_filename(id_sp));
if let Some(stem) = src_path.file_stem() {
let mut dest_path = src_path.clone();
dest_path.set_file_name(stem);
dest_path.push("mod.rs");
err.span_note(id_sp,
&format!("maybe move this module `{}` to its own \
directory via `{}`", src_path.to_string_lossy(),
dest_path.to_string_lossy()));
}
}
if paths.path_exists {
err.span_note(id_sp,
&format!("... or maybe `use` the module `{}` instead \
of possibly redeclaring it",
paths.name));
Err(err)
} else {
Err(err)
}
Err(err)
} else {
paths.result.map_err(|err| self.span_fatal_err(id_sp, err))
}
Expand Down
11 changes: 11 additions & 0 deletions src/test/ui/invalid-module-declaration/auxiliary/foo/bar.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

pub mod baz;
11 changes: 11 additions & 0 deletions src/test/ui/invalid-module-declaration/auxiliary/foo/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

pub mod bar;
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// ignore-tidy-linelength

// error-pattern: cannot declare a new module at this location
// error-pattern: maybe move this module

mod auxiliary {
mod foo;
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
error: cannot declare a new module at this location
--> $DIR/auxiliary/foo/bar.rs:11:9
|
11 | pub mod baz;
| ^^^
|
note: maybe move this module `$DIR/auxiliary/foo/bar.rs` to its own directory via `$DIR/auxiliary/foo/bar/mod.rs`
--> $DIR/auxiliary/foo/bar.rs:11:9
|
11 | pub mod baz;
| ^^^

error: aborting due to previous error