summary refs log tree commit diff
path: root/src/test/ui/tuple/tuple-struct-fields
diff options
context:
space:
mode:
authorDavid Wood <david@davidtw.co>2018-08-08 14:50:16 +0200
committerDavid Wood <david@davidtw.co>2018-08-14 11:12:09 +0200
commit3fc7ab237314a4ce85e612b4ce590c27f1425291 (patch)
treec775f852e05e1272032cb053ee347315c973c7b5 /src/test/ui/tuple/tuple-struct-fields
parent3e0a4079884eab5b54489c92f7428cda2797ea5c (diff)
downloadrust-3fc7ab237314a4ce85e612b4ce590c27f1425291.tar.gz
rust-3fc7ab237314a4ce85e612b4ce590c27f1425291.zip
Merged migrated compile-fail tests and ui tests. Fixes #46841.
Diffstat (limited to 'src/test/ui/tuple/tuple-struct-fields')
-rw-r--r--src/test/ui/tuple/tuple-struct-fields/test.rs17
-rw-r--r--src/test/ui/tuple/tuple-struct-fields/test.stderr20
-rw-r--r--src/test/ui/tuple/tuple-struct-fields/test2.rs22
-rw-r--r--src/test/ui/tuple/tuple-struct-fields/test2.stderr11
-rw-r--r--src/test/ui/tuple/tuple-struct-fields/test3.rs22
-rw-r--r--src/test/ui/tuple/tuple-struct-fields/test3.stderr11
6 files changed, 103 insertions, 0 deletions
diff --git a/src/test/ui/tuple/tuple-struct-fields/test.rs b/src/test/ui/tuple/tuple-struct-fields/test.rs
new file mode 100644
index 00000000000..22d54a38340
--- /dev/null
+++ b/src/test/ui/tuple/tuple-struct-fields/test.rs
@@ -0,0 +1,17 @@
+// 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 <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 {
+    type T = ();
+    struct S1(pub(in foo) (), pub(T), pub(crate) (), pub(((), T)));
+    struct S2(pub((foo)) ());
+    //~^ ERROR expected one of `)` or `,`, found `(`
+    //~| ERROR cannot find type `foo` in this scope
+}
diff --git a/src/test/ui/tuple/tuple-struct-fields/test.stderr b/src/test/ui/tuple/tuple-struct-fields/test.stderr
new file mode 100644
index 00000000000..59228ea8c14
--- /dev/null
+++ b/src/test/ui/tuple/tuple-struct-fields/test.stderr
@@ -0,0 +1,20 @@
+error: expected one of `)` or `,`, found `(`
+  --> $DIR/test.rs:14:26
+   |
+LL |     struct S2(pub((foo)) ());
+   |                          ^ expected one of `)` or `,` here
+
+error[E0412]: cannot find type `foo` in this scope
+  --> $DIR/test.rs:14:20
+   |
+LL |     struct S2(pub((foo)) ());
+   |                    ^^^ not found in this scope
+
+error[E0601]: `main` function not found in crate `test`
+   |
+   = note: consider adding a `main` function to `$DIR/test.rs`
+
+error: aborting due to 3 previous errors
+
+Some errors occurred: E0412, E0601.
+For more information about an error, try `rustc --explain E0412`.
diff --git a/src/test/ui/tuple/tuple-struct-fields/test2.rs b/src/test/ui/tuple/tuple-struct-fields/test2.rs
new file mode 100644
index 00000000000..eead027cb13
--- /dev/null
+++ b/src/test/ui/tuple/tuple-struct-fields/test2.rs
@@ -0,0 +1,22 @@
+// 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 <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! define_struct {
+    ($t:ty) => {
+        struct S1(pub $t);
+        struct S2(pub (in foo) ());
+        struct S3(pub $t ());
+        //~^ ERROR expected one of `)` or `,`, found `(`
+    }
+}
+
+mod foo {
+    define_struct! { (foo) }
+}
diff --git a/src/test/ui/tuple/tuple-struct-fields/test2.stderr b/src/test/ui/tuple/tuple-struct-fields/test2.stderr
new file mode 100644
index 00000000000..983e74772ac
--- /dev/null
+++ b/src/test/ui/tuple/tuple-struct-fields/test2.stderr
@@ -0,0 +1,11 @@
+error: expected one of `)` or `,`, found `(`
+  --> $DIR/test2.rs:15:26
+   |
+LL |         struct S3(pub $t ());
+   |                          ^ expected one of `)` or `,` here
+...
+LL |     define_struct! { (foo) }
+   |     ------------------------ in this macro invocation
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/tuple/tuple-struct-fields/test3.rs b/src/test/ui/tuple/tuple-struct-fields/test3.rs
new file mode 100644
index 00000000000..d666c8abd3c
--- /dev/null
+++ b/src/test/ui/tuple/tuple-struct-fields/test3.rs
@@ -0,0 +1,22 @@
+// 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 <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! define_struct {
+    ($t:ty) => {
+        struct S1(pub($t));
+        struct S2(pub (in foo) ());
+        struct S3(pub($t) ());
+        //~^ ERROR expected one of `)` or `,`, found `(`
+    }
+}
+
+mod foo {
+    define_struct! { foo }
+}
diff --git a/src/test/ui/tuple/tuple-struct-fields/test3.stderr b/src/test/ui/tuple/tuple-struct-fields/test3.stderr
new file mode 100644
index 00000000000..6738595b997
--- /dev/null
+++ b/src/test/ui/tuple/tuple-struct-fields/test3.stderr
@@ -0,0 +1,11 @@
+error: expected one of `)` or `,`, found `(`
+  --> $DIR/test3.rs:15:27
+   |
+LL |         struct S3(pub($t) ());
+   |                           ^ expected one of `)` or `,` here
+...
+LL |     define_struct! { foo }
+   |     ---------------------- in this macro invocation
+
+error: aborting due to previous error
+