Skip to content

For recursive impl trait point at statement that causes the recursion #57341

Closed
@estebank

Description

@estebank

After #56074, the error is already good enough:

error[E0720]: opaque type expands to a recursive type
  --> $DIR/recursive-impl-trait-type.rs:6:22
   |
LL | fn option(i: i32) -> impl Sized { //~ ERROR
   |                      ^^^^^^^^^^ expands to self-referential type
   |
   = note: expanded type is `std::option::Option<(impl Sized, i32)>`

but it'd be nice if we pointed at the exact statement causing the recursion:

error[E0720]: opaque type expands to a recursive type
  --> $DIR/recursive-impl-trait-type.rs:6:22
   |
LL | fn option(i: i32) -> impl Sized { //~ ERROR
   |                      ^^^^^^^^^^ expands to self-referential type
...
LL |         Some((option(i - 1), i))
   |         ^^^^^^^^^^^^^^^^^^^^^^^^ expanded type is `std::option::Option<(impl Sized, i32)>`
LL |     }
LL | }

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.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