diff --git a/src/libcore/at_vec.rs b/src/libcore/at_vec.rs index 2c54ed7aaf3..6377c25b8c4 100644 --- a/src/libcore/at_vec.rs +++ b/src/libcore/at_vec.rs @@ -5,7 +5,7 @@ #[forbid(deprecated_pattern)]; use cast::transmute; -use ptr::addr_of; +use ptr::p2::addr_of; /// Code for dealing with @-vectors. This is pretty incomplete, and /// contains a bunch of duplication from the code for ~-vectors. @@ -29,7 +29,7 @@ extern mod rusti { pub pure fn capacity(v: @[const T]) -> uint { unsafe { let repr: **raw::VecRepr = - ::cast::reinterpret_cast(&addr_of(v)); + ::cast::reinterpret_cast(&addr_of(&v)); (**repr).unboxed.alloc / sys::size_of::() } } @@ -161,7 +161,7 @@ pub mod raw { */ #[inline(always)] pub unsafe fn set_len(v: @[const T], new_len: uint) { - let repr: **VecRepr = ::cast::reinterpret_cast(&addr_of(v)); + let repr: **VecRepr = ::cast::reinterpret_cast(&addr_of(&v)); (**repr).unboxed.fill = new_len * sys::size_of::(); } @@ -182,7 +182,7 @@ pub mod raw { let repr: **VecRepr = ::cast::reinterpret_cast(&v); let fill = (**repr).unboxed.fill; (**repr).unboxed.fill += sys::size_of::(); - let p = ptr::addr_of((**repr).unboxed.data); + let p = addr_of(&((**repr).unboxed.data)); let p = ptr::offset(p, fill) as *mut T; rusti::move_val_init(*p, move initval); } diff --git a/src/libcore/box.rs b/src/libcore/box.rs index 65a641d208f..43307b92664 100644 --- a/src/libcore/box.rs +++ b/src/libcore/box.rs @@ -24,7 +24,7 @@ pub mod raw { pub pure fn ptr_eq(a: @T, b: @T) -> bool { //! Determine if two shared boxes point to the same object - unsafe { ptr::addr_of(*a) == ptr::addr_of(*b) } + unsafe { ptr::p2::addr_of(&(*a)) == ptr::p2::addr_of(&(*b)) } } impl @const T : Eq { diff --git a/src/libcore/comm.rs b/src/libcore/comm.rs index a32d7af2ac6..37468aaaab6 100644 --- a/src/libcore/comm.rs +++ b/src/libcore/comm.rs @@ -38,8 +38,7 @@ will once again be the preferred module for intertask communication. use either::Either; use libc::size_t; - - +// After snapshot, change p2::addr_of => addr_of /** * A communication endpoint that can receive messages @@ -104,7 +103,7 @@ struct PortPtr { // Once the port is detached it's guaranteed not to receive further // messages let yield = 0; - let yieldp = ptr::addr_of(yield); + let yieldp = ptr::p2::addr_of(&yield); rustrt::rust_port_begin_detach(self.po, yieldp); if yield != 0 { // Need to wait for the port to be detached @@ -177,7 +176,7 @@ pub fn Chan(p: Port) -> Chan { */ pub fn send(ch: Chan, +data: T) { let Chan_(p) = ch; - let data_ptr = ptr::addr_of(data) as *(); + let data_ptr = ptr::p2::addr_of(&data) as *(); let res = rustrt::rust_port_id_send(p, data_ptr); if res != 0 unsafe { // Data sent successfully @@ -207,10 +206,10 @@ fn peek_chan(ch: comm::Chan) -> bool { /// Receive on a raw port pointer fn recv_(p: *rust_port) -> T { let yield = 0; - let yieldp = ptr::addr_of(yield); + let yieldp = ptr::p2::addr_of(&yield); let mut res; res = rusti::init::(); - rustrt::port_recv(ptr::addr_of(res) as *uint, p, yieldp); + rustrt::port_recv(ptr::p2::addr_of(&res) as *uint, p, yieldp); if yield != 0 { // Data isn't available yet, so res has not been initialized. @@ -234,12 +233,12 @@ fn peek_(p: *rust_port) -> bool { pub fn select2(p_a: Port, p_b: Port) -> Either { let ports = ~[(**p_a).po, (**p_b).po]; - let yield = 0, yieldp = ptr::addr_of(yield); + let yield = 0, yieldp = ptr::p2::addr_of(&yield); let mut resport: *rust_port; resport = rusti::init::<*rust_port>(); do vec::as_imm_buf(ports) |ports, n_ports| { - rustrt::rust_port_select(ptr::addr_of(resport), ports, + rustrt::rust_port_select(ptr::p2::addr_of(&resport), ports, n_ports as size_t, yieldp); } diff --git a/src/libcore/core.rc b/src/libcore/core.rc index 5a09c595bd6..5ea7004de6d 100644 --- a/src/libcore/core.rc +++ b/src/libcore/core.rc @@ -39,6 +39,7 @@ Implicitly, all crates behave as if they included the following prologue: #[legacy_modes]; #[legacy_exports]; +#[warn(deprecated_mode)]; #[warn(deprecated_pattern)]; #[warn(vecs_implicitly_copyable)]; diff --git a/src/libcore/gc.rs b/src/libcore/gc.rs index a60dbe5e03a..ace4156f5b4 100644 --- a/src/libcore/gc.rs +++ b/src/libcore/gc.rs @@ -316,7 +316,7 @@ pub fn cleanup_stack_for_failure() { // own stack roots on the stack anyway. let sentinel_box = ~0; let sentinel: **Word = if expect_sentinel() { - cast::reinterpret_cast(&ptr::addr_of(sentinel_box)) + cast::reinterpret_cast(&ptr::p2::addr_of(&sentinel_box)) } else { ptr::null() }; diff --git a/src/libcore/io.rs b/src/libcore/io.rs index 285f84b6bf6..642d20fa990 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -889,8 +889,8 @@ mod tests { #[test] fn test_readchars_empty() { do io::with_str_reader(~"") |inp| { - let res : ~[char] = inp.read_chars(128u); - assert(vec::len(res) == 0u); + let res : ~[char] = inp.read_chars(128); + assert(vec::len(res) == 0); } } @@ -903,7 +903,7 @@ mod tests { 104, 101, 108, 108, 111, 29983, 38152, 30340, 27748, 21273, 20999, 32905, 27748]; - fn check_read_ln(len : uint, s: ~str, ivals: ~[int]) { + fn check_read_ln(len : uint, s: &str, ivals: &[int]) { do io::with_str_reader(s) |inp| { let res : ~[char] = inp.read_chars(len); if (len <= vec::len(ivals)) { @@ -913,13 +913,13 @@ mod tests { vec::map(res, |x| *x as int)); } } - let mut i = 0u; - while i < 8u { + let mut i = 0; + while i < 8 { check_read_ln(i, wide_test, ivals); - i += 1u; + i += 1; } // check a long read for good measure - check_read_ln(128u, wide_test, ivals); + check_read_ln(128, wide_test, ivals); } #[test] diff --git a/src/libcore/iter-trait.rs b/src/libcore/iter-trait.rs index a6acd1c040e..a2fb4698d7c 100644 --- a/src/libcore/iter-trait.rs +++ b/src/libcore/iter-trait.rs @@ -19,13 +19,13 @@ impl IMPL_T: iter::ExtendedIter { pure fn foldl(+b0: B, blk: fn(&B, &A) -> B) -> B { iter::foldl(&self, move b0, blk) } - pure fn position(f: fn(A) -> bool) -> Option { - iter::position(self, f) + pure fn position(f: fn(&A) -> bool) -> Option { + iter::position(&self, f) } } impl IMPL_T: iter::EqIter { - pure fn contains(x: &A) -> bool { iter::contains(self, x) } + pure fn contains(x: &A) -> bool { iter::contains(&self, x) } pure fn count(x: &A) -> uint { iter::count(&self, x) } } @@ -43,7 +43,7 @@ impl IMPL_T: iter::CopyableIter { iter::flat_map_to_vec(&self, op) } - pure fn find(p: fn(A) -> bool) -> Option { iter::find(self, p) } + pure fn find(p: fn(+a: A) -> bool) -> Option { iter::find(&self, p) } } impl IMPL_T: iter::CopyableOrderedIter { diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index ebc768931b5..84a581fb2cb 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -19,7 +19,7 @@ trait ExtendedIter { pure fn all(blk: fn(&A) -> bool) -> bool; pure fn any(blk: fn(&A) -> bool) -> bool; pure fn foldl(+b0: B, blk: fn(&B, &A) -> B) -> B; - pure fn position(f: fn(A) -> bool) -> Option; + pure fn position(f: fn(&A) -> bool) -> Option; } trait EqIter { @@ -38,7 +38,7 @@ trait CopyableIter { pure fn filter_to_vec(pred: fn(+a: A) -> bool) -> ~[A]; pure fn map_to_vec(op: fn(+v: A) -> B) -> ~[B]; pure fn to_vec() -> ~[A]; - pure fn find(p: fn(A) -> bool) -> Option; + pure fn find(p: fn(+a: A) -> bool) -> Option; } trait CopyableOrderedIter { @@ -131,7 +131,7 @@ pure fn to_vec>(self: &IA) -> ~[A] { foldl::(self, ~[], |r, a| vec::append(copy (*r), ~[*a])) } -pure fn contains>(self: IA, x: &A) -> bool { +pure fn contains>(self: &IA, x: &A) -> bool { for self.each |a| { if *a == *x { return true; } } @@ -148,12 +148,12 @@ pure fn count>(self: &IA, x: &A) -> uint { } } -pure fn position>(self: IA, f: fn(A) -> bool) +pure fn position>(self: &IA, f: fn(&A) -> bool) -> Option { let mut i = 0; for self.each |a| { - if f(*a) { return Some(i); } + if f(a) { return Some(i); } i += 1; } return None; @@ -164,10 +164,10 @@ pure fn position>(self: IA, f: fn(A) -> bool) // it would have to be implemented with foldr, which is too inefficient. pure fn repeat(times: uint, blk: fn() -> bool) { - let mut i = 0u; + let mut i = 0; while i < times { if !blk() { break } - i += 1u; + i += 1; } } @@ -199,8 +199,8 @@ pure fn max>(self: &IA) -> A { } } -pure fn find>(self: IA, - p: fn(A) -> bool) -> Option { +pure fn find>(self: &IA, + p: fn(+a: A) -> bool) -> Option { for self.each |i| { if p(*i) { return Some(*i) } } diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 31835f255b3..cee0007f8f3 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -252,20 +252,20 @@ impl Option : Eq { #[test] fn test_unwrap_ptr() { let x = ~0; - let addr_x = ptr::addr_of(*x); + let addr_x = ptr::p2::addr_of(&(*x)); let opt = Some(x); let y = unwrap(opt); - let addr_y = ptr::addr_of(*y); + let addr_y = ptr::p2::addr_of(&(*y)); assert addr_x == addr_y; } #[test] fn test_unwrap_str() { let x = ~"test"; - let addr_x = str::as_buf(x, |buf, _len| ptr::addr_of(buf)); + let addr_x = str::as_buf(x, |buf, _len| ptr::p2::addr_of(&buf)); let opt = Some(x); let y = unwrap(opt); - let addr_y = str::as_buf(y, |buf, _len| ptr::addr_of(buf)); + let addr_y = str::as_buf(y, |buf, _len| ptr::p2::addr_of(&buf)); assert addr_x == addr_y; } diff --git a/src/libcore/os.rs b/src/libcore/os.rs index 8ec8d1a2b08..9c0d9cdc02c 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -303,7 +303,7 @@ pub fn waitpid(pid: pid_t) -> c_int { use libc::funcs::posix01::wait::*; let status = 0 as c_int; - assert (waitpid(pid, ptr::mut_addr_of(status), + assert (waitpid(pid, ptr::mut_addr_of(&status), 0 as c_int) != (-1 as c_int)); return status; } @@ -313,7 +313,7 @@ pub fn waitpid(pid: pid_t) -> c_int { pub fn pipe() -> {in: c_int, out: c_int} { let fds = {mut in: 0 as c_int, mut out: 0 as c_int }; - assert (libc::pipe(ptr::mut_addr_of(fds.in)) == (0 as c_int)); + assert (libc::pipe(ptr::mut_addr_of(&(fds.in))) == (0 as c_int)); return {in: fds.in, out: fds.out}; } @@ -384,7 +384,7 @@ pub fn self_exe_path() -> Option { #[cfg(target_os = "macos")] fn load_self() -> Option<~str> { do fill_charp_buf() |buf, sz| { - libc::_NSGetExecutablePath(buf, ptr::mut_addr_of(sz as u32)) + libc::_NSGetExecutablePath(buf, ptr::mut_addr_of(&(sz as u32))) == (0 as c_int) } } diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs index 7ab6e5e3909..95edeca9837 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -219,7 +219,7 @@ fn unibuffer() -> ~Buffer> { #[doc(hidden)] pub fn packet() -> *Packet { let b = unibuffer(); - let p = ptr::addr_of(b.data); + let p = ptr::p2::addr_of(&(b.data)); // We'll take over memory management from here. unsafe { forget(move b) } p @@ -359,7 +359,7 @@ pub fn send(+p: SendPacketBuffered, let header = p.header(); let p_ = p.unwrap(); let p = unsafe { &*p_ }; - assert ptr::addr_of(p.header) == header; + assert ptr::p2::addr_of(&(p.header)) == header; assert p.payload.is_none(); p.payload <- Some(move payload); let old_state = swap_state_rel(&mut p.header.state, Full); @@ -377,7 +377,7 @@ pub fn send(+p: SendPacketBuffered, let old_task = swap_task(&mut p.header.blocked_task, ptr::null()); if !old_task.is_null() { rustrt::task_signal_event( - old_task, ptr::addr_of(p.header) as *libc::c_void); + old_task, ptr::p2::addr_of(&(p.header)) as *libc::c_void); rustrt::rust_task_deref(old_task); } @@ -529,7 +529,7 @@ fn sender_terminate(p: *Packet) { if !old_task.is_null() { rustrt::task_signal_event( old_task, - ptr::addr_of(p.header) as *libc::c_void); + ptr::p2::addr_of(&(p.header)) as *libc::c_void); rustrt::rust_task_deref(old_task); } // The receiver will eventually clean up. @@ -744,7 +744,7 @@ pub fn SendPacketBuffered(p: *Packet) p: Some(p), buffer: unsafe { Some(BufferResource( - get_buffer(ptr::addr_of((*p).header)))) + get_buffer(ptr::p2::addr_of(&((*p).header))))) } } } @@ -760,7 +760,7 @@ impl SendPacketBuffered { match self.p { Some(packet) => unsafe { let packet = &*packet; - let header = ptr::addr_of(packet.header); + let header = ptr::p2::addr_of(&(packet.header)); //forget(packet); header }, @@ -815,7 +815,7 @@ impl RecvPacketBuffered : Selectable { match self.p { Some(packet) => unsafe { let packet = &*packet; - let header = ptr::addr_of(packet.header); + let header = ptr::p2::addr_of(&(packet.header)); //forget(packet); header }, @@ -838,7 +838,7 @@ pub fn RecvPacketBuffered(p: *Packet) p: Some(p), buffer: unsafe { Some(BufferResource( - get_buffer(ptr::addr_of((*p).header)))) + get_buffer(ptr::p2::addr_of(&((*p).header))))) } } } diff --git a/src/libcore/private.rs b/src/libcore/private.rs index 7eba81803b3..025a6f28976 100644 --- a/src/libcore/private.rs +++ b/src/libcore/private.rs @@ -108,8 +108,8 @@ pub fn test_from_global_chan1() { // This is unreadable, right? // The global channel - let globchan = 0u; - let globchanp = ptr::addr_of(globchan); + let globchan = 0; + let globchanp = ptr::p2::addr_of(&globchan); // Create the global channel, attached to a new task let ch = unsafe { @@ -142,23 +142,23 @@ pub fn test_from_global_chan1() { #[test] pub fn test_from_global_chan2() { - for iter::repeat(100u) { + for iter::repeat(100) { // The global channel - let globchan = 0u; - let globchanp = ptr::addr_of(globchan); + let globchan = 0; + let globchanp = ptr::p2::addr_of(&globchan); let resultpo = comm::Port(); let resultch = comm::Chan(resultpo); // Spawn a bunch of tasks that all want to compete to // create the global channel - for uint::range(0u, 10u) |i| { + for uint::range(0, 10) |i| { do task::spawn { let ch = unsafe { do chan_from_global_ptr( globchanp, task::task) |po| { - for uint::range(0u, 10u) |_j| { + for uint::range(0, 10) |_j| { let ch = comm::recv(po); comm::send(ch, {i}); } diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 0cc283e89a4..d0b848adde2 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -24,15 +24,24 @@ extern mod rusti { fn addr_of(val: T) -> *T; } +/* +Remove this after snapshot; make p2::addr_of addr_of +*/ /// Get an unsafe pointer to a value #[inline(always)] pub pure fn addr_of(val: T) -> *T { unsafe { rusti::addr_of(val) } } +pub mod p2 { + /// Get an unsafe pointer to a value + #[inline(always)] + pub pure fn addr_of(val: &T) -> *T { unsafe { rusti::addr_of(*val) } } +} + /// Get an unsafe mut pointer to a value #[inline(always)] -pub pure fn mut_addr_of(val: T) -> *mut T { +pub pure fn mut_addr_of(val: &T) -> *mut T { unsafe { - cast::reinterpret_cast(&rusti::addr_of(val)) + cast::reinterpret_cast(&rusti::addr_of(*val)) } } @@ -61,16 +70,16 @@ pub fn mut_offset(ptr: *mut T, count: uint) -> *mut T { /// Return the offset of the first null pointer in `buf`. #[inline(always)] pub unsafe fn buf_len(buf: **T) -> uint { - position(buf, |i| i == null()) + position(buf, |i| *i == null()) } /// Return the first offset `i` such that `f(buf[i]) == true`. #[inline(always)] -pub unsafe fn position(buf: *T, f: fn(T) -> bool) -> uint { - let mut i = 0u; +pub unsafe fn position(buf: *T, f: fn(&T) -> bool) -> uint { + let mut i = 0; loop { - if f(*offset(buf, i)) { return i; } - else { i += 1u; } + if f(&(*offset(buf, i))) { return i; } + else { i += 1; } } } @@ -234,7 +243,7 @@ pub fn test() { unsafe { type Pair = {mut fst: int, mut snd: int}; let p = {mut fst: 10, mut snd: 20}; - let pptr: *mut Pair = mut_addr_of(p); + let pptr: *mut Pair = mut_addr_of(&p); let iptr: *mut int = cast::reinterpret_cast(&pptr); assert (*iptr == 10);; *iptr = 30; @@ -268,9 +277,9 @@ pub fn test_position() { let s = ~"hello"; unsafe { - assert 2u == as_c_str(s, |p| position(p, |c| c == 'l' as c_char)); - assert 4u == as_c_str(s, |p| position(p, |c| c == 'o' as c_char)); - assert 5u == as_c_str(s, |p| position(p, |c| c == 0 as c_char)); + assert 2u == as_c_str(s, |p| position(p, |c| *c == 'l' as c_char)); + assert 4u == as_c_str(s, |p| position(p, |c| *c == 'o' as c_char)); + assert 5u == as_c_str(s, |p| position(p, |c| *c == 0 as c_char)); } } diff --git a/src/libcore/str.rs b/src/libcore/str.rs index f7d8e8d34d2..c6e7116675f 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -1780,7 +1780,7 @@ pub pure fn as_c_str(s: &str, f: fn(*libc::c_char) -> T) -> T { #[inline(always)] pub pure fn as_buf(s: &str, f: fn(*u8, uint) -> T) -> T { unsafe { - let v : *(*u8,uint) = ::cast::reinterpret_cast(&ptr::addr_of(s)); + let v : *(*u8,uint) = ::cast::reinterpret_cast(&ptr::p2::addr_of(&s)); let (buf,len) = *v; f(buf, len) } @@ -2012,7 +2012,7 @@ pub mod raw { let v: **vec::raw::VecRepr = cast::transmute(copy v); let repr: *vec::raw::VecRepr = *v; (*repr).unboxed.fill = new_len + 1u; - let null = ptr::mut_offset(ptr::mut_addr_of((*repr).unboxed.data), + let null = ptr::mut_offset(ptr::mut_addr_of(&((*repr).unboxed.data)), new_len); *null = 0u8; } diff --git a/src/libcore/task.rs b/src/libcore/task.rs index 9e2949c37ef..d7e8416e9f7 100644 --- a/src/libcore/task.rs +++ b/src/libcore/task.rs @@ -1175,10 +1175,10 @@ fn avoid_copying_the_body(spawnfn: fn(+v: fn~())) { let ch = comm::Chan(p); let x = ~1; - let x_in_parent = ptr::addr_of(*x) as uint; + let x_in_parent = ptr::p2::addr_of(&(*x)) as uint; do spawnfn { - let x_in_child = ptr::addr_of(*x) as uint; + let x_in_child = ptr::p2::addr_of(&(*x)) as uint; comm::send(ch, x_in_child); } diff --git a/src/libcore/task/local_data_priv.rs b/src/libcore/task/local_data_priv.rs index 31369c47c64..0d3007286c5 100644 --- a/src/libcore/task/local_data_priv.rs +++ b/src/libcore/task/local_data_priv.rs @@ -68,7 +68,7 @@ unsafe fn local_data_lookup( let key_value = key_to_key_value(key); let map_pos = (*map).position(|entry| - match entry { + match *entry { Some((k,_,_)) => k == key_value, None => false } diff --git a/src/libcore/task/spawn.rs b/src/libcore/task/spawn.rs index 7ae4c7b0950..d410a4b192d 100644 --- a/src/libcore/task/spawn.rs +++ b/src/libcore/task/spawn.rs @@ -66,7 +66,7 @@ use rt::rust_task; use rt::rust_closure; macro_rules! move_it ( - { $x:expr } => { unsafe { let y <- *ptr::addr_of($x); move y } } + { $x:expr } => { unsafe { let y <- *ptr::p2::addr_of(&($x)); move y } } ) type TaskSet = send_map::linear::LinearMap<*rust_task,()>; @@ -511,7 +511,14 @@ fn spawn_raw(+opts: TaskOpts, +f: fn~()) { let child_wrapper = make_child_wrapper(new_task, move child_tg, move ancestors, is_main, move notify_chan, move f); - let fptr = ptr::addr_of(child_wrapper); + /* + Truly awful, but otherwise the borrow checker complains about + the move in the last line of this block, for reasons I can't + understand. -- tjc + */ + let tmp: u64 = cast::reinterpret_cast(&(&child_wrapper)); + let whatever: &~fn() = cast::reinterpret_cast(&tmp); + let fptr = ptr::p2::addr_of(whatever); let closure: *rust_closure = cast::reinterpret_cast(&fptr); // Getting killed between these two calls would free the child's diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 66b1c0d95ec..a8286eb4e08 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -6,7 +6,7 @@ use cmp::{Eq, Ord}; use option::{Some, None}; -use ptr::addr_of; +use ptr::p2::addr_of; use libc::size_t; export append; @@ -582,7 +582,7 @@ unsafe fn push_fast(+v: &mut ~[T], +initval: T) { let repr: **raw::VecRepr = ::cast::transmute(v); let fill = (**repr).unboxed.fill; (**repr).unboxed.fill += sys::size_of::(); - let p = ptr::addr_of((**repr).unboxed.data); + let p = addr_of(&((**repr).unboxed.data)); let p = ptr::offset(p, fill) as *mut T; rusti::move_val_init(*p, move initval); } @@ -1339,7 +1339,7 @@ pure fn as_imm_buf(s: &[T], /* NB---this CANNOT be const, see below */ unsafe { let v : *(*T,uint) = - ::cast::reinterpret_cast(&ptr::addr_of(s)); + ::cast::reinterpret_cast(&addr_of(&s)); let (buf,len) = *v; f(buf, len / sys::size_of::()) } @@ -1352,7 +1352,7 @@ pure fn as_const_buf(s: &[const T], unsafe { let v : *(*const T,uint) = - ::cast::reinterpret_cast(&ptr::addr_of(s)); + ::cast::reinterpret_cast(&addr_of(&s)); let (buf,len) = *v; f(buf, len / sys::size_of::()) } @@ -1365,7 +1365,7 @@ pure fn as_mut_buf(s: &[mut T], unsafe { let v : *(*mut T,uint) = - ::cast::reinterpret_cast(&ptr::addr_of(s)); + ::cast::reinterpret_cast(&addr_of(&s)); let (buf,len) = *v; f(buf, len / sys::size_of::()) } @@ -1816,21 +1816,21 @@ mod raw { #[inline(always)] unsafe fn to_ptr(+v: &[T]) -> *T { let repr: **SliceRepr = ::cast::transmute(&v); - return ::cast::reinterpret_cast(&addr_of((**repr).data)); + return ::cast::reinterpret_cast(&addr_of(&((**repr).data))); } /** see `to_ptr()` */ #[inline(always)] unsafe fn to_const_ptr(+v: &[const T]) -> *const T { let repr: **SliceRepr = ::cast::transmute(&v); - return ::cast::reinterpret_cast(&addr_of((**repr).data)); + return ::cast::reinterpret_cast(&addr_of(&((**repr).data))); } /** see `to_ptr()` */ #[inline(always)] unsafe fn to_mut_ptr(+v: &[mut T]) -> *mut T { let repr: **SliceRepr = ::cast::transmute(&v); - return ::cast::reinterpret_cast(&addr_of((**repr).data)); + return ::cast::reinterpret_cast(&addr_of(&((**repr).data))); } /** @@ -1841,7 +1841,7 @@ mod raw { unsafe fn form_slice(p: *T, len: uint, f: fn(v: &[T]) -> U) -> U { let pair = (p, len * sys::size_of::()); let v : *(&blk/[T]) = - ::cast::reinterpret_cast(&ptr::addr_of(pair)); + ::cast::reinterpret_cast(&addr_of(&pair)); f(*v) } @@ -1996,13 +1996,13 @@ impl &[A]: iter::ExtendedIter { pure fn foldl(+b0: B, blk: fn(&B, &A) -> B) -> B { iter::foldl(&self, move b0, blk) } - pure fn position(f: fn(A) -> bool) -> Option { - iter::position(self, f) + pure fn position(f: fn(&A) -> bool) -> Option { + iter::position(&self, f) } } impl &[A]: iter::EqIter { - pure fn contains(x: &A) -> bool { iter::contains(self, x) } + pure fn contains(x: &A) -> bool { iter::contains(&self, x) } pure fn count(x: &A) -> uint { iter::count(&self, x) } } @@ -2020,7 +2020,7 @@ impl &[A]: iter::CopyableIter { // iter::flat_map_to_vec(self, op) // } - pure fn find(p: fn(A) -> bool) -> Option { iter::find(self, p) } + pure fn find(p: fn(+a: A) -> bool) -> Option { iter::find(&self, p) } } impl &[A]: iter::CopyableOrderedIter { diff --git a/src/libsyntax/ext/pipes/pipec.rs b/src/libsyntax/ext/pipes/pipec.rs index b9b1484ce5a..cec2972b2a7 100644 --- a/src/libsyntax/ext/pipes/pipec.rs +++ b/src/libsyntax/ext/pipes/pipec.rs @@ -71,10 +71,10 @@ impl message: gen_send { body += ~"let b = pipe.reuse_buffer();\n"; body += fmt!("let %s = pipes::SendPacketBuffered(\ - ptr::addr_of(b.buffer.data.%s));\n", + ptr::p2::addr_of(&(b.buffer.data.%s)));\n", sp, next.name); body += fmt!("let %s = pipes::RecvPacketBuffered(\ - ptr::addr_of(b.buffer.data.%s));\n", + ptr::p2::addr_of(&(b.buffer.data.%s)));\n", rp, next.name); } else { @@ -351,7 +351,7 @@ impl protocol: gen_init { fmt!("data.%s.set_buffer_(buffer)", s.name))), ext_cx.parse_expr( - fmt!("ptr::addr_of(data.%s)", + fmt!("ptr::p2::addr_of(&(data.%s))", self.states[0].name)))); #ast {{ diff --git a/src/test/compile-fail/issue-3096-2.rs b/src/test/compile-fail/issue-3096-2.rs index cd3d63b5888..03e13f67a9a 100644 --- a/src/test/compile-fail/issue-3096-2.rs +++ b/src/test/compile-fail/issue-3096-2.rs @@ -1,6 +1,6 @@ enum bottom { } fn main() { - let x = ptr::addr_of(()) as *bottom; + let x = ptr::p2::addr_of(&()) as *bottom; match x { } //~ ERROR non-exhaustive patterns } diff --git a/src/test/compile-fail/mutable-huh-ptr-assign.rs b/src/test/compile-fail/mutable-huh-ptr-assign.rs index ecfbb9a1f08..4b680ec8b70 100644 --- a/src/test/compile-fail/mutable-huh-ptr-assign.rs +++ b/src/test/compile-fail/mutable-huh-ptr-assign.rs @@ -7,7 +7,7 @@ fn main() { unsafe { let a = 0; - let v = ptr::mut_addr_of(a); + let v = ptr::mut_addr_of(&a); f(v); } } diff --git a/src/test/compile-fail/mutable-huh-variance-ptr.rs b/src/test/compile-fail/mutable-huh-variance-ptr.rs index c96f3f624f1..e98b9b34c5f 100644 --- a/src/test/compile-fail/mutable-huh-variance-ptr.rs +++ b/src/test/compile-fail/mutable-huh-variance-ptr.rs @@ -4,7 +4,7 @@ extern mod std; fn main() { let a = ~[0]; - let v: *mut ~[int] = ptr::mut_addr_of(a); + let v: *mut ~[int] = ptr::mut_addr_of(&a); fn f(&&v: *mut ~[const int]) { unsafe { diff --git a/src/test/compile-fail/non-copyable-void.rs b/src/test/compile-fail/non-copyable-void.rs index 59136683e6f..a00dd7afd6d 100644 --- a/src/test/compile-fail/non-copyable-void.rs +++ b/src/test/compile-fail/non-copyable-void.rs @@ -1,5 +1,5 @@ fn main() { - let x : *~[int] = ptr::addr_of(~[1,2,3]); + let x : *~[int] = ptr::p2::addr_of(&~[1,2,3]); let y : *libc::c_void = x as *libc::c_void; unsafe { let _z = *y;