Rollup merge of #129223 - wafarm:fix-129215, r=compiler-errors
Fix wrong argument for `get_fn_decl` Closes #129215 (seems to be introduced in #129168)
This commit is contained in:
commit
5ba877c262
@ -1859,7 +1859,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
|
||||
};
|
||||
|
||||
// If this is due to an explicit `return`, suggest adding a return type.
|
||||
if let Some((fn_id, fn_decl, can_suggest)) = fcx.get_fn_decl(parent_id)
|
||||
if let Some((fn_id, fn_decl, can_suggest)) = fcx.get_fn_decl(block_or_return_id)
|
||||
&& !due_to_block
|
||||
{
|
||||
fcx.suggest_missing_return_type(&mut err, fn_decl, expected, found, can_suggest, fn_id);
|
||||
|
9
tests/ui/async-await/async-fn/recurse-ice-129215.rs
Normal file
9
tests/ui/async-await/async-fn/recurse-ice-129215.rs
Normal file
@ -0,0 +1,9 @@
|
||||
//@ edition: 2021
|
||||
|
||||
async fn a() {
|
||||
//~^ ERROR `()` is not a future
|
||||
//~| ERROR mismatched types
|
||||
a() //~ ERROR `()` is not a future
|
||||
}
|
||||
|
||||
fn main() {}
|
34
tests/ui/async-await/async-fn/recurse-ice-129215.stderr
Normal file
34
tests/ui/async-await/async-fn/recurse-ice-129215.stderr
Normal file
@ -0,0 +1,34 @@
|
||||
error[E0277]: `()` is not a future
|
||||
--> $DIR/recurse-ice-129215.rs:6:5
|
||||
|
|
||||
LL | a()
|
||||
| ^^^ `()` is not a future
|
||||
|
|
||||
= help: the trait `Future` is not implemented for `()`
|
||||
|
||||
error[E0277]: `()` is not a future
|
||||
--> $DIR/recurse-ice-129215.rs:3:1
|
||||
|
|
||||
LL | async fn a() {
|
||||
| ^^^^^^^^^^^^ `()` is not a future
|
||||
|
|
||||
= help: the trait `Future` is not implemented for `()`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/recurse-ice-129215.rs:3:14
|
||||
|
|
||||
LL | async fn a() {
|
||||
| ______________^
|
||||
LL | |
|
||||
LL | |
|
||||
LL | | a()
|
||||
LL | | }
|
||||
| |_^ expected `()`, found `async` fn body
|
||||
|
|
||||
= note: expected unit type `()`
|
||||
found `async` fn body `{async fn body of a()}`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0277, E0308.
|
||||
For more information about an error, try `rustc --explain E0277`.
|
@ -8,4 +8,5 @@ fn main() {
|
||||
foo(|| bar())
|
||||
//~^ ERROR mismatched types [E0308]
|
||||
//~| HELP consider using a semicolon here
|
||||
//~| HELP try adding a return type
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/add_semicolon_non_block_closure.rs:8:12
|
||||
|
|
||||
LL | fn main() {
|
||||
| - expected `()` because of default return type
|
||||
LL | foo(|| bar())
|
||||
| ^^^^^ expected `()`, found `i32`
|
||||
|
|
||||
@ -10,6 +8,10 @@ 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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user