Skip to content

Commit 768111f

Browse files
Add E0325 error explanation
1 parent 1ac7633 commit 768111f

File tree

1 file changed

+48
-6
lines changed

1 file changed

+48
-6
lines changed

src/librustc_typeck/diagnostics.rs

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2437,8 +2437,8 @@ impl Foo for Bar {
24372437
}
24382438
```
24392439
2440-
To fix this error, please check you didn't misspell the associated const
2441-
name or you did implement the good trait item. Example:
2440+
To fix this error, please verify you didn't misspell the associated
2441+
const name or you did implement the good trait item. Example:
24422442
24432443
```
24442444
struct Bar;
@@ -2482,14 +2482,14 @@ impl Foo for Bar {
24822482
}
24832483
```
24842484
2485-
To fix this error, please check you didn't misspell the method name. Example:
2485+
To fix this error, please verify you didn't misspell the method name. Example:
24862486
24872487
```
24882488
struct Bar;
24892489
24902490
trait Foo {
24912491
const N : u32;
2492-
2492+
24932493
fn M();
24942494
}
24952495
@@ -2501,6 +2501,50 @@ impl Foo for Bar {
25012501
```
25022502
"##,
25032503

2504+
E0325: r##"
2505+
An associated type was implemented when another trait item was expected.
2506+
Erroneous code example:
2507+
2508+
```
2509+
struct Bar;
2510+
2511+
trait Foo {
2512+
const N : u32;
2513+
}
2514+
2515+
impl Foo for Bar {
2516+
type N = u32;
2517+
// error: item `N` is an associated type, which doesn't match its
2518+
// trait `<Bar as Foo>`
2519+
}
2520+
```
2521+
2522+
To fix this error, please verify you didn't misspell the associated type name
2523+
and that your trait item implementation corresponds to the trait definition.
2524+
Example:
2525+
2526+
```
2527+
struct Bar;
2528+
2529+
trait Foo {
2530+
type N;
2531+
}
2532+
2533+
impl Foo for Bar {
2534+
type N = u32; // ok!
2535+
}
2536+
2537+
//or:
2538+
trait Foo {
2539+
const N : u32;
2540+
}
2541+
2542+
impl Foo for Bar {
2543+
const N : u32 = 0; // ok!
2544+
}
2545+
```
2546+
"##,
2547+
25042548
E0326: r##"
25052549
The types of any associated constants in a trait implementation must match the
25062550
types in the trait definition. This error indicates that there was a mismatch.
@@ -2872,8 +2916,6 @@ register_diagnostics! {
28722916
E0319, // trait impls for defaulted traits allowed just for structs/enums
28732917
E0320, // recursive overflow during dropck
28742918
E0321, // extended coherence rules for defaulted traits violated
2875-
E0324, // implemented a method when another trait item expected
2876-
E0325, // implemented an associated type when another trait item expected
28772919
E0328, // cannot implement Unsize explicitly
28782920
E0329, // associated const depends on type parameter or Self.
28792921
E0370, // discriminant overflow

0 commit comments

Comments
 (0)