Rollup merge of #129260 - wafarm:dont-suggest-closures, r=compiler-errors

Don't suggest adding return type for closures with default return type

Follow up of #129223

r? ``@compiler-errors``
This commit is contained in:
Matthias Krüger 2024-09-11 20:04:21 +02:00 committed by GitHub
commit 76e070fbd3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 74 additions and 73 deletions

View file

@ -8,5 +8,4 @@ fn main() {
foo(|| bar())
//~^ ERROR mismatched types [E0308]
//~| HELP consider using a semicolon here
//~| HELP try adding a return type
}

View file

@ -8,10 +8,6 @@ help: consider using a semicolon here
|
LL | foo(|| { bar(); })
| + +++
help: try adding a return type
|
LL | foo(|| -> i32 bar())
| ++++++
error: aborting due to 1 previous error

View file

@ -3,7 +3,6 @@
fn main() -> Result<(), ()> {
a(|| {
//~^ HELP: try adding a return type
b()
//~^ ERROR: mismatched types [E0308]
//~| NOTE: expected `()`, found `i32`

View file

@ -1,20 +1,13 @@
error[E0308]: mismatched types
--> $DIR/try-operator-dont-suggest-semicolon.rs:7:9
--> $DIR/try-operator-dont-suggest-semicolon.rs:6:9
|
LL | b()
| ^^^ expected `()`, found `i32`
|
help: consider using a semicolon here
|
LL | b();
| +
help: try adding a return type
|
LL | a(|| -> i32 {
| ++++++
| ^^^- help: consider using a semicolon here: `;`
| |
| expected `()`, found `i32`
error[E0308]: mismatched types
--> $DIR/try-operator-dont-suggest-semicolon.rs:17:9
--> $DIR/try-operator-dont-suggest-semicolon.rs:16:9
|
LL | / if true {
LL | |

View file

@ -2,9 +2,7 @@ error[E0308]: mismatched types
--> $DIR/issue-81943.rs:7:9
|
LL | f(|x| lib::d!(x));
| -^^^^^^^^^^ expected `()`, found `i32`
| |
| help: try adding a return type: `-> i32`
| ^^^^^^^^^^ expected `()`, found `i32`
|
= note: this error originates in the macro `lib::d` (in Nightly builds, run with -Z macro-backtrace for more info)
@ -12,22 +10,28 @@ error[E0308]: mismatched types
--> $DIR/issue-81943.rs:8:28
|
LL | f(|x| match x { tmp => { g(tmp) } });
| ^^^^^^ expected `()`, found `i32`
| -------------------^^^^^^----
| | |
| | expected `()`, found `i32`
| expected this to be `()`
|
help: consider using a semicolon here
|
LL | f(|x| match x { tmp => { g(tmp); } });
| +
help: try adding a return type
help: consider using a semicolon here
|
LL | f(|x| -> i32 match x { tmp => { g(tmp) } });
| ++++++
LL | f(|x| match x { tmp => { g(tmp) } };);
| +
error[E0308]: mismatched types
--> $DIR/issue-81943.rs:10:38
|
LL | ($e:expr) => { match $e { x => { g(x) } } }
| ^^^^ expected `()`, found `i32`
| ------------------^^^^----
| | |
| | expected `()`, found `i32`
| expected this to be `()`
LL | }
LL | f(|x| d!(x));
| ----- in this macro invocation
@ -37,10 +41,10 @@ help: consider using a semicolon here
|
LL | ($e:expr) => { match $e { x => { g(x); } } }
| +
help: try adding a return type
help: consider using a semicolon here
|
LL | f(|x| -> i32 d!(x));
| ++++++
LL | ($e:expr) => { match $e { x => { g(x) } }; }
| +
error: aborting due to 3 previous errors