Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide more context on recursive impl evaluation overflow #119389

Merged
merged 3 commits into from
Jan 25, 2024

Commits on Jan 19, 2024

  1. Provide more context on recursive impl evaluation overflow

    When an associated type `Self::Assoc` is part of a `where` clause,
    we end up unable to evaluate the requirement and emit a E0275.
    
    We now point at the associated type if specified in the `impl`. If
    so, we also suggest using that type instead of `Self::Assoc`.
    Otherwise, we explain that these are not allowed.
    
    ```
    error[E0275]: overflow evaluating the requirement `<(T,) as Grault>::A == _`
      --> $DIR/impl-wf-cycle-1.rs:15:1
       |
    LL | / impl<T: Grault> Grault for (T,)
    LL | |
    LL | | where
    LL | |     Self::A: Baz,
    LL | |     Self::B: Fiz,
       | |_________________^
    LL |   {
    LL |       type A = ();
       |       ------ associated type `<(T,) as Grault>::A` is specified here
       |
    note: required for `(T,)` to implement `Grault`
      --> $DIR/impl-wf-cycle-1.rs:15:17
       |
    LL | impl<T: Grault> Grault for (T,)
       |                 ^^^^^^     ^^^^
    ...
    LL |     Self::A: Baz,
       |              --- unsatisfied trait bound introduced here
       = note: 1 redundant requirement hidden
       = note: required for `(T,)` to implement `Grault`
    help: associated type for the current `impl` cannot be restricted in `where` clauses, remove this bound
       |
    LL -     Self::A: Baz,
    LL +     ,
       |
    ```
    ```
    error[E0275]: overflow evaluating the requirement `<T as B>::Type == <T as B>::Type`
      --> $DIR/impl-wf-cycle-3.rs:7:1
       |
    LL | / impl<T> B for T
    LL | | where
    LL | |     T: A<Self::Type>,
       | |_____________________^
    LL |   {
    LL |       type Type = bool;
       |       --------- associated type `<T as B>::Type` is specified here
       |
    note: required for `T` to implement `B`
      --> $DIR/impl-wf-cycle-3.rs:7:9
       |
    LL | impl<T> B for T
       |         ^     ^
    LL | where
    LL |     T: A<Self::Type>,
       |        ------------- unsatisfied trait bound introduced here
    help: replace the associated type with the type specified in this `impl`
       |
    LL |     T: A<bool>,
       |          ~~~~
    ```
    ```
    error[E0275]: overflow evaluating the requirement `<T as Filter>::ToMatch == <T as Filter>::ToMatch`
      --> $DIR/impl-wf-cycle-4.rs:5:1
       |
    LL | / impl<T> Filter for T
    LL | | where
    LL | |     T: Fn(Self::ToMatch),
       | |_________________________^
       |
    note: required for `T` to implement `Filter`
      --> $DIR/impl-wf-cycle-4.rs:5:9
       |
    LL | impl<T> Filter for T
       |         ^^^^^^     ^
    LL | where
    LL |     T: Fn(Self::ToMatch),
       |        ----------------- unsatisfied trait bound introduced here
    note: associated types for the current `impl` cannot be restricted in `where` clauses
      --> $DIR/impl-wf-cycle-4.rs:7:11
       |
    LL |     T: Fn(Self::ToMatch),
       |           ^^^^^^^^^^^^^
    ```
    
    Fix rust-lang#116925
    estebank committed Jan 19, 2024
    Configuration menu
    Copy the full SHA
    2c2f3ed View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    c85bb27 View commit details
    Browse the repository at this point in the history

Commits on Jan 22, 2024

  1. Configuration menu
    Copy the full SHA
    29bdf9e View commit details
    Browse the repository at this point in the history