Skip to content

Commit b8e0d30

Browse files
committed
---
yaml --- r: 188343 b: refs/heads/master c: 129173f h: refs/heads/master i: 188341: 7942ca5 188339: 8cd1cfd 188335: 935335c v: v3
1 parent f272e45 commit b8e0d30

File tree

134 files changed

+1875
-890
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+1875
-890
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: 62aa899e3df026086723773775e704862b710f24
2+
refs/heads/master: 129173f1980e9ac03f7ef0fc0193c41235d07649
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 3a96d6a9818fe2affc98a187fb1065120458cee9
55
refs/heads/try: 649d35e4d830b27806705dc5352c86ab6d6fd1a1

trunk/src/compiletest/runtest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ fn run_rfail_test(config: &Config, props: &TestProps, testfile: &Path) {
127127
};
128128

129129
// The value our Makefile configures valgrind to return on failure
130-
static VALGRIND_ERR: int = 100;
130+
const VALGRIND_ERR: int = 100;
131131
if proc_res.status.matches_exit_status(VALGRIND_ERR) {
132132
fatal_proc_rec("run-fail test isn't valgrind-clean!", &proc_res);
133133
}
@@ -139,7 +139,7 @@ fn run_rfail_test(config: &Config, props: &TestProps, testfile: &Path) {
139139

140140
fn check_correct_failure_status(proc_res: &ProcRes) {
141141
// The value the rust runtime returns on failure
142-
static RUST_ERR: int = 101;
142+
const RUST_ERR: int = 101;
143143
if !proc_res.status.matches_exit_status(RUST_ERR) {
144144
fatal_proc_rec(
145145
&format!("failure produced the wrong error: {:?}",

trunk/src/compiletest/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use common::Config;
1414
use std::env;
1515

1616
/// Conversion table from triple OS name to Rust SYSNAME
17-
static OS_TABLE: &'static [(&'static str, &'static str)] = &[
17+
const OS_TABLE: &'static [(&'static str, &'static str)] = &[
1818
("mingw32", "windows"),
1919
("win32", "windows"),
2020
("windows", "windows"),

trunk/src/doc/reference.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2495,6 +2495,12 @@ The currently implemented features of the reference compiler are:
24952495

24962496
* `staged_api` - Allows usage of stability markers and `#![staged_api]` in a crate
24972497

2498+
* `static_assert` - The `#[static_assert]` functionality is experimental and
2499+
unstable. The attribute can be attached to a `static` of
2500+
type `bool` and the compiler will error if the `bool` is
2501+
`false` at compile time. This version of this functionality
2502+
is unintuitive and suboptimal.
2503+
24982504
* `start` - Allows use of the `#[start]` attribute, which changes the entry point
24992505
into a Rust program. This capabiilty, especially the signature for the
25002506
annotated function, is subject to change.

trunk/src/etc/unicode.py

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,11 @@ def emit_bsearch_range_table(f):
290290
fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool {
291291
use core::cmp::Ordering::{Equal, Less, Greater};
292292
use core::slice::SliceExt;
293-
r.binary_search(|&(lo,hi)| {
293+
r.binary_search_by(|&(lo,hi)| {
294294
if lo <= c && c <= hi { Equal }
295295
else if hi < c { Less }
296296
else { Greater }
297-
}).found().is_some()
297+
}).is_ok()
298298
}\n
299299
""")
300300

@@ -303,7 +303,7 @@ def emit_table(f, name, t_data, t_type = "&'static [(char, char)]", is_pub=True,
303303
pub_string = ""
304304
if is_pub:
305305
pub_string = "pub "
306-
f.write(" %sstatic %s: %s = &[\n" % (pub_string, name, t_type))
306+
f.write(" %sconst %s: %s = &[\n" % (pub_string, name, t_type))
307307
data = ""
308308
first = True
309309
for dat in t_data:
@@ -329,14 +329,14 @@ def emit_property_module(f, mod, tbl, emit_fn):
329329
def emit_regex_module(f, cats, w_data):
330330
f.write("pub mod regex {\n")
331331
regex_class = "&'static [(char, char)]"
332-
class_table = "&'static [(&'static str, &'static %s)]" % regex_class
332+
class_table = "&'static [(&'static str, %s)]" % regex_class
333333

334334
emit_table(f, "UNICODE_CLASSES", cats, class_table,
335-
pfun=lambda x: "(\"%s\",&super::%s::%s_table)" % (x[0], x[1], x[0]))
335+
pfun=lambda x: "(\"%s\",super::%s::%s_table)" % (x[0], x[1], x[0]))
336336

337-
f.write(" pub static PERLD: &'static %s = &super::general_category::Nd_table;\n\n"
337+
f.write(" pub const PERLD: %s = super::general_category::Nd_table;\n\n"
338338
% regex_class)
339-
f.write(" pub static PERLS: &'static %s = &super::property::White_Space_table;\n\n"
339+
f.write(" pub const PERLS: %s = super::property::White_Space_table;\n\n"
340340
% regex_class)
341341

342342
emit_table(f, "PERLW", w_data, regex_class)
@@ -350,7 +350,7 @@ def emit_conversions_module(f, lowerupper, upperlower):
350350
use core::slice::SliceExt;
351351
use core::option::Option;
352352
use core::option::Option::{Some, None};
353-
use core::slice;
353+
use core::result::Result::{Ok, Err};
354354
355355
pub fn to_lower(c: char) -> char {
356356
match bsearch_case_table(c, LuLl_table) {
@@ -367,13 +367,13 @@ def emit_conversions_module(f, lowerupper, upperlower):
367367
}
368368
369369
fn bsearch_case_table(c: char, table: &'static [(char, char)]) -> Option<usize> {
370-
match table.binary_search(|&(key, _)| {
370+
match table.binary_search_by(|&(key, _)| {
371371
if c == key { Equal }
372372
else if key < c { Less }
373373
else { Greater }
374374
}) {
375-
slice::BinarySearchResult::Found(i) => Some(i),
376-
slice::BinarySearchResult::NotFound(_) => None,
375+
Ok(i) => Some(i),
376+
Err(_) => None,
377377
}
378378
}
379379
@@ -386,10 +386,9 @@ def emit_conversions_module(f, lowerupper, upperlower):
386386

387387
def emit_grapheme_module(f, grapheme_table, grapheme_cats):
388388
f.write("""pub mod grapheme {
389-
use core::kinds::Copy;
390389
use core::slice::SliceExt;
391390
pub use self::GraphemeCat::*;
392-
use core::slice;
391+
use core::result::Result::{Ok, Err};
393392
394393
#[allow(non_camel_case_types)]
395394
#[derive(Clone, Copy)]
@@ -401,16 +400,16 @@ def emit_grapheme_module(f, grapheme_table, grapheme_cats):
401400
402401
fn bsearch_range_value_table(c: char, r: &'static [(char, char, GraphemeCat)]) -> GraphemeCat {
403402
use core::cmp::Ordering::{Equal, Less, Greater};
404-
match r.binary_search(|&(lo, hi, _)| {
403+
match r.binary_search_by(|&(lo, hi, _)| {
405404
if lo <= c && c <= hi { Equal }
406405
else if hi < c { Less }
407406
else { Greater }
408407
}) {
409-
slice::BinarySearchResult::Found(idx) => {
408+
Ok(idx) => {
410409
let (_, _, cat) = r[idx];
411410
cat
412411
}
413-
slice::BinarySearchResult::NotFound(_) => GC_Any
412+
Err(_) => GC_Any
414413
}
415414
}
416415
@@ -430,20 +429,20 @@ def emit_charwidth_module(f, width_table):
430429
f.write(" use core::option::Option;\n")
431430
f.write(" use core::option::Option::{Some, None};\n")
432431
f.write(" use core::slice::SliceExt;\n")
433-
f.write(" use core::slice;\n")
432+
f.write(" use core::result::Result::{Ok, Err};\n")
434433
f.write("""
435434
fn bsearch_range_value_table(c: char, is_cjk: bool, r: &'static [(char, char, u8, u8)]) -> u8 {
436435
use core::cmp::Ordering::{Equal, Less, Greater};
437-
match r.binary_search(|&(lo, hi, _, _)| {
436+
match r.binary_search_by(|&(lo, hi, _, _)| {
438437
if lo <= c && c <= hi { Equal }
439438
else if hi < c { Less }
440439
else { Greater }
441440
}) {
442-
slice::BinarySearchResult::Found(idx) => {
441+
Ok(idx) => {
443442
let (_, _, r_ncjk, r_cjk) = r[idx];
444443
if is_cjk { r_cjk } else { r_ncjk }
445444
}
446-
slice::BinarySearchResult::NotFound(_) => 1
445+
Err(_) => 1
447446
}
448447
}
449448
""")
@@ -530,17 +529,17 @@ def comp_pfun(char):
530529
fn bsearch_range_value_table(c: char, r: &'static [(char, char, u8)]) -> u8 {
531530
use core::cmp::Ordering::{Equal, Less, Greater};
532531
use core::slice::SliceExt;
533-
use core::slice;
534-
match r.binary_search(|&(lo, hi, _)| {
532+
use core::result::Result::{Ok, Err};
533+
match r.binary_search_by(|&(lo, hi, _)| {
535534
if lo <= c && c <= hi { Equal }
536535
else if hi < c { Less }
537536
else { Greater }
538537
}) {
539-
slice::BinarySearchResult::Found(idx) => {
538+
Ok(idx) => {
540539
let (_, _, result) = r[idx];
541540
result
542541
}
543-
slice::BinarySearchResult::NotFound(_) => 0
542+
Err(_) => 0
544543
}
545544
}\n
546545
""")
@@ -609,7 +608,7 @@ def optimize_width_table(wtable):
609608
unicode_version = re.search(pattern, readme.read()).groups()
610609
rf.write("""
611610
/// The version of [Unicode](http://www.unicode.org/)
612-
/// that the `UnicodeChar` and `UnicodeStrPrelude` traits are based on.
611+
/// that the unicode parts of `CharExt` and `UnicodeStrPrelude` traits are based on.
613612
pub const UNICODE_VERSION: (u64, u64, u64) = (%s, %s, %s);
614613
""" % unicode_version)
615614
(canon_decomp, compat_decomp, gencats, combines,

trunk/src/libcollections/bit.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -818,19 +818,19 @@ impl BitVec {
818818
let full_value = if value { !0 } else { 0 };
819819

820820
// Correct the old tail word, setting or clearing formerly unused bits
821-
let old_last_word = blocks_for_bits(self.nbits) - 1;
821+
let num_cur_blocks = blocks_for_bits(self.nbits);
822822
if self.nbits % u32::BITS as usize > 0 {
823823
let mask = mask_for_bits(self.nbits);
824824
if value {
825-
self.storage[old_last_word] |= !mask;
825+
self.storage[num_cur_blocks - 1] |= !mask;
826826
} else {
827827
// Extra bits are already zero by invariant.
828828
}
829829
}
830830

831831
// Fill in words after the old tail word
832832
let stop_idx = cmp::min(self.storage.len(), new_nblocks);
833-
for idx in old_last_word + 1..stop_idx {
833+
for idx in num_cur_blocks..stop_idx {
834834
self.storage[idx] = full_value;
835835
}
836836

@@ -2544,7 +2544,7 @@ mod bit_vec_bench {
25442544

25452545
use super::BitVec;
25462546

2547-
static BENCH_BITS : usize = 1 << 14;
2547+
const BENCH_BITS : usize = 1 << 14;
25482548

25492549
fn rng() -> rand::IsaacRng {
25502550
let seed: &[_] = &[1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
@@ -3039,7 +3039,7 @@ mod bit_set_bench {
30393039

30403040
use super::{BitVec, BitSet};
30413041

3042-
static BENCH_BITS : usize = 1 << 14;
3042+
const BENCH_BITS : usize = 1 << 14;
30433043

30443044
fn rng() -> rand::IsaacRng {
30453045
let seed: &[_] = &[1, 2, 3, 4, 5, 6, 7, 8, 9, 0];

trunk/src/libcollections/btree/map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use core::fmt::Debug;
2525
use core::hash::{Hash, Hasher};
2626
use core::iter::{Map, FromIterator, IntoIterator};
2727
use core::ops::{Index, IndexMut};
28-
use core::{iter, fmt, mem};
28+
use core::{iter, fmt, mem, usize};
2929
use Bound::{self, Included, Excluded, Unbounded};
3030

3131
use borrow::Borrow;
@@ -1467,7 +1467,7 @@ macro_rules! range_impl {
14671467
$Range {
14681468
inner: AbsIter {
14691469
traversals: traversals,
1470-
size: 0, // unused
1470+
size: usize::MAX, // unused
14711471
}
14721472
}
14731473
}

trunk/src/libcollections/btree/node.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,8 @@ impl<K, V> Node<K, V> {
12151215
ptr::copy(
12161216
self.edges_mut().as_mut_ptr().offset(index as isize),
12171217
self.edges().as_ptr().offset(index as isize + 1),
1218-
self.len() - index + 1
1218+
// index can be == len+1, so do the +1 first to avoid underflow.
1219+
(self.len() + 1) - index
12191220
);
12201221

12211222
edge

trunk/src/libcollections/slice.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ use core::iter::{range_step, MultiplicativeIterator};
9696
use core::marker::Sized;
9797
use core::mem::size_of;
9898
use core::mem;
99+
use core::num::wrapping::WrappingOps;
99100
use core::ops::FnMut;
100101
use core::option::Option::{self, Some, None};
101102
use core::ptr::PtrExt;
@@ -1209,18 +1210,22 @@ struct SizeDirection {
12091210
impl Iterator for ElementSwaps {
12101211
type Item = (usize, usize);
12111212

1212-
#[inline]
1213+
// #[inline]
12131214
fn next(&mut self) -> Option<(usize, usize)> {
1215+
fn new_pos_wrapping(i: usize, s: Direction) -> usize {
1216+
i.wrapping_add(match s { Pos => 1, Neg => -1 })
1217+
}
1218+
12141219
fn new_pos(i: usize, s: Direction) -> usize {
1215-
i + match s { Pos => 1, Neg => -1 }
1220+
match s { Pos => i + 1, Neg => i - 1 }
12161221
}
12171222

12181223
// Find the index of the largest mobile element:
12191224
// The direction should point into the vector, and the
12201225
// swap should be with a smaller `size` element.
12211226
let max = self.sdir.iter().cloned().enumerate()
12221227
.filter(|&(i, sd)|
1223-
new_pos(i, sd.dir) < self.sdir.len() &&
1228+
new_pos_wrapping(i, sd.dir) < self.sdir.len() &&
12241229
self.sdir[new_pos(i, sd.dir)].size < sd.size)
12251230
.max_by(|&(_, sd)| sd.size);
12261231
match max {
@@ -1343,8 +1348,8 @@ fn insertion_sort<T, F>(v: &mut [T], mut compare: F) where F: FnMut(&T, &T) -> O
13431348

13441349
fn merge_sort<T, F>(v: &mut [T], mut compare: F) where F: FnMut(&T, &T) -> Ordering {
13451350
// warning: this wildly uses unsafe.
1346-
static BASE_INSERTION: usize = 32;
1347-
static LARGE_INSERTION: usize = 16;
1351+
const BASE_INSERTION: usize = 32;
1352+
const LARGE_INSERTION: usize = 16;
13481353

13491354
// FIXME #12092: smaller insertion runs seems to make sorting
13501355
// vectors of large elements a little faster on some platforms,

trunk/src/libcollections/str.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,7 @@ pub trait StrExt: Index<RangeFull, Output = str> {
756756
/// ```
757757
#[unstable(feature = "collections")]
758758
#[deprecated(since = "1.0.0", reason = "use `split()` with a `&str`")]
759+
#[allow(deprecated) /* for SplitStr */]
759760
fn split_str<'a, P: Pattern<'a>>(&'a self, pat: P) -> SplitStr<'a, P> {
760761
core_str::StrExt::split_str(&self[..], pat)
761762
}

trunk/src/libcollections/string.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ impl String {
153153
}
154154
}
155155

156-
static TAG_CONT_U8: u8 = 128u8;
157-
static REPLACEMENT: &'static [u8] = b"\xEF\xBF\xBD"; // U+FFFD in UTF-8
156+
const TAG_CONT_U8: u8 = 128u8;
157+
const REPLACEMENT: &'static [u8] = b"\xEF\xBF\xBD"; // U+FFFD in UTF-8
158158
let total = v.len();
159159
fn unsafe_get(xs: &[u8], i: usize) -> u8 {
160160
unsafe { *xs.get_unchecked(i) }

trunk/src/libcollections/vec.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,9 +1499,9 @@ impl<T> Extend<T> for Vec<T> {
14991499
__impl_slice_eq1! { Vec<A>, Vec<B> }
15001500
__impl_slice_eq2! { Vec<A>, &'b [B] }
15011501
__impl_slice_eq2! { Vec<A>, &'b mut [B] }
1502-
__impl_slice_eq2! { CowVec<'a, A>, &'b [B], Clone }
1503-
__impl_slice_eq2! { CowVec<'a, A>, &'b mut [B], Clone }
1504-
__impl_slice_eq2! { CowVec<'a, A>, Vec<B>, Clone }
1502+
__impl_slice_eq2! { Cow<'a, [A]>, &'b [B], Clone }
1503+
__impl_slice_eq2! { Cow<'a, [A]>, &'b mut [B], Clone }
1504+
__impl_slice_eq2! { Cow<'a, [A]>, Vec<B>, Clone }
15051505

15061506
macro_rules! array_impls {
15071507
($($N: expr)+) => {
@@ -1510,9 +1510,9 @@ macro_rules! array_impls {
15101510
__impl_slice_eq2! { Vec<A>, [B; $N] }
15111511
__impl_slice_eq2! { Vec<A>, &'b [B; $N] }
15121512
// __impl_slice_eq2! { Vec<A>, &'b mut [B; $N] }
1513-
// __impl_slice_eq2! { CowVec<'a, A>, [B; $N], Clone }
1514-
// __impl_slice_eq2! { CowVec<'a, A>, &'b [B; $N], Clone }
1515-
// __impl_slice_eq2! { CowVec<'a, A>, &'b mut [B; $N], Clone }
1513+
// __impl_slice_eq2! { Cow<'a, [A]>, [B; $N], Clone }
1514+
// __impl_slice_eq2! { Cow<'a, [A]>, &'b [B; $N], Clone }
1515+
// __impl_slice_eq2! { Cow<'a, [A]>, &'b mut [B; $N], Clone }
15161516
)+
15171517
}
15181518
}

0 commit comments

Comments
 (0)