Closed
Description
match_same_arms
will not consider the order of match arms.
Since it is specified that arms are checked in order, this leads to suggestions with two potential problems:
- less optimal performance, when expensive arm conditions are checked too early
- changes in semantics
Example for the latter:
fn main() {
let x = match 2 {
1 ... 3 => false,
0 ... 5 => true,
_ => false
};
}
If this seems bad anyway because of overlap, consider the slightly more complex
fn main() {
let y = 1;
let x = match 2 {
1 ... 3 => false,
0 ... 5 if y == 2 => true,
_ => false
};
}
Metadata
Metadata
Assignees
Labels
No labels