Auto merge of #1494 - RalfJung:stack-unwind-top, r=RalfJung
test unwinding past topmost frame of a stack This tests https://github.com/rust-lang/rust/pull/74984
This commit is contained in:
commit
8a28eaa3fc
3 changed files with 37 additions and 11 deletions
|
|
@ -1 +1 @@
|
|||
21867225a74d3b07c2b65e32c67f45197db36896
|
||||
dfe1e3b641abbede6230e3931d14f0d43e5b8e54
|
||||
|
|
|
|||
24
tests/compile-fail/concurrency/unwind_top_of_stack.rs
Normal file
24
tests/compile-fail/concurrency/unwind_top_of_stack.rs
Normal file
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(linked_list_extras)]
|
||||
#![feature(linked_list_cursors)]
|
||||
use std::collections::LinkedList;
|
||||
|
||||
fn list_from<T: Clone>(v: &[T]) -> LinkedList<T> {
|
||||
|
|
@ -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::<Vec<_>>(),
|
||||
[-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]);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue