mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-02 03:33:59 +00:00
Rollup merge of #55968 - ehuss:non-mod-rs-tests, r=petrochenkov
Clean up some non-mod-rs stuff. This includes the following: - Remove unused `non_modrs_mods` from `ParseSess` which as only used for feature gate diagnostics. - Remove the vestiges of the feature gate tests in `test/ui`, they were only partially removed during stabilization. - Fix the run-pass test, it was accidentally removed during stabilization. - Add a ui test to verify error behavior for missing inline-nested mods. - Add some tests for `#[path]` for inline-nested mods (both mod and non-mod-rs). - Enable the diagnostic tests on windows, they should be fixed by #49478. cc @cramertj
This commit is contained in:
commit
6ecbb05d76
@ -1890,7 +1890,6 @@ mod tests {
|
||||
missing_fragment_specifiers: Lock::new(FxHashSet::default()),
|
||||
raw_identifier_spans: Lock::new(Vec::new()),
|
||||
registered_diagnostics: Lock::new(ErrorMap::new()),
|
||||
non_modrs_mods: Lock::new(vec![]),
|
||||
buffered_lints: Lock::new(vec![]),
|
||||
}
|
||||
}
|
||||
|
@ -52,9 +52,6 @@ pub struct ParseSess {
|
||||
pub raw_identifier_spans: Lock<Vec<Span>>,
|
||||
/// The registered diagnostics codes
|
||||
crate registered_diagnostics: Lock<ErrorMap>,
|
||||
// Spans where a `mod foo;` statement was included in a non-mod.rs file.
|
||||
// These are used to issue errors if the non_modrs_mods feature is not enabled.
|
||||
pub non_modrs_mods: Lock<Vec<(ast::Ident, Span)>>,
|
||||
/// Used to determine and report recursive mod inclusions
|
||||
included_mod_stack: Lock<Vec<PathBuf>>,
|
||||
source_map: Lrc<SourceMap>,
|
||||
@ -81,7 +78,6 @@ impl ParseSess {
|
||||
registered_diagnostics: Lock::new(ErrorMap::new()),
|
||||
included_mod_stack: Lock::new(vec![]),
|
||||
source_map,
|
||||
non_modrs_mods: Lock::new(vec![]),
|
||||
buffered_lints: Lock::new(vec![]),
|
||||
}
|
||||
}
|
||||
|
@ -6591,16 +6591,7 @@ impl<'a> Parser<'a> {
|
||||
}
|
||||
|
||||
let relative = match self.directory.ownership {
|
||||
DirectoryOwnership::Owned { relative } => {
|
||||
// Push the usage onto the list of non-mod.rs mod uses.
|
||||
// This is used later for feature-gate error reporting.
|
||||
if let Some(cur_file_ident) = relative {
|
||||
self.sess
|
||||
.non_modrs_mods.borrow_mut()
|
||||
.push((cur_file_ident, id_sp));
|
||||
}
|
||||
relative
|
||||
},
|
||||
DirectoryOwnership::Owned { relative } => relative,
|
||||
DirectoryOwnership::UnownedViaBlock |
|
||||
DirectoryOwnership::UnownedViaMod(_) => None,
|
||||
};
|
||||
|
@ -12,3 +12,7 @@
|
||||
|
||||
pub mod inner_modrs_mod;
|
||||
pub mod inner_foors_mod;
|
||||
pub mod inline {
|
||||
#[path="somename.rs"]
|
||||
pub mod innie;
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
pub fn foo() {}
|
@ -0,0 +1 @@
|
||||
pub fn foo() {}
|
@ -10,3 +10,7 @@
|
||||
|
||||
pub mod inner_modrs_mod;
|
||||
pub mod inner_foors_mod;
|
||||
pub mod inline {
|
||||
#[path="somename.rs"]
|
||||
pub mod innie;
|
||||
}
|
||||
|
16
src/test/run-pass/non_modrs_mods/non_modrs_mods.rs
Normal file
16
src/test/run-pass/non_modrs_mods/non_modrs_mods.rs
Normal file
@ -0,0 +1,16 @@
|
||||
// run-pass
|
||||
//
|
||||
// ignore-pretty issue #37195
|
||||
pub mod modrs_mod;
|
||||
pub mod foors_mod;
|
||||
#[path = "some_crazy_attr_mod_dir/arbitrary_name.rs"]
|
||||
pub mod attr_mod;
|
||||
pub fn main() {
|
||||
modrs_mod::inner_modrs_mod::innest::foo();
|
||||
modrs_mod::inner_foors_mod::innest::foo();
|
||||
modrs_mod::inline::innie::foo();
|
||||
foors_mod::inner_modrs_mod::innest::foo();
|
||||
foors_mod::inner_foors_mod::innest::foo();
|
||||
foors_mod::inline::innie::foo();
|
||||
attr_mod::inner_modrs_mod::innest::foo();
|
||||
}
|
@ -9,7 +9,6 @@
|
||||
// except according to those terms.
|
||||
|
||||
// ignore-tidy-linelength
|
||||
// ignore-windows
|
||||
|
||||
mod auxiliary {
|
||||
mod foo;
|
||||
|
5
src/test/ui/missing_non_modrs_mod/foo_inline.rs
Normal file
5
src/test/ui/missing_non_modrs_mod/foo_inline.rs
Normal file
@ -0,0 +1,5 @@
|
||||
// ignore-test this is just a helper for the real test in this dir
|
||||
|
||||
mod inline {
|
||||
mod missing;
|
||||
}
|
@ -8,7 +8,5 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// ignore-windows
|
||||
|
||||
mod foo;
|
||||
fn main() {}
|
||||
|
@ -0,0 +1,2 @@
|
||||
mod foo_inline;
|
||||
fn main() {}
|
@ -0,0 +1,11 @@
|
||||
error[E0583]: file not found for module `missing`
|
||||
--> $DIR/foo_inline.rs:4:9
|
||||
|
|
||||
LL | mod missing;
|
||||
| ^^^^^^^
|
||||
|
|
||||
= help: name the file either missing.rs or missing/mod.rs inside the directory "$DIR/foo_inline/inline"
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0583`.
|
@ -1,14 +0,0 @@
|
||||
// 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.
|
||||
//
|
||||
// ignore-test: not a test, used by non_modrs_mods.rs
|
||||
|
||||
pub mod inner_modrs_mod;
|
||||
pub mod inner_foors_mod;
|
@ -1,11 +0,0 @@
|
||||
// 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 innest;
|
@ -1,11 +0,0 @@
|
||||
// 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 fn foo() {}
|
@ -1,11 +0,0 @@
|
||||
// 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 fn foo() {}
|
@ -1,11 +0,0 @@
|
||||
// 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 innest;
|
@ -1,11 +0,0 @@
|
||||
// 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 innest;
|
@ -1,11 +0,0 @@
|
||||
// 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 fn foo() {}
|
@ -1,11 +0,0 @@
|
||||
// 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 fn foo() {}
|
@ -1,11 +0,0 @@
|
||||
// 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 innest;
|
@ -1,12 +0,0 @@
|
||||
// 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 inner_modrs_mod;
|
||||
pub mod inner_foors_mod;
|
@ -1,11 +0,0 @@
|
||||
// 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 inner_modrs_mod;
|
@ -1,11 +0,0 @@
|
||||
// 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 fn foo() {}
|
@ -1,11 +0,0 @@
|
||||
// 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 innest;
|
Loading…
Reference in New Issue
Block a user