about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-12-05 02:51:06 +0000
committerbors <bors@rust-lang.org>2022-12-05 02:51:06 +0000
commitb9341bfdb1dec09b49b1e7d01d7c4db0e2436737 (patch)
tree6800154302bc90cde81fbc10593a70f59bf6b48a /src/test
parentd1449560e31f7f801d81268a3dad783181656dff (diff)
parenta68eae2f70ce58fbf3bc614f19b4570d2c28d54c (diff)
downloadrust-b9341bfdb1dec09b49b1e7d01d7c4db0e2436737.tar.gz
rust-b9341bfdb1dec09b49b1e7d01d7c4db0e2436737.zip
Auto merge of #104920 - compiler-errors:avoid-infcx-build, r=jackh726
Avoid some `InferCtxt::build` calls

Either because we're inside of an `InferCtxt` already, or because we're not in a place where we'd ever see inference vars.

r? types
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/return/tail-expr-as-potential-return.rs17
-rw-r--r--src/test/ui/return/tail-expr-as-potential-return.stderr21
2 files changed, 34 insertions, 4 deletions
diff --git a/src/test/ui/return/tail-expr-as-potential-return.rs b/src/test/ui/return/tail-expr-as-potential-return.rs
index 2c3610fb24d..f46e088b85f 100644
--- a/src/test/ui/return/tail-expr-as-potential-return.rs
+++ b/src/test/ui/return/tail-expr-as-potential-return.rs
@@ -12,7 +12,6 @@
 // edition:2018
 
 fn main() {
-    let _ = foo(true);
 }
 
 fn foo(x: bool) -> Result<f64, i32> {
@@ -30,3 +29,19 @@ async fn bar(x: bool) -> Result<f64, i32> {
     }
     Ok(42.0)
 }
+
+trait Identity {
+    type Out;
+}
+
+impl<T> Identity for T {
+    type Out = T;
+}
+
+async fn foo2() -> i32 {
+    if true {
+        1i32 //~ ERROR mismatched types
+            //| HELP you might have meant to return this value
+    }
+    0
+}
diff --git a/src/test/ui/return/tail-expr-as-potential-return.stderr b/src/test/ui/return/tail-expr-as-potential-return.stderr
index dec1cbc4624..9183b4599ba 100644
--- a/src/test/ui/return/tail-expr-as-potential-return.stderr
+++ b/src/test/ui/return/tail-expr-as-potential-return.stderr
@@ -1,5 +1,5 @@
 error[E0308]: mismatched types
-  --> $DIR/tail-expr-as-potential-return.rs:28:9
+  --> $DIR/tail-expr-as-potential-return.rs:27:9
    |
 LL | /     if x {
 LL | |         Err(42)
@@ -16,7 +16,22 @@ LL |         return Err(42);
    |         ++++++        +
 
 error[E0308]: mismatched types
-  --> $DIR/tail-expr-as-potential-return.rs:20:9
+  --> $DIR/tail-expr-as-potential-return.rs:43:9
+   |
+LL | /     if true {
+LL | |         1i32
+   | |         ^^^^ expected `()`, found `i32`
+LL | |             //| HELP you might have meant to return this value
+LL | |     }
+   | |_____- expected this to be `()`
+   |
+help: you might have meant to return this value
+   |
+LL |         return 1i32;
+   |         ++++++     +
+
+error[E0308]: mismatched types
+  --> $DIR/tail-expr-as-potential-return.rs:19:9
    |
 LL | /     if x {
 LL | |         Err(42)
@@ -32,6 +47,6 @@ help: you might have meant to return this value
 LL |         return Err(42);
    |         ++++++        +
 
-error: aborting due to 2 previous errors
+error: aborting due to 3 previous errors
 
 For more information about this error, try `rustc --explain E0308`.