From 07f51fb8684e1ea0a3859234d360814093d891bd Mon Sep 17 00:00:00 2001 From: Taylor Cramer Date: Mon, 27 Nov 2017 18:14:24 -0800 Subject: [PATCH 1/4] Implement non-mod.rs mod statements --- src/libsyntax/ext/base.rs | 2 +- src/libsyntax/ext/expand.rs | 10 +- src/libsyntax/ext/source_util.rs | 2 +- src/libsyntax/feature_gate.rs | 34 ++++- src/libsyntax/parse/lexer/mod.rs | 1 + src/libsyntax/parse/mod.rs | 9 +- src/libsyntax/parse/parser.rs | 132 ++++++++++++------ .../backcompat-warnings.rs | 3 +- .../foo/compiletest-ignore-dir | 0 .../foo/mod_file_not_owning/aux2.rs | 9 ++ .../foo/mod_file_not_owning_aux2.rs | 9 ++ .../mod_file_not_owning.rs | 2 +- .../compiletest-ignore-dir | 0 .../mod_file_not_owning_aux2.rs | 9 ++ .../unowned_mod_with_path.rs | 2 +- src/test/run-pass/non_modrs_mods/foors_mod.rs | 14 ++ .../foors_mod/compiletest-ignore-dir | 0 .../foors_mod/inner_foors_mod.rs | 11 ++ .../foors_mod/inner_foors_mod/innest.rs | 11 ++ .../foors_mod/inner_modrs_mod/innest.rs | 11 ++ .../foors_mod/inner_modrs_mod/mod.rs | 11 ++ .../modrs_mod/compiletest-ignore-dir | 0 .../modrs_mod/inner_foors_mod.rs | 11 ++ .../modrs_mod/inner_foors_mod/innest.rs | 11 ++ .../modrs_mod/inner_modrs_mod/innest.rs | 11 ++ .../modrs_mod/inner_modrs_mod/mod.rs | 11 ++ .../run-pass/non_modrs_mods/modrs_mod/mod.rs | 12 ++ .../run-pass/non_modrs_mods/non_modrs_mods.rs | 24 ++++ .../some_crazy_attr_mod_dir/arbitrary_name.rs | 11 ++ .../attr_mod/inner_modrs_mod/innest.rs | 11 ++ .../attr_mod/inner_modrs_mod/mod.rs | 11 ++ .../compiletest-ignore-dir | 0 .../invalid-module-declaration.rs | 1 + .../invalid-module-declaration.stderr | 8 +- src/test/ui/missing_non_modrs_mod/foo.rs | 13 ++ .../missing_non_modrs_mod.rs | 14 ++ .../missing_non_modrs_mod.stderr | 10 ++ src/test/ui/non_modrs_mods/foors_mod.rs | 14 ++ .../foors_mod/compiletest-ignore-dir | 0 .../foors_mod/inner_foors_mod.rs | 11 ++ .../foors_mod/inner_foors_mod/innest.rs | 11 ++ .../foors_mod/inner_modrs_mod/innest.rs | 11 ++ .../foors_mod/inner_modrs_mod/mod.rs | 11 ++ .../modrs_mod/compiletest-ignore-dir | 0 .../modrs_mod/inner_foors_mod.rs | 11 ++ .../modrs_mod/inner_foors_mod/innest.rs | 11 ++ .../modrs_mod/inner_modrs_mod/innest.rs | 11 ++ .../modrs_mod/inner_modrs_mod/mod.rs | 11 ++ src/test/ui/non_modrs_mods/modrs_mod/mod.rs | 12 ++ src/test/ui/non_modrs_mods/non_modrs_mods.rs | 27 ++++ .../ui/non_modrs_mods/non_modrs_mods.stderr | 47 +++++++ .../some_crazy_attr_mod_dir/arbitrary_name.rs | 11 ++ .../attr_mod/inner_modrs_mod/innest.rs | 11 ++ .../attr_mod/inner_modrs_mod/mod.rs | 11 ++ .../compiletest-ignore-dir | 0 src/tools/tidy/src/features.rs | 3 +- 56 files changed, 604 insertions(+), 61 deletions(-) create mode 100644 src/test/compile-fail/directory_ownership/foo/compiletest-ignore-dir create mode 100644 src/test/compile-fail/directory_ownership/foo/mod_file_not_owning/aux2.rs create mode 100644 src/test/compile-fail/directory_ownership/foo/mod_file_not_owning_aux2.rs create mode 100644 src/test/compile-fail/directory_ownership/mod_file_not_owning_aux1/compiletest-ignore-dir create mode 100644 src/test/compile-fail/directory_ownership/mod_file_not_owning_aux1/mod_file_not_owning_aux2.rs create mode 100644 src/test/run-pass/non_modrs_mods/foors_mod.rs create mode 100644 src/test/run-pass/non_modrs_mods/foors_mod/compiletest-ignore-dir create mode 100644 src/test/run-pass/non_modrs_mods/foors_mod/inner_foors_mod.rs create mode 100644 src/test/run-pass/non_modrs_mods/foors_mod/inner_foors_mod/innest.rs create mode 100644 src/test/run-pass/non_modrs_mods/foors_mod/inner_modrs_mod/innest.rs create mode 100644 src/test/run-pass/non_modrs_mods/foors_mod/inner_modrs_mod/mod.rs create mode 100644 src/test/run-pass/non_modrs_mods/modrs_mod/compiletest-ignore-dir create mode 100644 src/test/run-pass/non_modrs_mods/modrs_mod/inner_foors_mod.rs create mode 100644 src/test/run-pass/non_modrs_mods/modrs_mod/inner_foors_mod/innest.rs create mode 100644 src/test/run-pass/non_modrs_mods/modrs_mod/inner_modrs_mod/innest.rs create mode 100644 src/test/run-pass/non_modrs_mods/modrs_mod/inner_modrs_mod/mod.rs create mode 100644 src/test/run-pass/non_modrs_mods/modrs_mod/mod.rs create mode 100644 src/test/run-pass/non_modrs_mods/non_modrs_mods.rs create mode 100644 src/test/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/arbitrary_name.rs create mode 100644 src/test/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/attr_mod/inner_modrs_mod/innest.rs create mode 100644 src/test/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/attr_mod/inner_modrs_mod/mod.rs create mode 100644 src/test/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/compiletest-ignore-dir create mode 100644 src/test/ui/missing_non_modrs_mod/foo.rs create mode 100644 src/test/ui/missing_non_modrs_mod/missing_non_modrs_mod.rs create mode 100644 src/test/ui/missing_non_modrs_mod/missing_non_modrs_mod.stderr create mode 100644 src/test/ui/non_modrs_mods/foors_mod.rs create mode 100644 src/test/ui/non_modrs_mods/foors_mod/compiletest-ignore-dir create mode 100644 src/test/ui/non_modrs_mods/foors_mod/inner_foors_mod.rs create mode 100644 src/test/ui/non_modrs_mods/foors_mod/inner_foors_mod/innest.rs create mode 100644 src/test/ui/non_modrs_mods/foors_mod/inner_modrs_mod/innest.rs create mode 100644 src/test/ui/non_modrs_mods/foors_mod/inner_modrs_mod/mod.rs create mode 100644 src/test/ui/non_modrs_mods/modrs_mod/compiletest-ignore-dir create mode 100644 src/test/ui/non_modrs_mods/modrs_mod/inner_foors_mod.rs create mode 100644 src/test/ui/non_modrs_mods/modrs_mod/inner_foors_mod/innest.rs create mode 100644 src/test/ui/non_modrs_mods/modrs_mod/inner_modrs_mod/innest.rs create mode 100644 src/test/ui/non_modrs_mods/modrs_mod/inner_modrs_mod/mod.rs create mode 100644 src/test/ui/non_modrs_mods/modrs_mod/mod.rs create mode 100644 src/test/ui/non_modrs_mods/non_modrs_mods.rs create mode 100644 src/test/ui/non_modrs_mods/non_modrs_mods.stderr create mode 100644 src/test/ui/non_modrs_mods/some_crazy_attr_mod_dir/arbitrary_name.rs create mode 100644 src/test/ui/non_modrs_mods/some_crazy_attr_mod_dir/attr_mod/inner_modrs_mod/innest.rs create mode 100644 src/test/ui/non_modrs_mods/some_crazy_attr_mod_dir/attr_mod/inner_modrs_mod/mod.rs create mode 100644 src/test/ui/non_modrs_mods/some_crazy_attr_mod_dir/compiletest-ignore-dir diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index 0eb4ec23d08a2..d53335f5be7fb 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -687,7 +687,7 @@ impl<'a> ExtCtxt<'a> { mark: Mark::root(), depth: 0, module: Rc::new(ModuleData { mod_path: Vec::new(), directory: PathBuf::new() }), - directory_ownership: DirectoryOwnership::Owned, + directory_ownership: DirectoryOwnership::Owned { relative: None }, }, expansions: HashMap::new(), } diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index f2346ed19de42..07ea6a0908688 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -976,7 +976,8 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> { if inline_module { if let Some(path) = attr::first_attr_value_str_by_name(&item.attrs, "path") { - self.cx.current_expansion.directory_ownership = DirectoryOwnership::Owned; + self.cx.current_expansion.directory_ownership = + DirectoryOwnership::Owned { relative: None }; module.directory.push(&*path.as_str()); } else { module.directory.push(&*item.ident.name.as_str()); @@ -988,8 +989,11 @@ impl<'a, 'b> Folder for InvocationCollector<'a, 'b> { other => PathBuf::from(other.to_string()), }; let directory_ownership = match path.file_name().unwrap().to_str() { - Some("mod.rs") => DirectoryOwnership::Owned, - _ => DirectoryOwnership::UnownedViaMod(false), + Some("mod.rs") => DirectoryOwnership::Owned { relative: None }, + Some(_) => DirectoryOwnership::Owned { + relative: Some(item.ident), + }, + None => DirectoryOwnership::UnownedViaMod(false), }; path.pop(); module.directory = path; diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs index 2a80686aa0f30..4da485fc9a42c 100644 --- a/src/libsyntax/ext/source_util.rs +++ b/src/libsyntax/ext/source_util.rs @@ -100,7 +100,7 @@ pub fn expand_include<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::T }; // The file will be added to the code map by the parser let path = res_rel_file(cx, sp, file); - let directory_ownership = DirectoryOwnership::Owned; + let directory_ownership = DirectoryOwnership::Owned { relative: None }; let p = parse::new_sub_parser_from_file(cx.parse_sess(), &path, directory_ownership, None, sp); struct ExpandResult<'a> { diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index ba534676324a9..a6946d18d67ea 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -35,7 +35,7 @@ use visit::{self, FnKind, Visitor}; use parse::ParseSess; use symbol::{keywords, Symbol}; -use std::env; +use std::{env, path}; macro_rules! set { (proc_macro) => {{ @@ -435,6 +435,9 @@ declare_features! ( // Resolve absolute paths as paths from other crates (active, extern_absolute_paths, "1.24.0", Some(44660)), + + // `foo.rs` as an alternative to `foo/mod.rs` + (active, non_modrs_mods, "1.24.0", Some(44660)), ); declare_features! ( @@ -1302,6 +1305,31 @@ fn contains_novel_literal(item: &ast::MetaItem) -> bool { } } +impl<'a> PostExpansionVisitor<'a> { + fn whole_crate_feature_gates(&mut self) { + for &(ident, span) in &*self.context.parse_sess.non_modrs_mods.borrow() { + if !span.allows_unstable() { + let cx = &self.context; + let level = GateStrength::Hard; + let has_feature = cx.features.non_modrs_mods; + let name = "non_modrs_mods"; + debug!("gate_feature(feature = {:?}, span = {:?}); has? {}", + name, span, has_feature); + + if !has_feature && !span.allows_unstable() { + leveled_feature_err( + cx.parse_sess, name, span, GateIssue::Language, + "mod statements in non-mod.rs files are unstable", level + ) + .help(&format!("on stable builds, rename this file to {}{}mod.rs", + ident, path::MAIN_SEPARATOR)) + .emit(); + } + } + } + } +} + impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { fn visit_attribute(&mut self, attr: &ast::Attribute) { if !attr.span.allows_unstable() { @@ -1854,7 +1882,9 @@ pub fn check_crate(krate: &ast::Crate, parse_sess: sess, plugin_attributes, }; - visit::walk_crate(&mut PostExpansionVisitor { context: &ctx }, krate); + let visitor = &mut PostExpansionVisitor { context: &ctx }; + visitor.whole_crate_feature_gates(); + visit::walk_crate(visitor, krate); } #[derive(Clone, Copy, PartialEq, Eq, Hash)] diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 1e84fb98a66f1..9828995362a35 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -1754,6 +1754,7 @@ mod tests { included_mod_stack: RefCell::new(Vec::new()), code_map: cm, missing_fragment_specifiers: RefCell::new(HashSet::new()), + non_modrs_mods: RefCell::new(vec![]), } } diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index 4d435665d3ca9..89a54989f9693 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -47,6 +47,9 @@ pub struct ParseSess { pub unstable_features: UnstableFeatures, pub config: CrateConfig, pub missing_fragment_specifiers: RefCell>, + // 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: RefCell>, /// Used to determine and report recursive mod inclusions included_mod_stack: RefCell>, code_map: Rc, @@ -70,6 +73,7 @@ impl ParseSess { missing_fragment_specifiers: RefCell::new(HashSet::new()), included_mod_stack: RefCell::new(vec![]), code_map, + non_modrs_mods: RefCell::new(vec![]), } } @@ -86,7 +90,10 @@ pub struct Directory { #[derive(Copy, Clone)] pub enum DirectoryOwnership { - Owned, + Owned { + // None if `mod.rs`, `Some("foo")` if we're in `foo.rs` + relative: Option, + }, UnownedViaBlock, UnownedViaMod(bool /* legacy warnings? */), } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index c3dd17e877566..d6f09cd85d7f1 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -514,7 +514,10 @@ impl<'a> Parser<'a> { restrictions: Restrictions::empty(), obsolete_set: HashSet::new(), recurse_into_file_modules, - directory: Directory { path: PathBuf::new(), ownership: DirectoryOwnership::Owned }, + directory: Directory { + path: PathBuf::new(), + ownership: DirectoryOwnership::Owned { relative: None } + }, root_module_name: None, expected_tokens: Vec::new(), token_cursor: TokenCursor { @@ -5731,7 +5734,7 @@ impl<'a> Parser<'a> { fn push_directory(&mut self, id: Ident, attrs: &[Attribute]) { if let Some(path) = attr::first_attr_value_str_by_name(attrs, "path") { self.directory.path.push(&path.as_str()); - self.directory.ownership = DirectoryOwnership::Owned; + self.directory.ownership = DirectoryOwnership::Owned { relative: None }; } else { self.directory.path.push(&id.name.as_str()); } @@ -5742,10 +5745,28 @@ impl<'a> Parser<'a> { } /// Returns either a path to a module, or . - pub fn default_submod_path(id: ast::Ident, dir_path: &Path, codemap: &CodeMap) -> ModulePath { + pub fn default_submod_path( + id: ast::Ident, + relative: Option, + dir_path: &Path, + codemap: &CodeMap) -> ModulePath + { + // If we're in a foo.rs file instead of a mod.rs file, + // we need to look for submodules in + // `./foo/.rs` and `./foo//mod.rs` rather than + // `./.rs` and `.//mod.rs`. + let relative_prefix_string; + let relative_prefix = if let Some(ident) = relative { + relative_prefix_string = format!("{}{}", ident.name.as_str(), path::MAIN_SEPARATOR); + &relative_prefix_string + } else { + "" + }; + let mod_name = id.to_string(); - let default_path_str = format!("{}.rs", mod_name); - let secondary_path_str = format!("{}{}mod.rs", mod_name, path::MAIN_SEPARATOR); + let default_path_str = format!("{}{}.rs", relative_prefix, mod_name); + let secondary_path_str = format!("{}{}{}mod.rs", + relative_prefix, mod_name, path::MAIN_SEPARATOR); let default_path = dir_path.join(&default_path_str); let secondary_path = dir_path.join(&secondary_path_str); let default_exists = codemap.file_exists(&default_path); @@ -5754,12 +5775,16 @@ impl<'a> Parser<'a> { let result = match (default_exists, secondary_exists) { (true, false) => Ok(ModulePathSuccess { path: default_path, - directory_ownership: DirectoryOwnership::UnownedViaMod(false), + directory_ownership: DirectoryOwnership::Owned { + relative: Some(id), + }, warn: false, }), (false, true) => Ok(ModulePathSuccess { path: secondary_path, - directory_ownership: DirectoryOwnership::Owned, + directory_ownership: DirectoryOwnership::Owned { + relative: None, + }, warn: false, }), (false, false) => Err(Error::FileNotFoundForModule { @@ -5790,7 +5815,10 @@ impl<'a> Parser<'a> { if let Some(path) = Parser::submod_path_from_attr(outer_attrs, &self.directory.path) { return Ok(ModulePathSuccess { directory_ownership: match path.file_name().and_then(|s| s.to_str()) { - Some("mod.rs") => DirectoryOwnership::Owned, + Some("mod.rs") => DirectoryOwnership::Owned { relative: None }, + Some(_) => { + DirectoryOwnership::Owned { relative: Some(id) } + } _ => DirectoryOwnership::UnownedViaMod(true), }, path, @@ -5798,49 +5826,69 @@ impl<'a> Parser<'a> { }); } - let paths = Parser::default_submod_path(id, &self.directory.path, self.sess.codemap()); + 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::UnownedViaBlock | + DirectoryOwnership::UnownedViaMod(_) => None, + }; + let paths = Parser::default_submod_path( + id, relative, &self.directory.path, self.sess.codemap()); - if let DirectoryOwnership::UnownedViaBlock = self.directory.ownership { - let msg = - "Cannot declare a non-inline module inside a block unless it has a path attribute"; - let mut err = self.diagnostic().struct_span_err(id_sp, msg); - if paths.path_exists { - let msg = format!("Maybe `use` the module `{}` instead of redeclaring it", - paths.name); - err.span_note(id_sp, &msg); - } - Err(err) - } else if let DirectoryOwnership::UnownedViaMod(warn) = self.directory.ownership { - if warn { - if let Ok(result) = paths.result { - return Ok(ModulePathSuccess { warn: true, ..result }); + match self.directory.ownership { + DirectoryOwnership::Owned { .. } => { + paths.result.map_err(|err| self.span_fatal_err(id_sp, err)) + }, + DirectoryOwnership::UnownedViaBlock => { + let msg = + "Cannot declare a non-inline module inside a block \ + unless it has a path attribute"; + let mut err = self.diagnostic().struct_span_err(id_sp, msg); + if paths.path_exists { + let msg = format!("Maybe `use` the module `{}` instead of redeclaring it", + paths.name); + err.span_note(id_sp, &msg); } + Err(err) } - 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 src_path = self.sess.codemap().span_to_filename(id_sp); - if let FileName::Real(src_path) = src_path { - 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, + DirectoryOwnership::UnownedViaMod(warn) => { + if warn { + if let Ok(result) = paths.result { + return Ok(ModulePathSuccess { warn: true, ..result }); + } + } + 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 src_path = self.sess.codemap().span_to_filename(id_sp); + if let FileName::Real(src_path) = src_path { + 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.display(), dest_path.display())); + } } } + if paths.path_exists { + err.span_note(id_sp, + &format!("... or maybe `use` the module `{}` instead \ + of possibly redeclaring it", + paths.name)); + } + Err(err) } - 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 { - paths.result.map_err(|err| self.span_fatal_err(id_sp, err)) } } diff --git a/src/test/compile-fail/directory_ownership/backcompat-warnings.rs b/src/test/compile-fail/directory_ownership/backcompat-warnings.rs index 519792dfa3a8f..2da07a2cc7210 100644 --- a/src/test/compile-fail/directory_ownership/backcompat-warnings.rs +++ b/src/test/compile-fail/directory_ownership/backcompat-warnings.rs @@ -8,8 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern: cannot declare a new module at this location -// error-pattern: will become a hard error +// error-pattern: mod statements in non-mod.rs files are unstable #[path="mod_file_not_owning_aux3.rs"] mod foo; diff --git a/src/test/compile-fail/directory_ownership/foo/compiletest-ignore-dir b/src/test/compile-fail/directory_ownership/foo/compiletest-ignore-dir new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/src/test/compile-fail/directory_ownership/foo/mod_file_not_owning/aux2.rs b/src/test/compile-fail/directory_ownership/foo/mod_file_not_owning/aux2.rs new file mode 100644 index 0000000000000..fc4bca865c932 --- /dev/null +++ b/src/test/compile-fail/directory_ownership/foo/mod_file_not_owning/aux2.rs @@ -0,0 +1,9 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. diff --git a/src/test/compile-fail/directory_ownership/foo/mod_file_not_owning_aux2.rs b/src/test/compile-fail/directory_ownership/foo/mod_file_not_owning_aux2.rs new file mode 100644 index 0000000000000..fc4bca865c932 --- /dev/null +++ b/src/test/compile-fail/directory_ownership/foo/mod_file_not_owning_aux2.rs @@ -0,0 +1,9 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. diff --git a/src/test/compile-fail/directory_ownership/mod_file_not_owning.rs b/src/test/compile-fail/directory_ownership/mod_file_not_owning.rs index adbcedd91f205..ff93fddf9b366 100644 --- a/src/test/compile-fail/directory_ownership/mod_file_not_owning.rs +++ b/src/test/compile-fail/directory_ownership/mod_file_not_owning.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern: cannot declare a new module at this location +// error-pattern: mod statements in non-mod.rs files are unstable mod mod_file_not_owning_aux1; diff --git a/src/test/compile-fail/directory_ownership/mod_file_not_owning_aux1/compiletest-ignore-dir b/src/test/compile-fail/directory_ownership/mod_file_not_owning_aux1/compiletest-ignore-dir new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/src/test/compile-fail/directory_ownership/mod_file_not_owning_aux1/mod_file_not_owning_aux2.rs b/src/test/compile-fail/directory_ownership/mod_file_not_owning_aux1/mod_file_not_owning_aux2.rs new file mode 100644 index 0000000000000..fc4bca865c932 --- /dev/null +++ b/src/test/compile-fail/directory_ownership/mod_file_not_owning_aux1/mod_file_not_owning_aux2.rs @@ -0,0 +1,9 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. diff --git a/src/test/compile-fail/directory_ownership/unowned_mod_with_path.rs b/src/test/compile-fail/directory_ownership/unowned_mod_with_path.rs index 854f790befcf7..0cffb7cc9e517 100644 --- a/src/test/compile-fail/directory_ownership/unowned_mod_with_path.rs +++ b/src/test/compile-fail/directory_ownership/unowned_mod_with_path.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern: cannot declare a new module at this location +// error-pattern: mod statements in non-mod.rs files are unstable // This is not a directory owner since the file name is not "mod.rs". #[path = "mod_file_not_owning_aux1.rs"] diff --git a/src/test/run-pass/non_modrs_mods/foors_mod.rs b/src/test/run-pass/non_modrs_mods/foors_mod.rs new file mode 100644 index 0000000000000..7d37c6d939954 --- /dev/null +++ b/src/test/run-pass/non_modrs_mods/foors_mod.rs @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , 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; diff --git a/src/test/run-pass/non_modrs_mods/foors_mod/compiletest-ignore-dir b/src/test/run-pass/non_modrs_mods/foors_mod/compiletest-ignore-dir new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/src/test/run-pass/non_modrs_mods/foors_mod/inner_foors_mod.rs b/src/test/run-pass/non_modrs_mods/foors_mod/inner_foors_mod.rs new file mode 100644 index 0000000000000..77cab972352bd --- /dev/null +++ b/src/test/run-pass/non_modrs_mods/foors_mod/inner_foors_mod.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod innest; diff --git a/src/test/run-pass/non_modrs_mods/foors_mod/inner_foors_mod/innest.rs b/src/test/run-pass/non_modrs_mods/foors_mod/inner_foors_mod/innest.rs new file mode 100644 index 0000000000000..b61667cfd882c --- /dev/null +++ b/src/test/run-pass/non_modrs_mods/foors_mod/inner_foors_mod/innest.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn foo() {} diff --git a/src/test/run-pass/non_modrs_mods/foors_mod/inner_modrs_mod/innest.rs b/src/test/run-pass/non_modrs_mods/foors_mod/inner_modrs_mod/innest.rs new file mode 100644 index 0000000000000..b61667cfd882c --- /dev/null +++ b/src/test/run-pass/non_modrs_mods/foors_mod/inner_modrs_mod/innest.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn foo() {} diff --git a/src/test/run-pass/non_modrs_mods/foors_mod/inner_modrs_mod/mod.rs b/src/test/run-pass/non_modrs_mods/foors_mod/inner_modrs_mod/mod.rs new file mode 100644 index 0000000000000..77cab972352bd --- /dev/null +++ b/src/test/run-pass/non_modrs_mods/foors_mod/inner_modrs_mod/mod.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod innest; diff --git a/src/test/run-pass/non_modrs_mods/modrs_mod/compiletest-ignore-dir b/src/test/run-pass/non_modrs_mods/modrs_mod/compiletest-ignore-dir new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/src/test/run-pass/non_modrs_mods/modrs_mod/inner_foors_mod.rs b/src/test/run-pass/non_modrs_mods/modrs_mod/inner_foors_mod.rs new file mode 100644 index 0000000000000..77cab972352bd --- /dev/null +++ b/src/test/run-pass/non_modrs_mods/modrs_mod/inner_foors_mod.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod innest; diff --git a/src/test/run-pass/non_modrs_mods/modrs_mod/inner_foors_mod/innest.rs b/src/test/run-pass/non_modrs_mods/modrs_mod/inner_foors_mod/innest.rs new file mode 100644 index 0000000000000..b61667cfd882c --- /dev/null +++ b/src/test/run-pass/non_modrs_mods/modrs_mod/inner_foors_mod/innest.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn foo() {} diff --git a/src/test/run-pass/non_modrs_mods/modrs_mod/inner_modrs_mod/innest.rs b/src/test/run-pass/non_modrs_mods/modrs_mod/inner_modrs_mod/innest.rs new file mode 100644 index 0000000000000..b61667cfd882c --- /dev/null +++ b/src/test/run-pass/non_modrs_mods/modrs_mod/inner_modrs_mod/innest.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn foo() {} diff --git a/src/test/run-pass/non_modrs_mods/modrs_mod/inner_modrs_mod/mod.rs b/src/test/run-pass/non_modrs_mods/modrs_mod/inner_modrs_mod/mod.rs new file mode 100644 index 0000000000000..77cab972352bd --- /dev/null +++ b/src/test/run-pass/non_modrs_mods/modrs_mod/inner_modrs_mod/mod.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod innest; diff --git a/src/test/run-pass/non_modrs_mods/modrs_mod/mod.rs b/src/test/run-pass/non_modrs_mods/modrs_mod/mod.rs new file mode 100644 index 0000000000000..9e3f10f12ed63 --- /dev/null +++ b/src/test/run-pass/non_modrs_mods/modrs_mod/mod.rs @@ -0,0 +1,12 @@ +// 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 or the MIT license +// , 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; diff --git a/src/test/run-pass/non_modrs_mods/non_modrs_mods.rs b/src/test/run-pass/non_modrs_mods/non_modrs_mods.rs new file mode 100644 index 0000000000000..31a6704b3aa49 --- /dev/null +++ b/src/test/run-pass/non_modrs_mods/non_modrs_mods.rs @@ -0,0 +1,24 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +#![feature(non_modrs_mods)] + +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(); + foors_mod::inner_modrs_mod::innest::foo(); + foors_mod::inner_foors_mod::innest::foo(); + attr_mod::inner_modrs_mod::innest::foo(); +} diff --git a/src/test/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/arbitrary_name.rs b/src/test/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/arbitrary_name.rs new file mode 100644 index 0000000000000..226e6fda0a41f --- /dev/null +++ b/src/test/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/arbitrary_name.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod inner_modrs_mod; diff --git a/src/test/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/attr_mod/inner_modrs_mod/innest.rs b/src/test/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/attr_mod/inner_modrs_mod/innest.rs new file mode 100644 index 0000000000000..b61667cfd882c --- /dev/null +++ b/src/test/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/attr_mod/inner_modrs_mod/innest.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn foo() {} diff --git a/src/test/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/attr_mod/inner_modrs_mod/mod.rs b/src/test/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/attr_mod/inner_modrs_mod/mod.rs new file mode 100644 index 0000000000000..77cab972352bd --- /dev/null +++ b/src/test/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/attr_mod/inner_modrs_mod/mod.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod innest; diff --git a/src/test/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/compiletest-ignore-dir b/src/test/run-pass/non_modrs_mods/some_crazy_attr_mod_dir/compiletest-ignore-dir new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/src/test/ui/invalid-module-declaration/invalid-module-declaration.rs b/src/test/ui/invalid-module-declaration/invalid-module-declaration.rs index c15cfb8cc8e22..18ca5d09798bc 100644 --- a/src/test/ui/invalid-module-declaration/invalid-module-declaration.rs +++ b/src/test/ui/invalid-module-declaration/invalid-module-declaration.rs @@ -9,6 +9,7 @@ // except according to those terms. // ignore-tidy-linelength +// ignore-windows // error-pattern: cannot declare a new module at this location // error-pattern: maybe move this module diff --git a/src/test/ui/invalid-module-declaration/invalid-module-declaration.stderr b/src/test/ui/invalid-module-declaration/invalid-module-declaration.stderr index 3e9b21cdb740f..58df416030c54 100644 --- a/src/test/ui/invalid-module-declaration/invalid-module-declaration.stderr +++ b/src/test/ui/invalid-module-declaration/invalid-module-declaration.stderr @@ -1,14 +1,10 @@ -error: cannot declare a new module at this location +error[E0583]: file not found for module `baz` --> $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; - | ^^^ + = help: name the file either bar/baz.rs or bar/baz/mod.rs inside the directory "$DIR/auxiliary/foo" error: aborting due to previous error diff --git a/src/test/ui/missing_non_modrs_mod/foo.rs b/src/test/ui/missing_non_modrs_mod/foo.rs new file mode 100644 index 0000000000000..7262a26397cb8 --- /dev/null +++ b/src/test/ui/missing_non_modrs_mod/foo.rs @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +// ignore-test this is just a helper for the real test in this dir + +mod missing; diff --git a/src/test/ui/missing_non_modrs_mod/missing_non_modrs_mod.rs b/src/test/ui/missing_non_modrs_mod/missing_non_modrs_mod.rs new file mode 100644 index 0000000000000..9c95f45939367 --- /dev/null +++ b/src/test/ui/missing_non_modrs_mod/missing_non_modrs_mod.rs @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-windows + +mod foo; +fn main() {} diff --git a/src/test/ui/missing_non_modrs_mod/missing_non_modrs_mod.stderr b/src/test/ui/missing_non_modrs_mod/missing_non_modrs_mod.stderr new file mode 100644 index 0000000000000..3ba71d32a31a6 --- /dev/null +++ b/src/test/ui/missing_non_modrs_mod/missing_non_modrs_mod.stderr @@ -0,0 +1,10 @@ +error[E0583]: file not found for module `missing` + --> $DIR/foo.rs:13:5 + | +13 | mod missing; + | ^^^^^^^ + | + = help: name the file either foo/missing.rs or foo/missing/mod.rs inside the directory "$DIR" + +error: aborting due to previous error + diff --git a/src/test/ui/non_modrs_mods/foors_mod.rs b/src/test/ui/non_modrs_mods/foors_mod.rs new file mode 100644 index 0000000000000..7d37c6d939954 --- /dev/null +++ b/src/test/ui/non_modrs_mods/foors_mod.rs @@ -0,0 +1,14 @@ +// 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 or the MIT license +// , 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; diff --git a/src/test/ui/non_modrs_mods/foors_mod/compiletest-ignore-dir b/src/test/ui/non_modrs_mods/foors_mod/compiletest-ignore-dir new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/src/test/ui/non_modrs_mods/foors_mod/inner_foors_mod.rs b/src/test/ui/non_modrs_mods/foors_mod/inner_foors_mod.rs new file mode 100644 index 0000000000000..77cab972352bd --- /dev/null +++ b/src/test/ui/non_modrs_mods/foors_mod/inner_foors_mod.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod innest; diff --git a/src/test/ui/non_modrs_mods/foors_mod/inner_foors_mod/innest.rs b/src/test/ui/non_modrs_mods/foors_mod/inner_foors_mod/innest.rs new file mode 100644 index 0000000000000..b61667cfd882c --- /dev/null +++ b/src/test/ui/non_modrs_mods/foors_mod/inner_foors_mod/innest.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn foo() {} diff --git a/src/test/ui/non_modrs_mods/foors_mod/inner_modrs_mod/innest.rs b/src/test/ui/non_modrs_mods/foors_mod/inner_modrs_mod/innest.rs new file mode 100644 index 0000000000000..b61667cfd882c --- /dev/null +++ b/src/test/ui/non_modrs_mods/foors_mod/inner_modrs_mod/innest.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn foo() {} diff --git a/src/test/ui/non_modrs_mods/foors_mod/inner_modrs_mod/mod.rs b/src/test/ui/non_modrs_mods/foors_mod/inner_modrs_mod/mod.rs new file mode 100644 index 0000000000000..77cab972352bd --- /dev/null +++ b/src/test/ui/non_modrs_mods/foors_mod/inner_modrs_mod/mod.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod innest; diff --git a/src/test/ui/non_modrs_mods/modrs_mod/compiletest-ignore-dir b/src/test/ui/non_modrs_mods/modrs_mod/compiletest-ignore-dir new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/src/test/ui/non_modrs_mods/modrs_mod/inner_foors_mod.rs b/src/test/ui/non_modrs_mods/modrs_mod/inner_foors_mod.rs new file mode 100644 index 0000000000000..77cab972352bd --- /dev/null +++ b/src/test/ui/non_modrs_mods/modrs_mod/inner_foors_mod.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod innest; diff --git a/src/test/ui/non_modrs_mods/modrs_mod/inner_foors_mod/innest.rs b/src/test/ui/non_modrs_mods/modrs_mod/inner_foors_mod/innest.rs new file mode 100644 index 0000000000000..b61667cfd882c --- /dev/null +++ b/src/test/ui/non_modrs_mods/modrs_mod/inner_foors_mod/innest.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn foo() {} diff --git a/src/test/ui/non_modrs_mods/modrs_mod/inner_modrs_mod/innest.rs b/src/test/ui/non_modrs_mods/modrs_mod/inner_modrs_mod/innest.rs new file mode 100644 index 0000000000000..b61667cfd882c --- /dev/null +++ b/src/test/ui/non_modrs_mods/modrs_mod/inner_modrs_mod/innest.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn foo() {} diff --git a/src/test/ui/non_modrs_mods/modrs_mod/inner_modrs_mod/mod.rs b/src/test/ui/non_modrs_mods/modrs_mod/inner_modrs_mod/mod.rs new file mode 100644 index 0000000000000..77cab972352bd --- /dev/null +++ b/src/test/ui/non_modrs_mods/modrs_mod/inner_modrs_mod/mod.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod innest; diff --git a/src/test/ui/non_modrs_mods/modrs_mod/mod.rs b/src/test/ui/non_modrs_mods/modrs_mod/mod.rs new file mode 100644 index 0000000000000..9e3f10f12ed63 --- /dev/null +++ b/src/test/ui/non_modrs_mods/modrs_mod/mod.rs @@ -0,0 +1,12 @@ +// 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 or the MIT license +// , 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; diff --git a/src/test/ui/non_modrs_mods/non_modrs_mods.rs b/src/test/ui/non_modrs_mods/non_modrs_mods.rs new file mode 100644 index 0000000000000..200a1367b0de3 --- /dev/null +++ b/src/test/ui/non_modrs_mods/non_modrs_mods.rs @@ -0,0 +1,27 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +// Tests the formatting of the feature-gate errors for non_modrs_mods +// +// gate-test-non_modrs_mods +// ignore-windows +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(); + foors_mod::inner_modrs_mod::innest::foo(); + foors_mod::inner_foors_mod::innest::foo(); + attr_mod::inner_modrs_mod::innest::foo(); +} diff --git a/src/test/ui/non_modrs_mods/non_modrs_mods.stderr b/src/test/ui/non_modrs_mods/non_modrs_mods.stderr new file mode 100644 index 0000000000000..b4b524786cd7c --- /dev/null +++ b/src/test/ui/non_modrs_mods/non_modrs_mods.stderr @@ -0,0 +1,47 @@ +error: mod statements in non-mod.rs files are unstable (see issue #44660) + --> $DIR/modrs_mod/inner_foors_mod.rs:11:9 + | +11 | pub mod innest; + | ^^^^^^ + | + = help: add #![feature(non_modrs_mods)] to the crate attributes to enable + = help: on stable builds, rename this file to inner_foors_mod/mod.rs + +error: mod statements in non-mod.rs files are unstable (see issue #44660) + --> $DIR/foors_mod.rs:13:9 + | +13 | pub mod inner_modrs_mod; + | ^^^^^^^^^^^^^^^ + | + = help: add #![feature(non_modrs_mods)] to the crate attributes to enable + = help: on stable builds, rename this file to foors_mod/mod.rs + +error: mod statements in non-mod.rs files are unstable (see issue #44660) + --> $DIR/foors_mod.rs:14:9 + | +14 | pub mod inner_foors_mod; + | ^^^^^^^^^^^^^^^ + | + = help: add #![feature(non_modrs_mods)] to the crate attributes to enable + = help: on stable builds, rename this file to foors_mod/mod.rs + +error: mod statements in non-mod.rs files are unstable (see issue #44660) + --> $DIR/foors_mod/inner_foors_mod.rs:11:9 + | +11 | pub mod innest; + | ^^^^^^ + | + = help: add #![feature(non_modrs_mods)] to the crate attributes to enable + = help: on stable builds, rename this file to inner_foors_mod/mod.rs + +error: mod statements in non-mod.rs files are unstable (see issue #44660) + --> $DIR/some_crazy_attr_mod_dir/arbitrary_name.rs:11:9 + | +11 | pub mod inner_modrs_mod; + | ^^^^^^^^^^^^^^^ + | + = help: add #![feature(non_modrs_mods)] to the crate attributes to enable + = help: on stable builds, rename this file to attr_mod/mod.rs + +error: aborting due to 5 previous errors + diff --git a/src/test/ui/non_modrs_mods/some_crazy_attr_mod_dir/arbitrary_name.rs b/src/test/ui/non_modrs_mods/some_crazy_attr_mod_dir/arbitrary_name.rs new file mode 100644 index 0000000000000..226e6fda0a41f --- /dev/null +++ b/src/test/ui/non_modrs_mods/some_crazy_attr_mod_dir/arbitrary_name.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod inner_modrs_mod; diff --git a/src/test/ui/non_modrs_mods/some_crazy_attr_mod_dir/attr_mod/inner_modrs_mod/innest.rs b/src/test/ui/non_modrs_mods/some_crazy_attr_mod_dir/attr_mod/inner_modrs_mod/innest.rs new file mode 100644 index 0000000000000..b61667cfd882c --- /dev/null +++ b/src/test/ui/non_modrs_mods/some_crazy_attr_mod_dir/attr_mod/inner_modrs_mod/innest.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn foo() {} diff --git a/src/test/ui/non_modrs_mods/some_crazy_attr_mod_dir/attr_mod/inner_modrs_mod/mod.rs b/src/test/ui/non_modrs_mods/some_crazy_attr_mod_dir/attr_mod/inner_modrs_mod/mod.rs new file mode 100644 index 0000000000000..77cab972352bd --- /dev/null +++ b/src/test/ui/non_modrs_mods/some_crazy_attr_mod_dir/attr_mod/inner_modrs_mod/mod.rs @@ -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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod innest; diff --git a/src/test/ui/non_modrs_mods/some_crazy_attr_mod_dir/compiletest-ignore-dir b/src/test/ui/non_modrs_mods/some_crazy_attr_mod_dir/compiletest-ignore-dir new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/src/tools/tidy/src/features.rs b/src/tools/tidy/src/features.rs index eca225ee8a8c0..3156e93cc72bc 100644 --- a/src/tools/tidy/src/features.rs +++ b/src/tools/tidy/src/features.rs @@ -93,7 +93,8 @@ pub fn check(path: &Path, bad: &mut bool, quiet: bool) { &path.join("test/ui"), &path.join("test/compile-fail"), &path.join("test/compile-fail-fulldeps"), - &path.join("test/parse-fail"),], + &path.join("test/parse-fail"), + &path.join("test/ui"),], &mut |path| super::filter_dirs(path), &mut |file| { let filename = file.file_name().unwrap().to_string_lossy(); From b82e2e9db1fdc698b6cb6f69fc544f72a4093aba Mon Sep 17 00:00:00 2001 From: Taylor Cramer Date: Fri, 8 Dec 2017 17:41:36 -0800 Subject: [PATCH 2/4] Break rustfmt --- src/tools/toolstate.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/toolstate.toml b/src/tools/toolstate.toml index 86ea113061969..4b864791a27cb 100644 --- a/src/tools/toolstate.toml +++ b/src/tools/toolstate.toml @@ -33,4 +33,4 @@ rls = "Testing" # ping @nrc # when breaking rustfmt, always break rls as well -rustfmt = "Testing" +rustfmt = "Broken" From e3c229802ff904657799b309e12ea5383e424fec Mon Sep 17 00:00:00 2001 From: Taylor Cramer Date: Sun, 10 Dec 2017 11:21:08 -0800 Subject: [PATCH 3/4] Break rls --- src/tools/toolstate.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/toolstate.toml b/src/tools/toolstate.toml index 4b864791a27cb..b29e505c3b09e 100644 --- a/src/tools/toolstate.toml +++ b/src/tools/toolstate.toml @@ -29,7 +29,7 @@ miri = "Broken" clippy = "Testing" # ping @nrc -rls = "Testing" +rls = "Broken" # ping @nrc # when breaking rustfmt, always break rls as well From 1d5977b899e27235f4acb5cfc15a1082e897e8f1 Mon Sep 17 00:00:00 2001 From: Taylor Cramer Date: Tue, 19 Dec 2017 15:24:51 -0800 Subject: [PATCH 4/4] Ignore pretty printing tests for non_modrs_mods --- src/test/run-pass/non_modrs_mods/non_modrs_mods.rs | 2 ++ src/test/ui/non_modrs_mods/non_modrs_mods.rs | 1 + 2 files changed, 3 insertions(+) diff --git a/src/test/run-pass/non_modrs_mods/non_modrs_mods.rs b/src/test/run-pass/non_modrs_mods/non_modrs_mods.rs index 31a6704b3aa49..eab8112b85543 100644 --- a/src/test/run-pass/non_modrs_mods/non_modrs_mods.rs +++ b/src/test/run-pass/non_modrs_mods/non_modrs_mods.rs @@ -7,6 +7,8 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. +// +// ignore-pretty issue #37195 #![feature(non_modrs_mods)] pub mod modrs_mod; diff --git a/src/test/ui/non_modrs_mods/non_modrs_mods.rs b/src/test/ui/non_modrs_mods/non_modrs_mods.rs index 200a1367b0de3..9dc85f4d3f92d 100644 --- a/src/test/ui/non_modrs_mods/non_modrs_mods.rs +++ b/src/test/ui/non_modrs_mods/non_modrs_mods.rs @@ -12,6 +12,7 @@ // // gate-test-non_modrs_mods // ignore-windows +// ignore-pretty issue #37195 pub mod modrs_mod; pub mod foors_mod;