Skip to content

Commit a5518a3

Browse files
---
yaml --- r: 107788 b: refs/heads/dist-snap c: 89278f7 h: refs/heads/master v: v3
1 parent cfaf5e9 commit a5518a3

File tree

14 files changed

+72
-40
lines changed

14 files changed

+72
-40
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: f64fdf524a434f0e5cd0bc91d09c144723f3c90d
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: b3003e1e1af8ee5ca74458787f5eb8c565a47e1d
9+
refs/heads/dist-snap: 89278f773d772af7d55a6f6e5efd136420ff2204
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/libextra/arc.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2013 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,6 +47,7 @@ use sync::{Mutex, RWLock};
4747
use std::cast;
4848
use std::sync::arc::UnsafeArc;
4949
use std::task;
50+
use std::borrow;
5051

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

branches/dist-snap/src/libextra/sync.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2013 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,6 +18,7 @@
1818
*/
1919

2020

21+
use std::borrow;
2122
use std::comm;
2223
use std::unstable::sync::Exclusive;
2324
use std::sync::arc::UnsafeArc;
@@ -633,7 +634,7 @@ impl RWLock {
633634
/// To be called inside of the write_downgrade block.
634635
pub fn downgrade<'a>(&self, token: RWLockWriteMode<'a>)
635636
-> RWLockReadMode<'a> {
636-
if !((self as *RWLock) == (token.lock as *RWLock)) {
637+
if !borrow::ref_eq(self, token.lock) {
637638
fail!("Can't downgrade() with a different rwlock's write_mode!");
638639
}
639640
unsafe {

branches/dist-snap/src/librustc/middle/trans/debuginfo.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,7 +1646,7 @@ fn set_members_of_composite_type(cx: &CrateContext,
16461646
.map(|(i, member_description)| {
16471647
let (member_size, member_align) = size_and_align_of(cx, member_description.llvm_type);
16481648
let member_offset = match member_description.offset {
1649-
FixedMemberOffset { bytes } => bytes,
1649+
FixedMemberOffset { bytes } => bytes as u64,
16501650
ComputedMemberOffset => machine::llelement_offset(cx, composite_llvm_type, i)
16511651
};
16521652

@@ -1815,7 +1815,7 @@ fn fixed_vec_metadata(cx: &CrateContext,
18151815
return unsafe {
18161816
llvm::LLVMDIBuilderCreateArrayType(
18171817
DIB(cx),
1818-
bytes_to_bits(element_type_size * len),
1818+
bytes_to_bits(element_type_size * (len as u64)),
18191819
bytes_to_bits(element_type_align),
18201820
element_type_metadata,
18211821
subscripts)
@@ -2211,11 +2211,11 @@ fn span_start(cx: &CrateContext, span: Span) -> codemap::Loc {
22112211
cx.sess.codemap.lookup_char_pos(span.lo)
22122212
}
22132213

2214-
fn size_and_align_of(cx: &CrateContext, llvm_type: Type) -> (uint, uint) {
2214+
fn size_and_align_of(cx: &CrateContext, llvm_type: Type) -> (u64, u64) {
22152215
(machine::llsize_of_alloc(cx, llvm_type), machine::llalign_of_min(cx, llvm_type))
22162216
}
22172217

2218-
fn bytes_to_bits(bytes: uint) -> c_ulonglong {
2218+
fn bytes_to_bits(bytes: u64) -> c_ulonglong {
22192219
(bytes * 8) as c_ulonglong
22202220
}
22212221

branches/dist-snap/src/librustc/middle/trans/foreign.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ pub fn trans_native_call<'a>(
341341
let llalign = cmp::min(llforeign_align, llrust_align);
342342
debug!("llrust_size={:?}", llrust_size);
343343
base::call_memcpy(bcx, llretptr_i8, llscratch_i8,
344-
C_uint(ccx, llrust_size), llalign as u32);
344+
C_uint(ccx, llrust_size as uint), llalign as u32);
345345
}
346346
}
347347

branches/dist-snap/src/librustc/middle/trans/intrinsic.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ pub fn trans_intrinsic(ccx: @CrateContext,
247247
"size_of" => {
248248
let tp_ty = substs.tys[0];
249249
let lltp_ty = type_of::type_of(ccx, tp_ty);
250-
Ret(bcx, C_uint(ccx, machine::llsize_of_real(ccx, lltp_ty)));
250+
Ret(bcx, C_uint(ccx, machine::llsize_of_real(ccx, lltp_ty) as uint));
251251
}
252252
"move_val_init" => {
253253
// Create a datum reflecting the value being moved.
@@ -266,12 +266,12 @@ pub fn trans_intrinsic(ccx: @CrateContext,
266266
"min_align_of" => {
267267
let tp_ty = substs.tys[0];
268268
let lltp_ty = type_of::type_of(ccx, tp_ty);
269-
Ret(bcx, C_uint(ccx, machine::llalign_of_min(ccx, lltp_ty)));
269+
Ret(bcx, C_uint(ccx, machine::llalign_of_min(ccx, lltp_ty) as uint));
270270
}
271271
"pref_align_of"=> {
272272
let tp_ty = substs.tys[0];
273273
let lltp_ty = type_of::type_of(ccx, tp_ty);
274-
Ret(bcx, C_uint(ccx, machine::llalign_of_pref(ccx, lltp_ty)));
274+
Ret(bcx, C_uint(ccx, machine::llalign_of_pref(ccx, lltp_ty) as uint));
275275
}
276276
"get_tydesc" => {
277277
let tp_ty = substs.tys[0];
@@ -337,7 +337,7 @@ pub fn trans_intrinsic(ccx: @CrateContext,
337337
_ => fail!("transmute has non-expr arg"),
338338
}
339339
};
340-
let pluralize = |n| if 1u == n { "" } else { "s" };
340+
let pluralize = |n| if 1 == n { "" } else { "s" };
341341
ccx.sess.span_fatal(sp,
342342
format!("transmute called on types with \
343343
different sizes: {} ({} bit{}) to \

branches/dist-snap/src/librustc/middle/trans/machine.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ use middle::trans::type_::Type;
2121
// compute sizeof / alignof
2222

2323
// Returns the number of bytes clobbered by a Store to this type.
24-
pub fn llsize_of_store(cx: &CrateContext, ty: Type) -> uint {
24+
pub fn llsize_of_store(cx: &CrateContext, ty: Type) -> u64 {
2525
unsafe {
26-
return llvm::LLVMStoreSizeOfType(cx.td.lltd, ty.to_ref()) as uint;
26+
return llvm::LLVMStoreSizeOfType(cx.td.lltd, ty.to_ref()) as u64;
2727
}
2828
}
2929

3030
// Returns the number of bytes between successive elements of type T in an
3131
// array of T. This is the "ABI" size. It includes any ABI-mandated padding.
32-
pub fn llsize_of_alloc(cx: &CrateContext, ty: Type) -> uint {
32+
pub fn llsize_of_alloc(cx: &CrateContext, ty: Type) -> u64 {
3333
unsafe {
34-
return llvm::LLVMABISizeOfType(cx.td.lltd, ty.to_ref()) as uint;
34+
return llvm::LLVMABISizeOfType(cx.td.lltd, ty.to_ref()) as u64;
3535
}
3636
}
3737

@@ -43,22 +43,22 @@ pub fn llsize_of_alloc(cx: &CrateContext, ty: Type) -> uint {
4343
// that LLVM *does* distinguish between e.g. a 1-bit value and an 8-bit value
4444
// at the codegen level! In general you should prefer `llbitsize_of_real`
4545
// below.
46-
pub fn llsize_of_real(cx: &CrateContext, ty: Type) -> uint {
46+
pub fn llsize_of_real(cx: &CrateContext, ty: Type) -> u64 {
4747
unsafe {
48-
let nbits = llvm::LLVMSizeOfTypeInBits(cx.td.lltd, ty.to_ref()) as uint;
49-
if nbits & 7u != 0u {
48+
let nbits = llvm::LLVMSizeOfTypeInBits(cx.td.lltd, ty.to_ref()) as u64;
49+
if nbits & 7 != 0 {
5050
// Not an even number of bytes, spills into "next" byte.
51-
1u + (nbits >> 3)
51+
1 + (nbits >> 3)
5252
} else {
5353
nbits >> 3
5454
}
5555
}
5656
}
5757

5858
/// Returns the "real" size of the type in bits.
59-
pub fn llbitsize_of_real(cx: &CrateContext, ty: Type) -> uint {
59+
pub fn llbitsize_of_real(cx: &CrateContext, ty: Type) -> u64 {
6060
unsafe {
61-
llvm::LLVMSizeOfTypeInBits(cx.td.lltd, ty.to_ref()) as uint
61+
llvm::LLVMSizeOfTypeInBits(cx.td.lltd, ty.to_ref()) as u64
6262
}
6363
}
6464

@@ -71,7 +71,7 @@ pub fn llsize_of(cx: &CrateContext, ty: Type) -> ValueRef {
7171
// there's no need for that contrivance. The instruction
7272
// selection DAG generator would flatten that GEP(1) node into a
7373
// constant of the type's alloc size, so let's save it some work.
74-
return C_uint(cx, llsize_of_alloc(cx, ty));
74+
return C_uint(cx, llsize_of_alloc(cx, ty) as uint);
7575
}
7676

7777
// Returns the "default" size of t (see above), or 1 if the size would
@@ -89,18 +89,18 @@ pub fn nonzero_llsize_of(cx: &CrateContext, ty: Type) -> ValueRef {
8989
// The preferred alignment may be larger than the alignment used when
9090
// packing the type into structs. This will be used for things like
9191
// allocations inside a stack frame, which LLVM has a free hand in.
92-
pub fn llalign_of_pref(cx: &CrateContext, ty: Type) -> uint {
92+
pub fn llalign_of_pref(cx: &CrateContext, ty: Type) -> u64 {
9393
unsafe {
94-
return llvm::LLVMPreferredAlignmentOfType(cx.td.lltd, ty.to_ref()) as uint;
94+
return llvm::LLVMPreferredAlignmentOfType(cx.td.lltd, ty.to_ref()) as u64;
9595
}
9696
}
9797

9898
// Returns the minimum alignment of a type required by the platform.
9999
// This is the alignment that will be used for struct fields, arrays,
100100
// and similar ABI-mandated things.
101-
pub fn llalign_of_min(cx: &CrateContext, ty: Type) -> uint {
101+
pub fn llalign_of_min(cx: &CrateContext, ty: Type) -> u64 {
102102
unsafe {
103-
return llvm::LLVMABIAlignmentOfType(cx.td.lltd, ty.to_ref()) as uint;
103+
return llvm::LLVMABIAlignmentOfType(cx.td.lltd, ty.to_ref()) as u64;
104104
}
105105
}
106106

@@ -114,8 +114,8 @@ pub fn llalign_of(cx: &CrateContext, ty: Type) -> ValueRef {
114114
}
115115
}
116116

117-
pub fn llelement_offset(cx: &CrateContext, struct_ty: Type, element: uint) -> uint {
117+
pub fn llelement_offset(cx: &CrateContext, struct_ty: Type, element: uint) -> u64 {
118118
unsafe {
119-
return llvm::LLVMOffsetOfElement(cx.td.lltd, struct_ty.to_ref(), element as u32) as uint;
119+
return llvm::LLVMOffsetOfElement(cx.td.lltd, struct_ty.to_ref(), element as u32) as u64;
120120
}
121121
}

branches/dist-snap/src/librustc/middle/trans/reflect.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ impl<'a> Reflector<'a> {
7373
let tr = type_of(self.bcx.ccx(), t);
7474
let s = machine::llsize_of_real(self.bcx.ccx(), tr);
7575
let a = machine::llalign_of_min(self.bcx.ccx(), tr);
76-
return ~[self.c_uint(s),
77-
self.c_uint(a)];
76+
return ~[self.c_uint(s as uint),
77+
self.c_uint(a as uint)];
7878
}
7979

8080
pub fn c_tydesc(&mut self, t: ty::t) -> ValueRef {

branches/dist-snap/src/librustc/middle/trans/tvec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ pub struct VecTypes {
164164
unit_ty: ty::t,
165165
llunit_ty: Type,
166166
llunit_size: ValueRef,
167-
llunit_alloc_size: uint
167+
llunit_alloc_size: u64
168168
}
169169

170170
impl VecTypes {

branches/dist-snap/src/libstd/reference.rs renamed to branches/dist-snap/src/libstd/borrow.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@
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+
1628
// Equality for region pointers
1729
#[cfg(not(test))]
1830
impl<'a, T: Eq> Eq for &'a T {
@@ -59,3 +71,16 @@ impl<'a, T: TotalEq> TotalEq for &'a T {
5971
fn equals(&self, other: & &'a T) -> bool { (**self).equals(*other) }
6072
}
6173

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+
}

branches/dist-snap/src/libstd/lib.rs

Lines changed: 2 additions & 1 deletion
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-
mod reference;
126+
pub mod borrow;
127127
pub mod rc;
128128
pub mod gc;
129129

@@ -223,6 +223,7 @@ mod std {
223223
pub use kinds;
224224
pub use local_data;
225225
pub use logging;
226+
pub use logging;
226227
pub use option;
227228
pub use os;
228229
pub use rt;

branches/dist-snap/src/libstd/rt/task.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
//! to implement this.
1515
1616
use any::AnyOwnExt;
17+
use borrow;
1718
use cast;
1819
use cleanup;
1920
use clone::Clone;
@@ -286,7 +287,7 @@ impl Task {
286287

287288
impl Drop for Task {
288289
fn drop(&mut self) {
289-
rtdebug!("called drop for a task: {}", self as *mut Task as uint);
290+
rtdebug!("called drop for a task: {}", borrow::to_uint(self));
290291
rtassert!(self.destroyed);
291292
}
292293
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2013 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,6 +10,7 @@
1010

1111
#[feature(managed_boxes)];
1212

13+
use std::borrow;
1314
use std::ptr;
1415

1516
fn borrow(x: &int, f: |x: &int|) {
@@ -19,7 +20,7 @@ fn borrow(x: &int, f: |x: &int|) {
1920
fn test1(x: @~int) {
2021
borrow(&*(*x).clone(), |p| {
2122
let x_a = ptr::to_unsafe_ptr(&**x);
22-
assert!((x_a as uint) != (p as *int as uint));
23+
assert!((x_a as uint) != borrow::to_uint(p));
2324
assert_eq!(unsafe{*x_a}, *p);
2425
})
2526
}
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012 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,7 +8,9 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

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

0 commit comments

Comments
 (0)