diff options
| author | Corey Richardson <corey@octayn.net> | 2014-02-14 18:42:01 -0500 |
|---|---|---|
| committer | Corey Richardson <corey@octayn.net> | 2014-02-15 12:11:41 -0500 |
| commit | 49e11630fa84eefc27a34c39ad28a9afb515c5a1 (patch) | |
| tree | ed7700d5a4ccb1666fc975bc5962a32737f90836 /src/test | |
| parent | 3496e93d13590140242f862c905dc2d591d2e2ea (diff) | |
std: clean up ptr a bit
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/compile-fail/issue-3096-2.rs | 4 | ||||
| -rw-r--r-- | src/test/run-pass/borrowck-borrow-from-expr-block.rs | 4 | ||||
| -rw-r--r-- | src/test/run-pass/borrowck-preserve-box-in-field.rs | 9 | ||||
| -rw-r--r-- | src/test/run-pass/borrowck-preserve-box-in-uniq.rs | 9 | ||||
| -rw-r--r-- | src/test/run-pass/borrowck-preserve-box.rs | 9 | ||||
| -rw-r--r-- | src/test/run-pass/borrowck-preserve-expl-deref.rs | 9 | ||||
| -rw-r--r-- | src/test/run-pass/cap-clause-move.rs | 23 | ||||
| -rw-r--r-- | src/test/run-pass/const-region-ptrs-noncopy.rs | 4 | ||||
| -rw-r--r-- | src/test/run-pass/enum-alignment.rs | 4 | ||||
| -rw-r--r-- | src/test/run-pass/stable-addr-of.rs | 4 | ||||
| -rw-r--r-- | src/test/run-pass/swap-overlapping.rs | 2 | ||||
| -rw-r--r-- | src/test/run-pass/task-spawn-move-and-copy.rs | 5 | ||||
| -rw-r--r-- | src/test/run-pass/uniq-cc-generic.rs | 3 |
13 files changed, 21 insertions, 68 deletions
diff --git a/src/test/compile-fail/issue-3096-2.rs b/src/test/compile-fail/issue-3096-2.rs index 5f3af865454..799f5b4d532 100644 --- a/src/test/compile-fail/issue-3096-2.rs +++ b/src/test/compile-fail/issue-3096-2.rs @@ -8,11 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::ptr; - enum bottom { } fn main() { - let x = ptr::to_unsafe_ptr(&()) as *bottom; + let x = &() as *() as *bottom; match x { } //~ ERROR non-exhaustive patterns } diff --git a/src/test/run-pass/borrowck-borrow-from-expr-block.rs b/src/test/run-pass/borrowck-borrow-from-expr-block.rs index fe1be6d06db..4aedb4e96cf 100644 --- a/src/test/run-pass/borrowck-borrow-from-expr-block.rs +++ b/src/test/run-pass/borrowck-borrow-from-expr-block.rs @@ -10,15 +10,13 @@ #[feature(managed_boxes)]; -use std::ptr; - fn borrow(x: &int, f: |x: &int|) { f(x) } fn test1(x: @~int) { borrow(&*(*x).clone(), |p| { - let x_a = ptr::to_unsafe_ptr(&**x); + let x_a = &**x as *int; assert!((x_a as uint) != (p as *int as uint)); assert_eq!(unsafe{*x_a}, *p); }) diff --git a/src/test/run-pass/borrowck-preserve-box-in-field.rs b/src/test/run-pass/borrowck-preserve-box-in-field.rs index e789727c4fe..5cdda81c436 100644 --- a/src/test/run-pass/borrowck-preserve-box-in-field.rs +++ b/src/test/run-pass/borrowck-preserve-box-in-field.rs @@ -14,8 +14,6 @@ #[feature(managed_boxes)]; -use std::ptr; - fn borrow(x: &int, f: |x: &int|) { let before = *x; f(x); @@ -29,12 +27,11 @@ pub fn main() { let mut x = @F {f: ~3}; borrow(x.f, |b_x| { assert_eq!(*b_x, 3); - assert_eq!(ptr::to_unsafe_ptr(&(*x.f)), ptr::to_unsafe_ptr(&(*b_x))); + assert_eq!(&(*x.f) as *int, &(*b_x) as *int); x = @F {f: ~4}; - info!("ptr::to_unsafe_ptr(*b_x) = {:x}", - ptr::to_unsafe_ptr(&(*b_x)) as uint); + info!("&*b_x = {:p}", &(*b_x)); assert_eq!(*b_x, 3); - assert!(ptr::to_unsafe_ptr(&(*x.f)) != ptr::to_unsafe_ptr(&(*b_x))); + assert!(&(*x.f) as *int != &(*b_x) as *int); }) } diff --git a/src/test/run-pass/borrowck-preserve-box-in-uniq.rs b/src/test/run-pass/borrowck-preserve-box-in-uniq.rs index 8ac654ffbdd..3050d6fa011 100644 --- a/src/test/run-pass/borrowck-preserve-box-in-uniq.rs +++ b/src/test/run-pass/borrowck-preserve-box-in-uniq.rs @@ -14,8 +14,6 @@ #[feature(managed_boxes)]; -use std::ptr; - fn borrow(x: &int, f: |x: &int|) { let before = *x; f(x); @@ -29,12 +27,11 @@ pub fn main() { let mut x = ~@F{f: ~3}; borrow(x.f, |b_x| { assert_eq!(*b_x, 3); - assert_eq!(ptr::to_unsafe_ptr(&(*x.f)), ptr::to_unsafe_ptr(&(*b_x))); + assert_eq!(&(*x.f) as *int, &(*b_x) as *int); *x = @F{f: ~4}; - info!("ptr::to_unsafe_ptr(*b_x) = {:x}", - ptr::to_unsafe_ptr(&(*b_x)) as uint); + info!("&*b_x = {:p}", &(*b_x)); assert_eq!(*b_x, 3); - assert!(ptr::to_unsafe_ptr(&(*x.f)) != ptr::to_unsafe_ptr(&(*b_x))); + assert!(&(*x.f) as *int != &(*b_x) as *int); }) } diff --git a/src/test/run-pass/borrowck-preserve-box.rs b/src/test/run-pass/borrowck-preserve-box.rs index 9ce8daa966c..76dfbffc09c 100644 --- a/src/test/run-pass/borrowck-preserve-box.rs +++ b/src/test/run-pass/borrowck-preserve-box.rs @@ -14,8 +14,6 @@ #[feature(managed_boxes)]; -use std::ptr; - fn borrow(x: &int, f: |x: &int|) { let before = *x; f(x); @@ -27,12 +25,11 @@ pub fn main() { let mut x = @3; borrow(x, |b_x| { assert_eq!(*b_x, 3); - assert_eq!(ptr::to_unsafe_ptr(&(*x)), ptr::to_unsafe_ptr(&(*b_x))); + assert_eq!(&(*x) as *int, &(*b_x) as *int); x = @22; - info!("ptr::to_unsafe_ptr(*b_x) = {:x}", - ptr::to_unsafe_ptr(&(*b_x)) as uint); + info!("&*b_x = {:p}", &(*b_x)); assert_eq!(*b_x, 3); - assert!(ptr::to_unsafe_ptr(&(*x)) != ptr::to_unsafe_ptr(&(*b_x))); + assert!(&(*x) as *int != &(*b_x) as *int); }) } diff --git a/src/test/run-pass/borrowck-preserve-expl-deref.rs b/src/test/run-pass/borrowck-preserve-expl-deref.rs index 065ef1dd423..00e59f5132d 100644 --- a/src/test/run-pass/borrowck-preserve-expl-deref.rs +++ b/src/test/run-pass/borrowck-preserve-expl-deref.rs @@ -14,8 +14,6 @@ #[feature(managed_boxes)]; -use std::ptr; - fn borrow(x: &int, f: |x: &int|) { let before = *x; f(x); @@ -29,12 +27,11 @@ pub fn main() { let mut x = @F {f: ~3}; borrow((*x).f, |b_x| { assert_eq!(*b_x, 3); - assert_eq!(ptr::to_unsafe_ptr(&(*x.f)), ptr::to_unsafe_ptr(&(*b_x))); + assert_eq!(&(*x.f) as *int, &(*b_x) as *int); x = @F {f: ~4}; - info!("ptr::to_unsafe_ptr(*b_x) = {:x}", - ptr::to_unsafe_ptr(&(*b_x)) as uint); + info!("&*b_x = {:p}", &(*b_x)); assert_eq!(*b_x, 3); - assert!(ptr::to_unsafe_ptr(&(*x.f)) != ptr::to_unsafe_ptr(&(*b_x))); + assert!(&(*x.f) as *int != &(*b_x) as *int); }) } diff --git a/src/test/run-pass/cap-clause-move.rs b/src/test/run-pass/cap-clause-move.rs deleted file mode 100644 index 1fa78628d8a..00000000000 --- a/src/test/run-pass/cap-clause-move.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::ptr; - -pub fn main() { - let x = ~3; - let y = ptr::to_unsafe_ptr(&(*x)) as uint; - let snd_move: proc() -> uint = proc() ptr::to_unsafe_ptr(&(*x)) as uint; - assert_eq!(snd_move(), y); - - let x = ~4; - let y = ptr::to_unsafe_ptr(&(*x)) as uint; - let lam_move: proc() -> uint = proc() ptr::to_unsafe_ptr(&(*x)) as uint; - assert_eq!(lam_move(), y); -} diff --git a/src/test/run-pass/const-region-ptrs-noncopy.rs b/src/test/run-pass/const-region-ptrs-noncopy.rs index 6dce262dd9a..87363c0e55e 100644 --- a/src/test/run-pass/const-region-ptrs-noncopy.rs +++ b/src/test/run-pass/const-region-ptrs-noncopy.rs @@ -8,13 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::ptr; - type Big = [u64, ..8]; struct Pair<'a> { a: int, b: &'a Big } static x: &'static Big = &([13, 14, 10, 13, 11, 14, 14, 15]); static y: &'static Pair<'static> = &Pair {a: 15, b: x}; pub fn main() { - assert_eq!(ptr::to_unsafe_ptr(x), ptr::to_unsafe_ptr(y.b)); + assert_eq!(x as *Big, y.b as *Big); } diff --git a/src/test/run-pass/enum-alignment.rs b/src/test/run-pass/enum-alignment.rs index 3c8dd33ae9c..5763c613798 100644 --- a/src/test/run-pass/enum-alignment.rs +++ b/src/test/run-pass/enum-alignment.rs @@ -9,12 +9,10 @@ // except according to those terms. use std::cast; -use std::ptr; use std::mem; fn addr_of<T>(ptr: &T) -> uint { - let ptr = ptr::to_unsafe_ptr(ptr); - ptr as uint + ptr as *T as uint } fn is_aligned<T>(ptr: &T) -> bool { diff --git a/src/test/run-pass/stable-addr-of.rs b/src/test/run-pass/stable-addr-of.rs index dc68777e033..083d2e167a0 100644 --- a/src/test/run-pass/stable-addr-of.rs +++ b/src/test/run-pass/stable-addr-of.rs @@ -10,9 +10,7 @@ // Issue #2040 -use std::ptr; - pub fn main() { let foo = 1; - assert_eq!(ptr::to_unsafe_ptr(&foo), ptr::to_unsafe_ptr(&foo)); + assert_eq!(&foo as *int, &foo as *int); } diff --git a/src/test/run-pass/swap-overlapping.rs b/src/test/run-pass/swap-overlapping.rs index 42f3089a87a..d9cf585ad6c 100644 --- a/src/test/run-pass/swap-overlapping.rs +++ b/src/test/run-pass/swap-overlapping.rs @@ -25,7 +25,7 @@ pub fn main() { fn do_swap(test: &mut TestDescAndFn) { unsafe { - ptr::swap_ptr(test, test); + ptr::swap(test, test); } } diff --git a/src/test/run-pass/task-spawn-move-and-copy.rs b/src/test/run-pass/task-spawn-move-and-copy.rs index 1ed0c23fd7a..944c498ede3 100644 --- a/src/test/run-pass/task-spawn-move-and-copy.rs +++ b/src/test/run-pass/task-spawn-move-and-copy.rs @@ -8,17 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::ptr; use std::task; pub fn main() { let (p, ch) = Chan::<uint>::new(); let x = ~1; - let x_in_parent = ptr::to_unsafe_ptr(&(*x)) as uint; + let x_in_parent = &(*x) as *int as uint; task::spawn(proc() { - let x_in_child = ptr::to_unsafe_ptr(&(*x)) as uint; + let x_in_child = &(*x) as *int as uint; ch.send(x_in_child); }); diff --git a/src/test/run-pass/uniq-cc-generic.rs b/src/test/run-pass/uniq-cc-generic.rs index 53836a6e17d..9efa6c1b964 100644 --- a/src/test/run-pass/uniq-cc-generic.rs +++ b/src/test/run-pass/uniq-cc-generic.rs @@ -11,7 +11,6 @@ #[feature(managed_boxes)]; use std::cell::RefCell; -use std::ptr; enum maybe_pointy { none, @@ -24,7 +23,7 @@ struct Pointy { } fn make_uniq_closure<A:Send>(a: A) -> proc() -> uint { - let result: proc() -> uint = proc() ptr::to_unsafe_ptr(&a) as uint; + let result: proc() -> uint = proc() &a as *A as uint; result } |
