about summary refs log tree commit diff
path: root/tests/ui/pattern
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-03-26 11:50:27 +0000
committerbors <bors@rust-lang.org>2024-03-26 11:50:27 +0000
commit2e198d04ee1ccd20926701c4da7403d2c6bca7b3 (patch)
tree516054cbab817a3ae4ba709db47420054c52aee0 /tests/ui/pattern
parent78d556e28d4e4d60b45bd183c22748967731abb9 (diff)
parent89a36c03850a404d8d3a4b869cb85293e1f9a978 (diff)
downloadrust-2e198d04ee1ccd20926701c4da7403d2c6bca7b3.tar.gz
rust-2e198d04ee1ccd20926701c4da7403d2c6bca7b3.zip
Auto merge of #3419 - RalfJung:rustup, r=RalfJung
Rustup

https://github.com/rust-lang/rust/pull/123081 landed so hopefully this works now.
Diffstat (limited to 'tests/ui/pattern')
-rw-r--r--tests/ui/pattern/no-match-tuple-variant-self-ctor.rs37
-rw-r--r--tests/ui/pattern/no-match-tuple-variant-self-ctor.struct_.stderr19
-rw-r--r--tests/ui/pattern/no-match-tuple-variant-self-ctor.tuple.stderr9
3 files changed, 65 insertions, 0 deletions
diff --git a/tests/ui/pattern/no-match-tuple-variant-self-ctor.rs b/tests/ui/pattern/no-match-tuple-variant-self-ctor.rs
new file mode 100644
index 00000000000..7c2821e77ab
--- /dev/null
+++ b/tests/ui/pattern/no-match-tuple-variant-self-ctor.rs
@@ -0,0 +1,37 @@
+//@ revisions: tuple unit struct_
+//@[unit] check-pass
+
+#[cfg(unit)]
+mod unit {
+    struct S;
+    impl S {
+        fn foo() {
+            let Self = S;
+        }
+    }
+}
+
+#[cfg(tuple)]
+mod tuple {
+    struct S(());
+    impl S {
+        fn foo() {
+            let Self = S;
+            //[tuple]~^ ERROR expected unit struct
+        }
+    }
+}
+
+#[cfg(struct_)]
+mod struct_ {
+    struct S {}
+    impl S {
+        fn foo() {
+            let Self = S;
+            //[struct_]~^ ERROR expected value, found struct `S`
+            //[struct_]~| ERROR expected unit struct, found self constructor `Self`
+        }
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/pattern/no-match-tuple-variant-self-ctor.struct_.stderr b/tests/ui/pattern/no-match-tuple-variant-self-ctor.struct_.stderr
new file mode 100644
index 00000000000..5ed3979feb8
--- /dev/null
+++ b/tests/ui/pattern/no-match-tuple-variant-self-ctor.struct_.stderr
@@ -0,0 +1,19 @@
+error[E0423]: expected value, found struct `S`
+  --> $DIR/no-match-tuple-variant-self-ctor.rs:30:24
+   |
+LL |     struct S {}
+   |     ----------- `S` defined here
+...
+LL |             let Self = S;
+   |                        ^ help: use struct literal syntax instead: `S {}`
+
+error[E0533]: expected unit struct, found self constructor `Self`
+  --> $DIR/no-match-tuple-variant-self-ctor.rs:30:17
+   |
+LL |             let Self = S;
+   |                 ^^^^ not a unit struct
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0423, E0533.
+For more information about an error, try `rustc --explain E0423`.
diff --git a/tests/ui/pattern/no-match-tuple-variant-self-ctor.tuple.stderr b/tests/ui/pattern/no-match-tuple-variant-self-ctor.tuple.stderr
new file mode 100644
index 00000000000..d31a4a79189
--- /dev/null
+++ b/tests/ui/pattern/no-match-tuple-variant-self-ctor.tuple.stderr
@@ -0,0 +1,9 @@
+error[E0533]: expected unit struct, found self constructor `Self`
+  --> $DIR/no-match-tuple-variant-self-ctor.rs:19:17
+   |
+LL |             let Self = S;
+   |                 ^^^^ not a unit struct
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0533`.