summaryrefslogtreecommitdiffstats
path: root/tests/ui/empty
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:58 +0000
commita4b7ed7a42c716ab9f05e351f003d589124fd55d (patch)
treeb620cd3f223850b28716e474e80c58059dca5dd4 /tests/ui/empty
parentAdding upstream version 1.67.1+dfsg1. (diff)
downloadrustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.tar.xz
rustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.zip
Adding upstream version 1.68.2+dfsg1.upstream/1.68.2+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/empty')
-rw-r--r--tests/ui/empty/auxiliary/empty-struct.rs9
-rw-r--r--tests/ui/empty/auxiliary/two_macros.rs5
-rw-r--r--tests/ui/empty/empty-attributes.rs17
-rw-r--r--tests/ui/empty/empty-attributes.stderr71
-rw-r--r--tests/ui/empty/empty-comment.rs11
-rw-r--r--tests/ui/empty/empty-comment.stderr17
-rw-r--r--tests/ui/empty/empty-linkname.rs4
-rw-r--r--tests/ui/empty/empty-linkname.stderr9
-rw-r--r--tests/ui/empty/empty-macro-use.rs9
-rw-r--r--tests/ui/empty/empty-macro-use.stderr11
-rw-r--r--tests/ui/empty/empty-never-array.rs18
-rw-r--r--tests/ui/empty/empty-never-array.stderr24
-rw-r--r--tests/ui/empty/empty-struct-braces-expr.rs29
-rw-r--r--tests/ui/empty/empty-struct-braces-expr.stderr130
-rw-r--r--tests/ui/empty/empty-struct-braces-pat-1.rs34
-rw-r--r--tests/ui/empty/empty-struct-braces-pat-1.stderr15
-rw-r--r--tests/ui/empty/empty-struct-braces-pat-2.rs26
-rw-r--r--tests/ui/empty/empty-struct-braces-pat-2.stderr95
-rw-r--r--tests/ui/empty/empty-struct-braces-pat-3.rs32
-rw-r--r--tests/ui/empty/empty-struct-braces-pat-3.stderr27
-rw-r--r--tests/ui/empty/empty-struct-tuple-pat.rs37
-rw-r--r--tests/ui/empty/empty-struct-tuple-pat.stderr59
-rw-r--r--tests/ui/empty/empty-struct-unit-expr.rs21
-rw-r--r--tests/ui/empty/empty-struct-unit-expr.stderr65
-rw-r--r--tests/ui/empty/empty-struct-unit-pat.rs54
-rw-r--r--tests/ui/empty/empty-struct-unit-pat.stderr155
-rw-r--r--tests/ui/empty/issue-37026.rs8
-rw-r--r--tests/ui/empty/issue-37026.stderr19
-rw-r--r--tests/ui/empty/no-link.rs9
29 files changed, 1020 insertions, 0 deletions
diff --git a/tests/ui/empty/auxiliary/empty-struct.rs b/tests/ui/empty/auxiliary/empty-struct.rs
new file mode 100644
index 000000000..3fb40f6bf
--- /dev/null
+++ b/tests/ui/empty/auxiliary/empty-struct.rs
@@ -0,0 +1,9 @@
+pub struct XEmpty1 {}
+pub struct XEmpty2;
+pub struct XEmpty6();
+
+pub enum XE {
+ XEmpty3 {},
+ XEmpty4,
+ XEmpty5(),
+}
diff --git a/tests/ui/empty/auxiliary/two_macros.rs b/tests/ui/empty/auxiliary/two_macros.rs
new file mode 100644
index 000000000..2330c75c8
--- /dev/null
+++ b/tests/ui/empty/auxiliary/two_macros.rs
@@ -0,0 +1,5 @@
+#[macro_export]
+macro_rules! macro_one { () => ("one") }
+
+#[macro_export]
+macro_rules! macro_two { () => ("two") }
diff --git a/tests/ui/empty/empty-attributes.rs b/tests/ui/empty/empty-attributes.rs
new file mode 100644
index 000000000..d319227b2
--- /dev/null
+++ b/tests/ui/empty/empty-attributes.rs
@@ -0,0 +1,17 @@
+#![feature(lint_reasons)]
+
+#![deny(unused_attributes)]
+#![allow()] //~ ERROR unused attribute
+#![expect()] //~ ERROR unused attribute
+#![warn()] //~ ERROR unused attribute
+#![deny()] //~ ERROR unused attribute
+#![forbid()] //~ ERROR unused attribute
+#![feature()] //~ ERROR unused attribute
+
+#[repr()] //~ ERROR unused attribute
+pub struct S;
+
+#[target_feature()] //~ ERROR unused attribute
+pub unsafe fn foo() {}
+
+fn main() {}
diff --git a/tests/ui/empty/empty-attributes.stderr b/tests/ui/empty/empty-attributes.stderr
new file mode 100644
index 000000000..01d0d5a6b
--- /dev/null
+++ b/tests/ui/empty/empty-attributes.stderr
@@ -0,0 +1,71 @@
+error: unused attribute
+ --> $DIR/empty-attributes.rs:11:1
+ |
+LL | #[repr()]
+ | ^^^^^^^^^ help: remove this attribute
+ |
+ = note: attribute `repr` with an empty list has no effect
+note: the lint level is defined here
+ --> $DIR/empty-attributes.rs:3:9
+ |
+LL | #![deny(unused_attributes)]
+ | ^^^^^^^^^^^^^^^^^
+
+error: unused attribute
+ --> $DIR/empty-attributes.rs:14:1
+ |
+LL | #[target_feature()]
+ | ^^^^^^^^^^^^^^^^^^^ help: remove this attribute
+ |
+ = note: attribute `target_feature` with an empty list has no effect
+
+error: unused attribute
+ --> $DIR/empty-attributes.rs:4:1
+ |
+LL | #![allow()]
+ | ^^^^^^^^^^^ help: remove this attribute
+ |
+ = note: attribute `allow` with an empty list has no effect
+
+error: unused attribute
+ --> $DIR/empty-attributes.rs:5:1
+ |
+LL | #![expect()]
+ | ^^^^^^^^^^^^ help: remove this attribute
+ |
+ = note: attribute `expect` with an empty list has no effect
+
+error: unused attribute
+ --> $DIR/empty-attributes.rs:6:1
+ |
+LL | #![warn()]
+ | ^^^^^^^^^^ help: remove this attribute
+ |
+ = note: attribute `warn` with an empty list has no effect
+
+error: unused attribute
+ --> $DIR/empty-attributes.rs:7:1
+ |
+LL | #![deny()]
+ | ^^^^^^^^^^ help: remove this attribute
+ |
+ = note: attribute `deny` with an empty list has no effect
+
+error: unused attribute
+ --> $DIR/empty-attributes.rs:8:1
+ |
+LL | #![forbid()]
+ | ^^^^^^^^^^^^ help: remove this attribute
+ |
+ = note: attribute `forbid` with an empty list has no effect
+
+error: unused attribute
+ --> $DIR/empty-attributes.rs:9:1
+ |
+LL | #![feature()]
+ | ^^^^^^^^^^^^^ help: remove this attribute
+ |
+ = note: attribute `feature` with an empty list has no effect
+
+error: aborting due to 8 previous errors
+
diff --git a/tests/ui/empty/empty-comment.rs b/tests/ui/empty/empty-comment.rs
new file mode 100644
index 000000000..174274d28
--- /dev/null
+++ b/tests/ui/empty/empty-comment.rs
@@ -0,0 +1,11 @@
+// `/**/` was previously regarded as a doc comment because it starts with `/**` and ends with `*/`.
+// This could break some internal logic that assumes the length of a doc comment is at least 5,
+// leading to an ICE.
+
+macro_rules! one_arg_macro {
+ ($fmt:expr) => (print!(concat!($fmt, "\n")));
+}
+
+fn main() {
+ one_arg_macro!(/**/); //~ ERROR unexpected end
+}
diff --git a/tests/ui/empty/empty-comment.stderr b/tests/ui/empty/empty-comment.stderr
new file mode 100644
index 000000000..7cc8d8fe9
--- /dev/null
+++ b/tests/ui/empty/empty-comment.stderr
@@ -0,0 +1,17 @@
+error: unexpected end of macro invocation
+ --> $DIR/empty-comment.rs:10:5
+ |
+LL | macro_rules! one_arg_macro {
+ | -------------------------- when calling this macro
+...
+LL | one_arg_macro!(/**/);
+ | ^^^^^^^^^^^^^^^^^^^^ missing tokens in macro arguments
+ |
+note: while trying to match meta-variable `$fmt:expr`
+ --> $DIR/empty-comment.rs:6:6
+ |
+LL | ($fmt:expr) => (print!(concat!($fmt, "\n")));
+ | ^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/tests/ui/empty/empty-linkname.rs b/tests/ui/empty/empty-linkname.rs
new file mode 100644
index 000000000..7113d913c
--- /dev/null
+++ b/tests/ui/empty/empty-linkname.rs
@@ -0,0 +1,4 @@
+#[link(name = "")] //~ ERROR: link name must not be empty
+extern "C" {}
+
+fn main() {}
diff --git a/tests/ui/empty/empty-linkname.stderr b/tests/ui/empty/empty-linkname.stderr
new file mode 100644
index 000000000..adcf3670d
--- /dev/null
+++ b/tests/ui/empty/empty-linkname.stderr
@@ -0,0 +1,9 @@
+error[E0454]: link name must not be empty
+ --> $DIR/empty-linkname.rs:1:15
+ |
+LL | #[link(name = "")]
+ | ^^ empty link name
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0454`.
diff --git a/tests/ui/empty/empty-macro-use.rs b/tests/ui/empty/empty-macro-use.rs
new file mode 100644
index 000000000..846004e66
--- /dev/null
+++ b/tests/ui/empty/empty-macro-use.rs
@@ -0,0 +1,9 @@
+// aux-build:two_macros.rs
+
+#[macro_use()]
+extern crate two_macros;
+
+pub fn main() {
+ macro_two!();
+ //~^ ERROR cannot find macro
+}
diff --git a/tests/ui/empty/empty-macro-use.stderr b/tests/ui/empty/empty-macro-use.stderr
new file mode 100644
index 000000000..e0b3b8685
--- /dev/null
+++ b/tests/ui/empty/empty-macro-use.stderr
@@ -0,0 +1,11 @@
+error: cannot find macro `macro_two` in this scope
+ --> $DIR/empty-macro-use.rs:7:5
+ |
+LL | macro_two!();
+ | ^^^^^^^^^
+ |
+ = help: consider importing this macro:
+ two_macros::macro_two
+
+error: aborting due to previous error
+
diff --git a/tests/ui/empty/empty-never-array.rs b/tests/ui/empty/empty-never-array.rs
new file mode 100644
index 000000000..fd9334610
--- /dev/null
+++ b/tests/ui/empty/empty-never-array.rs
@@ -0,0 +1,18 @@
+#![feature(never_type)]
+
+enum Helper<T, U> {
+ T(T, [!; 0]),
+ #[allow(dead_code)]
+ U(U),
+}
+
+fn transmute<T, U>(t: T) -> U {
+ let Helper::U(u) = Helper::T(t, []);
+ //~^ ERROR refutable pattern in local binding
+ //~| `Helper::T(_, _)` not covered
+ u
+}
+
+fn main() {
+ println!("{:?}", transmute::<&str, (*const u8, u64)>("type safety"));
+}
diff --git a/tests/ui/empty/empty-never-array.stderr b/tests/ui/empty/empty-never-array.stderr
new file mode 100644
index 000000000..a488e484b
--- /dev/null
+++ b/tests/ui/empty/empty-never-array.stderr
@@ -0,0 +1,24 @@
+error[E0005]: refutable pattern in local binding
+ --> $DIR/empty-never-array.rs:10:9
+ |
+LL | let Helper::U(u) = Helper::T(t, []);
+ | ^^^^^^^^^^^^ pattern `Helper::T(_, _)` not covered
+ |
+ = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant
+ = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html
+note: `Helper<T, U>` defined here
+ --> $DIR/empty-never-array.rs:3:6
+ |
+LL | enum Helper<T, U> {
+ | ^^^^^^
+LL | T(T, [!; 0]),
+ | - not covered
+ = note: the matched value is of type `Helper<T, U>`
+help: you might want to use `let else` to handle the variant that isn't matched
+ |
+LL | let Helper::U(u) = Helper::T(t, []) else { todo!() };
+ | ++++++++++++++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0005`.
diff --git a/tests/ui/empty/empty-struct-braces-expr.rs b/tests/ui/empty/empty-struct-braces-expr.rs
new file mode 100644
index 000000000..2aab3e777
--- /dev/null
+++ b/tests/ui/empty/empty-struct-braces-expr.rs
@@ -0,0 +1,29 @@
+// Can't use empty braced struct as constant or constructor function
+
+// aux-build:empty-struct.rs
+
+extern crate empty_struct;
+use empty_struct::*;
+
+struct Empty1 {}
+
+enum E {
+ Empty3 {}
+}
+
+fn main() {
+ let e1 = Empty1; //~ ERROR expected value, found struct `Empty1`
+ let e1 = Empty1();
+ //~^ ERROR expected function, tuple struct or tuple variant, found struct `Empty1`
+ let e3 = E::Empty3; //~ ERROR expected value, found struct variant `E::Empty3`
+ let e3 = E::Empty3();
+ //~^ ERROR expected value, found struct variant `E::Empty3`
+
+ let xe1 = XEmpty1; //~ ERROR expected value, found struct `XEmpty1`
+ let xe1 = XEmpty1();
+ //~^ ERROR expected function, tuple struct or tuple variant, found struct `XEmpty1`
+ let xe3 = XE::Empty3; //~ ERROR no variant or associated item named `Empty3` found for enum
+ let xe3 = XE::Empty3(); //~ ERROR no variant or associated item named `Empty3` found for enum
+
+ XE::Empty1 {}; //~ ERROR no variant named `Empty1` found for enum `empty_struct::XE`
+}
diff --git a/tests/ui/empty/empty-struct-braces-expr.stderr b/tests/ui/empty/empty-struct-braces-expr.stderr
new file mode 100644
index 000000000..0e580aede
--- /dev/null
+++ b/tests/ui/empty/empty-struct-braces-expr.stderr
@@ -0,0 +1,130 @@
+error[E0423]: expected value, found struct `Empty1`
+ --> $DIR/empty-struct-braces-expr.rs:15:14
+ |
+LL | struct Empty1 {}
+ | ---------------- `Empty1` defined here
+...
+LL | let e1 = Empty1;
+ | ^^^^^^
+ |
+ ::: $DIR/auxiliary/empty-struct.rs:2:1
+ |
+LL | pub struct XEmpty2;
+ | ------------------ similarly named unit struct `XEmpty2` defined here
+ |
+help: use struct literal syntax instead
+ |
+LL | let e1 = Empty1 {};
+ | ~~~~~~~~~
+help: a unit struct with a similar name exists
+ |
+LL | let e1 = XEmpty2;
+ | ~~~~~~~
+
+error[E0423]: expected value, found struct `XEmpty1`
+ --> $DIR/empty-struct-braces-expr.rs:22:15
+ |
+LL | let xe1 = XEmpty1;
+ | ^^^^^^^
+ |
+ ::: $DIR/auxiliary/empty-struct.rs:1:1
+ |
+LL | pub struct XEmpty1 {}
+ | ------------------ `XEmpty1` defined here
+LL | pub struct XEmpty2;
+ | ------------------ similarly named unit struct `XEmpty2` defined here
+ |
+help: use struct literal syntax instead
+ |
+LL | let xe1 = XEmpty1 {};
+ | ~~~~~~~~~~
+help: a unit struct with a similar name exists
+ |
+LL | let xe1 = XEmpty2;
+ | ~~~~~~~
+
+error[E0423]: expected function, tuple struct or tuple variant, found struct `Empty1`
+ --> $DIR/empty-struct-braces-expr.rs:16:14
+ |
+LL | struct Empty1 {}
+ | ---------------- `Empty1` defined here
+...
+LL | let e1 = Empty1();
+ | ^^^^^^^^
+ |
+ ::: $DIR/auxiliary/empty-struct.rs:2:1
+ |
+LL | pub struct XEmpty2;
+ | ------------------ similarly named unit struct `XEmpty2` defined here
+ |
+help: use struct literal syntax instead
+ |
+LL | let e1 = Empty1 {};
+ | ~~~~~~~~~
+help: a unit struct with a similar name exists
+ |
+LL | let e1 = XEmpty2();
+ | ~~~~~~~
+
+error[E0533]: expected value, found struct variant `E::Empty3`
+ --> $DIR/empty-struct-braces-expr.rs:18:14
+ |
+LL | let e3 = E::Empty3;
+ | ^^^^^^^^^ not a value
+
+error[E0533]: expected value, found struct variant `E::Empty3`
+ --> $DIR/empty-struct-braces-expr.rs:19:14
+ |
+LL | let e3 = E::Empty3();
+ | ^^^^^^^^^ not a value
+
+error[E0423]: expected function, tuple struct or tuple variant, found struct `XEmpty1`
+ --> $DIR/empty-struct-braces-expr.rs:23:15
+ |
+LL | let xe1 = XEmpty1();
+ | ^^^^^^^^^
+ |
+ ::: $DIR/auxiliary/empty-struct.rs:1:1
+ |
+LL | pub struct XEmpty1 {}
+ | ------------------ `XEmpty1` defined here
+LL | pub struct XEmpty2;
+ | ------------------ similarly named unit struct `XEmpty2` defined here
+ |
+help: use struct literal syntax instead
+ |
+LL | let xe1 = XEmpty1 {};
+ | ~~~~~~~~~~
+help: a unit struct with a similar name exists
+ |
+LL | let xe1 = XEmpty2();
+ | ~~~~~~~
+
+error[E0599]: no variant or associated item named `Empty3` found for enum `XE` in the current scope
+ --> $DIR/empty-struct-braces-expr.rs:25:19
+ |
+LL | let xe3 = XE::Empty3;
+ | ^^^^^^
+ | |
+ | variant or associated item not found in `XE`
+ | help: there is a variant with a similar name: `XEmpty3`
+
+error[E0599]: no variant or associated item named `Empty3` found for enum `XE` in the current scope
+ --> $DIR/empty-struct-braces-expr.rs:26:19
+ |
+LL | let xe3 = XE::Empty3();
+ | ^^^^^^
+ | |
+ | variant or associated item not found in `XE`
+ | help: there is a variant with a similar name: `XEmpty3`
+
+error[E0599]: no variant named `Empty1` found for enum `empty_struct::XE`
+ --> $DIR/empty-struct-braces-expr.rs:28:9
+ |
+LL | XE::Empty1 {};
+ | ^^^^^^ help: there is a variant with a similar name: `XEmpty3`
+
+error: aborting due to 9 previous errors
+
+Some errors have detailed explanations: E0423, E0533, E0599.
+For more information about an error, try `rustc --explain E0423`.
diff --git a/tests/ui/empty/empty-struct-braces-pat-1.rs b/tests/ui/empty/empty-struct-braces-pat-1.rs
new file mode 100644
index 000000000..9bed93f9c
--- /dev/null
+++ b/tests/ui/empty/empty-struct-braces-pat-1.rs
@@ -0,0 +1,34 @@
+// Can't use empty braced struct as constant pattern
+
+// aux-build:empty-struct.rs
+
+extern crate empty_struct;
+use empty_struct::*;
+
+struct Empty1 {}
+
+enum E {
+ Empty3 {}
+}
+
+fn main() {
+ let e1 = Empty1 {};
+ let e3 = E::Empty3 {};
+ let xe1 = XEmpty1 {};
+ let xe3 = XE::XEmpty3 {};
+
+ match e1 {
+ Empty1 => () // Not an error, `Empty1` is interpreted as a new binding
+ }
+ match e3 {
+ E::Empty3 => ()
+ //~^ ERROR expected unit struct, unit variant or constant, found struct variant `E::Empty3`
+ }
+ match xe1 {
+ XEmpty1 => () // Not an error, `XEmpty1` is interpreted as a new binding
+ }
+ match xe3 {
+ XE::XEmpty3 => ()
+ //~^ ERROR expected unit struct, unit variant or constant, found struct variant `XE::XEmpty3`
+ }
+}
diff --git a/tests/ui/empty/empty-struct-braces-pat-1.stderr b/tests/ui/empty/empty-struct-braces-pat-1.stderr
new file mode 100644
index 000000000..14e09fc27
--- /dev/null
+++ b/tests/ui/empty/empty-struct-braces-pat-1.stderr
@@ -0,0 +1,15 @@
+error[E0533]: expected unit struct, unit variant or constant, found struct variant `E::Empty3`
+ --> $DIR/empty-struct-braces-pat-1.rs:24:9
+ |
+LL | E::Empty3 => ()
+ | ^^^^^^^^^ not a unit struct, unit variant or constant
+
+error[E0533]: expected unit struct, unit variant or constant, found struct variant `XE::XEmpty3`
+ --> $DIR/empty-struct-braces-pat-1.rs:31:9
+ |
+LL | XE::XEmpty3 => ()
+ | ^^^^^^^^^^^ not a unit struct, unit variant or constant
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0533`.
diff --git a/tests/ui/empty/empty-struct-braces-pat-2.rs b/tests/ui/empty/empty-struct-braces-pat-2.rs
new file mode 100644
index 000000000..cfe4641f3
--- /dev/null
+++ b/tests/ui/empty/empty-struct-braces-pat-2.rs
@@ -0,0 +1,26 @@
+// Can't use empty braced struct as enum pattern
+
+// aux-build:empty-struct.rs
+
+extern crate empty_struct;
+use empty_struct::*;
+
+struct Empty1 {}
+
+fn main() {
+ let e1 = Empty1 {};
+ let xe1 = XEmpty1 {};
+
+ match e1 {
+ Empty1() => () //~ ERROR expected tuple struct or tuple variant, found struct `Empty1`
+ }
+ match xe1 {
+ XEmpty1() => () //~ ERROR expected tuple struct or tuple variant, found struct `XEmpty1`
+ }
+ match e1 {
+ Empty1(..) => () //~ ERROR expected tuple struct or tuple variant, found struct `Empty1`
+ }
+ match xe1 {
+ XEmpty1(..) => () //~ ERROR expected tuple struct or tuple variant, found struct `XEmpty1`
+ }
+}
diff --git a/tests/ui/empty/empty-struct-braces-pat-2.stderr b/tests/ui/empty/empty-struct-braces-pat-2.stderr
new file mode 100644
index 000000000..7fb5cb203
--- /dev/null
+++ b/tests/ui/empty/empty-struct-braces-pat-2.stderr
@@ -0,0 +1,95 @@
+error[E0532]: expected tuple struct or tuple variant, found struct `Empty1`
+ --> $DIR/empty-struct-braces-pat-2.rs:15:9
+ |
+LL | struct Empty1 {}
+ | ---------------- `Empty1` defined here
+...
+LL | Empty1() => ()
+ | ^^^^^^^^
+ |
+ ::: $DIR/auxiliary/empty-struct.rs:3:1
+ |
+LL | pub struct XEmpty6();
+ | ------------------ similarly named tuple struct `XEmpty6` defined here
+ |
+help: use struct pattern syntax instead
+ |
+LL | Empty1 {} => ()
+ | ~~~~~~~~~
+help: a tuple struct with a similar name exists
+ |
+LL | XEmpty6() => ()
+ | ~~~~~~~
+
+error[E0532]: expected tuple struct or tuple variant, found struct `XEmpty1`
+ --> $DIR/empty-struct-braces-pat-2.rs:18:9
+ |
+LL | XEmpty1() => ()
+ | ^^^^^^^^^
+ |
+ ::: $DIR/auxiliary/empty-struct.rs:1:1
+ |
+LL | pub struct XEmpty1 {}
+ | ------------------ `XEmpty1` defined here
+LL | pub struct XEmpty2;
+LL | pub struct XEmpty6();
+ | ------------------ similarly named tuple struct `XEmpty6` defined here
+ |
+help: use struct pattern syntax instead
+ |
+LL | XEmpty1 {} => ()
+ | ~~~~~~~~~~
+help: a tuple struct with a similar name exists
+ |
+LL | XEmpty6() => ()
+ | ~~~~~~~
+
+error[E0532]: expected tuple struct or tuple variant, found struct `Empty1`
+ --> $DIR/empty-struct-braces-pat-2.rs:21:9
+ |
+LL | struct Empty1 {}
+ | ---------------- `Empty1` defined here
+...
+LL | Empty1(..) => ()
+ | ^^^^^^^^^^
+ |
+ ::: $DIR/auxiliary/empty-struct.rs:3:1
+ |
+LL | pub struct XEmpty6();
+ | ------------------ similarly named tuple struct `XEmpty6` defined here
+ |
+help: use struct pattern syntax instead
+ |
+LL | Empty1 {} => ()
+ | ~~~~~~~~~
+help: a tuple struct with a similar name exists
+ |
+LL | XEmpty6(..) => ()
+ | ~~~~~~~
+
+error[E0532]: expected tuple struct or tuple variant, found struct `XEmpty1`
+ --> $DIR/empty-struct-braces-pat-2.rs:24:9
+ |
+LL | XEmpty1(..) => ()
+ | ^^^^^^^^^^^
+ |
+ ::: $DIR/auxiliary/empty-struct.rs:1:1
+ |
+LL | pub struct XEmpty1 {}
+ | ------------------ `XEmpty1` defined here
+LL | pub struct XEmpty2;
+LL | pub struct XEmpty6();
+ | ------------------ similarly named tuple struct `XEmpty6` defined here
+ |
+help: use struct pattern syntax instead
+ |
+LL | XEmpty1 {} => ()
+ | ~~~~~~~~~~
+help: a tuple struct with a similar name exists
+ |
+LL | XEmpty6(..) => ()
+ | ~~~~~~~
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0532`.
diff --git a/tests/ui/empty/empty-struct-braces-pat-3.rs b/tests/ui/empty/empty-struct-braces-pat-3.rs
new file mode 100644
index 000000000..54d547eef
--- /dev/null
+++ b/tests/ui/empty/empty-struct-braces-pat-3.rs
@@ -0,0 +1,32 @@
+// Can't use empty braced struct as enum pattern
+
+// aux-build:empty-struct.rs
+
+extern crate empty_struct;
+use empty_struct::*;
+
+enum E {
+ Empty3 {}
+}
+
+fn main() {
+ let e3 = E::Empty3 {};
+ let xe3 = XE::XEmpty3 {};
+
+ match e3 {
+ E::Empty3() => ()
+ //~^ ERROR expected tuple struct or tuple variant, found struct variant `E::Empty3`
+ }
+ match xe3 {
+ XE::XEmpty3() => ()
+ //~^ ERROR expected tuple struct or tuple variant, found struct variant `XE::XEmpty3`
+ }
+ match e3 {
+ E::Empty3(..) => ()
+ //~^ ERROR expected tuple struct or tuple variant, found struct variant `E::Empty3`
+ }
+ match xe3 {
+ XE::XEmpty3(..) => ()
+ //~^ ERROR expected tuple struct or tuple variant, found struct variant `XE::XEmpty3
+ }
+}
diff --git a/tests/ui/empty/empty-struct-braces-pat-3.stderr b/tests/ui/empty/empty-struct-braces-pat-3.stderr
new file mode 100644
index 000000000..00c8b12e6
--- /dev/null
+++ b/tests/ui/empty/empty-struct-braces-pat-3.stderr
@@ -0,0 +1,27 @@
+error[E0164]: expected tuple struct or tuple variant, found struct variant `E::Empty3`
+ --> $DIR/empty-struct-braces-pat-3.rs:17:9
+ |
+LL | E::Empty3() => ()
+ | ^^^^^^^^^^^ not a tuple struct or tuple variant
+
+error[E0164]: expected tuple struct or tuple variant, found struct variant `XE::XEmpty3`
+ --> $DIR/empty-struct-braces-pat-3.rs:21:9
+ |
+LL | XE::XEmpty3() => ()
+ | ^^^^^^^^^^^^^ not a tuple struct or tuple variant
+
+error[E0164]: expected tuple struct or tuple variant, found struct variant `E::Empty3`
+ --> $DIR/empty-struct-braces-pat-3.rs:25:9
+ |
+LL | E::Empty3(..) => ()
+ | ^^^^^^^^^^^^^ not a tuple struct or tuple variant
+
+error[E0164]: expected tuple struct or tuple variant, found struct variant `XE::XEmpty3`
+ --> $DIR/empty-struct-braces-pat-3.rs:29:9
+ |
+LL | XE::XEmpty3(..) => ()
+ | ^^^^^^^^^^^^^^^ not a tuple struct or tuple variant
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0164`.
diff --git a/tests/ui/empty/empty-struct-tuple-pat.rs b/tests/ui/empty/empty-struct-tuple-pat.rs
new file mode 100644
index 000000000..47da8a306
--- /dev/null
+++ b/tests/ui/empty/empty-struct-tuple-pat.rs
@@ -0,0 +1,37 @@
+// Can't use unit struct as enum pattern
+
+// aux-build:empty-struct.rs
+
+extern crate empty_struct;
+use empty_struct::*;
+
+struct Empty2();
+
+enum E {
+ Empty4()
+}
+
+// remove attribute after warning cycle and promoting warnings to errors
+fn main() {
+ let e2 = Empty2();
+ let e4 = E::Empty4();
+ let xe6 = XEmpty6();
+ let xe5 = XE::XEmpty5();
+
+ match e2 {
+ Empty2 => () //~ ERROR match bindings cannot shadow tuple structs
+ }
+ match xe6 {
+ XEmpty6 => () //~ ERROR match bindings cannot shadow tuple structs
+ }
+
+ match e4 {
+ E::Empty4 => ()
+ //~^ ERROR expected unit struct, unit variant or constant, found tuple variant `E::Empty4`
+ }
+ match xe5 {
+ XE::XEmpty5 => (),
+ //~^ ERROR expected unit struct, unit variant or constant, found tuple variant `XE::XEmpty5`
+ _ => {},
+ }
+}
diff --git a/tests/ui/empty/empty-struct-tuple-pat.stderr b/tests/ui/empty/empty-struct-tuple-pat.stderr
new file mode 100644
index 000000000..8d0f75d20
--- /dev/null
+++ b/tests/ui/empty/empty-struct-tuple-pat.stderr
@@ -0,0 +1,59 @@
+error[E0530]: match bindings cannot shadow tuple structs
+ --> $DIR/empty-struct-tuple-pat.rs:22:9
+ |
+LL | struct Empty2();
+ | ---------------- the tuple struct `Empty2` is defined here
+...
+LL | Empty2 => ()
+ | ^^^^^^
+ | |
+ | cannot be named the same as a tuple struct
+ | help: try specify the pattern arguments: `Empty2(..)`
+
+error[E0530]: match bindings cannot shadow tuple structs
+ --> $DIR/empty-struct-tuple-pat.rs:25:9
+ |
+LL | use empty_struct::*;
+ | --------------- the tuple struct `XEmpty6` is imported here
+...
+LL | XEmpty6 => ()
+ | ^^^^^^^
+ | |
+ | cannot be named the same as a tuple struct
+ | help: try specify the pattern arguments: `XEmpty6(..)`
+
+error[E0532]: expected unit struct, unit variant or constant, found tuple variant `E::Empty4`
+ --> $DIR/empty-struct-tuple-pat.rs:29:9
+ |
+LL | Empty4()
+ | -------- `E::Empty4` defined here
+...
+LL | E::Empty4 => ()
+ | ^^^^^^^^^ help: use the tuple variant pattern syntax instead: `E::Empty4()`
+
+error[E0532]: expected unit struct, unit variant or constant, found tuple variant `XE::XEmpty5`
+ --> $DIR/empty-struct-tuple-pat.rs:33:9
+ |
+LL | XE::XEmpty5 => (),
+ | ^^^^^^^^^^^
+ |
+ ::: $DIR/auxiliary/empty-struct.rs:7:5
+ |
+LL | XEmpty4,
+ | ------- similarly named unit variant `XEmpty4` defined here
+LL | XEmpty5(),
+ | ------- `XE::XEmpty5` defined here
+ |
+help: use the tuple variant pattern syntax instead
+ |
+LL | XE::XEmpty5(/* fields */) => (),
+ | ~~~~~~~~~~~~~~~~~~~~~~~~~
+help: a unit variant with a similar name exists
+ |
+LL | XE::XEmpty4 => (),
+ | ~~~~~~~
+
+error: aborting due to 4 previous errors
+
+Some errors have detailed explanations: E0530, E0532.
+For more information about an error, try `rustc --explain E0530`.
diff --git a/tests/ui/empty/empty-struct-unit-expr.rs b/tests/ui/empty/empty-struct-unit-expr.rs
new file mode 100644
index 000000000..8f3688a2a
--- /dev/null
+++ b/tests/ui/empty/empty-struct-unit-expr.rs
@@ -0,0 +1,21 @@
+// Can't use unit struct as constructor function
+
+// aux-build:empty-struct.rs
+
+extern crate empty_struct;
+use empty_struct::*;
+
+struct Empty2;
+
+enum E {
+ Empty4
+}
+
+fn main() {
+ let e2 = Empty2(); //~ ERROR expected function, found struct `Empty2`
+ let e4 = E::Empty4();
+ //~^ ERROR expected function, found enum variant `E::Empty4` [E0618]
+ let xe2 = XEmpty2(); //~ ERROR expected function, found struct `XEmpty2`
+ let xe4 = XE::XEmpty4();
+ //~^ ERROR expected function, found enum variant `XE::XEmpty4` [E0618]
+}
diff --git a/tests/ui/empty/empty-struct-unit-expr.stderr b/tests/ui/empty/empty-struct-unit-expr.stderr
new file mode 100644
index 000000000..e97209527
--- /dev/null
+++ b/tests/ui/empty/empty-struct-unit-expr.stderr
@@ -0,0 +1,65 @@
+error[E0618]: expected function, found struct `Empty2`
+ --> $DIR/empty-struct-unit-expr.rs:15:14
+ |
+LL | struct Empty2;
+ | ------------- struct `Empty2` defined here
+...
+LL | let e2 = Empty2();
+ | ^^^^^^--
+ | |
+ | call expression requires function
+ |
+help: `Empty2` is a unit struct, and does not take parentheses to be constructed
+ |
+LL - let e2 = Empty2();
+LL + let e2 = Empty2;
+ |
+
+error[E0618]: expected function, found enum variant `E::Empty4`
+ --> $DIR/empty-struct-unit-expr.rs:16:14
+ |
+LL | Empty4
+ | ------ enum variant `E::Empty4` defined here
+...
+LL | let e4 = E::Empty4();
+ | ^^^^^^^^^--
+ | |
+ | call expression requires function
+ |
+help: `E::Empty4` is a unit enum variant, and does not take parentheses to be constructed
+ |
+LL - let e4 = E::Empty4();
+LL + let e4 = E::Empty4;
+ |
+
+error[E0618]: expected function, found struct `XEmpty2`
+ --> $DIR/empty-struct-unit-expr.rs:18:15
+ |
+LL | let xe2 = XEmpty2();
+ | ^^^^^^^--
+ | |
+ | call expression requires function
+ |
+help: `XEmpty2` is a unit struct, and does not take parentheses to be constructed
+ |
+LL - let xe2 = XEmpty2();
+LL + let xe2 = XEmpty2;
+ |
+
+error[E0618]: expected function, found enum variant `XE::XEmpty4`
+ --> $DIR/empty-struct-unit-expr.rs:19:15
+ |
+LL | let xe4 = XE::XEmpty4();
+ | ^^^^^^^^^^^--
+ | |
+ | call expression requires function
+ |
+help: `XE::XEmpty4` is a unit enum variant, and does not take parentheses to be constructed
+ |
+LL - let xe4 = XE::XEmpty4();
+LL + let xe4 = XE::XEmpty4;
+ |
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0618`.
diff --git a/tests/ui/empty/empty-struct-unit-pat.rs b/tests/ui/empty/empty-struct-unit-pat.rs
new file mode 100644
index 000000000..44a1e9e3d
--- /dev/null
+++ b/tests/ui/empty/empty-struct-unit-pat.rs
@@ -0,0 +1,54 @@
+// Can't use unit struct as tuple struct pattern
+
+// aux-build:empty-struct.rs
+
+extern crate empty_struct;
+use empty_struct::*;
+
+struct Empty2;
+
+enum E {
+ Empty4
+}
+
+fn main() {
+ let e2 = Empty2;
+ let e4 = E::Empty4;
+ let xe2 = XEmpty2;
+ let xe4 = XE::XEmpty4;
+
+ match e2 {
+ Empty2() => () //~ ERROR expected tuple struct or tuple variant, found unit struct `Empty2`
+ }
+ match xe2 {
+ XEmpty2() => ()
+ //~^ ERROR expected tuple struct or tuple variant, found unit struct `XEmpty2`
+ }
+ match e2 {
+ Empty2(..) => ()
+ //~^ ERROR expected tuple struct or tuple variant, found unit struct `Empty2`
+ }
+ match xe2 {
+ XEmpty2(..) => ()
+ //~^ ERROR expected tuple struct or tuple variant, found unit struct `XEmpty2`
+ }
+
+ match e4 {
+ E::Empty4() => ()
+ //~^ ERROR expected tuple struct or tuple variant, found unit variant `E::Empty4`
+ }
+ match xe4 {
+ XE::XEmpty4() => (),
+ //~^ ERROR expected tuple struct or tuple variant, found unit variant `XE::XEmpty4`
+ _ => {},
+ }
+ match e4 {
+ E::Empty4(..) => ()
+ //~^ ERROR expected tuple struct or tuple variant, found unit variant `E::Empty4`
+ }
+ match xe4 {
+ XE::XEmpty4(..) => (),
+ //~^ ERROR expected tuple struct or tuple variant, found unit variant `XE::XEmpty4`
+ _ => {},
+ }
+}
diff --git a/tests/ui/empty/empty-struct-unit-pat.stderr b/tests/ui/empty/empty-struct-unit-pat.stderr
new file mode 100644
index 000000000..5c0b4cffa
--- /dev/null
+++ b/tests/ui/empty/empty-struct-unit-pat.stderr
@@ -0,0 +1,155 @@
+error[E0532]: expected tuple struct or tuple variant, found unit struct `Empty2`
+ --> $DIR/empty-struct-unit-pat.rs:21:9
+ |
+LL | struct Empty2;
+ | -------------- `Empty2` defined here
+...
+LL | Empty2() => ()
+ | ^^^^^^^^
+ |
+ ::: $DIR/auxiliary/empty-struct.rs:3:1
+ |
+LL | pub struct XEmpty6();
+ | ------------------ similarly named tuple struct `XEmpty6` defined here
+ |
+help: use this syntax instead
+ |
+LL | Empty2 => ()
+ | ~~~~~~
+help: a tuple struct with a similar name exists
+ |
+LL | XEmpty6() => ()
+ | ~~~~~~~
+
+error[E0532]: expected tuple struct or tuple variant, found unit struct `XEmpty2`
+ --> $DIR/empty-struct-unit-pat.rs:24:9
+ |
+LL | XEmpty2() => ()
+ | ^^^^^^^^^
+ |
+ ::: $DIR/auxiliary/empty-struct.rs:2:1
+ |
+LL | pub struct XEmpty2;
+ | ------------------ `XEmpty2` defined here
+LL | pub struct XEmpty6();
+ | ------------------ similarly named tuple struct `XEmpty6` defined here
+ |
+help: use this syntax instead
+ |
+LL | XEmpty2 => ()
+ | ~~~~~~~
+help: a tuple struct with a similar name exists
+ |
+LL | XEmpty6() => ()
+ | ~~~~~~~
+
+error[E0532]: expected tuple struct or tuple variant, found unit struct `Empty2`
+ --> $DIR/empty-struct-unit-pat.rs:28:9
+ |
+LL | struct Empty2;
+ | -------------- `Empty2` defined here
+...
+LL | Empty2(..) => ()
+ | ^^^^^^^^^^
+ |
+ ::: $DIR/auxiliary/empty-struct.rs:3:1
+ |
+LL | pub struct XEmpty6();
+ | ------------------ similarly named tuple struct `XEmpty6` defined here
+ |
+help: use this syntax instead
+ |
+LL | Empty2 => ()
+ | ~~~~~~
+help: a tuple struct with a similar name exists
+ |
+LL | XEmpty6(..) => ()
+ | ~~~~~~~
+
+error[E0532]: expected tuple struct or tuple variant, found unit struct `XEmpty2`
+ --> $DIR/empty-struct-unit-pat.rs:32:9
+ |
+LL | XEmpty2(..) => ()
+ | ^^^^^^^^^^^
+ |
+ ::: $DIR/auxiliary/empty-struct.rs:2:1
+ |
+LL | pub struct XEmpty2;
+ | ------------------ `XEmpty2` defined here
+LL | pub struct XEmpty6();
+ | ------------------ similarly named tuple struct `XEmpty6` defined here
+ |
+help: use this syntax instead
+ |
+LL | XEmpty2 => ()
+ | ~~~~~~~
+help: a tuple struct with a similar name exists
+ |
+LL | XEmpty6(..) => ()
+ | ~~~~~~~
+
+error[E0532]: expected tuple struct or tuple variant, found unit variant `E::Empty4`
+ --> $DIR/empty-struct-unit-pat.rs:37:9
+ |
+LL | Empty4
+ | ------ `E::Empty4` defined here
+...
+LL | E::Empty4() => ()
+ | ^^^^^^^^^^^ help: use this syntax instead: `E::Empty4`
+
+error[E0532]: expected tuple struct or tuple variant, found unit variant `XE::XEmpty4`
+ --> $DIR/empty-struct-unit-pat.rs:41:9
+ |
+LL | XE::XEmpty4() => (),
+ | ^^^^^^^^^^^^^
+ |
+ ::: $DIR/auxiliary/empty-struct.rs:7:5
+ |
+LL | XEmpty4,
+ | ------- `XE::XEmpty4` defined here
+LL | XEmpty5(),
+ | ------- similarly named tuple variant `XEmpty5` defined here
+ |
+help: use this syntax instead
+ |
+LL | XE::XEmpty4 => (),
+ | ~~~~~~~~~~~
+help: a tuple variant with a similar name exists
+ |
+LL | XE::XEmpty5() => (),
+ | ~~~~~~~
+
+error[E0532]: expected tuple struct or tuple variant, found unit variant `E::Empty4`
+ --> $DIR/empty-struct-unit-pat.rs:46:9
+ |
+LL | Empty4
+ | ------ `E::Empty4` defined here
+...
+LL | E::Empty4(..) => ()
+ | ^^^^^^^^^^^^^ help: use this syntax instead: `E::Empty4`
+
+error[E0532]: expected tuple struct or tuple variant, found unit variant `XE::XEmpty4`
+ --> $DIR/empty-struct-unit-pat.rs:50:9
+ |
+LL | XE::XEmpty4(..) => (),
+ | ^^^^^^^^^^^^^^^
+ |
+ ::: $DIR/auxiliary/empty-struct.rs:7:5
+ |
+LL | XEmpty4,
+ | ------- `XE::XEmpty4` defined here
+LL | XEmpty5(),
+ | ------- similarly named tuple variant `XEmpty5` defined here
+ |
+help: use this syntax instead
+ |
+LL | XE::XEmpty4 => (),
+ | ~~~~~~~~~~~
+help: a tuple variant with a similar name exists
+ |
+LL | XE::XEmpty5(..) => (),
+ | ~~~~~~~
+
+error: aborting due to 8 previous errors
+
+For more information about this error, try `rustc --explain E0532`.
diff --git a/tests/ui/empty/issue-37026.rs b/tests/ui/empty/issue-37026.rs
new file mode 100644
index 000000000..fd678a717
--- /dev/null
+++ b/tests/ui/empty/issue-37026.rs
@@ -0,0 +1,8 @@
+// aux-build:empty-struct.rs
+
+extern crate empty_struct;
+
+fn main() {
+ let empty_struct::XEmpty2 = (); //~ ERROR mismatched types
+ let empty_struct::XEmpty6(..) = (); //~ ERROR mismatched types
+}
diff --git a/tests/ui/empty/issue-37026.stderr b/tests/ui/empty/issue-37026.stderr
new file mode 100644
index 000000000..48a4a5bca
--- /dev/null
+++ b/tests/ui/empty/issue-37026.stderr
@@ -0,0 +1,19 @@
+error[E0308]: mismatched types
+ --> $DIR/issue-37026.rs:6:9
+ |
+LL | let empty_struct::XEmpty2 = ();
+ | ^^^^^^^^^^^^^^^^^^^^^ -- this expression has type `()`
+ | |
+ | expected `()`, found struct `XEmpty2`
+
+error[E0308]: mismatched types
+ --> $DIR/issue-37026.rs:7:9
+ |
+LL | let empty_struct::XEmpty6(..) = ();
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ -- this expression has type `()`
+ | |
+ | expected `()`, found struct `XEmpty6`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/empty/no-link.rs b/tests/ui/empty/no-link.rs
new file mode 100644
index 000000000..c80e61b45
--- /dev/null
+++ b/tests/ui/empty/no-link.rs
@@ -0,0 +1,9 @@
+// check-pass
+// aux-build:empty-struct.rs
+
+#[no_link]
+extern crate empty_struct;
+
+fn main() {
+ empty_struct::XEmpty1 {};
+}