Skip to content

Commit 9b84689

Browse files
authored
Merge pull request #61 from SimonSapin/nll
Fix mutable aliasing uncovered by MIR borrow-checking
2 parents 3265e1f + b05704b commit 9b84689

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22

33
name = "getopts"
4-
version = "0.2.16"
4+
version = "0.2.17"
55
authors = ["The Rust Project Developers"]
66
license = "MIT/Apache-2.0"
77
readme = "README.md"

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -968,11 +968,11 @@ fn each_split_within<'a, F>(ss: &'a str, lim: usize, mut it: F)
968968
lim = fake_i;
969969
}
970970

971-
let mut machine = |cont: &mut bool, (i, c): (usize, char)| {
971+
let mut machine = |cont: &mut bool, state: &mut SplitWithinState, (i, c): (usize, char)| {
972972
let whitespace = if c.is_whitespace() { Ws } else { Cr };
973973
let limit = if (i - slice_start + 1) <= lim { UnderLim } else { OverLim };
974974

975-
state = match (state, whitespace, limit) {
975+
*state = match (*state, whitespace, limit) {
976976
(A, Ws, _) => { A }
977977
(A, Cr, _) => { slice_start = i; last_start = i; B }
978978

@@ -1020,11 +1020,11 @@ fn each_split_within<'a, F>(ss: &'a str, lim: usize, mut it: F)
10201020
*cont
10211021
};
10221022

1023-
ss.char_indices().all(|x| machine(&mut cont, x));
1023+
ss.char_indices().all(|x| machine(&mut cont, &mut state, x));
10241024

10251025
// Let the automaton 'run out' by supplying trailing whitespace
10261026
while cont && match state { B | C => true, A => false } {
1027-
machine(&mut cont, (fake_i, ' '));
1027+
machine(&mut cont, &mut state, (fake_i, ' '));
10281028
fake_i += 1;
10291029
}
10301030
return cont;

0 commit comments

Comments
 (0)