Skip to content

Commit 522a978

Browse files
committed
Add long diagnostic for E0276
1 parent b531776 commit 522a978

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/librustc/diagnostics.rs

+22-1
Original file line numberDiff line numberDiff line change
@@ -1462,6 +1462,28 @@ recursive requirement that can't be resolved directly.
14621462
Consider changing your trait bounds so that they're less self-referential.
14631463
"##,
14641464

1465+
E0276: r##"
1466+
This error occurs when a bound in an implementation of a trait does not match
1467+
the bounds specified in the original trait. For example:
1468+
1469+
```
1470+
trait Foo {
1471+
fn foo<T>(x: T);
1472+
}
1473+
1474+
impl Foo for bool {
1475+
fn foo<T>(x: T) where T: Copy {}
1476+
}
1477+
```
1478+
1479+
Here, all types implementing `Foo` must have a method `foo<T>(x: T)` which can
1480+
take any type `T`. However, in the `impl` for `bool`, we have added an extra
1481+
bound that `T` is `Copy`, which isn't compatible with the original trait.
1482+
1483+
Consider removing the bound from the method or adding the bound to the original
1484+
method definition in the trait.
1485+
"##,
1486+
14651487
E0277: r##"
14661488
You tried to use a type which doesn't implement some trait in a place which
14671489
expected that trait. Erroneous code example:
@@ -1886,7 +1908,6 @@ register_diagnostics! {
18861908
// E0134,
18871909
// E0135,
18881910
E0264, // unknown external lang item
1889-
E0276, // requirement appears on impl method but not on corresponding trait method
18901911
E0278, // requirement is not satisfied
18911912
E0279, // requirement is not satisfied
18921913
E0280, // requirement is not satisfied

0 commit comments

Comments
 (0)