@@ -749,6 +749,54 @@ for v in &vs {
749
749
```
750
750
"## ,
751
751
752
+ E0277 : r##"
753
+ You tried to use a type which doesn't implement some trait in a place which
754
+ expected that trait. Erroneous code example:
755
+
756
+ ```
757
+ // here we declare the Foo trait with a bar method
758
+ trait Foo {
759
+ fn bar(&self);
760
+ }
761
+
762
+ // we now declare a function which takes an object with Foo trait implemented
763
+ // as parameter
764
+ fn some_func<T: Foo>(foo: T) {
765
+ foo.bar();
766
+ }
767
+
768
+ fn main() {
769
+ // we now call the method with the i32 type, which doesn't implement
770
+ // the Foo trait
771
+ some_func(5i32); // error: the trait `Foo` is not implemented for the
772
+ // type `i32`
773
+ }
774
+ ```
775
+
776
+ In order to fix this error, verify that the type you're using does implement
777
+ the trait. Example:
778
+
779
+ ```
780
+ trait Foo {
781
+ fn bar(&self);
782
+ }
783
+
784
+ fn some_func<T: Foo>(foo: T) {
785
+ foo.bar(); // we can now use this method since i32 implements the
786
+ // Foo trait
787
+ }
788
+
789
+ // we implement the trait on the i32 type
790
+ impl Foo for i32 {
791
+ fn bar(&self) {}
792
+ }
793
+
794
+ fn main() {
795
+ some_func(5i32); // ok!
796
+ }
797
+ ```
798
+ "## ,
799
+
752
800
E0282 : r##"
753
801
This error indicates that type inference did not result in one unique possible
754
802
type, and extra information is required. In most cases this can be provided
@@ -1103,7 +1151,6 @@ register_diagnostics! {
1103
1151
E0274 , // rustc_on_unimplemented must have a value
1104
1152
E0275 , // overflow evaluating requirement
1105
1153
E0276 , // requirement appears on impl method but not on corresponding trait method
1106
- E0277 , // trait is not implemented for type
1107
1154
E0278 , // requirement is not satisfied
1108
1155
E0279 , // requirement is not satisfied
1109
1156
E0280 , // requirement is not satisfied
0 commit comments