From 30ac06fd732bb53c0c4e6ddcc1dba9a54fc9e9ae Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Sat, 5 Nov 2016 05:31:35 +0000 Subject: Add a regression test and organize tests. --- .../directory_ownership/macro-expanded-mod.rs | 23 ++++++++++++++++++++++ .../macro_expanded_mod_helper/foo/bar.rs | 11 +++++++++++ .../macro_expanded_mod_helper/foo/mod.rs | 13 ++++++++++++ .../directory_ownership/mod_file_not_owning.rs | 15 ++++++++++++++ .../mod_file_not_owning_aux1.rs | 16 +++++++++++++++ .../mod_file_not_owning_aux2.rs | 11 +++++++++++ .../non-inline-mod-restriction.rs | 15 ++++++++++++++ .../directory_ownership/unowned_mod_with_path.rs | 15 ++++++++++++++ src/test/compile-fail/macro-expanded-mod.rs | 23 ---------------------- .../macro_expanded_mod_helper/foo/bar.rs | 11 ----------- .../macro_expanded_mod_helper/foo/mod.rs | 13 ------------ src/test/compile-fail/mod_file_not_owning.rs | 17 ---------------- src/test/compile-fail/mod_file_not_owning_aux1.rs | 13 ------------ src/test/compile-fail/mod_file_not_owning_aux2.rs | 11 ----------- .../compile-fail/non-inline-mod-restriction.rs | 15 -------------- 15 files changed, 119 insertions(+), 103 deletions(-) create mode 100644 src/test/compile-fail/directory_ownership/macro-expanded-mod.rs create mode 100644 src/test/compile-fail/directory_ownership/macro_expanded_mod_helper/foo/bar.rs create mode 100644 src/test/compile-fail/directory_ownership/macro_expanded_mod_helper/foo/mod.rs create mode 100644 src/test/compile-fail/directory_ownership/mod_file_not_owning.rs create mode 100644 src/test/compile-fail/directory_ownership/mod_file_not_owning_aux1.rs create mode 100644 src/test/compile-fail/directory_ownership/mod_file_not_owning_aux2.rs create mode 100644 src/test/compile-fail/directory_ownership/non-inline-mod-restriction.rs create mode 100644 src/test/compile-fail/directory_ownership/unowned_mod_with_path.rs delete mode 100644 src/test/compile-fail/macro-expanded-mod.rs delete mode 100644 src/test/compile-fail/macro_expanded_mod_helper/foo/bar.rs delete mode 100644 src/test/compile-fail/macro_expanded_mod_helper/foo/mod.rs delete mode 100644 src/test/compile-fail/mod_file_not_owning.rs delete mode 100644 src/test/compile-fail/mod_file_not_owning_aux1.rs delete mode 100644 src/test/compile-fail/mod_file_not_owning_aux2.rs delete mode 100644 src/test/compile-fail/non-inline-mod-restriction.rs diff --git a/src/test/compile-fail/directory_ownership/macro-expanded-mod.rs b/src/test/compile-fail/directory_ownership/macro-expanded-mod.rs new file mode 100644 index 00000000000..8e631a64f7a --- /dev/null +++ b/src/test/compile-fail/directory_ownership/macro-expanded-mod.rs @@ -0,0 +1,23 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that macro-expanded non-inline modules behave correctly + +macro_rules! mod_decl { + ($i:ident) => { mod $i; } +} + +mod macro_expanded_mod_helper { + mod_decl!(foo); // This should search in the folder `macro_expanded_mod_helper` +} + +fn main() { + mod_decl!(foo); //~ ERROR Cannot declare a non-inline module inside a block +} diff --git a/src/test/compile-fail/directory_ownership/macro_expanded_mod_helper/foo/bar.rs b/src/test/compile-fail/directory_ownership/macro_expanded_mod_helper/foo/bar.rs new file mode 100644 index 00000000000..3ec34362da5 --- /dev/null +++ b/src/test/compile-fail/directory_ownership/macro_expanded_mod_helper/foo/bar.rs @@ -0,0 +1,11 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-test diff --git a/src/test/compile-fail/directory_ownership/macro_expanded_mod_helper/foo/mod.rs b/src/test/compile-fail/directory_ownership/macro_expanded_mod_helper/foo/mod.rs new file mode 100644 index 00000000000..25fcf11ce17 --- /dev/null +++ b/src/test/compile-fail/directory_ownership/macro_expanded_mod_helper/foo/mod.rs @@ -0,0 +1,13 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-test + +mod_decl!(bar); 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 new file mode 100644 index 00000000000..adbcedd91f2 --- /dev/null +++ b/src/test/compile-fail/directory_ownership/mod_file_not_owning.rs @@ -0,0 +1,15 @@ +// Copyright 2014 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. + +// error-pattern: cannot declare a new module at this location + +mod mod_file_not_owning_aux1; + +fn main() {} diff --git a/src/test/compile-fail/directory_ownership/mod_file_not_owning_aux1.rs b/src/test/compile-fail/directory_ownership/mod_file_not_owning_aux1.rs new file mode 100644 index 00000000000..4ac94a92e37 --- /dev/null +++ b/src/test/compile-fail/directory_ownership/mod_file_not_owning_aux1.rs @@ -0,0 +1,16 @@ +// Copyright 2014 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 not a test + +macro_rules! m { + () => { mod mod_file_not_owning_aux2; } +} +m!(); diff --git a/src/test/compile-fail/directory_ownership/mod_file_not_owning_aux2.rs b/src/test/compile-fail/directory_ownership/mod_file_not_owning_aux2.rs new file mode 100644 index 00000000000..41401d640f6 --- /dev/null +++ b/src/test/compile-fail/directory_ownership/mod_file_not_owning_aux2.rs @@ -0,0 +1,11 @@ +// Copyright 2014 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 not a test diff --git a/src/test/compile-fail/directory_ownership/non-inline-mod-restriction.rs b/src/test/compile-fail/directory_ownership/non-inline-mod-restriction.rs new file mode 100644 index 00000000000..c4ede12e820 --- /dev/null +++ b/src/test/compile-fail/directory_ownership/non-inline-mod-restriction.rs @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that non-inline modules are not allowed inside blocks. + +fn main() { + mod foo; //~ ERROR Cannot declare a non-inline module inside a block +} 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 new file mode 100644 index 00000000000..854f790befc --- /dev/null +++ b/src/test/compile-fail/directory_ownership/unowned_mod_with_path.rs @@ -0,0 +1,15 @@ +// 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 or the MIT license +// , at your +// 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 + +// This is not a directory owner since the file name is not "mod.rs". +#[path = "mod_file_not_owning_aux1.rs"] +mod foo; diff --git a/src/test/compile-fail/macro-expanded-mod.rs b/src/test/compile-fail/macro-expanded-mod.rs deleted file mode 100644 index 8e631a64f7a..00000000000 --- a/src/test/compile-fail/macro-expanded-mod.rs +++ /dev/null @@ -1,23 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that macro-expanded non-inline modules behave correctly - -macro_rules! mod_decl { - ($i:ident) => { mod $i; } -} - -mod macro_expanded_mod_helper { - mod_decl!(foo); // This should search in the folder `macro_expanded_mod_helper` -} - -fn main() { - mod_decl!(foo); //~ ERROR Cannot declare a non-inline module inside a block -} diff --git a/src/test/compile-fail/macro_expanded_mod_helper/foo/bar.rs b/src/test/compile-fail/macro_expanded_mod_helper/foo/bar.rs deleted file mode 100644 index 3ec34362da5..00000000000 --- a/src/test/compile-fail/macro_expanded_mod_helper/foo/bar.rs +++ /dev/null @@ -1,11 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test diff --git a/src/test/compile-fail/macro_expanded_mod_helper/foo/mod.rs b/src/test/compile-fail/macro_expanded_mod_helper/foo/mod.rs deleted file mode 100644 index 25fcf11ce17..00000000000 --- a/src/test/compile-fail/macro_expanded_mod_helper/foo/mod.rs +++ /dev/null @@ -1,13 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-test - -mod_decl!(bar); diff --git a/src/test/compile-fail/mod_file_not_owning.rs b/src/test/compile-fail/mod_file_not_owning.rs deleted file mode 100644 index 7dcff6e6644..00000000000 --- a/src/test/compile-fail/mod_file_not_owning.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 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. - -// compile-flags: -Z parse-only - -// error-pattern: cannot declare a new module at this location - -mod mod_file_not_owning_aux1; - -fn main() {} diff --git a/src/test/compile-fail/mod_file_not_owning_aux1.rs b/src/test/compile-fail/mod_file_not_owning_aux1.rs deleted file mode 100644 index 2d522be6dc5..00000000000 --- a/src/test/compile-fail/mod_file_not_owning_aux1.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 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 not a test - -mod mod_file_not_owning_aux2; diff --git a/src/test/compile-fail/mod_file_not_owning_aux2.rs b/src/test/compile-fail/mod_file_not_owning_aux2.rs deleted file mode 100644 index 41401d640f6..00000000000 --- a/src/test/compile-fail/mod_file_not_owning_aux2.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 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 not a test diff --git a/src/test/compile-fail/non-inline-mod-restriction.rs b/src/test/compile-fail/non-inline-mod-restriction.rs deleted file mode 100644 index c4ede12e820..00000000000 --- a/src/test/compile-fail/non-inline-mod-restriction.rs +++ /dev/null @@ -1,15 +0,0 @@ -// 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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that non-inline modules are not allowed inside blocks. - -fn main() { - mod foo; //~ ERROR Cannot declare a non-inline module inside a block -} -- cgit 1.4.1-3-g733a5