diff options
| author | Jacob Pratt <jacob@jhpratt.dev> | 2025-01-31 00:26:29 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-31 00:26:29 -0500 |
| commit | ae9dbf169fa43b45617107d8bd90eced26b1dea2 (patch) | |
| tree | 202788201e194ca5ea816f61f7b8b9872109c3cd /compiler/rustc_interface/src/tests.rs | |
| parent | 6c1d960d88dd3755548b3818630acb63fa98187e (diff) | |
| parent | d11676711347a220339f3601c79f74076bdb43a8 (diff) | |
| download | rust-ae9dbf169fa43b45617107d8bd90eced26b1dea2.tar.gz rust-ae9dbf169fa43b45617107d8bd90eced26b1dea2.zip | |
Rollup merge of #132156 - estebank:closure-return, r=Nadrieril,compiler-errors
When encountering unexpected closure return type, point at return type/expression
```
error[E0271]: expected `{closure@fallback-closure-wrap.rs:18:40}` to be a closure that returns `()`, but it returns `!`
--> $DIR/fallback-closure-wrap.rs:19:9
|
LL | let error = Closure::wrap(Box::new(move || {
| -------
LL | panic!("Can't connect to server.");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `!`
|
= note: expected unit type `()`
found type `!`
= note: required for the cast from `Box<{closure@$DIR/fallback-closure-wrap.rs:18:40: 18:47}>` to `Box<dyn FnMut()>`
```
```
error[E0271]: expected `{closure@dont-ice-for-type-mismatch-in-closure-in-async.rs:6:10}` to be a closure that returns `bool`, but it returns `Option<()>`
--> $DIR/dont-ice-for-type-mismatch-in-closure-in-async.rs:6:16
|
LL | call(|| -> Option<()> {
| ---- ------^^^^^^^^^^
| | |
| | expected `bool`, found `Option<()>`
| required by a bound introduced by this call
|
= note: expected type `bool`
found enum `Option<()>`
note: required by a bound in `call`
--> $DIR/dont-ice-for-type-mismatch-in-closure-in-async.rs:3:25
|
LL | fn call(_: impl Fn() -> bool) {}
| ^^^^ required by this bound in `call`
```
```
error[E0271]: expected `{closure@f670.rs:28:13}` to be a closure that returns `Result<(), _>`, but it returns `!`
--> f670.rs:28:20
|
28 | let c = |e| -> ! {
| -------^
| |
| expected `Result<(), _>`, found `!`
...
32 | f().or_else(c);
| ------- required by a bound introduced by this call
-Ztrack-diagnostics: created at compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs:1433:28
|
= note: expected enum `Result<(), _>`
found type `!`
note: required by a bound in `Result::<T, E>::or_else`
--> /home/gh-estebank/rust/library/core/src/result.rs:1406:39
|
1406 | pub fn or_else<F, O: FnOnce(E) -> Result<T, F>>(self, op: O) -> Result<T, F> {
| ^^^^^^^^^^^^ required by this bound in `Result::<T, E>::or_else`
```
CC #111539.
Diffstat (limited to 'compiler/rustc_interface/src/tests.rs')
0 files changed, 0 insertions, 0 deletions
