Skip to content

Commit 423de1c

Browse files
committed
rustc_error_codes: improve docs for E0642
1 parent b15e71a commit 423de1c

File tree

1 file changed

+11
-1
lines changed
  • compiler/rustc_error_codes/src/error_codes

1 file changed

+11
-1
lines changed

compiler/rustc_error_codes/src/error_codes/E0642.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
Trait methods currently cannot take patterns as arguments.
1+
Trait methods cannot take patterns as arguments.
2+
3+
Traits cannot control the way in which implementations take arguments, only the
4+
types of those arguments. A pattern here has no effect, because the
5+
implementation can bind its arguments however it would like.
26

37
Erroneous code example:
48

@@ -16,3 +20,9 @@ trait Foo {
1620
fn foo(x_and_y: (i32, i32)); // ok!
1721
}
1822
```
23+
24+
And you can use patterns in its implementations:
25+
26+
impl Foo for Bar {
27+
fn foo((x, y): (i32, i32)) { /* ... */ } // ok!
28+
}

0 commit comments

Comments
 (0)