core: clean up tests (mostly unused unsafe blocks)
This commit is contained in:
parent
c97bee2696
commit
98dfeb173f
6 changed files with 31 additions and 43 deletions
|
|
@ -112,8 +112,6 @@ pub mod streamp {
|
|||
|
||||
#[allow(non_camel_case_types)]
|
||||
pub mod server {
|
||||
priv use core::kinds::Owned;
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
pub type Open<T> = ::core::pipes::RecvPacket<super::Open<T>>;
|
||||
}
|
||||
|
|
@ -388,8 +386,6 @@ pub mod oneshot {
|
|||
|
||||
#[allow(non_camel_case_types)]
|
||||
pub mod server {
|
||||
priv use core::kinds::Owned;
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
pub type Oneshot<T> =
|
||||
::core::pipes::RecvPacketBuffered<super::Oneshot<T>,
|
||||
|
|
|
|||
|
|
@ -66,18 +66,16 @@ pub fn borrow(f: &fn(&mut Scheduler)) {
|
|||
/// Because this leaves the Scheduler in thread-local storage it is possible
|
||||
/// For the Scheduler pointer to be aliased
|
||||
pub unsafe fn unsafe_borrow() -> &mut Scheduler {
|
||||
unsafe {
|
||||
let key = tls_key();
|
||||
let mut void_sched: *mut c_void = tls::get(key);
|
||||
assert!(void_sched.is_not_null());
|
||||
{
|
||||
let void_sched_ptr = &mut void_sched;
|
||||
let sched: &mut ~Scheduler = {
|
||||
transmute::<&mut *mut c_void, &mut ~Scheduler>(void_sched_ptr)
|
||||
};
|
||||
let sched: &mut Scheduler = &mut **sched;
|
||||
return sched;
|
||||
}
|
||||
let key = tls_key();
|
||||
let mut void_sched: *mut c_void = tls::get(key);
|
||||
assert!(void_sched.is_not_null());
|
||||
{
|
||||
let void_sched_ptr = &mut void_sched;
|
||||
let sched: &mut ~Scheduler = {
|
||||
transmute::<&mut *mut c_void, &mut ~Scheduler>(void_sched_ptr)
|
||||
};
|
||||
let sched: &mut Scheduler = &mut **sched;
|
||||
return sched;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -388,7 +388,7 @@ fn connect_read() {
|
|||
vec_to_uv_buf(vec::from_elem(size, 0))
|
||||
};
|
||||
do stream_watcher.read_start(alloc)
|
||||
|stream_watcher, nread, buf, status| {
|
||||
|stream_watcher, _nread, buf, status| {
|
||||
|
||||
let buf = vec_from_uv_buf(buf);
|
||||
rtdebug!("read cb!");
|
||||
|
|
|
|||
|
|
@ -64,9 +64,7 @@ fn test_simple_deep() {
|
|||
if i == 0 { return }
|
||||
|
||||
for walk_stack |_frame| {
|
||||
unsafe {
|
||||
breakpoint();
|
||||
}
|
||||
breakpoint();
|
||||
}
|
||||
run(i - 1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3346,7 +3346,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_shift_byte() {
|
||||
let mut s = ~"ABC";
|
||||
let b = unsafe { raw::shift_byte(&mut s) };
|
||||
let b = raw::shift_byte(&mut s);
|
||||
assert!((s == ~"BC"));
|
||||
assert!((b == 65u8));
|
||||
}
|
||||
|
|
@ -3354,7 +3354,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_pop_byte() {
|
||||
let mut s = ~"ABC";
|
||||
let b = unsafe { raw::pop_byte(&mut s) };
|
||||
let b = raw::pop_byte(&mut s);
|
||||
assert!((s == ~"AB"));
|
||||
assert!((b == 67u8));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -150,32 +150,28 @@ fn test_tls_modify() {
|
|||
|
||||
#[test]
|
||||
fn test_tls_crust_automorestack_memorial_bug() {
|
||||
unsafe {
|
||||
// This might result in a stack-canary clobber if the runtime fails to
|
||||
// set sp_limit to 0 when calling the cleanup extern - it might
|
||||
// automatically jump over to the rust stack, which causes next_c_sp
|
||||
// to get recorded as something within a rust stack segment. Then a
|
||||
// subsequent upcall (esp. for logging, think vsnprintf) would run on
|
||||
// a stack smaller than 1 MB.
|
||||
fn my_key(_x: @~str) { }
|
||||
do task::spawn {
|
||||
unsafe { local_data_set(my_key, @~"hax"); }
|
||||
}
|
||||
// This might result in a stack-canary clobber if the runtime fails to
|
||||
// set sp_limit to 0 when calling the cleanup extern - it might
|
||||
// automatically jump over to the rust stack, which causes next_c_sp
|
||||
// to get recorded as something within a rust stack segment. Then a
|
||||
// subsequent upcall (esp. for logging, think vsnprintf) would run on
|
||||
// a stack smaller than 1 MB.
|
||||
fn my_key(_x: @~str) { }
|
||||
do task::spawn {
|
||||
unsafe { local_data_set(my_key, @~"hax"); }
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_tls_multiple_types() {
|
||||
unsafe {
|
||||
fn str_key(_x: @~str) { }
|
||||
fn box_key(_x: @@()) { }
|
||||
fn int_key(_x: @int) { }
|
||||
do task::spawn {
|
||||
unsafe {
|
||||
local_data_set(str_key, @~"string data");
|
||||
local_data_set(box_key, @@());
|
||||
local_data_set(int_key, @42);
|
||||
}
|
||||
fn str_key(_x: @~str) { }
|
||||
fn box_key(_x: @@()) { }
|
||||
fn int_key(_x: @int) { }
|
||||
do task::spawn {
|
||||
unsafe {
|
||||
local_data_set(str_key, @~"string data");
|
||||
local_data_set(box_key, @@());
|
||||
local_data_set(int_key, @42);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue