Skip to content

Confusing error message with let _ : impl Trait; #70968

Closed
@CDirkx

Description

@CDirkx

A let binding with an existential type annotation and without an initializer expression results in error[E0720]: opaque type expands to a recursive type.

#![feature(impl_trait_in_bindings)]

fn foo() {
    let _ : impl Copy;
}
error[E0720]: opaque type expands to a recursive type
 --> src/lib.rs:4:13
  |
4 |     let _ : impl Copy;
  |             ^^^^^^^^^ expands to a recursive type
  |
  = note: type resolves to itself

(playground)

The mention of recursion here distracts from the actual problem (the type could not be resolved to/satisfied as a concrete type) and no hint is given how to fix this error.

Related: #66523

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-enhancementCategory: An issue proposing an enhancement or a PR with one.D-confusingDiagnostics: Confusing error or lint that should be reworked.D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.F-impl_trait_in_bindings`#![feature(impl_trait_in_bindings)]`P-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions