rust/tests/ui/async-await/async-closures
bors b3f75cc872 Auto merge of #132147 - estebank:long-types-2, r=davidtwco
Tweak E0277 output when a candidate is available

*Follow up to #132086.*

Go from

```
error[E0277]: the trait bound `Then<Ignored<chumsky::combinator::Filter<chumsky::primitive::Any<&str, chumsky::extra::Full<EmptyErr, (), ()>>, {closure@src/main.rs:9:17: 9:27}>, char>, chumsky::combinator::Map<impl CSTParser<'a, O>, O, {closure@src/main.rs:11:24: 11:27}>, (), (), chumsky::extra::Full<EmptyErr, (), ()>>: CSTParser<'a>` is not satisfied
 --> src/main.rs:7:50
  |
7 | fn leaf<'a, O>(parser: impl CSTParser<'a, O>) -> impl CSTParser<'a, ()> {
  |                                                  ^^^^^^^^^^^^^^^^^^^^^^ the trait `chumsky::private::ParserSealed<'_, &str, (), chumsky::extra::Full<EmptyErr, (), ()>>` is not implemented for `Then<Ignored<Filter<Any<&str, ...>, ...>, ...>, ..., ..., ..., ...>`, which is required by `Then<Ignored<chumsky::combinator::Filter<chumsky::primitive::Any<&str, chumsky::extra::Full<EmptyErr, (), ()>>, {closure@src/main.rs:9:17: 9:27}>, char>, chumsky::combinator::Map<impl CSTParser<'a, O>, O, {closure@src/main.rs:11:24: 11:27}>, (), (), chumsky::extra::Full<EmptyErr, (), ()>>: CSTParser<'a>`
  |
  = help: the trait `chumsky::private::ParserSealed<'_, &'a str, ((), ()), chumsky::extra::Full<EmptyErr, (), ()>>` is implemented for `Then<Ignored<chumsky::combinator::Filter<chumsky::primitive::Any<&str, chumsky::extra::Full<EmptyErr, (), ()>>, {closure@src/main.rs:9:17: 9:27}>, char>, chumsky::combinator::Map<impl CSTParser<'a, O>, O, {closure@src/main.rs:11:24: 11:27}>, (), (), chumsky::extra::Full<EmptyErr, (), ()>>`
  = help: for that trait implementation, expected `((), ())`, found `()`
  = note: required for `Then<Ignored<Filter<Any<&str, ...>, ...>, ...>, ..., ..., ..., ...>` to implement `Parser<'_, &str, ()>`
note: required for `Then<Ignored<Filter<Any<&str, ...>, ...>, ...>, ..., ..., ..., ...>` to implement `CSTParser<'a>`
 --> src/main.rs:5:16
  |
5 | impl<'a, O, T> CSTParser<'a, O> for T where T: Parser<'a, &'a str, O> {}
  |                ^^^^^^^^^^^^^^^^     ^          ---------------------- unsatisfied trait bound introduced here
  = note: the full name for the type has been written to '/home/gh-estebank/longlong/target/debug/deps/longlong-0008f9a4f2023b08.long-type-13239977239800463552.txt'
  = note: consider using `--verbose` to print the full type name to the console
  = note: the full name for the type has been written to '/home/gh-estebank/longlong/target/debug/deps/longlong-0008f9a4f2023b08.long-type-13239977239800463552.txt'
  = note: consider using `--verbose` to print the full type name to the console
```

to

```
error[E0277]: the trait bound `Then<Ignored<chumsky::combinator::Filter<chumsky::primitive::Any<&str, chumsky::extra::Full<EmptyErr, (), ()>>, {closure@src/main.rs:9:17: 9:27}>, char>, chumsky::combinator::Map<impl CSTParser<'a, O>, O, {closure@src/main.rs:11:24: 11:27}>, (), (), chumsky::extra::Full<EmptyErr, (), ()>>: CSTParser<'a>` is not satisfied
  --> src/main.rs:7:50
   |
7  | fn leaf<'a, O>(parser: impl CSTParser<'a, O>) -> impl CSTParser<'a, ()> {
   |                                                  ^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound
...
11 |     ws.then(parser.map(|_| ()))
   |     --------------------------- return type was inferred to be `Then<Ignored<..., ...>, ..., ..., ..., ...>` here
   |
   = help: the trait `ParserSealed<'_, &_, (), Full<_, _, _>>` is not implemented for `Then<Ignored<..., ...>, ..., ..., ..., ...>`
           but trait `ParserSealed<'_, &'a _, ((), ()), Full<_, _, _>>` is implemented for it
   = help: for that trait implementation, expected `((), ())`, found `()`
   = note: required for `Then<Ignored<..., ...>, ..., ..., ..., ...>` to implement `Parser<'_, &str, ()>`
note: required for `Then<Ignored<..., ...>, ..., ..., ..., ...>` to implement `CSTParser<'a>`
  --> src/main.rs:5:16
   |
5  | impl<'a, O, T> CSTParser<'a, O> for T where T: Parser<'a, &'a str, O> {}
   |                ^^^^^^^^^^^^^^^^     ^          ---------------------- unsatisfied trait bound introduced here
   = note: the full name for the type has been written to '/home/gh-estebank/longlong/target/debug/deps/longlong-df9d52be87eada65.long-type-1337037744507305372.txt'
   = note: consider using `--verbose` to print the full type name to the console
```

* Remove redundant wording
* Introduce trait diff highlighting logic and use it
* Fix incorrect "long type written to path" logic (can be split off)
* Point at tail expression in more cases in E0277
* Avoid long primary span labels in E0277 by moving them to a `help`

Fix #132013.

There are individual commits that can be their own PR. If the review load is too big, happy to split them off.
2024-11-02 20:22:49 +00:00
..
auxiliary
ambiguous-arg.rs
ambiguous-arg.stderr
arg-mismatch.rs
arg-mismatch.stderr
async-fn-mut-for-async-fn.rs
async-fn-once-for-async-fn.rs
await-inference-guidance.rs
body-check-on-non-fnmut.rs Don't call closure_by_move_body_def_id on FnOnce async closures in MIR validation 2024-09-10 10:55:05 -04:00
box-deref-in-debuginfo.rs
brand.rs
captures.rs
captures.run.stdout
clone-closure.rs
clone-closure.run.stdout
closure-shim-borrowck-error.rs Don't ICE when generating Fn shim for async closure with borrowck error 2024-09-16 10:57:58 -04:00
closure-shim-borrowck-error.stderr Don't ICE when generating Fn shim for async closure with borrowck error 2024-09-16 10:57:58 -04:00
constrained-but-no-upvars-yet.rs
debuginfo-by-move-body.rs Consider synthetic closure bodies to be typeck children 2024-09-14 16:33:25 -04:00
def-path.rs
def-path.stderr
different-projection-lengths-for-different-upvars.rs
dont-ice-when-body-tainted-by-errors.rs
dont-ice-when-body-tainted-by-errors.stderr
drop.rs
drop.run.stdout
fn-exception-target-features.rs
fn-exception-target-features.stderr
fn-exception.rs
fn-exception.stderr
force-move-due-to-actually-fnonce.rs
force-move-due-to-inferred-kind.rs
foreign.rs Encode coroutine_by_move_body_def_id in crate metadata 2024-09-16 19:59:04 -04:00
higher-ranked-return.rs
higher-ranked-return.stderr
higher-ranked.rs
implements-fnmut.rs
inline-body.rs Fix a couple more DefKind discrepancies between DefKind::Closure and DefKind::SyntheticCoroutineBody 2024-09-16 22:09:42 -04:00
is-fn.rs
is-not-fn.rs
is-not-fn.stderr
lint-closure-returning-async-block.rs
lint-closure-returning-async-block.stderr
mac-body.rs Replace walk with visit so we dont skip outermost expr kind in def collector 2024-09-01 11:16:50 -04:00
mangle.rs Remove or fix some FIXME(async_closure) 2024-11-02 03:33:31 +00:00
moro-example.rs
move-consuming-capture.rs
move-consuming-capture.stderr
move-is-async-fn.rs
move-out-of-ref.rs Fix projections when parent capture is by-ref 2024-08-14 13:24:07 -04:00
move-out-of-ref.stderr Fix projections when parent capture is by-ref 2024-08-14 13:24:07 -04:00
mut-ref-reborrow.rs
mutate.rs
no-borrow-from-env.rs Remove or fix some FIXME(async_closure) 2024-11-02 03:33:31 +00:00
non-copy-arg-does-not-force-inner-move.rs
not-clone-closure.rs
not-clone-closure.stderr On long E0277 primary span label, move it to a help 2024-11-02 03:08:04 +00:00
not-fn.rs Remove or fix some FIXME(async_closure) 2024-11-02 03:33:31 +00:00
not-fn.stderr
not-lending.rs
not-lending.stderr
once.rs
overlapping-projs.rs
overlapping-projs.run.stdout
precise-captures.call_once.run.stdout
precise-captures.call.run.stdout
precise-captures.force_once.run.stdout
precise-captures.rs Remove or fix some FIXME(async_closure) 2024-11-02 03:33:31 +00:00
refd.rs
return-type-mismatch.rs
return-type-mismatch.stderr
sig-from-bare-fn.rs Infer async closure args from Fn bound even if there is no corresponding Future bound 2024-08-14 15:33:03 -04:00
signature-deduction.rs
signature-inference-from-two-part-bound.rs
tainted-body-2.rs Don't build by-move body when async closure is tainted 2024-09-07 07:50:44 -04:00
tainted-body-2.stderr Don't build by-move body when async closure is tainted 2024-09-07 07:50:44 -04:00
tainted-body.rs
tainted-body.stderr
truncated-fields-when-imm.rs
validate-synthetic-body.rs Do not call query to compute coroutine layout for synthetic body of async closure 2024-09-01 06:13:04 -04:00
without-precise-captures-we-are-powerless.rs Remove or fix some FIXME(async_closure) 2024-11-02 03:33:31 +00:00
without-precise-captures-we-are-powerless.stderr Remove or fix some FIXME(async_closure) 2024-11-02 03:33:31 +00:00
wrong-fn-kind.rs
wrong-fn-kind.stderr