rust/tests/ui/const-generics/generic_const_exprs
Esteban Küber 796be88062 Use fn ptr signature instead of {closure@..} in infer error
When suggesting a type on inference error, do not use `{closure@..}`.
Instead, replace with an appropriate `fn` ptr.

On the error message, use `short_ty_string` and write long types to
disk.

```
error[E0284]: type annotations needed for `Select<{closure@lib.rs:2782:13}, _, Expression<'_>, _>`
  --> crates/lang/src/parser.rs:41:13
   |
41 |         let lit = select! {
   |             ^^^
42 |             Token::Int(i) = e => Expression::new(Expr::Lit(ast::Lit::Int(i.parse().unwrap())), e.span()),
   |                                                                                                  ---- type must be known at this point
   |
   = note: the full type name has been written to '/home/gh-estebank/iowo/target/debug/deps/lang-e2d6e25819442273.long-type-4587393693885174369.txt'
   = note: cannot satisfy `<_ as chumsky::input::Input<'_>>::Span == SimpleSpan`
help: consider giving `lit` an explicit type, where the type for type parameter `I` is specified
   |
41 |         let lit: Select<for<'a, 'b> fn(tokens::Token<'_>, &'a mut MapExtra<'_, 'b, _, _>) -> Option<Expression<'_>>, _, Expression<'_>, _> = select! {
   |                +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
```

instead of

```
error[E0284]: type annotations needed for `Select<{closure@/home/gh-estebank/.cargo/registry/src/index.crates.io-6f17d22bba15001f/chumsky-1.0.0-alpha.6/src/lib.rs:2782:13: 2782:28}, _, Expression<'_>, _>`
  --> crates/lang/src/parser.rs:41:13
   |
41 |         let lit = select! {
   |             ^^^
42 |             Token::Int(i) = e => Expression::new(Expr::Lit(ast::Lit::Int(i.parse().unwrap())), e.span()),
   |                                                                                                  ---- type must be known at this point
   |
   = note: cannot satisfy `<_ as chumsky::input::Input<'_>>::Span == SimpleSpan`
help: consider giving `lit` an explicit type, where the type for type parameter `I` is specified
   |
41 |         let lit: Select<{closure@/home/gh-estebank/.cargo/registry/src/index.crates.io-6f17d22bba15001f/chumsky-1.0.0-alpha.6/src/lib.rs:2782:13: 2782:28}, _, Expression<'_>, _> = select! {
   |                ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
```

Fix #123630.
2024-04-10 00:41:27 +00:00
..
assoc_const_unification Provide structured suggestion for unconstrained generic constant 2024-03-21 00:03:59 +00:00
auxiliary Remove some unnecessary allow(incomplete_features) 2024-03-11 19:42:04 +00:00
const_kind_expr Provide structured suggestion for unconstrained generic constant 2024-03-21 00:03:59 +00:00
abstract-const-as-cast-1.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
abstract-const-as-cast-2.fixed Provide structured suggestion for unconstrained generic constant 2024-03-21 00:03:59 +00:00
abstract-const-as-cast-2.rs Provide structured suggestion for unconstrained generic constant 2024-03-21 00:03:59 +00:00
abstract-const-as-cast-2.stderr Provide structured suggestion for unconstrained generic constant 2024-03-21 00:03:59 +00:00
abstract-const-as-cast-3.rs
abstract-const-as-cast-3.stderr Provide structured suggestion for unconstrained generic constant 2024-03-21 00:03:59 +00:00
abstract-const-as-cast-4.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
abstract-consts-as-cast-5.rs
abstract-consts-as-cast-5.stderr Provide structured suggestion for unconstrained generic constant 2024-03-21 00:03:59 +00:00
array-size-in-generic-struct-param.full.stderr Provide structured suggestion for unconstrained generic constant 2024-03-21 00:03:59 +00:00
array-size-in-generic-struct-param.min.stderr Provide structured suggestion for #![feature(foo)] 2024-03-18 16:08:58 +00:00
array-size-in-generic-struct-param.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
associated-const.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
associated-consts.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
closures.rs
closures.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
const_eval_resolve_canonical.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
const-block-is-poly.rs
const-block-is-poly.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
convert-refree-region-vid-ice-114464.rs add test for #114464 2024-03-24 10:09:56 +01:00
convert-refree-region-vid-ice-114464.stderr add test for #114464 2024-03-24 10:09:56 +01:00
cross_crate_predicate.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
cross_crate_predicate.stderr Provide structured suggestion for unconstrained generic constant 2024-03-21 00:03:59 +00:00
cross_crate.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
dependence_lint.full.stderr generic_const_exprs: suggest to add the feature, not use it 2023-11-30 20:59:51 +01:00
dependence_lint.gce.stderr Provide structured suggestion for unconstrained generic constant 2024-03-21 00:03:59 +00:00
dependence_lint.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
different-fn.rs
different-fn.stderr Provide structured suggestion for unconstrained generic constant 2024-03-21 00:03:59 +00:00
division.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
dont-eagerly-error-in-is-const-evaluatable.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
drop_impl.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
elaborate-trait-pred.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
eval-privacy.rs Replace old private-in-public diagnostic with type privacy lints 2023-08-02 13:40:28 +03:00
eval-privacy.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
eval-try-unify.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
eval-try-unify.stderr
evaluated-to-ambig.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
failed-to-normalize-ice-issue-88421.rs add issue numbers via // issue: rust-lang/rust#ISSUE_NUM directive 2024-03-24 09:34:11 +01:00
feature-gate-generic_const_exprs.rs
feature-gate-generic_const_exprs.stderr generic_const_exprs: suggest to add the feature, not use it 2023-11-30 20:59:51 +01:00
fn_call.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
from-sig-fail.rs
from-sig-fail.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
from-sig.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
function-call.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
function-call.stderr
ice-generics_of-no-entry-found-for-key-113017.rs address review comments 2024-03-22 11:35:31 +01:00
ice-generics_of-no-entry-found-for-key-113017.stderr address review comments 2024-03-22 11:35:31 +01:00
ice-predicates-of-no-entry-found-for-key-119275.rs add test for ice #119275 "no entry found for key" in predicates_of.rs 2024-03-22 08:45:03 +01:00
ice-predicates-of-no-entry-found-for-key-119275.stderr add test for ice #119275 "no entry found for key" in predicates_of.rs 2024-03-22 08:45:03 +01:00
impl-bounds.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
infer-too-generic.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
inline-const-in-const-generic-defaults.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-62504.full.stderr Use fn ptr signature instead of {closure@..} in infer error 2024-04-10 00:41:27 +00:00
issue-62504.min.stderr Use fn ptr signature instead of {closure@..} in infer error 2024-04-10 00:41:27 +00:00
issue-62504.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-69654.rs
issue-69654.stderr
issue-72787.min.stderr generic_const_exprs: suggest to add the feature, not use it 2023-11-30 20:59:51 +01:00
issue-72787.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-72819-generic-in-const-eval.full.stderr
issue-72819-generic-in-const-eval.min.stderr generic_const_exprs: suggest to add the feature, not use it 2023-11-30 20:59:51 +01:00
issue-72819-generic-in-const-eval.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-73298.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-73899.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-74634.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-74713.rs improve diagnostics and bless tests 2023-05-05 21:42:54 +01:00
issue-74713.stderr generic_const_exprs: suggest to add the feature, not use it 2023-11-30 20:59:51 +01:00
issue-76595.rs
issue-76595.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-79518-default_trait_method_normalization.rs
issue-79518-default_trait_method_normalization.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-80561-incorrect-param-env.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-80742.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-80742.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-82268.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-83765.rs
issue-83765.stderr Provide structured suggestion for unconstrained generic constant 2024-03-21 00:03:59 +00:00
issue-83972.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-84408.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-84669.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-85848.rs
issue-85848.stderr Provide structured suggestion for unconstrained generic constant 2024-03-21 00:03:59 +00:00
issue-86710.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-89851.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-90847.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-94287.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-94287.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-94293.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-96699.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-97047-ice-1.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-97047-ice-1.stderr
issue-97047-ice-2.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-97047-ice-2.stderr
issue-99647.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-99705.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-100217.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-100360.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-102074.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
issue-102768.rs Avoid silencing relevant follow-up errors 2024-01-09 21:08:16 +00:00
issue-102768.stderr Avoid silencing relevant follow-up errors 2024-01-09 21:08:16 +00:00
issue-105257.rs Avoid silencing relevant follow-up errors 2024-01-09 21:08:16 +00:00
issue-105257.stderr Avoid silencing relevant follow-up errors 2024-01-09 21:08:16 +00:00
issue-105608.rs
issue-105608.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
issue-109141.rs register opaques that reference errors 2024-03-20 17:30:19 +00:00
issue-109141.stderr register opaques that reference errors 2024-03-20 17:30:19 +00:00
less_than.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
let-bindings.rs
let-bindings.stderr
mismatched-gat-subst-kind.rs
mismatched-gat-subst-kind.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
needs_where_clause.rs
needs_where_clause.stderr Provide structured suggestion for unconstrained generic constant 2024-03-21 00:03:59 +00:00
nested_uneval_unification-1.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
nested_uneval_unification-2.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
nested-abstract-consts-1.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
nested-abstract-consts-2.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
no_dependence.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
no_where_clause.rs Continue compilation after check_mod_type_wf errors 2024-02-14 11:00:30 +00:00
no_where_clause.stderr Provide structured suggestion for unconstrained generic constant 2024-03-21 00:03:59 +00:00
no-entry-found-for-key-ice-gce-nlb-113133.rs add test for ICE: no entry found for key for const function in generic_const_exprs #113133 2024-03-24 10:16:29 +01:00
no-entry-found-for-key-ice-gce-nlb-113133.stderr add test for ICE: no entry found for key for const function in generic_const_exprs #113133 2024-03-24 10:16:29 +01:00
non_local_anon_const_diagnostics.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
non_local_anon_const_diagnostics.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
normed_to_param_is_evaluatable.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
object-safety-err-ret.rs Continue compilation after check_mod_type_wf errors 2024-02-14 11:00:30 +00:00
object-safety-err-ret.stderr Continue compilation after check_mod_type_wf errors 2024-02-14 11:00:30 +00:00
object-safety-err-where-bounds.rs
object-safety-err-where-bounds.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
object-safety-ok-infer-err.rs
object-safety-ok-infer-err.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
object-safety-ok.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
obligation-cause.rs
obligation-cause.stderr Deduplicate more sized errors on call exprs 2024-01-24 02:53:15 +00:00
opaque_type.rs Allow defining opaque types when checking const equality bounds 2024-04-04 15:43:02 +00:00
opaque_type.stderr Allow defining opaque types when checking const equality bounds 2024-04-04 15:43:02 +00:00
poly-const-uneval-ice-106423.rs add test for #106423 2024-03-23 12:32:32 +01:00
simple_fail.rs
simple_fail.stderr
single-satisfied-ConstEvaluatable-in-probe.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
subexprs_are_const_evalutable.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
ty-alias-substitution.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
type_mismatch.rs Make generic const type mismatches not hide trait impls from the trait solver 2024-01-22 13:23:45 +00:00
type_mismatch.stderr Revert "Auto merge of #122140 - oli-obk:track_errors13, r=davidtwco" 2024-03-11 21:28:16 +00:00
typeid-equality-by-subtyping.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
typeid-equality-by-subtyping.stderr Make infer higher ranked equate use bidirectional subtyping in invariant context 2024-02-29 15:27:56 -03:00
unevaluated-const-ice-119731.rs add test for https://github.com/rust-lang/rust/issues/119731 2024-03-24 10:01:50 +01:00
unevaluated-const-ice-119731.stderr add test for https://github.com/rust-lang/rust/issues/119731 2024-03-24 10:01:50 +01:00
unify-op-with-fn-call.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
unify-op-with-fn-call.stderr Provide structured suggestion for unconstrained generic constant 2024-03-21 00:03:59 +00:00
unknown-alias-defkind-anonconst-ice-116710.rs add test for ice: unknown alias DefKind: AnonConst #116710 2024-04-07 01:20:56 +02:00
unknown-alias-defkind-anonconst-ice-116710.stderr add test for ice: unknown alias DefKind: AnonConst #116710 2024-04-07 01:20:56 +02:00
unop.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00
unresolved_lifetimes_error.rs improve diagnostics and bless tests 2023-05-05 21:42:54 +01:00
unresolved_lifetimes_error.stderr Show number in error message even for one error 2023-11-24 19:15:52 +01:00
unused_expr.rs
unused_expr.stderr
unused-complex-default-expr.rs [AUTO-GENERATED] Migrate ui tests from // to //@ directives 2024-02-16 20:02:50 +00:00