Skip to content

Commit 26a47b2

Browse files
committed
---
yaml --- r: 188119 b: refs/heads/try c: fb19cd7 h: refs/heads/master i: 188117: 27d359a 188115: 8a94192 188111: fcc3bde v: v3
1 parent 81b792d commit 26a47b2

File tree

18 files changed

+125
-80
lines changed

18 files changed

+125
-80
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 38e97b99a6b133cb4c621c68e75b28abc6c617c1
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 3a96d6a9818fe2affc98a187fb1065120458cee9
5-
refs/heads/try: df126589b91c7b60e2426b46c5a8b14d7d04f667
5+
refs/heads/try: fb19cd7fb775fee1afb315525dcdc82472796337
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/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.0svn | 3.0 | 3.1* | 3.2* | 3.3* | 3.4* | 3.5* | 3.6*)
878+
(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

branches/try/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`. [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.
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.
14611461
#[unstable(feature = "collections",
14621462
reason = "this functionality may only be provided by libunicode")]
14631463
fn width(&self, is_cjk: bool) -> usize {

branches/try/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 u32), f);
703+
let ret = LowerHex::fmt(&(*self as usize), f);
704704
f.flags &= !(1 << (FlagV1::Alternate as u32));
705705
ret
706706
}

branches/try/src/libcore/iter.rs

Lines changed: 1 addition & 5 deletions
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::{Send, Sized, Sync};
71+
use marker::Sized;
7272
use usize;
7373

7474
/// An interface for dealing with "external iterators". These types of iterators
@@ -1783,10 +1783,6 @@ 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-
17901786
impl<I: Iterator + Clone> Clone for Peekable<I> where I::Item: Clone {
17911787
fn clone(&self) -> Peekable<I> {
17921788
Peekable {

branches/try/src/libcore/num/mod.rs

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

branches/try/src/libcoretest/num/int_macros.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,17 @@ 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+
}
204215
}
205216

206217
)}

branches/try/src/librbml/lib.rs

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

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

141139
use serialize;
142140

@@ -199,20 +197,24 @@ pub mod reader {
199197
return vuint_at_slow(data, start);
200198
}
201199

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.
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.
206205
//
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).
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).
212213
//
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
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
216218
// speedup of around 2x on x86_64.
217219
static SHIFT_MASK_TABLE: [(uint, u32); 16] = [
218220
(0, 0x0), (0, 0x0fffffff),
@@ -318,17 +320,23 @@ pub mod reader {
318320

319321
pub fn doc_as_u16(d: Doc) -> u16 {
320322
assert_eq!(d.end, d.start + 2);
321-
u64_from_be_bytes(d.data, d.start, 2) as u16
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() }
322326
}
323327

324328
pub fn doc_as_u32(d: Doc) -> u32 {
325329
assert_eq!(d.end, d.start + 4);
326-
u64_from_be_bytes(d.data, d.start, 4) as u32
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() }
327333
}
328334

329335
pub fn doc_as_u64(d: Doc) -> u64 {
330336
assert_eq!(d.end, d.start + 8);
331-
u64_from_be_bytes(d.data, 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() }
332340
}
333341

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

691699
pub mod writer {
692-
use std::clone::Clone;
693-
use std::old_io::extensions::u64_to_be_bytes;
700+
use std::mem;
701+
use std::num::Int;
694702
use std::old_io::{Writer, Seek};
695703
use std::old_io;
696-
use std::mem;
697704

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

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

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

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

814818
pub fn wr_tagged_u8(&mut self, tag_id: uint, v: u8) -> EncodeResult {
815819
self.wr_tagged_bytes(tag_id, &[v])
816820
}
817821

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

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

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

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

branches/try/src/librustc/metadata/decoder.rs

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

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

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

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+
6370
fn lookup_hash<'a, F>(d: rbml::Doc<'a>, mut eq_fn: F, hash: u64) -> Option<rbml::Doc<'a>> where
6471
F: FnMut(&[u8]) -> bool,
6572
{
6673
let index = reader::get_doc(d, tag_index);
6774
let table = reader::get_doc(index, tag_index_table);
6875
let hash_pos = table.start + (hash % 256 * 4) as uint;
69-
let pos = u64_from_be_bytes(d.data, hash_pos, 4) as uint;
76+
let pos = u32_from_be_bytes(&d.data[hash_pos..]) as uint;
7077
let tagged_doc = reader::doc_at(d.data, pos).unwrap();
7178

7279
let belt = tag_index_buckets_bucket_elt;
7380

7481
let mut ret = None;
7582
reader::tagged_docs(tagged_doc.doc, belt, |elt| {
76-
let pos = u64_from_be_bytes(elt.data, elt.start, 4) as uint;
83+
let pos = u32_from_be_bytes(&elt.data[elt.start..]) as uint;
7784
if eq_fn(&elt.data[elt.start + 4 .. elt.end]) {
7885
ret = Some(reader::doc_at(d.data, pos).unwrap().doc);
7986
false
@@ -87,9 +94,7 @@ fn lookup_hash<'a, F>(d: rbml::Doc<'a>, mut eq_fn: F, hash: u64) -> Option<rbml:
8794
pub fn maybe_find_item<'a>(item_id: ast::NodeId,
8895
items: rbml::Doc<'a>) -> Option<rbml::Doc<'a>> {
8996
fn eq_item(bytes: &[u8], item_id: ast::NodeId) -> bool {
90-
return u64_from_be_bytes(
91-
&bytes[0..4], 0, 4) as ast::NodeId
92-
== item_id;
97+
u32_from_be_bytes(bytes) == item_id
9398
}
9499
lookup_hash(items,
95100
|a| eq_item(a, item_id),

branches/try/src/librustc_trans/back/write.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,9 @@ 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.time_llvm_passes() { llvm::LLVMRustPrintPassTimings(); }
854+
if sess.opts.cg.codegen_units == 1 && sess.time_llvm_passes() {
855+
unsafe { llvm::LLVMRustPrintPassTimings(); }
856+
}
855857
}
856858

857859
struct WorkItem {

branches/try/src/librustc_trans/trans/base.rs

Lines changed: 10 additions & 5 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::*;
436+
use syntax::attr::{find_inline_attr, InlineAttr};
437437
// Set the inline hint if there is one
438438
match find_inline_attr(Some(ccx.sess().diagnostic()), attrs) {
439-
InlineHint => set_inline_hint(llfn),
440-
InlineAlways => set_always_inline(llfn),
441-
InlineNever => set_no_inline(llfn),
442-
InlineNone => { /* fallthrough */ }
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 */ }
443443
}
444444

445445
for attr in attrs {
@@ -2332,6 +2332,11 @@ 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+
}
23352340
if m == ast::MutMutable {
23362341
ccx.sess().span_fatal(expr.span,
23372342
"cannot have static_assert on a mutable \

branches/try/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));});
1833+
b.iter(|| {v.iter().fold(0, |old, new| old.pow(*new as u32));});
18341834
}
18351835
}

branches/try/src/libstd/old_io/extensions.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
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")]
1418

1519
// FIXME: Not sure how this should be structured
1620
// FIXME: Iteration should probably be considered separately

branches/try/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 + 3 * PAGE_SIZE as uint
167+
current_stack.ss_sp as uint - current_stack.ss_size as uint + PAGE_SIZE as uint
168168

169169
} else {
170170
// new thread

0 commit comments

Comments
 (0)