about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorÖmer Sinan Ağacan <omeragacan@gmail.com>2021-02-18 16:47:01 +0300
committerÖmer Sinan Ağacan <omeragacan@gmail.com>2021-02-18 16:47:01 +0300
commit9ef67e09a4c2fdfd528ac174e3aec2fe0e97f347 (patch)
treeeac0fb4d95f52530f6260f6b569032339f3cdb54 /src
parent15fdccc6ae636b0f5663e2e75e0a115d60b8633c (diff)
downloadrust-9ef67e09a4c2fdfd528ac174e3aec2fe0e97f347.tar.gz
rust-9ef67e09a4c2fdfd528ac174e3aec2fe0e97f347.zip
Add regression test
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/suggestions/auxiliary/issue-81839.rs9
-rw-r--r--src/test/ui/suggestions/issue-81839.rs17
-rw-r--r--src/test/ui/suggestions/issue-81839.stderr27
3 files changed, 53 insertions, 0 deletions
diff --git a/src/test/ui/suggestions/auxiliary/issue-81839.rs b/src/test/ui/suggestions/auxiliary/issue-81839.rs
new file mode 100644
index 00000000000..5683c45adf2
--- /dev/null
+++ b/src/test/ui/suggestions/auxiliary/issue-81839.rs
@@ -0,0 +1,9 @@
+// edition:2018
+
+pub struct Test {}
+
+impl Test {
+    pub async fn answer_str(&self, _s: &str) -> Test {
+        Test {}
+    }
+}
diff --git a/src/test/ui/suggestions/issue-81839.rs b/src/test/ui/suggestions/issue-81839.rs
new file mode 100644
index 00000000000..0b9b7aefe73
--- /dev/null
+++ b/src/test/ui/suggestions/issue-81839.rs
@@ -0,0 +1,17 @@
+// aux-build:issue-81839.rs
+// edition:2018
+
+extern crate issue_81839;
+
+async fn test(ans: &str, num: i32, cx: &issue_81839::Test) -> u32 {
+    match num {
+        1 => {
+            cx.answer_str("hi");
+        }
+        _ => cx.answer_str("hi"), //~ `match` arms have incompatible types
+    }
+
+    1
+}
+
+fn main() {}
diff --git a/src/test/ui/suggestions/issue-81839.stderr b/src/test/ui/suggestions/issue-81839.stderr
new file mode 100644
index 00000000000..1a289d39e44
--- /dev/null
+++ b/src/test/ui/suggestions/issue-81839.stderr
@@ -0,0 +1,27 @@
+error[E0308]: `match` arms have incompatible types
+  --> $DIR/issue-81839.rs:11:14
+   |
+LL | /     match num {
+LL | |         1 => {
+LL | |             cx.answer_str("hi");
+   | |             --------------------
+   | |             |                  |
+   | |             |                  help: consider removing this semicolon
+   | |             this is found to be of type `()`
+LL | |         }
+LL | |         _ => cx.answer_str("hi"),
+   | |              ^^^^^^^^^^^^^^^^^^^ expected `()`, found opaque type
+LL | |     }
+   | |_____- `match` arms have incompatible types
+   | 
+  ::: $DIR/auxiliary/issue-81839.rs:6:49
+   |
+LL |       pub async fn answer_str(&self, _s: &str) -> Test {
+   |                                                   ---- the `Output` of this `async fn`'s found opaque type
+   |
+   = note:     expected type `()`
+           found opaque type `impl Future`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.