Skip to content

Commit dddc4ca

Browse files
Improve E0046
1 parent 14b7591 commit dddc4ca

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

src/librustc_typeck/diagnostics.rs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,10 +401,35 @@ extern "C" {
401401
"##,
402402

403403
E0046: r##"
404+
Items are missing in a trait implementation. Erroneous code example:
405+
406+
```
407+
trait Foo {
408+
fn foo();
409+
}
410+
411+
struct Bar;
412+
413+
impl Foo for Bar {}
414+
// error: not all trait items implemented, missing: `foo`
415+
```
416+
404417
When trying to make some type implement a trait `Foo`, you must, at minimum,
405418
provide implementations for all of `Foo`'s required methods (meaning the
406419
methods that do not have default implementations), as well as any required
407-
trait items like associated types or constants.
420+
trait items like associated types or constants. Example:
421+
422+
```
423+
trait Foo {
424+
fn foo();
425+
}
426+
427+
struct Bar;
428+
429+
impl Foo for Bar {
430+
fn foo() {} // ok!
431+
}
432+
```
408433
"##,
409434

410435
E0049: r##"

0 commit comments

Comments
 (0)