Overflow evaluating the requirement error could be better for trivially recursive impls

e1f90ba
Opened by gnzlbg at 2020-06-08 10:18:18

This overflow error could be better:

pub trait A {}
impl<T: A> A for T {}

pub trait B: A {}

struct C {}

impl B for C {}

fn main() {}

errors with:

error[E0275]: overflow evaluating the requirement `C: A`
 --> src/main.rs:8:6
  |
8 | impl B for C {}
  |      ^
  |
  = note: required by `B`

error: aborting due to previous error

which doesn't really point at the problem. The problem is that the impl<T: A> A for T {} is recursive.

  1. Even more trivial recursion affected by this, with only one trait and no structs:

    
    trait Trait {}
    
    impl<T> Trait for T where T: Trait {}
    
    fn func<X: Trait>() {}
    
    fn main() {
        func::<u32>();
    }
    

    lcdr at 2020-06-08 10:18:18