about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-12-14 17:17:58 +0100
committerGitHub <noreply@github.com>2022-12-14 17:17:58 +0100
commite2c982369346210cf0a8121d364d3f67bca413bf (patch)
treef1e3b42a4db4254717f6f1c447d7eeaf3016a5b5
parent0e861ccb9e86b54715089ea96ff37b891f5b44f0 (diff)
parentf7db4f0a4ceb5175155fdddb7e3609e4de33ddc5 (diff)
downloadrust-e2c982369346210cf0a8121d364d3f67bca413bf.tar.gz
rust-e2c982369346210cf0a8121d364d3f67bca413bf.zip
Rollup merge of #105630 - albertlarsan68:test-92481, r=TaKO8Ki
Add a test for #92481

The test was copied ad-hoc from #92481, but I can't get the test to pass, because of needing to get twice the same error on the last line of the source.

Closes #92481
-rw-r--r--src/test/ui/typeck/issue-92481.rs14
-rw-r--r--src/test/ui/typeck/issue-92481.stderr60
2 files changed, 74 insertions, 0 deletions
diff --git a/src/test/ui/typeck/issue-92481.rs b/src/test/ui/typeck/issue-92481.rs
new file mode 100644
index 00000000000..0a6b1843d99
--- /dev/null
+++ b/src/test/ui/typeck/issue-92481.rs
@@ -0,0 +1,14 @@
+//check-fail
+
+#![crate_type="lib"]
+
+fn r({) {
+    Ok {             //~ ERROR mismatched types [E0308]
+        d..||_=m
+    }
+}
+//~^^^^^ ERROR expected parameter name, found `{`
+//~| ERROR expected one of `,`, `:`, or `}`, found `..`
+//~^^^^^ ERROR cannot find value `d` in this scope [E0425]
+//~| ERROR cannot find value `m` in this scope [E0425]
+//~| ERROR variant `Result<_, _>::Ok` has no field named `d` [E0559]
diff --git a/src/test/ui/typeck/issue-92481.stderr b/src/test/ui/typeck/issue-92481.stderr
new file mode 100644
index 00000000000..cd778a649b6
--- /dev/null
+++ b/src/test/ui/typeck/issue-92481.stderr
@@ -0,0 +1,60 @@
+error: expected parameter name, found `{`
+  --> $DIR/issue-92481.rs:5:6
+   |
+LL | fn r({) {
+   |      ^ expected parameter name
+
+error: expected one of `,`, `:`, or `}`, found `..`
+  --> $DIR/issue-92481.rs:5:6
+   |
+LL | fn r({) {
+   |      ^ unclosed delimiter
+LL |     Ok {
+LL |         d..||_=m
+   |          -^
+   |          |
+   |          help: `}` may belong here
+
+error[E0425]: cannot find value `d` in this scope
+  --> $DIR/issue-92481.rs:7:9
+   |
+LL |         d..||_=m
+   |         ^ not found in this scope
+
+error[E0425]: cannot find value `m` in this scope
+  --> $DIR/issue-92481.rs:7:16
+   |
+LL |         d..||_=m
+   |                ^ not found in this scope
+
+error[E0559]: variant `Result<_, _>::Ok` has no field named `d`
+  --> $DIR/issue-92481.rs:7:9
+   |
+LL |         d..||_=m
+   |         ^ field does not exist
+  --> $SRC_DIR/core/src/result.rs:LL:COL
+   |
+   = note: `Result<_, _>::Ok` defined here
+   |
+help: `Result<_, _>::Ok` is a tuple variant, use the appropriate syntax
+   |
+LL |     Result<_, _>::Ok(/* fields */)
+   |
+
+error[E0308]: mismatched types
+  --> $DIR/issue-92481.rs:6:5
+   |
+LL |   fn r({) {
+   |           - help: a return type might be missing here: `-> _`
+LL | /     Ok {
+LL | |         d..||_=m
+LL | |     }
+   | |_____^ expected `()`, found enum `Result`
+   |
+   = note: expected unit type `()`
+                   found enum `Result<_, _>`
+
+error: aborting due to 6 previous errors
+
+Some errors have detailed explanations: E0308, E0425, E0559.
+For more information about an error, try `rustc --explain E0308`.