]> git.lizzy.rs Git - rust.git/commitdiff
Move hygiene tests to UI
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Sat, 7 Apr 2018 14:28:31 +0000 (17:28 +0300)
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Thu, 12 Apr 2018 20:06:03 +0000 (23:06 +0300)
38 files changed:
src/test/compile-fail/for-loop-hygiene.rs [deleted file]
src/test/compile-fail/hygiene/assoc_item_ctxt.rs [deleted file]
src/test/compile-fail/hygiene/assoc_ty_bindings.rs [deleted file]
src/test/compile-fail/hygiene/auxiliary/intercrate.rs [deleted file]
src/test/compile-fail/hygiene/fields.rs [deleted file]
src/test/compile-fail/hygiene/globs.rs [deleted file]
src/test/compile-fail/hygiene/impl_items.rs [deleted file]
src/test/compile-fail/hygiene/intercrate.rs [deleted file]
src/test/compile-fail/hygiene/nested_macro_privacy.rs [deleted file]
src/test/compile-fail/hygiene/no_implicit_prelude.rs [deleted file]
src/test/compile-fail/hygiene/privacy.rs [deleted file]
src/test/compile-fail/hygiene/trait_items.rs [deleted file]
src/test/compile-fail/pattern-macro-hygiene.rs [deleted file]
src/test/ui/hygiene/assoc_item_ctxt.rs [new file with mode: 0644]
src/test/ui/hygiene/assoc_item_ctxt.stderr [new file with mode: 0644]
src/test/ui/hygiene/assoc_ty_bindings.rs [new file with mode: 0644]
src/test/ui/hygiene/assoc_ty_bindings.stderr [new file with mode: 0644]
src/test/ui/hygiene/auxiliary/intercrate.rs [new file with mode: 0644]
src/test/ui/hygiene/fields.rs [new file with mode: 0644]
src/test/ui/hygiene/fields.stderr [new file with mode: 0644]
src/test/ui/hygiene/for-loop.rs [new file with mode: 0644]
src/test/ui/hygiene/for-loop.stderr [new file with mode: 0644]
src/test/ui/hygiene/globs.rs [new file with mode: 0644]
src/test/ui/hygiene/globs.stderr [new file with mode: 0644]
src/test/ui/hygiene/impl_items.rs [new file with mode: 0644]
src/test/ui/hygiene/impl_items.stderr [new file with mode: 0644]
src/test/ui/hygiene/intercrate.rs [new file with mode: 0644]
src/test/ui/hygiene/intercrate.stderr [new file with mode: 0644]
src/test/ui/hygiene/nested_macro_privacy.rs [new file with mode: 0644]
src/test/ui/hygiene/nested_macro_privacy.stderr [new file with mode: 0644]
src/test/ui/hygiene/no_implicit_prelude.rs [new file with mode: 0644]
src/test/ui/hygiene/no_implicit_prelude.stderr [new file with mode: 0644]
src/test/ui/hygiene/pattern-macro.rs [new file with mode: 0644]
src/test/ui/hygiene/pattern-macro.stderr [new file with mode: 0644]
src/test/ui/hygiene/privacy.rs [new file with mode: 0644]
src/test/ui/hygiene/privacy.stderr [new file with mode: 0644]
src/test/ui/hygiene/trait_items.rs [new file with mode: 0644]
src/test/ui/hygiene/trait_items.stderr [new file with mode: 0644]

diff --git a/src/test/compile-fail/for-loop-hygiene.rs b/src/test/compile-fail/for-loop-hygiene.rs
deleted file mode 100644 (file)
index d938642..0000000
+++ /dev/null
@@ -1,18 +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 <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.
-
-// for-loops are expanded in the front end, and use an `iter` ident in their expansion. Check that
-// `iter` is not accessible inside the for loop.
-
-fn main() {
-    for _ in 0..10 {
-        iter.next();  //~ ERROR cannot find value `iter` in this scope
-    }
-}
diff --git a/src/test/compile-fail/hygiene/assoc_item_ctxt.rs b/src/test/compile-fail/hygiene/assoc_item_ctxt.rs
deleted file mode 100644 (file)
index e336b0d..0000000
+++ /dev/null
@@ -1,52 +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-pretty pretty-printing is unhygienic
-
-#![feature(decl_macro)]
-#![allow(unused)]
-
-mod ok {
-    macro mac_trait_item($method: ident) {
-        fn $method();
-    }
-
-    trait Tr {
-        mac_trait_item!(method);
-    }
-
-    macro mac_trait_impl() {
-        impl Tr for u8 { // OK
-            fn method() {} // OK
-        }
-    }
-
-    mac_trait_impl!();
-}
-
-mod error {
-    macro mac_trait_item() {
-        fn method();
-    }
-
-    trait Tr {
-        mac_trait_item!();
-    }
-
-    macro mac_trait_impl() {
-        impl Tr for u8 { //~ ERROR not all trait items implemented, missing: `method`
-            fn method() {} //~ ERROR method `method` is not a member of trait `Tr`
-        }
-    }
-
-    mac_trait_impl!();
-}
-
-fn main() {}
diff --git a/src/test/compile-fail/hygiene/assoc_ty_bindings.rs b/src/test/compile-fail/hygiene/assoc_ty_bindings.rs
deleted file mode 100644 (file)
index 46a1387..0000000
+++ /dev/null
@@ -1,49 +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-pretty pretty-printing is unhygienic
-
-#![feature(decl_macro, associated_type_defaults)]
-#![feature(rustc_attrs)]
-
-trait Base {
-    type AssocTy;
-    fn f();
-}
-trait Derived: Base {
-    fn g();
-}
-
-macro mac() {
-    type A = Base<AssocTy = u8>;
-    type B = Derived<AssocTy = u8>;
-
-    impl Base for u8 {
-        type AssocTy = u8;
-        fn f() {
-            let _: Self::AssocTy;
-        }
-    }
-    impl Derived for u8 {
-        fn g() {
-            let _: Self::AssocTy;
-        }
-    }
-
-    fn h<T: Base, U: Derived>() {
-        let _: T::AssocTy;
-        let _: U::AssocTy;
-    }
-}
-
-mac!();
-
-#[rustc_error]
-fn main() {} //~ ERROR compilation successful
diff --git a/src/test/compile-fail/hygiene/auxiliary/intercrate.rs b/src/test/compile-fail/hygiene/auxiliary/intercrate.rs
deleted file mode 100644 (file)
index aa67e5c..0000000
+++ /dev/null
@@ -1,21 +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.
-
-#![feature(decl_macro)]
-
-pub mod foo {
-    pub use self::bar::m;
-    mod bar {
-        fn f() -> u32 { 1 }
-        pub macro m() {
-            f();
-        }
-    }
-}
diff --git a/src/test/compile-fail/hygiene/fields.rs b/src/test/compile-fail/hygiene/fields.rs
deleted file mode 100644 (file)
index 6421777..0000000
+++ /dev/null
@@ -1,40 +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-pretty pretty-printing is unhygienic
-
-#![feature(decl_macro)]
-
-mod foo {
-    struct S { x: u32 }
-    struct T(u32);
-
-    pub macro m($S:ident, $x:ident) {{
-        struct $S {
-            $x: u32,
-            x: i32,
-        }
-
-        let s = S { x: 0 }; //~ ERROR type `foo::S` is private
-        let _ = s.x; //~ ERROR type `foo::S` is private
-
-        let t = T(0); //~ ERROR type `foo::T` is private
-        let _ = t.0; //~ ERROR type `foo::T` is private
-
-        let s = $S { $x: 0, x: 1 };
-        assert_eq!((s.$x, s.x), (0, 1));
-        s
-    }}
-}
-
-fn main() {
-    let s = foo::m!(S, x);
-    assert_eq!(s.x, 0);
-}
diff --git a/src/test/compile-fail/hygiene/globs.rs b/src/test/compile-fail/hygiene/globs.rs
deleted file mode 100644 (file)
index 7ba2170..0000000
+++ /dev/null
@@ -1,68 +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.
-
-#![feature(decl_macro)]
-
-mod foo {
-    pub fn f() {}
-}
-
-mod bar {
-    pub fn g() {}
-}
-
-macro m($($t:tt)*) {
-    $($t)*
-    use foo::*;
-    f();
-    g(); //~ ERROR cannot find function `g` in this scope
-}
-
-fn main() {
-    m! {
-        use bar::*;
-        g();
-        f(); //~ ERROR cannot find function `f` in this scope
-    }
-}
-
-n!(f);
-macro n($i:ident) {
-    mod foo {
-        pub fn $i() -> u32 { 0 }
-        pub fn f() {}
-
-        mod test {
-            use super::*;
-            fn g() {
-                let _: u32 = $i();
-                let _: () = f();
-            }
-        }
-
-        macro n($j:ident) {
-            mod test {
-                use super::*;
-                fn g() {
-                    let _: u32 = $i();
-                    let _: () = f();
-                    $j();
-                }
-            }
-        }
-
-        n!(f);
-        mod test2 {
-            super::n! {
-                f //~ ERROR cannot find function `f` in this scope
-            }
-        }
-    }
-}
diff --git a/src/test/compile-fail/hygiene/impl_items.rs b/src/test/compile-fail/hygiene/impl_items.rs
deleted file mode 100644 (file)
index cdba559..0000000
+++ /dev/null
@@ -1,44 +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-pretty pretty-printing is unhygienic
-
-#![feature(decl_macro)]
-
-mod foo {
-    struct S;
-    impl S {
-        fn f(&self) {}
-    }
-
-    pub macro m() {
-        let _: () = S.f(); //~ ERROR type `for<'r> fn(&'r foo::S) {foo::S::f}` is private
-    }
-}
-
-struct S;
-
-macro m($f:ident) {
-    impl S {
-        fn f(&self) -> u32 { 0 }
-        fn $f(&self) -> i32 { 0 }
-    }
-    fn f() {
-        let _: u32 = S.f();
-        let _: i32 = S.$f();
-    }
-}
-
-m!(f);
-
-fn main() {
-    let _: i32 = S.f();
-    foo::m!();
-}
diff --git a/src/test/compile-fail/hygiene/intercrate.rs b/src/test/compile-fail/hygiene/intercrate.rs
deleted file mode 100644 (file)
index 50fc985..0000000
+++ /dev/null
@@ -1,23 +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-pretty pretty-printing is unhygienic
-
-// aux-build:intercrate.rs
-
-// error-pattern:type `fn() -> u32 {intercrate::foo::bar::f}` is private
-
-#![feature(decl_macro)]
-
-extern crate intercrate;
-
-fn main() {
-    assert_eq!(intercrate::foo::m!(), 1);
-}
diff --git a/src/test/compile-fail/hygiene/nested_macro_privacy.rs b/src/test/compile-fail/hygiene/nested_macro_privacy.rs
deleted file mode 100644 (file)
index 6612359..0000000
+++ /dev/null
@@ -1,27 +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.
-
-#![feature(decl_macro)]
-
-macro n($foo:ident, $S:ident, $i:ident, $m:ident) {
-    mod $foo {
-        #[derive(Default)]
-        pub struct $S { $i: u32 }
-        pub macro $m($e:expr) { $e.$i }
-    }
-}
-
-n!(foo, S, i, m);
-
-fn main() {
-    use foo::{S, m};
-    S::default().i; //~ ERROR field `i` of struct `foo::S` is private
-    m!(S::default()); // ok
-}
diff --git a/src/test/compile-fail/hygiene/no_implicit_prelude.rs b/src/test/compile-fail/hygiene/no_implicit_prelude.rs
deleted file mode 100644 (file)
index c90c7b3..0000000
+++ /dev/null
@@ -1,25 +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.
-
-#![feature(decl_macro)]
-
-mod foo {
-    pub macro m() { Vec::new(); ().clone() }
-    fn f() { ::bar::m!(); }
-}
-
-#[no_implicit_prelude]
-mod bar {
-    pub macro m() {
-        Vec::new(); //~ ERROR failed to resolve
-        ().clone() //~ ERROR no method named `clone` found
-    }
-    fn f() { ::foo::m!(); }
-}
diff --git a/src/test/compile-fail/hygiene/privacy.rs b/src/test/compile-fail/hygiene/privacy.rs
deleted file mode 100644 (file)
index 987cad1..0000000
+++ /dev/null
@@ -1,28 +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.
-
-#![feature(decl_macro)]
-
-mod foo {
-    fn f() {}
-
-    pub macro m($e:expr) {
-        f();
-        self::f();
-        ::foo::f();
-        $e
-    }
-}
-
-fn main() {
-    foo::m!(
-        foo::f() //~ ERROR `f` is private
-    );
-}
diff --git a/src/test/compile-fail/hygiene/trait_items.rs b/src/test/compile-fail/hygiene/trait_items.rs
deleted file mode 100644 (file)
index 3bd19cb..0000000
+++ /dev/null
@@ -1,31 +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.
-
-#![feature(decl_macro)]
-
-mod foo {
-    pub trait T {
-        fn f(&self) {}
-    }
-    impl T for () {}
-}
-
-mod bar {
-    use foo::*;
-    pub macro m() { ().f() }
-    fn f() { ::baz::m!(); }
-}
-
-mod baz {
-    pub macro m() { ().f() } //~ ERROR no method named `f` found for type `()` in the current scope
-    fn f() { ::bar::m!(); }
-}
-
-fn main() {}
diff --git a/src/test/compile-fail/pattern-macro-hygiene.rs b/src/test/compile-fail/pattern-macro-hygiene.rs
deleted file mode 100644 (file)
index 26d411c..0000000
+++ /dev/null
@@ -1,16 +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 <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.
-
-macro_rules! foo { () => ( x ) }
-
-fn main() {
-    let foo!() = 2;
-    x + 1; //~ ERROR cannot find value `x` in this scope
-}
diff --git a/src/test/ui/hygiene/assoc_item_ctxt.rs b/src/test/ui/hygiene/assoc_item_ctxt.rs
new file mode 100644 (file)
index 0000000..e336b0d
--- /dev/null
@@ -0,0 +1,52 @@
+// 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-pretty pretty-printing is unhygienic
+
+#![feature(decl_macro)]
+#![allow(unused)]
+
+mod ok {
+    macro mac_trait_item($method: ident) {
+        fn $method();
+    }
+
+    trait Tr {
+        mac_trait_item!(method);
+    }
+
+    macro mac_trait_impl() {
+        impl Tr for u8 { // OK
+            fn method() {} // OK
+        }
+    }
+
+    mac_trait_impl!();
+}
+
+mod error {
+    macro mac_trait_item() {
+        fn method();
+    }
+
+    trait Tr {
+        mac_trait_item!();
+    }
+
+    macro mac_trait_impl() {
+        impl Tr for u8 { //~ ERROR not all trait items implemented, missing: `method`
+            fn method() {} //~ ERROR method `method` is not a member of trait `Tr`
+        }
+    }
+
+    mac_trait_impl!();
+}
+
+fn main() {}
diff --git a/src/test/ui/hygiene/assoc_item_ctxt.stderr b/src/test/ui/hygiene/assoc_item_ctxt.stderr
new file mode 100644 (file)
index 0000000..8b41040
--- /dev/null
@@ -0,0 +1,25 @@
+error[E0407]: method `method` is not a member of trait `Tr`
+  --> $DIR/assoc_item_ctxt.rs:45:13
+   |
+LL |             fn method() {} //~ ERROR method `method` is not a member of trait `Tr`
+   |             ^^^^^^^^^^^^^^ not a member of trait `Tr`
+...
+LL |     mac_trait_impl!();
+   |     ------------------ in this macro invocation
+
+error[E0046]: not all trait items implemented, missing: `method`
+  --> $DIR/assoc_item_ctxt.rs:44:9
+   |
+LL |         fn method();
+   |         ------------ `method` from trait
+...
+LL |         impl Tr for u8 { //~ ERROR not all trait items implemented, missing: `method`
+   |         ^^^^^^^^^^^^^^ missing `method` in implementation
+...
+LL |     mac_trait_impl!();
+   |     ------------------ in this macro invocation
+
+error: aborting due to 2 previous errors
+
+Some errors occurred: E0046, E0407.
+For more information about an error, try `rustc --explain E0046`.
diff --git a/src/test/ui/hygiene/assoc_ty_bindings.rs b/src/test/ui/hygiene/assoc_ty_bindings.rs
new file mode 100644 (file)
index 0000000..46a1387
--- /dev/null
@@ -0,0 +1,49 @@
+// 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-pretty pretty-printing is unhygienic
+
+#![feature(decl_macro, associated_type_defaults)]
+#![feature(rustc_attrs)]
+
+trait Base {
+    type AssocTy;
+    fn f();
+}
+trait Derived: Base {
+    fn g();
+}
+
+macro mac() {
+    type A = Base<AssocTy = u8>;
+    type B = Derived<AssocTy = u8>;
+
+    impl Base for u8 {
+        type AssocTy = u8;
+        fn f() {
+            let _: Self::AssocTy;
+        }
+    }
+    impl Derived for u8 {
+        fn g() {
+            let _: Self::AssocTy;
+        }
+    }
+
+    fn h<T: Base, U: Derived>() {
+        let _: T::AssocTy;
+        let _: U::AssocTy;
+    }
+}
+
+mac!();
+
+#[rustc_error]
+fn main() {} //~ ERROR compilation successful
diff --git a/src/test/ui/hygiene/assoc_ty_bindings.stderr b/src/test/ui/hygiene/assoc_ty_bindings.stderr
new file mode 100644 (file)
index 0000000..0adf809
--- /dev/null
@@ -0,0 +1,8 @@
+error: compilation successful
+  --> $DIR/assoc_ty_bindings.rs:49:1
+   |
+LL | fn main() {} //~ ERROR compilation successful
+   | ^^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/hygiene/auxiliary/intercrate.rs b/src/test/ui/hygiene/auxiliary/intercrate.rs
new file mode 100644 (file)
index 0000000..aa67e5c
--- /dev/null
@@ -0,0 +1,21 @@
+// 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.
+
+#![feature(decl_macro)]
+
+pub mod foo {
+    pub use self::bar::m;
+    mod bar {
+        fn f() -> u32 { 1 }
+        pub macro m() {
+            f();
+        }
+    }
+}
diff --git a/src/test/ui/hygiene/fields.rs b/src/test/ui/hygiene/fields.rs
new file mode 100644 (file)
index 0000000..6421777
--- /dev/null
@@ -0,0 +1,40 @@
+// 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-pretty pretty-printing is unhygienic
+
+#![feature(decl_macro)]
+
+mod foo {
+    struct S { x: u32 }
+    struct T(u32);
+
+    pub macro m($S:ident, $x:ident) {{
+        struct $S {
+            $x: u32,
+            x: i32,
+        }
+
+        let s = S { x: 0 }; //~ ERROR type `foo::S` is private
+        let _ = s.x; //~ ERROR type `foo::S` is private
+
+        let t = T(0); //~ ERROR type `foo::T` is private
+        let _ = t.0; //~ ERROR type `foo::T` is private
+
+        let s = $S { $x: 0, x: 1 };
+        assert_eq!((s.$x, s.x), (0, 1));
+        s
+    }}
+}
+
+fn main() {
+    let s = foo::m!(S, x);
+    assert_eq!(s.x, 0);
+}
diff --git a/src/test/ui/hygiene/fields.stderr b/src/test/ui/hygiene/fields.stderr
new file mode 100644 (file)
index 0000000..c4be183
--- /dev/null
@@ -0,0 +1,38 @@
+error: type `foo::S` is private
+  --> $DIR/fields.rs:25:17
+   |
+LL |         let s = S { x: 0 }; //~ ERROR type `foo::S` is private
+   |                 ^^^^^^^^^^
+...
+LL |     let s = foo::m!(S, x);
+   |             ------------- in this macro invocation
+
+error: type `foo::S` is private
+  --> $DIR/fields.rs:26:17
+   |
+LL |         let _ = s.x; //~ ERROR type `foo::S` is private
+   |                 ^
+...
+LL |     let s = foo::m!(S, x);
+   |             ------------- in this macro invocation
+
+error: type `foo::T` is private
+  --> $DIR/fields.rs:28:17
+   |
+LL |         let t = T(0); //~ ERROR type `foo::T` is private
+   |                 ^^^^
+...
+LL |     let s = foo::m!(S, x);
+   |             ------------- in this macro invocation
+
+error: type `foo::T` is private
+  --> $DIR/fields.rs:29:17
+   |
+LL |         let _ = t.0; //~ ERROR type `foo::T` is private
+   |                 ^
+...
+LL |     let s = foo::m!(S, x);
+   |             ------------- in this macro invocation
+
+error: aborting due to 4 previous errors
+
diff --git a/src/test/ui/hygiene/for-loop.rs b/src/test/ui/hygiene/for-loop.rs
new file mode 100644 (file)
index 0000000..d938642
--- /dev/null
@@ -0,0 +1,18 @@
+// 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.
+
+// for-loops are expanded in the front end, and use an `iter` ident in their expansion. Check that
+// `iter` is not accessible inside the for loop.
+
+fn main() {
+    for _ in 0..10 {
+        iter.next();  //~ ERROR cannot find value `iter` in this scope
+    }
+}
diff --git a/src/test/ui/hygiene/for-loop.stderr b/src/test/ui/hygiene/for-loop.stderr
new file mode 100644 (file)
index 0000000..7e606b2
--- /dev/null
@@ -0,0 +1,9 @@
+error[E0425]: cannot find value `iter` in this scope
+  --> $DIR/for-loop.rs:16:9
+   |
+LL |         iter.next();  //~ ERROR cannot find value `iter` in this scope
+   |         ^^^^ not found in this scope
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/src/test/ui/hygiene/globs.rs b/src/test/ui/hygiene/globs.rs
new file mode 100644 (file)
index 0000000..7ba2170
--- /dev/null
@@ -0,0 +1,68 @@
+// 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.
+
+#![feature(decl_macro)]
+
+mod foo {
+    pub fn f() {}
+}
+
+mod bar {
+    pub fn g() {}
+}
+
+macro m($($t:tt)*) {
+    $($t)*
+    use foo::*;
+    f();
+    g(); //~ ERROR cannot find function `g` in this scope
+}
+
+fn main() {
+    m! {
+        use bar::*;
+        g();
+        f(); //~ ERROR cannot find function `f` in this scope
+    }
+}
+
+n!(f);
+macro n($i:ident) {
+    mod foo {
+        pub fn $i() -> u32 { 0 }
+        pub fn f() {}
+
+        mod test {
+            use super::*;
+            fn g() {
+                let _: u32 = $i();
+                let _: () = f();
+            }
+        }
+
+        macro n($j:ident) {
+            mod test {
+                use super::*;
+                fn g() {
+                    let _: u32 = $i();
+                    let _: () = f();
+                    $j();
+                }
+            }
+        }
+
+        n!(f);
+        mod test2 {
+            super::n! {
+                f //~ ERROR cannot find function `f` in this scope
+            }
+        }
+    }
+}
diff --git a/src/test/ui/hygiene/globs.stderr b/src/test/ui/hygiene/globs.stderr
new file mode 100644 (file)
index 0000000..d77242e
--- /dev/null
@@ -0,0 +1,49 @@
+error[E0425]: cannot find function `f` in this scope
+  --> $DIR/globs.rs:32:9
+   |
+LL |         f(); //~ ERROR cannot find function `f` in this scope
+   |         ^ not found in this scope
+help: possible candidates are found in other modules, you can import them into scope
+   |
+LL | use foo::f;
+   |
+LL | use foo::f;
+   |
+LL | use foo::f;
+   |
+
+error[E0425]: cannot find function `g` in this scope
+  --> $DIR/globs.rs:25:5
+   |
+LL |       g(); //~ ERROR cannot find function `g` in this scope
+   |       ^ not found in this scope
+...
+LL | /     m! {
+LL | |         use bar::*;
+LL | |         g();
+LL | |         f(); //~ ERROR cannot find function `f` in this scope
+LL | |     }
+   | |_____- in this macro invocation
+help: possible candidates are found in other modules, you can import them into scope
+   |
+LL | use bar::g;
+   |
+LL | use foo::test2::test::g;
+   |
+LL | use foo::test::g;
+   |
+LL | use foo::test::g;
+   |
+
+error[E0425]: cannot find function `f` in this scope
+  --> $DIR/globs.rs:64:17
+   |
+LL | n!(f);
+   | ------ in this macro invocation
+...
+LL |                 f //~ ERROR cannot find function `f` in this scope
+   |                 ^ not found in this scope
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/src/test/ui/hygiene/impl_items.rs b/src/test/ui/hygiene/impl_items.rs
new file mode 100644 (file)
index 0000000..cdba559
--- /dev/null
@@ -0,0 +1,44 @@
+// 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-pretty pretty-printing is unhygienic
+
+#![feature(decl_macro)]
+
+mod foo {
+    struct S;
+    impl S {
+        fn f(&self) {}
+    }
+
+    pub macro m() {
+        let _: () = S.f(); //~ ERROR type `for<'r> fn(&'r foo::S) {foo::S::f}` is private
+    }
+}
+
+struct S;
+
+macro m($f:ident) {
+    impl S {
+        fn f(&self) -> u32 { 0 }
+        fn $f(&self) -> i32 { 0 }
+    }
+    fn f() {
+        let _: u32 = S.f();
+        let _: i32 = S.$f();
+    }
+}
+
+m!(f);
+
+fn main() {
+    let _: i32 = S.f();
+    foo::m!();
+}
diff --git a/src/test/ui/hygiene/impl_items.stderr b/src/test/ui/hygiene/impl_items.stderr
new file mode 100644 (file)
index 0000000..dbcf535
--- /dev/null
@@ -0,0 +1,11 @@
+error: type `for<'r> fn(&'r foo::S) {foo::S::f}` is private
+  --> $DIR/impl_items.rs:22:23
+   |
+LL |         let _: () = S.f(); //~ ERROR type `for<'r> fn(&'r foo::S) {foo::S::f}` is private
+   |                       ^
+...
+LL |     foo::m!();
+   |     ---------- in this macro invocation
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/hygiene/intercrate.rs b/src/test/ui/hygiene/intercrate.rs
new file mode 100644 (file)
index 0000000..50fc985
--- /dev/null
@@ -0,0 +1,23 @@
+// 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-pretty pretty-printing is unhygienic
+
+// aux-build:intercrate.rs
+
+// error-pattern:type `fn() -> u32 {intercrate::foo::bar::f}` is private
+
+#![feature(decl_macro)]
+
+extern crate intercrate;
+
+fn main() {
+    assert_eq!(intercrate::foo::m!(), 1);
+}
diff --git a/src/test/ui/hygiene/intercrate.stderr b/src/test/ui/hygiene/intercrate.stderr
new file mode 100644 (file)
index 0000000..ecbc6e7
--- /dev/null
@@ -0,0 +1,10 @@
+error: type `fn() -> u32 {intercrate::foo::bar::f}` is private
+  --> $DIR/intercrate.rs:22:16
+   |
+LL |     assert_eq!(intercrate::foo::m!(), 1);
+   |                ^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/hygiene/nested_macro_privacy.rs b/src/test/ui/hygiene/nested_macro_privacy.rs
new file mode 100644 (file)
index 0000000..6612359
--- /dev/null
@@ -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 <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.
+
+#![feature(decl_macro)]
+
+macro n($foo:ident, $S:ident, $i:ident, $m:ident) {
+    mod $foo {
+        #[derive(Default)]
+        pub struct $S { $i: u32 }
+        pub macro $m($e:expr) { $e.$i }
+    }
+}
+
+n!(foo, S, i, m);
+
+fn main() {
+    use foo::{S, m};
+    S::default().i; //~ ERROR field `i` of struct `foo::S` is private
+    m!(S::default()); // ok
+}
diff --git a/src/test/ui/hygiene/nested_macro_privacy.stderr b/src/test/ui/hygiene/nested_macro_privacy.stderr
new file mode 100644 (file)
index 0000000..1179065
--- /dev/null
@@ -0,0 +1,9 @@
+error[E0616]: field `i` of struct `foo::S` is private
+  --> $DIR/nested_macro_privacy.rs:25:5
+   |
+LL |     S::default().i; //~ ERROR field `i` of struct `foo::S` is private
+   |     ^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0616`.
diff --git a/src/test/ui/hygiene/no_implicit_prelude.rs b/src/test/ui/hygiene/no_implicit_prelude.rs
new file mode 100644 (file)
index 0000000..c90c7b3
--- /dev/null
@@ -0,0 +1,25 @@
+// 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.
+
+#![feature(decl_macro)]
+
+mod foo {
+    pub macro m() { Vec::new(); ().clone() }
+    fn f() { ::bar::m!(); }
+}
+
+#[no_implicit_prelude]
+mod bar {
+    pub macro m() {
+        Vec::new(); //~ ERROR failed to resolve
+        ().clone() //~ ERROR no method named `clone` found
+    }
+    fn f() { ::foo::m!(); }
+}
diff --git a/src/test/ui/hygiene/no_implicit_prelude.stderr b/src/test/ui/hygiene/no_implicit_prelude.stderr
new file mode 100644 (file)
index 0000000..5753d1a
--- /dev/null
@@ -0,0 +1,30 @@
+error[E0433]: failed to resolve. Use of undeclared type or module `Vec`
+  --> $DIR/no_implicit_prelude.rs:21:9
+   |
+LL |     fn f() { ::bar::m!(); }
+   |              ------------ in this macro invocation
+...
+LL |         Vec::new(); //~ ERROR failed to resolve
+   |         ^^^ Use of undeclared type or module `Vec`
+
+error[E0601]: `main` function not found in crate `no_implicit_prelude`
+   |
+   = note: consider adding a `main` function to `$DIR/no_implicit_prelude.rs`
+
+error[E0599]: no method named `clone` found for type `()` in the current scope
+  --> $DIR/no_implicit_prelude.rs:22:12
+   |
+LL |     fn f() { ::bar::m!(); }
+   |              ------------ in this macro invocation
+...
+LL |         ().clone() //~ ERROR no method named `clone` found
+   |            ^^^^^
+   |
+   = help: items from traits can only be used if the trait is in scope
+   = note: the following trait is implemented but not in scope, perhaps add a `use` for it:
+           candidate #1: `use std::clone::Clone;`
+
+error: aborting due to 3 previous errors
+
+Some errors occurred: E0433, E0599, E0601.
+For more information about an error, try `rustc --explain E0433`.
diff --git a/src/test/ui/hygiene/pattern-macro.rs b/src/test/ui/hygiene/pattern-macro.rs
new file mode 100644 (file)
index 0000000..26d411c
--- /dev/null
@@ -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 <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.
+
+macro_rules! foo { () => ( x ) }
+
+fn main() {
+    let foo!() = 2;
+    x + 1; //~ ERROR cannot find value `x` in this scope
+}
diff --git a/src/test/ui/hygiene/pattern-macro.stderr b/src/test/ui/hygiene/pattern-macro.stderr
new file mode 100644 (file)
index 0000000..b26084d
--- /dev/null
@@ -0,0 +1,9 @@
+error[E0425]: cannot find value `x` in this scope
+  --> $DIR/pattern-macro.rs:15:5
+   |
+LL |     x + 1; //~ ERROR cannot find value `x` in this scope
+   |     ^ not found in this scope
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/src/test/ui/hygiene/privacy.rs b/src/test/ui/hygiene/privacy.rs
new file mode 100644 (file)
index 0000000..987cad1
--- /dev/null
@@ -0,0 +1,28 @@
+// 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.
+
+#![feature(decl_macro)]
+
+mod foo {
+    fn f() {}
+
+    pub macro m($e:expr) {
+        f();
+        self::f();
+        ::foo::f();
+        $e
+    }
+}
+
+fn main() {
+    foo::m!(
+        foo::f() //~ ERROR `f` is private
+    );
+}
diff --git a/src/test/ui/hygiene/privacy.stderr b/src/test/ui/hygiene/privacy.stderr
new file mode 100644 (file)
index 0000000..808d244
--- /dev/null
@@ -0,0 +1,9 @@
+error[E0603]: function `f` is private
+  --> $DIR/privacy.rs:26:9
+   |
+LL |         foo::f() //~ ERROR `f` is private
+   |         ^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0603`.
diff --git a/src/test/ui/hygiene/trait_items.rs b/src/test/ui/hygiene/trait_items.rs
new file mode 100644 (file)
index 0000000..3bd19cb
--- /dev/null
@@ -0,0 +1,31 @@
+// 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.
+
+#![feature(decl_macro)]
+
+mod foo {
+    pub trait T {
+        fn f(&self) {}
+    }
+    impl T for () {}
+}
+
+mod bar {
+    use foo::*;
+    pub macro m() { ().f() }
+    fn f() { ::baz::m!(); }
+}
+
+mod baz {
+    pub macro m() { ().f() } //~ ERROR no method named `f` found for type `()` in the current scope
+    fn f() { ::bar::m!(); }
+}
+
+fn main() {}
diff --git a/src/test/ui/hygiene/trait_items.stderr b/src/test/ui/hygiene/trait_items.stderr
new file mode 100644 (file)
index 0000000..56d9c58
--- /dev/null
@@ -0,0 +1,16 @@
+error[E0599]: no method named `f` found for type `()` in the current scope
+  --> $DIR/trait_items.rs:27:24
+   |
+LL |     fn f() { ::baz::m!(); }
+   |              ------------ in this macro invocation
+...
+LL |     pub macro m() { ().f() } //~ ERROR no method named `f` found for type `()` in the current scope
+   |                        ^
+   |
+   = help: items from traits can only be used if the trait is in scope
+   = note: the following trait is implemented but not in scope, perhaps add a `use` for it:
+           candidate #1: `use foo::T;`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0599`.