Skip to content

Commit

Permalink
Improve E0025 error explanation
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Aug 26, 2015
1 parent 612221f commit 5d8dc90
Showing 1 changed file with 33 additions and 4 deletions.
37 changes: 33 additions & 4 deletions src/librustc_typeck/diagnostics.rs
Expand Up @@ -73,10 +73,39 @@ the enum.
"##,

E0025: r##"
Each field of a struct can only be bound once in a pattern. Each occurrence of a
field name binds the value of that field, so to fix this error you will have to
remove or alter the duplicate uses of the field name. Perhaps you misspelt
another field name?
Each field of a struct can only be bound once in a pattern. Erroneous code
example:
```
struct Foo {
a: u8,
b: u8,
}
fn main(){
let x = Foo { a:1, b:2 };
let Foo { a: x, a: y } = x;
// error: field `a` bound multiple times in the pattern
}
```
Each occurrence of a field name binds the value of that field, so to fix this
error you will have to remove or alter the duplicate uses of the field name.
Perhaps you misspelled another field name? Example:
```
struct Foo {
a: u8,
b: u8,
}
fn main(){
let x = Foo { a:1, b:2 };
let Foo { a: x, b: y } = x; // ok!
}
```
"##,

E0026: r##"
Expand Down

0 comments on commit 5d8dc90

Please sign in to comment.