Skip to content

Commit 239daf6

Browse files
---
yaml --- r: 185599 b: refs/heads/master c: 9e28cae h: refs/heads/master i: 185597: 0035991 185595: 52c896f 185591: 8e4e791 185583: c4f04b9 185567: d76032e 185535: a7b8e16 185471: 9b60322 185343: 0a7bc07 v: v3
1 parent 991eb51 commit 239daf6

File tree

19 files changed

+81
-128
lines changed

19 files changed

+81
-128
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 157614249594f187f421cd97f928e64c5ab5c1fa
2+
refs/heads/master: 9e28caef31de0b36262273be13d29cec80876f77
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 3a96d6a9818fe2affc98a187fb1065120458cee9
55
refs/heads/try: ccf8fedf1cffcb8f6f3581d53d220039e192fe77

trunk/configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ then
875875
| cut -d ' ' -f 2)
876876

877877
case $CFG_CLANG_VERSION in
878-
(3.2* | 3.3* | 3.4* | 3.5* | 3.6*)
878+
(3.0svn | 3.0 | 3.1* | 3.2* | 3.3* | 3.4* | 3.5* | 3.6*)
879879
step_msg "found ok version of CLANG: $CFG_CLANG_VERSION"
880880
if [ -z "$CC" ]
881881
then

trunk/src/libcollections/str.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,9 +1455,9 @@ pub trait StrExt: Index<RangeFull, Output = str> {
14551455
///
14561456
/// `is_cjk` determines behavior for characters in the Ambiguous category: if `is_cjk` is
14571457
/// `true`, these are 2 columns wide; otherwise, they are 1. In CJK locales, `is_cjk` should be
1458-
/// `true`, else it should be `false`.
1459-
/// [Unicode Standard Annex #11](http://www.unicode.org/reports/tr11/) recommends that these
1460-
/// characters be treated as 1 column (i.e., `is_cjk = false`) if the locale is unknown.
1458+
/// `true`, else it should be `false`. [Unicode Standard Annex
1459+
/// #11](http://www.unicode.org/reports/tr11/) recommends that these characters be treated as 1
1460+
/// column (i.e., `is_cjk` = `false`) if the locale is unknown.
14611461
#[unstable(feature = "collections",
14621462
reason = "this functionality may only be provided by libunicode")]
14631463
fn width(&self, is_cjk: bool) -> usize {

trunk/src/libcore/fmt/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ impl Display for char {
700700
impl<T> Pointer for *const T {
701701
fn fmt(&self, f: &mut Formatter) -> Result {
702702
f.flags |= 1 << (FlagV1::Alternate as u32);
703-
let ret = LowerHex::fmt(&(*self as usize), f);
703+
let ret = LowerHex::fmt(&(*self as u32), f);
704704
f.flags &= !(1 << (FlagV1::Alternate as u32));
705705
ret
706706
}

trunk/src/libcore/iter.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ use num::{ToPrimitive, Int};
6868
use ops::{Add, Deref, FnMut};
6969
use option::Option;
7070
use option::Option::{Some, None};
71-
use marker::Sized;
71+
use marker::{Send, Sized, Sync};
7272
use usize;
7373

7474
/// An interface for dealing with "external iterators". These types of iterators
@@ -1783,6 +1783,10 @@ pub struct Peekable<I: Iterator> {
17831783
peeked: Option<I::Item>,
17841784
}
17851785

1786+
// FIXME: after #22828 being fixed, the following unsafe impl should be removed
1787+
unsafe impl<I: Iterator> Sync for Peekable<I> where I: Sync, I::Item: Sync {}
1788+
unsafe impl<I: Iterator> Send for Peekable<I> where I: Send, I::Item: Send {}
1789+
17861790
impl<I: Iterator + Clone> Clone for Peekable<I> where I::Item: Clone {
17871791
fn clone(&self) -> Peekable<I> {
17881792
Peekable {

trunk/src/libcore/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
//! distribution.
4040
//!
4141
//! * `rust_begin_unwind` - This function takes three arguments, a
42-
//! `fmt::Arguments`, a `&str`, and a `uint`. These three arguments dictate
42+
//! `fmt::Arguments`, a `&str`, and a `usize`. These three arguments dictate
4343
//! the panic message, the file at which panic was invoked, and the line.
4444
//! It is up to consumers of this core library to define this panic
4545
//! function; it is only required to never return.
@@ -88,14 +88,12 @@ mod int_macros;
8888
#[macro_use]
8989
mod uint_macros;
9090

91-
#[path = "num/int.rs"] pub mod int;
9291
#[path = "num/isize.rs"] pub mod isize;
9392
#[path = "num/i8.rs"] pub mod i8;
9493
#[path = "num/i16.rs"] pub mod i16;
9594
#[path = "num/i32.rs"] pub mod i32;
9695
#[path = "num/i64.rs"] pub mod i64;
9796

98-
#[path = "num/uint.rs"] pub mod uint;
9997
#[path = "num/usize.rs"] pub mod usize;
10098
#[path = "num/u8.rs"] pub mod u8;
10199
#[path = "num/u16.rs"] pub mod u16;

trunk/src/libcore/num/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,10 +372,9 @@ pub trait Int
372372
#[unstable(feature = "core",
373373
reason = "pending integer conventions")]
374374
#[inline]
375-
fn pow(self, mut exp: u32) -> Self {
375+
fn pow(self, mut exp: uint) -> Self {
376376
let mut base = self;
377377
let mut acc: Self = Int::one();
378-
379378
while exp > 0 {
380379
if (exp & 1) == 1 {
381380
acc = acc * base;

trunk/src/libcoretest/num/int_macros.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -201,17 +201,6 @@ mod tests {
201201
assert_eq!(FromStrRadix::from_str_radix("Z", 35).ok(), None::<$T>);
202202
assert_eq!(FromStrRadix::from_str_radix("-9", 2).ok(), None::<$T>);
203203
}
204-
205-
#[test]
206-
fn test_pow() {
207-
let mut r = 2 as $T;
208-
209-
assert_eq!(r.pow(2u32), 4 as $T);
210-
assert_eq!(r.pow(0u32), 1 as $T);
211-
r = -2 as $T;
212-
assert_eq!(r.pow(2u32), 4 as $T);
213-
assert_eq!(r.pow(3u32), -8 as $T);
214-
}
215204
}
216205

217206
)}

trunk/src/librbml/lib.rs

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,11 @@ pub mod reader {
132132
use std::char;
133133

134134
use std::isize;
135+
use std::old_io::extensions::u64_from_be_bytes;
135136
use std::mem::transmute;
136137
use std::num::Int;
137-
use std::slice::bytes;
138+
use std::option::Option;
139+
use std::option::Option::{None, Some};
138140

139141
use serialize;
140142

@@ -197,24 +199,20 @@ pub mod reader {
197199
return vuint_at_slow(data, start);
198200
}
199201

200-
// Lookup table for parsing EBML Element IDs as per
201-
// http://ebml.sourceforge.net/specs/ The Element IDs are parsed by
202-
// reading a big endian u32 positioned at data[start]. Using the four
203-
// most significant bits of the u32 we lookup in the table below how
204-
// the element ID should be derived from it.
202+
// Lookup table for parsing EBML Element IDs as per http://ebml.sourceforge.net/specs/
203+
// The Element IDs are parsed by reading a big endian u32 positioned at data[start].
204+
// Using the four most significant bits of the u32 we lookup in the table below how the
205+
// element ID should be derived from it.
205206
//
206-
// The table stores tuples (shift, mask) where shift is the number the
207-
// u32 should be right shifted with and mask is the value the right
208-
// shifted value should be masked with. If for example the most
209-
// significant bit is set this means it's a class A ID and the u32
210-
// should be right shifted with 24 and masked with 0x7f. Therefore we
211-
// store (24, 0x7f) at index 0x8 - 0xF (four bit numbers where the most
212-
// significant bit is set).
207+
// The table stores tuples (shift, mask) where shift is the number the u32 should be right
208+
// shifted with and mask is the value the right shifted value should be masked with.
209+
// If for example the most significant bit is set this means it's a class A ID and the u32
210+
// should be right shifted with 24 and masked with 0x7f. Therefore we store (24, 0x7f) at
211+
// index 0x8 - 0xF (four bit numbers where the most significant bit is set).
213212
//
214-
// By storing the number of shifts and masks in a table instead of
215-
// checking in order if the most significant bit is set, the second
216-
// most significant bit is set etc. we can replace up to three
217-
// "and+branch" with a single table lookup which gives us a measured
213+
// By storing the number of shifts and masks in a table instead of checking in order if
214+
// the most significant bit is set, the second most significant bit is set etc. we can
215+
// replace up to three "and+branch" with a single table lookup which gives us a measured
218216
// speedup of around 2x on x86_64.
219217
static SHIFT_MASK_TABLE: [(uint, u32); 16] = [
220218
(0, 0x0), (0, 0x0fffffff),
@@ -320,23 +318,17 @@ pub mod reader {
320318

321319
pub fn doc_as_u16(d: Doc) -> u16 {
322320
assert_eq!(d.end, d.start + 2);
323-
let mut b = [0; 2];
324-
bytes::copy_memory(&mut b, &d.data[d.start..d.end]);
325-
unsafe { (*(b.as_ptr() as *const u16)).to_be() }
321+
u64_from_be_bytes(d.data, d.start, 2) as u16
326322
}
327323

328324
pub fn doc_as_u32(d: Doc) -> u32 {
329325
assert_eq!(d.end, d.start + 4);
330-
let mut b = [0; 4];
331-
bytes::copy_memory(&mut b, &d.data[d.start..d.end]);
332-
unsafe { (*(b.as_ptr() as *const u32)).to_be() }
326+
u64_from_be_bytes(d.data, d.start, 4) as u32
333327
}
334328

335329
pub fn doc_as_u64(d: Doc) -> u64 {
336330
assert_eq!(d.end, d.start + 8);
337-
let mut b = [0; 8];
338-
bytes::copy_memory(&mut b, &d.data[d.start..d.end]);
339-
unsafe { (*(b.as_ptr() as *const u64)).to_be() }
331+
u64_from_be_bytes(d.data, d.start, 8)
340332
}
341333

342334
pub fn doc_as_i8(d: Doc) -> i8 { doc_as_u8(d) as i8 }
@@ -697,10 +689,11 @@ pub mod reader {
697689
}
698690

699691
pub mod writer {
700-
use std::mem;
701-
use std::num::Int;
692+
use std::clone::Clone;
693+
use std::old_io::extensions::u64_to_be_bytes;
702694
use std::old_io::{Writer, Seek};
703695
use std::old_io;
696+
use std::mem;
704697

705698
use super::{ EsVec, EsMap, EsEnum, EsVecLen, EsVecElt, EsMapLen, EsMapKey,
706699
EsEnumVid, EsU64, EsU32, EsU16, EsU8, EsInt, EsI64, EsI32, EsI16, EsI8,
@@ -801,34 +794,43 @@ pub mod writer {
801794
}
802795

803796
pub fn wr_tagged_u64(&mut self, tag_id: uint, v: u64) -> EncodeResult {
804-
let bytes: [u8; 8] = unsafe { mem::transmute(v.to_be()) };
805-
self.wr_tagged_bytes(tag_id, &bytes)
797+
u64_to_be_bytes(v, 8, |v| {
798+
self.wr_tagged_bytes(tag_id, v)
799+
})
806800
}
807801

808802
pub fn wr_tagged_u32(&mut self, tag_id: uint, v: u32) -> EncodeResult{
809-
let bytes: [u8; 4] = unsafe { mem::transmute(v.to_be()) };
810-
self.wr_tagged_bytes(tag_id, &bytes)
803+
u64_to_be_bytes(v as u64, 4, |v| {
804+
self.wr_tagged_bytes(tag_id, v)
805+
})
811806
}
812807

813808
pub fn wr_tagged_u16(&mut self, tag_id: uint, v: u16) -> EncodeResult {
814-
let bytes: [u8; 2] = unsafe { mem::transmute(v.to_be()) };
815-
self.wr_tagged_bytes(tag_id, &bytes)
809+
u64_to_be_bytes(v as u64, 2, |v| {
810+
self.wr_tagged_bytes(tag_id, v)
811+
})
816812
}
817813

818814
pub fn wr_tagged_u8(&mut self, tag_id: uint, v: u8) -> EncodeResult {
819815
self.wr_tagged_bytes(tag_id, &[v])
820816
}
821817

822818
pub fn wr_tagged_i64(&mut self, tag_id: uint, v: i64) -> EncodeResult {
823-
self.wr_tagged_u64(tag_id, v as u64)
819+
u64_to_be_bytes(v as u64, 8, |v| {
820+
self.wr_tagged_bytes(tag_id, v)
821+
})
824822
}
825823

826824
pub fn wr_tagged_i32(&mut self, tag_id: uint, v: i32) -> EncodeResult {
827-
self.wr_tagged_u32(tag_id, v as u32)
825+
u64_to_be_bytes(v as u64, 4, |v| {
826+
self.wr_tagged_bytes(tag_id, v)
827+
})
828828
}
829829

830830
pub fn wr_tagged_i16(&mut self, tag_id: uint, v: i16) -> EncodeResult {
831-
self.wr_tagged_u16(tag_id, v as u16)
831+
u64_to_be_bytes(v as u64, 2, |v| {
832+
self.wr_tagged_bytes(tag_id, v)
833+
})
832834
}
833835

834836
pub fn wr_tagged_i8(&mut self, tag_id: uint, v: i8) -> EncodeResult {

trunk/src/librustc/metadata/decoder.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,10 @@ use middle::astencode::vtable_decoder_helpers;
3434

3535
use std::collections::HashMap;
3636
use std::hash::{self, Hash, SipHasher};
37-
use std::num::FromPrimitive;
38-
use std::num::Int;
37+
use std::old_io::extensions::u64_from_be_bytes;
3938
use std::old_io;
39+
use std::num::FromPrimitive;
4040
use std::rc::Rc;
41-
use std::slice::bytes;
4241
use std::str;
4342

4443
use rbml::reader;
@@ -61,26 +60,20 @@ pub type Cmd<'a> = &'a crate_metadata;
6160
// what crate that's in and give us a def_id that makes sense for the current
6261
// build.
6362

64-
fn u32_from_be_bytes(bytes: &[u8]) -> u32 {
65-
let mut b = [0; 4];
66-
bytes::copy_memory(&mut b, &bytes[..4]);
67-
unsafe { (*(b.as_ptr() as *const u32)).to_be() }
68-
}
69-
7063
fn lookup_hash<'a, F>(d: rbml::Doc<'a>, mut eq_fn: F, hash: u64) -> Option<rbml::Doc<'a>> where
7164
F: FnMut(&[u8]) -> bool,
7265
{
7366
let index = reader::get_doc(d, tag_index);
7467
let table = reader::get_doc(index, tag_index_table);
7568
let hash_pos = table.start + (hash % 256 * 4) as uint;
76-
let pos = u32_from_be_bytes(&d.data[hash_pos..]) as uint;
69+
let pos = u64_from_be_bytes(d.data, hash_pos, 4) as uint;
7770
let tagged_doc = reader::doc_at(d.data, pos).unwrap();
7871

7972
let belt = tag_index_buckets_bucket_elt;
8073

8174
let mut ret = None;
8275
reader::tagged_docs(tagged_doc.doc, belt, |elt| {
83-
let pos = u32_from_be_bytes(&elt.data[elt.start..]) as uint;
76+
let pos = u64_from_be_bytes(elt.data, elt.start, 4) as uint;
8477
if eq_fn(&elt.data[elt.start + 4 .. elt.end]) {
8578
ret = Some(reader::doc_at(d.data, pos).unwrap().doc);
8679
false
@@ -94,7 +87,9 @@ fn lookup_hash<'a, F>(d: rbml::Doc<'a>, mut eq_fn: F, hash: u64) -> Option<rbml:
9487
pub fn maybe_find_item<'a>(item_id: ast::NodeId,
9588
items: rbml::Doc<'a>) -> Option<rbml::Doc<'a>> {
9689
fn eq_item(bytes: &[u8], item_id: ast::NodeId) -> bool {
97-
u32_from_be_bytes(bytes) == item_id
90+
return u64_from_be_bytes(
91+
&bytes[0..4], 0, 4) as ast::NodeId
92+
== item_id;
9893
}
9994
lookup_hash(items,
10095
|a| eq_item(a, item_id),

trunk/src/librustc_trans/back/write.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -851,9 +851,7 @@ pub fn run_passes(sess: &Session,
851851

852852
// FIXME: time_llvm_passes support - does this use a global context or
853853
// something?
854-
if sess.opts.cg.codegen_units == 1 && sess.time_llvm_passes() {
855-
unsafe { llvm::LLVMRustPrintPassTimings(); }
856-
}
854+
//if sess.time_llvm_passes() { llvm::LLVMRustPrintPassTimings(); }
857855
}
858856

859857
struct WorkItem {

trunk/src/librustc_trans/trans/base.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -433,13 +433,13 @@ pub fn set_inline_hint(f: ValueRef) {
433433
}
434434

435435
pub fn set_llvm_fn_attrs(ccx: &CrateContext, attrs: &[ast::Attribute], llfn: ValueRef) {
436-
use syntax::attr::{find_inline_attr, InlineAttr};
436+
use syntax::attr::*;
437437
// Set the inline hint if there is one
438438
match find_inline_attr(Some(ccx.sess().diagnostic()), attrs) {
439-
InlineAttr::Hint => set_inline_hint(llfn),
440-
InlineAttr::Always => set_always_inline(llfn),
441-
InlineAttr::Never => set_no_inline(llfn),
442-
InlineAttr::None => { /* fallthrough */ }
439+
InlineHint => set_inline_hint(llfn),
440+
InlineAlways => set_always_inline(llfn),
441+
InlineNever => set_no_inline(llfn),
442+
InlineNone => { /* fallthrough */ }
443443
}
444444

445445
for attr in attrs {
@@ -2332,11 +2332,6 @@ pub fn trans_item(ccx: &CrateContext, item: &ast::Item) {
23322332
// Do static_assert checking. It can't really be done much earlier
23332333
// because we need to get the value of the bool out of LLVM
23342334
if attr::contains_name(&item.attrs, "static_assert") {
2335-
if !ty::type_is_bool(ty::expr_ty(ccx.tcx(), expr)) {
2336-
ccx.sess().span_fatal(expr.span,
2337-
"can only have static_assert on a static \
2338-
with type `bool`");
2339-
}
23402335
if m == ast::MutMutable {
23412336
ccx.sess().span_fatal(expr.span,
23422337
"cannot have static_assert on a mutable \

trunk/src/libstd/num/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1830,6 +1830,6 @@ mod bench {
18301830
#[bench]
18311831
fn bench_pow_function(b: &mut Bencher) {
18321832
let v = (0..1024).collect::<Vec<_>>();
1833-
b.iter(|| {v.iter().fold(0, |old, new| old.pow(*new as u32));});
1833+
b.iter(|| {v.iter().fold(0, |old, new| old.pow(*new));});
18341834
}
18351835
}

trunk/src/libstd/old_io/extensions.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
//! Utility mixins that apply to all Readers and Writers
1212
1313
#![allow(missing_docs)]
14-
#![unstable(feature = "old_io")]
15-
#![deprecated(since = "1.0.0",
16-
reason = "functionality will be removed with no immediate \
17-
replacement")]
1814

1915
// FIXME: Not sure how this should be structured
2016
// FIXME: Iteration should probably be considered separately

trunk/src/libstd/sys/unix/thread.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ pub mod guard {
164164

165165
if pthread_main_np() == 1 {
166166
// main thread
167-
current_stack.ss_sp as uint - current_stack.ss_size as uint + PAGE_SIZE as uint
167+
current_stack.ss_sp as uint - current_stack.ss_size as uint + 3 * PAGE_SIZE as uint
168168

169169
} else {
170170
// new thread

0 commit comments

Comments
 (0)