Auto merge of #22995 - Manishearth:rollup, r=Manishearth

This commit is contained in:
bors 2015-03-03 11:32:11 +00:00
commit 38e97b99a6
88 changed files with 680 additions and 509 deletions

View File

@ -127,7 +127,7 @@ fn run_rfail_test(config: &Config, props: &TestProps, testfile: &Path) {
};
// The value our Makefile configures valgrind to return on failure
static VALGRIND_ERR: int = 100;
const VALGRIND_ERR: int = 100;
if proc_res.status.matches_exit_status(VALGRIND_ERR) {
fatal_proc_rec("run-fail test isn't valgrind-clean!", &proc_res);
}
@ -139,7 +139,7 @@ fn run_rfail_test(config: &Config, props: &TestProps, testfile: &Path) {
fn check_correct_failure_status(proc_res: &ProcRes) {
// The value the rust runtime returns on failure
static RUST_ERR: int = 101;
const RUST_ERR: int = 101;
if !proc_res.status.matches_exit_status(RUST_ERR) {
fatal_proc_rec(
&format!("failure produced the wrong error: {:?}",

View File

@ -14,7 +14,7 @@ use common::Config;
use std::env;
/// Conversion table from triple OS name to Rust SYSNAME
static OS_TABLE: &'static [(&'static str, &'static str)] = &[
const OS_TABLE: &'static [(&'static str, &'static str)] = &[
("mingw32", "windows"),
("win32", "windows"),
("windows", "windows"),

View File

@ -2495,6 +2495,12 @@ The currently implemented features of the reference compiler are:
* `staged_api` - Allows usage of stability markers and `#![staged_api]` in a crate
* `static_assert` - The `#[static_assert]` functionality is experimental and
unstable. The attribute can be attached to a `static` of
type `bool` and the compiler will error if the `bool` is
`false` at compile time. This version of this functionality
is unintuitive and suboptimal.
* `start` - Allows use of the `#[start]` attribute, which changes the entry point
into a Rust program. This capabiilty, especially the signature for the
annotated function, is subject to change.

View File

@ -290,11 +290,11 @@ def emit_bsearch_range_table(f):
fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool {
use core::cmp::Ordering::{Equal, Less, Greater};
use core::slice::SliceExt;
r.binary_search(|&(lo,hi)| {
r.binary_search_by(|&(lo,hi)| {
if lo <= c && c <= hi { Equal }
else if hi < c { Less }
else { Greater }
}).found().is_some()
}).is_ok()
}\n
""")
@ -303,7 +303,7 @@ def emit_table(f, name, t_data, t_type = "&'static [(char, char)]", is_pub=True,
pub_string = ""
if is_pub:
pub_string = "pub "
f.write(" %sstatic %s: %s = &[\n" % (pub_string, name, t_type))
f.write(" %sconst %s: %s = &[\n" % (pub_string, name, t_type))
data = ""
first = True
for dat in t_data:
@ -329,14 +329,14 @@ def emit_property_module(f, mod, tbl, emit_fn):
def emit_regex_module(f, cats, w_data):
f.write("pub mod regex {\n")
regex_class = "&'static [(char, char)]"
class_table = "&'static [(&'static str, &'static %s)]" % regex_class
class_table = "&'static [(&'static str, %s)]" % regex_class
emit_table(f, "UNICODE_CLASSES", cats, class_table,
pfun=lambda x: "(\"%s\",&super::%s::%s_table)" % (x[0], x[1], x[0]))
pfun=lambda x: "(\"%s\",super::%s::%s_table)" % (x[0], x[1], x[0]))
f.write(" pub static PERLD: &'static %s = &super::general_category::Nd_table;\n\n"
f.write(" pub const PERLD: %s = super::general_category::Nd_table;\n\n"
% regex_class)
f.write(" pub static PERLS: &'static %s = &super::property::White_Space_table;\n\n"
f.write(" pub const PERLS: %s = super::property::White_Space_table;\n\n"
% regex_class)
emit_table(f, "PERLW", w_data, regex_class)
@ -350,7 +350,7 @@ def emit_conversions_module(f, lowerupper, upperlower):
use core::slice::SliceExt;
use core::option::Option;
use core::option::Option::{Some, None};
use core::slice;
use core::result::Result::{Ok, Err};
pub fn to_lower(c: char) -> char {
match bsearch_case_table(c, LuLl_table) {
@ -367,13 +367,13 @@ def emit_conversions_module(f, lowerupper, upperlower):
}
fn bsearch_case_table(c: char, table: &'static [(char, char)]) -> Option<usize> {
match table.binary_search(|&(key, _)| {
match table.binary_search_by(|&(key, _)| {
if c == key { Equal }
else if key < c { Less }
else { Greater }
}) {
slice::BinarySearchResult::Found(i) => Some(i),
slice::BinarySearchResult::NotFound(_) => None,
Ok(i) => Some(i),
Err(_) => None,
}
}
@ -386,10 +386,9 @@ def emit_conversions_module(f, lowerupper, upperlower):
def emit_grapheme_module(f, grapheme_table, grapheme_cats):
f.write("""pub mod grapheme {
use core::kinds::Copy;
use core::slice::SliceExt;
pub use self::GraphemeCat::*;
use core::slice;
use core::result::Result::{Ok, Err};
#[allow(non_camel_case_types)]
#[derive(Clone, Copy)]
@ -401,16 +400,16 @@ def emit_grapheme_module(f, grapheme_table, grapheme_cats):
fn bsearch_range_value_table(c: char, r: &'static [(char, char, GraphemeCat)]) -> GraphemeCat {
use core::cmp::Ordering::{Equal, Less, Greater};
match r.binary_search(|&(lo, hi, _)| {
match r.binary_search_by(|&(lo, hi, _)| {
if lo <= c && c <= hi { Equal }
else if hi < c { Less }
else { Greater }
}) {
slice::BinarySearchResult::Found(idx) => {
Ok(idx) => {
let (_, _, cat) = r[idx];
cat
}
slice::BinarySearchResult::NotFound(_) => GC_Any
Err(_) => GC_Any
}
}
@ -430,20 +429,20 @@ def emit_charwidth_module(f, width_table):
f.write(" use core::option::Option;\n")
f.write(" use core::option::Option::{Some, None};\n")
f.write(" use core::slice::SliceExt;\n")
f.write(" use core::slice;\n")
f.write(" use core::result::Result::{Ok, Err};\n")
f.write("""
fn bsearch_range_value_table(c: char, is_cjk: bool, r: &'static [(char, char, u8, u8)]) -> u8 {
use core::cmp::Ordering::{Equal, Less, Greater};
match r.binary_search(|&(lo, hi, _, _)| {
match r.binary_search_by(|&(lo, hi, _, _)| {
if lo <= c && c <= hi { Equal }
else if hi < c { Less }
else { Greater }
}) {
slice::BinarySearchResult::Found(idx) => {
Ok(idx) => {
let (_, _, r_ncjk, r_cjk) = r[idx];
if is_cjk { r_cjk } else { r_ncjk }
}
slice::BinarySearchResult::NotFound(_) => 1
Err(_) => 1
}
}
""")
@ -530,17 +529,17 @@ def emit_norm_module(f, canon, compat, combine, norm_props):
fn bsearch_range_value_table(c: char, r: &'static [(char, char, u8)]) -> u8 {
use core::cmp::Ordering::{Equal, Less, Greater};
use core::slice::SliceExt;
use core::slice;
match r.binary_search(|&(lo, hi, _)| {
use core::result::Result::{Ok, Err};
match r.binary_search_by(|&(lo, hi, _)| {
if lo <= c && c <= hi { Equal }
else if hi < c { Less }
else { Greater }
}) {
slice::BinarySearchResult::Found(idx) => {
Ok(idx) => {
let (_, _, result) = r[idx];
result
}
slice::BinarySearchResult::NotFound(_) => 0
Err(_) => 0
}
}\n
""")
@ -609,7 +608,7 @@ if __name__ == "__main__":
unicode_version = re.search(pattern, readme.read()).groups()
rf.write("""
/// The version of [Unicode](http://www.unicode.org/)
/// that the `UnicodeChar` and `UnicodeStrPrelude` traits are based on.
/// that the unicode parts of `CharExt` and `UnicodeStrPrelude` traits are based on.
pub const UNICODE_VERSION: (u64, u64, u64) = (%s, %s, %s);
""" % unicode_version)
(canon_decomp, compat_decomp, gencats, combines,

View File

@ -2544,7 +2544,7 @@ mod bit_vec_bench {
use super::BitVec;
static BENCH_BITS : usize = 1 << 14;
const BENCH_BITS : usize = 1 << 14;
fn rng() -> rand::IsaacRng {
let seed: &[_] = &[1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
@ -3039,7 +3039,7 @@ mod bit_set_bench {
use super::{BitVec, BitSet};
static BENCH_BITS : usize = 1 << 14;
const BENCH_BITS : usize = 1 << 14;
fn rng() -> rand::IsaacRng {
let seed: &[_] = &[1, 2, 3, 4, 5, 6, 7, 8, 9, 0];

View File

@ -1343,8 +1343,8 @@ fn insertion_sort<T, F>(v: &mut [T], mut compare: F) where F: FnMut(&T, &T) -> O
fn merge_sort<T, F>(v: &mut [T], mut compare: F) where F: FnMut(&T, &T) -> Ordering {
// warning: this wildly uses unsafe.
static BASE_INSERTION: usize = 32;
static LARGE_INSERTION: usize = 16;
const BASE_INSERTION: usize = 32;
const LARGE_INSERTION: usize = 16;
// FIXME #12092: smaller insertion runs seems to make sorting
// vectors of large elements a little faster on some platforms,

View File

@ -756,6 +756,7 @@ pub trait StrExt: Index<RangeFull, Output = str> {
/// ```
#[unstable(feature = "collections")]
#[deprecated(since = "1.0.0", reason = "use `split()` with a `&str`")]
#[allow(deprecated) /* for SplitStr */]
fn split_str<'a, P: Pattern<'a>>(&'a self, pat: P) -> SplitStr<'a, P> {
core_str::StrExt::split_str(&self[..], pat)
}

View File

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

View File

@ -1499,9 +1499,9 @@ impl<T> Extend<T> for Vec<T> {
__impl_slice_eq1! { Vec<A>, Vec<B> }
__impl_slice_eq2! { Vec<A>, &'b [B] }
__impl_slice_eq2! { Vec<A>, &'b mut [B] }
__impl_slice_eq2! { CowVec<'a, A>, &'b [B], Clone }
__impl_slice_eq2! { CowVec<'a, A>, &'b mut [B], Clone }
__impl_slice_eq2! { CowVec<'a, A>, Vec<B>, Clone }
__impl_slice_eq2! { Cow<'a, [A]>, &'b [B], Clone }
__impl_slice_eq2! { Cow<'a, [A]>, &'b mut [B], Clone }
__impl_slice_eq2! { Cow<'a, [A]>, Vec<B>, Clone }
macro_rules! array_impls {
($($N: expr)+) => {
@ -1510,9 +1510,9 @@ macro_rules! array_impls {
__impl_slice_eq2! { Vec<A>, [B; $N] }
__impl_slice_eq2! { Vec<A>, &'b [B; $N] }
// __impl_slice_eq2! { Vec<A>, &'b mut [B; $N] }
// __impl_slice_eq2! { CowVec<'a, A>, [B; $N], Clone }
// __impl_slice_eq2! { CowVec<'a, A>, &'b [B; $N], Clone }
// __impl_slice_eq2! { CowVec<'a, A>, &'b mut [B; $N], Clone }
// __impl_slice_eq2! { Cow<'a, [A]>, [B; $N], Clone }
// __impl_slice_eq2! { Cow<'a, [A]>, &'b [B; $N], Clone }
// __impl_slice_eq2! { Cow<'a, [A]>, &'b mut [B; $N], Clone }
)+
}
}

View File

@ -39,8 +39,8 @@ use alloc::heap;
#[unstable(feature = "collections")]
pub use VecDeque as RingBuf;
static INITIAL_CAPACITY: usize = 7; // 2^3 - 1
static MINIMUM_CAPACITY: usize = 1; // 2 - 1
const INITIAL_CAPACITY: usize = 7; // 2^3 - 1
const MINIMUM_CAPACITY: usize = 1; // 2 - 1
/// `VecDeque` is a growable ring buffer, which can be used as a
/// double-ended queue efficiently.

View File

@ -1067,6 +1067,7 @@ pub struct AtomicInt {
v: UnsafeCell<int>,
}
#[allow(deprecated)]
unsafe impl Sync for AtomicInt {}
#[unstable(feature = "core")]
@ -1077,6 +1078,7 @@ pub struct AtomicUint {
v: UnsafeCell<uint>,
}
#[allow(deprecated)]
unsafe impl Sync for AtomicUint {}
#[unstable(feature = "core")]

View File

@ -53,7 +53,7 @@ pub enum SignFormat {
SignNeg
}
static DIGIT_E_RADIX: u32 = ('e' as u32) - ('a' as u32) + 11;
const DIGIT_E_RADIX: u32 = ('e' as u32) - ('a' as u32) + 11;
/// Converts a number to its string representation as a byte vector.
/// This is meant to be a common base implementation for all numeric string

View File

@ -84,7 +84,7 @@ struct LowerHex;
/// A hexadecimal (base 16) radix, formatted with upper-case characters
#[derive(Clone, PartialEq)]
pub struct UpperHex;
struct UpperHex;
macro_rules! radix {
($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> {
}
macro_rules! radix_fmt {
($T:ty as $U:ty, $fmt:ident, $S:expr) => {
($T:ty as $U:ty, $fmt:ident) => {
#[stable(feature = "rust1", since = "1.0.0")]
impl fmt::Debug for RadixFmt<$T, Radix> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@ -182,8 +182,8 @@ macro_rules! int_base {
}
}
macro_rules! show {
($T:ident with $S:expr) => {
macro_rules! debug {
($T:ident) => {
#[stable(feature = "rust1", since = "1.0.0")]
impl fmt::Debug for $T {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@ -194,27 +194,24 @@ macro_rules! show {
}
macro_rules! integer {
($Int:ident, $Uint:ident) => {
integer! { $Int, $Uint, stringify!($Int), stringify!($Uint) }
};
($Int:ident, $Uint:ident, $SI:expr, $SU:expr) => {
int_base! { Display for $Int as $Int -> Decimal }
int_base! { Binary for $Int as $Uint -> Binary }
int_base! { Octal for $Int as $Uint -> Octal }
int_base! { LowerHex for $Int as $Uint -> LowerHex }
int_base! { UpperHex for $Int as $Uint -> UpperHex }
radix_fmt! { $Int as $Int, fmt_int, $SI }
show! { $Int with $SI }
radix_fmt! { $Int as $Int, fmt_int }
debug! { $Int }
int_base! { Display for $Uint as $Uint -> Decimal }
int_base! { Binary for $Uint as $Uint -> Binary }
int_base! { Octal for $Uint as $Uint -> Octal }
int_base! { LowerHex for $Uint as $Uint -> LowerHex }
int_base! { UpperHex for $Uint as $Uint -> UpperHex }
radix_fmt! { $Uint as $Uint, fmt_int, $SU }
show! { $Uint with $SU }
radix_fmt! { $Uint as $Uint, fmt_int }
debug! { $Uint }
}
}
integer! { isize, usize, "i", "u" }
integer! { isize, usize }
integer! { i8, u8 }
integer! { i16, u16 }
integer! { i32, u32 }

View File

@ -2061,6 +2061,7 @@ pub struct Scan<I, St, F> {
f: F,
/// The current internal state to be passed to the closure next.
#[unstable(feature = "core")]
pub state: St,
}
@ -2338,6 +2339,7 @@ impl<I: RandomAccessIterator, F> RandomAccessIterator for Inspect<I, F>
pub struct Unfold<St, F> {
f: F,
/// Internal state that will be passed to the closure on the next iteration
#[unstable(feature = "core")]
pub state: St,
}

View File

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

View File

@ -351,6 +351,7 @@ impl<T> SliceExt for [T] {
ChunksMut { v: self, chunk_size: chunk_size }
}
#[inline]
fn swap(&mut self, a: usize, b: usize) {
unsafe {
// Can't take two mutable loans from one vector, so instead just cast
@ -1167,13 +1168,23 @@ forward_iterator! { SplitNMut: T, &'a mut [T] }
forward_iterator! { RSplitNMut: T, &'a mut [T] }
/// An iterator over overlapping subslices of length `size`.
#[derive(Clone)]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Windows<'a, T:'a> {
v: &'a [T],
size: usize
}
// FIXME(#19839) Remove in favor of `#[derive(Clone)]`
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> Clone for Windows<'a, T> {
fn clone(&self) -> Windows<'a, T> {
Windows {
v: self.v,
size: self.size,
}
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> Iterator for Windows<'a, T> {
type Item = &'a [T];
@ -1239,13 +1250,23 @@ impl<'a, T> RandomAccessIterator for Windows<'a, T> {
///
/// When the slice len is not evenly divided by the chunk size, the last slice
/// of the iteration will be the remainder.
#[derive(Clone)]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Chunks<'a, T:'a> {
v: &'a [T],
size: usize
}
// FIXME(#19839) Remove in favor of `#[derive(Clone)]`
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> Clone for Chunks<'a, T> {
fn clone(&self) -> Chunks<'a, T> {
Chunks {
v: self.v,
size: self.size,
}
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> Iterator for Chunks<'a, T> {
type Item = &'a [T];

View File

@ -134,12 +134,23 @@ impl FromStr for bool {
/// Parse a `bool` from a string.
///
/// Yields an `Option<bool>`, because `s` may or may not actually be
/// parseable.
/// Yields a `Result<bool, ParseBoolError>`, because `s` may or may not
/// actually be parseable.
///
/// # Examples
///
/// ```rust
/// use std::str::FromStr;
///
/// assert_eq!(FromStr::from_str("true"), Ok(true));
/// assert_eq!(FromStr::from_str("false"), Ok(false));
/// assert!(<bool as FromStr>::from_str("not even a boolean").is_err());
/// ```
///
/// Note, in many cases, the StrExt::parse() which is based on
/// this FromStr::from_str() is more proper.
///
/// ```rust
/// assert_eq!("true".parse(), Ok(true));
/// assert_eq!("false".parse(), Ok(false));
/// assert!("not even a boolean".parse::<bool>().is_err());
@ -935,6 +946,7 @@ impl<'a, P: Pattern<'a>> Iterator for MatchIndices<'a, P> {
#[unstable(feature = "core")]
#[deprecated(since = "1.0.0", reason = "use `Split` with a `&str`")]
pub struct SplitStr<'a, P: Pattern<'a>>(Split<'a, P>);
#[allow(deprecated)]
impl<'a, P: Pattern<'a>> Iterator for SplitStr<'a, P> {
type Item = &'a str;
@ -1325,6 +1337,7 @@ pub trait StrExt {
fn split_terminator<'a, P: Pattern<'a>>(&'a self, pat: P) -> SplitTerminator<'a, P>;
fn rsplitn<'a, P: Pattern<'a>>(&'a self, count: usize, pat: P) -> RSplitN<'a, P>;
fn match_indices<'a, P: Pattern<'a>>(&'a self, pat: P) -> MatchIndices<'a, P>;
#[allow(deprecated) /* for SplitStr */]
fn split_str<'a, P: Pattern<'a>>(&'a self, pat: P) -> SplitStr<'a, P>;
fn lines<'a>(&'a self) -> Lines<'a>;
fn lines_any<'a>(&'a self) -> LinesAny<'a>;

View File

@ -70,12 +70,12 @@ mod tests {
assert!(-(0b11 as $T) - (1 as $T) == (0b11 as $T).not());
}
static A: $T = 0b0101100;
static B: $T = 0b0100001;
static C: $T = 0b1111001;
const A: $T = 0b0101100;
const B: $T = 0b0100001;
const C: $T = 0b1111001;
static _0: $T = 0;
static _1: $T = !0;
const _0: $T = 0;
const _1: $T = !0;
#[test]
fn test_count_ones() {

View File

@ -38,12 +38,12 @@ mod tests {
assert!(MAX - (0b1011 as $T) == (0b1011 as $T).not());
}
static A: $T = 0b0101100;
static B: $T = 0b0100001;
static C: $T = 0b1111001;
const A: $T = 0b0101100;
const B: $T = 0b0100001;
const C: $T = 0b1111001;
static _0: $T = 0;
static _1: $T = !0;
const _0: $T = 0;
const _1: $T = !0;
#[test]
fn test_count_ones() {

View File

@ -73,9 +73,9 @@ extern {
-> *mut c_void;
}
static LZ_NORM : c_int = 0x80; // LZ with 128 probes, "normal"
static TINFL_FLAG_PARSE_ZLIB_HEADER : c_int = 0x1; // parse zlib header and adler32 checksum
static TDEFL_WRITE_ZLIB_HEADER : c_int = 0x01000; // write zlib header and adler32 checksum
const LZ_NORM: c_int = 0x80; // LZ with 128 probes, "normal"
const TINFL_FLAG_PARSE_ZLIB_HEADER: c_int = 0x1; // parse zlib header and adler32 checksum
const TDEFL_WRITE_ZLIB_HEADER: c_int = 0x01000; // write zlib header and adler32 checksum
fn deflate_bytes_internal(bytes: &[u8], flags: c_int) -> Option<Bytes> {
unsafe {

View File

@ -37,7 +37,7 @@
//! Each node label is derived directly from the int representing the node,
//! while the edge labels are all empty strings.
//!
//! This example also illustrates how to use `CowVec` to return
//! This example also illustrates how to use `Cow<[T]>` to return
//! an owned vector or a borrowed slice as appropriate: we construct the
//! node vector from scratch, but borrow the edge list (rather than
//! constructing a copy of all the edges from scratch).
@ -502,7 +502,7 @@ pub type Edges<'a,E> = Cow<'a,[E]>;
/// that is bound by the self lifetime `'a`.
///
/// The `nodes` and `edges` method each return instantiations of
/// `CowVec` to leave implementers the freedom to create
/// `Cow<[T]>` to leave implementers the freedom to create
/// entirely new vectors or to pass back slices into internally owned
/// vectors.
pub trait GraphWalk<'a, N, E> {

View File

@ -223,7 +223,7 @@ fn ziggurat<R: Rng, P, Z>(
mut pdf: P,
mut zero_case: Z)
-> f64 where P: FnMut(f64) -> f64, Z: FnMut(&mut R, f64) -> f64 {
static SCALE: f64 = (1u64 << 53) as f64;
const SCALE: f64 = (1u64 << 53) as f64;
loop {
// reimplement the f64 generation as an optimisation suggested
// by the Doornik paper: we have a lot of precision-space

View File

@ -127,7 +127,7 @@ impl IsaacRng {
let mut a = self.a;
let mut b = self.b + self.c;
static MIDPOINT: uint = (RAND_SIZE / 2) as uint;
const MIDPOINT: uint = (RAND_SIZE / 2) as uint;
macro_rules! ind {
($x:expr) => ( self.mem[(($x >> 2) as uint & ((RAND_SIZE - 1) as uint))] )

View File

@ -52,7 +52,7 @@ use distributions::{Range, IndependentSample};
use distributions::range::SampleRange;
#[cfg(test)]
static RAND_BENCH_N: u64 = 100;
const RAND_BENCH_N: u64 = 100;
pub mod distributions;
pub mod isaac;
@ -342,7 +342,7 @@ impl<'a, R: Rng> Iterator for AsciiGenerator<'a, R> {
type Item = char;
fn next(&mut self) -> Option<char> {
static GEN_ASCII_STR_CHARSET: &'static [u8] =
const GEN_ASCII_STR_CHARSET: &'static [u8] =
b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\
abcdefghijklmnopqrstuvwxyz\
0123456789";

View File

@ -141,7 +141,7 @@ impl Rand for char {
#[inline]
fn rand<R: Rng>(rng: &mut R) -> char {
// a char is 21 bits
static CHAR_MASK: u32 = 0x001f_ffff;
const CHAR_MASK: u32 = 0x001f_ffff;
loop {
// Rejection sampling. About 0.2% of numbers with at most
// 21-bits are invalid codepoints (surrogates), so this

View File

@ -18,7 +18,7 @@ use core::default::Default;
/// How many bytes of entropy the underling RNG is allowed to generate
/// before it is reseeded.
static DEFAULT_GENERATION_THRESHOLD: uint = 32 * 1024;
const DEFAULT_GENERATION_THRESHOLD: uint = 32 * 1024;
/// A wrapper around any RNG which reseeds the underlying RNG after it
/// has generated a certain number of random bytes.
@ -212,7 +212,7 @@ mod test {
assert_eq!(string1, string2);
}
static FILL_BYTES_V_LEN: uint = 13579;
const FILL_BYTES_V_LEN: uint = 13579;
#[test]
fn test_rng_fill_bytes() {
let mut v = repeat(0u8).take(FILL_BYTES_V_LEN).collect::<Vec<_>>();

View File

@ -13,7 +13,7 @@ use std::old_io;
use std::slice;
use std::iter::repeat;
static BUF_CAPACITY: uint = 128;
const BUF_CAPACITY: uint = 128;
fn combine(seek: SeekStyle, cur: uint, end: uint, offset: i64) -> IoResult<u64> {
// compute offset as signed and clamp to prevent overflow

View File

@ -568,9 +568,9 @@ impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> {
})
}
// FIXME(#10894) should continue recursing
fn visit_ty(&mut self, t: &ast::Ty) {
run_lints!(self, check_ty, t);
visit::walk_ty(self, t);
}
fn visit_ident(&mut self, sp: Span, id: ast::Ident) {

View File

@ -202,9 +202,9 @@ pub fn get_or_default_sysroot() -> Path {
}
#[cfg(windows)]
static PATH_ENTRY_SEPARATOR: &'static str = ";";
const PATH_ENTRY_SEPARATOR: char = ';';
#[cfg(not(windows))]
static PATH_ENTRY_SEPARATOR: &'static str = ":";
const PATH_ENTRY_SEPARATOR: char = ':';
/// Returns RUST_PATH as a string, without default paths added
pub fn get_rust_path() -> Option<String> {

View File

@ -540,9 +540,9 @@ struct Specials {
clean_exit_var: Variable
}
static ACC_READ: u32 = 1;
static ACC_WRITE: u32 = 2;
static ACC_USE: u32 = 4;
const ACC_READ: u32 = 1;
const ACC_WRITE: u32 = 2;
const ACC_USE: u32 = 4;
struct Liveness<'a, 'tcx: 'a> {
ir: &'a mut IrMaps<'a, 'tcx>,

View File

@ -76,7 +76,7 @@ use std::hash::{Hash, SipHasher, Hasher};
use std::mem;
use std::ops;
use std::rc::Rc;
use std::vec::{CowVec, IntoIter};
use std::vec::IntoIter;
use collections::enum_set::{EnumSet, CLike};
use std::collections::{HashMap, HashSet};
use syntax::abi;
@ -5580,7 +5580,7 @@ pub fn predicates<'tcx>(
/// Get the attributes of a definition.
pub fn get_attrs<'tcx>(tcx: &'tcx ctxt, did: DefId)
-> CowVec<'tcx, ast::Attribute> {
-> Cow<'tcx, [ast::Attribute]> {
if is_local(did) {
let item = tcx.map.expect_item(did.node);
Cow::Borrowed(&item.attrs)
@ -5753,22 +5753,22 @@ pub fn closure_upvars<'tcx>(typer: &mc::Typer<'tcx>,
pub fn is_binopable<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>, op: ast::BinOp) -> bool {
#![allow(non_upper_case_globals)]
static tycat_other: int = 0;
static tycat_bool: int = 1;
static tycat_char: int = 2;
static tycat_int: int = 3;
static tycat_float: int = 4;
static tycat_raw_ptr: int = 6;
const tycat_other: int = 0;
const tycat_bool: int = 1;
const tycat_char: int = 2;
const tycat_int: int = 3;
const tycat_float: int = 4;
const tycat_raw_ptr: int = 6;
static opcat_add: int = 0;
static opcat_sub: int = 1;
static opcat_mult: int = 2;
static opcat_shift: int = 3;
static opcat_rel: int = 4;
static opcat_eq: int = 5;
static opcat_bit: int = 6;
static opcat_logic: int = 7;
static opcat_mod: int = 8;
const opcat_add: int = 0;
const opcat_sub: int = 1;
const opcat_mult: int = 2;
const opcat_shift: int = 3;
const opcat_rel: int = 4;
const opcat_eq: int = 5;
const opcat_bit: int = 6;
const opcat_logic: int = 7;
const opcat_mod: int = 8;
fn opcat(op: ast::BinOp) -> int {
match op.node {
@ -5807,8 +5807,8 @@ pub fn is_binopable<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>, op: ast::BinOp) -> bool
}
}
static t: bool = true;
static f: bool = false;
const t: bool = true;
const f: bool = false;
let tbl = [
// +, -, *, shift, rel, ==, bit, logic, mod

View File

@ -18,7 +18,7 @@ use std::os;
use std::str;
use syntax::diagnostic::Handler as ErrorHandler;
pub static METADATA_FILENAME: &'static str = "rust.metadata.bin";
pub const METADATA_FILENAME: &'static str = "rust.metadata.bin";
pub struct ArchiveConfig<'a> {
pub handler: &'a ErrorHandler,
@ -242,7 +242,7 @@ impl<'a> ArchiveBuilder<'a> {
// Don't allow the total size of `args` to grow beyond 32,000 bytes.
// Windows will raise an error if the argument string is longer than
// 32,768, and we leave a bit of extra space for the program name.
static ARG_LENGTH_LIMIT: uint = 32000;
const ARG_LENGTH_LIMIT: uint = 32_000;
for member_name in &self.members {
let len = member_name.as_vec().len();

View File

@ -15,7 +15,7 @@ use std::os;
/// Returns an absolute path in the filesystem that `path` points to. The
/// returned path does not contain any symlinks in its hierarchy.
pub fn realpath(original: &Path) -> old_io::IoResult<Path> {
static MAX_LINKS_FOLLOWED: uint = 256;
const MAX_LINKS_FOLLOWED: uint = 256;
let original = try!(os::getcwd()).join(original);
// Right now lstat on windows doesn't work quite well

View File

@ -312,7 +312,7 @@ impl<'tcx> LoanPath<'tcx> {
// FIXME (pnkfelix): See discussion here
// https://github.com/pnkfelix/rust/commit/
// b2b39e8700e37ad32b486b9a8409b50a8a53aa51#commitcomment-7892003
static DOWNCAST_PRINTED_OPERATOR : &'static str = " as ";
const DOWNCAST_PRINTED_OPERATOR: &'static str = " as ";
// A local, "cleaned" version of `mc::InteriorKind` that drops
// information that is not relevant to loan-path analysis. (In

View File

@ -91,8 +91,7 @@ impl Clone for MovePathIndex {
}
#[allow(non_upper_case_globals)]
static InvalidMovePathIndex: MovePathIndex =
MovePathIndex(usize::MAX);
const InvalidMovePathIndex: MovePathIndex = MovePathIndex(usize::MAX);
/// Index into `MoveData.moves`, used like a pointer
#[derive(Copy, PartialEq)]
@ -105,8 +104,7 @@ impl MoveIndex {
}
#[allow(non_upper_case_globals)]
static InvalidMoveIndex: MoveIndex =
MoveIndex(usize::MAX);
const InvalidMoveIndex: MoveIndex = MoveIndex(usize::MAX);
pub struct MovePath<'tcx> {
/// Loan path corresponding to this move path

View File

@ -93,7 +93,7 @@ pub mod driver;
pub mod pretty;
static BUG_REPORT_URL: &'static str =
const BUG_REPORT_URL: &'static str =
"https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports";
@ -770,7 +770,7 @@ fn parse_crate_attrs(sess: &Session, input: &Input) ->
/// The diagnostic emitter yielded to the procedure should be used for reporting
/// errors of the compiler.
pub fn monitor<F:FnOnce()+Send+'static>(f: F) {
static STACK_SIZE: uint = 8 * 1024 * 1024; // 8MB
const STACK_SIZE: uint = 8 * 1024 * 1024; // 8MB
let (tx, rx) = channel();
let w = old_io::ChanWriter::new(tx);

View File

@ -44,7 +44,7 @@ struct RH<'a> {
sub: &'a [RH<'a>]
}
static EMPTY_SOURCE_STR: &'static str = "#![feature(no_std)] #![no_std]";
const EMPTY_SOURCE_STR: &'static str = "#![feature(no_std)] #![no_std]";
struct ExpectErrorEmitter {
messages: Vec<String>

View File

@ -571,7 +571,7 @@ struct RawPtrDeriveVisitor<'a, 'tcx: 'a> {
impl<'a, 'tcx, 'v> Visitor<'v> for RawPtrDeriveVisitor<'a, 'tcx> {
fn visit_ty(&mut self, ty: &ast::Ty) {
static MSG: &'static str = "use of `#[derive]` with a raw pointer";
const MSG: &'static str = "use of `#[derive]` with a raw pointer";
if let ast::TyPtr(..) = ty.node {
self.cx.span_lint(RAW_POINTER_DERIVE, ty.span, MSG);
}

View File

@ -1376,10 +1376,11 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> {
}
}
Some(ref tr) => {
// Any private types in a trait impl fall into two
// Any private types in a trait impl fall into three
// categories.
// 1. mentioned in the trait definition
// 2. mentioned in the type params/generics
// 3. mentioned in the associated types of the impl
//
// Those in 1. can only occur if the trait is in
// this crate and will've been warned about on the
@ -1389,6 +1390,16 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> {
// Those in 2. are warned via walk_generics and this
// call here.
visit::walk_path(self, &tr.path);
// Those in 3. are warned with this call.
for impl_item in impl_items {
match *impl_item {
ast::MethodImplItem(..) => {},
ast::TypeImplItem(ref typedef) => {
self.visit_ty(&typedef.typ);
}
}
}
}
}
} else if trait_ref.is_none() && self_is_public_path {

View File

@ -317,7 +317,7 @@ pub fn mangle_exported_name<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, path: PathEl
// e.g. `fn foo() { { fn a() {} } { fn a() {} } }`, so we
// generate unique characters from the node id. For now
// hopefully 3 characters is enough to avoid collisions.
static EXTRA_CHARS: &'static str =
const EXTRA_CHARS: &'static str =
"abcdefghijklmnopqrstuvwxyz\
ABCDEFGHIJKLMNOPQRSTUVWXYZ\
0123456789";

View File

@ -487,12 +487,12 @@ fn range_to_inttype(cx: &CrateContext, hint: Hint, bounds: &IntBounds) -> IntTyp
debug!("range_to_inttype: {:?} {:?}", hint, bounds);
// Lists of sizes to try. u64 is always allowed as a fallback.
#[allow(non_upper_case_globals)]
static choose_shortest: &'static[IntType] = &[
const choose_shortest: &'static [IntType] = &[
attr::UnsignedInt(ast::TyU8), attr::SignedInt(ast::TyI8),
attr::UnsignedInt(ast::TyU16), attr::SignedInt(ast::TyI16),
attr::UnsignedInt(ast::TyU32), attr::SignedInt(ast::TyI32)];
#[allow(non_upper_case_globals)]
static at_least_32: &'static[IntType] = &[
const at_least_32: &'static [IntType] = &[
attr::UnsignedInt(ast::TyU32), attr::SignedInt(ast::TyI32)];
let attempts;
@ -1000,7 +1000,7 @@ pub fn trans_drop_flag_ptr<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, r: &Repr<'tcx
let fcx = bcx.fcx;
let custom_cleanup_scope = fcx.push_custom_cleanup_scope();
let scratch = unpack_datum!(bcx, datum::lvalue_scratch_datum(
bcx, tcx.types.bool, "drop_flag", false,
bcx, tcx.types.bool, "drop_flag",
cleanup::CustomScope(custom_cleanup_scope), (), |_, bcx, _| bcx
));
bcx = fold_variants(bcx, r, val, |variant_cx, st, value| {

View File

@ -1203,21 +1203,6 @@ pub fn alloca_no_lifetime(cx: Block, ty: Type, name: &str) -> ValueRef {
Alloca(cx, ty, name)
}
pub fn alloca_zeroed<'blk, 'tcx>(cx: Block<'blk, 'tcx>, ty: Ty<'tcx>,
name: &str) -> ValueRef {
let llty = type_of::type_of(cx.ccx(), ty);
if cx.unreachable.get() {
unsafe {
return llvm::LLVMGetUndef(llty.ptr_to().to_ref());
}
}
let p = alloca_no_lifetime(cx, llty, name);
let b = cx.fcx.ccx.builder();
b.position_before(cx.fcx.alloca_insert_pt.get().unwrap());
memzero(&b, p, ty);
p
}
// Creates the alloca slot which holds the pointer to the slot for the final return value
pub fn make_return_slot_pointer<'a, 'tcx>(fcx: &FunctionContext<'a, 'tcx>,
output_type: Ty<'tcx>) -> ValueRef {
@ -1547,7 +1532,6 @@ fn create_datums_for_fn_args_under_call_abi<'blk, 'tcx>(
datum::lvalue_scratch_datum(bcx,
arg_ty,
"tupled_args",
false,
tuple_args_scope_id,
(),
|(),

View File

@ -195,24 +195,18 @@ pub fn immediate_rvalue_bcx<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
/// Allocates temporary space on the stack using alloca() and returns a by-ref Datum pointing to
/// it. The memory will be dropped upon exit from `scope`. The callback `populate` should
/// initialize the memory. If `zero` is true, the space will be zeroed when it is allocated; this
/// is not necessary unless `bcx` does not dominate the end of `scope`.
/// initialize the memory.
pub fn lvalue_scratch_datum<'blk, 'tcx, A, F>(bcx: Block<'blk, 'tcx>,
ty: Ty<'tcx>,
name: &str,
zero: bool,
scope: cleanup::ScopeId,
arg: A,
populate: F)
-> DatumBlock<'blk, 'tcx, Lvalue> where
F: FnOnce(A, Block<'blk, 'tcx>, ValueRef) -> Block<'blk, 'tcx>,
{
let scratch = if zero {
alloca_zeroed(bcx, ty, name)
} else {
let llty = type_of::type_of(bcx.ccx(), ty);
alloca(bcx, llty, name)
};
let llty = type_of::type_of(bcx.ccx(), ty);
let scratch = alloca(bcx, llty, name);
// Subtle. Populate the scratch memory *before* scheduling cleanup.
let bcx = populate(arg, bcx, scratch);
@ -383,7 +377,7 @@ impl<'tcx> Datum<'tcx, Rvalue> {
ByValue => {
lvalue_scratch_datum(
bcx, self.ty, name, false, scope, self,
bcx, self.ty, name, scope, self,
|this, bcx, llval| this.store_to(bcx, llval))
}
}

View File

@ -45,7 +45,7 @@ use syntax::ast_util::PostExpansionMethod;
use syntax::codemap::DUMMY_SP;
// drop_glue pointer, size, align.
static VTABLE_OFFSET: uint = 3;
const VTABLE_OFFSET: uint = 3;
/// The main "translation" pass for methods. Generates code
/// for non-monomorphized methods only. Other methods will

View File

@ -167,7 +167,7 @@ mod imp {
use std::os;
use std::ptr;
static LOCKFILE_EXCLUSIVE_LOCK: libc::DWORD = 0x00000002;
const LOCKFILE_EXCLUSIVE_LOCK: libc::DWORD = 0x00000002;
#[allow(non_snake_case)]
extern "system" {

View File

@ -94,7 +94,7 @@ type Pass = (&'static str, // name
fn(clean::Crate) -> plugins::PluginResult, // fn
&'static str); // description
static PASSES: &'static [Pass] = &[
const PASSES: &'static [Pass] = &[
("strip-hidden", passes::strip_hidden,
"strips all doc(hidden) items from the output"),
("unindent-comments", passes::unindent_comments,
@ -105,7 +105,7 @@ static PASSES: &'static [Pass] = &[
"strips all private items from a crate which cannot be seen externally"),
];
static DEFAULT_PASSES: &'static [&'static str] = &[
const DEFAULT_PASSES: &'static [&'static str] = &[
"strip-hidden",
"strip-private",
"collapse-docs",

View File

@ -24,7 +24,7 @@ pub trait ToHex {
fn to_hex(&self) -> String;
}
static CHARS: &'static[u8] = b"0123456789abcdef";
const CHARS: &'static [u8] = b"0123456789abcdef";
impl ToHex for [u8] {
/// Turn a vector of `u8` bytes into a hexadecimal string.

View File

@ -34,10 +34,10 @@
use core::prelude::*;
use borrow::{Borrow, ToOwned};
use borrow::{Borrow, Cow, ToOwned};
use fmt::{self, Debug};
use mem;
use string::{String, CowString};
use string::String;
use ops;
use cmp;
use hash::{Hash, Hasher};
@ -183,10 +183,10 @@ impl OsStr {
self.inner.to_str()
}
/// Convert an `OsStr` to a `CowString`.
/// Convert an `OsStr` to a `Cow<str>`.
///
/// Any non-Unicode sequences are replaced with U+FFFD REPLACEMENT CHARACTER.
pub fn to_string_lossy(&self) -> CowString {
pub fn to_string_lossy(&self) -> Cow<str> {
self.inner.to_string_lossy()
}

View File

@ -123,6 +123,7 @@
#![feature(unsafe_no_drop_flag)]
#![feature(macro_reexport)]
#![feature(hash)]
#![feature(int_uint)]
#![feature(unique)]
#![cfg_attr(test, feature(test, rustc_private, env))]

View File

@ -425,7 +425,7 @@ mod tests {
#[test]
fn multiple_connect_interleaved_lazy_schedule_ip4() {
static MAX: usize = 10;
const MAX: usize = 10;
each_ip(&mut |addr| {
let acceptor = t!(TcpListener::bind(&addr));

View File

@ -422,8 +422,8 @@ pub fn float_to_str_common<T: Float>(
// Some constants for from_str_bytes_common's input validation,
// they define minimum radix values for which the character is a valid digit.
static DIGIT_P_RADIX: u32 = ('p' as u32) - ('a' as u32) + 11;
static DIGIT_E_RADIX: u32 = ('e' as u32) - ('a' as u32) + 11;
const DIGIT_P_RADIX: u32 = ('p' as u32) - ('a' as u32) + 11;
const DIGIT_E_RADIX: u32 = ('e' as u32) - ('a' as u32) + 11;
#[cfg(test)]
mod tests {

View File

@ -321,7 +321,7 @@ impl reseeding::Reseeder<StdRng> for ThreadRngReseeder {
}
}
}
static THREAD_RNG_RESEED_THRESHOLD: usize = 32_768;
const THREAD_RNG_RESEED_THRESHOLD: usize = 32_768;
type ThreadRngInner = reseeding::ReseedingRng<StdRng, ThreadRngReseeder>;
/// The thread-local RNG.
@ -638,19 +638,18 @@ mod test {
}
}
#[cfg(test)]
static RAND_BENCH_N: u64 = 100;
#[cfg(test)]
mod bench {
extern crate test;
use prelude::v1::*;
use self::test::Bencher;
use super::{XorShiftRng, StdRng, IsaacRng, Isaac64Rng, Rng, RAND_BENCH_N};
use super::{XorShiftRng, StdRng, IsaacRng, Isaac64Rng, Rng};
use super::{OsRng, weak_rng};
use mem::size_of;
const RAND_BENCH_N: u64 = 100;
#[bench]
fn rand_xorshift(b: &mut Bencher) {
let mut rng: XorShiftRng = OsRng::new().unwrap().gen();

View File

@ -281,9 +281,9 @@ mod imp {
hcryptprov: HCRYPTPROV
}
static PROV_RSA_FULL: DWORD = 1;
static CRYPT_SILENT: DWORD = 64;
static CRYPT_VERIFYCONTEXT: DWORD = 0xF0000000;
const PROV_RSA_FULL: DWORD = 1;
const CRYPT_SILENT: DWORD = 64;
const CRYPT_VERIFYCONTEXT: DWORD = 0xF0000000;
#[allow(non_snake_case)]
extern "system" {

View File

@ -1157,8 +1157,8 @@ mod test {
#[test]
fn stress_shared() {
static AMT: u32 = 10000;
static NTHREADS: u32 = 8;
const AMT: u32 = 10000;
const NTHREADS: u32 = 8;
let (tx, rx) = channel::<i32>();
let t = thread::spawn(move|| {
@ -1663,8 +1663,8 @@ mod sync_tests {
#[test]
fn stress_shared() {
static AMT: u32 = 1000;
static NTHREADS: u32 = 8;
const AMT: u32 = 1000;
const NTHREADS: u32 = 8;
let (tx, rx) = sync_channel::<i32>(0);
let (dtx, drx) = sync_channel::<()>(0);

View File

@ -473,7 +473,7 @@ mod test {
#[test]
fn stress() {
static AMT: i32 = 10000;
const AMT: i32 = 10000;
let (tx1, rx1) = channel::<i32>();
let (tx2, rx2) = channel::<i32>();
let (tx3, rx3) = channel::<()>();

View File

@ -390,8 +390,8 @@ mod test {
fn lots_and_lots() {
static M: StaticMutex = MUTEX_INIT;
static mut CNT: u32 = 0;
static J: u32 = 1000;
static K: u32 = 3;
const J: u32 = 1000;
const K: u32 = 3;
fn inc() {
for _ in 0..J {

View File

@ -436,8 +436,8 @@ mod tests {
#[test]
fn frob() {
static R: StaticRwLock = RW_LOCK_INIT;
static N: usize = 10;
static M: usize = 1000;
const N: usize = 10;
const M: usize = 1000;
let (tx, rx) = channel::<()>();
for _ in 0..N {

View File

@ -38,12 +38,12 @@ use num::Int;
use ops;
use slice;
use str;
use string::{String, CowString};
use string::String;
use sys_common::AsInner;
use unicode::str::{Utf16Item, utf16_items};
use vec::Vec;
static UTF8_REPLACEMENT_CHARACTER: &'static [u8] = b"\xEF\xBF\xBD";
const UTF8_REPLACEMENT_CHARACTER: &'static [u8] = b"\xEF\xBF\xBD";
/// A Unicode code point: from U+0000 to U+10FFFF.
///
@ -530,7 +530,7 @@ impl Wtf8 {
/// Surrogates are replaced with `"\u{FFFD}"` (the replacement character “<>”).
///
/// This only copies the data if necessary (if it contains any surrogate).
pub fn to_string_lossy(&self) -> CowString {
pub fn to_string_lossy(&self) -> Cow<str> {
let surrogate_pos = match self.next_surrogate(0) {
None => return Cow::Borrowed(unsafe { str::from_utf8_unchecked(&self.bytes) }),
Some((pos, _)) => pos,
@ -844,7 +844,6 @@ mod tests {
use borrow::Cow;
use super::*;
use mem::transmute;
use string::CowString;
#[test]
fn code_point_from_u32() {
@ -1224,7 +1223,7 @@ mod tests {
assert_eq!(Wtf8::from_str("aé 💩").to_string_lossy(), Cow::Borrowed("aé 💩"));
let mut string = Wtf8Buf::from_str("aé 💩");
string.push(CodePoint::from_u32(0xD800).unwrap());
let expected: CowString = Cow::Owned(String::from_str("aé 💩<>"));
let expected: Cow<str> = Cow::Owned(String::from_str("aé 💩<>"));
assert_eq!(string.to_string_lossy(), expected);
}

View File

@ -566,7 +566,7 @@ mod uw {
// This function doesn't exist on Android or ARM/Linux, so make it same
// to _Unwind_GetIP
#[cfg(any(target_os = "android",
#[cfg(any(all(target_os = "android", target_arch = "arm"),
all(target_os = "linux", target_arch = "arm")))]
pub unsafe fn _Unwind_GetIPInfo(ctx: *mut _Unwind_Context,
ip_before_insn: *mut libc::c_int)

View File

@ -13,11 +13,12 @@
use core::prelude::*;
use borrow::Cow;
use fmt::{self, Debug};
use vec::Vec;
use slice::SliceExt as StdSliceExt;
use str;
use string::{String, CowString};
use string::String;
use mem;
#[derive(Clone, Hash)]
@ -76,7 +77,7 @@ impl Slice {
str::from_utf8(&self.inner).ok()
}
pub fn to_string_lossy(&self) -> CowString {
pub fn to_string_lossy(&self) -> Cow<str> {
String::from_utf8_lossy(&self.inner)
}

View File

@ -59,8 +59,8 @@ pub fn error_string(errnum: i32) -> String {
-> DWORD;
}
static FORMAT_MESSAGE_FROM_SYSTEM: DWORD = 0x00001000;
static FORMAT_MESSAGE_IGNORE_INSERTS: DWORD = 0x00000200;
const FORMAT_MESSAGE_FROM_SYSTEM: DWORD = 0x00001000;
const FORMAT_MESSAGE_IGNORE_INSERTS: DWORD = 0x00000200;
// This value is calculated from the macro
// MAKELANGID(LANG_SYSTEM_DEFAULT, SUBLANG_SYS_DEFAULT)

View File

@ -11,9 +11,10 @@
/// The underlying OsString/OsStr implementation on Windows is a
/// wrapper around the "WTF-8" encoding; see the `wtf8` module for more.
use borrow::Cow;
use fmt::{self, Debug};
use sys_common::wtf8::{Wtf8, Wtf8Buf};
use string::{String, CowString};
use string::String;
use result::Result;
use option::Option;
use mem;
@ -70,7 +71,7 @@ impl Slice {
self.inner.as_str()
}
pub fn to_string_lossy(&self) -> CowString {
pub fn to_string_lossy(&self) -> Cow<str> {
self.inner.to_string_lossy()
}

View File

@ -277,7 +277,7 @@ impl Builder {
// address at which our stack started).
let main = move || {
let something_around_the_top_of_the_stack = 1;
let addr = &something_around_the_top_of_the_stack as *const isize;
let addr = &something_around_the_top_of_the_stack as *const i32;
let my_stack_top = addr as usize;
let my_stack_bottom = my_stack_top - stack_size + 1024;
unsafe {
@ -802,13 +802,13 @@ mod test {
}
fn avoid_copying_the_body<F>(spawnfn: F) where F: FnOnce(Thunk<'static>) {
let (tx, rx) = channel::<u32>();
let (tx, rx) = channel();
let x = box 1;
let x_in_parent = (&*x) as *const isize as u32;
let x_in_parent = (&*x) as *const i32 as usize;
spawnfn(Thunk::new(move|| {
let x_in_child = (&*x) as *const isize as u32;
let x_in_child = (&*x) as *const i32 as usize;
tx.send(x_in_child).unwrap();
}));
@ -847,8 +847,8 @@ mod test {
// climbing the task tree to dereference each ancestor. (See #1789)
// (well, it would if the constant were 8000+ - I lowered it to be more
// valgrind-friendly. try this at home, instead..!)
static GENERATIONS: usize = 16;
fn child_no(x: usize) -> Thunk<'static> {
const GENERATIONS: u32 = 16;
fn child_no(x: u32) -> Thunk<'static> {
return Thunk::new(move|| {
if x < GENERATIONS {
thread::spawn(move|| child_no(x+1).invoke(()));

View File

@ -119,7 +119,7 @@ macro_rules! __scoped_thread_local_inner {
const _INIT: __Key<$t> = __Key {
inner: ::std::thread_local::scoped::__impl::KeyInner {
inner: ::std::thread_local::scoped::__impl::OS_INIT,
marker: ::std::marker::InvariantType,
marker: ::std::marker::PhantomData::<::std::cell::Cell<$t>>,
}
};
@ -244,12 +244,13 @@ mod imp {
target_arch = "aarch64"))]
mod imp {
use marker;
use std::cell::Cell;
use sys_common::thread_local::StaticKey as OsStaticKey;
#[doc(hidden)]
pub struct KeyInner<T> {
pub inner: OsStaticKey,
pub marker: marker::InvariantType<T>,
pub marker: marker::PhantomData<Cell<T>>,
}
unsafe impl<T> ::marker::Sync for KeyInner<T> { }

View File

@ -77,11 +77,11 @@ pub enum AbiArchitecture {
}
#[allow(non_upper_case_globals)]
static AbiDatas: &'static [AbiData] = &[
const AbiDatas: &'static [AbiData] = &[
// Platform-specific ABIs
AbiData {abi: Cdecl, name: "cdecl" },
AbiData {abi: Stdcall, name: "stdcall" },
AbiData {abi: Fastcall, name:"fastcall" },
AbiData {abi: Fastcall, name: "fastcall" },
AbiData {abi: Aapcs, name: "aapcs" },
AbiData {abi: Win64, name: "win64" },

View File

@ -25,7 +25,7 @@ use term::WriterWrapper;
use term;
/// maximum number of lines we will print for each error; arbitrary.
static MAX_LINES: usize = 6;
const MAX_LINES: usize = 6;
#[derive(Clone, Copy)]
pub enum RenderSpan {

View File

@ -45,7 +45,7 @@ impl State {
}
}
static OPTIONS: &'static [&'static str] = &["volatile", "alignstack", "intel"];
const OPTIONS: &'static [&'static str] = &["volatile", "alignstack", "intel"];
pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
-> Box<base::MacResult+'cx> {

View File

@ -45,7 +45,7 @@ use std::ascii::AsciiExt;
// stable (active).
// NB: The featureck.py script parses this information directly out of the source
// so take care when modifying it.
static KNOWN_FEATURES: &'static [(&'static str, &'static str, Status)] = &[
const KNOWN_FEATURES: &'static [(&'static str, &'static str, Status)] = &[
("globs", "1.0.0", Accepted),
("macro_rules", "1.0.0", Accepted),
("struct_variant", "1.0.0", Accepted),
@ -139,6 +139,9 @@ static KNOWN_FEATURES: &'static [(&'static str, &'static str, Status)] = &[
// Allows the use of rustc_* attributes; RFC 572
("rustc_attrs", "1.0.0", Active),
// Allows the use of `static_assert`
("static_assert", "1.0.0", Active),
];
// (changing above list without updating src/doc/reference.md makes @cmr sad)
@ -159,7 +162,7 @@ enum Status {
}
// Attributes that have a special meaning to rustc or rustdoc
pub static KNOWN_ATTRIBUTES: &'static [(&'static str, AttributeType)] = &[
pub const KNOWN_ATTRIBUTES: &'static [(&'static str, AttributeType)] = &[
// Normal attributes
("warn", Normal),
@ -242,7 +245,8 @@ pub static KNOWN_ATTRIBUTES: &'static [(&'static str, AttributeType)] = &[
("no_split_stack", Whitelisted),
("no_stack_check", Whitelisted),
("packed", Whitelisted),
("static_assert", Whitelisted),
("static_assert", Gated("static_assert",
"`#[static_assert]` is an experimental feature, and has a poor API")),
("no_debug", Whitelisted),
("omit_gdb_pretty_printer_section", Whitelisted),
("unsafe_no_drop_flag", Gated("unsafe_no_drop_flag",
@ -770,4 +774,3 @@ pub fn check_crate(cm: &CodeMap, span_handler: &SpanHandler, krate: &ast::Crate)
|ctx, krate| visit::walk_crate(&mut PostExpansionVisitor { context: ctx },
krate))
}

View File

@ -124,8 +124,8 @@ pub fn strip_doc_comment_decoration(comment: &str) -> String {
}
// one-line comments lose their prefix
static ONLINERS: &'static [&'static str] = &["///!", "///", "//!", "//"];
for prefix in ONLINERS {
const ONELINERS: &'static [&'static str] = &["///!", "///", "//!", "//"];
for prefix in ONELINERS {
if comment.starts_with(*prefix) {
return (&comment[prefix.len()..]).to_string();
}

View File

@ -425,10 +425,10 @@ macro_rules! declare_special_idents_and_keywords {(
$( ($rk_name:expr, $rk_variant:ident, $rk_str:expr); )*
}
) => {
static STRICT_KEYWORD_START: ast::Name = first!($( ast::Name($sk_name), )*);
static STRICT_KEYWORD_FINAL: ast::Name = last!($( ast::Name($sk_name), )*);
static RESERVED_KEYWORD_START: ast::Name = first!($( ast::Name($rk_name), )*);
static RESERVED_KEYWORD_FINAL: ast::Name = last!($( ast::Name($rk_name), )*);
const STRICT_KEYWORD_START: ast::Name = first!($( ast::Name($sk_name), )*);
const STRICT_KEYWORD_FINAL: ast::Name = last!($( ast::Name($sk_name), )*);
const RESERVED_KEYWORD_START: ast::Name = first!($( ast::Name($rk_name), )*);
const RESERVED_KEYWORD_FINAL: ast::Name = last!($( ast::Name($rk_name), )*);
pub mod special_idents {
use ast;

View File

@ -159,7 +159,7 @@ pub struct PrintStackElem {
pbreak: PrintStackBreak
}
static SIZE_INFINITY: isize = 0xffff;
const SIZE_INFINITY: isize = 0xffff;
pub fn mk_printer(out: Box<old_io::Writer+'static>, linewidth: usize) -> Printer {
// Yes 3, it makes the ring buffers big enough to never

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,43 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// force-host
#![feature(plugin_registrar)]
#![feature(box_syntax)]
extern crate syntax;
#[macro_use] extern crate rustc;
use syntax::{ast, attr};
use rustc::lint::{Context, LintPass, LintPassObject, LintArray};
use rustc::plugin::Registry;
declare_lint!(CRATE_NOT_OKAY, Warn, "crate not marked with #![crate_okay]");
struct Pass;
impl LintPass for Pass {
fn get_lints(&self) -> LintArray {
lint_array!(CRATE_NOT_OKAY)
}
fn check_crate(&mut self, cx: &Context, krate: &ast::Crate) {
if !attr::contains_name(&krate.attrs, "crate_okay") {
cx.span_lint(CRATE_NOT_OKAY, krate.span,
"crate is not marked with #![crate_okay]");
}
}
}
#[plugin_registrar]
pub fn plugin_registrar(reg: &mut Registry) {
reg.register_lint_pass(box Pass as LintPassObject);
}

View File

@ -0,0 +1,18 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// aux-build:lint_for_crate.rs
// ignore-stage1
// compile-flags: -D crate-not-okay
#![feature(plugin, custom_attribute)] //~ ERROR crate is not marked with #![crate_okay]
#![plugin(lint_for_crate)]
pub fn main() { }

View File

@ -10,13 +10,14 @@
// ignore-android
#![feature(asm)]
#![feature(asm, rustc_attrs)]
#![allow(dead_code, non_upper_case_globals)]
#[cfg(any(target_arch = "x86",
target_arch = "x86_64"))]
pub fn main() {
#[rustc_error]
pub fn main() { //~ ERROR compilation successful
// assignment not dead
let mut x: isize = 0;
unsafe {
@ -33,7 +34,3 @@ pub fn main() {
}
assert_eq!(x, 13);
}
// At least one error is needed so that compilation fails
#[static_assert]
static b: bool = false; //~ ERROR static assertion failed

View File

@ -0,0 +1,14 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[static_assert] //~ ERROR `#[static_assert]` is an experimental feature
static X: bool = true;
fn main() {}

View File

@ -9,6 +9,7 @@
// except according to those terms.
// error-pattern: too big for the current
#![allow(exceeding_bitshifts)]
fn main() {
let fat : [u8; (1<<61)+(1<<31)] = [0; (1u64<<61) as usize +(1u64<<31) as usize];

View File

@ -0,0 +1,41 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
pub struct PublicType;
struct PrivateType;
pub trait PublicTrait {
type Item;
}
trait PrivateTrait {
type Item;
}
impl PublicTrait for PublicType {
type Item = PrivateType; //~ ERROR private type in exported type signature
}
// OK
impl PublicTrait for PrivateType {
type Item = PrivateType;
}
// OK
impl PrivateTrait for PublicType {
type Item = PrivateType;
}
// OK
impl PrivateTrait for PrivateType {
type Item = PrivateType;
}
fn main() {}

View File

@ -8,13 +8,15 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(rustc_attrs)]
#![allow(dead_code)]
// Matching against NaN should result in a warning
use std::f64::NAN;
fn main() {
#[rustc_error]
fn main() { //~ ERROR compilation successful
let x = NAN;
match x {
NAN => {},
@ -27,7 +29,3 @@ fn main() {
};
//~^^^ WARNING unmatchable NaN in pattern, use the is_nan method in a guard instead
}
// At least one error is needed so that compilation fails
#[static_assert]
static B: bool = false; //~ ERROR static assertion failed

View File

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(static_assert)]
#![allow(dead_code)]
#[static_assert]

View File

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(static_assert)]
#![allow(dead_code)]
#[static_assert]

View File

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(static_assert)]
#![allow(dead_code)]
#[static_assert]

View File

@ -0,0 +1,19 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// aux-build:lint_for_crate.rs
// ignore-stage1
// compile-flags: -D crate-not-okay
#![feature(plugin, custom_attribute)]
#![plugin(lint_for_crate)]
#![crate_okay]
pub fn main() { }

View File

@ -16,7 +16,7 @@ pub trait Foo {
}
#[derive(PartialEq)]
struct Bar;
pub struct Bar;
impl Foo for int {
type A = uint;

View File

@ -15,7 +15,7 @@ pub trait Foo {
fn boo(&self) -> <Self as Foo>::A;
}
struct Bar;
pub struct Bar;
impl Foo for char {
type A = Bar;

View File

@ -16,7 +16,7 @@ pub trait Foo {
}
#[derive(PartialEq)]
struct Bar;
pub struct Bar;
impl Foo for int {
type A = uint;

View File

@ -53,7 +53,9 @@ fn runtest(me: &str) {
"bad output: {}", s);
// Make sure the stack trace is *not* printed
let p = template.clone().arg("fail").spawn().unwrap();
// (Remove RUST_BACKTRACE from our own environment, in case developer
// is running `make check` with it on.)
let p = template.clone().arg("fail").env_remove("RUST_BACKTRACE").spawn().unwrap();
let out = p.wait_with_output().unwrap();
assert!(!out.status.success());
let s = str::from_utf8(&out.error).unwrap();

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(static_assert)]
#[static_assert]
static b: bool = true;