about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/async-await/proper-span-for-type-error.fixed11
-rw-r--r--src/test/ui/async-await/proper-span-for-type-error.rs11
-rw-r--r--src/test/ui/async-await/proper-span-for-type-error.stderr16
3 files changed, 38 insertions, 0 deletions
diff --git a/src/test/ui/async-await/proper-span-for-type-error.fixed b/src/test/ui/async-await/proper-span-for-type-error.fixed
new file mode 100644
index 00000000000..1f1e1184dcc
--- /dev/null
+++ b/src/test/ui/async-await/proper-span-for-type-error.fixed
@@ -0,0 +1,11 @@
+// edition:2021
+// run-rustfix
+#![allow(dead_code)]
+
+async fn a() {}
+
+async fn foo() -> Result<(), i32> {
+    Ok(a().await) //~ ERROR mismatched types
+}
+
+fn main() {}
diff --git a/src/test/ui/async-await/proper-span-for-type-error.rs b/src/test/ui/async-await/proper-span-for-type-error.rs
new file mode 100644
index 00000000000..00ccde1bf99
--- /dev/null
+++ b/src/test/ui/async-await/proper-span-for-type-error.rs
@@ -0,0 +1,11 @@
+// edition:2021
+// run-rustfix
+#![allow(dead_code)]
+
+async fn a() {}
+
+async fn foo() -> Result<(), i32> {
+    a().await //~ ERROR mismatched types
+}
+
+fn main() {}
diff --git a/src/test/ui/async-await/proper-span-for-type-error.stderr b/src/test/ui/async-await/proper-span-for-type-error.stderr
new file mode 100644
index 00000000000..611dc0407bf
--- /dev/null
+++ b/src/test/ui/async-await/proper-span-for-type-error.stderr
@@ -0,0 +1,16 @@
+error[E0308]: mismatched types
+  --> $DIR/proper-span-for-type-error.rs:8:5
+   |
+LL |     a().await
+   |     ^^^^^^^^^ expected enum `Result`, found `()`
+   |
+   = note:   expected enum `Result<(), i32>`
+           found unit type `()`
+help: try wrapping the expression in `Ok`
+   |
+LL |     Ok(a().await)
+   |     +++         +
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.