diff options
| author | Michael Goulet <michael@errs.io> | 2022-11-26 00:10:35 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-12-02 04:11:48 +0000 |
| commit | 3e7e1b1f838b86701e5539d788b633da1f0f950a (patch) | |
| tree | 1760b10b784ce8145049acc93b05af6c73e15f08 /src | |
| parent | 56c241c86212d84b9528dca1628bc06e32c742c1 (diff) | |
| download | rust-3e7e1b1f838b86701e5539d788b633da1f0f950a.tar.gz rust-3e7e1b1f838b86701e5539d788b633da1f0f950a.zip | |
Avoid InferCtxt::build in suggest_missing_break_or_return_expr
Diffstat (limited to 'src')
| -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`. |
