Skip to content

Commit

Permalink
Rollup merge of rust-lang#24482 - GuillaumeGomez:error-explanation, r…
Browse files Browse the repository at this point in the history
…=alexcrichton

 Part of rust-lang#24407.
  • Loading branch information
Manishearth committed Apr 17, 2015
2 parents fb88cca + 9a15234 commit 2580f08
Showing 1 changed file with 47 additions and 1 deletion.
48 changes: 47 additions & 1 deletion src/librustc/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,53 @@ reference when using guards or refactor the entire expression, perhaps by
putting the condition inside the body of the arm.
"##,

E0009: r##"
In a pattern, all values that don't implement the `Copy` trait have to be bound
the same way. The goal here is to avoid binding simultaneous by-move and by-ref.
This limitation may be removed in a future version of Rust.
Wrong example:
```
struct X { x: (), }
let x = Some((X { x: () }, X { x: () }));
match x {
Some((y, ref z)) => {},
None => panic!()
}
```
You have two solutions:
1. Bind the pattern's values the same way:
```
struct X { x: (), }
let x = Some((X { x: () }, X { x: () }));
match x {
Some((ref y, ref z)) => {},
// or Some((y, z)) => {}
None => panic!()
}
```
2. Implement the `Copy` trait for the X structure (however, please
keep in mind that the first solution should be preferred!):
```
#[derive(Clone, Copy)]
struct X { x: (), }
let x = Some((X { x: () }, X { x: () }));
match x {
Some((y, ref z)) => {},
None => panic!()
}
```
"##,

E0162: r##"
An if-let pattern attempts to match the pattern, and enters the body if the
match was succesful. If the match is irrefutable (when it cannot fail to match),
Expand Down Expand Up @@ -278,7 +325,6 @@ See also https://github.com/rust-lang/rust/issues/14587
}

register_diagnostics! {
E0009,
E0010,
E0011,
E0012,
Expand Down

0 comments on commit 2580f08

Please sign in to comment.