about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorJakub Wieczorek <jakub@jakub.cc>2014-07-18 00:56:56 +0200
committerJakub Wieczorek <jakub@jakub.cc>2014-07-20 12:40:08 +0200
commit4b9bc2e8f268dfe2a2462c4e378e5a0eeefa2cf4 (patch)
treeada16b620d93f1ae709185df0986c58a62614e8d /src/test
parent50481f55030f02543e1b3b6ae008d77b1cef3e98 (diff)
downloadrust-4b9bc2e8f268dfe2a2462c4e378e5a0eeefa2cf4.tar.gz
rust-4b9bc2e8f268dfe2a2462c4e378e5a0eeefa2cf4.zip
Implement new mod import sugar
Implements RFC #168.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/compile-fail/use-mod-2.rs19
-rw-r--r--src/test/compile-fail/use-mod-3.rs24
-rw-r--r--src/test/compile-fail/use-mod.rs32
-rw-r--r--src/test/run-pass/use-mod.rs38
4 files changed, 113 insertions, 0 deletions
diff --git a/src/test/compile-fail/use-mod-2.rs b/src/test/compile-fail/use-mod-2.rs
new file mode 100644
index 00000000000..12d4531078d
--- /dev/null
+++ b/src/test/compile-fail/use-mod-2.rs
@@ -0,0 +1,19 @@
+// 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 <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.
+
+mod foo {
+    use self::{mod};
+    //~^ ERROR unresolved import `self`. There is no `self` in `???`
+
+    use super::{mod};
+    //~^ ERROR unresolved import `super`. There is no `super` in `???`
+}
+
+fn main() {}
diff --git a/src/test/compile-fail/use-mod-3.rs b/src/test/compile-fail/use-mod-3.rs
new file mode 100644
index 00000000000..0263dc392f1
--- /dev/null
+++ b/src/test/compile-fail/use-mod-3.rs
@@ -0,0 +1,24 @@
+// 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 <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.
+
+use foo::bar::{
+    mod //~ ERROR module `bar` is private
+};
+use foo::bar::{
+    Bar, //~ ERROR type `Bar` is inaccessible
+    //~^ NOTE module `bar` is private
+    mod //~ ERROR module `bar` is private
+};
+
+mod foo {
+    mod bar { pub type Bar = int; }
+}
+
+fn main() {}
diff --git a/src/test/compile-fail/use-mod.rs b/src/test/compile-fail/use-mod.rs
new file mode 100644
index 00000000000..b2b0eb21ace
--- /dev/null
+++ b/src/test/compile-fail/use-mod.rs
@@ -0,0 +1,32 @@
+// 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 <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.
+
+use foo::bar::{
+    mod,
+//~^ ERROR `mod` import can only appear once in the list
+    Bar,
+    mod
+//~^ NOTE another `mod` import appears here
+};
+
+use {mod};
+//~^ ERROR `mod` import can only appear in an import list with a non-empty prefix
+
+use foo::mod;
+//~^ ERROR `mod` imports are only allowed within a { } list
+
+mod foo {
+    pub mod bar {
+        pub struct Bar;
+        pub struct Baz;
+    }
+}
+
+fn main() {}
diff --git a/src/test/run-pass/use-mod.rs b/src/test/run-pass/use-mod.rs
new file mode 100644
index 00000000000..34c9f581f07
--- /dev/null
+++ b/src/test/run-pass/use-mod.rs
@@ -0,0 +1,38 @@
+// 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 <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 use foo::bar::{mod, First};
+use self::bar::Second;
+
+mod foo {
+    pub use self::bar::baz::{mod};
+
+    pub mod bar {
+        pub mod baz {
+            pub struct Fourth;
+        }
+        pub struct First;
+        pub struct Second;
+    }
+
+    pub struct Third;
+}
+
+mod baz {
+    use super::foo::{bar, mod};
+    pub use foo::Third;
+}
+
+fn main() {
+    let _ = First;
+    let _ = Second;
+    let _ = baz::Third;
+    let _ = foo::baz::Fourth;
+}