Use consts instead of statics where appropriate

This changes the type of some public constants/statics in libunicode.
Notably some `&'static &'static [(char, char)]` have changed
to `&'static [(char, char)]`. The regexp crate seems to be the
sole user of these, yet this is technically a [breaking-change]
This commit is contained in:
Florian Zeitz 2015-02-27 15:36:53 +01:00
parent 1cc8b6ec66
commit f35f973cb7
53 changed files with 414 additions and 419 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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -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

@ -856,9 +856,9 @@ pub mod writer {
// Set to true to generate more debugging in EBML code.
// Totally lame approach.
#[cfg(not(ndebug))]
static DEBUG: bool = true;
const DEBUG: bool = true;
#[cfg(ndebug)]
static DEBUG: bool = false;
const DEBUG: bool = false;
impl<'a, W: Writer + Seek> Encoder<'a, W> {
// used internally to emit things like the vector length and so on

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

@ -5757,22 +5757,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 {
@ -5811,8 +5811,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

@ -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;

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

@ -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

@ -43,7 +43,7 @@ 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.
///

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

@ -853,7 +853,7 @@ 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;
const GENERATIONS: usize = 16;
fn child_no(x: usize) -> Thunk<'static> {
return Thunk::new(move|| {
if x < GENERATIONS {

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),
@ -159,7 +159,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),

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