Skip to content

Commit 96b2225

Browse files
authored
Merge pull request #697 from RalfJung/linked-list
add LinkedList test and mention the bug Miri found there
2 parents 4376b9a + 791abb7 commit 96b2225

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ Miri has already found a number of bugs in the Rust standard library, which we c
297297
* [Futures turning a shared reference into a mutable one](https://github.com/rust-lang/rust/pull/56319)
298298
* [`str` turning a shared reference into a mutable one](https://github.com/rust-lang/rust/pull/58200)
299299
* [`BTreeMap` creating mutable references that overlap with shared references](https://github.com/rust-lang/rust/pull/58431)
300+
* [`LinkedList` creating overlapping mutable references](https://github.com/rust-lang/rust/pull/60072)
300301

301302
## License
302303

rust-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
efe2f32a6b8217425f361ec7c206910c611c03ee
1+
130dc3e7dac132cf30272ccf4541b512828e2108

tests/run-pass/linked-list.rs

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#![feature(linked_list_extras)]
2+
use std::collections::LinkedList;
3+
4+
fn list_from<T: Clone>(v: &[T]) -> LinkedList<T> {
5+
v.iter().cloned().collect()
6+
}
7+
8+
fn main() {
9+
let mut m = list_from(&[0, 2, 4, 6, 8]);
10+
let len = m.len();
11+
{
12+
let mut it = m.iter_mut();
13+
it.insert_next(-2);
14+
loop {
15+
match it.next() {
16+
None => break,
17+
Some(elt) => {
18+
it.insert_next(*elt + 1);
19+
match it.peek_next() {
20+
Some(x) => assert_eq!(*x, *elt + 2),
21+
None => assert_eq!(8, *elt),
22+
}
23+
}
24+
}
25+
}
26+
it.insert_next(0);
27+
it.insert_next(1);
28+
}
29+
30+
assert_eq!(m.len(), 3 + len * 2);
31+
assert_eq!(m.into_iter().collect::<Vec<_>>(),
32+
[-2, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1]);
33+
}

0 commit comments

Comments
 (0)