]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0275.md
Merge commit '40dd3e2b7089b5e96714e064b731f6dbf17c61a9' into sync_cg_clif-2021-05-27
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0275.md
1 An evaluation of a trait requirement overflowed.
2
3 Erroneous code example:
4
5 ```compile_fail,E0275
6 trait Foo {}
7
8 struct Bar<T>(T);
9
10 impl<T> Foo for T where Bar<T>: Foo {}
11 ```
12
13 This error occurs when there was a recursive trait requirement that overflowed
14 before it could be evaluated. This often means that there is an unbounded
15 recursion in resolving some type bounds.
16
17 To determine if a `T` is `Foo`, we need to check if `Bar<T>` is `Foo`. However,
18 to do this check, we need to determine that `Bar<Bar<T>>` is `Foo`. To
19 determine this, we check if `Bar<Bar<Bar<T>>>` is `Foo`, and so on. This is
20 clearly a recursive requirement that can't be resolved directly.
21
22 Consider changing your trait bounds so that they're less self-referential.