Skip to content

Commit cf8a163

Browse files
committed
add diagnostics for E0437 and E0438
1 parent 5542830 commit cf8a163

File tree

1 file changed

+51
-2
lines changed

1 file changed

+51
-2
lines changed

src/librustc_resolve/diagnostics.rs

+51-2
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,57 @@ use something_which_doesnt_exist;
426426
Please verify you didn't misspell the import's name.
427427
"##,
428428

429+
E0437: r##"
430+
Trait impls can only implement associated types that are members of the trait in
431+
question. This error indicates that you attempted to implement an associated
432+
type whose name does not match the name of any associated type in the trait.
433+
434+
Here is an example that demonstrates the error:
435+
436+
```
437+
trait Foo {}
438+
439+
impl Foo for i32 {
440+
type Bar = bool;
441+
}
442+
```
443+
444+
The solution to this problem is to remove the extraneous associated type:
445+
446+
```
447+
trait Foo {}
448+
449+
impl Foo for i32 {}
450+
```
451+
"##,
452+
453+
E0438: r##"
454+
Trait impls can only implement associated constants that are members of the
455+
trait in question. This error indicates that you attempted to implement an
456+
associated constant whose name does not match the name of any associated
457+
constant in the trait.
458+
459+
Here is an example that demonstrates the error:
460+
461+
```
462+
#![feature(associated_consts)]
463+
464+
trait Foo {}
465+
466+
impl Foo for i32 {
467+
const BAR: bool = true;
468+
}
469+
```
470+
471+
The solution to this problem is to remove the extraneous associated constant:
472+
473+
```
474+
trait Foo {}
475+
476+
impl Foo for i32 {}
477+
```
478+
"##
479+
429480
}
430481

431482
register_diagnostics! {
@@ -468,6 +519,4 @@ register_diagnostics! {
468519
E0432, // unresolved import
469520
E0434, // can't capture dynamic environment in a fn item
470521
E0435, // attempt to use a non-constant value in a constant
471-
E0437, // type is not a member of trait
472-
E0438, // const is not a member of trait
473522
}

0 commit comments

Comments
 (0)