rust/tests
Matthias Krüger d09c988791
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.
2023-10-26 22:26:11 +02:00
..
assembly Auto merge of #116037 - wesleywiser:stack_protector_test_windows, r=cuviper 2023-10-19 07:50:09 +00:00
auxiliary
codegen coverage: Add UI tests for values accepted by -Cinstrument-coverage 2023-10-23 17:41:40 +11:00
codegen-units Automatically enable cross-crate inlining for small functions 2023-10-17 19:53:51 -04:00
coverage-map coverage: Handle fn signature spans more consistently near ? 2023-10-21 11:53:27 +11:00
debuginfo s/generator/coroutine/ 2023-10-20 21:14:01 +00:00
incremental Bless incremental tests. 2023-10-06 15:46:11 +00:00
mir-opt Auto merge of #113262 - Nilstrieb:rawr-casting, r=lcnr 2023-10-26 12:54:19 +00:00
pretty Preserve unicode escapes in format string literals when pretty-printing AST 2023-10-16 21:20:21 +02:00
run-coverage coverage: Handle fn signature spans more consistently near ? 2023-10-21 11:53:27 +11:00
run-coverage-rustdoc
run-make Mark .rmeta files as /SAFESEH on x86 Windows. 2023-10-24 13:42:28 -07:00
run-make-fulldeps Auto merge of #116818 - Nilstrieb:stop-submitting-bug-reports, r=wesleywiser 2023-10-26 02:08:07 +00:00
run-pass-valgrind
rustdoc Handle structured stable attribute 'since' version in rustdoc 2023-10-24 17:34:59 -07:00
rustdoc-gui Auto merge of #115948 - notriddle:notriddle/logo-lockup, r=fmease 2023-10-11 06:28:36 +00:00
rustdoc-js Add regression test for #115480 2023-10-11 11:41:39 +02:00
rustdoc-js-std
rustdoc-json
rustdoc-ui s/generator/coroutine/ 2023-10-20 21:14:01 +00:00
ui Rollup merge of #117106 - estebank:issue-27300, r=petrochenkov 2023-10-26 22:26:11 +02:00
ui-fulldeps Add test for smir locals 2023-10-26 00:22:56 +01:00
COMPILER_TESTS.md