Skip to content

Commit 38e97b9

Browse files
committed
Auto merge of rust-lang#22995 - Manishearth:rollup, r=Manishearth
2 parents 24a840d + 4f1f5eb commit 38e97b9

Some content is hidden

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

88 files changed

+685
-514
lines changed

src/compiletest/runtest.rs

+2-2
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: {:?}",

src/compiletest/util.rs

+1-1
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"),

src/doc/reference.md

+6
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.

src/etc/unicode.py

+24-25
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,

src/libcollections/bit.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -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];

src/libcollections/slice.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1343,8 +1343,8 @@ fn insertion_sort<T, F>(v: &mut [T], mut compare: F) where F: FnMut(&T, &T) -> O
13431343

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

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

src/libcollections/str.rs

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

src/libcollections/string.rs

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

src/libcollections/vec.rs

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

src/libcollections/vec_deque.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ use alloc::heap;
3939
#[unstable(feature = "collections")]
4040
pub use VecDeque as RingBuf;
4141

42-
static INITIAL_CAPACITY: usize = 7; // 2^3 - 1
43-
static MINIMUM_CAPACITY: usize = 1; // 2 - 1
42+
const INITIAL_CAPACITY: usize = 7; // 2^3 - 1
43+
const MINIMUM_CAPACITY: usize = 1; // 2 - 1
4444

4545
/// `VecDeque` is a growable ring buffer, which can be used as a
4646
/// double-ended queue efficiently.

src/libcore/atomic.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1067,6 +1067,7 @@ pub struct AtomicInt {
10671067
v: UnsafeCell<int>,
10681068
}
10691069

1070+
#[allow(deprecated)]
10701071
unsafe impl Sync for AtomicInt {}
10711072

10721073
#[unstable(feature = "core")]
@@ -1077,6 +1078,7 @@ pub struct AtomicUint {
10771078
v: UnsafeCell<uint>,
10781079
}
10791080

1081+
#[allow(deprecated)]
10801082
unsafe impl Sync for AtomicUint {}
10811083

10821084
#[unstable(feature = "core")]

src/libcore/fmt/float.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub enum SignFormat {
5353
SignNeg
5454
}
5555

56-
static DIGIT_E_RADIX: u32 = ('e' as u32) - ('a' as u32) + 11;
56+
const DIGIT_E_RADIX: u32 = ('e' as u32) - ('a' as u32) + 11;
5757

5858
/// Converts a number to its string representation as a byte vector.
5959
/// This is meant to be a common base implementation for all numeric string

src/libcore/fmt/num.rs

+9-12
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ struct LowerHex;
8484

8585
/// A hexadecimal (base 16) radix, formatted with upper-case characters
8686
#[derive(Clone, PartialEq)]
87-
pub struct UpperHex;
87+
struct UpperHex;
8888

8989
macro_rules! radix {
9090
($T:ident, $base:expr, $prefix:expr, $($x:pat => $conv:expr),+) => {
@@ -156,7 +156,7 @@ pub fn radix<T>(x: T, base: u8) -> RadixFmt<T, Radix> {
156156
}
157157

158158
macro_rules! radix_fmt {
159-
($T:ty as $U:ty, $fmt:ident, $S:expr) => {
159+
($T:ty as $U:ty, $fmt:ident) => {
160160
#[stable(feature = "rust1", since = "1.0.0")]
161161
impl fmt::Debug for RadixFmt<$T, Radix> {
162162
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@@ -182,8 +182,8 @@ macro_rules! int_base {
182182
}
183183
}
184184

185-
macro_rules! show {
186-
($T:ident with $S:expr) => {
185+
macro_rules! debug {
186+
($T:ident) => {
187187
#[stable(feature = "rust1", since = "1.0.0")]
188188
impl fmt::Debug for $T {
189189
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@@ -194,27 +194,24 @@ macro_rules! show {
194194
}
195195
macro_rules! integer {
196196
($Int:ident, $Uint:ident) => {
197-
integer! { $Int, $Uint, stringify!($Int), stringify!($Uint) }
198-
};
199-
($Int:ident, $Uint:ident, $SI:expr, $SU:expr) => {
200197
int_base! { Display for $Int as $Int -> Decimal }
201198
int_base! { Binary for $Int as $Uint -> Binary }
202199
int_base! { Octal for $Int as $Uint -> Octal }
203200
int_base! { LowerHex for $Int as $Uint -> LowerHex }
204201
int_base! { UpperHex for $Int as $Uint -> UpperHex }
205-
radix_fmt! { $Int as $Int, fmt_int, $SI }
206-
show! { $Int with $SI }
202+
radix_fmt! { $Int as $Int, fmt_int }
203+
debug! { $Int }
207204

208205
int_base! { Display for $Uint as $Uint -> Decimal }
209206
int_base! { Binary for $Uint as $Uint -> Binary }
210207
int_base! { Octal for $Uint as $Uint -> Octal }
211208
int_base! { LowerHex for $Uint as $Uint -> LowerHex }
212209
int_base! { UpperHex for $Uint as $Uint -> UpperHex }
213-
radix_fmt! { $Uint as $Uint, fmt_int, $SU }
214-
show! { $Uint with $SU }
210+
radix_fmt! { $Uint as $Uint, fmt_int }
211+
debug! { $Uint }
215212
}
216213
}
217-
integer! { isize, usize, "i", "u" }
214+
integer! { isize, usize }
218215
integer! { i8, u8 }
219216
integer! { i16, u16 }
220217
integer! { i32, u32 }

src/libcore/iter.rs

+2
Original file line numberDiff line numberDiff line change
@@ -2061,6 +2061,7 @@ pub struct Scan<I, St, F> {
20612061
f: F,
20622062

20632063
/// The current internal state to be passed to the closure next.
2064+
#[unstable(feature = "core")]
20642065
pub state: St,
20652066
}
20662067

@@ -2338,6 +2339,7 @@ impl<I: RandomAccessIterator, F> RandomAccessIterator for Inspect<I, F>
23382339
pub struct Unfold<St, F> {
23392340
f: F,
23402341
/// Internal state that will be passed to the closure on the next iteration
2342+
#[unstable(feature = "core")]
23412343
pub state: St,
23422344
}
23432345

src/libcore/raw.rs

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ impl<T> Copy for Slice<T> {}
7070
#[deprecated(reason = "unboxed new closures do not have a universal representation; \
7171
`&Fn` (etc) trait objects should use `TraitObject` instead",
7272
since= "1.0.0")]
73+
#[allow(deprecated) /* for deriving Copy impl */]
7374
pub struct Closure {
7475
pub code: *mut (),
7576
pub env: *mut (),

0 commit comments

Comments
 (0)