rust/tests/ui/wf
bors 757b8efed4 Auto merge of #120712 - compiler-errors:async-closures-harmonize, r=oli-obk
Harmonize `AsyncFn` implementations, make async closures conditionally impl `Fn*` traits

This PR implements several changes to the built-in and libcore-provided implementations of `Fn*` and `AsyncFn*` to address two problems:
1. async closures do not implement the `Fn*` family traits, leading to breakage: https://crater-reports.s3.amazonaws.com/pr-120361/index.html
2. *references* to async closures do not implement `AsyncFn*`, as a consequence of the existing blanket impls of the shape `AsyncFn for F where F: Fn, F::Output: Future`.

In order to fix (1.), we implement `Fn` traits appropriately for async closures. It turns out that async closures can:
* always implement `FnOnce`, meaning that they're drop-in compatible with `FnOnce`-bound combinators like `Option::map`.
* conditionally implement `Fn`/`FnMut` if they have no captures, which means that existing usages of async closures should *probably* work without breakage (crater checking this: https://github.com/rust-lang/rust/pull/120712#issuecomment-1930587805).

In order to fix (2.), we make all of the built-in callables implement `AsyncFn*` via built-in impls, and instead adjust the blanket impls for `AsyncFn*` provided by libcore to match the blanket impls for `Fn*`.
2024-02-10 07:15:15 +00:00
..
hir-wf-canonicalized.rs improve pretty printing for trait objects 2024-02-07 16:09:46 +01:00
hir-wf-canonicalized.stderr improve pretty printing for trait objects 2024-02-07 16:09:46 +01:00
hir-wf-check-erase-regions.rs Work around the fact that check_mod_type_wf may spuriously return ErrorGuaranteed, even if that error is only emitted by check_modwitem_types 2023-10-25 12:04:54 +00:00
hir-wf-check-erase-regions.stderr Provide more context on derived obligation error primary label 2024-01-30 21:28:18 +00:00
issue-48638.rs
issue-87495.rs
issue-87495.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-95665.rs
issue-95665.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-96810.rs
issue-96810.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-103573.rs
issue-103573.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-110157.rs Work around the fact that check_mod_type_wf may spuriously return ErrorGuaranteed, even if that error is only emitted by check_modwitem_types 2023-10-25 12:04:54 +00:00
issue-110157.stderr Work around the fact that check_mod_type_wf may spuriously return ErrorGuaranteed, even if that error is only emitted by check_modwitem_types 2023-10-25 12:04:54 +00:00
unnormalized-projection-guides-inference.rs temporarily revert "ice on ambguity in mir typeck" 2023-12-08 07:49:06 +00:00
wf-array-elem-sized.rs
wf-array-elem-sized.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
wf-associated-const.rs wf-check type annotations before normalization 2024-01-16 09:25:28 +01:00
wf-associated-const.stderr wf-check type annotations before normalization 2024-01-16 09:25:28 +01:00
wf-complex-assoc-type.rs
wf-complex-assoc-type.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
wf-const-type.rs Work around the fact that check_mod_type_wf may spuriously return ErrorGuaranteed, even if that error is only emitted by check_modwitem_types 2023-10-25 12:04:54 +00:00
wf-const-type.stderr Provide more context on derived obligation error primary label 2024-01-30 21:28:18 +00:00
wf-convert-unsafe-trait-obj-box.rs
wf-convert-unsafe-trait-obj-box.stderr On object safety error, mention new enum as alternative 2023-10-29 23:55:46 +00:00
wf-convert-unsafe-trait-obj.rs
wf-convert-unsafe-trait-obj.stderr On object safety error, mention new enum as alternative 2023-10-29 23:55:46 +00:00
wf-enum-bound.rs
wf-enum-bound.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
wf-enum-fields-struct-variant.rs
wf-enum-fields-struct-variant.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
wf-enum-fields.rs
wf-enum-fields.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
wf-fn-where-clause.rs
wf-fn-where-clause.stderr review comment: change wording 2024-02-01 03:31:03 +00:00
wf-foreign-fn-decl-ret.rs
wf-foreign-fn-decl-ret.stderr Point out if a local trait has no implementations 2023-09-10 21:20:36 +00:00
wf-impl-associated-type-region.rs
wf-impl-associated-type-region.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
wf-impl-associated-type-trait.rs
wf-impl-associated-type-trait.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
wf-impl-self-type.rs
wf-impl-self-type.stderr On E0277 be clearer about implicit Sized bounds on type params and assoc types 2024-02-01 03:30:26 +00:00
wf-in-fn-arg.rs
wf-in-fn-arg.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
wf-in-fn-ret.rs
wf-in-fn-ret.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
wf-in-fn-type-arg.rs
wf-in-fn-type-arg.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
wf-in-fn-type-ret.rs
wf-in-fn-type-ret.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
wf-in-fn-type-static.rs
wf-in-fn-type-static.stderr remove trailing dots 2023-10-08 10:06:17 +00:00
wf-in-fn-where-clause.rs
wf-in-fn-where-clause.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
wf-in-foreign-fn-decls-issue-80468.rs
wf-in-foreign-fn-decls-issue-80468.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
wf-in-obj-type-static.rs
wf-in-obj-type-static.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
wf-in-obj-type-trait.rs
wf-in-obj-type-trait.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
wf-in-where-clause-static.rs add known-bug test for unsound issue 98117 2023-04-22 13:31:00 -04:00
wf-inherent-impl-method-where-clause.rs
wf-inherent-impl-method-where-clause.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
wf-inherent-impl-where-clause.rs
wf-inherent-impl-where-clause.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
wf-misc-methods-issue-28609.rs
wf-misc-methods-issue-28609.stderr
wf-normalization-sized.rs add known-bug test for unsound issue 100041 2023-04-22 13:37:13 -04:00
wf-object-safe.rs
wf-object-safe.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
wf-outlives-ty-in-fn-or-trait.rs
wf-outlives-ty-in-fn-or-trait.stderr remove trailing dots 2023-10-08 10:06:17 +00:00
wf-packed-on-proj-of-type-as-unimpl-trait.rs
wf-packed-on-proj-of-type-as-unimpl-trait.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
wf-static-method.rs borrowck: use implied bounds from impl header 2024-01-16 09:25:28 +01:00
wf-static-method.stderr borrowck: use implied bounds from impl header 2024-01-16 09:25:28 +01:00
wf-static-type.rs Work around the fact that check_mod_type_wf may spuriously return ErrorGuaranteed, even if that error is only emitted by check_modwitem_types 2023-10-25 12:04:54 +00:00
wf-static-type.stderr Provide more context on derived obligation error primary label 2024-01-30 21:28:18 +00:00
wf-struct-bound.rs
wf-struct-bound.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
wf-struct-field.rs
wf-struct-field.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
wf-trait-associated-type-bound.rs
wf-trait-associated-type-bound.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
wf-trait-associated-type-region.rs
wf-trait-associated-type-region.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
wf-trait-associated-type-trait.rs
wf-trait-associated-type-trait.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
wf-trait-bound.rs
wf-trait-bound.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
wf-trait-default-fn-arg.rs
wf-trait-default-fn-arg.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
wf-trait-default-fn-ret.rs
wf-trait-default-fn-ret.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
wf-trait-default-fn-where-clause.rs
wf-trait-default-fn-where-clause.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
wf-trait-fn-arg.rs
wf-trait-fn-arg.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
wf-trait-fn-ret.rs
wf-trait-fn-ret.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
wf-trait-fn-where-clause.rs
wf-trait-fn-where-clause.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
wf-trait-superbound.rs
wf-trait-superbound.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
wf-unsafe-trait-obj-match.rs
wf-unsafe-trait-obj-match.stderr sort suggestions for object diagnostic 2024-02-08 18:56:52 +00:00