From 677bd6f65646a6610ec2e3d11b203392477e3dd8 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 18 Apr 2019 11:54:21 +0200 Subject: [PATCH 1/2] add LinkedList test and mention the bug Miri found there --- README.md | 1 + tests/run-pass/linked-list.rs | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 tests/run-pass/linked-list.rs diff --git a/README.md b/README.md index 716c26c03a..464c1c33c2 100644 --- a/README.md +++ b/README.md @@ -297,6 +297,7 @@ Miri has already found a number of bugs in the Rust standard library, which we c * [Futures turning a shared reference into a mutable one](https://github.com/rust-lang/rust/pull/56319) * [`str` turning a shared reference into a mutable one](https://github.com/rust-lang/rust/pull/58200) * [`BTreeMap` creating mutable references that overlap with shared references](https://github.com/rust-lang/rust/pull/58431) +* [`LinkedList` creating overlapping mutable references](https://github.com/rust-lang/rust/pull/60072) ## License diff --git a/tests/run-pass/linked-list.rs b/tests/run-pass/linked-list.rs new file mode 100644 index 0000000000..f1d21728b2 --- /dev/null +++ b/tests/run-pass/linked-list.rs @@ -0,0 +1,33 @@ +#![feature(linked_list_extras)] +use std::collections::LinkedList; + +fn list_from(v: &[T]) -> LinkedList { + v.iter().cloned().collect() +} + +fn main() { + let mut m = list_from(&[0, 2, 4, 6, 8]); + let len = m.len(); + { + let mut it = m.iter_mut(); + it.insert_next(-2); + loop { + match it.next() { + None => break, + Some(elt) => { + it.insert_next(*elt + 1); + match it.peek_next() { + Some(x) => assert_eq!(*x, *elt + 2), + None => assert_eq!(8, *elt), + } + } + } + } + it.insert_next(0); + it.insert_next(1); + } + + assert_eq!(m.len(), 3 + len * 2); + assert_eq!(m.into_iter().collect::>(), + [-2, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1]); +} From 791abb7a7e87c1ab20616d37184b661acc425753 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 19 Apr 2019 23:08:35 +0200 Subject: [PATCH 2/2] bump Rust version --- rust-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-version b/rust-version index 40e42e6886..f0c4e551b3 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -efe2f32a6b8217425f361ec7c206910c611c03ee +130dc3e7dac132cf30272ccf4541b512828e2108