Skip to content

Error reporting for trait cycles could be improved #30974

@nikomatsakis

Description

@nikomatsakis
Contributor

The new fulfillment context from #30533 can detect and extract cycles in the trait resolution graph, but (for the most part) it still reports them the same way as any other overflow. We can do a lot better. In fact, it does do a lot better, for the Sized trait in particular. This machinery could surely be adopted:

  • We should be able to print out the full cycle.
  • We should be able to avoid suggesting increasing the overflow limit, as that will not help.

We could probably stop aborting compilation too, but it'd be just a touch trickier. I think the most correct thing would be to refactor the fulfillment context interface to transmit back "overflow" as a distinct category from other errors. This is because overflow seems different from the absence of an impl. OTOH, I'm not sure if this matters in practice, particularly if we adapt the way we handle negative reasoning. Perhaps the absence of an impl and overflow can both be treated as an error in that case.

cc @aturon @arielb1

Activity

added
C-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.
on Jan 17, 2016
steveklabnik

steveklabnik commented on Sep 30, 2017

@steveklabnik
Member

Triage: I'm not aware of any changes here, but this isn't my area of specialty either.

estebank

estebank commented on Apr 18, 2018

@estebank
Contributor
oskgo

oskgo commented on Jan 24, 2024

@oskgo
Contributor

Since the fix (#49950) has been merged this should be closed.

Some diagnostics examples can be found in the tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-trait-systemArea: Trait systemC-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

        Participants

        @steveklabnik@nikomatsakis@estebank@oskgo@Dylan-DPC

        Issue actions

          Error reporting for trait cycles could be improved · Issue #30974 · rust-lang/rust