diff options
| author | bors <bors@rust-lang.org> | 2022-12-05 02:51:06 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-12-05 02:51:06 +0000 |
| commit | b9341bfdb1dec09b49b1e7d01d7c4db0e2436737 (patch) | |
| tree | 6800154302bc90cde81fbc10593a70f59bf6b48a /src/test | |
| parent | d1449560e31f7f801d81268a3dad783181656dff (diff) | |
| parent | a68eae2f70ce58fbf3bc614f19b4570d2c28d54c (diff) | |
| download | rust-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.rs | 17 | ||||
| -rw-r--r-- | src/test/ui/return/tail-expr-as-potential-return.stderr | 21 |
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`. |
