Skip to content

Commit b531776

Browse files
committed
Add long diagnostic explanation for E0275
1 parent dc556be commit b531776

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/librustc/diagnostics.rs

+23-1
Original file line numberDiff line numberDiff line change
@@ -1439,6 +1439,29 @@ anything, please remove the attribute or add some helpful note for users of the
14391439
trait.
14401440
"##,
14411441

1442+
E0275: r##"
1443+
This error occurs when there was a recursive trait requirement that overflowed
1444+
before it could be evaluated. Often this means that there is unbounded recursion
1445+
in resolving some type bounds.
1446+
1447+
For example, in the following code
1448+
1449+
```
1450+
trait Foo {}
1451+
1452+
struct Bar<T>(T);
1453+
1454+
impl<T> Foo for T where Bar<T>: Foo {}
1455+
```
1456+
1457+
to determine if a `T` is `Foo`, we need to check if `Bar<T>` is `Foo`. However,
1458+
to do this check, we need to determine that `Bar<Bar<T>>` is `Foo`. To determine
1459+
this, we check if `Bar<Bar<Bar<T>>>` is `Foo`, and so on. This is clearly a
1460+
recursive requirement that can't be resolved directly.
1461+
1462+
Consider changing your trait bounds so that they're less self-referential.
1463+
"##,
1464+
14421465
E0277: r##"
14431466
You tried to use a type which doesn't implement some trait in a place which
14441467
expected that trait. Erroneous code example:
@@ -1863,7 +1886,6 @@ register_diagnostics! {
18631886
// E0134,
18641887
// E0135,
18651888
E0264, // unknown external lang item
1866-
E0275, // overflow evaluating requirement
18671889
E0276, // requirement appears on impl method but not on corresponding trait method
18681890
E0278, // requirement is not satisfied
18691891
E0279, // requirement is not satisfied

0 commit comments

Comments
 (0)