rust/tests/ui/typeck
bors 87e1447aad Auto merge of #117805 - estebank:arg-fn-mismatch, r=petrochenkov
On Fn arg mismatch for a fn path, suggest a closure

When encountering a fn call that has a path to another fn being passed in, where an `Fn` impl is expected, and the arguments differ, suggest wrapping the argument with a closure with the appropriate arguments.

The last `help` is new:

```
error[E0631]: type mismatch in function arguments
  --> $DIR/E0631.rs:9:9
   |
LL |     fn f(_: u64) {}
   |     ------------ found signature defined here
...
LL |     foo(f);
   |     --- ^ expected due to this
   |     |
   |     required by a bound introduced by this call
   |
   = note: expected function signature `fn(usize) -> _`
              found function signature `fn(u64) -> _`
note: required by a bound in `foo`
  --> $DIR/E0631.rs:3:11
   |
LL | fn foo<F: Fn(usize)>(_: F) {}
   |           ^^^^^^^^^ required by this bound in `foo`
help: consider wrapping the function in a closure
   |
LL |     foo(|arg0: usize| f(/* u64 */));
   |         +++++++++++++  +++++++++++
```
2023-11-30 20:12:53 +00:00
..
auxiliary
issue-87181 Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-114918 Show number in error message even for one error 2023-11-24 19:15:52 +01:00
apit-with-error-type-in-sig.rs
apit-with-error-type-in-sig.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
assign-non-lval-derefmut.fixed
assign-non-lval-derefmut.rs
assign-non-lval-derefmut.stderr
assign-non-lval-mut-ref.fixed
assign-non-lval-mut-ref.rs
assign-non-lval-mut-ref.stderr
assign-non-lval-needs-deref.rs
assign-non-lval-needs-deref.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
autoderef-with-param-env-error.rs
autoderef-with-param-env-error.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
bad-index-due-to-nested.rs
bad-index-due-to-nested.stderr Tweak wording of type errors involving type params 2023-10-18 23:53:18 +00:00
bad-index-modulo-higher-ranked-regions.rs Don't ICE when ambiguity is found when selecting Index implementation in typeck 2023-11-20 23:37:04 +00:00
bad-index-modulo-higher-ranked-regions.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
bad-recursive-type-sig-infer.rs
bad-recursive-type-sig-infer.stderr
bad-type-in-vec-contains.rs
bad-type-in-vec-contains.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
bad-type-in-vec-push.rs
bad-type-in-vec-push.stderr
call-block.rs
call-block.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
check-args-on-fn-err-2.rs
check-args-on-fn-err-2.stderr
check-args-on-fn-err.rs
check-args-on-fn-err.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
conversion-methods.rs
conversion-methods.stderr
deref-multi.rs
deref-multi.stderr
derive-sugg-arg-arity.rs
derive-sugg-arg-arity.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
do-not-suggest-adding-missing-zero-to-floating-point-number.rs
do-not-suggest-adding-missing-zero-to-floating-point-number.stderr
do-not-suggest-placeholder-to-const-static-without-type.rs
do-not-suggest-placeholder-to-const-static-without-type.stderr
dont-record-adjustments-when-pointing-at-arg.rs
dont-record-adjustments-when-pointing-at-arg.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
escaping_bound_vars.rs add test 2023-10-09 13:57:26 +03:00
escaping_bound_vars.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
explain_clone_autoref.rs
explain_clone_autoref.stderr
issue-1871.rs
issue-1871.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-2063-resource.rs
issue-2063.rs
issue-7813.rs
issue-7813.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-10401.rs
issue-10401.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-10969.rs
issue-10969.stderr
issue-13853-2.rs
issue-13853-2.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-13853-5.rs
issue-13853-5.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-13853.rs
issue-13853.stderr Tweak wording of type errors involving type params 2023-10-18 23:53:18 +00:00
issue-18937-1.rs
issue-18937.rs
issue-18937.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-22375.rs
issue-29124.rs
issue-29124.stderr
issue-29181.rs
issue-29181.stderr
issue-31173.rs
issue-31173.stderr
issue-33575.rs
issue-33575.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-36708.rs
issue-36708.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-43189.rs
issue-43189.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-46112.rs
issue-46112.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-50687-ice-on-borrow.rs
issue-50687-ice-on-borrow.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-52082-type-param-shadows-existing-type.rs
issue-52082-type-param-shadows-existing-type.stderr recover primary span label 2023-11-16 17:00:23 +00:00
issue-53712.rs
issue-53712.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-55810-must-typeck-match-pats-before-guards.rs
issue-57404.rs
issue-57404.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-57673-ice-on-deref-of-boxed-trait.rs
issue-57673-ice-on-deref-of-boxed-trait.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-61711-once-caused-rustc-inf-loop.rs
issue-65611.rs
issue-65611.stderr recover primary span label 2023-11-16 17:00:23 +00:00
issue-67971.rs
issue-67971.stderr recover primary span label 2023-11-16 17:00:23 +00:00
issue-68590-reborrow-through-derefmut.rs
issue-69378-ice-on-invalid-type-node-after-recovery.rs
issue-69378-ice-on-invalid-type-node-after-recovery.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-72225-call-fnmut-through-derefmut.rs
issue-73592-borrow_mut-through-deref.fixed
issue-73592-borrow_mut-through-deref.rs
issue-73592-borrow_mut-through-deref.stderr
issue-74086.rs
issue-74086.stderr
issue-74933.rs
issue-75883.rs
issue-75883.stderr
issue-75889.rs
issue-75889.stderr
issue-79040.rs
issue-79040.stderr
issue-80207-unsized-return.rs
issue-80779.rs
issue-80779.stderr
issue-81293.rs
issue-81293.stderr
issue-81885.rs
issue-81885.stderr
issue-81943.rs
issue-81943.stderr
issue-82772.rs
issue-82772.stderr
issue-83621-placeholder-static-in-extern.rs
issue-83621-placeholder-static-in-extern.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-83693.rs
issue-83693.stderr
issue-84160.rs
issue-84160.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-84768.rs
issue-84768.stderr
issue-84831.rs
issue-84831.stderr
issue-86721-return-expr-ice.rev1.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-86721-return-expr-ice.rev2.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-86721-return-expr-ice.rs
issue-87771-ice-assign-assign-to-bool.rs
issue-87771-ice-assign-assign-to-bool.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-87872-missing-inaccessible-field-literal.rs
issue-87872-missing-inaccessible-field-literal.stderr Tweak message on ADT with private fields building 2023-11-29 18:11:57 +00:00
issue-87872-missing-inaccessible-field-pattern.rs
issue-87872-missing-inaccessible-field-pattern.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-88609.rs
issue-88643.rs
issue-88643.stderr
issue-88803-call-expr-method.fixed
issue-88803-call-expr-method.rs
issue-88803-call-expr-method.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-88844.rs
issue-88844.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-89044-wrapped-expr-method.fixed
issue-89044-wrapped-expr-method.rs
issue-89044-wrapped-expr-method.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-89275.rs
issue-89275.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-89806.rs
issue-89806.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-89856.fixed
issue-89856.rs
issue-89856.stderr
issue-89935.rs
issue-90027-async-fn-return-suggestion.rs
issue-90027-async-fn-return-suggestion.stderr
issue-90101.rs
issue-90101.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-90164.rs
issue-90164.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-90319.rs
issue-90319.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-90483-inaccessible-field-adjustment.rs
issue-90483-inaccessible-field-adjustment.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-90804-incorrect-reference-suggestion.rs
issue-90804-incorrect-reference-suggestion.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-91210-ptr-method.fixed
issue-91210-ptr-method.rs
issue-91210-ptr-method.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-91267.rs
issue-91267.stderr
issue-91328.fixed
issue-91328.rs
issue-91328.stderr
issue-91334.rs s/generator/coroutine/ 2023-10-20 21:14:01 +00:00
issue-91334.stderr
issue-91450-inner-ty-error.rs
issue-91450-inner-ty-error.stderr
issue-91633.rs
issue-92481.rs
issue-92481.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-93486.rs
issue-93486.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-96530.rs
issue-96530.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-96738.rs
issue-96738.stderr recover primary span label 2023-11-16 17:00:23 +00:00
issue-98260.rs
issue-98260.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-98982.rs
issue-98982.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-100164.fixed
issue-100164.rs
issue-100164.stderr
issue-100246.rs
issue-100246.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-100285.rs
issue-100285.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-103899.rs
issue-104510-ice.rs
issue-104510-ice.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-104513-ice.rs
issue-104513-ice.stderr
issue-104582.rs
issue-104582.stderr
issue-105946.rs
issue-105946.stderr On resolve error of [rest..], suggest [rest @ ..] 2023-11-17 00:55:55 +00:00
issue-106929.rs
issue-106929.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-107087.rs
issue-107087.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-107775.rs
issue-107775.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-110017-format-into-help-deletes-macro.fixed
issue-110017-format-into-help-deletes-macro.rs
issue-110017-format-into-help-deletes-macro.stderr
issue-110052.rs
issue-110052.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-112007-leaked-writeln-macro-internals.fixed
issue-112007-leaked-writeln-macro-internals.rs
issue-112007-leaked-writeln-macro-internals.stderr
issue-112252-ptr-arithmetics-help.fixed
issue-112252-ptr-arithmetics-help.rs
issue-112252-ptr-arithmetics-help.stderr
issue-112385-while-assign-lhs-place-expr-ice.rs
issue-112385-while-assign-lhs-place-expr-ice.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-114423-ice-regression-in-suggestion.rs
issue-114423-ice-regression-in-suggestion.stderr
issue-114529-illegal-break-with-value.rs Typeck break expr even if break is illegal 2023-11-20 15:14:08 +05:30
issue-114529-illegal-break-with-value.stderr Typeck break expr even if break is illegal 2023-11-20 15:14:08 +05:30
issue-116473-ice-wrong-span-variant-args.rs Fix suggestion span involving wrongly placed generic arg on enum variants 2023-10-09 08:04:00 +05:30
issue-116473-ice-wrong-span-variant-args.stderr Fix duplicate labels emitted in render_multispan_macro_backtrace() 2023-10-19 08:03:40 +05:30
mismatched-map-under-self.rs
mismatched-map-under-self.stderr On Fn arg mismatch for a fn path, suggest a closure 2023-11-29 18:55:00 +00:00
missing-private-fields-in-struct-literal.rs
missing-private-fields-in-struct-literal.stderr Tweak message on ADT with private fields building 2023-11-29 18:11:57 +00:00
no-type-for-node-ice.rs
no-type-for-node-ice.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
nonexistent-field-not-ambiguous.rs
nonexistent-field-not-ambiguous.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
output-type-mismatch.rs
output-type-mismatch.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
path-to-method-sugg-unresolved-expr.rs
path-to-method-sugg-unresolved-expr.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
pin-unsound-issue-85099-derefmut.rs
point-at-type-param-in-path-expr.rs
point-at-type-param-in-path-expr.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
point-at-type-parameter-definition.rs
point-at-type-parameter-definition.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
prim-with-args.fixed
prim-with-args.rs
prim-with-args.stderr
project-cache-issue-37154.rs
ptr-null-mutability-suggestions.fixed
ptr-null-mutability-suggestions.rs
ptr-null-mutability-suggestions.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
quiet-type-err-let-binding.rs
quiet-type-err-let-binding.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
remove-extra-argument.fixed
remove-extra-argument.rs
remove-extra-argument.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
repeat-expr-checks-wf.rs
repeat-expr-checks-wf.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
return_type_containing_closure.rs
return_type_containing_closure.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
return-dyn-type-mismatch-2.rs
return-dyn-type-mismatch-2.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
return-dyn-type-mismatch.rs
return-dyn-type-mismatch.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
slow-lhs-suggestion.rs
slow-lhs-suggestion.stderr
struct-enum-wrong-args.rs
struct-enum-wrong-args.stderr
suggest-adding-missing-zero-to-floating-point-number.fixed
suggest-adding-missing-zero-to-floating-point-number.rs
suggest-adding-missing-zero-to-floating-point-number.stderr
suppressed-error.rs
suppressed-error.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
tag-that-dare-not-speak-its-name.rs
tag-that-dare-not-speak-its-name.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
terr-in-field.rs
terr-in-field.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
terr-sorts.rs
terr-sorts.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
type-placeholder-fn-in-const.rs
type-placeholder-fn-in-const.stderr
typeck_type_placeholder_1.rs
typeck_type_placeholder_item_help.rs
typeck_type_placeholder_item_help.stderr
typeck_type_placeholder_item.rs
typeck_type_placeholder_item.stderr
typeck_type_placeholder_lifetime_1.rs
typeck_type_placeholder_lifetime_1.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
typeck_type_placeholder_lifetime_2.rs
typeck_type_placeholder_lifetime_2.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
typeck_type_placeholder_mismatch.rs
typeck_type_placeholder_mismatch.stderr
typeck-builtin-bound-type-parameters.rs
typeck-builtin-bound-type-parameters.stderr Add a note to duplicate diagnostics 2023-10-05 01:04:41 +00:00
typeck-cast-pointer-to-float.rs
typeck-cast-pointer-to-float.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
typeck-closure-to-unsafe-fn-ptr.rs
typeck-default-trait-impl-assoc-type.fixed
typeck-default-trait-impl-assoc-type.rs
typeck-default-trait-impl-assoc-type.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
typeck-default-trait-impl-cross-crate-coherence.rs
typeck-default-trait-impl-cross-crate-coherence.stderr
typeck-default-trait-impl-negation-send.rs
typeck-default-trait-impl-negation-send.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
typeck-default-trait-impl-negation-sync.rs
typeck-default-trait-impl-negation-sync.stderr
typeck-default-trait-impl-send-param.rs
typeck-default-trait-impl-send-param.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
typeck-fn-to-unsafe-fn-ptr.rs
typeck-unsafe-always-share.rs
typeck-unsafe-always-share.stderr
ufcs-type-params.rs
unify-return-ty.rs
while-loop-block-cond.rs
while-loop-block-cond.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
while-type-error.rs
while-type-error.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
wrong-ret-type.rs
wrong-ret-type.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00