From 35309a200ba880b2c5203e16a115ab14d0088e12 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 1 Aug 2020 14:18:52 +0200 Subject: [PATCH 1/2] rustup; fix linked_list test --- rust-version | 2 +- tests/run-pass/linked-list.rs | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/rust-version b/rust-version index 0765203ccbc3..7c4b8a50cc28 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -21867225a74d3b07c2b65e32c67f45197db36896 +dfe1e3b641abbede6230e3931d14f0d43e5b8e54 diff --git a/tests/run-pass/linked-list.rs b/tests/run-pass/linked-list.rs index f1d21728b2f0..976a35da6061 100644 --- a/tests/run-pass/linked-list.rs +++ b/tests/run-pass/linked-list.rs @@ -1,4 +1,4 @@ -#![feature(linked_list_extras)] +#![feature(linked_list_cursors)] use std::collections::LinkedList; fn list_from(v: &[T]) -> LinkedList { @@ -9,25 +9,27 @@ 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); + let mut it = m.cursor_front_mut(); + it.insert_before(-2); loop { - match it.next() { + match it.current().copied() { 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), + Some(x) => assert_eq!(*x, elt + 2), + None => assert_eq!(8, elt), } + it.insert_after(elt + 1); + it.move_next(); // Move by 2 to skip the one we inserted. + it.move_next(); } } } - it.insert_next(0); - it.insert_next(1); + it.insert_before(99); + it.insert_after(-10); } 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]); + [-10, -2, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 99]); } From 5d221450690cc0a31da829563042762dff3139df Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 31 Jul 2020 19:28:59 +0200 Subject: [PATCH 2/2] test unwinding past topmost frame of a stack --- .../concurrency/unwind_top_of_stack.rs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/compile-fail/concurrency/unwind_top_of_stack.rs diff --git a/tests/compile-fail/concurrency/unwind_top_of_stack.rs b/tests/compile-fail/concurrency/unwind_top_of_stack.rs new file mode 100644 index 000000000000..93b15202fc38 --- /dev/null +++ b/tests/compile-fail/concurrency/unwind_top_of_stack.rs @@ -0,0 +1,24 @@ +// ignore-windows: Concurrency on Windows is not supported yet. +// error-pattern: unwinding past the topmost frame of the stack + +//! Unwinding past the top frame of a stack is Undefined Behavior. + +#![feature(rustc_private)] + +extern crate libc; + +use std::{mem, ptr}; + +extern "C" fn thread_start(_null: *mut libc::c_void) -> *mut libc::c_void { + panic!() +} + +fn main() { + unsafe { + let mut native: libc::pthread_t = mem::zeroed(); + let attr: libc::pthread_attr_t = mem::zeroed(); + // assert_eq!(libc::pthread_attr_init(&mut attr), 0); FIXME: this function is not yet implemented. + assert_eq!(libc::pthread_create(&mut native, &attr, thread_start, ptr::null_mut()), 0); + assert_eq!(libc::pthread_join(native, ptr::null_mut()), 0); + } +}