]> git.lizzy.rs Git - rust.git/blob - src/librustc_error_codes/error_codes/E0275.md
Rollup merge of #67875 - dtolnay:hidden, r=GuillaumeGomez
[rust.git] / src / librustc_error_codes / error_codes / E0275.md
1 This error occurs when there was a recursive trait requirement that overflowed
2 before it could be evaluated. Often this means that there is unbounded
3 recursion in resolving some type bounds.
4
5 For example, in the following code:
6
7 ```compile_fail,E0275
8 trait Foo {}
9
10 struct Bar<T>(T);
11
12 impl<T> Foo for T where Bar<T>: Foo {}
13 ```
14
15 To determine if a `T` is `Foo`, we need to check if `Bar<T>` is `Foo`. However,
16 to do this check, we need to determine that `Bar<Bar<T>>` is `Foo`. To
17 determine this, we check if `Bar<Bar<Bar<T>>>` is `Foo`, and so on. This is
18 clearly a recursive requirement that can't be resolved directly.
19
20 Consider changing your trait bounds so that they're less self-referential.