Skip to content

Nonsensical suggested type using chumsky select! (E0284) #123630

Closed
@schrottkatze

Description

@schrottkatze

Code

https://forge.katzen.cafe/schrottkatze/iowo/src/commit/bfd4b3765f35a98112b691d2f29c2c3446fe4d5c/crates/lang/src/parser.rs#L41-L44

Current output

error[E0284]: type annotations needed for `Select<{closure@/home/jade/.cargo/registry/src/index.crates.io-6f17d22bba15001f/chumsky-1.0.0-alpha.6/src/lib.rs:2782:13: 2782:28}, I, Expression<'_>, E>`
  --> 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/jade/.cargo/registry/src/index.crates.io-6f17d22bba15001f/chumsky-1.0.0-alpha.6/src/lib.rs:2782:13: 2782:28}, I, Expression<'_>, E> = select! {
   |                +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Desired output

No response

Rationale and extra context

This error is very confusing and unreadable, and the compiler even proposes adding a type containing a local path into the code.

That seems very problematic and incorrect.

Other cases

No response

Rust Version

rustc 1.77.0-nightly (190f4c961 2024-01-09)
binary: rustc
commit-hash: 190f4c96116a3b59b7de4881cfec544be0246d84
commit-date: 2024-01-09
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6

Anything else?

No response

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsD-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.E-needs-mcveCall for participation: This issue has a repro, but needs a Minimal Complete and Verifiable ExampleE-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions