Skip to content

Commit b3003e1

Browse files
committed
auto merge of #11895 : xales/rust/libstd, r=alexcrichton
Fixes #11814
2 parents 3427137 + f17d972 commit b3003e1

File tree

7 files changed

+10
-42
lines changed

7 files changed

+10
-42
lines changed

src/libextra/arc.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -47,7 +47,6 @@ use sync::{Mutex, RWLock};
4747
use std::cast;
4848
use std::sync::arc::UnsafeArc;
4949
use std::task;
50-
use std::borrow;
5150

5251
/// As sync::condvar, a mechanism for unlock-and-descheduling and signaling.
5352
pub struct Condvar<'a> {
@@ -465,7 +464,7 @@ impl<T:Freeze + Send> RWArc<T> {
465464
// of this cast is removing the mutability.)
466465
let new_data = data;
467466
// Downgrade ensured the token belonged to us. Just a sanity check.
468-
assert!(borrow::ref_eq(&(*state).data, new_data));
467+
assert!((&(*state).data as *T as uint) == (new_data as *mut T as uint));
469468
// Produce new token
470469
RWReadMode {
471470
data: new_data,

src/libextra/sync.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -18,7 +18,6 @@
1818
*/
1919

2020

21-
use std::borrow;
2221
use std::comm;
2322
use std::unstable::sync::Exclusive;
2423
use std::sync::arc::UnsafeArc;
@@ -634,7 +633,7 @@ impl RWLock {
634633
/// To be called inside of the write_downgrade block.
635634
pub fn downgrade<'a>(&self, token: RWLockWriteMode<'a>)
636635
-> RWLockReadMode<'a> {
637-
if !borrow::ref_eq(self, token.lock) {
636+
if !((self as *RWLock) == (token.lock as *RWLock)) {
638637
fail!("Can't downgrade() with a different rwlock's write_mode!");
639638
}
640639
unsafe {

src/libstd/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ pub mod send_str;
123123
pub mod ptr;
124124
pub mod owned;
125125
pub mod managed;
126-
pub mod borrow;
126+
mod reference;
127127
pub mod rc;
128128
pub mod gc;
129129

@@ -223,7 +223,6 @@ mod std {
223223
pub use kinds;
224224
pub use local_data;
225225
pub use logging;
226-
pub use logging;
227226
pub use option;
228227
pub use os;
229228
pub use rt;

src/libstd/borrow.rs renamed to src/libstd/reference.rs

-25
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,6 @@
1313
#[cfg(not(test))]
1414
use prelude::*;
1515

16-
/// Cast a region pointer - &T - to a uint.
17-
#[inline]
18-
pub fn to_uint<T>(thing: &T) -> uint {
19-
thing as *T as uint
20-
}
21-
22-
/// Determine if two borrowed pointers point to the same thing.
23-
#[inline]
24-
pub fn ref_eq<'a, 'b, T>(thing: &'a T, other: &'b T) -> bool {
25-
(thing as *T) == (other as *T)
26-
}
27-
2816
// Equality for region pointers
2917
#[cfg(not(test))]
3018
impl<'a, T: Eq> Eq for &'a T {
@@ -71,16 +59,3 @@ impl<'a, T: TotalEq> TotalEq for &'a T {
7159
fn equals(&self, other: & &'a T) -> bool { (**self).equals(*other) }
7260
}
7361

74-
#[cfg(test)]
75-
mod tests {
76-
use super::ref_eq;
77-
78-
#[test]
79-
fn test_ref_eq() {
80-
let x = 1;
81-
let y = 1;
82-
83-
assert!(ref_eq(&x, &x));
84-
assert!(!ref_eq(&x, &y));
85-
}
86-
}

src/libstd/rt/task.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
//! to implement this.
1515
1616
use any::AnyOwnExt;
17-
use borrow;
1817
use cast;
1918
use cleanup;
2019
use clone::Clone;
@@ -287,7 +286,7 @@ impl Task {
287286

288287
impl Drop for Task {
289288
fn drop(&mut self) {
290-
rtdebug!("called drop for a task: {}", borrow::to_uint(self));
289+
rtdebug!("called drop for a task: {}", self as *mut Task as uint);
291290
rtassert!(self.destroyed);
292291
}
293292
}

src/test/run-pass/borrowck-borrow-from-expr-block.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -10,7 +10,6 @@
1010

1111
#[feature(managed_boxes)];
1212

13-
use std::borrow;
1413
use std::ptr;
1514

1615
fn borrow(x: &int, f: |x: &int|) {
@@ -20,7 +19,7 @@ fn borrow(x: &int, f: |x: &int|) {
2019
fn test1(x: @~int) {
2120
borrow(&*(*x).clone(), |p| {
2221
let x_a = ptr::to_unsafe_ptr(&**x);
23-
assert!((x_a as uint) != borrow::to_uint(p));
22+
assert!((x_a as uint) != (p as *int as uint));
2423
assert_eq!(unsafe{*x_a}, *p);
2524
})
2625
}
+2-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -8,9 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::borrow;
12-
1311
pub fn main() {
1412
let x = 3;
15-
info!("&x={:x}", borrow::to_uint(&x));
13+
info!("&x={:x}", (&x as *int as uint));
1614
}

0 commit comments

Comments
 (0)