diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-10-26 22:26:11 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-26 22:26:11 +0200 |
| commit | d09c9887914667266f3568517ff0e1a4d3c3498b (patch) | |
| tree | ceeaa6047ae988643060ad4c4f9c8d34efe5020a /tests/rustdoc-js-std/parser-slice-array.js | |
| parent | 596369fea049f2ca85234f6c1e646ee4fc5afefc (diff) | |
| parent | c1bfd46c7b2b5ec21275fdab2fa931c54f9b1f9c (diff) | |
| download | rust-d09c9887914667266f3568517ff0e1a4d3c3498b.tar.gz rust-d09c9887914667266f3568517ff0e1a4d3c3498b.zip | |
Rollup merge of #117106 - estebank:issue-27300, r=petrochenkov
When expecting closure argument but finding block provide suggestion
Detect if there is a potential typo where the `{` meant to open the closure body was written before the body.
```
error[E0277]: expected a `FnOnce<({integer},)>` closure, found `Option<usize>`
--> $DIR/ruby_style_closure_successful_parse.rs:3:31
|
LL | let p = Some(45).and_then({|x|
| ______________________--------_^
| | |
| | required by a bound introduced by this call
LL | | 1 + 1;
LL | | Some(x * 2)
| | ----------- this tail expression is of type `Option<usize>`
LL | | });
| |_____^ expected an `FnOnce<({integer},)>` closure, found `Option<usize>`
|
= help: the trait `FnOnce<({integer},)>` is not implemented for `Option<usize>`
note: required by a bound in `Option::<T>::and_then`
--> $SRC_DIR/core/src/option.rs:LL:COL
help: you might have meant to open the closure body instead of placing a closure within a block
|
LL - let p = Some(45).and_then({|x|
LL + let p = Some(45).and_then(|x| {
|
```
Detect the potential typo where the closure header is missing.
```
error[E0277]: expected a `FnOnce<(&bool,)>` closure, found `bool`
--> $DIR/block_instead_of_closure_in_arg.rs:3:23
|
LL | Some(true).filter({
| _________________------_^
| | |
| | required by a bound introduced by this call
LL | |/ if number % 2 == 0 {
LL | || number == 0
LL | || } else {
LL | || number != 0
LL | || }
| ||_________- this tail expression is of type `bool`
LL | | });
| |______^ expected an `FnOnce<(&bool,)>` closure, found `bool`
|
= help: the trait `for<'a> FnOnce<(&'a bool,)>` is not implemented for `bool`
note: required by a bound in `Option::<T>::filter`
--> $SRC_DIR/core/src/option.rs:LL:COL
help: you might have meant to create the closure instead of a block
|
LL | Some(true).filter(|_| {
| +++
```
Partially address #27300. Fix #104690.
Diffstat (limited to 'tests/rustdoc-js-std/parser-slice-array.js')
0 files changed, 0 insertions, 0 deletions
