librustc: Remove ptr::addr_of.
This commit is contained in:
parent
58791c2fd8
commit
b0522a497c
61 changed files with 276 additions and 300 deletions
|
|
@ -27,7 +27,7 @@ use core::io::WriterUtil;
|
|||
use core::comm::{Port, Chan, SharedChan};
|
||||
|
||||
macro_rules! move_out (
|
||||
{ $x:expr } => { unsafe { let y = *ptr::addr_of(&($x)); y } }
|
||||
{ $x:expr } => { unsafe { let y = *ptr::to_unsafe_ptr(&($x)); y } }
|
||||
)
|
||||
|
||||
enum request {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ use core::io::WriterUtil;
|
|||
use core::comm::{Port, PortSet, Chan, stream};
|
||||
|
||||
macro_rules! move_out (
|
||||
{ $x:expr } => { unsafe { let y = *ptr::addr_of(&($x)); y } }
|
||||
{ $x:expr } => { unsafe { let y = *ptr::to_unsafe_ptr(&($x)); y } }
|
||||
)
|
||||
|
||||
enum request {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ proto! ring (
|
|||
)
|
||||
|
||||
macro_rules! move_out (
|
||||
($x:expr) => { unsafe { let y = *ptr::addr_of(&$x); y } }
|
||||
($x:expr) => { unsafe { let y = *ptr::to_unsafe_ptr(&$x); y } }
|
||||
)
|
||||
|
||||
fn thread_ring(i: uint,
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ proto! pingpong_unbounded (
|
|||
|
||||
// This stuff should go in libcore::pipes
|
||||
macro_rules! move_it (
|
||||
{ $x:expr } => { let t = *ptr::addr_of(&($x)); t }
|
||||
{ $x:expr } => { let t = *ptr::to_unsafe_ptr(&($x)); t }
|
||||
)
|
||||
|
||||
macro_rules! follow (
|
||||
|
|
|
|||
|
|
@ -11,6 +11,6 @@
|
|||
enum bottom { }
|
||||
|
||||
fn main() {
|
||||
let x = ptr::addr_of(&()) as *bottom;
|
||||
let x = ptr::to_unsafe_ptr(&()) as *bottom;
|
||||
match x { } //~ ERROR non-exhaustive patterns
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
let x : *~[int] = ptr::addr_of(&~[1,2,3]);
|
||||
let x : *~[int] = &~[1,2,3];
|
||||
let y : *libc::c_void = x as *libc::c_void;
|
||||
unsafe {
|
||||
let _z = copy *y;
|
||||
|
|
|
|||
|
|
@ -107,8 +107,8 @@ fn test_class() {
|
|||
|
||||
unsafe {
|
||||
error!("q = %x, r = %x",
|
||||
(::core::cast::reinterpret_cast::<*p, uint>(&ptr::addr_of(&q))),
|
||||
(::core::cast::reinterpret_cast::<*p, uint>(&ptr::addr_of(&r))));
|
||||
(::core::cast::reinterpret_cast::<*p, uint>(& &q)),
|
||||
(::core::cast::reinterpret_cast::<*p, uint>(& &r)));
|
||||
}
|
||||
assert!((q == r));
|
||||
r.y = 17;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ fn borrow(x: &int, f: &fn(x: &int)) {
|
|||
|
||||
fn test1(x: @~int) {
|
||||
do borrow(&*(*x).clone()) |p| {
|
||||
let x_a = ptr::addr_of(&(**x));
|
||||
let x_a = ptr::to_unsafe_ptr(&**x);
|
||||
assert!((x_a as uint) != ptr::to_uint(p));
|
||||
assert!(unsafe{*x_a} == *p);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,13 +17,14 @@ pub fn main() {
|
|||
match x {
|
||||
@F {f: ref b_x} => {
|
||||
assert!(**b_x == 3);
|
||||
assert!(ptr::addr_of(&(*x.f)) == ptr::addr_of(&(**b_x)));
|
||||
assert!(ptr::to_unsafe_ptr(&(*x.f)) == ptr::to_unsafe_ptr(&(**b_x)));
|
||||
|
||||
x = @F {f: ~4};
|
||||
|
||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(&(**b_x)) as uint);
|
||||
debug!("ptr::to_unsafe_ptr(*b_x) = %x",
|
||||
ptr::to_unsafe_ptr(&(**b_x)) as uint);
|
||||
assert!(**b_x == 3);
|
||||
assert!(ptr::addr_of(&(*x.f)) != ptr::addr_of(&(**b_x)));
|
||||
assert!(ptr::to_unsafe_ptr(&(*x.f)) != ptr::to_unsafe_ptr(&(**b_x)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,11 +23,12 @@ pub fn main() {
|
|||
let mut x = @F {f: ~3};
|
||||
do borrow(x.f) |b_x| {
|
||||
assert!(*b_x == 3);
|
||||
assert!(ptr::addr_of(&(*x.f)) == ptr::addr_of(&(*b_x)));
|
||||
assert!(ptr::to_unsafe_ptr(&(*x.f)) == ptr::to_unsafe_ptr(&(*b_x)));
|
||||
x = @F {f: ~4};
|
||||
|
||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(&(*b_x)) as uint);
|
||||
debug!("ptr::to_unsafe_ptr(*b_x) = %x",
|
||||
ptr::to_unsafe_ptr(&(*b_x)) as uint);
|
||||
assert!(*b_x == 3);
|
||||
assert!(ptr::addr_of(&(*x.f)) != ptr::addr_of(&(*b_x)));
|
||||
assert!(ptr::to_unsafe_ptr(&(*x.f)) != ptr::to_unsafe_ptr(&(*b_x)));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,13 +17,14 @@ pub fn main() {
|
|||
match x {
|
||||
@@F{f: ref b_x} => {
|
||||
assert!(**b_x == 3);
|
||||
assert!(ptr::addr_of(&(x.f)) == ptr::addr_of(b_x));
|
||||
assert!(ptr::to_unsafe_ptr(&(x.f)) == ptr::to_unsafe_ptr(b_x));
|
||||
|
||||
*x = @F {f: ~4};
|
||||
|
||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(&(**b_x)) as uint);
|
||||
debug!("ptr::to_unsafe_ptr(*b_x) = %x",
|
||||
ptr::to_unsafe_ptr(&(**b_x)) as uint);
|
||||
assert!(**b_x == 3);
|
||||
assert!(ptr::addr_of(&(*x.f)) != ptr::addr_of(&(**b_x)));
|
||||
assert!(ptr::to_unsafe_ptr(&(*x.f)) != ptr::to_unsafe_ptr(&(**b_x)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,11 +23,12 @@ pub fn main() {
|
|||
let mut x = ~@F{f: ~3};
|
||||
do borrow(x.f) |b_x| {
|
||||
assert!(*b_x == 3);
|
||||
assert!(ptr::addr_of(&(*x.f)) == ptr::addr_of(&(*b_x)));
|
||||
assert!(ptr::to_unsafe_ptr(&(*x.f)) == ptr::to_unsafe_ptr(&(*b_x)));
|
||||
*x = @F{f: ~4};
|
||||
|
||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(&(*b_x)) as uint);
|
||||
debug!("ptr::to_unsafe_ptr(*b_x) = %x",
|
||||
ptr::to_unsafe_ptr(&(*b_x)) as uint);
|
||||
assert!(*b_x == 3);
|
||||
assert!(ptr::addr_of(&(*x.f)) != ptr::addr_of(&(*b_x)));
|
||||
assert!(ptr::to_unsafe_ptr(&(*x.f)) != ptr::to_unsafe_ptr(&(*b_x)));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,11 +21,12 @@ pub fn main() {
|
|||
let mut x = @3;
|
||||
do borrow(x) |b_x| {
|
||||
assert!(*b_x == 3);
|
||||
assert!(ptr::addr_of(&(*x)) == ptr::addr_of(&(*b_x)));
|
||||
assert!(ptr::to_unsafe_ptr(&(*x)) == ptr::to_unsafe_ptr(&(*b_x)));
|
||||
x = @22;
|
||||
|
||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(&(*b_x)) as uint);
|
||||
debug!("ptr::to_unsafe_ptr(*b_x) = %x",
|
||||
ptr::to_unsafe_ptr(&(*b_x)) as uint);
|
||||
assert!(*b_x == 3);
|
||||
assert!(ptr::addr_of(&(*x)) != ptr::addr_of(&(*b_x)));
|
||||
assert!(ptr::to_unsafe_ptr(&(*x)) != ptr::to_unsafe_ptr(&(*b_x)));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,11 +23,12 @@ pub fn main() {
|
|||
let mut x = @F {f: ~3};
|
||||
do borrow((*x).f) |b_x| {
|
||||
assert!(*b_x == 3);
|
||||
assert!(ptr::addr_of(&(*x.f)) == ptr::addr_of(&(*b_x)));
|
||||
assert!(ptr::to_unsafe_ptr(&(*x.f)) == ptr::to_unsafe_ptr(&(*b_x)));
|
||||
x = @F {f: ~4};
|
||||
|
||||
debug!("ptr::addr_of(*b_x) = %x", ptr::addr_of(&(*b_x)) as uint);
|
||||
debug!("ptr::to_unsafe_ptr(*b_x) = %x",
|
||||
ptr::to_unsafe_ptr(&(*b_x)) as uint);
|
||||
assert!(*b_x == 3);
|
||||
assert!(ptr::addr_of(&(*x.f)) != ptr::addr_of(&(*b_x)));
|
||||
assert!(ptr::to_unsafe_ptr(&(*x.f)) != ptr::to_unsafe_ptr(&(*b_x)));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,22 +10,22 @@
|
|||
|
||||
pub fn main() {
|
||||
let x = ~1;
|
||||
let y = ptr::addr_of(&(*x)) as uint;
|
||||
let lam_move: @fn() -> uint = || ptr::addr_of(&(*x)) as uint;
|
||||
let y = ptr::to_unsafe_ptr(&(*x)) as uint;
|
||||
let lam_move: @fn() -> uint = || ptr::to_unsafe_ptr(&(*x)) as uint;
|
||||
assert!(lam_move() == y);
|
||||
|
||||
let x = ~2;
|
||||
let y = ptr::addr_of(&(*x)) as uint;
|
||||
let lam_move: @fn() -> uint = || ptr::addr_of(&(*x)) as uint;
|
||||
let y = ptr::to_unsafe_ptr(&(*x)) as uint;
|
||||
let lam_move: @fn() -> uint = || ptr::to_unsafe_ptr(&(*x)) as uint;
|
||||
assert!(lam_move() == y);
|
||||
|
||||
let x = ~3;
|
||||
let y = ptr::addr_of(&(*x)) as uint;
|
||||
let snd_move: ~fn() -> uint = || ptr::addr_of(&(*x)) as uint;
|
||||
let y = ptr::to_unsafe_ptr(&(*x)) as uint;
|
||||
let snd_move: ~fn() -> uint = || ptr::to_unsafe_ptr(&(*x)) as uint;
|
||||
assert!(snd_move() == y);
|
||||
|
||||
let x = ~4;
|
||||
let y = ptr::addr_of(&(*x)) as uint;
|
||||
let lam_move: ~fn() -> uint = || ptr::addr_of(&(*x)) as uint;
|
||||
let y = ptr::to_unsafe_ptr(&(*x)) as uint;
|
||||
let lam_move: ~fn() -> uint = || ptr::to_unsafe_ptr(&(*x)) as uint;
|
||||
assert!(lam_move() == y);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,5 +14,5 @@ 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!(ptr::addr_of(x) == ptr::addr_of(y.b));
|
||||
assert!(ptr::to_unsafe_ptr(x) == ptr::to_unsafe_ptr(y.b));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,12 +9,12 @@
|
|||
// except according to those terms.
|
||||
|
||||
fn addr_of<T>(ptr: &T) -> uint {
|
||||
let ptr = ptr::addr_of(ptr);
|
||||
let ptr = ptr::to_unsafe_ptr(ptr);
|
||||
unsafe { ptr as uint }
|
||||
}
|
||||
|
||||
fn is_aligned<T>(ptr: &T) -> bool {
|
||||
(addr_of(ptr) % sys::min_align_of::<T>()) == 0
|
||||
(to_unsafe_ptr(ptr) % sys::min_align_of::<T>()) == 0
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
|
|
|
|||
|
|
@ -232,7 +232,7 @@ pub mod pingpong {
|
|||
pub fn liberate_ping(+p: ping) -> ::pipes::send_packet<pong> {
|
||||
unsafe {
|
||||
let addr : *::pipes::send_packet<pong> = match &p {
|
||||
&ping(ref x) => { cast::transmute(ptr::addr_of(x)) }
|
||||
&ping(ref x) => { cast::transmute(x) }
|
||||
};
|
||||
let liberated_value = *addr;
|
||||
cast::forget(p);
|
||||
|
|
@ -243,7 +243,7 @@ pub mod pingpong {
|
|||
pub fn liberate_pong(+p: pong) -> ::pipes::send_packet<ping> {
|
||||
unsafe {
|
||||
let addr : *::pipes::send_packet<ping> = match &p {
|
||||
&pong(ref x) => { cast::transmute(ptr::addr_of(x)) }
|
||||
&pong(ref x) => { cast::transmute(x) }
|
||||
};
|
||||
let liberated_value = *addr;
|
||||
cast::forget(p);
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ proto! bank (
|
|||
)
|
||||
|
||||
macro_rules! move_it (
|
||||
{ $x:expr } => { unsafe { let y = *ptr::addr_of(&($x)); y } }
|
||||
{ $x:expr } => { unsafe { let y = *ptr::to_unsafe_ptr(&($x)); y } }
|
||||
)
|
||||
|
||||
fn switch<T:Owned,U>(+endp: pipes::RecvPacket<T>,
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ mod pingpong {
|
|||
do pipes::entangle_buffer(buffer) |buffer, data| {
|
||||
data.ping.set_buffer(buffer);
|
||||
data.pong.set_buffer(buffer);
|
||||
ptr::addr_of(&(data.ping))
|
||||
ptr::to_unsafe_ptr(&(data.ping))
|
||||
}
|
||||
}
|
||||
pub struct ping(server::pong);
|
||||
|
|
@ -53,8 +53,8 @@ mod pingpong {
|
|||
pub fn ping(+pipe: ping) -> pong {
|
||||
{
|
||||
let b = pipe.reuse_buffer();
|
||||
let s = SendPacketBuffered(ptr::addr_of(&(b.buffer.data.pong)));
|
||||
let c = RecvPacketBuffered(ptr::addr_of(&(b.buffer.data.pong)));
|
||||
let s = SendPacketBuffered(&b.buffer.data.pong);
|
||||
let c = RecvPacketBuffered(&b.buffer.data.pong);
|
||||
let message = ::pingpong::ping(s);
|
||||
send(pipe, message);
|
||||
c
|
||||
|
|
@ -75,8 +75,8 @@ mod pingpong {
|
|||
pub fn pong(+pipe: pong) -> ping {
|
||||
{
|
||||
let b = pipe.reuse_buffer();
|
||||
let s = SendPacketBuffered(ptr::addr_of(&(b.buffer.data.ping)));
|
||||
let c = RecvPacketBuffered(ptr::addr_of(&(b.buffer.data.ping)));
|
||||
let s = SendPacketBuffered(&b.buffer.data.ping);
|
||||
let c = RecvPacketBuffered(&b.buffer.data.ping);
|
||||
let message = ::pingpong::pong(s);
|
||||
send(pipe, message);
|
||||
c
|
||||
|
|
|
|||
|
|
@ -642,7 +642,7 @@ struct Triple { x: int, y: int, z: int }
|
|||
pub fn main() {
|
||||
unsafe {
|
||||
let r = (1,2,3,true,false, Triple {x:5,y:4,z:3}, (12,));
|
||||
let p = ptr::addr_of(&r) as *c_void;
|
||||
let p = ptr::to_unsafe_ptr(&r) as *c_void;
|
||||
let u = my_visitor(@mut Stuff {ptr1: p,
|
||||
ptr2: p,
|
||||
vals: ~[]});
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ impl Drop for r {
|
|||
fn finalize(&self) {
|
||||
unsafe {
|
||||
debug!("r's dtor: self = %x, self.v = %x, self.v's value = %x",
|
||||
cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(self)),
|
||||
cast::reinterpret_cast::<**int, uint>(&ptr::addr_of(&(self.v))),
|
||||
cast::reinterpret_cast::<*r, uint>(&self),
|
||||
cast::reinterpret_cast::<**int, uint>(& &(self.v)),
|
||||
cast::reinterpret_cast::<*int, uint>(&self.v));
|
||||
let v2: ~int = cast::reinterpret_cast(&self.v);
|
||||
}
|
||||
|
|
@ -54,28 +54,26 @@ pub fn main() {
|
|||
next: None,
|
||||
r: {
|
||||
let rs = r(i1p);
|
||||
debug!("r = %x",
|
||||
cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(&rs)));
|
||||
debug!("r = %x", cast::reinterpret_cast::<*r, uint>(& &rs));
|
||||
rs }
|
||||
});
|
||||
|
||||
debug!("x1 = %x, x1.r = %x",
|
||||
cast::reinterpret_cast::<@mut t, uint>(&x1),
|
||||
cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(&(x1.r))));
|
||||
cast::reinterpret_cast::<*r, uint>(& &(x1.r)));
|
||||
|
||||
let mut x2 = @mut t(Node{
|
||||
next: None,
|
||||
r: {
|
||||
let rs = r(i2p);
|
||||
debug!("r2 = %x",
|
||||
cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(&rs)));
|
||||
debug!("r2 = %x", cast::reinterpret_cast::<*r, uint>(& &rs));
|
||||
rs
|
||||
}
|
||||
});
|
||||
|
||||
debug!("x2 = %x, x2.r = %x",
|
||||
cast::reinterpret_cast::<@mut t, uint>(&x2),
|
||||
cast::reinterpret_cast::<*r, uint>(&ptr::addr_of(&(x2.r))));
|
||||
cast::reinterpret_cast::<*r, uint>(& &(x2.r)));
|
||||
|
||||
x1.next = Some(x2);
|
||||
x2.next = Some(x1);
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ pub fn main() {
|
|||
ch.send(());
|
||||
}
|
||||
};
|
||||
let fptr = cast::reinterpret_cast(&ptr::addr_of(&f));
|
||||
let fptr = cast::reinterpret_cast(& &f);
|
||||
rustrt::start_task(new_task_id, fptr);
|
||||
cast::forget(f);
|
||||
po.recv();
|
||||
|
|
|
|||
|
|
@ -12,5 +12,5 @@
|
|||
|
||||
pub fn main() {
|
||||
let foo = 1;
|
||||
assert!(ptr::addr_of(&foo) == ptr::addr_of(&foo));
|
||||
assert!(ptr::to_unsafe_ptr(&foo) == ptr::to_unsafe_ptr(&foo));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ fn mk_rec() -> t_rec {
|
|||
}
|
||||
|
||||
fn is_8_byte_aligned(&&u: a_tag<u64>) -> bool {
|
||||
let p = ptr::addr_of(u) as uint;
|
||||
let p = ptr::to_unsafe_ptr(u) as uint;
|
||||
return (p & 7u) == 0u;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ fn mk_rec<A:copy,B:copy>(a: A, b: B) -> t_rec<A,B> {
|
|||
}
|
||||
|
||||
fn is_aligned<A>(amnt: uint, &&u: A) -> bool {
|
||||
let p = ptr::addr_of(u) as uint;
|
||||
let p = ptr::to_unsafe_ptr(u) as uint;
|
||||
return (p & (amnt-1u)) == 0u;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ fn mk_rec() -> t_rec {
|
|||
}
|
||||
|
||||
fn is_8_byte_aligned(&&u: a_tag) -> bool {
|
||||
let p = ptr::addr_of(u) as u64;
|
||||
let p = ptr::to_unsafe_ptr(u) as u64;
|
||||
return (p & 7u64) == 0u64;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ impl Drop for notify {
|
|||
unsafe {
|
||||
error!("notify: task=%? v=%x unwinding=%b b=%b",
|
||||
task::get_task(),
|
||||
ptr::addr_of(&(*(self.v))) as uint,
|
||||
ptr::to_unsafe_ptr(&(*(self.v))) as uint,
|
||||
task::failing(),
|
||||
*(self.v));
|
||||
let b = *(self.v);
|
||||
|
|
@ -47,7 +47,7 @@ fn joinable(f: ~fn()) -> Port<bool> {
|
|||
let b = @mut false;
|
||||
error!("wrapper: task=%? allocated v=%x",
|
||||
task::get_task(),
|
||||
ptr::addr_of(&(*b)) as uint);
|
||||
ptr::to_unsafe_ptr(&(*b)) as uint);
|
||||
let _r = notify(c, b);
|
||||
f();
|
||||
*b = true;
|
||||
|
|
|
|||
|
|
@ -14,10 +14,10 @@ pub fn main() {
|
|||
let (p, ch) = stream::<uint>();
|
||||
|
||||
let x = ~1;
|
||||
let x_in_parent = ptr::addr_of(&(*x)) as uint;
|
||||
let x_in_parent = ptr::to_unsafe_ptr(&(*x)) as uint;
|
||||
|
||||
task::spawn(|| {
|
||||
let x_in_child = ptr::addr_of(&(*x)) as uint;
|
||||
let x_in_child = ptr::to_unsafe_ptr(&(*x)) as uint;
|
||||
ch.send(x_in_child);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ struct Pointy {
|
|||
}
|
||||
|
||||
fn make_uniq_closure<A:Owned + Copy>(a: A) -> ~fn() -> uint {
|
||||
let result: ~fn() -> uint = || ptr::addr_of(&a) as uint;
|
||||
let result: ~fn() -> uint = || ptr::to_unsafe_ptr(&a) as uint;
|
||||
result
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue