Skip to content

Commit 537cace

Browse files
---
yaml --- r: 232769 b: refs/heads/try c: 5d8dc90 h: refs/heads/master i: 232767: 1d772f6 v: v3
1 parent 19505e8 commit 537cace

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: edeb4f1c86cbf6af8ef9874d4b3af50f721ea1b8
33
refs/heads/snap-stage3: 1af31d4974e33027a68126fa5a5a3c2c6491824f
4-
refs/heads/try: 612221ff8035b21a343c73921334071346609eb9
4+
refs/heads/try: 5d8dc9076bf387398eeac9c50109a15026e22b36
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/src/librustc_typeck/diagnostics.rs

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,39 @@ the enum.
7373
"##,
7474

7575
E0025: r##"
76-
Each field of a struct can only be bound once in a pattern. Each occurrence of a
77-
field name binds the value of that field, so to fix this error you will have to
78-
remove or alter the duplicate uses of the field name. Perhaps you misspelt
79-
another field name?
76+
Each field of a struct can only be bound once in a pattern. Erroneous code
77+
example:
78+
79+
```
80+
struct Foo {
81+
a: u8,
82+
b: u8,
83+
}
84+
85+
fn main(){
86+
let x = Foo { a:1, b:2 };
87+
88+
let Foo { a: x, a: y } = x;
89+
// error: field `a` bound multiple times in the pattern
90+
}
91+
```
92+
93+
Each occurrence of a field name binds the value of that field, so to fix this
94+
error you will have to remove or alter the duplicate uses of the field name.
95+
Perhaps you misspelled another field name? Example:
96+
97+
```
98+
struct Foo {
99+
a: u8,
100+
b: u8,
101+
}
102+
103+
fn main(){
104+
let x = Foo { a:1, b:2 };
105+
106+
let Foo { a: x, b: y } = x; // ok!
107+
}
108+
```
80109
"##,
81110

82111
E0026: r##"

0 commit comments

Comments
 (0)