about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-01-23 01:09:43 +0100
committerGitHub <noreply@github.com>2022-01-23 01:09:43 +0100
commita15252817a11acfbb6127d34a6ec0ede3ad4a7ae (patch)
treed71b46972a1497f0dee25239dabb221d4e764545 /src
parent24ac541de64938791bd7c72c9a63ec328508bdac (diff)
parent7356e28abbd56ff600dff1d34553b5bebcfc8767 (diff)
Rollup merge of #93103 - estebank:await-span, r=nagisa
Tweak `expr.await` desugaring `Span`

Fix #93074
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`.