Skip to content

Rename std::borrow to std::reference. #11895

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 30, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/libextra/arc.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand Down Expand Up @@ -47,7 +47,6 @@ use sync::{Mutex, RWLock};
use std::cast;
use std::sync::arc::UnsafeArc;
use std::task;
use std::borrow;

/// As sync::condvar, a mechanism for unlock-and-descheduling and signaling.
pub struct Condvar<'a> {
Expand Down Expand Up @@ -465,7 +464,7 @@ impl<T:Freeze + Send> RWArc<T> {
// of this cast is removing the mutability.)
let new_data = data;
// Downgrade ensured the token belonged to us. Just a sanity check.
assert!(borrow::ref_eq(&(*state).data, new_data));
assert!((&(*state).data as *T as uint) == (new_data as *mut T as uint));
// Produce new token
RWReadMode {
data: new_data,
Expand Down
5 changes: 2 additions & 3 deletions src/libextra/sync.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand All @@ -18,7 +18,6 @@
*/


use std::borrow;
use std::comm;
use std::unstable::sync::Exclusive;
use std::sync::arc::UnsafeArc;
Expand Down Expand Up @@ -634,7 +633,7 @@ impl RWLock {
/// To be called inside of the write_downgrade block.
pub fn downgrade<'a>(&self, token: RWLockWriteMode<'a>)
-> RWLockReadMode<'a> {
if !borrow::ref_eq(self, token.lock) {
if !((self as *RWLock) == (token.lock as *RWLock)) {
fail!("Can't downgrade() with a different rwlock's write_mode!");
}
unsafe {
Expand Down
3 changes: 1 addition & 2 deletions src/libstd/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ pub mod send_str;
pub mod ptr;
pub mod owned;
pub mod managed;
pub mod borrow;
mod reference;
pub mod rc;
pub mod gc;

Expand Down Expand Up @@ -223,7 +223,6 @@ mod std {
pub use kinds;
pub use local_data;
pub use logging;
pub use logging;
pub use option;
pub use os;
pub use rt;
Expand Down
25 changes: 0 additions & 25 deletions src/libstd/borrow.rs → src/libstd/reference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,6 @@
#[cfg(not(test))]
use prelude::*;

/// Cast a region pointer - &T - to a uint.
#[inline]
pub fn to_uint<T>(thing: &T) -> uint {
thing as *T as uint
}

/// Determine if two borrowed pointers point to the same thing.
#[inline]
pub fn ref_eq<'a, 'b, T>(thing: &'a T, other: &'b T) -> bool {
(thing as *T) == (other as *T)
}

// Equality for region pointers
#[cfg(not(test))]
impl<'a, T: Eq> Eq for &'a T {
Expand Down Expand Up @@ -71,16 +59,3 @@ impl<'a, T: TotalEq> TotalEq for &'a T {
fn equals(&self, other: & &'a T) -> bool { (**self).equals(*other) }
}

#[cfg(test)]
mod tests {
use super::ref_eq;

#[test]
fn test_ref_eq() {
let x = 1;
let y = 1;

assert!(ref_eq(&x, &x));
assert!(!ref_eq(&x, &y));
}
}
3 changes: 1 addition & 2 deletions src/libstd/rt/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
//! to implement this.

use any::AnyOwnExt;
use borrow;
use cast;
use cleanup;
use clone::Clone;
Expand Down Expand Up @@ -287,7 +286,7 @@ impl Task {

impl Drop for Task {
fn drop(&mut self) {
rtdebug!("called drop for a task: {}", borrow::to_uint(self));
rtdebug!("called drop for a task: {}", self as *mut Task as uint);
rtassert!(self.destroyed);
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/test/run-pass/borrowck-borrow-from-expr-block.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand All @@ -10,7 +10,6 @@

#[feature(managed_boxes)];

use std::borrow;
use std::ptr;

fn borrow(x: &int, f: |x: &int|) {
Expand All @@ -20,7 +19,7 @@ fn borrow(x: &int, f: |x: &int|) {
fn test1(x: @~int) {
borrow(&*(*x).clone(), |p| {
let x_a = ptr::to_unsafe_ptr(&**x);
assert!((x_a as uint) != borrow::to_uint(p));
assert!((x_a as uint) != (p as *int as uint));
assert_eq!(unsafe{*x_a}, *p);
})
}
Expand Down
6 changes: 2 additions & 4 deletions src/test/run-pass/cast-region-to-uint.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand All @@ -8,9 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::borrow;

pub fn main() {
let x = 3;
info!("&x={:x}", borrow::to_uint(&x));
info!("&x={:x}", (&x as *int as uint));
}